diff options
author | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
---|---|---|
committer | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
commit | 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch) | |
tree | e08bf04f0823650a231227ac3499121270172a23 /buildscripts/jGrouseDoc/skins/noframes/js | |
parent | 3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff) |
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'buildscripts/jGrouseDoc/skins/noframes/js')
-rw-r--r-- | buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js | 650 | ||||
-rw-r--r-- | buildscripts/jGrouseDoc/skins/noframes/js/navTree.js | 818 |
2 files changed, 734 insertions, 734 deletions
diff --git a/buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js b/buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js index 9d1f1364..3e6a9aa5 100644 --- a/buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js +++ b/buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js @@ -1,326 +1,326 @@ -/**
- * Searcher for JGrouseDoc
- * $Id: jgdoc.js 324 2008-01-06 16:44:39Z denis.riabtchik $
- */
-
-if (typeof jgdoc == 'undefined')
-{
- jgdoc = {}
-
- jgdoc._dataHandlers = [];
-
- jgdoc.setData = function(data)
- {
- for (var i = 0; i < jgdoc._dataHandlers.length; i++)
- {
- jgdoc._dataHandlers[i](data);
- }
- }
-}
-
-jgdoc.Searcher =
-{
- initialize : function()
- {
- this._searchBox = document.getElementById("jgsSearchString");
- this._searchResults = document.getElementById("jgsSearchResults");
- this._info = document.getElementById("jgsInfo");
- this._currentValue = "";
- this._currentItems = [];
- this._currentItem = -1;
- this._data = null;
- this._searchPanel = document.getElementById("jgsSearchPanel");
- this.addListener(this._searchBox, 'focus', this.dispatcher);
- this.addListener(this._searchBox, 'blur', this.dispatcher);
- this.addListener(window, 'resize', this.dispatcher);
- var width = this._searchBox.offsetWidth - 4;
- this._searchPanel.style.width = width + 'px';
-
- /*var node = this._searchBox;
- var current = 0;
- var currentTop = 0;
- while (node)
- {
- current += node.offsetLeft;
- currentTop += node.offsetTop;
- node = node.offsetParent;
- }
-
- this._searchPanel.style.left = current + 'px';*/
- this.positionBox();
- return this;
- },
-
- positionBox : function()
- {
- var node = this._searchBox;
- var current = 0;
- var currentTop = 0;
- while (node)
- {
- current += node.offsetLeft;
- currentTop += node.offsetTop;
- node = node.offsetParent;
- }
-
- this._searchPanel.style.left = current + 'px';
- this._searchPanel.style.top = (currentTop + this._searchBox.offsetHeight) + "px";
-
- },
-
- _getEvent : function(event)
- {
- return window.event? window.event : event;
- },
-
- _getTarget : function(event)
- {
- return event.target || event.srcElement
- },
-
- 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(' ');
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- a.splice(i, 1);
- break;
- }
- }
- element.className = a.join(' ');
-
- },
-
- dispatcher : function(event)
- {
- if (this != jgdoc.Searcher)
- {
- arguments.callee.apply(jgdoc.Searcher, arguments)
- return;
- }
- event = this._getEvent(event);
- var type = event.type;
- var handler = "on" + type;
- this[handler](event, this._getTarget(event));
- },
-
- onclick : function(event, target)
- {
- // workaround for IE bug
- window.location.href = target.getAttribute("href", 1);
- },
-
- onmouseover : function(event, target)
- {
- this.selectItem(target.index);
- },
-
- onresize : function(event, target)
- {
- if (this._searchPanel.style.display != 'none')
- {
- this.positionBox();
- }
- },
-
- onmouseout : function(event, target)
- {
- this.unselectItem(target.index);
- },
-
- onfocus : function(event, target)
- {
- this._searchPanel.style.display = '';
- this.positionBox();
- },
-
- onblur : function(event, target)
- {
- var athis = this;
- window.setTimeout(function()
- {
- athis._searchPanel.style.display = 'none';
- }, 300);
-
- },
-
- selectItem : function(index)
- {
- if (index != this._currentItem)
- {
- this._currentItem = index;
- var item = this._currentItems[index];
- this.addClass(item, 'jgdSelectedItem');
- var text = item._data.summary.split('\n').join('<br/>');
- this._info.innerHTML = text;
- }
- },
-
- unselectItem : function(index)
- {
- this._currentItem = -1;
- var item = this._currentItems[index];
- this.removeClass(item, 'jgdSelectedItem');
- this._info.innerHTML = 'No selection';
- },
-
- openItem : function(name)
- {
-
- },
-
-
- onTimer : function()
- {
- if (this != jgdoc.Searcher)
- {
- arguments.callee.apply(jgdoc.Searcher, arguments)
- return;
- }
- var val = this._searchBox.value;
- if (val != this._currentValue)
- {
- this._currentValue = val;
- this.redraw();
- }
- },
-
- setData : function(data)
- {
- this._data = data;
- this.redraw();
- //this._searchBox.focus();
- },
-
- 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);
- }
- },
-
- findMatches : function()
- {
- var result = [];
- if (this._currentValue)
- {
- var v = this._currentValue.toUpperCase();
- for (var i = 0; i < this._data.length; i++)
- {
- var item = this._data[i];
- if (item.localName.toUpperCase().indexOf(v) == 0)
- {
- result.push(item);
- }
- }
- }
- return result;
- },
-
-
- clearItem : function(item)
- {
- item._data = null;
- this.removeListener(item, 'click', this.dispatcher);
- this.removeListener(item, 'mouseover', this.dispatcher);
- this.removeListener(item, 'mouseout', this.dispatcher);
- },
-
- clear : function()
- {
- for (var i = 0; i < this._currentItems.length; i++)
- {
- this.clearItem(this._currentItems[i]);
- }
- this._currentItems = [];
- this._searchResults.innerHTML = "";
- this._currentItem = -1;
- },
-
-
- createItem : function(item, index)
- {
- var d1 = document.createElement("div");
- d1.innerHTML = "<a href='" + item.ref + "'>" + item.fullName + "</a>";
- d = d1.firstChild;
- /*d.href = item.ref;
- item.ref = d.href;*/
- d.className = "searchItem";
- //d.title = item.summary;
- //d.innerHTML = item.fullName;
- d.index = index;
- d._data = item;
- this.addListener(d, 'click', this.dispatcher);
- this.addListener(d, 'mouseover', this.dispatcher);
- this.addListener(d, 'mouseout', this.dispatcher);
- //todo - set listeners
- return d;
- },
-
- redraw : function()
- {
- this.clear();
- var res = this.findMatches();
- if (res.length > 0)
- {
- for (var i = 0; i < res.length; i++)
- {
- var d = this.createItem(res[i], i);
- this._currentItems.push(d);
- this._searchResults.appendChild(d);
- }
- }
- else
- {
- var s = (this._currentValue)? "Not found" : "Start typing the name of the item";
- this._searchResults.innerHTML = s;
- }
- },
-
- start : function()
- {
- var instance = jgdoc.Searcher.initialize();
- instance.setData([]);
- instance._timer = window.setInterval(instance.onTimer, 100);
- }
-}
-
-jgdoc._dataHandlers.push(function(data)
-{
- jgdoc.Searcher.setData(data);
+/** + * Searcher for JGrouseDoc + * $Id: jgdoc.js 324 2008-01-06 16:44:39Z denis.riabtchik $ + */ + +if (typeof jgdoc == 'undefined') +{ + jgdoc = {} + + jgdoc._dataHandlers = []; + + jgdoc.setData = function(data) + { + for (var i = 0; i < jgdoc._dataHandlers.length; i++) + { + jgdoc._dataHandlers[i](data); + } + } +} + +jgdoc.Searcher = +{ + initialize : function() + { + this._searchBox = document.getElementById("jgsSearchString"); + this._searchResults = document.getElementById("jgsSearchResults"); + this._info = document.getElementById("jgsInfo"); + this._currentValue = ""; + this._currentItems = []; + this._currentItem = -1; + this._data = null; + this._searchPanel = document.getElementById("jgsSearchPanel"); + this.addListener(this._searchBox, 'focus', this.dispatcher); + this.addListener(this._searchBox, 'blur', this.dispatcher); + this.addListener(window, 'resize', this.dispatcher); + var width = this._searchBox.offsetWidth - 4; + this._searchPanel.style.width = width + 'px'; + + /*var node = this._searchBox; + var current = 0; + var currentTop = 0; + while (node) + { + current += node.offsetLeft; + currentTop += node.offsetTop; + node = node.offsetParent; + } + + this._searchPanel.style.left = current + 'px';*/ + this.positionBox(); + return this; + }, + + positionBox : function() + { + var node = this._searchBox; + var current = 0; + var currentTop = 0; + while (node) + { + current += node.offsetLeft; + currentTop += node.offsetTop; + node = node.offsetParent; + } + + this._searchPanel.style.left = current + 'px'; + this._searchPanel.style.top = (currentTop + this._searchBox.offsetHeight) + "px"; + + }, + + _getEvent : function(event) + { + return window.event? window.event : event; + }, + + _getTarget : function(event) + { + return event.target || event.srcElement + }, + + 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(' '); + for (var i = 0; i < a.length; i++) + { + if (a[i] == className) + { + a.splice(i, 1); + break; + } + } + element.className = a.join(' '); + + }, + + dispatcher : function(event) + { + if (this != jgdoc.Searcher) + { + arguments.callee.apply(jgdoc.Searcher, arguments) + return; + } + event = this._getEvent(event); + var type = event.type; + var handler = "on" + type; + this[handler](event, this._getTarget(event)); + }, + + onclick : function(event, target) + { + // workaround for IE bug + window.location.href = target.getAttribute("href", 1); + }, + + onmouseover : function(event, target) + { + this.selectItem(target.index); + }, + + onresize : function(event, target) + { + if (this._searchPanel.style.display != 'none') + { + this.positionBox(); + } + }, + + onmouseout : function(event, target) + { + this.unselectItem(target.index); + }, + + onfocus : function(event, target) + { + this._searchPanel.style.display = ''; + this.positionBox(); + }, + + onblur : function(event, target) + { + var athis = this; + window.setTimeout(function() + { + athis._searchPanel.style.display = 'none'; + }, 300); + + }, + + selectItem : function(index) + { + if (index != this._currentItem) + { + this._currentItem = index; + var item = this._currentItems[index]; + this.addClass(item, 'jgdSelectedItem'); + var text = item._data.summary.split('\n').join('<br/>'); + this._info.innerHTML = text; + } + }, + + unselectItem : function(index) + { + this._currentItem = -1; + var item = this._currentItems[index]; + this.removeClass(item, 'jgdSelectedItem'); + this._info.innerHTML = 'No selection'; + }, + + openItem : function(name) + { + + }, + + + onTimer : function() + { + if (this != jgdoc.Searcher) + { + arguments.callee.apply(jgdoc.Searcher, arguments) + return; + } + var val = this._searchBox.value; + if (val != this._currentValue) + { + this._currentValue = val; + this.redraw(); + } + }, + + setData : function(data) + { + this._data = data; + this.redraw(); + //this._searchBox.focus(); + }, + + 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); + } + }, + + findMatches : function() + { + var result = []; + if (this._currentValue) + { + var v = this._currentValue.toUpperCase(); + for (var i = 0; i < this._data.length; i++) + { + var item = this._data[i]; + if (item.localName.toUpperCase().indexOf(v) == 0) + { + result.push(item); + } + } + } + return result; + }, + + + clearItem : function(item) + { + item._data = null; + this.removeListener(item, 'click', this.dispatcher); + this.removeListener(item, 'mouseover', this.dispatcher); + this.removeListener(item, 'mouseout', this.dispatcher); + }, + + clear : function() + { + for (var i = 0; i < this._currentItems.length; i++) + { + this.clearItem(this._currentItems[i]); + } + this._currentItems = []; + this._searchResults.innerHTML = ""; + this._currentItem = -1; + }, + + + createItem : function(item, index) + { + var d1 = document.createElement("div"); + d1.innerHTML = "<a href='" + item.ref + "'>" + item.fullName + "</a>"; + d = d1.firstChild; + /*d.href = item.ref; + item.ref = d.href;*/ + d.className = "searchItem"; + //d.title = item.summary; + //d.innerHTML = item.fullName; + d.index = index; + d._data = item; + this.addListener(d, 'click', this.dispatcher); + this.addListener(d, 'mouseover', this.dispatcher); + this.addListener(d, 'mouseout', this.dispatcher); + //todo - set listeners + return d; + }, + + redraw : function() + { + this.clear(); + var res = this.findMatches(); + if (res.length > 0) + { + for (var i = 0; i < res.length; i++) + { + var d = this.createItem(res[i], i); + this._currentItems.push(d); + this._searchResults.appendChild(d); + } + } + else + { + var s = (this._currentValue)? "Not found" : "Start typing the name of the item"; + this._searchResults.innerHTML = s; + } + }, + + start : function() + { + var instance = jgdoc.Searcher.initialize(); + instance.setData([]); + instance._timer = window.setInterval(instance.onTimer, 100); + } +} + +jgdoc._dataHandlers.push(function(data) +{ + jgdoc.Searcher.setData(data); });
\ No newline at end of file diff --git a/buildscripts/jGrouseDoc/skins/noframes/js/navTree.js b/buildscripts/jGrouseDoc/skins/noframes/js/navTree.js index ac011da4..98e30a29 100644 --- a/buildscripts/jGrouseDoc/skins/noframes/js/navTree.js +++ b/buildscripts/jGrouseDoc/skins/noframes/js/navTree.js @@ -1,409 +1,409 @@ -if (typeof jgdoc == 'undefined')
-{
- jgdoc = {}
-
- jgdoc._dataHandlers = [];
-
- jgdoc.setData = function(data)
- {
- for (var i = 0; i < jgdoc._dataHandlers.length; i++)
- {
- jgdoc._dataHandlers[i](data);
- }
- }
-}
-
-jgdoc.TreeItem = function(nodeName, item)
-{
- this._nodeName = nodeName;
- this._data = item;
- this._children = [];
-
-}
-
-jgdoc.Common =
-{
- 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;
- },
-
- 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);
- }
- }
-}
-
-jgdoc.NavPanel =
-{
- clicked : function(e)
- {
- e = window.event? window.event : e;
- var target = e.target || e.srcElement;
- var node = target;
- while (node != null && node.tagName != 'UL')
- {
- node = node.parentNode;
- }
- if (node)
- {
- var parent = node.parentNode;
- var current = parent.firstChild;
- while (current)
- {
- if (current != node && current.nodeType === 1)
- {
- jgdoc.Common.addClass(current, "closed");
- }
- current = current.nextSibling;
- }
- jgdoc.Common.removeClass(node, "closed");
- }
- },
-
- dummy : function()
- {
- }
-}
-
-/*
-jgdoc.App =
-{
- initialize : function()
- {
- this._container = document.getElementById("startup");
- this._banner = document.getElementById("banner");
- this._content = document.getElementById("docContent");
- this._navigation = document.getElementById("navigation");
- this._docScroll = document.getElementById("docScroll");
- this._html = document.getElementsByTagName('html')[0];
- this._body = document.getElementsByTagName("body")[0];
- this._searchBlock = document.getElementById("searchBlock");
- this._html.style.overflowY = "hidden";
-
- }
-}*/
-
-jgdoc.NavTree =
-{
- initialize : function(defaultName)
- {
- this._defaultName = defaultName;
- },
-
-
- setData : function(data) {
- this._data = data;
- this.processItems();
- this.render();
- this.openItem(this._defaultName);
- },
-
- 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);
- }
- }
- },
-
- findItem : function(name)
- {
- return this._byName[name];
- },
-
- /*setData : function(data)
- {
- this._data = data;
- data.sort(this.sorter);
- this._root = data[0];
- this.processItems();
- this.render();
- this.openItem(this._defaultName);
- },
-
- findItem : function(name)
- {
- if (name === '' || name == 'GLOBAL')
- {
- return this._root;
- }
- var s = name.split('.');
- var current = this._root._children;
- var found = null;
- for (var i = 0; i < s.length; i++)
- {
- var detected = false;
- for (var j = 0; j < current.length; j++)
- {
- var item = current[j];
- if (item.localName == s[i])
- {
- detected = true;
- current = item._children;
- found = item;
- break;
- }
- }
- if (!detected)
- {
- return false;
- }
- }
- return found;
- },
-
- processItems : function()
- {
- for (var i = 1; i < this._data.length; i++)
- {
- var item = this._data[i];
- if (item.elementType == "logical_container")
- {
- var parent = this.findItem(item.parent);
- if (!parent._children)
- {
- parent._children = [];
- }
- parent._children.push(item);
- }
- }
- },
-
-
- sorter : function(item1, item2)
- {
- if (item1.parent == "")
- {
- return -1;
- }
- if (item2.parent == "")
- {
- return 1;
- }
- if (item1.parent == item2.parent)
- {
- return item1.localName < item2.localName? -1 : item1.localName > item2.localName? 1 : 0;
- }
- if (item1.parent == "GLOBAL")
- {
- return -1;
- }
- if (item2.parent == "GLOBAL")
- {
- return 1;
- }
- return item1.parent < item2.parent? -1 : 1;
- },
- */
-
-
- 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.Common.removeClass(li, 'open');
- if (wasOpen)
- {
- jgdoc.Common.addClass(li, 'closed');
- }
- else
- {
- jgdoc.Common.removeClass(li, 'closed');
- jgdoc.Common.addClass(li, 'open');
- }
- span.title = "Click to " + (wasOpen? "expand" : "collapse");
-
- },
-
-
-
-
- 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'> </span></span><a href='" + item.ref + "' title='" + item.summary + "'>" + item.localName + "</a>";
- var span = node.firstChild;
- var img = span.firstChild;
- jgdoc.Common.addListener(img, 'mousedown', athis.clicked);
- if (item._children)
- {
- 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';
- }
- if (item.fullName == athis._defaultName)
- {
- node.firstChild.nextSibling.className += ' currentNode';
- }
- 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)
- {
- jgdoc.Common.removeClass(anode._node, rc);
- jgdoc.Common.addClass(anode._node, ac);
- }
- for (var i = 0; i < anode._children.length; i++)
- {
- doSwitchNode(anode._children[i]);
- }
- }
- }
- doSwitchNode(this._root);
- },
-
- openItem : function(name)
- {
- this.switchAll(false);
- while (name != 'GLOBAL')
- {
- var item = this.findItem(name);
- if (item)
- {
- var node = item._node;
- jgdoc.Common.removeClass(node, 'closed');
- jgdoc.Common.addClass(node, 'open');
- name = item.parent;
- }
- else
- {
- return;
- }
- }
- },
-
- onOpenAll : function()
- {
- jgdoc.NavTree.switchAll(true);
- },
-
- onCloseAll : function()
- {
- jgdoc.NavTree.switchAll(false);
- }
-
-};
-
-jgdoc._dataHandlers.push(function(data)
-{
- //jgdoc.App.initialize();
- jgdoc.NavTree.setData(data);
-});
+if (typeof jgdoc == 'undefined') +{ + jgdoc = {} + + jgdoc._dataHandlers = []; + + jgdoc.setData = function(data) + { + for (var i = 0; i < jgdoc._dataHandlers.length; i++) + { + jgdoc._dataHandlers[i](data); + } + } +} + +jgdoc.TreeItem = function(nodeName, item) +{ + this._nodeName = nodeName; + this._data = item; + this._children = []; + +} + +jgdoc.Common = +{ + 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; + }, + + 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); + } + } +} + +jgdoc.NavPanel = +{ + clicked : function(e) + { + e = window.event? window.event : e; + var target = e.target || e.srcElement; + var node = target; + while (node != null && node.tagName != 'UL') + { + node = node.parentNode; + } + if (node) + { + var parent = node.parentNode; + var current = parent.firstChild; + while (current) + { + if (current != node && current.nodeType === 1) + { + jgdoc.Common.addClass(current, "closed"); + } + current = current.nextSibling; + } + jgdoc.Common.removeClass(node, "closed"); + } + }, + + dummy : function() + { + } +} + +/* +jgdoc.App = +{ + initialize : function() + { + this._container = document.getElementById("startup"); + this._banner = document.getElementById("banner"); + this._content = document.getElementById("docContent"); + this._navigation = document.getElementById("navigation"); + this._docScroll = document.getElementById("docScroll"); + this._html = document.getElementsByTagName('html')[0]; + this._body = document.getElementsByTagName("body")[0]; + this._searchBlock = document.getElementById("searchBlock"); + this._html.style.overflowY = "hidden"; + + } +}*/ + +jgdoc.NavTree = +{ + initialize : function(defaultName) + { + this._defaultName = defaultName; + }, + + + setData : function(data) { + this._data = data; + this.processItems(); + this.render(); + this.openItem(this._defaultName); + }, + + 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); + } + } + }, + + findItem : function(name) + { + return this._byName[name]; + }, + + /*setData : function(data) + { + this._data = data; + data.sort(this.sorter); + this._root = data[0]; + this.processItems(); + this.render(); + this.openItem(this._defaultName); + }, + + findItem : function(name) + { + if (name === '' || name == 'GLOBAL') + { + return this._root; + } + var s = name.split('.'); + var current = this._root._children; + var found = null; + for (var i = 0; i < s.length; i++) + { + var detected = false; + for (var j = 0; j < current.length; j++) + { + var item = current[j]; + if (item.localName == s[i]) + { + detected = true; + current = item._children; + found = item; + break; + } + } + if (!detected) + { + return false; + } + } + return found; + }, + + processItems : function() + { + for (var i = 1; i < this._data.length; i++) + { + var item = this._data[i]; + if (item.elementType == "logical_container") + { + var parent = this.findItem(item.parent); + if (!parent._children) + { + parent._children = []; + } + parent._children.push(item); + } + } + }, + + + sorter : function(item1, item2) + { + if (item1.parent == "") + { + return -1; + } + if (item2.parent == "") + { + return 1; + } + if (item1.parent == item2.parent) + { + return item1.localName < item2.localName? -1 : item1.localName > item2.localName? 1 : 0; + } + if (item1.parent == "GLOBAL") + { + return -1; + } + if (item2.parent == "GLOBAL") + { + return 1; + } + return item1.parent < item2.parent? -1 : 1; + }, + */ + + + 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.Common.removeClass(li, 'open'); + if (wasOpen) + { + jgdoc.Common.addClass(li, 'closed'); + } + else + { + jgdoc.Common.removeClass(li, 'closed'); + jgdoc.Common.addClass(li, 'open'); + } + span.title = "Click to " + (wasOpen? "expand" : "collapse"); + + }, + + + + + 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'> </span></span><a href='" + item.ref + "' title='" + item.summary + "'>" + item.localName + "</a>"; + var span = node.firstChild; + var img = span.firstChild; + jgdoc.Common.addListener(img, 'mousedown', athis.clicked); + if (item._children) + { + 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'; + } + if (item.fullName == athis._defaultName) + { + node.firstChild.nextSibling.className += ' currentNode'; + } + 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) + { + jgdoc.Common.removeClass(anode._node, rc); + jgdoc.Common.addClass(anode._node, ac); + } + for (var i = 0; i < anode._children.length; i++) + { + doSwitchNode(anode._children[i]); + } + } + } + doSwitchNode(this._root); + }, + + openItem : function(name) + { + this.switchAll(false); + while (name != 'GLOBAL') + { + var item = this.findItem(name); + if (item) + { + var node = item._node; + jgdoc.Common.removeClass(node, 'closed'); + jgdoc.Common.addClass(node, 'open'); + name = item.parent; + } + else + { + return; + } + } + }, + + onOpenAll : function() + { + jgdoc.NavTree.switchAll(true); + }, + + onCloseAll : function() + { + jgdoc.NavTree.switchAll(false); + } + +}; + +jgdoc._dataHandlers.push(function(data) +{ + //jgdoc.App.initialize(); + jgdoc.NavTree.setData(data); +}); |