VIVO-201: removed some java script redundancies
This commit is contained in:
parent
488f7ce265
commit
e0d5b6b10a
6 changed files with 37 additions and 209 deletions
|
@ -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') + "> <http://vivoweb.org/ontology/core#hideFromDisplay> \"true\" ." ;
|
||||
var n3String = "<" + $(item).data('relatedUri') + "> <http://vivoweb.org/ontology/core#hideFromDisplay> \"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();
|
||||
});
|
|
@ -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') + "> <http://vivoweb.org/ontology/core#hideFromDisplay> \"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();
|
||||
});
|
|
@ -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') + "> <http://vivoweb.org/ontology/core#hideFromDisplay> \"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();
|
||||
});
|
|
@ -13,7 +13,7 @@
|
|||
<p style="margin-left:25px;margin-bottom:12px">
|
||||
${i18n().check_grants_to_exclude}
|
||||
<script type="text/javascript">
|
||||
var grantData = [];
|
||||
var itemData = [];
|
||||
</script>
|
||||
</p>
|
||||
<@lvf.unsupportedBrowser urls.base />
|
||||
|
@ -25,11 +25,11 @@ ${i18n().check_grants_to_exclude}
|
|||
<ul >
|
||||
<#list grantList as grant>
|
||||
<li>
|
||||
<input type="checkbox" class="grantCheckbox" <#if grant.hideThis??>checked</#if> />${grant.label!grant.activity!}
|
||||
<input type="checkbox" class="itemCheckbox" <#if grant.hideThis??>checked</#if> />${grant.label!grant.activity!}
|
||||
</li>
|
||||
<script type="text/javascript">
|
||||
grantData.push({
|
||||
"roleUri": "${grant.role!}"
|
||||
itemData.push({
|
||||
"relatedUri": "${grant.role!}"
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -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}'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -59,5 +59,5 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarke
|
|||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/utils.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/manageGrantsForIndividual.js"></script>')}
|
||||
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/manageHideShowStatus.js"></script>')}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<p style="margin-left:25px;margin-bottom:12px">
|
||||
${i18n().check_people_to_exclude}
|
||||
<script type="text/javascript">
|
||||
var peopleData = [];
|
||||
var itemData = [];
|
||||
</script>
|
||||
</p>
|
||||
|
||||
|
@ -21,11 +21,11 @@ ${i18n().check_people_to_exclude}
|
|||
<ul >
|
||||
<#list peeps as person>
|
||||
<li>
|
||||
<input type="checkbox" class="pubCheckbox" <#if person.hideThis??>checked</#if> />${person.name}
|
||||
<input type="checkbox" class="itemCheckbox" <#if person.hideThis??>checked</#if> />${person.name}
|
||||
</li>
|
||||
<script type="text/javascript">
|
||||
peopleData.push({
|
||||
"positionUri": "${person.position}"
|
||||
itemData.push({
|
||||
"relatedUri": "${person.position}"
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -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}'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -55,5 +55,5 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarke
|
|||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/utils.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/managePeopleForOrganization.js"></script>')}
|
||||
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/manageHideShowStatus.js"></script>')}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<p style="margin-left:25px;margin-bottom:12px">
|
||||
${i18n().check_pubs_to_exclude}
|
||||
<script type="text/javascript">
|
||||
var publicationData = [];
|
||||
var itemData = [];
|
||||
</script>
|
||||
</p>
|
||||
|
||||
|
@ -37,12 +37,12 @@ ${i18n().check_pubs_to_exclude}
|
|||
<ul >
|
||||
<#list pubs as pub>
|
||||
<li>
|
||||
<input type="checkbox" class="pubCheckbox" <#if pub.hideThis??>checked</#if> />
|
||||
<input type="checkbox" class="itemCheckbox" <#if pub.hideThis??>checked</#if> />
|
||||
<#if pub.title?has_content>${pub.title!}<#else>${i18n().title_not_found}</#if>
|
||||
</li>
|
||||
<script type="text/javascript">
|
||||
publicationData.push({
|
||||
"authorshipUri": "${pub.authorship}"
|
||||
itemData.push({
|
||||
"relatedUri": "${pub.authorship}"
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -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}'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -72,5 +72,5 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarke
|
|||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/utils.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/managePublicationsForIndividual.js"></script>')}
|
||||
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/manageHideShowStatus.js"></script>')}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue