improvements to blank node handling in bulk deletion
This commit is contained in:
parent
cef7b583e2
commit
b480cb2eea
78 changed files with 5882 additions and 605 deletions
26
webapp/web/js/jquery.fix.clone.js
Normal file
26
webapp/web/js/jquery.fix.clone.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Textarea and select clone() bug workaround | Spencer Tipping
|
||||
// Licensed under the terms of the MIT source code license
|
||||
|
||||
// Motivation.
|
||||
// jQuery's clone() method works in most cases, but it fails to copy the value of textareas and select elements. This patch replaces jQuery's clone() method with a wrapper that fills in the
|
||||
// values after the fact.
|
||||
|
||||
// An interesting error case submitted by Piotr Przybył: If two <select> options had the same value, the clone() method would select the wrong one in the cloned box. The fix, suggested by Piotr
|
||||
// and implemented here, is to use the selectedIndex property on the <select> box itself rather than relying on jQuery's value-based val().
|
||||
|
||||
(function (original) {
|
||||
jQuery.fn.clone = function () {
|
||||
var result = original.apply(this, arguments),
|
||||
my_textareas = this.find('textarea').add(this.filter('textarea')),
|
||||
result_textareas = result.find('textarea').add(this.filter('textarea')),
|
||||
my_selects = this.find('select').add(this.filter('select')),
|
||||
result_selects = result.find('select').add(this.filter('select'));
|
||||
|
||||
for (var i = 0, l = my_textareas.length; i < l; ++i) $(result_textareas[i]).val($(my_textareas[i]).val());
|
||||
for (var i = 0, l = my_selects.length; i < l; ++i) result_selects[i].selectedIndex = my_selects[i].selectedIndex;
|
||||
|
||||
return result;
|
||||
};
|
||||
}) (jQuery.fn.clone);
|
||||
|
||||
// Generated by SDoc
|
|
@ -1,18 +1,34 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
var pageManagementUtils = {
|
||||
|
||||
dataGetterLabelToURI:null,//initialized by custom data
|
||||
processDataGetterUtils:processDataGetterUtils,//an external class that should exist before this one
|
||||
dataGetterMap:null,
|
||||
// on initial page setup
|
||||
onLoad:function(){
|
||||
if (this.disableFormInUnsupportedBrowsers()) {
|
||||
return;
|
||||
}
|
||||
this.mixIn();
|
||||
this.initDataGetterProcessors(),
|
||||
this.initObjects();
|
||||
this.bindEventListeners();
|
||||
this.initDisplay();
|
||||
|
||||
},
|
||||
initDataGetterProcessors:function() {
|
||||
//data getter processor map should come in from custom data
|
||||
//Go through each and initialize with their class
|
||||
|
||||
if(pageManagementUtils.processDataGetterUtils != null) {
|
||||
var dataGetterProcessorMap = pageManagementUtils.dataGetterProcessorMap = pageManagementUtils.processDataGetterUtils.dataGetterProcessorMap;
|
||||
$.each(dataGetterProcessorMap, function(key, dataGetterProcessorObject) {
|
||||
//passes class name from data getter label to uri to processor
|
||||
dataGetterProcessorObject.initProcessor(pageManagementUtils.dataGetterLabelToURI[key]);
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
disableFormInUnsupportedBrowsers: function() {
|
||||
var disableWrapper = $('#ie67DisableWrapper');
|
||||
|
||||
|
@ -28,6 +44,7 @@ var pageManagementUtils = {
|
|||
},
|
||||
|
||||
mixIn: function() {
|
||||
//Data getter process list input should be retrieved from the custom data
|
||||
// Mix in the custom form utility methods
|
||||
$.extend(this, vitro.customFormUtils);
|
||||
// Get the custom form data from the page
|
||||
|
@ -35,11 +52,12 @@ var pageManagementUtils = {
|
|||
},
|
||||
initObjects:function(){
|
||||
this.counter = 0;
|
||||
this.contentTypeSelect = $("#typeSelect");
|
||||
this.contentTypeSelect = $("select#typeSelect");
|
||||
//list of options
|
||||
this.contentTypeSelectOptions = $('select#typeSelect option');
|
||||
this.classGroupSection = $("section#classGroup");
|
||||
this.nonClassGroupSection = $("section#nonClassGroup");
|
||||
this.classGroupSection = $("section#browseClassGroup");
|
||||
this.sparqlQuerySection = $("section#sparqlQuery");
|
||||
this.fixedHTMLSection = $("section#fixedHtml");
|
||||
//From original menu management edit
|
||||
this.defaultTemplateRadio = $('input.default-template');
|
||||
this.customTemplateRadio = $('input.custom-template');
|
||||
|
@ -48,12 +66,19 @@ var pageManagementUtils = {
|
|||
// this.changeContentType = $('#changeContentType');
|
||||
this.selectContentType = $('#selectContentType');
|
||||
// this.existingContentType = $('#existingContentType');
|
||||
this.selectClassGroupDropdown = $('#selectClassGroup');
|
||||
this.classesForClassGroup = $('#classesInSelectedGroup');
|
||||
this.selectClassGroupDropdown = $('select#selectClassGroup');
|
||||
this.classesForClassGroup = $('section#classesInSelectedGroup');
|
||||
this.selectedGroupForPage = $('#selectedContentTypeValue');
|
||||
this.allClassesSelectedCheckbox = $('#allSelected');
|
||||
this.displayInternalMessage = $('#internal-class label em');
|
||||
this.pageContentSubmissionInputs = $("#pageContentSubmissionInputs");
|
||||
this.headerBar = $("section#headerBar");
|
||||
this.moreContentButton = $("input#moreContent");
|
||||
this.isMenuCheckbox = $("input#menuCheckbox");
|
||||
this.menuSection = $("section#menu");
|
||||
this.submitButton = $("input#submit");
|
||||
this.leftSideDiv = $("div#leftSide");
|
||||
this.rightSideDiv = $("div#rightSide")
|
||||
},
|
||||
initDisplay: function(){
|
||||
//right side components
|
||||
|
@ -62,125 +87,120 @@ var pageManagementUtils = {
|
|||
|
||||
//Why would you want to hide this? This hides everything
|
||||
// $("section#pageDetails").hide();
|
||||
$("section#headerBar").hide();
|
||||
this.headerBar.hide();
|
||||
this.classGroupSection.hide();
|
||||
this.nonClassGroupSection.hide();
|
||||
$("section#classesInSelectedGroup").addClass('hidden');
|
||||
$("input#moreContent").hide();
|
||||
this.sparqlQuerySection.hide();
|
||||
this.fixedHTMLSection.hide();
|
||||
this.classesForClassGroup.addClass('hidden');
|
||||
this.moreContentButton.hide();
|
||||
//left side components
|
||||
$("input.default-template").attr('checked',true);
|
||||
$("input#menuCheckbox").attr('checked',false);
|
||||
$("section#menu").hide();
|
||||
this.defaultTemplateRadio.attr('checked',true);
|
||||
this.isMenuCheckbox.attr('checked',false);
|
||||
this.menuSection.hide();
|
||||
|
||||
},
|
||||
bindEventListeners:function(){
|
||||
$("input.default-template").click( function() {
|
||||
$("section#custom-template").addClass('hidden');
|
||||
|
||||
this.defaultTemplateRadio.click( function() {
|
||||
pageManagementUtils.customTemplate.addClass('hidden');
|
||||
//Also clear custom template value so as not to submit it
|
||||
pageManagementUtils.clearInputs(pageManagementUtils.customTemplate);
|
||||
|
||||
});
|
||||
|
||||
$("input.custom-template").click( function() {
|
||||
$("section#custom-template").removeClass('hidden');
|
||||
this.customTemplateRadio.click( function() {
|
||||
pageManagementUtils.customTemplate.removeClass('hidden');
|
||||
});
|
||||
|
||||
$("input#menuCheckbox").click( function() {
|
||||
if ( $("section#menu").is(':hidden') ) {
|
||||
$("section#menu").show();
|
||||
this.isMenuCheckbox.click( function() {
|
||||
if ( pageManagementUtils.menuSection.is(':hidden') ) {
|
||||
pageManagementUtils.menuSection.show();
|
||||
}
|
||||
else {
|
||||
$("section#menu").hide();
|
||||
pageManagementUtils.menuSection.hide();
|
||||
}
|
||||
});
|
||||
|
||||
$("input#submit").click( function() {
|
||||
this.submitButton.click( function() {
|
||||
$("section#pageDetails").show();
|
||||
});
|
||||
|
||||
//Collapses the current content and creates a new section of content
|
||||
//Resets the content to be cloned to default settings
|
||||
$("input#moreContent").click( function() {
|
||||
this.moreContentButton.click( function() {
|
||||
var selectedType = pageManagementUtils.contentTypeSelect.val();
|
||||
var selectedTypeText = $("#typeSelect option:selected").text();
|
||||
//Not sure why selected group here? This won't always be true for more content
|
||||
//var selectedGroup = $('select#selectClassGroup').val();
|
||||
|
||||
//Aren't these already hidden?
|
||||
//Hide both sections
|
||||
$("section#classGroup").hide();
|
||||
$("section#nonClassGroup").hide();
|
||||
|
||||
//Reset class group
|
||||
pageManagementUtils.resetClassGroupSection();
|
||||
//Hide all sections
|
||||
pageManagementUtils.classGroupSection.hide();
|
||||
pageManagementUtils.fixedHTMLSection.hide();
|
||||
pageManagementUtils.sparqlQuerySection.hide();
|
||||
//Reset main content type drop-down
|
||||
pageManagementUtils.contentTypeSelectOptions.eq(0).attr('selected', 'selected');
|
||||
$("input#moreContent").hide();
|
||||
if ( $("div#leftSide").css("height") != undefined ) {
|
||||
$("div#leftSide").css("height","");
|
||||
if ( $("div#leftSide").height() < $("div#rightSide").height() ) {
|
||||
$("div#leftSide").css("height",$("div#rightSide").height() + "px");
|
||||
pageManagementUtils.moreContentButton.hide();
|
||||
if ( pageManagementUtils.leftSideDiv.css("height") != undefined ) {
|
||||
pageManagementUtils.leftSideDiv.css("height","");
|
||||
if ( pageManagementUtils.leftSideDiv.height() < pageManagementUtils.rightSideDiv.height() ) {
|
||||
pageManagementUtils.leftSideDiv.css("height",pageManagementUtils.rightSideDiv.height() + "px");
|
||||
}
|
||||
}
|
||||
$("section#headerBar").hide();
|
||||
$("section#headerBar").text("");
|
||||
//pageManagementUtils.cloneContentArea(selectedType,selectedGroup);
|
||||
pageManagementUtils.cloneContentArea(selectedType, selectedTypeText);
|
||||
pageManagementUtils.contentTypeSelect.focus();
|
||||
pageManagementUtils.headerBar.hide();
|
||||
pageManagementUtils.headerBar.text("");
|
||||
pageManagementUtils.cloneContentArea(selectedType, selectedTypeText);
|
||||
//Reset class group section AFTER cloning not before
|
||||
pageManagementUtils.resetClassGroupSection();
|
||||
//Clear all inputs values
|
||||
pageManagementUtils.clearSourceTemplateValues();
|
||||
pageManagementUtils.contentTypeSelect.focus();
|
||||
});
|
||||
|
||||
//replacing with menu management edit version which is extended with some of the logic below
|
||||
this.selectClassGroupDropdown.change(function() {
|
||||
pageManagementUtils.chooseClassGroup();
|
||||
});
|
||||
/*
|
||||
$("select#selectClassGroup").change( function() {
|
||||
if ( $("select#selectClassGroup").val() == "" ) {
|
||||
$("section#classesInSelectedGroup").addClass('hidden');
|
||||
$("div#leftSide").css("height","");
|
||||
$("input#moreContent").hide();
|
||||
|
||||
|
||||
this.contentTypeSelect.change( function() {
|
||||
_this = pageManagementUtils;
|
||||
pageManagementUtils.clearSourceTemplateValues();
|
||||
if ( _this.contentTypeSelect.val() == "browseClassGroup" ) {
|
||||
pageManagementUtils.classGroupSection.show();
|
||||
pageManagementUtils.fixedHTMLSection.hide();
|
||||
pageManagementUtils.sparqlQuerySection.hide();
|
||||
pageManagementUtils.moreContentButton.hide();
|
||||
pageManagementUtils.headerBar.text("Browse Class Group - ");
|
||||
pageManagementUtils.headerBar.show();
|
||||
}
|
||||
else {
|
||||
$("section#classesInSelectedGroup").removeClass('hidden');
|
||||
$("input#moreContent").show();
|
||||
if ( $("div#leftSide").height() < $("div#rightSide").height() ) {
|
||||
$("div#leftSide").css("height",$("div#rightSide").height() + "px");
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
$("select#typeSelect").change( function() {
|
||||
$('input#variable').val("");
|
||||
$('textarea#textArea').val("");
|
||||
if ( $("#typeSelect").val() == "browseClassGroup" ) {
|
||||
$("section#classGroup").show();
|
||||
$("section#nonClassGroup").hide();
|
||||
$("input#moreContent").hide();
|
||||
$("section#headerBar").text("Browse Class Group - ");
|
||||
$("section#headerBar").show();
|
||||
}
|
||||
if ( $("#typeSelect").val() == "fixedHtml" || $("#typeSelect").val() == "sparqlQuery" ) {
|
||||
$("section#classGroup").hide();
|
||||
if ( $("#typeSelect").val() == "fixedHtml" ) {
|
||||
$('span#taSpan').text("Enter fixed HTML here");
|
||||
$("section#headerBar").text("Fixed HTML - ");
|
||||
if ( _this.contentTypeSelect.val() == "fixedHtml" || _this.contentTypeSelect.val() == "sparqlQuery" ) {
|
||||
pageManagementUtils.classGroupSection.hide();
|
||||
//if fixed html show that, otherwise show sparq
|
||||
if ( _this.contentTypeSelect.val() == "fixedHtml" ) {
|
||||
pageManagementUtils.headerBar.text("Fixed HTML - ");
|
||||
pageManagementUtils.fixedHTMLSection.show();
|
||||
pageManagementUtils.sparqlQuerySection.hide();
|
||||
}
|
||||
else {
|
||||
$('span#taSpan').text("Enter SPARQL query here");
|
||||
$("section#headerBar").text("SPARQL Query Results - ");
|
||||
pageManagementUtils.headerBar.text("SPARQL Query Results - ");
|
||||
pageManagementUtils.sparqlQuerySection.show();
|
||||
pageManagementUtils.fixedHTMLSection.hide();
|
||||
}
|
||||
$("section#nonClassGroup").show();
|
||||
$("section#headerBar").show();
|
||||
$('select#selectClassGroup option').eq(0).attr('selected', 'selected');
|
||||
$("section#classesInSelectedGroup").addClass('hidden');
|
||||
$("input#moreContent").show();
|
||||
|
||||
pageManagementUtils.headerBar.show();
|
||||
//$('select#selectClassGroup option').eq(0).attr('selected', 'selected');
|
||||
pageManagementUtils.classesForClassGroup.addClass('hidden');
|
||||
pageManagementUtils.moreContentButton.show();
|
||||
}
|
||||
if ( $("#typeSelect").val() == "" ) {
|
||||
$("section#classGroup").hide();
|
||||
$("section#nonClassGroup").hide();
|
||||
$("input#moreContent").hide();
|
||||
$('select#selectClassGroup option').eq(0).attr('selected', 'selected');
|
||||
$("section#classesInSelectedGroup").addClass('hidden');
|
||||
$("section#headerBar").hide();
|
||||
$("section#headerBar").text("");
|
||||
if ( _this.contentTypeSelect.val() == "" ) {
|
||||
pageManagementUtils.classGroupSection.hide();
|
||||
pageManagementUtils.fixedHTMLSection.hide();
|
||||
pageManagementUtils.sparqlQuerySection.hide();
|
||||
|
||||
pageManagementUtils.moreContentButton.hide();
|
||||
|
||||
//$('select#selectClassGroup option').eq(0).attr('selected', 'selected');
|
||||
|
||||
pageManagementUtils.classesForClassGroup.addClass('hidden');
|
||||
pageManagementUtils.headerBar.hide();
|
||||
pageManagementUtils.headerBar.text("");
|
||||
}
|
||||
pageManagementUtils.adjustSaveButtonHeight();
|
||||
});
|
||||
|
@ -194,13 +214,17 @@ var pageManagementUtils = {
|
|||
});*/
|
||||
|
||||
//Submission: validate as well as create appropriate hidden json inputs
|
||||
$("form").submit(function () {
|
||||
$("form").submit(function (event) {
|
||||
var validationError = pageManagementUtils.validateMenuItemForm();
|
||||
if (validationError == "") {
|
||||
//Create the appropriate json objects
|
||||
pageManagementUtils.createPageContentForSubmission();
|
||||
//return true;
|
||||
//For testing, not submitting anything
|
||||
//event.preventDefault();
|
||||
return true;
|
||||
} else{
|
||||
|
||||
$('#error-alert').removeClass('hidden');
|
||||
$('#error-alert p').html(validationError);
|
||||
//TODO: Check why scrolling appears to be a problem
|
||||
|
@ -209,69 +233,48 @@ var pageManagementUtils = {
|
|||
}
|
||||
});
|
||||
|
||||
},
|
||||
//Clear values in content areas that are cloned to create the page content type specific sections
|
||||
//i.e. reset sparql query/class group areas
|
||||
//TODO: Check if reset is more what we need here?
|
||||
clearSourceTemplateValues:function() {
|
||||
//inputs, textareas
|
||||
pageManagementUtils.clearInputs(pageManagementUtils.fixedHTMLSection);
|
||||
pageManagementUtils.clearInputs(pageManagementUtils.sparqlQuerySection);
|
||||
pageManagementUtils.clearInputs(pageManagementUtils.classGroupSection);
|
||||
|
||||
},
|
||||
clearInputs:function($el) {
|
||||
//jquery selector :input selects all input text area select and button elements
|
||||
$el.find("input").val("");
|
||||
$el.find("textarea").val("");
|
||||
//resetting class group section as well so selection is reset if type changes
|
||||
$el.find("select option:eq(0)").attr("selected", "selected");
|
||||
|
||||
},
|
||||
//Clone content area
|
||||
cloneContentArea: function(contentType, contentTypeLabel) {
|
||||
var ctr = pageManagementUtils.counter;
|
||||
var counter = pageManagementUtils.counter;
|
||||
var varOrClas;
|
||||
var varOrClass;
|
||||
|
||||
//Clone the object, renaming ids and copying text area values as well
|
||||
$newContentObj = pageManagementUtils.createCloneObject(contentType, counter);
|
||||
|
||||
if ( contentType == "fixedHTML" || contentType == "sparqlQuery" ) {
|
||||
var taValue = $('textarea#textArea').val();
|
||||
alert("original text area value is " + taValue);
|
||||
var $newContentObj = $('section#nonClassGroup').clone();
|
||||
$newContentObj.addClass("pageContent");
|
||||
varOrClass = $newContentObj.find('input').val();
|
||||
$newContentObj.show();
|
||||
//Save content type
|
||||
$newContentObj.attr("contentType", contentType);
|
||||
$newContentObj.attr("id", contentType + counter);
|
||||
$newContentObj.find('input#variable').attr("id","variable" + counter);
|
||||
$newContentObj.find('textarea#textArea').attr("id","textArea" + counter);
|
||||
$newContentObj.find('label#variableLabel').attr("id","variableLabel" + counter);
|
||||
$newContentObj.find('label#taLabel').attr("id","taLabel" + counter);
|
||||
|
||||
//Keep the name of the inputs the same
|
||||
// $newContentObj.find('input#variable').attr("name","variable" + counter);
|
||||
// $newContentObj.find('textarea#textArea').attr("name","textArea" + counter);
|
||||
// There's a jquery bug when cloning textareas: the value doesn't
|
||||
// get cloned. So
|
||||
// copy the value "manually."
|
||||
$newContentObj.find("textarea[name='textArea']").val(taValue);
|
||||
}
|
||||
if ( contentType == "sparqlQuery" || contentType == "fixedHtml") {
|
||||
varOrClass = $newContentObj.find('input[name="saveToVar"]').val();
|
||||
}
|
||||
else if ( contentType == "browseClassGroup" ) {
|
||||
|
||||
var $newContentObj = $('section#classGroup').clone();
|
||||
|
||||
$newContentObj.addClass("pageContent");
|
||||
$newContentObj.show();
|
||||
$newContentObj.attr("contentType", contentType);
|
||||
$newContentObj.attr("id", "classGroup" + counter);
|
||||
$newContentObj.find('section#selectContentType').attr("id", "selectContentType" + counter);
|
||||
$newContentObj.find('select#selectClassGroup').val(groupValue);
|
||||
$newContentObj.find('select#selectClassGroup').attr("id","selectClassGroup" + counter);
|
||||
$newContentObj.find('select#selectClassGroup' + counter).attr("name","selectClassGroup" + counter);
|
||||
$newContentObj.find('section#classesInSelectedGroup').attr("id","classesInSelectedGroup" + counter);
|
||||
$newContentObj.find('section#classesInSelectedGroup' + counter).removeClass('hidden');
|
||||
$newContentObj.find('p#selectClassesMessage').attr("id","selectClassesMessage" + counter);
|
||||
// Will need to uncomment this and find a way to apply the css style
|
||||
// $newContentObj.find('section#internal-class').attr("id","internal-class" +
|
||||
// counter);
|
||||
$newContentObj.find("input[name='display-internalClass']").attr("name","display-internalClass" + counter);
|
||||
$newContentObj.find('ul#selectedClasses').attr("id","selectedClasses" + counter);
|
||||
$newContentObj.find('ul#selectedClasses' + counter).attr("name","selectedClasses" + counter);
|
||||
|
||||
$newContentObj.find('ul#selectedClasses' + counter).children("li").each( function(i,abc) {
|
||||
var $theCheckbox = $(this).find('input');
|
||||
$theCheckbox.attr("name", $theCheckbox.attr("name") + counter);
|
||||
});
|
||||
|
||||
varOrClass = $newContentObj.find('select#selectClassGroup' + counter + ' option:selected').text();
|
||||
$newContentObj.find('section#classesInSelectedGroup' + counter).removeClass('hidden');
|
||||
varOrClass = $newContentObj.find('select#selectClassGroup' + counter + ' option:selected').text();
|
||||
}
|
||||
|
||||
pageManagementUtils.createClonedContentContainer($newContentObj, counter, contentTypeLabel, varOrClass);
|
||||
//previously increased by 10, just increasing by 1 here
|
||||
pageManagementUtils.counter++;
|
||||
},
|
||||
createClonedContentContainer:function($newContentObj, counter, contentTypeLabel, varOrClass) {
|
||||
//Create the container for the new content
|
||||
|
||||
$newDivContainer = $("<div></div>", {
|
||||
id: "divContainer" + counter,
|
||||
"class": "pageContentContainer",
|
||||
|
@ -281,10 +284,20 @@ var pageManagementUtils = {
|
|||
+ "' class='pageContentWrapper'><input id='remove" + counter
|
||||
+ "' type='button' class='delete' value='Delete' class='deleteButton' /></div>"
|
||||
});
|
||||
var $clickableSpan = $newDivContainer.children('span#clickable' + counter);
|
||||
//Hide inner div
|
||||
var $innerDiv = $newDivContainer.children('div#innerContainer' + counter);
|
||||
$innerDiv.hide();
|
||||
//Expand/collapse toggle
|
||||
//Bind event listers for the new content for display/removal etc.
|
||||
pageManagementUtils.bindClonedContentContainerEvents($newDivContainer, counter);
|
||||
//Append the new container to the section storing these containers
|
||||
$newDivContainer.appendTo($('section#contentDivs'));
|
||||
//place new content object
|
||||
$newContentObj.prependTo($innerDiv);
|
||||
},
|
||||
bindClonedContentContainerEvents:function($newDivContainer, counter) {
|
||||
var $clickableSpan = $newDivContainer.children('span#clickable' + counter);
|
||||
var $innerDiv = $newDivContainer.children('div#innerContainer' + counter);
|
||||
//Expand/collapse toggle
|
||||
$clickableSpan.click(function() {
|
||||
if ( $innerDiv.is(':visible') ) {
|
||||
$innerDiv.slideUp(222);
|
||||
|
@ -302,26 +315,20 @@ var pageManagementUtils = {
|
|||
}
|
||||
window.setTimeout('pageManagementUtils.adjustSaveButtonHeight()', 223);
|
||||
});
|
||||
//remove button
|
||||
$newRemoveButton = $innerDiv.find('input#remove' + counter);
|
||||
// this will have to disable submitted fields as well as hide them.
|
||||
$newRemoveButton.click(function() {
|
||||
$innerDiv.parent("div").css("display","none");
|
||||
pageManagementUtils.adjustSaveButtonHeight();
|
||||
});
|
||||
|
||||
$newDivContainer.appendTo($('section#contentDivs'));
|
||||
$newContentObj.prependTo($innerDiv);
|
||||
counter = counter + 10;
|
||||
},
|
||||
resetClassGroupSection:function() {
|
||||
$('select#selectClassGroup option').eq(0).attr('selected', 'selected');
|
||||
$("section#classesInSelectedGroup").addClass('hidden');
|
||||
},
|
||||
//finalize later, but basically use same attribute across page content and use attribute instead of id
|
||||
//Attribute would be what keeps track of content, so contentCounter or something like that
|
||||
toggleArrow:function() {
|
||||
|
||||
|
||||
//doing this in clear inputs instead which will be triggered
|
||||
//every time content type is changed AS well as on more content button after
|
||||
//original content is cloned and stored
|
||||
//$('select#selectClassGroup option').eq(0).attr('selected', 'selected');
|
||||
pageManagementUtils.classesForClassGroup.addClass('hidden');
|
||||
},
|
||||
//Adjust save button height
|
||||
adjustSaveButtonHeight:function() {
|
||||
|
@ -345,7 +352,6 @@ var pageManagementUtils = {
|
|||
|
||||
} else {
|
||||
//update existing content type with correct class group name and hide class group select again
|
||||
var _this = pageManagementUtils;
|
||||
// pageManagementUtils.hideClassGroups();
|
||||
|
||||
pageManagementUtils.selectedGroupForPage.html(results.classGroupName);
|
||||
|
@ -372,14 +378,14 @@ var pageManagementUtils = {
|
|||
|
||||
//From NEW code
|
||||
if (pageManagementUtils.selectClassGroupDropdown.val() == "" ) {
|
||||
$("section#classesInSelectedGroup").addClass('hidden');
|
||||
pageManagementUtils.classesForClassGroup.addClass('hidden');
|
||||
$("div#leftSide").css("height","");
|
||||
$("input#moreContent").hide();
|
||||
pageManagementUtils.moreContentButton.hide();
|
||||
|
||||
}
|
||||
else {
|
||||
$("section#classesInSelectedGroup").removeClass('hidden');
|
||||
$("input#moreContent").show();
|
||||
pageManagementUtils.classesForClassGroup.removeClass('hidden');
|
||||
pageManagementUtils.moreContentButton.show();
|
||||
if ( $("div#leftSide").height() < $("div#rightSide").height() ) {
|
||||
$("div#leftSide").css("height",$("div#rightSide").height() + "px");
|
||||
}
|
||||
|
@ -390,39 +396,24 @@ var pageManagementUtils = {
|
|||
|
||||
});
|
||||
},
|
||||
/*
|
||||
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');
|
||||
// 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
|
||||
$('input:checkbox[name=classInClassGroup]').removeAttr('checked');
|
||||
$(this).closest("ul").find('input:checkbox[name=classInClassGroup]').removeAttr('checked');
|
||||
|
||||
// $('input:checkbox[name=classInClassGroup]').removeAttr('checked');
|
||||
}
|
||||
});
|
||||
|
||||
$('input:checkbox[name=classInClassGroup]').click(function(){
|
||||
$('input:checkbox[name=allSelected]').removeAttr('checked');
|
||||
$(this).closest(ul).find('input:checkbox[name=allSelected]').removeAttr('checked');
|
||||
});
|
||||
}, //This is SPECIFIC to VIVO so should be moved there
|
||||
updateInternalClassMessage:function(classGroupName) { //User has changed content type
|
||||
|
@ -482,29 +473,63 @@ var pageManagementUtils = {
|
|||
//Create a new hidden input with a specific name and assign value per page content
|
||||
pageManagementUtils.createPageContentInputForSubmission(jsonObjectString);
|
||||
});
|
||||
//in this case it's a sparql data getter, but what about the others
|
||||
/*
|
||||
var len = pageContentSections.length;
|
||||
var i;
|
||||
for(i = 0; i < len; i++) {
|
||||
var pageContentSection = $(pageContentSections[i]);
|
||||
var pageContentSectionId = pageContentSection.attr("id");
|
||||
var jsonObject = pageManagementUtils.processPageContentSection(pageContentSection);
|
||||
var jsonObjectString = JSON.stringify(jsonObject);
|
||||
//Create a new hidden input with a specific name and assign value per page content
|
||||
pageManagementUtils.createPageContentInputForSubmission(jsonObjectString);
|
||||
}*/
|
||||
|
||||
},
|
||||
createPageContentInputForSubmission: function(inputValue) {
|
||||
$("<input type='hidden' name='pageContentUnit' value='" + inputValue + "'>").appendTo(pageManagementUtils.pageContentSubmissionInputs);
|
||||
},
|
||||
//returns a json object with the data getter information required
|
||||
processPageContentSection:function(pageContentSection) {
|
||||
|
||||
var variableValue = pageContentSection.find("input[name='variable']").val();
|
||||
var queryValue = pageContentSection.find("textarea[name='textArea']").val();
|
||||
var returnObject = {saveToVar:variableValue, query:queryValue, dataGetterClass:pageManagementUtils.dataGetterLabelToURI["sparqlDataGetter"], queryModel:"vitro:contextDisplayModel"};
|
||||
return returnObject;
|
||||
//This processing should be specific to the type and so that content type's specific processor will
|
||||
//return the json object required
|
||||
if(pageManagementUtils.processDataGetterUtils != null) {
|
||||
var dataGetterType = pageManagementUtils.processDataGetterUtils.selectDataGetterType(pageContentSection);
|
||||
if(pageManagementUtils.dataGetterProcessorMap != null) {
|
||||
var dataGetterProcessor = pageManagementUtils.dataGetterProcessorMap[dataGetterType];
|
||||
//the content type specific processor will create the json object to be returned
|
||||
var jsonObject = dataGetterProcessor.processPageContentSection(pageContentSection);
|
||||
return jsonObject;
|
||||
} else {
|
||||
//ERROR handling
|
||||
alert("An error has occurred and the map of processors for this content is missing. Please contact the administrator");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
alert("An error has occurred and the code for processing this content is missing a component. Please contact the administrator.");
|
||||
//Error handling here
|
||||
return null;
|
||||
},
|
||||
//clones and returns cloned object for content type
|
||||
createCloneObject:function(contentType, counter) {
|
||||
var originalObjectPath = 'section#' + contentType;
|
||||
var $newContentObj = $(originalObjectPath).clone();
|
||||
$newContentObj.addClass("pageContent");
|
||||
//Save content type
|
||||
$newContentObj.attr("contentType", contentType);
|
||||
//Set id for object
|
||||
$newContentObj.attr("id", contentType + counter);
|
||||
$newContentObj.show();
|
||||
pageManagementUtils.renameIdsInClone($newContentObj, counter);
|
||||
// pageManagementUtils.cloneTextAreaValues(originalObjectPath, $newContentObj);
|
||||
return $newContentObj;
|
||||
},
|
||||
//This is specifically for cloning text area values
|
||||
//May not need this if implementing the jquery fix
|
||||
///would need a similar function for select as well
|
||||
cloneTextAreaValues:function(originalAncestorPath, $newAncestorObject) {
|
||||
$(originalAncestorPath + " textarea").each(function(index, el) {
|
||||
var originalTextAreaValue = $(this).val();
|
||||
var originalTextAreaName = $(this).attr("name");
|
||||
$newAncestorObject.find("textarea[name='" + originalTextAreaName + "']").val(originalTextAreaValue);
|
||||
});
|
||||
},
|
||||
//given an object and a counter, rename all the ids
|
||||
renameIdsInClone:function($newContentObj, counter) {
|
||||
$newContentObj.find("[id]").each(function(index, el) {
|
||||
var originalId = $(this).attr("id");
|
||||
var newId = originalId + counter;
|
||||
$(this).attr("id", newId);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
|
21
webapp/web/js/menupage/processClassGroupDataGetterContent.js
Normal file
21
webapp/web/js/menupage/processClassGroupDataGetterContent.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
|
||||
}
|
29
webapp/web/js/menupage/processDataGetterUtils.js
Normal file
29
webapp/web/js/menupage/processDataGetterUtils.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* $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;
|
||||
}
|
||||
};
|
20
webapp/web/js/menupage/processFixedHTMLDataGetterContent.js
Normal file
20
webapp/web/js/menupage/processFixedHTMLDataGetterContent.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
//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();
|
||||
//query model should also be an input
|
||||
var returnObject = {saveToVar:saveToVarValue, htmlValue:htmlValue, dataGetterClass:this.dataGetterClass};
|
||||
return returnObject;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/* $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;
|
||||
}
|
||||
|
||||
}
|
23
webapp/web/js/menupage/processSparqlDataGetterContent.js
Normal file
23
webapp/web/js/menupage/processSparqlDataGetterContent.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
//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();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
};
|
449
webapp/web/js/openSocial/shindig.js
Normal file
449
webapp/web/js/openSocial/shindig.js
Normal file
|
@ -0,0 +1,449 @@
|
|||
/*
|
||||
Profiles Shindig Helper functions for gadget-to-container commands
|
||||
|
||||
*/
|
||||
|
||||
// dummy function so google analytics does not break for institutions who do not use it
|
||||
|
||||
_gaq = {};
|
||||
_gaq.push = function(data) { //
|
||||
};
|
||||
|
||||
// pubsub
|
||||
gadgets.pubsubrouter.init(function(id) {
|
||||
return my.gadgets[shindig.container.gadgetService.getGadgetIdFromModuleId(id)].url;
|
||||
}, {
|
||||
onSubscribe: function(sender, channel) {
|
||||
setTimeout("my.onSubscribe('" + sender + "', '" + channel + "')", 3000);
|
||||
// return true to reject the request.
|
||||
return false;
|
||||
},
|
||||
onUnsubscribe: function(sender, channel) {
|
||||
//alert(sender + " unsubscribes from channel '" + channel + "'");
|
||||
// return true to reject the request.
|
||||
return false;
|
||||
},
|
||||
onPublish: function(sender, channel, message) {
|
||||
// return true to reject the request.
|
||||
|
||||
// track with google analytics
|
||||
if (sender != '..' ) {
|
||||
var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(sender);
|
||||
}
|
||||
|
||||
if (channel == 'VISIBLE') {
|
||||
var statusId = document.getElementById(sender + '_status');
|
||||
if (statusId) {
|
||||
// only act on these in HOME view since they are only meant to be seen when viewer=owner
|
||||
if (my.gadgets[moduleId].view != 'home') {
|
||||
return true;
|
||||
}
|
||||
if (message == 'Y') {
|
||||
statusId.style.color = 'GREEN';
|
||||
statusId.innerHTML = 'This section is VISIBLE';
|
||||
if (my.gadgets[moduleId].visible_scope == 'U') {
|
||||
statusId.innerHTML += ' to UCSF';
|
||||
}
|
||||
else {
|
||||
statusId.innerHTML += ' to the public';
|
||||
}
|
||||
}
|
||||
else {
|
||||
statusId.style.color = '#CC0000';
|
||||
statusId.innerHTML = 'This section is HIDDEN';
|
||||
if (my.gadgets[moduleId].visible_scope == 'U') {
|
||||
statusId.innerHTML += ' from UCSF';
|
||||
}
|
||||
else {
|
||||
statusId.innerHTML += ' from the public';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (channel == 'added' && my.gadgets[moduleId].view == 'home') {
|
||||
if (message == 'Y') {
|
||||
_gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'SHOW', 'profile_edit_view']);
|
||||
osapi.activities.create(
|
||||
{ 'userId': gadgets.util.getUrlParameters()['Person'],
|
||||
'appId': my.gadgets[moduleId].appId,
|
||||
'activity': {'postedTime': new Date().getTime(), 'title': 'added a gadget', 'body': 'added the ' + my.gadgets[moduleId].name + ' gadget to their profile' }
|
||||
}).execute(function(response){});
|
||||
}
|
||||
else {
|
||||
_gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'HIDE', 'profile_edit_view']);
|
||||
}
|
||||
}
|
||||
else if (channel == 'status') {
|
||||
// message should be of the form 'COLOR:Message Content'
|
||||
var statusId = document.getElementById(sender + '_status');
|
||||
if (statusId) {
|
||||
var messageSplit = message.split(':');
|
||||
if (messageSplit.length == 2) {
|
||||
statusId.style.color = messageSplit[0];
|
||||
statusId.innerHTML = messageSplit[1];
|
||||
}
|
||||
else {
|
||||
statusId.innerHTML = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (channel == 'analytics') {
|
||||
// publish to google analytics
|
||||
// message should be JSON encoding object with required action and optional label and value
|
||||
// as documented here: http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
|
||||
// note that event category will be set to the gadget name automatically by this code
|
||||
// Note: message will be already converted to an object
|
||||
if (message.hasOwnProperty('value')) {
|
||||
_gaq.push(['_trackEvent', my.gadgets[moduleId].name, message.action, message.label, message.value]);
|
||||
}
|
||||
else if (message.hasOwnProperty('label')) {
|
||||
_gaq.push(['_trackEvent', my.gadgets[moduleId].name, message.action, message.label]);
|
||||
}
|
||||
else {
|
||||
_gaq.push(['_trackEvent', my.gadgets[moduleId].name, message.action]);
|
||||
}
|
||||
}
|
||||
else if (channel == 'profile') {
|
||||
_gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'go_to_profile', message]);
|
||||
document.location.href = '/' + location.pathname.split('/')[1] + '/display/n' + message;
|
||||
}
|
||||
else if (channel == 'JSONPersonIds' || channel == 'JSONPubMedIds') {
|
||||
// do nothing, no need to alert
|
||||
}
|
||||
else {
|
||||
alert(sender + " publishes '" + message + "' to channel '" + channel + "'");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// helper functions
|
||||
my.findGadgetsAttachingTo = function(chromeId) {
|
||||
var retval = [];
|
||||
for (var i = 0; i < my.gadgets.length; i++) {
|
||||
if (my.gadgets[i].chrome_id == chromeId) {
|
||||
retval[retval.length] = my.gadgets[i];
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
};
|
||||
|
||||
my.removeGadgets = function(gadgetsToRemove) {
|
||||
for (var i = 0; i < gadgetsToRemove.length; i++) {
|
||||
for (var j = 0; j < my.gadgets.length; j++) {
|
||||
if (gadgetsToRemove[i].url == my.gadgets[j].url) {
|
||||
my.gadgets.splice(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
my.onSubscribe = function(sender, channel) {
|
||||
// lookup pubsub data based on channel and if a match is found, publish the data to that channel after a delay
|
||||
if (my.pubsubData[channel]) {
|
||||
gadgets.pubsubrouter.publish(channel, my.pubsubData[channel]);
|
||||
}
|
||||
else {
|
||||
alert(sender + " subscribes to channel '" + channel + "'");
|
||||
}
|
||||
//PageMethods.onSubscribe(sender, channel, my.pubsubHint, my.CallSuccess, my.CallFailed);
|
||||
};
|
||||
|
||||
my.removeParameterFromURL = function(url, parameter) {
|
||||
var urlparts= url.split('?'); // prefer to use l.search if you have a location/link object
|
||||
if (urlparts.length>=2) {
|
||||
var prefix= encodeURIComponent(parameter)+'=';
|
||||
var pars= urlparts[1].split(/[&;]/g);
|
||||
for (var i= pars.length; i-->0;) //reverse iteration as may be destructive
|
||||
if (pars[i].lastIndexOf(prefix, 0)!==-1) //idiom for string.startsWith
|
||||
pars.splice(i, 1);
|
||||
url= urlparts[0]+'?'+pars.join('&');
|
||||
}
|
||||
return url;
|
||||
};
|
||||
|
||||
// publish the people
|
||||
my.CallSuccess = function(result) {
|
||||
gadgets.pubsubrouter.publish('person', result);
|
||||
};
|
||||
|
||||
// alert message on some failure
|
||||
my.CallFailed = function(error) {
|
||||
alert(error.get_message());
|
||||
};
|
||||
|
||||
my.requestGadgetMetaData = function(view, opt_callback) {
|
||||
var request = {
|
||||
context: {
|
||||
country: "default",
|
||||
language: "default",
|
||||
view: view,
|
||||
ignoreCache : my.noCache,
|
||||
container: "default"
|
||||
},
|
||||
gadgets: []
|
||||
};
|
||||
|
||||
for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
|
||||
// only add those with matching views
|
||||
if (my.gadgets[moduleId].view == view) {
|
||||
request.gadgets[request.gadgets.length] = {'url': my.gadgets[moduleId].url, 'moduleId': moduleId};
|
||||
}
|
||||
}
|
||||
|
||||
var makeRequestParams = {
|
||||
"CONTENT_TYPE" : "JSON",
|
||||
"METHOD" : "POST",
|
||||
"POST_DATA" : gadgets.json.stringify(request)};
|
||||
|
||||
gadgets.io.makeNonProxiedRequest(my.openSocialURL + "/gadgets/metadata",
|
||||
function(data) {
|
||||
data = data.data;
|
||||
if (opt_callback) {
|
||||
opt_callback(data);
|
||||
}
|
||||
},
|
||||
makeRequestParams,
|
||||
"application/javascript"
|
||||
);
|
||||
};
|
||||
|
||||
my.renderableGadgets = [];
|
||||
|
||||
my.generateGadgets = function(metadata) {
|
||||
// put them in moduleId order
|
||||
for (var i = 0; i < metadata.gadgets.length; i++) {
|
||||
var moduleId = metadata.gadgets[i].moduleId;
|
||||
// Notes by Eric. Not sure if I should have to calculate this myself, but I will.
|
||||
var height = metadata.gadgets[i].height;
|
||||
var width = metadata.gadgets[i].width;
|
||||
var viewPrefs = metadata.gadgets[i].views[my.gadgets[moduleId].view];
|
||||
if (viewPrefs) {
|
||||
height = viewPrefs.preferredHeight || height;
|
||||
width = viewPrefs.preferredWidth || width;
|
||||
}
|
||||
my.renderableGadgets[moduleId] = shindig.container.createGadget({'specUrl': metadata.gadgets[i].url, 'secureToken': my.gadgets[moduleId].secureToken,
|
||||
'title': metadata.gadgets[i].title, 'userPrefs': metadata.gadgets[i].userPrefs,
|
||||
'height': height, 'width': width, 'debug': my.debug});
|
||||
// set the metadata for easy access
|
||||
my.renderableGadgets[moduleId].setMetadata(metadata.gadgets[i]);
|
||||
}
|
||||
// this will be called multiple times, only render when all gadgets have been processed
|
||||
var ready = my.renderableGadgets.length == my.gadgets.length;
|
||||
for (var i = 0; ready && i < my.renderableGadgets.length; i++) {
|
||||
if (!my.renderableGadgets[i]) {
|
||||
ready = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
shindig.container.addGadgets(my.renderableGadgets );
|
||||
shindig.container.renderGadgets();
|
||||
}
|
||||
};
|
||||
|
||||
my.init = function() {
|
||||
// overwrite this RPC function. Do it at this level so that rpc.f (this.f) is accessible for getting module ID
|
||||
// gadgets.rpc.register('requestNavigateTo', doProfilesNavigation);
|
||||
|
||||
shindig.container.gadgetClass = ProfilesGadget;
|
||||
shindig.container.layoutManager = new ProfilesLayoutManager();
|
||||
shindig.container.setNoCache(my.noCache);
|
||||
shindig.container.gadgetService = new ProfilesGadgetService();
|
||||
|
||||
// since we render multiple views, we need to do somethign fancy by swapping out this value in getIframeUrl
|
||||
shindig.container.setView('REPLACE_THIS_VIEW');
|
||||
|
||||
// do multiple times as needed if we have multiple views
|
||||
// find out what views are being used and call requestGadgetMetaData for each one
|
||||
var views = {};
|
||||
for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
|
||||
var view = my.gadgets[moduleId].view;
|
||||
if (!views[view]) {
|
||||
views[view] = view;
|
||||
my.requestGadgetMetaData(view, my.generateGadgets);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ProfilesGadgetService
|
||||
|
||||
ProfilesGadgetService = function() {
|
||||
shindig.IfrGadgetService.call(this);
|
||||
};
|
||||
|
||||
ProfilesGadgetService.inherits(shindig.IfrGadgetService);
|
||||
|
||||
ProfilesGadgetService.prototype.requestNavigateTo = function(view, opt_params) {
|
||||
var urlTemplate = gadgets.config.get('views')[view].urlTemplate;
|
||||
var url = urlTemplate || 'OpenSocial.aspx?';
|
||||
|
||||
url += window.location.search.substring(1);
|
||||
|
||||
// remove appId if present
|
||||
url = my.removeParameterFromURL(url, 'appId');
|
||||
|
||||
// Add appId if the URL Template begins with the word 'gadget'
|
||||
if (urlTemplate.toLowerCase().indexOf('gadget') == 0) {
|
||||
var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
|
||||
var appId = my.gadgets[moduleId].appId;
|
||||
url += (url.indexOf('?') != url.length - 1 ? '&' : '') + 'appId=' + appId;
|
||||
}
|
||||
|
||||
if (opt_params) {
|
||||
var paramStr = gadgets.json.stringify(opt_params);
|
||||
if (paramStr.length > 0) {
|
||||
url += (url.indexOf('?') != url.length - 1 ? '&' : '') + 'appParams=' + encodeURIComponent(paramStr);
|
||||
}
|
||||
}
|
||||
if (url && document.location.href.indexOf(url) == -1) {
|
||||
document.location.href = url;
|
||||
}
|
||||
};
|
||||
|
||||
// ProfilesGadget
|
||||
|
||||
ProfilesGadget = function(opt_params) {
|
||||
shindig.Gadget.call(this, opt_params);
|
||||
this.debug = my.debug;
|
||||
this.serverBase_ = my.openSocialURL + "/gadgets/";
|
||||
var gadget = this;
|
||||
var subClass = shindig.IfrGadget;
|
||||
this.metadata = {};
|
||||
for (var name in subClass) if (subClass.hasOwnProperty(name)) {
|
||||
if (name == 'getIframeUrl') {
|
||||
// we need to keep this old one
|
||||
gadget['originalGetIframeUrl'] = subClass[name];
|
||||
}
|
||||
else if (name != 'finishRender') {
|
||||
gadget[name] = subClass[name];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ProfilesGadget.inherits(shindig.BaseIfrGadget);
|
||||
|
||||
ProfilesGadget.prototype.setMetadata = function(metadata) {
|
||||
this.metadata = metadata;
|
||||
};
|
||||
|
||||
ProfilesGadget.prototype.hasFeature = function(feature) {
|
||||
for (var i = 0; i < this.metadata.features.length; i++) {
|
||||
if (this.metadata.features[i] == feature) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
ProfilesGadget.prototype.getAdditionalParams = function() {
|
||||
var params = '';
|
||||
for (var key in my.gadgets[this.id].additionalParams) {
|
||||
params += '&' + key + '=' + my.gadgets[this.id].additionalParams[key];
|
||||
}
|
||||
return params;
|
||||
};
|
||||
|
||||
ProfilesGadget.prototype.finishRender = function(chrome) {
|
||||
window.frames[this.getIframeId()].location = this.getIframeUrl();
|
||||
if (my.gadgets[this.id].start_closed) {
|
||||
this.handleToggle();
|
||||
}
|
||||
else if (chrome) {
|
||||
// set the gadget box width, and remember that we always render as open
|
||||
chrome.style.width = (my.gadgets[this.id].open_width || 600) + 'px';
|
||||
}
|
||||
};
|
||||
|
||||
ProfilesGadget.prototype.getIframeUrl = function() {
|
||||
var url = this.originalGetIframeUrl();
|
||||
return url.replace('REPLACE_THIS_VIEW', my.gadgets[this.id].view);
|
||||
};
|
||||
|
||||
ProfilesGadget.prototype.handleToggle = function() {
|
||||
var gadgetIframe = document.getElementById(this.getIframeId());
|
||||
if (gadgetIframe) {
|
||||
var gadgetContent = gadgetIframe.parentNode;
|
||||
var gadgetImg = document.getElementById('gadgets-gadget-title-image-' + this.id);
|
||||
if (gadgetContent.style.display) {
|
||||
//OPEN
|
||||
gadgetContent.parentNode.style.width = (my.gadgets[this.id].open_width || 600) + 'px';
|
||||
gadgetContent.style.display = '';
|
||||
gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/opensocial/images/openSocial/icon_squareDownArrow.gif';
|
||||
// refresh if certain features require so
|
||||
//if (this.hasFeature('dynamic-height')) {
|
||||
if (my.gadgets[this.id].chrome_id == 'gadgets-search') {
|
||||
this.refresh();
|
||||
document.getElementById(this.getIframeId()).contentWindow.location.reload(true);
|
||||
}
|
||||
|
||||
if (my.gadgets[this.id].view == 'home') {
|
||||
// record in google analytics
|
||||
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN_IN_EDIT', 'profile_edit_view']);
|
||||
}
|
||||
else {
|
||||
osapi.activities.create(
|
||||
{ 'userId': gadgets.util.getUrlParameters()['Person'],
|
||||
'appId': my.gadgets[this.id].appId,
|
||||
'activity': {'postedTime': new Date().getTime(), 'title': 'gadget viewed', 'body': my.gadgets[this.id].name + ' gadget was viewed' }
|
||||
}).execute(function(response){});
|
||||
// record in google analytics
|
||||
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//CLOSE
|
||||
gadgetContent.parentNode.style.width = (my.gadgets[this.id].closed_width || 600) + 'px';
|
||||
gadgetContent.style.display = 'none';
|
||||
gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/opensocial/images/openSocial/icon_squareArrow.gif';
|
||||
if (my.gadgets[this.id].view == 'home') {
|
||||
// record in google analytics
|
||||
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'CLOSE_IN_EDIT', 'profile_edit_view']);
|
||||
}
|
||||
else {
|
||||
// record in google analytics
|
||||
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'CLOSE']);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ProfilesGadget.prototype.getTitleBarContent = function(continuation) {
|
||||
if (my.gadgets[this.id].view == 'canvas') {
|
||||
document.getElementById("gadgets-title").innerHTML = (this.title ? this.title : 'Gadget');
|
||||
continuation('<span class="gadgets-gadget-canvas-title"></span>');
|
||||
}
|
||||
else {
|
||||
continuation(
|
||||
'<div id="' + this.cssClassTitleBar + '-' + this.id +
|
||||
'" class="' + this.cssClassTitleBar + '"><span class="' +
|
||||
this.cssClassTitleButtonBar + '">' +
|
||||
'<a href="#" onclick="shindig.container.getGadget(' + this.id +
|
||||
').handleToggle();return false;" class="' + this.cssClassTitleButton +
|
||||
'"><img id="gadgets-gadget-title-image-' + this.id + '" src="/' + location.pathname.split('/')[1] + '/themes/opensocial/images/openSocial/icon_squareDownArrow.gif"/></a></span> <span id="' +
|
||||
this.getIframeId() + '_title" class="' + this.cssClassTitle + '">' +
|
||||
'<a href="#" onclick="shindig.container.getGadget(' + this.id + ').handleToggle();return false;">' +
|
||||
(this.title ? this.title : 'Gadget') + '</a>' + '</span><span id="' +
|
||||
this.getIframeId() + '_status" class="gadgets-gadget-status"></span></div>');
|
||||
}
|
||||
};
|
||||
|
||||
// ProfilesLayoutManager. Creates a FloatLeftLayoutManager for every chromeId in our gadgets
|
||||
ProfilesLayoutManager = function() {
|
||||
shindig.LayoutManager.call(this);
|
||||
// find out what chromeId's are being used, create a FloatLeftLayoutManager for each
|
||||
this.layoutManagers = {};
|
||||
for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
|
||||
var chromeId = my.gadgets[moduleId].chrome_id;
|
||||
if (!this.layoutManagers[chromeId]) {
|
||||
this.layoutManagers[chromeId] = new shindig.FloatLeftLayoutManager(chromeId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ProfilesLayoutManager.inherits(shindig.LayoutManager);
|
||||
|
||||
ProfilesLayoutManager.prototype.getGadgetChrome = function(gadget) {
|
||||
return this.layoutManagers[my.gadgets[gadget.id].chrome_id].getGadgetChrome(gadget);
|
||||
};
|
|
@ -32,6 +32,7 @@
|
|||
this.form = $('form#classHierarchyForm');
|
||||
this.select = $('select#displayOption');
|
||||
this.addClass = $('input#addClass');
|
||||
this.addGroup = $('input#addGroup');
|
||||
},
|
||||
|
||||
bindEventListeners: function() {
|
||||
|
@ -49,6 +50,10 @@
|
|||
classHierarchyUtils.form.attr("action", "vclass_retry");
|
||||
classHierarchyUtils.form.submit();
|
||||
});
|
||||
this.addGroup.click(function() {
|
||||
classHierarchyUtils.form.attr("action", "editForm?controller=Classgroup");
|
||||
classHierarchyUtils.form.submit();
|
||||
});
|
||||
},
|
||||
|
||||
buildClassHierarchyHtml: function() {
|
||||
|
@ -96,6 +101,7 @@
|
|||
|
||||
getTheChildren: function(node) {
|
||||
var childDetails = "";
|
||||
var subclassString = " ";
|
||||
var ctr = 0
|
||||
$.each(node.children, function() {
|
||||
if ( ctr == 0 ) {
|
||||
|
@ -105,12 +111,18 @@
|
|||
else {
|
||||
childDetails += "<tr><td></td>" ;
|
||||
}
|
||||
|
||||
|
||||
if ( this.children.length == 1 ) {
|
||||
subclassString += "<span style='font-size:0.8em'> (1 subclass)</span>";
|
||||
}
|
||||
else if ( this.children.length > 1 ) {
|
||||
subclassString += "<span style='font-size:0.8em'> (" + this.children.length + " subclasses)</span>";
|
||||
}
|
||||
childDetails += "<td class='subclassCell'><span class='subclassExpandPlus' id='subclassExpand"
|
||||
+ classHierarchyUtils.expandCounter + "'> </span>"
|
||||
+ this.name + "</td></tr><tr><td></td><td><table id='subclassTable"
|
||||
+ this.name + subclassString + "</td></tr><tr><td></td><td><table id='subclassTable"
|
||||
+ classHierarchyUtils.expandCounter + "' class='subclassTable'>";
|
||||
|
||||
subclassString = " ";
|
||||
classHierarchyUtils.clickableSpans.push('subclassExpand' + classHierarchyUtils.expandCounter);
|
||||
|
||||
classHierarchyUtils.expandCounter += 1;
|
||||
|
@ -141,13 +153,13 @@
|
|||
$clickableHeader.click(function() {
|
||||
if ( $clickableHeader.attr('view') == "less" ) {
|
||||
$clickableHeader.addClass("headerSpanMinus");
|
||||
$('table#classHierarchy' + ctr).find('span').addClass("subclassExpandMinus");
|
||||
$('table#classHierarchy' + ctr).find('span.subclassExpandPlus').addClass("subclassExpandMinus");
|
||||
$('table#classHierarchy' + ctr).find('table.subclassTable').show();
|
||||
$clickableHeader.attr('view', 'more' );
|
||||
}
|
||||
else {
|
||||
$clickableHeader.removeClass("headerSpanMinus");
|
||||
$('table#classHierarchy' + ctr).find('span').removeClass("subclassExpandMinus");
|
||||
$('table#classHierarchy' + ctr).find('span.subclassExpandPlus').removeClass("subclassExpandMinus");
|
||||
$('table#classHierarchy' + ctr).find('table.subclassTable').hide();
|
||||
$clickableHeader.attr('view', 'less' );
|
||||
}
|
||||
|
@ -180,14 +192,14 @@
|
|||
if ( classHierarchyUtils.expandAll.text() == "expand all" ) {
|
||||
classHierarchyUtils.expandAll.text("collapse all");
|
||||
$('span.headerSpanPlus').addClass("headerSpanMinus");
|
||||
$('table.classHierarchy').find('span').addClass("subclassExpandMinus");
|
||||
$('table.classHierarchy').find('span.subclassExpandPlus').addClass("subclassExpandMinus");
|
||||
$('table.classHierarchy').find('table.subclassTable').show();
|
||||
$('section#container').find('span.headerSpanPlus').attr('view','more');
|
||||
}
|
||||
else {
|
||||
classHierarchyUtils.expandAll.text("expand all");
|
||||
$('span.headerSpanPlus').removeClass("headerSpanMinus");
|
||||
$('table.classHierarchy').find('span').removeClass("subclassExpandMinus");
|
||||
$('table.classHierarchy').find('span.subclassExpandPlus').removeClass("subclassExpandMinus");
|
||||
$('table.classHierarchy').find('table.subclassTable').hide();
|
||||
$('section#container').find('span.headerSpanPlus').attr('view','less');
|
||||
}
|
||||
|
|
293
webapp/web/js/siteAdmin/objectPropertyHierarchyUtils.js
Normal file
293
webapp/web/js/siteAdmin/objectPropertyHierarchyUtils.js
Normal file
|
@ -0,0 +1,293 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
var objectPropHierarchyUtils = {
|
||||
onLoad: function(urlBase,displayOption,type) {
|
||||
this.imagePath = urlBase + "/images/";
|
||||
this.propType = type;
|
||||
this.initObjects();
|
||||
this.expandAll.hide();
|
||||
this.checkJsonTree();
|
||||
|
||||
if ( noProps ) {
|
||||
this.buildNoPropsHtml();
|
||||
}
|
||||
else if ( displayOption == "all" ) {
|
||||
this.buildAllPropsHtml();
|
||||
}
|
||||
else {
|
||||
this.buildPropertyHierarchyHtml();
|
||||
this.wireExpandLink();
|
||||
}
|
||||
|
||||
if ( displayOption == "hierarchy" ) {
|
||||
this.expandAll.show();
|
||||
}
|
||||
this.bindEventListeners();
|
||||
},
|
||||
|
||||
initObjects: function() {
|
||||
this.expandAll = $('span#expandAll').find('a');
|
||||
this.classCounter = 1;
|
||||
this.expandCounter = 1;
|
||||
this.classHtml = "";
|
||||
this.clickableSpans = [] ;
|
||||
this.form = $('form#classHierarchyForm');
|
||||
this.select = $('select#displayOption');
|
||||
this.addProperty = $('input#addProperty');
|
||||
noProps = new Boolean;
|
||||
},
|
||||
|
||||
bindEventListeners: function() {
|
||||
if ( this.propType == "object" ) {
|
||||
this.select.change(function() {
|
||||
if ( objectPropHierarchyUtils.select.val() == "all") {
|
||||
objectPropHierarchyUtils.form.attr("action", "listPropertyWebapps");
|
||||
}
|
||||
else {
|
||||
objectPropHierarchyUtils.form.attr("action", "showObjectPropertyHierarchy");
|
||||
}
|
||||
objectPropHierarchyUtils.form.submit();
|
||||
});
|
||||
|
||||
this.addProperty.click(function() {
|
||||
objectPropHierarchyUtils.form.attr("action", "editForm?controller=Property");
|
||||
objectPropHierarchyUtils.form.submit();
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.select.change(function() {
|
||||
if ( objectPropHierarchyUtils.select.val() == "all") {
|
||||
objectPropHierarchyUtils.form.attr("action", "listDatatypeProperties");
|
||||
}
|
||||
else {
|
||||
objectPropHierarchyUtils.form.attr("action", "showDataPropertyHierarchy");
|
||||
}
|
||||
objectPropHierarchyUtils.form.submit();
|
||||
});
|
||||
|
||||
this.addProperty.click(function() {
|
||||
objectPropHierarchyUtils.form.attr("action", "editForm?controller=Dataprop");
|
||||
objectPropHierarchyUtils.form.submit();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
checkJsonTree: function() {
|
||||
if ( json.length == 1 ) {
|
||||
$.each(json, function() {
|
||||
// check to see whether we have a 'no properties' message or an actual json tree
|
||||
if ( this.name.indexOf("properties") != -1 && this.data == undefined ) {
|
||||
noProps = true;
|
||||
}
|
||||
else {
|
||||
noProps = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
noProps = false;
|
||||
}
|
||||
},
|
||||
|
||||
buildPropertyHierarchyHtml: function() {
|
||||
|
||||
$.each(json, function() {
|
||||
$newClassSection = jQuery("<section></section>", {
|
||||
id: "classContainer" + objectPropHierarchyUtils.classCounter
|
||||
});
|
||||
var descendants = "";
|
||||
var headerSpan = "";
|
||||
|
||||
if ( this.children.length ) {
|
||||
descendants = objectPropHierarchyUtils.getTheChildren(this);
|
||||
headerSpan = "<span class='headerSpanPlus' id='headerSpan" + objectPropHierarchyUtils.classCounter
|
||||
+ "' view='less'> </span>";
|
||||
}
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<div>" + this.name + headerSpan + "</div>" + "<table class='classHierarchy' id='classHierarchy"
|
||||
+ objectPropHierarchyUtils.classCounter + "'>" ;
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<tr><td class='classDetail'>Local Name:</td><td>"
|
||||
+ (this.data.internalName.length > 0 ? this.data.internalName : "none" ) + "</td></tr>";
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<tr><td class='classDetail'>Group:</td><td>"
|
||||
+ (this.data.group.length > 0 ? this.data.group : "unspecified" ) + "</td></tr>";
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<tr><td class='classDetail'>Domain Class:</td><td>"
|
||||
+ (this.data.domainVClass.length > 0 ? this.data.domainVClass : "none" ) + " ";
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<span class='rangeClass'>Range Class:</span>"
|
||||
+ (this.data.rangeVClass.length > 0 ? this.data.rangeVClass : "none" ) + "</td></tr>";
|
||||
|
||||
|
||||
objectPropHierarchyUtils.classHtml += descendants;
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "</table>";
|
||||
// alert(objectPropHierarchyUtils.classHtml);
|
||||
$newClassSection.html(objectPropHierarchyUtils.classHtml);
|
||||
$newClassSection.appendTo($('section#container'));
|
||||
objectPropHierarchyUtils.makeHeaderSpansClickable(objectPropHierarchyUtils.classCounter);
|
||||
objectPropHierarchyUtils.makeSubpropertySpansClickable();
|
||||
objectPropHierarchyUtils.clickableSpans = [] ;
|
||||
objectPropHierarchyUtils.classHtml = "";
|
||||
objectPropHierarchyUtils.classCounter += 1;
|
||||
});
|
||||
},
|
||||
|
||||
getTheChildren: function(node) {
|
||||
var childDetails = "";
|
||||
var subclassString = " ";
|
||||
var ctr = 0
|
||||
$.each(node.children, function() {
|
||||
if ( ctr == 0 ) {
|
||||
childDetails += "<tr><td class='classDetail'>Subproperties:</td>";
|
||||
ctr = ctr + 1;
|
||||
}
|
||||
else {
|
||||
childDetails += "<tr><td></td>" ;
|
||||
}
|
||||
|
||||
if ( this.children.length == 1 ) {
|
||||
subclassString += "<span style='font-size:0.8em'> (1 subclass)</span>";
|
||||
}
|
||||
else if ( this.children.length > 1 ) {
|
||||
subclassString += "<span style='font-size:0.8em'> (" + this.children.length + " subclasses)</span>";
|
||||
}
|
||||
|
||||
childDetails += "<td class='subclassCell' colspan='2'><span class='subclassExpandPlus' id='subclassExpand"
|
||||
+ objectPropHierarchyUtils.expandCounter + "'> </span>"
|
||||
+ this.name + subclassString + "</td></tr><tr><td></td><td colspan='2'><table id='subclassTable"
|
||||
+ objectPropHierarchyUtils.expandCounter + "' class='subclassTable'>";
|
||||
|
||||
subclassString = " ";
|
||||
|
||||
objectPropHierarchyUtils.clickableSpans.push('subclassExpand' + objectPropHierarchyUtils.expandCounter);
|
||||
|
||||
objectPropHierarchyUtils.expandCounter += 1;
|
||||
|
||||
childDetails += "<tr><td class='classDetail'>Local Name:</td><td>"
|
||||
+ (this.data.internalName.length > 0 ? this.data.internalName : "none" ) + "</td></tr>";
|
||||
|
||||
childDetails += "<tr><td class='classDetail'>Group:</td><td>"
|
||||
+ (this.data.group.length > 0 ? this.data.group : "unspecified" ) + "</td></tr>";
|
||||
|
||||
childDetails += "<tr><td class='classDetail'>Domain Class:</td><td>"
|
||||
+ (this.data.domainVClass.length > 0 ? this.data.domainVClass : "none" ) + " ";
|
||||
|
||||
childDetails += "<span class='rangeClass'>Range Class:</span>"
|
||||
+ (this.data.rangeVClass.length > 0 ? this.data.rangeVClass : "none" ) + "</td></tr>";
|
||||
|
||||
if ( this.children ) {
|
||||
var grandChildren = objectPropHierarchyUtils.getTheChildren(this);
|
||||
childDetails += grandChildren;
|
||||
}
|
||||
});
|
||||
childDetails += "</table></td></tr>";
|
||||
return childDetails;
|
||||
},
|
||||
|
||||
makeHeaderSpansClickable: function(ctr) {
|
||||
|
||||
var $clickableHeader = $('section#classContainer' + ctr).find('span.headerSpanPlus');
|
||||
|
||||
$clickableHeader.click(function() {
|
||||
if ( $clickableHeader.attr('view') == "less" ) {
|
||||
$clickableHeader.addClass("headerSpanMinus");
|
||||
$('table#classHierarchy' + ctr).find('span.subclassExpandPlus').addClass("subclassExpandMinus");
|
||||
$('table#classHierarchy' + ctr).find('table.subclassTable').show();
|
||||
$clickableHeader.attr('view', 'more' );
|
||||
}
|
||||
else {
|
||||
$clickableHeader.removeClass("headerSpanMinus");
|
||||
$('table#classHierarchy' + ctr).find('span.subclassExpandPlus').removeClass("subclassExpandMinus");
|
||||
$('table#classHierarchy' + ctr).find('table.subclassTable').hide();
|
||||
$clickableHeader.attr('view', 'less' );
|
||||
}
|
||||
});
|
||||
},// $('myOjbect').css('background-image', 'url(' + imageUrl + ')');
|
||||
|
||||
makeSubpropertySpansClickable: function() {
|
||||
$.each(objectPropHierarchyUtils.clickableSpans, function() {
|
||||
var currentSpan = this;
|
||||
var $clickableSpan = $('section#container').find('span#' + currentSpan);
|
||||
var $subclassTable = $('section#container').find('table#subclassTable' + currentSpan.replace("subclassExpand",""));
|
||||
|
||||
$clickableSpan.click(function() {
|
||||
if ( $subclassTable.is(':visible') ) {
|
||||
$subclassTable.hide();
|
||||
$subclassTable.find('table.subclassTable').hide();
|
||||
$subclassTable.find('span').removeClass("subclassExpandMinus");
|
||||
$clickableSpan.removeClass("subclassExpandMinus");
|
||||
}
|
||||
else {
|
||||
$subclassTable.show();
|
||||
$clickableSpan.addClass("subclassExpandMinus");
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
wireExpandLink: function() {
|
||||
this.expandAll.click(function() {
|
||||
if ( objectPropHierarchyUtils.expandAll.text() == "expand all" ) {
|
||||
objectPropHierarchyUtils.expandAll.text("collapse all");
|
||||
$('span.headerSpanPlus').addClass("headerSpanMinus");
|
||||
$('table.classHierarchy').find('span.subclassExpandPlus').addClass("subclassExpandMinus");
|
||||
$('table.classHierarchy').find('table.subclassTable').show();
|
||||
$('section#container').find('span.headerSpanPlus').attr('view','more');
|
||||
}
|
||||
else {
|
||||
objectPropHierarchyUtils.expandAll.text("expand all");
|
||||
$('span.headerSpanPlus').removeClass("headerSpanMinus");
|
||||
$('table.classHierarchy').find('span.subclassExpandPlus').removeClass("subclassExpandMinus");
|
||||
$('table.classHierarchy').find('table.subclassTable').hide();
|
||||
$('section#container').find('span.headerSpanPlus').attr('view','less');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
buildAllPropsHtml: function() {
|
||||
|
||||
$.each(json, function() {
|
||||
$newClassSection = jQuery("<section></section>", {
|
||||
id: "classContainer" + objectPropHierarchyUtils.classCounter
|
||||
});
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<div>" + this.name + "</div>" + "<table class='classHierarchy' id='classHierarchy"
|
||||
+ objectPropHierarchyUtils.classCounter + "'>" ;
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<tr><td class='classDetail'>Local Name:</td><td>"
|
||||
+ (this.data.internalName.length > 0 ? this.data.internalName : "none" ) + "</td></tr>";
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<tr><td class='classDetail'>Group:</td><td>"
|
||||
+ (this.data.group.length > 0 ? this.data.group : "unspecified" ) + "</td></tr>";
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<tr><td class='classDetail'>Domain Class:</td><td>"
|
||||
+ (this.data.domainVClass.length > 0 ? this.data.domainVClass : "none" ) + " ";
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "<span class='rangeClass'>Range Class:</span>"
|
||||
+ (this.data.rangeVClass.length > 0 ? this.data.rangeVClass : "none" ) + "</td></tr>";
|
||||
|
||||
objectPropHierarchyUtils.classHtml += "</table>";
|
||||
|
||||
$newClassSection.html(objectPropHierarchyUtils.classHtml);
|
||||
$newClassSection.appendTo($('section#container'));
|
||||
objectPropHierarchyUtils.classHtml = "";
|
||||
objectPropHierarchyUtils.classCounter += 1;
|
||||
});
|
||||
},
|
||||
|
||||
buildNoPropsHtml: function() {
|
||||
|
||||
$.each(json, function() {
|
||||
$newClassSection = jQuery("<section></section>", {
|
||||
id: "classContainer" + objectPropHierarchyUtils.classCounter
|
||||
});
|
||||
|
||||
objectPropHierarchyUtils.classHtml = "<h4>" + this.name + "</h4>";
|
||||
$newClassSection.html(objectPropHierarchyUtils.classHtml);
|
||||
$newClassSection.appendTo($('section#container'));
|
||||
objectPropHierarchyUtils.classHtml = "";
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue