Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upstream from ub-heidelberg #4

Merged
merged 5 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,412 changes: 1,123 additions & 289 deletions DataciteExportPlugin.inc.php

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#### OMPDatacite and DA|RA Plugin

*For OMP Version 3.1.2*

#### Introduction
This plugin registers DOIS for monographs and chapters for DOI provider [Datacite.org](https://datacite.org).

Expand Down
2 changes: 2 additions & 0 deletions README_DE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
##### OMPDatacite and DA|RA Plugin

*Für OMP Version 3.1.2*

###### Einleitung
Dieses Plugin registriert DOIS für Mongraphen, Sammelbände und Kapitel für den DOI-Anbieter [Datacite.org](https://datacite.org).

Expand Down
35 changes: 0 additions & 35 deletions controllers/grid/DataciteQueuedListHandler.inc.php

This file was deleted.

88 changes: 88 additions & 0 deletions css/datacite-content.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
.datacite-table
{
table-layout : fixed;
}

.datacite-ellipsis
{
display : block;
overflow-x : hidden;
text-overflow : ellipsis;
white-space : nowrap;
}

.datacite-authors
{
font-weight : bolder;
}

.datacite-break-word
{
word-wrap : break-word;
}

input[type="checkbox"]:disabled
{
cursor: not-allowed;
}

.gridItemsPerPage label
{
font-size: 14px;
font-weight: 400;
}

.datacite-show-row
{
display: table-row;
}

.datacite-hide
{
display: none;
}

.datacite-hidden
{
visibility: hidden;
}

.datacite-nav-button
{
padding: 7px 16px;
vertical-align: middle;
background-color: #eee;
background-image: linear-gradient(#eee, #ddd);
border: 1px solid #ccc;
border-radius: 2px;
box-shadow: 0 1px 2px rgba(0,0,0,0.1),inset 0 1px 1px rgba(255,255,255,0.6);
font-size: 12px;
font-weight: 700;
line-height: 16px;
color: rgba(0,0,0,0.84);
text-shadow: 0 2px 0 rgba(255,255,255,0.6);
cursor: pointer;
text-decoration: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-appearance: none;
}

#pageId
{
background-color: #009de5;
background-image: linear-gradient(#19b7ff, #006999);
color: #fff;
box-shadow: 0 1px 2px rgba(0,0,0,0.1),inset 0 1px 1px rgba(255,255,255,0.4);
text-shadow: 0 2px 0 rgba(0,0,0,0.2);
border-color: #007ab2;
}

body.waiting,
body.waiting a:hover,
body.waiting *
{
cursor: wait !important;
}
228 changes: 228 additions & 0 deletions js/datacite-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
let paginationButtons, selectItemsPerPage, mainForm, grid, itemsCount, csrfToken;

function changeDatacitePagination(page = 1, itemsPerPage = 10) {
let firstItem = (page * itemsPerPage) - itemsPerPage;
let lastItem = firstItem + itemsPerPage - 1;
let startPageText = 0;
let endPageText;
let endPage = $('#datacite-page-end');

if( itemsCount > 0 )
{
startPageText = firstItem + 1;
}

for (let i = 0; i < itemsCount; i++) {
let row = $('#datacitelistgrid-row-' + i)
if (i < firstItem || i > lastItem) {
row.removeClass('datacite-show-row');
row.addClass('datacite-hide');
} else {
row.removeClass('datacite-hide');
row.addClass('datacite-show-row');
}
}

startPageText = startPageText.toString();
$('#datacite-page-start').text(startPageText);
if (lastItem > itemsCount) {
endPage.text( String(itemsCount) );
} else {
endPageText = (lastItem + 1).toString();
endPage.text(endPageText);
}
}

function changeDatacitePaginationButton(currentPage = 1) {
let itemsPerPage = parseInt(selectItemsPerPage.val());
let totalPages = 1;
let pageMinus2 = $('#pageId-2');
let pageMinus1 = $('#pageId-1');
let pagePlus1 = $('#pageIdPlus1');
let pagePlus2 = $('#pageIdPlus2');

if( itemsCount > 0 )
{
totalPages = Math.ceil(itemsCount / itemsPerPage);
}

$('#pageId').val(currentPage.toString());
pageMinus2.val((currentPage - 2).toString());
pageMinus1.val((currentPage - 1).toString());
pagePlus1.val((currentPage + 1).toString());
pagePlus2.val((currentPage + 2).toString());
paginationButtons.removeClass('datacite-hide');

if (currentPage === 1) {
$('#firstPageId').addClass('datacite-hide');
$('#prevPageId').addClass('datacite-hide');
pageMinus2.addClass('datacite-hide');
pageMinus1.addClass('datacite-hide');
}

if (currentPage === totalPages) {
$('#lastPageId').addClass('datacite-hide');
$('#nextPageId').addClass('datacite-hide');
pagePlus2.addClass('datacite-hide');
pagePlus1.addClass('datacite-hide');
}

if (currentPage === totalPages - 1) {
pagePlus2.addClass('datacite-hide');
}

if (currentPage === 2) {
pageMinus2.addClass('datacite-hide');
}
}

function bindCollapseButtonClick() {
$('td.first_column > a').click( function () {
let classList = $(this).attr('class').split(/\s+/);
let itemId = '';
$.each( classList, function (index, item) {
if( item.toLowerCase().indexOf( 'dropdown-' ) >= 0 ) {
itemId = item.replace( 'dropdown-', '' );
return false;
}
});

if( itemId !== '' ) {
let collapseTable = $('#datacitelistgrid-row-' + itemId + '-control-row');
if ($(this).hasClass( 'show_extras' )) {
$(this).addClass( 'hide_extras' );
$(this).removeClass( 'show_extras' )
collapseTable.css('display', 'table-row');
}
else {
$(this).addClass( 'show_extras' );
$(this).removeClass( 'hide_extras' )
collapseTable.css('display', 'none');
}
}
});
}

function closeAllChapterTables() {
$('a.hide_extras').each(function () {
$(this).click();
});
}

$(document).ready(function () {
paginationButtons = $('.datacite-nav-button');
selectItemsPerPage = $('#selItemsPerPage');
mainForm = $('#queueXmlForm');
grid = $('#datacitelistgrid');
itemsCount = $('#datacitelistgrid-table > tbody > tr').length / 2;

bindCollapseButtonClick();
grid.pkpHandler(
'$.pkp.controllers.grid.GridHandler',
{
bodySelector: '#datacitelistgrid-table',
});

$('body').on('change','.submissionCheckbox',function(){
let itemId = $(this).val();
let collapseTable = $('#datacitelistgrid-row-' + itemId + '-control-row')
if (this.checked) {
$('input.select-chapter-' + itemId).each(function () {
$(this).prop('checked', true);
});
} else {
$('input.select-chapter-' + itemId).each(function () {
$(this).prop('checked', false);
});
}
if (collapseTable.is(':hidden')) {
$('.dropdown-' + itemId).trigger('click');
}
});

$('#datacite-search-button').click(function () {
$('body').addClass('waiting');
$.ajax({
type: 'POST',
dataType: "html",
data: {
'csrfToken':$('input[name ="csrfToken"]').val(),
'isAjax':true,
'sel-search-type':$('#sel-search-type').val(),
'search-text':$('#search-text').val(),
'sel-search-status':$('#sel-search-status').val()
},
success: function (data) {
$('#datacitelistgrid-table > tbody').html(data);
if( data !== '' ) {
itemsCount = $('#datacitelistgrid-table > tbody > tr').length / 2;
}
else
{
itemsCount = 0;
}
$('#datacite-page-count-items').html( itemsCount );
closeAllChapterTables();
changeDatacitePaginationButton();
changeDatacitePagination(1, parseInt( $('#selItemsPerPage').val() ) );
bindCollapseButtonClick();
$('body').removeClass('waiting');
},
error: function(jqXHR, textStatus, errorThrown) {
$('body').removeClass('waiting');
alert( 'Error: Status: ' + jqXHR.status + ': ' + errorThrown);
}
});
});

paginationButtons.click(function () {
let buttonValue = $(this).val();
let itemsPerPage = parseInt(selectItemsPerPage.val());
let currentPage = parseInt($('#pageId').val());
let totalPages = Math.ceil(itemsCount / itemsPerPage);

if (buttonValue === '<<') {
buttonValue = 1;
} else if (buttonValue === '<') {
if (currentPage !== 1) {
buttonValue = currentPage - 1;
} else {
buttonValue = 1;
}

} else if (buttonValue === '>') {
if (currentPage !== totalPages) {
buttonValue = currentPage + 1;
} else {
buttonValue = totalPages;
}
} else if (buttonValue === '>>') {
buttonValue = totalPages
}

closeAllChapterTables();
changeDatacitePagination(parseInt(buttonValue), itemsPerPage);
changeDatacitePaginationButton(parseInt(buttonValue));
});

selectItemsPerPage.change(function () {

closeAllChapterTables();
let itemsPerPage = $('#selItemsPerPage').val();
changeDatacitePaginationButton();
let currentPage = $('#pageId').val();
changeDatacitePagination(parseInt(currentPage), parseInt(itemsPerPage));

});

$('#search-text').keydown(function(event) {
// noinspection JSUnresolvedVariable
if (event.keyCode === 13) {
event.preventDefault();
$('#datacite-search-button').click();
}
});

changeDatacitePaginationButton();
changeDatacitePagination();
});
Loading