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$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
var manageGrants = {
|
var manageHideShowStatus = {
|
||||||
|
|
||||||
/* *** Initial page setup *** */
|
/* *** Initial page setup *** */
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ var manageGrants = {
|
||||||
// Initial page setup. Called only at page load.
|
// Initial page setup. Called only at page load.
|
||||||
initPage: function() {
|
initPage: function() {
|
||||||
|
|
||||||
this.initGrantData();
|
this.initItemData();
|
||||||
|
|
||||||
this.bindEventListeners();
|
this.bindEventListeners();
|
||||||
|
|
||||||
|
@ -29,28 +29,28 @@ var manageGrants = {
|
||||||
// On page load, associate data with each list item. Then we don't
|
// 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
|
// have to keep retrieving data from or modifying the DOM as we manipulate the
|
||||||
// items.
|
// items.
|
||||||
initGrantData: function() {
|
initItemData: function() {
|
||||||
$('.grantCheckbox').each(function(index) {
|
$('.itemCheckbox').each(function(index) {
|
||||||
$(this).data(grantData[index]);
|
$(this).data(itemData[index]);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
bindEventListeners: function() {
|
bindEventListeners: function() {
|
||||||
|
|
||||||
$('.grantCheckbox').click(function() {
|
$('.itemCheckbox').click(function() {
|
||||||
manageGrants.processGrant(this);
|
manageHideShowStatus.processItem(this);
|
||||||
//return false;
|
//return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
processGrant: function(grant) {
|
processItem: function(item) {
|
||||||
|
|
||||||
var add = "";
|
var add = "";
|
||||||
var retract = "";
|
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;
|
add = n3String;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -58,22 +58,22 @@ var manageGrants = {
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: manageGrants.processingUrl,
|
url: manageHideShowStatus.processingUrl,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
additions: add,
|
additions: add,
|
||||||
retractions: retract
|
retractions: retract
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
context: grant, // context for callback
|
context: item, // context for callback
|
||||||
complete: function(request, status) {
|
complete: function(request, status) {
|
||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
window.status = manageGrants.grantSuccessfullyExcluded;
|
window.status = manageHideShowStatus.itemSuccessfullyExcluded;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
alert(manageGrants.errorExcludingGrant);
|
alert(manageHideShowStatus.errorExcludingItem);
|
||||||
$(grant).removeAttr('checked');
|
$(item).removeAttr('checked');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -82,5 +82,5 @@ var manageGrants = {
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(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">
|
<p style="margin-left:25px;margin-bottom:12px">
|
||||||
${i18n().check_grants_to_exclude}
|
${i18n().check_grants_to_exclude}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var grantData = [];
|
var itemData = [];
|
||||||
</script>
|
</script>
|
||||||
</p>
|
</p>
|
||||||
<@lvf.unsupportedBrowser urls.base />
|
<@lvf.unsupportedBrowser urls.base />
|
||||||
|
@ -25,11 +25,11 @@ ${i18n().check_grants_to_exclude}
|
||||||
<ul >
|
<ul >
|
||||||
<#list grantList as grant>
|
<#list grantList as grant>
|
||||||
<li>
|
<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>
|
</li>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
grantData.push({
|
itemData.push({
|
||||||
"roleUri": "${grant.role!}"
|
"relatedUri": "${grant.role!}"
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ var customFormData = {
|
||||||
processingUrl: '${urls.base}/edit/primitiveRdfEdit'
|
processingUrl: '${urls.base}/edit/primitiveRdfEdit'
|
||||||
};
|
};
|
||||||
var i18nStrings = {
|
var i18nStrings = {
|
||||||
grantSuccessfullyExcluded: '${i18n().grant_successfully_excluded}',
|
itemSuccessfullyExcluded: '${i18n().grant_successfully_excluded}',
|
||||||
errorExcludingGrant: '${i18n().error_excluding_grant}'
|
errorExcludingItem: '${i18n().error_excluding_grant}'
|
||||||
};
|
};
|
||||||
</script>
|
</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>',
|
${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/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}/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">
|
<p style="margin-left:25px;margin-bottom:12px">
|
||||||
${i18n().check_people_to_exclude}
|
${i18n().check_people_to_exclude}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var peopleData = [];
|
var itemData = [];
|
||||||
</script>
|
</script>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ ${i18n().check_people_to_exclude}
|
||||||
<ul >
|
<ul >
|
||||||
<#list peeps as person>
|
<#list peeps as person>
|
||||||
<li>
|
<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>
|
</li>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
peopleData.push({
|
itemData.push({
|
||||||
"positionUri": "${person.position}"
|
"relatedUri": "${person.position}"
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ var customFormData = {
|
||||||
processingUrl: '${urls.base}/edit/primitiveRdfEdit'
|
processingUrl: '${urls.base}/edit/primitiveRdfEdit'
|
||||||
};
|
};
|
||||||
var i18nStrings = {
|
var i18nStrings = {
|
||||||
personSuccessfullyExcluded: '${i18n().person_successfully_excluded}',
|
itemSuccessfullyExcluded: '${i18n().person_successfully_excluded}',
|
||||||
errorExcludingPerson: '${i18n().error_excluding_person}'
|
errorExcludingItem: '${i18n().error_excluding_person}'
|
||||||
};
|
};
|
||||||
</script>
|
</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>',
|
${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/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}/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">
|
<p style="margin-left:25px;margin-bottom:12px">
|
||||||
${i18n().check_pubs_to_exclude}
|
${i18n().check_pubs_to_exclude}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var publicationData = [];
|
var itemData = [];
|
||||||
</script>
|
</script>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -37,12 +37,12 @@ ${i18n().check_pubs_to_exclude}
|
||||||
<ul >
|
<ul >
|
||||||
<#list pubs as pub>
|
<#list pubs as pub>
|
||||||
<li>
|
<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>
|
<#if pub.title?has_content>${pub.title!}<#else>${i18n().title_not_found}</#if>
|
||||||
</li>
|
</li>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
publicationData.push({
|
itemData.push({
|
||||||
"authorshipUri": "${pub.authorship}"
|
"relatedUri": "${pub.authorship}"
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ var customFormData = {
|
||||||
processingUrl: '${urls.base}/edit/primitiveRdfEdit'
|
processingUrl: '${urls.base}/edit/primitiveRdfEdit'
|
||||||
};
|
};
|
||||||
var i18nStrings = {
|
var i18nStrings = {
|
||||||
publicationSuccessfullyExcluded: '${i18n().publication_successfully_excluded}',
|
itemSuccessfullyExcluded: '${i18n().publication_successfully_excluded}',
|
||||||
errorExcludingPublication: '${i18n().error_excluding_publication}'
|
errorExcludingItem: '${i18n().error_excluding_publication}'
|
||||||
};
|
};
|
||||||
</script>
|
</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>',
|
${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/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}/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