summaryrefslogtreecommitdiff
path: root/buildscripts/jGrouseDoc/skins/common/js/navTree.js
diff options
context:
space:
mode:
authorCiro Mattia Gonano <ciromattia@gmail.com>2013-09-11 15:56:48 +0200
committerCiro Mattia Gonano <ciromattia@gmail.com>2013-09-11 15:57:07 +0200
commit3069eaf35e833ffe4a1c1c7829dd7e168ae27420 (patch)
treed0c2e4d934cc34ba7d4232f759923b5a257dcb21 /buildscripts/jGrouseDoc/skins/common/js/navTree.js
parentb833247ce597ec26159b46c8dfbea7f1e265950b (diff)
Merge up to r3319
Diffstat (limited to 'buildscripts/jGrouseDoc/skins/common/js/navTree.js')
-rw-r--r--buildscripts/jGrouseDoc/skins/common/js/navTree.js213
1 files changed, 0 insertions, 213 deletions
diff --git a/buildscripts/jGrouseDoc/skins/common/js/navTree.js b/buildscripts/jGrouseDoc/skins/common/js/navTree.js
deleted file mode 100644
index 5a71ec51..00000000
--- a/buildscripts/jGrouseDoc/skins/common/js/navTree.js
+++ /dev/null
@@ -1,213 +0,0 @@
-jgdoc = {};
-jgdoc.TreeItem = function(nodeName, item)
-{
- this._nodeName = nodeName;
- this._data = item;
- this._children = [];
-
-}
-
-jgdoc.Searcher =
-{
- setData : function(data) {
- this._data = data;
- this.processItems();
- this.render();
- },
-
- sorter: function(o1, o2) {
- var l1 = o1.localName;
- var l2 = o2.localName;
- return l1 < l2? -1 : (l1 > l2 ? 1 : 0);
- },
-
- processItems : function() {
- var root;
-
- // Pass 1: Build index by fullName, and locate the root element
- this._byName = {};
- for (var i = 0; i < this._data.length; i++) {
- var d = this._data[i];
- if (d.fullName == "GLOBAL") {
- root = this._root = d;
- }
- this._byName[d.fullName] = d;
- }
-
- // Pass 2: Populate _children arrays
- for (var i = 0; i < this._data.length; i++) {
- var item = this._data[i];
- if (item.elementType == "logical_container" && item != this._root) {
- var parent = this._byName[item.parent];
- parent._children = parent._children || [];
- parent._children.push(item);
- }
- }
- },
-
- addClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- return;
- }
- }
- a.push(className);
- element.className = a.join(' ');
- },
-
- removeClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- var found = false;
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- a.splice(i, 1);
- found = true;
- break;
- }
- }
- element.className = a.join(' ');
- return found;
- },
-
- clicked : function(event)
- {
- event = window.event? window.event : event;
- var target = event.target || event.srcElement;
- var span = target.parentNode;
- var li = span.parentNode;
- var wasOpen = jgdoc.Searcher.removeClass(li, 'open');
- if (wasOpen)
- {
- jgdoc.Searcher.addClass(li, 'closed');
- }
- else
- {
- jgdoc.Searcher.removeClass(li, 'closed');
- jgdoc.Searcher.addClass(li, 'open');
- }
- span.title = "Click to " + (wasOpen? "expand" : "collapse");
-
- },
-
- addListener : function(element, eventName, handler)
- {
- if (element.addEventListener)
- {
- element.addEventListener(eventName, handler, false);
- }
- else
- {
- element.attachEvent('on' + eventName, handler);
- }
- },
-
- removeListener : function(element, eventName, handler)
- {
- if (element.removeEventListener)
- {
- element.removeEventListener(eventName, handler, false);
- }
- else
- {
- element.detachEvent('on' + eventName, handler);
- }
- },
-
-
- render : function()
- {
- var d = document.getElementById('content');
- d.innerHTML = '';
- var athis = this;
- function renderNode(item)
- {
- var node = document.createElement('li');
- node.className = item.type;
- node.innerHTML = "<span class='node'><span class='markerSpace'>&nbsp;</span></span><a href='" + item.ref + "' target='classFrame' title='" + item.summary + "'>" + item.localName + "</a>";
- var span = node.firstChild;
- var img = span.firstChild;
- athis.addListener(img, 'mousedown', athis.clicked);
- if (item._children)
- {
- item._children.sort(jgdoc.Searcher.sorter);
- node.className += (item == athis._root)? ' open' : ' closed';
- span.title = "Click to " + (item != athis._root? 'expand' : 'collapse');
- var subnode = document.createElement("ul");
- subnode.className = 'contents';
- for (var i = 0; i < item._children.length; i++)
- {
- var child = renderNode(item._children[i]);
- subnode.appendChild(child);
- }
- node.appendChild(subnode);
- }
- else
- {
- node.className += ' leaf';
- }
- item._node = node;
- return node;
- }
- var root = renderNode(this._root);
- d.appendChild(root);
- },
-
- cancelEvent : function(event)
- {
- if (event.preventDefault)
- {
- event.preventDefault();
- event.stopPropagation();
- }
- else
- {
- event.preventDefault();
- event.stopPropagation();
- }
- },
-
- switchAll : function(doOpen)
- {
- var ac = doOpen? 'open' : 'closed';
- var rc = doOpen? 'closed' : 'open';
-
- var athis = this;
-
- function doSwitchNode(anode)
- {
- if (anode._children)
- {
- if (doOpen || anode != athis._root)
- {
- athis.removeClass(anode._node, rc);
- athis.addClass(anode._node, ac);
- }
- for (var i = 0; i < anode._children.length; i++)
- {
- doSwitchNode(anode._children[i]);
- }
- }
- }
- doSwitchNode(this._root);
- },
-
- onOpenAll : function()
- {
- jgdoc.Searcher.switchAll(true);
- },
-
- onCloseAll : function()
- {
- jgdoc.Searcher.switchAll(false);
- }
-
-};