/* $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("
", { id: "classContainer" + objectPropHierarchyUtils.classCounter }); var descendants = ""; var headerSpan = ""; if ( this.children.length ) { descendants = objectPropHierarchyUtils.getTheChildren(this); headerSpan = " "; } objectPropHierarchyUtils.classHtml += "
" + this.name + headerSpan + "
" + "" ; objectPropHierarchyUtils.classHtml += ""; objectPropHierarchyUtils.classHtml += ""; objectPropHierarchyUtils.classHtml += ""; objectPropHierarchyUtils.classHtml += descendants; objectPropHierarchyUtils.classHtml += "
Local Name:" + (this.data.internalName.length > 0 ? this.data.internalName : "none" ) + "
Group:" + (this.data.group.length > 0 ? this.data.group : "unspecified" ) + "
Domain Class:" + (this.data.domainVClass.length > 0 ? this.data.domainVClass : "none" ) + " "; objectPropHierarchyUtils.classHtml += "Range Class:" + (this.data.rangeVClass.length > 0 ? this.data.rangeVClass : "none" ) + "
"; // 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 += "Subproperties:"; ctr = ctr + 1; } else { childDetails += "" ; } if ( this.children.length == 1 ) { subclassString += " (1 subclass)"; } else if ( this.children.length > 1 ) { subclassString += " (" + this.children.length + " subclasses)"; } childDetails += " " + this.name + subclassString + ""; subclassString = " "; objectPropHierarchyUtils.clickableSpans.push('subclassExpand' + objectPropHierarchyUtils.expandCounter); objectPropHierarchyUtils.expandCounter += 1; childDetails += ""; childDetails += ""; childDetails += ""; if ( this.children ) { var grandChildren = objectPropHierarchyUtils.getTheChildren(this); childDetails += grandChildren; } }); childDetails += "
Local Name:" + (this.data.internalName.length > 0 ? this.data.internalName : "none" ) + "
Group:" + (this.data.group.length > 0 ? this.data.group : "unspecified" ) + "
Domain Class:" + (this.data.domainVClass.length > 0 ? this.data.domainVClass : "none" ) + " "; childDetails += "Range Class:" + (this.data.rangeVClass.length > 0 ? this.data.rangeVClass : "none" ) + "
"; 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("
", { id: "classContainer" + objectPropHierarchyUtils.classCounter }); objectPropHierarchyUtils.classHtml += "
" + this.name + "
" + "" ; objectPropHierarchyUtils.classHtml += ""; objectPropHierarchyUtils.classHtml += ""; objectPropHierarchyUtils.classHtml += ""; objectPropHierarchyUtils.classHtml += "
Local Name:" + (this.data.internalName.length > 0 ? this.data.internalName : "none" ) + "
Group:" + (this.data.group.length > 0 ? this.data.group : "unspecified" ) + "
Domain Class:" + (this.data.domainVClass.length > 0 ? this.data.domainVClass : "none" ) + " "; objectPropHierarchyUtils.classHtml += "Range Class:" + (this.data.rangeVClass.length > 0 ? this.data.rangeVClass : "none" ) + "
"; $newClassSection.html(objectPropHierarchyUtils.classHtml); $newClassSection.appendTo($('section#container')); objectPropHierarchyUtils.classHtml = ""; objectPropHierarchyUtils.classCounter += 1; }); }, buildNoPropsHtml: function() { $.each(json, function() { $newClassSection = jQuery("
", { id: "classContainer" + objectPropHierarchyUtils.classCounter }); objectPropHierarchyUtils.classHtml = "

" + this.name + "

"; $newClassSection.html(objectPropHierarchyUtils.classHtml); $newClassSection.appendTo($('section#container')); objectPropHierarchyUtils.classHtml = ""; }); } }