From e0d5b6b10a45444381cce917542b229a7ca2ac2f Mon Sep 17 00:00:00 2001 From: Tim Worrall Date: Mon, 23 Jun 2014 12:38:48 -0400 Subject: [PATCH] VIVO-201: removed some java script redundancies --- ...rIndividual.js => manageHideShowStatus.js} | 32 +++---- .../forms/js/managePeopleForOrganization.js | 86 ------------------- .../js/managePublicationsForIndividual.js | 86 ------------------- .../edit/forms/manageGrantsForIndividual.ftl | 14 +-- .../forms/managePeopleForOrganization.ftl | 14 +-- .../forms/managePublicationsForIndividual.ftl | 14 +-- 6 files changed, 37 insertions(+), 209 deletions(-) rename productMods/templates/freemarker/edit/forms/js/{manageGrantsForIndividual.js => manageHideShowStatus.js} (63%) delete mode 100644 productMods/templates/freemarker/edit/forms/js/managePeopleForOrganization.js delete mode 100644 productMods/templates/freemarker/edit/forms/js/managePublicationsForIndividual.js diff --git a/productMods/templates/freemarker/edit/forms/js/manageGrantsForIndividual.js b/productMods/templates/freemarker/edit/forms/js/manageHideShowStatus.js similarity index 63% rename from productMods/templates/freemarker/edit/forms/js/manageGrantsForIndividual.js rename to productMods/templates/freemarker/edit/forms/js/manageHideShowStatus.js index 36eb16e8..fac2d15b 100644 --- a/productMods/templates/freemarker/edit/forms/js/manageGrantsForIndividual.js +++ b/productMods/templates/freemarker/edit/forms/js/manageHideShowStatus.js @@ -1,6 +1,6 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ -var manageGrants = { +var manageHideShowStatus = { /* *** Initial page setup *** */ @@ -20,7 +20,7 @@ var manageGrants = { // Initial page setup. Called only at page load. initPage: function() { - this.initGrantData(); + this.initItemData(); this.bindEventListeners(); @@ -29,28 +29,28 @@ var manageGrants = { // On page load, associate data with each list item. Then we don't // have to keep retrieving data from or modifying the DOM as we manipulate the // items. - initGrantData: function() { - $('.grantCheckbox').each(function(index) { - $(this).data(grantData[index]); + initItemData: function() { + $('.itemCheckbox').each(function(index) { + $(this).data(itemData[index]); }); }, bindEventListeners: function() { - $('.grantCheckbox').click(function() { - manageGrants.processGrant(this); + $('.itemCheckbox').click(function() { + manageHideShowStatus.processItem(this); //return false; }); }, - processGrant: function(grant) { + processItem: function(item) { var add = ""; var retract = ""; - var n3String = "<" + $(grant).data('roleUri') + "> \"true\" ." ; + var n3String = "<" + $(item).data('relatedUri') + "> \"true\" ." ; - if ( $(grant).is(':checked') ) { + if ( $(item).is(':checked') ) { add = n3String; } else { @@ -58,22 +58,22 @@ var manageGrants = { } $.ajax({ - url: manageGrants.processingUrl, + url: manageHideShowStatus.processingUrl, type: 'POST', data: { additions: add, retractions: retract }, dataType: 'json', - context: grant, // context for callback + context: item, // context for callback complete: function(request, status) { if (status === 'success') { - window.status = manageGrants.grantSuccessfullyExcluded; + window.status = manageHideShowStatus.itemSuccessfullyExcluded; } else { - alert(manageGrants.errorExcludingGrant); - $(grant).removeAttr('checked'); + alert(manageHideShowStatus.errorExcludingItem); + $(item).removeAttr('checked'); } } }); @@ -82,5 +82,5 @@ var manageGrants = { }; $(document).ready(function() { - manageGrants.onLoad(); + manageHideShowStatus.onLoad(); }); diff --git a/productMods/templates/freemarker/edit/forms/js/managePeopleForOrganization.js b/productMods/templates/freemarker/edit/forms/js/managePeopleForOrganization.js deleted file mode 100644 index 672ee820..00000000 --- a/productMods/templates/freemarker/edit/forms/js/managePeopleForOrganization.js +++ /dev/null @@ -1,86 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -var managePeople = { - - /* *** Initial page setup *** */ - - onLoad: function() { - - this.mixIn(); - this.initPage(); - }, - - mixIn: function() { - - // Get the custom form data from the page - $.extend(this, customFormData); - $.extend(this, i18nStrings); - }, - - // Initial page setup. Called only at page load. - initPage: function() { - - this.initPeopleData(); - - this.bindEventListeners(); - - }, - - // On page load, associate data with each list item. Then we don't - // have to keep retrieving data from or modifying the DOM as we manipulate the - // items. - initPeopleData: function() { - $('.pubCheckbox').each(function(index) { - $(this).data(peopleData[index]); - }); - }, - - bindEventListeners: function() { - - $('.pubCheckbox').click(function() { - managePeople.processPeople(this); - //return false; - }); - - }, - - processPeople: function(person) { - - var add = ""; - var retract = ""; - var n3String = "<" + $(person).data('positionUri') + "> \"true\" ." ; - - if ( $(person).is(':checked') ) { - add = n3String; - } - else { - retract = n3String; - } - - $.ajax({ - url: managePeople.processingUrl, - type: 'POST', - data: { - additions: add, - retractions: retract - }, - dataType: 'json', - context: person, // context for callback - complete: function(request, status) { - - if (status === 'success') { - window.status = managePeople.personSuccessfullyExcluded; - - } else { - alert(managePeople.errorExcludingPerson); - $(person).removeAttr('checked'); - } - } - }); - }, - -}; - -$(document).ready(function() { - managePeople.onLoad(); -}); diff --git a/productMods/templates/freemarker/edit/forms/js/managePublicationsForIndividual.js b/productMods/templates/freemarker/edit/forms/js/managePublicationsForIndividual.js deleted file mode 100644 index 5d39f2e9..00000000 --- a/productMods/templates/freemarker/edit/forms/js/managePublicationsForIndividual.js +++ /dev/null @@ -1,86 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -var managePublications = { - - /* *** Initial page setup *** */ - - onLoad: function() { - - this.mixIn(); - this.initPage(); - }, - - mixIn: function() { - - // Get the custom form data from the page - $.extend(this, customFormData); - $.extend(this, i18nStrings); - }, - - // Initial page setup. Called only at page load. - initPage: function() { - - this.initPublicationData(); - - this.bindEventListeners(); - - }, - - // On page load, associate data with each list item. Then we don't - // have to keep retrieving data from or modifying the DOM as we manipulate the - // items. - initPublicationData: function() { - $('.pubCheckbox').each(function(index) { - $(this).data(publicationData[index]); - }); - }, - - bindEventListeners: function() { - - $('.pubCheckbox').click(function() { - managePublications.processPublication(this); - //return false; - }); - - }, - - processPublication: function(publication) { - - var add = ""; - var retract = ""; - var n3String = "<" + $(publication).data('authorshipUri') + "> \"true\" ." ; - - if ( $(publication).is(':checked') ) { - add = n3String; - } - else { - retract = n3String; - } - - $.ajax({ - url: managePublications.processingUrl, - type: 'POST', - data: { - additions: add, - retractions: retract - }, - dataType: 'json', - context: publication, // context for callback - complete: function(request, status) { - - if (status === 'success') { - window.status = managePublications.publicationSuccessfullyExcluded; - - } else { - alert(managePublications.errorExcludingPublication); - $(publication).removeAttr('checked'); - } - } - }); - }, - -}; - -$(document).ready(function() { - managePublications.onLoad(); -}); diff --git a/productMods/templates/freemarker/edit/forms/manageGrantsForIndividual.ftl b/productMods/templates/freemarker/edit/forms/manageGrantsForIndividual.ftl index 7bb30d3f..97787a1e 100644 --- a/productMods/templates/freemarker/edit/forms/manageGrantsForIndividual.ftl +++ b/productMods/templates/freemarker/edit/forms/manageGrantsForIndividual.ftl @@ -13,7 +13,7 @@

${i18n().check_grants_to_exclude}

<@lvf.unsupportedBrowser urls.base /> @@ -25,11 +25,11 @@ ${i18n().check_grants_to_exclude}
    <#list grantList as grant>
  • - checked />${grant.label!grant.activity!} + checked />${grant.label!grant.activity!}
  • @@ -48,8 +48,8 @@ var customFormData = { processingUrl: '${urls.base}/edit/primitiveRdfEdit' }; var i18nStrings = { - grantSuccessfullyExcluded: '${i18n().grant_successfully_excluded}', - errorExcludingGrant: '${i18n().error_excluding_grant}' + itemSuccessfullyExcluded: '${i18n().grant_successfully_excluded}', + errorExcludingItem: '${i18n().error_excluding_grant}' }; @@ -59,5 +59,5 @@ ${stylesheets.add('', '', '', - '')} + '')} diff --git a/productMods/templates/freemarker/edit/forms/managePeopleForOrganization.ftl b/productMods/templates/freemarker/edit/forms/managePeopleForOrganization.ftl index e02dd101..6e55598e 100644 --- a/productMods/templates/freemarker/edit/forms/managePeopleForOrganization.ftl +++ b/productMods/templates/freemarker/edit/forms/managePeopleForOrganization.ftl @@ -7,7 +7,7 @@

    ${i18n().check_people_to_exclude}

    @@ -21,11 +21,11 @@ ${i18n().check_people_to_exclude}
      <#list peeps as person>
    • - checked />${person.name} + checked />${person.name}
    • @@ -44,8 +44,8 @@ var customFormData = { processingUrl: '${urls.base}/edit/primitiveRdfEdit' }; var i18nStrings = { - personSuccessfullyExcluded: '${i18n().person_successfully_excluded}', - errorExcludingPerson: '${i18n().error_excluding_person}' + itemSuccessfullyExcluded: '${i18n().person_successfully_excluded}', + errorExcludingItem: '${i18n().error_excluding_person}' }; @@ -55,5 +55,5 @@ ${stylesheets.add('', '', '', - '')} + '')} diff --git a/productMods/templates/freemarker/edit/forms/managePublicationsForIndividual.ftl b/productMods/templates/freemarker/edit/forms/managePublicationsForIndividual.ftl index bc188ef9..e1c8b036 100644 --- a/productMods/templates/freemarker/edit/forms/managePublicationsForIndividual.ftl +++ b/productMods/templates/freemarker/edit/forms/managePublicationsForIndividual.ftl @@ -13,7 +13,7 @@

      ${i18n().check_pubs_to_exclude}

      @@ -37,12 +37,12 @@ ${i18n().check_pubs_to_exclude}
        <#list pubs as pub>
      • - checked /> + checked /> <#if pub.title?has_content>${pub.title!}<#else>${i18n().title_not_found}
      • @@ -61,8 +61,8 @@ var customFormData = { processingUrl: '${urls.base}/edit/primitiveRdfEdit' }; var i18nStrings = { - publicationSuccessfullyExcluded: '${i18n().publication_successfully_excluded}', - errorExcludingPublication: '${i18n().error_excluding_publication}' + itemSuccessfullyExcluded: '${i18n().publication_successfully_excluded}', + errorExcludingItem: '${i18n().error_excluding_publication}' }; @@ -72,5 +72,5 @@ ${stylesheets.add('', '', '', - '')} + '')}