/*
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
function AuthorLookup(url, authorityInput, collectionID) {
// TODO i18n
var content = $('
' +
'
' +
'' +
'
Name
' +
'' +
'' +
'
Loading...
' +
'' +
'
' +
'There\'s no one selected' +
'
' +
'
'+
'
' +
'' +
'' +
'
' +
'
' +
'' +
'
' +
'
' +
'
');
var moreButton = '';
var lessButton = '';
var button = moreButton;
var datatable = content.find("table.dttable");
datatable.dataTable({
"aoColumns": [
{
"bSortable": false,
"sWidth": "200px"
},
{
"bSortable": false,
"bSearchable": false,
"bVisible": false
}
],
"oLanguage": {
"sInfo": 'Showing _START_ to _END_ of _TOTAL_ people',
"sInfoEmpty": 'Showing 0 to 0 of 0 people',
"sInfoFiltered": '(filtered from _MAX_ total people)',
"sLengthMenu": '_MENU_ people/page',
"sZeroRecords": 'No people found'
},
"bAutoWidth": false,
"bJQueryUI": true,
"bProcessing": true,
"bSort": false,
"bPaginate": false,
"sPaginationType": "two_button",
"bServerSide": true,
"sAjaxSource": url,
"sDom": '<"H"lfr><"clearfix"t<"vcard-wrapper">><"F"ip>',
"fnInitComplete": function() {
content.find("table.dttable").show();
content.find("div.vcard-wrapper").append(content.find('.no-vcard-selected')).append(content.find('ul.vcard'));
content.dialog({
autoOpen: true,
resizable: false,
modal: false,
width: 600
});
$('.dataTables_wrapper').parent().attr('style', 'width: auto; min-height: 121px; height: auto;');
var searchFilter = $('.dataTables_filter > input');
var initialInput = "";
if (authorityInput.indexOf('value_') != -1) { // edit item
initialInput = $('textarea[name=' + authorityInput + ']').val();
} else { // submission
var lastName = $('input[name=' + authorityInput + '_last]');
if (lastName.size()) { // author input type
initialInput = (lastName.val() + " " + $('input[name=' + authorityInput + '_first]').val()).trim();
} else { // other input types
initialInput = $('input[name=' + authorityInput + ']').val();
}
}
searchFilter.val(initialInput);
setTimeout(function () {
searchFilter.trigger($.Event("keyup", { keyCode: 13 }));
},50);
},
"fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) {
return "Showing "+ iEnd + " results. "+button;
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
aData = aData[1];
var $row = $(nRow);
var authorityID = $(this).closest('.dataTables_wrapper').find('.vcard-wrapper .vcard').data('authorityID');
if (authorityID != undefined && aData['authority'] == authorityID) {
$row.addClass('current-item');
}
$row.addClass('clickable');
if(aData['insolr']=="false"){
$row.addClass("notinsolr");
}
$row.click(function() {
var $this = $(this);
$this.siblings('.current-item').removeClass('current-item');
$this.addClass('current-item');
var wrapper = $this.closest('.dataTables_wrapper').find('.vcard-wrapper');
wrapper.find('.no-vcard-selected:visible').hide();
var vcard = wrapper.find('.vcard');
vcard.data('authorityID', aData['authority']);
vcard.data('name', aData['value']);
var notDisplayed = ['insolr','value','authority'];
var predefinedOrder = ['last-name','first-name'];
var variable = vcard.find('.variable');
variable.empty();
predefinedOrder.forEach(function (entry) {
variableItem(aData, entry, variable);
});
for (var key in aData) {
if (aData.hasOwnProperty(key) && notDisplayed.indexOf(key) < 0 && predefinedOrder.indexOf(key) < 0) {
variableItem(aData, key, variable);
}
}
function variableItem(aData, key, variable) {
var label = key.replace(/-/g, ' ');
var dataString = '';
dataString += '