From 4875fe566ec41cda5c0beef200aa61505b0c72ea Mon Sep 17 00:00:00 2001 From: Tim Worrall Date: Mon, 16 Mar 2015 11:02:05 -0400 Subject: [PATCH] VIVO-970: needed to break out the more/less javascript toggle into a separate file. --- productMods/js/individual/individualUtils.js | 86 ------------------- .../individual--foaf-person-2column.ftl | 1 + .../individual--foaf-person-quickview.ftl | 1 + .../templates/individual--foaf-person.ftl | 1 + 4 files changed, 3 insertions(+), 86 deletions(-) diff --git a/productMods/js/individual/individualUtils.js b/productMods/js/individual/individualUtils.js index 31658fc7..4da10242 100644 --- a/productMods/js/individual/individualUtils.js +++ b/productMods/js/individual/individualUtils.js @@ -14,93 +14,7 @@ $(document).ready(function(){ // "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 limit = $(this).attr("displayLimit"); - var $additionalItems = $(this).find('li:gt(' + (limit - 1) + ')'); - 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 limit = $(this).parent().parent().attr("displayLimit"); - var $additionalItems = $(this).find('li:gt(' + (limit - 1) + ')'); - 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'); diff --git a/productMods/templates/freemarker/body/individual/individual--foaf-person-2column.ftl b/productMods/templates/freemarker/body/individual/individual--foaf-person-2column.ftl index b078c739..261512c7 100644 --- a/productMods/templates/freemarker/body/individual/individual--foaf-person-2column.ftl +++ b/productMods/templates/freemarker/body/individual/individual--foaf-person-2column.ftl @@ -201,5 +201,6 @@ ${scripts.add('', '', '', + '', '', '')} diff --git a/productMods/templates/freemarker/body/individual/individual--foaf-person-quickview.ftl b/productMods/templates/freemarker/body/individual/individual--foaf-person-quickview.ftl index 7f92e23e..1b55df8c 100644 --- a/productMods/templates/freemarker/body/individual/individual--foaf-person-quickview.ftl +++ b/productMods/templates/freemarker/body/individual/individual--foaf-person-quickview.ftl @@ -262,5 +262,6 @@ ${scripts.add('', '', '', + '', '', '')} diff --git a/themes/wilma/templates/individual--foaf-person.ftl b/themes/wilma/templates/individual--foaf-person.ftl index 53576623..32c366b7 100644 --- a/themes/wilma/templates/individual--foaf-person.ftl +++ b/themes/wilma/templates/individual--foaf-person.ftl @@ -172,5 +172,6 @@ ${headScripts.add('', '', '', + '', '', '')}