Normalize line endings VIVO-101

This commit is contained in:
Brian Caruso 2013-07-18 15:19:53 -04:00
parent b097a4d754
commit 54f79f2ea7
587 changed files with 91501 additions and 91501 deletions

View file

@ -1,174 +1,174 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var menuManagementEdit = {
onLoad: function() {
$.extend(this, i18nStrings);
this.initObjects();
this.bindEventListeners();
this.toggleClassSelection();
},
initObjects: function() {
this.defaultTemplateRadio = $('input.default-template');
this.customTemplateRadio = $('input.custom-template');
this.customTemplate = $('#custom-template');
this.changeContentType = $('#changeContentType');
this.selectContentType = $('#selectContentType');
this.existingContentType = $('#existingContentType');
this.selectClassGroupDropdown = $('#selectClassGroup');
this.classesForClassGroup = $('#classesInSelectedGroup');
this.selectedGroupForPage = $('#selectedContentTypeValue');
this.allClassesSelectedCheckbox = $('#allSelected');
this.displayInternalMessage = $('#internal-class label em');
},
bindEventListeners: function() {
// Listeners for vClass switching
this.changeContentType.click(function() {
menuManagementEdit.showClassGroups();
return false;
});
this.selectClassGroupDropdown.change(function() {
menuManagementEdit.chooseClassGroup();
});
// Listeners for template field
this.defaultTemplateRadio.click(function(){
menuManagementEdit.customTemplate.addClass('hidden');
});
this.customTemplateRadio.click(function(){
// If checked, hide this input element
menuManagementEdit.customTemplate.removeClass('hidden');
});
$("form").submit(function () {
var validationError = menuManagementEdit.validateMenuItemForm();
if (validationError == "") {
$(this).submit();
} else{
$('#error-alert').removeClass('hidden');
$('#error-alert p').html(validationError);
$.scrollTo({ top:0, left:0}, 500)
return false;
}
});
},
updateInternalClassMessage:function(classGroupName) { //User has changed content type
//Set content type within internal class message
this.displayInternalMessage.filter(":first").html(classGroupName);
},
showClassGroups: function() { //User has clicked change content type
//Show the section with the class group dropdown
this.selectContentType.removeClass("hidden");
//Hide the "change content type" section which shows the selected class group
this.existingContentType.addClass("hidden");
//Hide the checkboxes for classes within the class group
this.classesForClassGroup.addClass("hidden");
},
hideClassGroups: function() { //User has selected class group/content type, page should show classes for class group and 'existing' type with change link
//Hide the class group dropdown
this.selectContentType.addClass("hidden");
//Show the "change content type" section which shows the selected class group
this.existingContentType.removeClass("hidden");
//Show the classes in the class group
this.classesForClassGroup.removeClass("hidden");
},
toggleClassSelection: function() {
// Check/unckeck all classes for selection
$('input:checkbox[name=allSelected]').click(function(){
if ( this.checked ) {
// if checked, select all the checkboxes
$('input:checkbox[name=classInClassGroup]').attr('checked','checked');
} else {
// if not checked, deselect all the checkboxes
$('input:checkbox[name=classInClassGroup]').removeAttr('checked');
}
});
$('input:checkbox[name=classInClassGroup]').click(function(){
$('input:checkbox[name=allSelected]').removeAttr('checked');
});
},
validateMenuItemForm: function() {
var validationError = "";
// Check menu name
if ($('input[type=text][name=menuName]').val() == "") {
validationError += menuManagementEdit.supplyName + "<br />";
}
// Check pretty url
if ($('input[type=text][name=prettyUrl]').val() == "") {
validationError += menuManagementEdit.supplyPrettyUrl + "<br />";
}
if ($('input[type=text][name=prettyUrl]').val().charAt(0) != "/") {
validationError += menuManagementEdit.startUrlWithSlash + "<br />";
}
// Check custom template
if ($('input:radio[name=selectedTemplate]:checked').val() == "custom") {
if ($('input[name=customTemplate]').val() == "") {
validationError += menuManagementEdit.supplyTemplate + "<br />";
}
}
// if no class group selected, this is an error
if ($('#selectClassGroup').val() =='-1') {
validationError += menuManagementEdit.supplyContentType + "<br />";
} else {
//class group has been selected, make sure there is at least one class selected
var allSelected = $('input[name="allSelected"]:checked').length;
var noClassesSelected = $('input[name="classInClassGroup"]:checked').length;
if (allSelected == 0 && noClassesSelected == 0) {
//at least one class should be selected
validationError += menuManagementEdit.selectContentType + "<br />";
}
}
//check select class group
return validationError;
},
chooseClassGroup: function() {
var url = "dataservice?getVClassesForVClassGroup=1&classgroupUri=";
var vclassUri = this.selectClassGroupDropdown.val();
url += encodeURIComponent(vclassUri);
//Make ajax call to retrieve vclasses
$.getJSON(url, function(results) {
if ( results.classes.length == 0 ) {
} else {
//update existing content type with correct class group name and hide class group select again
var _this = menuManagementEdit;
menuManagementEdit.hideClassGroups();
menuManagementEdit.selectedGroupForPage.html(results.classGroupName);
//update content type in message to "display x within my institution"
menuManagementEdit.updateInternalClassMessage(results.classGroupName);
//retrieve classes for class group and display with all selected
var selectedClassesList = menuManagementEdit.classesForClassGroup.children('ul#selectedClasses');
selectedClassesList.empty();
selectedClassesList.append('<li class="ui-state-default"> <input type="checkbox" name="allSelected" id="allSelected" value="all" checked="checked" /> <label class="inline" for="All"> ' + menuManagementEdit.allCapitalized + '</label> </li>');
$.each(results.classes, function(i, item) {
var thisClass = results.classes[i];
var thisClassName = thisClass.name;
//When first selecting new content type, all classes should be selected
appendHtml = ' <li class="ui-state-default">' +
'<input type="checkbox" checked="checked" name="classInClassGroup" value="' + thisClass.URI + '" />' +
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
'</li>';
selectedClassesList.append(appendHtml);
});
menuManagementEdit.toggleClassSelection();
}
});
}
};
$(document).ready(function() {
menuManagementEdit.onLoad();
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var menuManagementEdit = {
onLoad: function() {
$.extend(this, i18nStrings);
this.initObjects();
this.bindEventListeners();
this.toggleClassSelection();
},
initObjects: function() {
this.defaultTemplateRadio = $('input.default-template');
this.customTemplateRadio = $('input.custom-template');
this.customTemplate = $('#custom-template');
this.changeContentType = $('#changeContentType');
this.selectContentType = $('#selectContentType');
this.existingContentType = $('#existingContentType');
this.selectClassGroupDropdown = $('#selectClassGroup');
this.classesForClassGroup = $('#classesInSelectedGroup');
this.selectedGroupForPage = $('#selectedContentTypeValue');
this.allClassesSelectedCheckbox = $('#allSelected');
this.displayInternalMessage = $('#internal-class label em');
},
bindEventListeners: function() {
// Listeners for vClass switching
this.changeContentType.click(function() {
menuManagementEdit.showClassGroups();
return false;
});
this.selectClassGroupDropdown.change(function() {
menuManagementEdit.chooseClassGroup();
});
// Listeners for template field
this.defaultTemplateRadio.click(function(){
menuManagementEdit.customTemplate.addClass('hidden');
});
this.customTemplateRadio.click(function(){
// If checked, hide this input element
menuManagementEdit.customTemplate.removeClass('hidden');
});
$("form").submit(function () {
var validationError = menuManagementEdit.validateMenuItemForm();
if (validationError == "") {
$(this).submit();
} else{
$('#error-alert').removeClass('hidden');
$('#error-alert p').html(validationError);
$.scrollTo({ top:0, left:0}, 500)
return false;
}
});
},
updateInternalClassMessage:function(classGroupName) { //User has changed content type
//Set content type within internal class message
this.displayInternalMessage.filter(":first").html(classGroupName);
},
showClassGroups: function() { //User has clicked change content type
//Show the section with the class group dropdown
this.selectContentType.removeClass("hidden");
//Hide the "change content type" section which shows the selected class group
this.existingContentType.addClass("hidden");
//Hide the checkboxes for classes within the class group
this.classesForClassGroup.addClass("hidden");
},
hideClassGroups: function() { //User has selected class group/content type, page should show classes for class group and 'existing' type with change link
//Hide the class group dropdown
this.selectContentType.addClass("hidden");
//Show the "change content type" section which shows the selected class group
this.existingContentType.removeClass("hidden");
//Show the classes in the class group
this.classesForClassGroup.removeClass("hidden");
},
toggleClassSelection: function() {
// Check/unckeck all classes for selection
$('input:checkbox[name=allSelected]').click(function(){
if ( this.checked ) {
// if checked, select all the checkboxes
$('input:checkbox[name=classInClassGroup]').attr('checked','checked');
} else {
// if not checked, deselect all the checkboxes
$('input:checkbox[name=classInClassGroup]').removeAttr('checked');
}
});
$('input:checkbox[name=classInClassGroup]').click(function(){
$('input:checkbox[name=allSelected]').removeAttr('checked');
});
},
validateMenuItemForm: function() {
var validationError = "";
// Check menu name
if ($('input[type=text][name=menuName]').val() == "") {
validationError += menuManagementEdit.supplyName + "<br />";
}
// Check pretty url
if ($('input[type=text][name=prettyUrl]').val() == "") {
validationError += menuManagementEdit.supplyPrettyUrl + "<br />";
}
if ($('input[type=text][name=prettyUrl]').val().charAt(0) != "/") {
validationError += menuManagementEdit.startUrlWithSlash + "<br />";
}
// Check custom template
if ($('input:radio[name=selectedTemplate]:checked').val() == "custom") {
if ($('input[name=customTemplate]').val() == "") {
validationError += menuManagementEdit.supplyTemplate + "<br />";
}
}
// if no class group selected, this is an error
if ($('#selectClassGroup').val() =='-1') {
validationError += menuManagementEdit.supplyContentType + "<br />";
} else {
//class group has been selected, make sure there is at least one class selected
var allSelected = $('input[name="allSelected"]:checked').length;
var noClassesSelected = $('input[name="classInClassGroup"]:checked').length;
if (allSelected == 0 && noClassesSelected == 0) {
//at least one class should be selected
validationError += menuManagementEdit.selectContentType + "<br />";
}
}
//check select class group
return validationError;
},
chooseClassGroup: function() {
var url = "dataservice?getVClassesForVClassGroup=1&classgroupUri=";
var vclassUri = this.selectClassGroupDropdown.val();
url += encodeURIComponent(vclassUri);
//Make ajax call to retrieve vclasses
$.getJSON(url, function(results) {
if ( results.classes.length == 0 ) {
} else {
//update existing content type with correct class group name and hide class group select again
var _this = menuManagementEdit;
menuManagementEdit.hideClassGroups();
menuManagementEdit.selectedGroupForPage.html(results.classGroupName);
//update content type in message to "display x within my institution"
menuManagementEdit.updateInternalClassMessage(results.classGroupName);
//retrieve classes for class group and display with all selected
var selectedClassesList = menuManagementEdit.classesForClassGroup.children('ul#selectedClasses');
selectedClassesList.empty();
selectedClassesList.append('<li class="ui-state-default"> <input type="checkbox" name="allSelected" id="allSelected" value="all" checked="checked" /> <label class="inline" for="All"> ' + menuManagementEdit.allCapitalized + '</label> </li>');
$.each(results.classes, function(i, item) {
var thisClass = results.classes[i];
var thisClassName = thisClass.name;
//When first selecting new content type, all classes should be selected
appendHtml = ' <li class="ui-state-default">' +
'<input type="checkbox" checked="checked" name="classInClassGroup" value="' + thisClass.URI + '" />' +
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
'</li>';
selectedClassesList.append(appendHtml);
});
menuManagementEdit.toggleClassSelection();
}
});
}
};
$(document).ready(function() {
menuManagementEdit.onLoad();
});

View file

@ -1,153 +1,153 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
$.extend(this, i18nStringsBrowseGroups);
//Process sparql data getter and provide a json object with the necessary information
//Depending on what is included here, a different type of data getter might be used
var processClassGroupDataGetterContent = {
dataGetterClass:null,
//can use this if expect to initialize from elsewhere
initProcessor:function(dataGetterClassInput) {
this.dataGetterClass = dataGetterClassInput;
},
//Do we need a separate content type for each of the others?
processPageContentSection:function(pageContentSection) {
//Will look at classes etc.
var classGroup = pageContentSection.find("select[name='selectClassGroup']").val();
//query model should also be an input, ensure class group URI is saved as URI and not string
var returnObject = {classGroup:classGroup, dataGetterClass:this.dataGetterClass};
return returnObject;
},
//For an existing set of content where form is already set, fill in the values
populatePageContentSection:function(existingContentObject, pageContentSection) {
var classGroupValue = existingContentObject["classGroup"];
pageContentSection.find("select[name='selectClassGroup']").val(classGroupValue);
//For now, will utilize the function in pageManagementUtils
//But should move over any class group specific event handlers etc. into this javascript section
//Get 'results' from content object
var results = existingContentObject["results"];
if(results != null) {
processClassGroupDataGetterContent.displayClassesForClassGroup(results, pageContentSection);
//Bind event handlers
processClassGroupDataGetterContent.bindEventHandlers(pageContentSection);
//Show hidden class
}
},
//For the label of the content section for editing, need to add additional value
retrieveContentLabel:function() {
return i18nStringsBrowseGroups.browseClassGroup;
},
retrieveAdditionalLabelText:function(existingContentObject) {
var label = "";
var results = existingContentObject["results"];
if(results != null && results["classGroupName"] != null) {
label = results["classGroupName"];
}
return label;
},
//this is copied from pageManagementUtils but eventually
//we should move all event bindings etc. specific to a content type into its own
//processing methods
//TODO: Refine so no references to pageManagementUtils required
//Page content section specific methods
displayClassesForClassGroup:function(results, pageContentSection) {
if ( results.classes.length == 0 ) {
} else {
var contentNumber = pageContentSection.attr("contentNumber");
var classesForClassGroup = pageContentSection.find('section[name="classesInSelectedGroup"]');
//retrieve classes for class group and display with all selected
var selectedClassesList = classesForClassGroup.children('ul[name="selectedClasses"]');
selectedClassesList.empty();
var newId = "allSelected" + contentNumber;
selectedClassesList.append('<li class="ui-state-default"> <input type="checkbox" name="allSelected" id="' + contentNumber + '" value="all" checked="checked" /> <label class="inline" for="All"> ' + i18nStringsBrowseGroups.allCapitalized + '</label> </li>');
$.each(results.classes, function(i, item) {
var thisClass = results.classes[i];
var thisClassName = thisClass.name;
//For the class group, ALL classes should be selected
appendHtml = ' <li class="ui-state-default">' +
'<input type="checkbox" checked="checked" name="classInClassGroup" value="' + thisClass.URI + '" />' +
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
'</li>';
selectedClassesList.append(appendHtml);
});
//Need a way of handling this without it being in the internal class data getter
var displayInternalMessage = pageContentSection.find('label[for="display-internalClass"] em');
if(displayInternalMessage != null) {
displayInternalMessage.filter(":first").html(results.classGroupName);
}
//This is an EXISTING selection, so value should not be empty
classesForClassGroup.removeClass('hidden');
if ( $("div#leftSide").height() < $("div#rightSide").height() ) {
$("div#leftSide").css("height",$("div#rightSide").height() + "px");
}
}
},
//Toggle class selection already deals with names but want to attach that event
//handler to THIS new section
toggleClassSelection: function(pageContentSection) {
// Check/unckeck all classes for selection
pageContentSection.find('input:checkbox[name=allSelected]').click(function(){
if ( this.checked ) {
// if checked, select all the checkboxes for this particular section
$(this).closest("ul").find('input:checkbox[name=classInClassGroup]').attr('checked','checked');
//$('input:checkbox[name=classInClassGroup]').attr('checked','checked');
} else {
// if not checked, deselect all the checkboxes
$(this).closest("ul").find('input:checkbox[name=classInClassGroup]').removeAttr('checked');
// $('input:checkbox[name=classInClassGroup]').removeAttr('checked');
}
});
pageContentSection.find('input:checkbox[name=classInClassGroup]').click(function(){
$(this).closest("ul").find('input:checkbox[name=allSelected]').removeAttr('checked');
});
},
bindEventHandlers:function(pageContentSection) {
processClassGroupDataGetterContent.toggleClassSelection(pageContentSection);
var selectClassGroupDropdown = pageContentSection.find("select[name='selectClassGroup']");
selectClassGroupDropdown.change(function(e, el) {
processClassGroupDataGetterContent.chooseClassGroup(pageContentSection);
});
},
chooseClassGroup: function(pageContentSection) {
var selectClassGroupDropdown = pageContentSection.find("select[name='selectClassGroup']");
var url = "dataservice?getVClassesForVClassGroup=1&classgroupUri=";
var vclassUri = selectClassGroupDropdown.val();
url += encodeURIComponent(vclassUri);
//Get the page content section
//Make ajax call to retrieve vclasses
$.getJSON(url, function(results) {
//Moved the function to processClassGroupDataGetterContent
//Should probably remove this entire method and copy there
processClassGroupDataGetterContent.displayClassesForClassGroup(results, pageContentSection);
});
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
var validationError = "";
if (pageContentSection.find('select[name="selectClassGroup"]').val() =='-1') {
validationError += pageContentSectionLabel + ": " + i18nStringsBrowseGroups.supplyClassGroup + " <br />";
} else {
//class group has been selected, make sure there is at least one class selected
var allSelected = pageContentSection.find('input[name="allSelected"]:checked').length;
var noClassesSelected = pageContentSection.find('input[name="classInClassGroup"]:checked').length;
if (allSelected == 0 && noClassesSelected == 0) {
//at least one class should be selected
validationError += pageContentSectionLabel + ": " + i18nStringsBrowseGroups.selectClasses + "<br />";
}
}
return validationError;
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
$.extend(this, i18nStringsBrowseGroups);
//Process sparql data getter and provide a json object with the necessary information
//Depending on what is included here, a different type of data getter might be used
var processClassGroupDataGetterContent = {
dataGetterClass:null,
//can use this if expect to initialize from elsewhere
initProcessor:function(dataGetterClassInput) {
this.dataGetterClass = dataGetterClassInput;
},
//Do we need a separate content type for each of the others?
processPageContentSection:function(pageContentSection) {
//Will look at classes etc.
var classGroup = pageContentSection.find("select[name='selectClassGroup']").val();
//query model should also be an input, ensure class group URI is saved as URI and not string
var returnObject = {classGroup:classGroup, dataGetterClass:this.dataGetterClass};
return returnObject;
},
//For an existing set of content where form is already set, fill in the values
populatePageContentSection:function(existingContentObject, pageContentSection) {
var classGroupValue = existingContentObject["classGroup"];
pageContentSection.find("select[name='selectClassGroup']").val(classGroupValue);
//For now, will utilize the function in pageManagementUtils
//But should move over any class group specific event handlers etc. into this javascript section
//Get 'results' from content object
var results = existingContentObject["results"];
if(results != null) {
processClassGroupDataGetterContent.displayClassesForClassGroup(results, pageContentSection);
//Bind event handlers
processClassGroupDataGetterContent.bindEventHandlers(pageContentSection);
//Show hidden class
}
},
//For the label of the content section for editing, need to add additional value
retrieveContentLabel:function() {
return i18nStringsBrowseGroups.browseClassGroup;
},
retrieveAdditionalLabelText:function(existingContentObject) {
var label = "";
var results = existingContentObject["results"];
if(results != null && results["classGroupName"] != null) {
label = results["classGroupName"];
}
return label;
},
//this is copied from pageManagementUtils but eventually
//we should move all event bindings etc. specific to a content type into its own
//processing methods
//TODO: Refine so no references to pageManagementUtils required
//Page content section specific methods
displayClassesForClassGroup:function(results, pageContentSection) {
if ( results.classes.length == 0 ) {
} else {
var contentNumber = pageContentSection.attr("contentNumber");
var classesForClassGroup = pageContentSection.find('section[name="classesInSelectedGroup"]');
//retrieve classes for class group and display with all selected
var selectedClassesList = classesForClassGroup.children('ul[name="selectedClasses"]');
selectedClassesList.empty();
var newId = "allSelected" + contentNumber;
selectedClassesList.append('<li class="ui-state-default"> <input type="checkbox" name="allSelected" id="' + contentNumber + '" value="all" checked="checked" /> <label class="inline" for="All"> ' + i18nStringsBrowseGroups.allCapitalized + '</label> </li>');
$.each(results.classes, function(i, item) {
var thisClass = results.classes[i];
var thisClassName = thisClass.name;
//For the class group, ALL classes should be selected
appendHtml = ' <li class="ui-state-default">' +
'<input type="checkbox" checked="checked" name="classInClassGroup" value="' + thisClass.URI + '" />' +
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
'</li>';
selectedClassesList.append(appendHtml);
});
//Need a way of handling this without it being in the internal class data getter
var displayInternalMessage = pageContentSection.find('label[for="display-internalClass"] em');
if(displayInternalMessage != null) {
displayInternalMessage.filter(":first").html(results.classGroupName);
}
//This is an EXISTING selection, so value should not be empty
classesForClassGroup.removeClass('hidden');
if ( $("div#leftSide").height() < $("div#rightSide").height() ) {
$("div#leftSide").css("height",$("div#rightSide").height() + "px");
}
}
},
//Toggle class selection already deals with names but want to attach that event
//handler to THIS new section
toggleClassSelection: function(pageContentSection) {
// Check/unckeck all classes for selection
pageContentSection.find('input:checkbox[name=allSelected]').click(function(){
if ( this.checked ) {
// if checked, select all the checkboxes for this particular section
$(this).closest("ul").find('input:checkbox[name=classInClassGroup]').attr('checked','checked');
//$('input:checkbox[name=classInClassGroup]').attr('checked','checked');
} else {
// if not checked, deselect all the checkboxes
$(this).closest("ul").find('input:checkbox[name=classInClassGroup]').removeAttr('checked');
// $('input:checkbox[name=classInClassGroup]').removeAttr('checked');
}
});
pageContentSection.find('input:checkbox[name=classInClassGroup]').click(function(){
$(this).closest("ul").find('input:checkbox[name=allSelected]').removeAttr('checked');
});
},
bindEventHandlers:function(pageContentSection) {
processClassGroupDataGetterContent.toggleClassSelection(pageContentSection);
var selectClassGroupDropdown = pageContentSection.find("select[name='selectClassGroup']");
selectClassGroupDropdown.change(function(e, el) {
processClassGroupDataGetterContent.chooseClassGroup(pageContentSection);
});
},
chooseClassGroup: function(pageContentSection) {
var selectClassGroupDropdown = pageContentSection.find("select[name='selectClassGroup']");
var url = "dataservice?getVClassesForVClassGroup=1&classgroupUri=";
var vclassUri = selectClassGroupDropdown.val();
url += encodeURIComponent(vclassUri);
//Get the page content section
//Make ajax call to retrieve vclasses
$.getJSON(url, function(results) {
//Moved the function to processClassGroupDataGetterContent
//Should probably remove this entire method and copy there
processClassGroupDataGetterContent.displayClassesForClassGroup(results, pageContentSection);
});
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
var validationError = "";
if (pageContentSection.find('select[name="selectClassGroup"]').val() =='-1') {
validationError += pageContentSectionLabel + ": " + i18nStringsBrowseGroups.supplyClassGroup + " <br />";
} else {
//class group has been selected, make sure there is at least one class selected
var allSelected = pageContentSection.find('input[name="allSelected"]:checked').length;
var noClassesSelected = pageContentSection.find('input[name="classInClassGroup"]:checked').length;
if (allSelected == 0 && noClassesSelected == 0) {
//at least one class should be selected
validationError += pageContentSectionLabel + ": " + i18nStringsBrowseGroups.selectClasses + "<br />";
}
}
return validationError;
}
}

View file

@ -1,38 +1,38 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
//This class is responsible for the product-specific form processing/content selection that might be possible
//Overrides the usual behavior of selecting the specific JavaScript class needed to convert the form inputs
//into a JSON object for submission based on the page content type
//This will need to be overridden or extended, what have you.. in VIVO
var processDataGetterUtils = {
dataGetterProcessorMap:{"browseClassGroup": processClassGroupDataGetterContent,
"sparqlQuery": processSparqlDataGetterContent,
"fixedHtml":processFixedHTMLDataGetterContent,
"individualsForClasses":processIndividualsForClassesDataGetterContent},
selectDataGetterType:function(pageContentSection) {
var contentType = pageContentSection.attr("contentType");
//The form can provide "browse class group" as content type but need to check
//whether this is in fact individuals for classes instead
if(contentType == "browseClassGroup") {
//Is ALL NOT selected and there are other classes, pick one
//this SHOULD be an array
var allClassesSelected = pageContentSection.find("input[name='allSelected']:checked");
//If all NOT selected then need to pick a different content type
if(allClassesSelected.length == 0) {
contentType = "individualsForClasses";
}
}
return contentType;
},
isRelatedToBrowseClassGroup:function(contentType) {
return (contentType == "browseClassGroup" || contentType == "individualsForClasses");
},
getContentTypeForCloning:function(contentType) {
if(contentType == "browseClassGroup" || contentType == "individualsForClasses") {
return "browseClassGroup";
}
return contentType;
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
//This class is responsible for the product-specific form processing/content selection that might be possible
//Overrides the usual behavior of selecting the specific JavaScript class needed to convert the form inputs
//into a JSON object for submission based on the page content type
//This will need to be overridden or extended, what have you.. in VIVO
var processDataGetterUtils = {
dataGetterProcessorMap:{"browseClassGroup": processClassGroupDataGetterContent,
"sparqlQuery": processSparqlDataGetterContent,
"fixedHtml":processFixedHTMLDataGetterContent,
"individualsForClasses":processIndividualsForClassesDataGetterContent},
selectDataGetterType:function(pageContentSection) {
var contentType = pageContentSection.attr("contentType");
//The form can provide "browse class group" as content type but need to check
//whether this is in fact individuals for classes instead
if(contentType == "browseClassGroup") {
//Is ALL NOT selected and there are other classes, pick one
//this SHOULD be an array
var allClassesSelected = pageContentSection.find("input[name='allSelected']:checked");
//If all NOT selected then need to pick a different content type
if(allClassesSelected.length == 0) {
contentType = "individualsForClasses";
}
}
return contentType;
},
isRelatedToBrowseClassGroup:function(contentType) {
return (contentType == "browseClassGroup" || contentType == "individualsForClasses");
},
getContentTypeForCloning:function(contentType) {
if(contentType == "browseClassGroup" || contentType == "individualsForClasses") {
return "browseClassGroup";
}
return contentType;
}
};

View file

@ -1,77 +1,77 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
$.extend(this, i18nStringsFixedHtml);
//Process sparql data getter and provide a json object with the necessary information
var processFixedHTMLDataGetterContent = {
dataGetterClass:null,
//can use this if expect to initialize from elsewhere
initProcessor:function(dataGetterClass) {
this.dataGetterClass =dataGetterClass;
},
//requires variable and text area
processPageContentSection:function(pageContentSection) {
var saveToVarValue = pageContentSection.find("input[name='saveToVar']").val();
var htmlValue = pageContentSection.find("textarea[name='htmlValue']").val();
//JSON parsing on the server side does not handle single quotes, as it appears it thinks the string has
//ended. Different data getter types may handle apostrophes/single quotes differently
//In this case, this is HTML so it simply html Encodes any apostrophes
htmlValue = processFixedHTMLDataGetterContent.encodeQuotes(htmlValue);
var returnObject = {saveToVar:saveToVarValue, htmlValue:htmlValue, dataGetterClass:this.dataGetterClass};
return returnObject;
},
//For an existing set of content where form is already set, fill in the values
populatePageContentSection:function(existingContentObject, pageContentSection) {
var saveToVarValue = existingContentObject["saveToVar"];
var htmlValue = existingContentObject["htmlValue"];
//In displaying the html value for the edit field, replace the encoded quotes with regular quotes
htmlValue = processFixedHTMLDataGetterContent.replaceEncodedWithEscapedQuotes(htmlValue);
//Now find and set value
pageContentSection.find("input[name='saveToVar']").val(saveToVarValue);
pageContentSection.find("textarea[name='htmlValue']").val(htmlValue);
},
//For the label of the content section for editing, need to add additional value
retrieveContentLabel:function() {
return i18nStringsFixedHtml.fixedHtml;
},
//For the label of the content section for editing, need to add additional value
retrieveAdditionalLabelText:function(existingContentObject) {
var saveToVarValue = existingContentObject["saveToVar"];
return saveToVarValue;
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
var validationError = "";
//Check that query and saveToVar have been input
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
if(variableValue == "") {
validationError += pageContentSectionLabel + ": " + i18nStringsFixedHtml.supplyVariableName + " <br />";
}
if(processFixedHTMLDataGetterContent.stringHasSingleQuote(variableValue)) {
validationError += pageContentSectionLabel + ": " + i18nStringsFixedHtml.noApostrophes + " <br />";
}
if(processFixedHTMLDataGetterContent.stringHasDoubleQuote(variableValue)) {
validationError += pageContentSectionLabel + ": " + i18nStringsFixedHtml.noDoubleQuotes + " <br />";
}
var htmlValue = pageContentSection.find("textarea[name='htmlValue']").val();
if(htmlValue == "") {
validationError += pageContentSectionLabel + ": " + i18nStringsFixedHtml.supplyHtml + " <br />";
}
return validationError;
},
encodeQuotes:function(inputStr) {
return inputStr.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
},
//For the variable name, no single quote should be allowed
//This can be extended for other special characters
stringHasSingleQuote:function(inputStr) {
return(inputStr.indexOf("'") != -1);
},
stringHasDoubleQuote:function(inputStr) {
return(inputStr.indexOf("\"") != -1);
},
replaceEncodedWithEscapedQuotes: function(inputStr) {
return inputStr.replace(/&#39;/g, "\'").replace(/&quot;/g, "\"");
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
$.extend(this, i18nStringsFixedHtml);
//Process sparql data getter and provide a json object with the necessary information
var processFixedHTMLDataGetterContent = {
dataGetterClass:null,
//can use this if expect to initialize from elsewhere
initProcessor:function(dataGetterClass) {
this.dataGetterClass =dataGetterClass;
},
//requires variable and text area
processPageContentSection:function(pageContentSection) {
var saveToVarValue = pageContentSection.find("input[name='saveToVar']").val();
var htmlValue = pageContentSection.find("textarea[name='htmlValue']").val();
//JSON parsing on the server side does not handle single quotes, as it appears it thinks the string has
//ended. Different data getter types may handle apostrophes/single quotes differently
//In this case, this is HTML so it simply html Encodes any apostrophes
htmlValue = processFixedHTMLDataGetterContent.encodeQuotes(htmlValue);
var returnObject = {saveToVar:saveToVarValue, htmlValue:htmlValue, dataGetterClass:this.dataGetterClass};
return returnObject;
},
//For an existing set of content where form is already set, fill in the values
populatePageContentSection:function(existingContentObject, pageContentSection) {
var saveToVarValue = existingContentObject["saveToVar"];
var htmlValue = existingContentObject["htmlValue"];
//In displaying the html value for the edit field, replace the encoded quotes with regular quotes
htmlValue = processFixedHTMLDataGetterContent.replaceEncodedWithEscapedQuotes(htmlValue);
//Now find and set value
pageContentSection.find("input[name='saveToVar']").val(saveToVarValue);
pageContentSection.find("textarea[name='htmlValue']").val(htmlValue);
},
//For the label of the content section for editing, need to add additional value
retrieveContentLabel:function() {
return i18nStringsFixedHtml.fixedHtml;
},
//For the label of the content section for editing, need to add additional value
retrieveAdditionalLabelText:function(existingContentObject) {
var saveToVarValue = existingContentObject["saveToVar"];
return saveToVarValue;
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
var validationError = "";
//Check that query and saveToVar have been input
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
if(variableValue == "") {
validationError += pageContentSectionLabel + ": " + i18nStringsFixedHtml.supplyVariableName + " <br />";
}
if(processFixedHTMLDataGetterContent.stringHasSingleQuote(variableValue)) {
validationError += pageContentSectionLabel + ": " + i18nStringsFixedHtml.noApostrophes + " <br />";
}
if(processFixedHTMLDataGetterContent.stringHasDoubleQuote(variableValue)) {
validationError += pageContentSectionLabel + ": " + i18nStringsFixedHtml.noDoubleQuotes + " <br />";
}
var htmlValue = pageContentSection.find("textarea[name='htmlValue']").val();
if(htmlValue == "") {
validationError += pageContentSectionLabel + ": " + i18nStringsFixedHtml.supplyHtml + " <br />";
}
return validationError;
},
encodeQuotes:function(inputStr) {
return inputStr.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
},
//For the variable name, no single quote should be allowed
//This can be extended for other special characters
stringHasSingleQuote:function(inputStr) {
return(inputStr.indexOf("'") != -1);
},
stringHasDoubleQuote:function(inputStr) {
return(inputStr.indexOf("\"") != -1);
},
replaceEncodedWithEscapedQuotes: function(inputStr) {
return inputStr.replace(/&#39;/g, "\'").replace(/&quot;/g, "\"");
}
}

View file

@ -1,62 +1,62 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var processIndividualsForClassesDataGetterContent = {
dataGetterClass:null,
//can use this if expect to initialize from elsewhere
initProcessor:function(dataGetterClassInput) {
this.dataGetterClass = dataGetterClassInput;
},
//Do we need a separate content type for each of the others?
processPageContentSection:function(pageContentSection) {
//Will look at classes etc.
var classGroup = pageContentSection.find("select[name='selectClassGroup']").val();
//query model should also be an input
//Get classes selected
var classesSelected = [];
pageContentSection.find("input[name='classInClassGroup']:checked").each(function(){
//Need to make sure that the class is also saved as a URI
classesSelected.push($(this).val());
});
var returnObject = {classGroup:classGroup, classesSelectedInClassGroup:classesSelected, dataGetterClass:this.dataGetterClass};
return returnObject;
},
//For the label of the content section for editing, need to add additional value
retrieveContentLabel:function() {
return processClassGroupDataGetterContent.retrieveContentLabel();
},
//For an existing set of content where form is already set, fill in the values
populatePageContentSection:function(existingContentObject, pageContentSection) {
//select class group in dropdown and append the classes within that class group
processClassGroupDataGetterContent.populatePageContentSection(existingContentObject, pageContentSection);
var classesSelected = existingContentObject["classesSelectedInClassGroup"];
var numberSelected = classesSelected.length;
var i;
//Uncheck all since default is checked
pageContentSection.find("input[name='classInClassGroup']").removeAttr("checked");
for(i = 0; i < numberSelected; i++) {
var classSelected = classesSelected[i];
pageContentSection.find("input[name='classInClassGroup'][value='" + classSelected + "']").attr("checked", "checked");
}
//If number of classes selected is not equal to total number of classes, uncheck all
var results =existingContentObject["results"];
if(results != null && results.classGroupName != null) {
var resultsClasses = results["classes"];
if(resultsClasses != null) {
var numberClasses = resultsClasses.length;
if(numberClasses != numberSelected) {
pageContentSection.find("input[name='allSelected']").removeAttr("checked");
}
}
}
},
//For the label of the content section for editing, need to add additional value
retrieveAdditionalLabelText:function(existingContentObject) {
return processClassGroupDataGetterContent.retrieveAdditionalLabelText(existingContentObject);
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
return processClassGroupDataGetterContent.validateFormSubmission(pageContentSection, pageContentSectionLabel);
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var processIndividualsForClassesDataGetterContent = {
dataGetterClass:null,
//can use this if expect to initialize from elsewhere
initProcessor:function(dataGetterClassInput) {
this.dataGetterClass = dataGetterClassInput;
},
//Do we need a separate content type for each of the others?
processPageContentSection:function(pageContentSection) {
//Will look at classes etc.
var classGroup = pageContentSection.find("select[name='selectClassGroup']").val();
//query model should also be an input
//Get classes selected
var classesSelected = [];
pageContentSection.find("input[name='classInClassGroup']:checked").each(function(){
//Need to make sure that the class is also saved as a URI
classesSelected.push($(this).val());
});
var returnObject = {classGroup:classGroup, classesSelectedInClassGroup:classesSelected, dataGetterClass:this.dataGetterClass};
return returnObject;
},
//For the label of the content section for editing, need to add additional value
retrieveContentLabel:function() {
return processClassGroupDataGetterContent.retrieveContentLabel();
},
//For an existing set of content where form is already set, fill in the values
populatePageContentSection:function(existingContentObject, pageContentSection) {
//select class group in dropdown and append the classes within that class group
processClassGroupDataGetterContent.populatePageContentSection(existingContentObject, pageContentSection);
var classesSelected = existingContentObject["classesSelectedInClassGroup"];
var numberSelected = classesSelected.length;
var i;
//Uncheck all since default is checked
pageContentSection.find("input[name='classInClassGroup']").removeAttr("checked");
for(i = 0; i < numberSelected; i++) {
var classSelected = classesSelected[i];
pageContentSection.find("input[name='classInClassGroup'][value='" + classSelected + "']").attr("checked", "checked");
}
//If number of classes selected is not equal to total number of classes, uncheck all
var results =existingContentObject["results"];
if(results != null && results.classGroupName != null) {
var resultsClasses = results["classes"];
if(resultsClasses != null) {
var numberClasses = resultsClasses.length;
if(numberClasses != numberSelected) {
pageContentSection.find("input[name='allSelected']").removeAttr("checked");
}
}
}
},
//For the label of the content section for editing, need to add additional value
retrieveAdditionalLabelText:function(existingContentObject) {
return processClassGroupDataGetterContent.retrieveAdditionalLabelText(existingContentObject);
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
return processClassGroupDataGetterContent.validateFormSubmission(pageContentSection, pageContentSectionLabel);
}
}

View file

@ -1,97 +1,97 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
$.extend(this, i18nStringsSparqlQuery);
//Process sparql data getter and provide a json object with the necessary information
var processSparqlDataGetterContent = {
dataGetterClass:null,
//can use this if expect to initialize from elsewhere
initProcessor:function(dataGetterClass) {
this.dataGetterClass =dataGetterClass;
},
processPageContentSection:function(pageContentSection) {
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
var queryValue = pageContentSection.find("textarea[name='query']").val();
queryValue = processSparqlDataGetterContent.encodeQuotes(queryValue);
var queryModel = pageContentSection.find("input[name='queryModel']").val();
//query model should also be an input
//set query model to query model here - vitro:contentDisplayModel
var returnObject = {saveToVar:variableValue, query:queryValue, dataGetterClass:this.dataGetterClass, queryModel:queryModel};
return returnObject;
},
//For an existing set of content where form is already set, fill in the values
populatePageContentSection:function(existingContentObject, pageContentSection) {
var saveToVarValue = existingContentObject["saveToVar"];
var queryValue = existingContentObject["query"];
//replace any encoded quotes with escaped quotes that will show up as quotes in the textarea
queryValue = processSparqlDataGetterContent.replaceEncodedWithEscapedQuotes(queryValue);
var queryModelValue = existingContentObject["queryModel"];
//Now find and set value
pageContentSection.find("input[name='saveToVar']").val(saveToVarValue);
pageContentSection.find("textarea[name='query']").val(queryValue);
pageContentSection.find("input[name='queryModel']").val(queryModelValue);
},
//For the label of the content section for editing, need to add additional value
retrieveContentLabel:function() {
return i18nStringsSparqlQuery.sparqlResults;
},
//For the label of the content section for editing, need to add additional value
retrieveAdditionalLabelText:function(existingContentObject) {
var saveToVarValue = existingContentObject["saveToVar"];
return saveToVarValue;
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
var validationError = "";
//Check that query and saveToVar have been input
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
if(variableValue == "") {
validationError += pageContentSectionLabel + ": " + i18nStringsSparqlQuery.supplyQueryVariable + " <br />"
}
if(processSparqlDataGetterContent.stringHasSingleQuote(variableValue)) {
validationError += pageContentSectionLabel + ": " + i18nStringsSparqlQuery.noApostrophes + " <br />";
}
if(processSparqlDataGetterContent.stringHasDoubleQuote(variableValue)) {
validationError += pageContentSectionLabel + ": " + i18nStringsSparqlQuery.noDoubleQuotes + " <br />";
}
//Check that query model does not have single or double quotes within it
//Uncomment this/adapt this when we actually allow display the query model input
/*
var queryModelValue = pageContentSection.find("input[name='queryModel']").val();
if(processSparqlDataGetterContent.stringHasSingleQuote(queryModelValue)) {
validationError += pageContentSectionLabel + ": The query model should not have an apostrophe . <br />";
}
if(processSparqlDataGetterContent.stringHasDoubleQuote(queryModelValue)) {
validationError += pageContentSectionLabel + ": The query model should not have a double quote . <br />";
}*/
var queryValue = pageContentSection.find("textarea[name='query']").val();
if(queryValue == "") {
validationError += pageContentSectionLabel + ": " + i18nStringsSparqlQuery.supplyQuery + " <br />";
}
return validationError;
},
encodeQuotes:function(inputStr) {
return inputStr.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
},
//For the variable name, no single quote should be allowed
//This can be extended for other special characters
stringHasSingleQuote:function(inputStr) {
return(inputStr.indexOf("'") != -1);
},
stringHasDoubleQuote:function(inputStr) {
return(inputStr.indexOf("\"") != -1);
},
replaceEncodedWithEscapedQuotes: function(inputStr) {
return inputStr.replace(/&#39;/g, "\'").replace(/&quot;/g, "\"");
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
$.extend(this, i18nStringsSparqlQuery);
//Process sparql data getter and provide a json object with the necessary information
var processSparqlDataGetterContent = {
dataGetterClass:null,
//can use this if expect to initialize from elsewhere
initProcessor:function(dataGetterClass) {
this.dataGetterClass =dataGetterClass;
},
processPageContentSection:function(pageContentSection) {
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
var queryValue = pageContentSection.find("textarea[name='query']").val();
queryValue = processSparqlDataGetterContent.encodeQuotes(queryValue);
var queryModel = pageContentSection.find("input[name='queryModel']").val();
//query model should also be an input
//set query model to query model here - vitro:contentDisplayModel
var returnObject = {saveToVar:variableValue, query:queryValue, dataGetterClass:this.dataGetterClass, queryModel:queryModel};
return returnObject;
},
//For an existing set of content where form is already set, fill in the values
populatePageContentSection:function(existingContentObject, pageContentSection) {
var saveToVarValue = existingContentObject["saveToVar"];
var queryValue = existingContentObject["query"];
//replace any encoded quotes with escaped quotes that will show up as quotes in the textarea
queryValue = processSparqlDataGetterContent.replaceEncodedWithEscapedQuotes(queryValue);
var queryModelValue = existingContentObject["queryModel"];
//Now find and set value
pageContentSection.find("input[name='saveToVar']").val(saveToVarValue);
pageContentSection.find("textarea[name='query']").val(queryValue);
pageContentSection.find("input[name='queryModel']").val(queryModelValue);
},
//For the label of the content section for editing, need to add additional value
retrieveContentLabel:function() {
return i18nStringsSparqlQuery.sparqlResults;
},
//For the label of the content section for editing, need to add additional value
retrieveAdditionalLabelText:function(existingContentObject) {
var saveToVarValue = existingContentObject["saveToVar"];
return saveToVarValue;
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
var validationError = "";
//Check that query and saveToVar have been input
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
if(variableValue == "") {
validationError += pageContentSectionLabel + ": " + i18nStringsSparqlQuery.supplyQueryVariable + " <br />"
}
if(processSparqlDataGetterContent.stringHasSingleQuote(variableValue)) {
validationError += pageContentSectionLabel + ": " + i18nStringsSparqlQuery.noApostrophes + " <br />";
}
if(processSparqlDataGetterContent.stringHasDoubleQuote(variableValue)) {
validationError += pageContentSectionLabel + ": " + i18nStringsSparqlQuery.noDoubleQuotes + " <br />";
}
//Check that query model does not have single or double quotes within it
//Uncomment this/adapt this when we actually allow display the query model input
/*
var queryModelValue = pageContentSection.find("input[name='queryModel']").val();
if(processSparqlDataGetterContent.stringHasSingleQuote(queryModelValue)) {
validationError += pageContentSectionLabel + ": The query model should not have an apostrophe . <br />";
}
if(processSparqlDataGetterContent.stringHasDoubleQuote(queryModelValue)) {
validationError += pageContentSectionLabel + ": The query model should not have a double quote . <br />";
}*/
var queryValue = pageContentSection.find("textarea[name='query']").val();
if(queryValue == "") {
validationError += pageContentSectionLabel + ": " + i18nStringsSparqlQuery.supplyQuery + " <br />";
}
return validationError;
},
encodeQuotes:function(inputStr) {
return inputStr.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
},
//For the variable name, no single quote should be allowed
//This can be extended for other special characters
stringHasSingleQuote:function(inputStr) {
return(inputStr.indexOf("'") != -1);
},
stringHasDoubleQuote:function(inputStr) {
return(inputStr.indexOf("\"") != -1);
},
replaceEncodedWithEscapedQuotes: function(inputStr) {
return inputStr.replace(/&#39;/g, "\'").replace(/&quot;/g, "\"");
}
};