/* $This file is distributed under the terms of the license in /doc/license.txt$ */ $(document).ready(function(){ // ensures proper layout when an organization has its webpage link displayed as a thumnail. // there's a timing issue, so we can't check the length here, so check the role just to see // if $('ul.webpages-withThumnails') exists if ( $('ul.webpages-withThumbnails').children('li').length > 0 ) { $('div.individual-overview').css("float","left"); $('div#activeGrantsLink').css("margin-top","30px"); $('section#individual-info').children('h2#overview').css("clear","both"); } $.extend(this, i18nStrings); // "more"/"less" HTML truncator for showing more or less content in data property core:overview $('.overview-value').truncate({max_length: 500}); $.fn.exists = function () { return this.length !== 0; } $.fn.moreLess = function () { $(this).each } var togglePropDisplay = { showMore: function($toggleLink, $itemContainer) { $toggleLink.click(function() { $itemContainer.show(); $(this).attr('href', '#show less content'); $(this).text(i18nStrings.displayLess); togglePropDisplay.showLess($toggleLink, $itemContainer); return false; }); }, showLess: function($toggleLink, $itemContainer) { $toggleLink.click(function() { $itemContainer.hide(); $(this).attr('href', '#show more content'); $(this).text(i18nStrings.displayMoreEllipsis); togglePropDisplay.showMore($toggleLink, $itemContainer); return false; }); } }; // var $propList = $('.property-list').not('>li>ul'); var $propList = $('.property-list:not(:has(>li>ul))'); $propList.each(function() { var $additionalItems = $(this).find('li:gt(4)'); if ( $additionalItems.exists() ) { // create container for additional elements var $itemContainer = $('
').appendTo(this); // create toggle link var $toggleLink = $('' + i18nStrings.displayMoreEllipsis + '').appendTo(this); $additionalItems.appendTo($itemContainer); $itemContainer.hide(); togglePropDisplay.showMore($toggleLink, $itemContainer); } }); var $subPropList = $('.subclass-property-list'); $subPropList.each(function() { var $additionalItems = $(this).find('li:gt(4)'); if ( $additionalItems.exists() ) { // create container for additional elements var $itemContainer = $('').appendTo(this); // create toggle link var $toggleLink = $('' + i18nStrings.displayMoreEllipsis + '').appendTo(this); $additionalItems.appendTo($itemContainer); $itemContainer.hide(); togglePropDisplay.showMore($toggleLink, $itemContainer); } }); var $subPropSibs = $subPropList.closest('li').last().nextAll(); var $subPropParent = $subPropList.closest('li').last().parent(); var $additionalItems = $subPropSibs.slice(3); if ( $additionalItems.length > 0 ) { // create container for additional elements var $itemContainer = $('').appendTo($subPropParent); // create toggle link var $toggleLink = $('' + i18nStrings.displayMoreEllipsis + '').appendTo($subPropParent); $additionalItems.appendTo($itemContainer); $itemContainer.hide(); togglePropDisplay.showMore($toggleLink, $itemContainer); } // Change background color button when verbose mode is off $('a#verbosePropertySwitch:contains("' + i18nStrings.verboseTurnOff + '")').addClass('verbose-off'); // Reveal vCard QR code when QR icon is clicked $('#qrIcon, .qrCloseLink').click(function() { // only create the img the first time, so check if it already exists if ( !$('img#codeImage').length ) { $.ajax({ url: baseUrl + "/qrCodeAjax", dataType: "json", data: { action: "getQrCodeDetails", uri: individualUri, }, complete: function(xhr, status) { var results = $.parseJSON(xhr.responseText); if ( results.length == 0 ) { var html = i18nStrings.currentlyNoResearchers; } else { if ( results[0].firstName.length < 1 || results[1].lastName.length < 1 ) { $('#qrCodeImage').css("width","225px"); var noCodeStr = "