diff options
author | Nina Vyedin <nina.vyedin@gmail.com> | 2013-03-05 02:56:46 +0400 |
---|---|---|
committer | Nina Vyedin <nina.vyedin@gmail.com> | 2013-03-05 07:54:32 +0400 |
commit | 278eb83c4f0ae4235b4940a794205dd7f3146934 (patch) | |
tree | 9974a6f3571a1a2db83fb6f041ae859375f192cf /webdoc/plugins | |
parent | a17ec4720a373150ac199e6687291726b5eccd54 (diff) |
[webdoc] add the sidebar plugin
Diffstat (limited to 'webdoc/plugins')
62 files changed, 1739 insertions, 0 deletions
diff --git a/webdoc/plugins/sidebar-plugin/make-tree.js b/webdoc/plugins/sidebar-plugin/make-tree.js new file mode 100644 index 00000000..ba540967 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/make-tree.js @@ -0,0 +1,44 @@ +$(document).ready(function() { + var content_frame = $('#content_frame'); + var page_link = $('#pageLink'); + + change_page = function (pagename) { + content_frame.attr ('src', 'monodoc.ashx?link=' + pagename); + page_link.attr ('href', '?link=' + pagename); + if (window.history && window.history.pushState) + window.history.pushState (null, '', '/?link=' + pagename); + }; + + var tree = new PTree (); + tree.strSrcBase = 'monodoc.ashx?tree='; + tree.strActionBase = '?link='; + tree.strImagesBase = 'plugins/sidebar-plugin/xtree/images/msdn2/'; + tree.strImageExt = '.gif'; + tree.onClickCallback = function (url) { change_page (url); }; + var content = document.getElementById ('contentList'); + var root = tree.CreateItem (null, 'Documentation List', 'root:', '', true); + content.appendChild (root); + + update_tree = function () { + var tree_path = $('#content_frame').contents ().find ('meta[name=TreePath]'); + if (tree_path.length > 0) { + var path = tree_path.attr ('value'); + tree.ExpandFromPath (path); + } + }; + + update_tree (); + add_native_browser_link = function () { + var contentDiv = $('#content_frame').contents ().find ('div[class=Content]').first (); + if (contentDiv.length > 0 && contentDiv.attr ('id')) { + var id = contentDiv.attr ('id').replace (':Summary', ''); + var h2 = contentDiv.children ('h2').first (); + if (h2.prev ().attr ('class') != 'native-browser') + h2.before ('<p><a class="native-browser" href="mdoc://' + encodeURIComponent (id) + '"><span class="native-icon"><img src="images/native-browser-icon.png" /></span>Open in Native Browser</a></p>'); + } + }; + add_native_browser_link (); + + content_frame.load (update_tree); + content_frame.load (add_native_browser_link); +} diff --git a/webdoc/plugins/sidebar-plugin/ptree/searching.gif b/webdoc/plugins/sidebar-plugin/ptree/searching.gif Binary files differnew file mode 100644 index 00000000..5ca0ab86 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/ptree/searching.gif diff --git a/webdoc/plugins/sidebar-plugin/ptree/tree.css b/webdoc/plugins/sidebar-plugin/ptree/tree.css new file mode 100755 index 00000000..d9259916 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/ptree/tree.css @@ -0,0 +1,53 @@ +.tree-node, +.tree-node-collapsed +{ + margin: 0px; + padding: 0px; + border: 0px; + white-space: nowrap; +} + +.tree-label, +.tree-label-selected +{ + margin: 0px; + padding: 0px; + border: 0px; + height: 33px; + line-height: 21px; +} + +.tree-node-collapsed .tree-node, +.tree-node-collapsed .tree-node-collapsed +{ + display: none; +} + +.tree-label-selected a, +.tree-label-selected a:hover +{ + text-decoration: none; + background-color: #f2f2f2; + color: #2a2c2f; +} + +.tree-label a +{ + text-decoration: none; + color: #2a2c2f; + background: none repeat scroll 0 0 #f2f2f2;; +} + +.tree-label a:hover +{ + text-decoration: none; + background: none repeat scroll 0 0 #F7F7F7; + color: #2a2c2f; +} + +.tree-node img +{ + vertical-align: middle; + border: 0px; +} + diff --git a/webdoc/plugins/sidebar-plugin/ptree/tree.js b/webdoc/plugins/sidebar-plugin/ptree/tree.js new file mode 100755 index 00000000..3866ceb7 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/ptree/tree.js @@ -0,0 +1,466 @@ +// +// PTree - A dynamically loaded TOC tree +// +// Author: +// Piers Haken (piersh@friskit.com) +// +// (C) 2003 Piers Haken +// + +// TODO: +// work out how to cancel scrolling keyboard events on Mozilla +// better support for multiple trees in a single body + +function PTree () +{ + this.strActionBase = ""; + this.strSrcBase = ""; + this.strTargetDefault = ""; + this.strImagesBase = "images/"; + this.strImageExt = ".png"; + this.eltSelected = null; + this.nImageWidth = 18; + this.nImageHeight = 23; + this.onClickCallback = null; + + this.CreateItemFromXML = function (oNode, fLast, eltParent) + { + var strText = oNode.getAttribute ("text"); + var strAction = oNode.getAttribute ("action"); + var strSrc = oNode.getAttribute ("src"); + var strTarget = oNode.getAttribute ("target"); + return this.CreateItem (eltParent, strText, strAction, strSrc, fLast, strTarget, fLast, eltParent); + } + + this.CreateItem = function (eltParent, strText, strAction, strSrc, fLast, strTarget) + { + var _this = this; + + var eltDiv = document.createElement ("DIV"); + if (eltParent == null) + eltDiv.tree_fRoot = true; + + if (fLast) + eltDiv.tree_fLast = true; + + if (strAction) + eltDiv.tree_action = strAction; + + if (strSrc != null) + eltDiv.tree_src = strSrc; + + var eltSpan = document.createElement ("SPAN"); + eltSpan.className = "tree-label"; + + if (eltParent) + { + eltDiv.className = "tree-node-collapsed"; + + // this node's tree icon + var eltIcon = new Image (); + eltIcon.width = this.nImageWidth; + eltIcon.height = this.nImageHeight; + if (strSrc) + eltIcon.onclick = function () { _this.LoadNode (this); } + eltIcon.src = this.GetIconSrc (eltDiv, true); + eltSpan.appendChild (eltIcon); + + // parent's tree icons + var eltIconLast = eltIcon; + var eltParentDiv = eltParent; + while (!this.IsRootDiv (eltParentDiv)) + { + var eltIcon = new Image (); + eltIcon.width = this.nImageWidth; + eltIcon.height = this.nImageHeight; + if (this.IsLastDiv (eltParentDiv)) + eltIcon.src = this.strImagesBase + "blank" + this.strImageExt; + else + eltIcon.src = this.strImagesBase + "I" + this.strImageExt; + + eltSpan.insertBefore (eltIcon, eltIconLast); + eltIconLast = eltIcon; + eltParentDiv = this.GetParentDiv (eltParentDiv); + } + } + else + { + eltDiv.className = "tree-node"; + //document.body.onkeydown = function () { return _this.onKeyDown (); } + } + + // description + var eltText = document.createTextNode (strText); + var eltDescription; + + if (strAction) + { + eltDescription = document.createElement ("a"); + if (strAction.indexOf ('http://') === 0) + eltDescription.href = strAction; + else + eltDescription.href = this.strActionBase + strAction; + eltDescription.title = strText; + if (strTarget) + eltDescription.target = strTarget; + else if (this.strTargetDefault) + eltDescription.target = this.strTargetDefault; + eltDescription.appendChild (eltText); + var parent = this; + eltDescription.onclick = function (e) { + if (!e) + e = window.event; + if (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || e.modifiers > 0) + return; + _this.SelectNode (eltDiv); + if (parent.onClickCallback) { + e.cancelBubble = true; + e.returnValue = false; + if (e.stopPropagation) { + e.stopPropagation (); + e.preventDefault (); + } + parent.onClickCallback(strAction); + } + } + eltDescription.onmouseover = function () { this.blur (); } + eltDescription.onmouseup = function () { this.blur (); } + } + else + { + eltDescription = document.createElement ("span"); + eltDescription.className = "tree-label"; + eltDescription.innerHTML = strText; + } + + eltSpan.appendChild (eltDescription); + eltDiv.appendChild (eltSpan); + + // append this node to its parent + if (eltParent) + eltParent.appendChild (eltDiv); + else + this.SelectNode (eltDiv); + + return eltDiv; + } + + this.SelectNode = function (eltDiv) + { + if (this.eltSelected != eltDiv) + { + if (eltDiv) + { + var eltLabel = this.GetSpan (eltDiv); + eltLabel.className = "tree-label-selected"; + } + if (this.eltSelected) + { + var eltLabel = this.GetSpan (this.eltSelected); + eltLabel.className = "tree-label"; + } + this.eltSelected = eltDiv; + } + } + + this.LoadNode = function (eltIcon) + { + var eltDiv = this.GetDivFromIcon (eltIcon); + eltIcon.onclick = null; + + var eltLoading = this.CreateItem (eltDiv, "<img src=\"plugins/sidebar-plugin/ptree/searching.gif\"/>Loading...", null, null, true); + eltLoading.className = ''; + + var xmlHttp = XmlHttp.create(); + xmlHttp.open ("GET", this.strSrcBase + eltDiv.tree_src, true); // async + var _this = this; + xmlHttp.onreadystatechange = function () { _this.onReadyStateChange (xmlHttp, eltIcon, eltLoading); } + setTimeout (function () { xmlHttp.send (null); }, 10); + } + + this.onReadyStateChange = function (xmlHttp, eltIcon, eltLoading) + { + if (xmlHttp.readyState != 4) + return; + // XML loaded + var eltDiv = this.GetDivFromIcon (eltIcon); + + try + { + var doc = xmlHttp.responseXML; + var root = doc.documentElement; + + var nodes = root.childNodes; + var cNodes = nodes.length; + + for (var iNode = 0; iNode < cNodes; iNode ++) + this.CreateItemFromXML (nodes [iNode], iNode == cNodes-1, eltDiv); + + eltDiv.removeChild (eltLoading); + + if (this.eltSelected == eltLoading) + this.SelectNode (this.GetFirstChild (eltDiv)); + + eltIcon.src = this.GetIconSrc (eltDiv, false); + } + catch (e) + { + this.SetText (eltLoading, "Failed to load topic"); + } + eltDiv.className = "tree-node"; + var _this = this; + eltIcon.onclick = function () { _this.onClickMinus (this); } + } + + this.ExpandFromPath = function (path) + { + var root = $('.tree-node').first (); + var elements = path.split('@'); + + var thisSave = this; + var finish = function (node, i, opened) { + node = $(node); + if (!opened) { + node.attr('class', 'tree-node'); + var icon = node.children('span').children('img:nth-child(' + (i + 1) + ')'); + icon[0].onclick = function () { thisSave.onClickMinus (this); }; + icon.attr('src', thisSave.GetIconSrc (node[0], false)); + } + root = node; + if (i == elements.length - 1) { + thisSave.SelectNode (node[0]); + var container = $('#contents').parent (); + container.scrollTop (node[0].offsetTop - 100); + } + }; + var recurse = function (i) { + if (i >= elements.length) + return; + var node = root.children ('div')[elements[i]]; + // Tree already loaded + if ($(node).find ('div').first ().length == 0) { + var url = thisSave.strSrcBase + elements.slice(0, i + 1).join('@'); + $.get (url, function (data) { + var doc = data.documentElement; + + var children = doc.childNodes; + var cChildren = children.length; + + for (var iNode = 0; iNode < cChildren; iNode ++) + thisSave.CreateItemFromXML (children[iNode], iNode == cChildren - 1, node) + + // We finish node creation by opening up its tree like clicking would normally do + finish (node, i, false); + recurse (i + 1); + }); + } else { + finish (node, i, true); + recurse (i + 1); + } + }; + recurse (0); + } + + this.onClickPlus = function (eltIcon) + { + var eltDiv = this.GetDivFromIcon (eltIcon); + eltDiv.className = "tree-node"; + eltIcon.src = this.GetIconSrc (eltDiv, false); + var _this = this; + eltIcon.onclick = function () { _this.onClickMinus (this); } + } + + this.onClickMinus = function (eltIcon) + { + var eltDiv = this.GetDivFromIcon (eltIcon); + eltDiv.className = "tree-node-collapsed"; + eltIcon.src = this.GetIconSrc (eltDiv, true); + var _this = this; + eltIcon.onclick = function () { _this.onClickPlus (this); } + } + + this.onKeyDown = function (event) + { + var eltSelect = this.eltSelected; + var fLast = this.IsLastDiv (eltSelect); + var fRoot = this.IsRootDiv (eltSelect); + + switch (event.keyCode) + { + case 13: // return + var eltLink = eltSelect.firstChild.lastChild; + if (eltSelect.tree_action) + window.open (eltLink.href, eltLink.target); + this.SelectNode (eltSelect); + return false; // don't EnsureVisible + + case 38: // up + if (!fRoot) + { + if (this.IsFirstChild (eltSelect)) + eltSelect = this.GetParentDiv (eltSelect); + else + { + eltSelect = eltSelect.previousSibling; + while (this.IsExpanded (eltSelect)) + eltSelect = eltSelect.lastChild; + } + } + break; + + case 40: // down + if (this.IsExpanded (eltSelect)) + eltSelect = this.GetFirstChild (eltSelect); + else if (!fLast) + eltSelect = eltSelect.nextSibling; + else + { + while (!this.IsRootDiv (eltSelect) && this.IsLastDiv (eltSelect)) + eltSelect = this.GetParentDiv (eltSelect); + + if (this.IsRootDiv (eltSelect)) + return false; + + eltSelect = eltSelect.nextSibling; + } + break; + + case 37: // left + if (!fRoot) + { + if (this.IsExpanded (eltSelect)) + this.onClickMinus (this.GetIconFromDiv (eltSelect)); + else + eltSelect = this.GetParentDiv (eltSelect); + } + break; + + case 39: // right + if (this.HasChildren (eltSelect)) + { + var eltChild = this.GetFirstChild (eltSelect); + if (this.IsExpanded (eltSelect)) + eltSelect = eltChild; + else if (eltChild != null) + this.onClickPlus (this.GetIconFromDiv (eltSelect)); + else + this.LoadNode (this.GetIconFromDiv (eltSelect)); + } + break; + + default: + return true; + } + + this.SelectNode (eltSelect); + this.EnsureVisible (this.GetLabel (eltSelect)); + + return false; + } + + this.SetText = function (eltDiv, strText) + { + var eltText = eltDiv.lastChild; + eltText.nodeValue = strText; + } + + this.GetIconSrc = function (eltDiv, fPlus) + { + var strIconSrc = this.IsLastDiv (eltDiv) ? "L" : "T"; + if (eltDiv.tree_src != null) + strIconSrc += fPlus ? "plus" : "minus"; + return this.strImagesBase + strIconSrc + this.strImageExt; + } + + this.GetDivFromIcon = function (eltIcon) + { + return eltIcon.parentNode.parentNode; + } + + this.GetIconFromDiv = function (eltDiv) + { + return eltDiv.firstChild.lastChild.previousSibling; + } + + this.GetFirstChild = function (eltDiv) + { + return eltDiv.firstChild.nextSibling; + } + + this.GetSpan = function (eltDiv) + { + return eltDiv.firstChild; + } + + this.GetLabel = function (eltDiv) + { + return eltDiv.firstChild.lastChild; + } + + this.GetParentDiv = function (eltDiv) + { + if (this.IsRootDiv (eltDiv)) + return null; + return eltDiv.parentNode; + } + + this.HasChildren = function (eltDiv) + { + return eltDiv.tree_src || this.IsRootDiv (eltDiv); + } + + this.IsLastDiv = function (eltDiv) + { + return eltDiv.tree_fLast; + } + + this.IsRootDiv = function (eltDiv) + { + return Boolean (eltDiv.tree_fRoot); + } + + this.IsExpanded = function (eltDiv) + { + return eltDiv.className != "tree-node-collapsed"; + } + + this.IsFirstChild = function (eltDiv) + { + var fFirst = + eltDiv.previousSibling && + eltDiv.previousSibling.tagName != "DIV"; + return fFirst; + } + + this.EnsureVisible = function (elt) + { + var x = 0; + var y = 0; + var parent = elt; + while (parent != null) + { + x += parent.offsetLeft; + y += parent.offsetTop; + parent = parent.offsetParent; + } + + var yView = window.frameElement.scrollTop + document.body.scrollTop; + var dyView = document.body.clientHeight; + var dy = 0; + if (y + elt.offsetHeight > yView + dyView) + dy = (y + elt.offsetHeight) - (yView + dyView); + if (y < yView + dy) + dy = y - yView; + + var xView = window.frameElement.scrollLeft + document.body.scrollLeft; + var dxView = document.body.clientWidth; + var dx = 0; + if (x + elt.offsetWidth > xView + dxView) + dx = (x + elt.offsetWidth) - (xView + dxView); + if (x < xView + dx) + dx = x - xView; + + if (dx != 0 || dy != 0) + window.scrollBy (dx, dy); + } +} diff --git a/webdoc/plugins/sidebar-plugin/sidebar.css b/webdoc/plugins/sidebar-plugin/sidebar.css new file mode 100644 index 00000000..73760ccc --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/sidebar.css @@ -0,0 +1,130 @@ +.tab { + display: none !important; +} + +.activeTab { + padding-top: 15px; + padding-left: 10px; + padding-right: 10px; + display: block !important; + overflow-x: hidden; + overflow-y: visible; +} + +input[type=text] { + border: 1px solid #B1A598; + padding: 2px; +} + +input[type=text]:focus { +} + +.error { + color: red; + font-weight: bold; +} + +ul#indexList { + padding: 0px; + margin-left: 0px; + margin-right: 0px; + margin-bottom: 0px; + margin-top: 10px; +} + +ul#indexList li { + list-style: none; + padding-left: 13px; + padding-top: 2px; + padding-bottom: 2px; + background: url('/images/treenodedot.gif') no-repeat center left; +} + +#contentsList ul { + padding: 0px; + margin-left: 0px; + margin-top: 0px; +} + +#contentsList ul ul{ + padding-left: 15px; + margin: 0px !important; +} + +#contentsList ul li { + list-style: none; + padding-bottom: 3px; +} + +#contentsList ul li a { + text-decoration: none; + color: black; +} + +#contentsList ul li img { + border: 0px; + vertical-align: middle; +} + +#tabs { + position: fixed; + top: 0; + left: 0; + right: 0; +} + +#tabs ul { + margin-left: 0px; + padding-left: 5px; + border-bottom: 1px solid #B1A598; + padding-bottom: 3px; + background-color: #EFEBE7; + padding-top: 10px; + margin-top: 0px !important; + margin-bottom: 0px !important; +} +#tabs { + border-bottom: 2px solid white; +} + + +#tabs ul li { + display: inline; + border-top: 1px solid #B1A598; + border-left: 1px solid #B1A598; + border-right: 1px solid #B1A598; + padding-top: 3px; + padding-bottom: 3px; + padding-left: 5px; + padding-right: 5px; +} + +#tabs ul li.selected, ul#tabs li:hover { + background-color: white; +} +#tabs ul li.selected { + border-bottom: 1px solid white; +} +#tabs ul li a { + color: black; + text-decoration: none; +} + +a.selected { + /*font-weight: bold;*/ + background: #eee; + border: 1px solid #ccc; + padding: 1px; +} + +#errorText { + margin-top: 10px; +} + +#contentList > div.tree-node:first-child > span { + font-size: 18px; + height: 35px; + line-height: 35px; + padding: 0 10px; +} + diff --git a/webdoc/plugins/sidebar-plugin/sidebar.js b/webdoc/plugins/sidebar-plugin/sidebar.js new file mode 100644 index 00000000..f62b1770 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/sidebar.js @@ -0,0 +1,28 @@ +function SetSelection(b,v) +{ + if (v){ + t = "activeTab"; + tab = "selected"; + } else { + t = "tab"; + tab = ""; + } + + document.getElementById (b).className = t; + document.getElementById (b + "Tab").className = tab; +} + +function ShowContents () +{ + SetSelection ("contents", true); + SetSelection ("index", false); +} + +function ShowIndex () +{ + SetSelection ("contents", false); + SetSelection ("index", true); + document.getElementById ('indexInput').focus (); +} + + diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/I.png b/webdoc/plugins/sidebar-plugin/xtree/images/I.png Binary files differnew file mode 100644 index 00000000..e8512fb9 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/I.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/L.png b/webdoc/plugins/sidebar-plugin/xtree/images/L.png Binary files differnew file mode 100644 index 00000000..eb334eda --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/L.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/Lminus.png b/webdoc/plugins/sidebar-plugin/xtree/images/Lminus.png Binary files differnew file mode 100644 index 00000000..f7c43c0a --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/Lminus.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/Lplus.png b/webdoc/plugins/sidebar-plugin/xtree/images/Lplus.png Binary files differnew file mode 100644 index 00000000..848ec2fc --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/Lplus.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/T.png b/webdoc/plugins/sidebar-plugin/xtree/images/T.png Binary files differnew file mode 100644 index 00000000..30173254 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/T.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/Tminus.png b/webdoc/plugins/sidebar-plugin/xtree/images/Tminus.png Binary files differnew file mode 100644 index 00000000..2260e424 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/Tminus.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/Tplus.png b/webdoc/plugins/sidebar-plugin/xtree/images/Tplus.png Binary files differnew file mode 100644 index 00000000..2c8d8f4f --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/Tplus.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/blank.png b/webdoc/plugins/sidebar-plugin/xtree/images/blank.png Binary files differnew file mode 100644 index 00000000..cee9cd37 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/blank.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/clean/I.gif b/webdoc/plugins/sidebar-plugin/xtree/images/clean/I.gif Binary files differnew file mode 100644 index 00000000..b2d86c54 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/clean/I.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/clean/L.gif b/webdoc/plugins/sidebar-plugin/xtree/images/clean/L.gif Binary files differnew file mode 100644 index 00000000..b58e9378 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/clean/L.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/clean/Lminus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/clean/Lminus.gif Binary files differnew file mode 100644 index 00000000..33c49d13 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/clean/Lminus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/clean/Lplus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/clean/Lplus.gif Binary files differnew file mode 100644 index 00000000..9d2a2ac5 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/clean/Lplus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/clean/T.gif b/webdoc/plugins/sidebar-plugin/xtree/images/clean/T.gif Binary files differnew file mode 100644 index 00000000..b58e9378 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/clean/T.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/clean/Tminus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/clean/Tminus.gif Binary files differnew file mode 100644 index 00000000..33c49d13 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/clean/Tminus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/clean/Tplus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/clean/Tplus.gif Binary files differnew file mode 100644 index 00000000..9d2a2ac5 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/clean/Tplus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/clean/blank.gif b/webdoc/plugins/sidebar-plugin/xtree/images/clean/blank.gif Binary files differnew file mode 100755 index 00000000..c23b58ca --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/clean/blank.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/file.png b/webdoc/plugins/sidebar-plugin/xtree/images/file.png Binary files differnew file mode 100644 index 00000000..a20c6fa0 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/file.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/foldericon.png b/webdoc/plugins/sidebar-plugin/xtree/images/foldericon.png Binary files differnew file mode 100644 index 00000000..2684748b --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/foldericon.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/I.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/I.gif Binary files differnew file mode 100644 index 00000000..f9b3f272 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/I.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/L.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/L.gif Binary files differnew file mode 100644 index 00000000..29f21fd2 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/L.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Lminus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Lminus.gif Binary files differnew file mode 100644 index 00000000..0fae6aca --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Lminus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Lplus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Lplus.gif Binary files differnew file mode 100644 index 00000000..092e97e1 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Lplus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/T.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/T.gif Binary files differnew file mode 100644 index 00000000..9e02eb26 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/T.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Tminus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Tminus.gif Binary files differnew file mode 100644 index 00000000..3f191949 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Tminus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Tplus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Tplus.gif Binary files differnew file mode 100644 index 00000000..7a7af256 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/Tplus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/blank.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/blank.gif Binary files differnew file mode 100755 index 00000000..c23b58ca --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/blank.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_bar.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_bar.gif Binary files differnew file mode 100644 index 00000000..f9b3f272 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_bar.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_corner.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_corner.gif Binary files differnew file mode 100644 index 00000000..29f21fd2 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_corner.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_corner_minus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_corner_minus.gif Binary files differnew file mode 100644 index 00000000..0fae6aca --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_corner_minus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_corner_plus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_corner_plus.gif Binary files differnew file mode 100644 index 00000000..092e97e1 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_corner_plus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_tee.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_tee.gif Binary files differnew file mode 100644 index 00000000..9e02eb26 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_tee.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_tee_minus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_tee_minus.gif Binary files differnew file mode 100644 index 00000000..3f191949 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_tee_minus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_tee_plus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_tee_plus.gif Binary files differnew file mode 100644 index 00000000..7a7af256 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn/menu_tee_plus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/I.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/I.gif Binary files differnew file mode 100644 index 00000000..4784a029 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/I.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/L.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/L.gif Binary files differnew file mode 100644 index 00000000..29f21fd2 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/L.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Lminus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Lminus.gif Binary files differnew file mode 100644 index 00000000..4f5afece --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Lminus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Lplus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Lplus.gif Binary files differnew file mode 100644 index 00000000..c7a12abe --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Lplus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/T.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/T.gif Binary files differnew file mode 100644 index 00000000..9e02eb26 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/T.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Tminus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Tminus.gif Binary files differnew file mode 100644 index 00000000..2c60466b --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Tminus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Tplus.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Tplus.gif Binary files differnew file mode 100644 index 00000000..e444a44e --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/Tplus.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/blank.gif b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/blank.gif Binary files differnew file mode 100755 index 00000000..c23b58ca --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/msdn2/blank.gif diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/openfoldericon.png b/webdoc/plugins/sidebar-plugin/xtree/images/openfoldericon.png Binary files differnew file mode 100644 index 00000000..15fcd567 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/openfoldericon.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/I.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/I.png Binary files differnew file mode 100644 index 00000000..e8512fb9 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/I.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/L.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/L.png Binary files differnew file mode 100644 index 00000000..eb334eda --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/L.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/Lminus.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/Lminus.png Binary files differnew file mode 100644 index 00000000..bba1a318 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/Lminus.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/Lplus.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/Lplus.png Binary files differnew file mode 100644 index 00000000..727889b2 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/Lplus.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/T.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/T.png Binary files differnew file mode 100644 index 00000000..30173254 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/T.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/Tminus.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/Tminus.png Binary files differnew file mode 100644 index 00000000..ca8745a3 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/Tminus.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/Tplus.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/Tplus.png Binary files differnew file mode 100644 index 00000000..64bc9daf --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/Tplus.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/file.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/file.png Binary files differnew file mode 100644 index 00000000..a723c74f --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/file.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/folder.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/folder.png Binary files differnew file mode 100644 index 00000000..7b6835d0 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/folder.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/images/xp/openfolder.png b/webdoc/plugins/sidebar-plugin/xtree/images/xp/openfolder.png Binary files differnew file mode 100644 index 00000000..c8292f43 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/images/xp/openfolder.png diff --git a/webdoc/plugins/sidebar-plugin/xtree/xloadtree.js b/webdoc/plugins/sidebar-plugin/xtree/xloadtree.js new file mode 100644 index 00000000..24ad21b9 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/xloadtree.js @@ -0,0 +1,276 @@ +/*----------------------------------------------------------------------------\ +| XLoadTree 1.11 | +|-----------------------------------------------------------------------------| +| Created by Erik Arvidsson | +| (http://webfx.eae.net/contact.html#erik) | +| For WebFX (http://webfx.eae.net/) | +|-----------------------------------------------------------------------------| +| An extension to xTree that allows sub trees to be loaded at runtime by | +| reading XML files from the server. Works with IE5+ and Mozilla 1.0+ | +|-----------------------------------------------------------------------------| +| Copyright (c) 1999 - 2002 Erik Arvidsson | +|-----------------------------------------------------------------------------| +| This software is provided "as is", without warranty of any kind, express or | +| implied, including but not limited to the warranties of merchantability, | +| fitness for a particular purpose and noninfringement. In no event shall the | +| authors or copyright holders be liable for any claim, damages or other | +| liability, whether in an action of contract, tort or otherwise, arising | +| from, out of or in connection with the software or the use or other | +| dealings in the software. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| This software is available under the three different licenses mentioned | +| below. To use this software you must chose, and qualify, for one of those. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| The WebFX Non-Commercial License http://webfx.eae.net/license.html | +| Permits anyone the right to use the software in a non-commercial context | +| free of charge. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| The WebFX Commercial license http://webfx.eae.net/commercial.html | +| Permits the license holder the right to use the software in a commercial | +| context. Such license must be specifically obtained, however it's valid for | +| any number of implementations of the licensed software. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| GPL - The GNU General Public License http://www.gnu.org/licenses/gpl.txt | +| Permits anyone the right to use and modify the software without limitations | +| as long as proper credits are given and the original and modified source | +| code are included. Requires that the final product, software derivate from | +| the original source or any software utilizing a GPL component, such as | +| this, is also licensed under the GPL license. | +|-----------------------------------------------------------------------------| +| 2001-09-27 | Original Version Posted. | +| 2002-01-19 | Added some simple error handling and string templates for | +| | reporting the errors. | +| 2002-01-28 | Fixed loading issues in IE50 and IE55 that made the tree load | +| | twice. | +| 2002-10-10 | (1.1) Added reload method that reloads the XML file from the | +| | server. | +/ 2003-05-06 | Added support for target attribute | +|-----------------------------------------------------------------------------| +| Dependencies: xtree.js - original xtree library | +| xtree.css - simple css styling of xtree | +| xmlextras.js - provides xml http objects and xml document | +| objects | +|-----------------------------------------------------------------------------| +| Created 2001-09-27 | All changes are in the log above. | Updated 2003-05-06 | +\----------------------------------------------------------------------------*/ + + +webFXTreeConfig.loadingText = "Loading..."; +webFXTreeConfig.loadErrorTextTemplate = "Error loading \"%1%\""; +webFXTreeConfig.emptyErrorTextTemplate = "Error \"%1%\" does not contain any tree items"; + +/* + * WebFXLoadTree class + */ + +function WebFXLoadTree(sText, sXmlSrc, sAction, sBehavior, sIcon, sOpenIcon) { + // call super + this.WebFXTree = WebFXTree; + this.WebFXTree(sText, sAction, sBehavior, sIcon, sOpenIcon); + + // setup default property values + this.src = sXmlSrc; + this.loading = false; + this.loaded = false; + this.errorText = ""; + + // check start state and load if open + if (this.open) + _startLoadXmlTree(this.src, this); + else { + // and create loading item if not + this._loadingItem = new WebFXTreeItem(webFXTreeConfig.loadingText); + this.add(this._loadingItem); + } +} + +WebFXLoadTree.prototype = new WebFXTree; + +// override the expand method to load the xml file +WebFXLoadTree.prototype._webfxtree_expand = WebFXTree.prototype.expand; +WebFXLoadTree.prototype.expand = function() { + if (!this.loaded && !this.loading) { + // load + _startLoadXmlTree(this.src, this); + } + this._webfxtree_expand(); +}; + +/* + * WebFXLoadTreeItem class + */ + +function WebFXLoadTreeItem(sText, sXmlSrc, sAction, eParent, sIcon, sOpenIcon) { + // call super + this.WebFXTreeItem = WebFXTreeItem; + this.WebFXTreeItem(sText, sAction, eParent, sIcon, sOpenIcon); + + // setup default property values + this.src = sXmlSrc; + this.loading = false; + this.loaded = false; + this.errorText = ""; + + // check start state and load if open + if (this.open) + _startLoadXmlTree(this.src, this); + else { + // and create loading item if not + this._loadingItem = new WebFXTreeItem(webFXTreeConfig.loadingText); + this.add(this._loadingItem); + } +} + +WebFXLoadTreeItem.prototype = new WebFXTreeItem; + +// override the expand method to load the xml file +WebFXLoadTreeItem.prototype._webfxtreeitem_expand = WebFXTreeItem.prototype.expand; +WebFXLoadTreeItem.prototype.expand = function() { + if (!this.loaded && !this.loading) { + // load + _startLoadXmlTree(this.src, this); + } + this._webfxtreeitem_expand(); +}; + +// reloads the src file if already loaded +WebFXLoadTree.prototype.reload = +WebFXLoadTreeItem.prototype.reload = function () { + // if loading do nothing + if (this.loaded) { + var open = this.open; + // remove + while (this.childNodes.length > 0) + this.childNodes[this.childNodes.length - 1].remove(); + + this.loaded = false; + + this._loadingItem = new WebFXTreeItem(webFXTreeConfig.loadingText); + this.add(this._loadingItem); + + if (open) + this.expand(); + } + else if (this.open && !this.loading) + _startLoadXmlTree(this.src, this); +}; + +/* + * Helper functions + */ + +// creates the xmlhttp object and starts the load of the xml document +function _startLoadXmlTree(sSrc, jsNode) { + if (jsNode.loading || jsNode.loaded) + return; + jsNode.loading = true; + var xmlHttp = XmlHttp.create(); + xmlHttp.open("GET", sSrc, true); // async + xmlHttp.onreadystatechange = function () { + if (xmlHttp.readyState == 4) { + _xmlFileLoaded(xmlHttp.responseXML, jsNode); + } + }; + // call in new thread to allow ui to update + window.setTimeout(function () { + xmlHttp.send(null); + }, 10); +} + + +// Converts an xml tree to a js tree. See article about xml tree format +function _xmlTreeToJsTree(oNode) { + // retreive attributes + var text = oNode.getAttribute("text"); + var action = oNode.getAttribute("action"); + var parent = null; + var icon = oNode.getAttribute("icon"); + var openIcon = oNode.getAttribute("openIcon"); + var src = oNode.getAttribute("src"); + var target = oNode.getAttribute("target"); + // create jsNode + var jsNode; + if (src != null && src != "") + jsNode = new WebFXLoadTreeItem(text, src, action, parent, icon, openIcon); + else + jsNode = new WebFXTreeItem(text, action, parent, icon, openIcon); + + if (target != "") + jsNode.target = target; + + // go through childNOdes + var cs = oNode.childNodes; + var l = cs.length; + for (var i = 0; i < l; i++) { + if (cs[i].tagName == "tree") + jsNode.add( _xmlTreeToJsTree(cs[i]), true ); + } + + return jsNode; +} + +// Inserts an xml document as a subtree to the provided node +function _xmlFileLoaded(oXmlDoc, jsParentNode) { + if (jsParentNode.loaded) + return; + + var bIndent = false; + var bAnyChildren = false; + jsParentNode.loaded = true; + jsParentNode.loading = false; + + // check that the load of the xml file went well + if( oXmlDoc == null || oXmlDoc.documentElement == null) { + alert(oXmlDoc.xml); + jsParentNode.errorText = parseTemplateString(webFXTreeConfig.loadErrorTextTemplate, + jsParentNode.src); + } + else { + // there is one extra level of tree elements + var root = oXmlDoc.documentElement; + + // loop through all tree children + var cs = root.childNodes; + var l = cs.length; + for (var i = 0; i < l; i++) { + if (cs[i].tagName == "tree") { + bAnyChildren = true; + bIndent = true; + jsParentNode.add( _xmlTreeToJsTree(cs[i]), true); + } + } + + // if no children we got an error + if (!bAnyChildren) + jsParentNode.errorText = parseTemplateString(webFXTreeConfig.emptyErrorTextTemplate, + jsParentNode.src); + } + + // remove dummy + if (jsParentNode._loadingItem != null) { + jsParentNode._loadingItem.remove(); + bIndent = true; + } + + if (bIndent) { + // indent now that all items are added + jsParentNode.indent(); + } + + // show error in status bar + if (jsParentNode.errorText != "") + window.status = jsParentNode.errorText; +} + +// parses a string and replaces %n% with argument nr n +function parseTemplateString(sTemplate) { + var args = arguments; + var s = sTemplate; + + s = s.replace(/\%\%/g, "%"); + + for (var i = 1; i < args.length; i++) + s = s.replace( new RegExp("\%" + i + "\%", "g"), args[i] ) + + return s; +}
\ No newline at end of file diff --git a/webdoc/plugins/sidebar-plugin/xtree/xmlextras.js b/webdoc/plugins/sidebar-plugin/xtree/xmlextras.js new file mode 100644 index 00000000..70806c28 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/xmlextras.js @@ -0,0 +1,147 @@ +//<script> +////////////////// +// Helper Stuff // +////////////////// + +// used to find the Automation server name +function getDomDocumentPrefix() { + if (getDomDocumentPrefix.prefix) + return getDomDocumentPrefix.prefix; + + var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"]; + var o; + for (var i = 0; i < prefixes.length; i++) { + try { + // try to create the objects + o = new ActiveXObject(prefixes[i] + ".DomDocument"); + return getDomDocumentPrefix.prefix = prefixes[i]; + } + catch (ex) {}; + } + + throw new Error("Could not find an installed XML parser"); +} + +function getXmlHttpPrefix() { + if (getXmlHttpPrefix.prefix) + return getXmlHttpPrefix.prefix; + + var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"]; + var o; + for (var i = 0; i < prefixes.length; i++) { + try { + // try to create the objects + o = new ActiveXObject(prefixes[i] + ".XmlHttp"); + return getXmlHttpPrefix.prefix = prefixes[i]; + } + catch (ex) {}; + } + + throw new Error("Could not find an installed XML parser"); +} + +////////////////////////// +// Start the Real stuff // +////////////////////////// + + +// XmlHttp factory +function XmlHttp() {} + +XmlHttp.create = function () { + try { + if (window.XMLHttpRequest) { + var req = new XMLHttpRequest(); + + // some versions of Moz do not support the readyState property + // and the onreadystate event so we patch it! + if (req.readyState == null) { + req.readyState = 1; + req.addEventListener("load", function () { + req.readyState = 4; + if (typeof req.onreadystatechange == "function") + req.onreadystatechange(); + }, false); + } + + return req; + } + if (window.ActiveXObject) { + return new ActiveXObject(getXmlHttpPrefix() + ".XmlHttp"); + } + } + catch (ex) {} + // fell through + throw new Error("Your browser does not support XmlHttp objects"); +}; + +// XmlDocument factory +function XmlDocument() {} + +XmlDocument.create = function () { + try { + // DOM2 + if (document.implementation && document.implementation.createDocument) { + var doc = document.implementation.createDocument("", "", null); + + // some versions of Moz do not support the readyState property + // and the onreadystate event so we patch it! + if (doc.readyState == null) { + doc.readyState = 1; + doc.addEventListener("load", function () { + doc.readyState = 4; + if (typeof doc.onreadystatechange == "function") + doc.onreadystatechange(); + }, false); + } + + return doc; + } + if (window.ActiveXObject) + return new ActiveXObject(getDomDocumentPrefix() + ".DomDocument"); + } + catch (ex) {} + throw new Error("Your browser does not support XmlDocument objects"); +}; + +// Create the loadXML method and xml getter for Mozilla +if (window.DOMParser && + window.XMLSerializer && + window.Node && Node.prototype && Node.prototype.__defineGetter__) { + + // XMLDocument did not extend the Document interface in some versions + // of Mozilla. Extend both! + XMLDocument.prototype.loadXML = + Document.prototype.loadXML = function (s) { + + // parse the string to a new doc + var doc2 = (new DOMParser()).parseFromString(s, "text/xml"); + + // remove all initial children + while (this.hasChildNodes()) + this.removeChild(this.lastChild); + + // insert and import nodes + for (var i = 0; i < doc2.childNodes.length; i++) { + this.appendChild(this.importNode(doc2.childNodes[i], true)); + } + }; + + + /* + * xml getter + * + * This serializes the DOM tree to an XML String + * + * Usage: var sXml = oNode.xml + * + */ + // XMLDocument did not extend the Document interface in some versions + // of Mozilla. Extend both! + XMLDocument.prototype.__defineGetter__("xml", function () { + return (new XMLSerializer()).serializeToString(this); + }); + Document.prototype.__defineGetter__("xml", function () { + return (new XMLSerializer()).serializeToString(this); + }); +}
\ No newline at end of file diff --git a/webdoc/plugins/sidebar-plugin/xtree/xtree.css b/webdoc/plugins/sidebar-plugin/xtree/xtree.css new file mode 100644 index 00000000..3630da97 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/xtree.css @@ -0,0 +1,54 @@ +body { + font-family: verdana; + font-size: 70.5%; + font-weight: normal; + background-color: #f1f1f1; + color: Black; + margin: 0px 0px 0px 0px; + padding: 0px 0px 0px 0px; +} + +.webfx-tree-container { + margin: 0px; + padding: 0px; + white-space: nowrap; +} + +.webfx-tree-item { + padding: 0px; + margin: 0px; + color: WindowText; + white-space: nowrap; + height: 16px; +} + +.webfx-tree-item a, .webfx-tree-item a:active, .webfx-tree-item a:hover { + margin-left: 3px; + padding: 0px 2px 1px 2px; +} + +.webfx-tree-item a { + color: black; + text-decoration: none; +} + +.webfx-tree-item a:hover { + color: blue; + text-decoration: underline; +} + +.webfx-tree-item a:active { + background: highlight; + color: highlighttext; + text-decoration: none; +} + +.webfx-tree-item img { + vertical-align: middle; + border: 0px; +} + +.webfx-tree-icon { + width:0px; + visibility: hidden; +}
\ No newline at end of file diff --git a/webdoc/plugins/sidebar-plugin/xtree/xtree.js b/webdoc/plugins/sidebar-plugin/xtree/xtree.js new file mode 100644 index 00000000..19362e10 --- /dev/null +++ b/webdoc/plugins/sidebar-plugin/xtree/xtree.js @@ -0,0 +1,541 @@ +/*----------------------------------------------------------------------------\ +| Cross Browser Tree Widget 1.17 | +|-----------------------------------------------------------------------------| +| Created by Emil A Eklund | +| (http://webfx.eae.net/contact.html#emil) | +| For WebFX (http://webfx.eae.net/) | +|-----------------------------------------------------------------------------| +| An object based tree widget, emulating the one found in microsoft windows, | +| with persistence using cookies. Works in IE 5+, Mozilla and konqueror 3. | +|-----------------------------------------------------------------------------| +| Copyright (c) 1999 - 2002 Emil A Eklund | +|-----------------------------------------------------------------------------| +| This software is provided "as is", without warranty of any kind, express or | +| implied, including but not limited to the warranties of merchantability, | +| fitness for a particular purpose and noninfringement. In no event shall the | +| authors or copyright holders be liable for any claim, damages or other | +| liability, whether in an action of contract, tort or otherwise, arising | +| from, out of or in connection with the software or the use or other | +| dealings in the software. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| This software is available under the three different licenses mentioned | +| below. To use this software you must chose, and qualify, for one of those. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| The WebFX Non-Commercial License http://webfx.eae.net/license.html | +| Permits anyone the right to use the software in a non-commercial context | +| free of charge. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| The WebFX Commercial license http://webfx.eae.net/commercial.html | +| Permits the license holder the right to use the software in a commercial | +| context. Such license must be specifically obtained, however it's valid for | +| any number of implementations of the licensed software. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| GPL - The GNU General Public License http://www.gnu.org/licenses/gpl.txt | +| Permits anyone the right to use and modify the software without limitations | +| as long as proper credits are given and the original and modified source | +| code are included. Requires that the final product, software derivate from | +| the original source or any software utilizing a GPL component, such as | +| this, is also licensed under the GPL license. | +|-----------------------------------------------------------------------------| +| Dependencies: xtree.css (To set up the CSS of the tree classes) | +|-----------------------------------------------------------------------------| +| 2001-01-10 | Original Version Posted. | +| 2001-03-18 | Added getSelected and get/setBehavior that can make it behave | +| | more like windows explorer, check usage for more information. | +| 2001-09-23 | Version 1.1 - New features included keyboard navigation (ie) | +| | and the ability to add and remove nodes dynamically and some | +| | other small tweaks and fixes. | +| 2002-01-27 | Version 1.11 - Bug fixes and improved mozilla support. | +| 2002-06-11 | Version 1.12 - Fixed a bug that prevented the indentation line | +| | from updating correctly under some circumstances. This bug | +| | happened when removing the last item in a subtree and items in | +| | siblings to the remove subtree where not correctly updated. | +| 2002-06-13 | Fixed a few minor bugs cased by the 1.12 bug-fix. | +| 2002-08-20 | Added usePersistence flag to allow disable of cookies. | +| 2002-10-23 | (1.14) Fixed a plus icon issue | +| 2002-10-29 | (1.15) Last changes broke more than they fixed. This version | +| | is based on 1.13 and fixes the bugs 1.14 fixed withou breaking | +| | lots of other things. | +| 2003-02-15 | The selected node can now be made visible even when the tree | +| | control loses focus. It uses a new class declaration in the | +| | css file '.webfx-tree-item a.selected-inactive', by default it | +| | puts a light-gray rectangle around the selected node. | +| 2003-03-16 | Adding target support after lots of lobbying... | +|-----------------------------------------------------------------------------| +| Created 2000-12-11 | All changes are in the log above. | Updated 2003-03-16 | +\----------------------------------------------------------------------------*/ + +var webFXTreeConfig = { + rootIcon : 'xtree/images/foldericon.png', + openRootIcon : 'xtree/images/openfoldericon.png', + folderIcon : 'xtree/images/foldericon.png', + openFolderIcon : 'xtree/images/openfoldericon.png', + fileIcon : 'xtree/images/file.png', + iIcon : 'xtree/images/I.png', + lIcon : 'xtree/images/L.png', + lMinusIcon : 'xtree/images/Lminus.png', + lPlusIcon : 'xtree/images/Lplus.png', + tIcon : 'xtree/images/T.png', + tMinusIcon : 'xtree/images/Tminus.png', + tPlusIcon : 'xtree/images/Tplus.png', + blankIcon : 'xtree/images/blank.png', + defaultText : 'Tree Item', + defaultAction : 'javascript:void(0);', + defaultBehavior : 'classic', + usePersistence : true +}; + +var webFXTreeHandler = { + idCounter : 0, + idPrefix : "webfx-tree-object-", + all : {}, + behavior : null, + selected : null, + onSelect : null, /* should be part of tree, not handler */ + getId : function() { return this.idPrefix + this.idCounter++; }, + toggle : function (oItem) { this.all[oItem.id.replace('-plus','')].toggle(); }, + select : function (oItem) { this.all[oItem.id.replace('-icon','')].select(); }, + focus : function (oItem) { this.all[oItem.id.replace('-anchor','')].focus(); }, + blur : function (oItem) { this.all[oItem.id.replace('-anchor','')].blur(); }, + keydown : function (oItem, e) { return this.all[oItem.id].keydown(e.keyCode); }, + cookies : new WebFXCookie(), + insertHTMLBeforeEnd : function (oElement, sHTML) { + if (oElement.insertAdjacentHTML != null) { + oElement.insertAdjacentHTML("BeforeEnd", sHTML) + return; + } + var df; // DocumentFragment + var r = oElement.ownerDocument.createRange(); + r.selectNodeContents(oElement); + r.collapse(false); + df = r.createContextualFragment(sHTML); + oElement.appendChild(df); + } +}; + +/* + * WebFXCookie class + */ + +function WebFXCookie() { + if (document.cookie.length) { this.cookies = ' ' + document.cookie; } +} + +WebFXCookie.prototype.setCookie = function (key, value) { + document.cookie = key + "=" + escape(value); +} + +WebFXCookie.prototype.getCookie = function (key) { + if (this.cookies) { + var start = this.cookies.indexOf(' ' + key + '='); + if (start == -1) { return null; } + var end = this.cookies.indexOf(";", start); + if (end == -1) { end = this.cookies.length; } + end -= start; + var cookie = this.cookies.substr(start,end); + return unescape(cookie.substr(cookie.indexOf('=') + 1, cookie.length - cookie.indexOf('=') + 1)); + } + else { return null; } +} + +/* + * WebFXTreeAbstractNode class + */ + +function WebFXTreeAbstractNode(sText, sAction) { + this.childNodes = []; + this.id = webFXTreeHandler.getId(); + this.text = sText || webFXTreeConfig.defaultText; + this.action = sAction || webFXTreeConfig.defaultAction; + this._last = false; + webFXTreeHandler.all[this.id] = this; +} + +/* + * To speed thing up if you're adding multiple nodes at once (after load) + * use the bNoIdent parameter to prevent automatic re-indentation and call + * the obj.ident() method manually once all nodes has been added. + */ + +WebFXTreeAbstractNode.prototype.add = function (node, bNoIdent) { + node.parentNode = this; + this.childNodes[this.childNodes.length] = node; + var root = this; + if (this.childNodes.length >= 2) { + this.childNodes[this.childNodes.length - 2]._last = false; + } + while (root.parentNode) { root = root.parentNode; } + if (root.rendered) { + if (this.childNodes.length >= 2) { + document.getElementById(this.childNodes[this.childNodes.length - 2].id + '-plus').src = ((this.childNodes[this.childNodes.length -2].folder)?((this.childNodes[this.childNodes.length -2].open)?webFXTreeConfig.tMinusIcon:webFXTreeConfig.tPlusIcon):webFXTreeConfig.tIcon); + this.childNodes[this.childNodes.length - 2].plusIcon = webFXTreeConfig.tPlusIcon; + this.childNodes[this.childNodes.length - 2].minusIcon = webFXTreeConfig.tMinusIcon; + this.childNodes[this.childNodes.length - 2]._last = false; + } + this._last = true; + var foo = this; + while (foo.parentNode) { + for (var i = 0; i < foo.parentNode.childNodes.length; i++) { + if (foo.id == foo.parentNode.childNodes[i].id) { break; } + } + if (i == foo.parentNode.childNodes.length - 1) { foo.parentNode._last = true; } + else { foo.parentNode._last = false; } + foo = foo.parentNode; + } + webFXTreeHandler.insertHTMLBeforeEnd(document.getElementById(this.id + '-cont'), node.toString()); + if ((!this.folder) && (!this.openIcon)) { + this.icon = webFXTreeConfig.folderIcon; + this.openIcon = webFXTreeConfig.openFolderIcon; + } + if (!this.folder) { this.folder = true; this.collapse(true); } + if (!bNoIdent) { this.indent(); } + } + return node; +} + +WebFXTreeAbstractNode.prototype.toggle = function() { + if (this.folder) { + if (this.open) { this.collapse(); } + else { this.expand(); } +} } + +WebFXTreeAbstractNode.prototype.select = function() { + document.getElementById(this.id + '-anchor').focus(); +} + +WebFXTreeAbstractNode.prototype.deSelect = function() { + document.getElementById(this.id + '-anchor').className = ''; + webFXTreeHandler.selected = null; +} + +WebFXTreeAbstractNode.prototype.focus = function() { + if ((webFXTreeHandler.selected) && (webFXTreeHandler.selected != this)) { webFXTreeHandler.selected.deSelect(); } + webFXTreeHandler.selected = this; + if ((this.openIcon) && (webFXTreeHandler.behavior != 'classic')) { document.getElementById(this.id + '-icon').src = this.openIcon; } + document.getElementById(this.id + '-anchor').className = 'selected'; + document.getElementById(this.id + '-anchor').focus(); + if (webFXTreeHandler.onSelect) { webFXTreeHandler.onSelect(this); } +} + +WebFXTreeAbstractNode.prototype.blur = function() { + if ((this.openIcon) && (webFXTreeHandler.behavior != 'classic')) { document.getElementById(this.id + '-icon').src = this.icon; } + document.getElementById(this.id + '-anchor').className = 'selected-inactive'; +} + +WebFXTreeAbstractNode.prototype.doExpand = function() { + if (webFXTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = this.openIcon; } + if (this.childNodes.length) { document.getElementById(this.id + '-cont').style.display = 'block'; } + this.open = true; + if (webFXTreeConfig.usePersistence) { + webFXTreeHandler.cookies.setCookie(this.id.substr(18,this.id.length - 18), '1'); +} } + +WebFXTreeAbstractNode.prototype.doCollapse = function() { + if (webFXTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = this.icon; } + if (this.childNodes.length) { document.getElementById(this.id + '-cont').style.display = 'none'; } + this.open = false; + if (webFXTreeConfig.usePersistence) { + webFXTreeHandler.cookies.setCookie(this.id.substr(18,this.id.length - 18), '0'); +} } + +WebFXTreeAbstractNode.prototype.expandAll = function() { + this.expandChildren(); + if ((this.folder) && (!this.open)) { this.expand(); } +} + +WebFXTreeAbstractNode.prototype.expandChildren = function() { + for (var i = 0; i < this.childNodes.length; i++) { + this.childNodes[i].expandAll(); +} } + +WebFXTreeAbstractNode.prototype.collapseAll = function() { + this.collapseChildren(); + if ((this.folder) && (this.open)) { this.collapse(true); } +} + +WebFXTreeAbstractNode.prototype.collapseChildren = function() { + for (var i = 0; i < this.childNodes.length; i++) { + this.childNodes[i].collapseAll(); +} } + +WebFXTreeAbstractNode.prototype.indent = function(lvl, del, last, level, nodesLeft) { + /* + * Since we only want to modify items one level below ourself, + * and since the rightmost indentation position is occupied by + * the plus icon we set this to -2 + */ + if (lvl == null) { lvl = -2; } + var state = 0; + for (var i = this.childNodes.length - 1; i >= 0 ; i--) { + state = this.childNodes[i].indent(lvl + 1, del, last, level); + if (state) { return; } + } + if (del) { + if ((level >= this._level) && (document.getElementById(this.id + '-plus'))) { + if (this.folder) { + document.getElementById(this.id + '-plus').src = (this.open)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.lPlusIcon; + this.plusIcon = webFXTreeConfig.lPlusIcon; + this.minusIcon = webFXTreeConfig.lMinusIcon; + } + else if (nodesLeft) { document.getElementById(this.id + '-plus').src = webFXTreeConfig.lIcon; } + return 1; + } } + var foo = document.getElementById(this.id + '-indent-' + lvl); + if (foo) { + if ((foo._last) || ((del) && (last))) { foo.src = webFXTreeConfig.blankIcon; } + else { foo.src = webFXTreeConfig.iIcon; } + } + return 0; +} + +/* + * WebFXTree class + */ + +function WebFXTree(sText, sAction, sBehavior, sIcon, sOpenIcon) { + this.base = WebFXTreeAbstractNode; + this.base(sText, sAction); + this.icon = sIcon || webFXTreeConfig.rootIcon; + this.openIcon = sOpenIcon || webFXTreeConfig.openRootIcon; + /* Defaults to open */ + if (webFXTreeConfig.usePersistence) { + this.open = (webFXTreeHandler.cookies.getCookie(this.id.substr(18,this.id.length - 18)) == '0')?false:true; + } else { this.open = true; } + this.folder = true; + this.rendered = false; + this.onSelect = null; + if (!webFXTreeHandler.behavior) { webFXTreeHandler.behavior = sBehavior || webFXTreeConfig.defaultBehavior; } +} + +WebFXTree.prototype = new WebFXTreeAbstractNode; + +WebFXTree.prototype.setBehavior = function (sBehavior) { + webFXTreeHandler.behavior = sBehavior; +}; + +WebFXTree.prototype.getBehavior = function (sBehavior) { + return webFXTreeHandler.behavior; +}; + +WebFXTree.prototype.getSelected = function() { + if (webFXTreeHandler.selected) { return webFXTreeHandler.selected; } + else { return null; } +} + +WebFXTree.prototype.remove = function() { } + +WebFXTree.prototype.expand = function() { + this.doExpand(); +} + +WebFXTree.prototype.collapse = function(b) { + if (!b) { this.focus(); } + this.doCollapse(); +} + +WebFXTree.prototype.getFirst = function() { + return null; +} + +WebFXTree.prototype.getLast = function() { + return null; +} + +WebFXTree.prototype.getNextSibling = function() { + return null; +} + +WebFXTree.prototype.getPreviousSibling = function() { + return null; +} + +WebFXTree.prototype.keydown = function(key) { + if (key == 39) { + if (!this.open) { this.expand(); } + else if (this.childNodes.length) { this.childNodes[0].select(); } + return false; + } + if (key == 37) { this.collapse(); return false; } + if ((key == 40) && (this.open) && (this.childNodes.length)) { this.childNodes[0].select(); return false; } + return true; +} + +WebFXTree.prototype.toString = function() { + var str = "<div id=\"" + this.id + "\" ondblclick=\"webFXTreeHandler.toggle(this);\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this, event)\">" + + "<img id=\"" + this.id + "-icon\" class=\"webfx-tree-icon\" src=\"" + ((webFXTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"webFXTreeHandler.select(this);\">" + + "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\"" + + (this.target ? " target=\"" + this.target + "\"" : "") + + ">" + this.text + "</a></div>" + + "<div id=\"" + this.id + "-cont\" class=\"webfx-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">"; + var sb = []; + for (var i = 0; i < this.childNodes.length; i++) { + sb[i] = this.childNodes[i].toString(i, this.childNodes.length); + } + this.rendered = true; + return str + sb.join("") + "</div>"; +}; + +/* + * WebFXTreeItem class + */ + +function WebFXTreeItem(sText, sAction, eParent, sIcon, sOpenIcon) { + this.base = WebFXTreeAbstractNode; + this.base(sText, sAction); + /* Defaults to close */ + if (webFXTreeConfig.usePersistence) { + this.open = (webFXTreeHandler.cookies.getCookie(this.id.substr(18,this.id.length - 18)) == '1')?true:false; + } else { this.open = false; } + if (sIcon) { this.icon = sIcon; } + if (sOpenIcon) { this.openIcon = sOpenIcon; } + if (eParent) { eParent.add(this); } +} + +WebFXTreeItem.prototype = new WebFXTreeAbstractNode; + +WebFXTreeItem.prototype.remove = function() { + var iconSrc = document.getElementById(this.id + '-plus').src; + var parentNode = this.parentNode; + var prevSibling = this.getPreviousSibling(true); + var nextSibling = this.getNextSibling(true); + var folder = this.parentNode.folder; + var last = ((nextSibling) && (nextSibling.parentNode) && (nextSibling.parentNode.id == parentNode.id))?false:true; + this.getPreviousSibling().focus(); + this._remove(); + if (parentNode.childNodes.length == 0) { + document.getElementById(parentNode.id + '-cont').style.display = 'none'; + parentNode.doCollapse(); + parentNode.folder = false; + parentNode.open = false; + } + if (!nextSibling || last) { parentNode.indent(null, true, last, this._level, parentNode.childNodes.length); } + if ((prevSibling == parentNode) && !(parentNode.childNodes.length)) { + prevSibling.folder = false; + prevSibling.open = false; + iconSrc = document.getElementById(prevSibling.id + '-plus').src; + iconSrc = iconSrc.replace('minus', '').replace('plus', ''); + document.getElementById(prevSibling.id + '-plus').src = iconSrc; + document.getElementById(prevSibling.id + '-icon').src = webFXTreeConfig.fileIcon; + } + if (document.getElementById(prevSibling.id + '-plus')) { + if (parentNode == prevSibling.parentNode) { + iconSrc = iconSrc.replace('minus', '').replace('plus', ''); + document.getElementById(prevSibling.id + '-plus').src = iconSrc; +} } } + +WebFXTreeItem.prototype._remove = function() { + for (var i = this.childNodes.length - 1; i >= 0; i--) { + this.childNodes[i]._remove(); + } + for (var i = 0; i < this.parentNode.childNodes.length; i++) { + if (this == this.parentNode.childNodes[i]) { + for (var j = i; j < this.parentNode.childNodes.length; j++) { + this.parentNode.childNodes[j] = this.parentNode.childNodes[j+1]; + } + this.parentNode.childNodes.length -= 1; + if (i + 1 == this.parentNode.childNodes.length) { this.parentNode._last = true; } + break; + } } + webFXTreeHandler.all[this.id] = null; + var tmp = document.getElementById(this.id); + if (tmp) { tmp.parentNode.removeChild(tmp); } + tmp = document.getElementById(this.id + '-cont'); + if (tmp) { tmp.parentNode.removeChild(tmp); } +} + +WebFXTreeItem.prototype.expand = function() { + this.doExpand(); + document.getElementById(this.id + '-plus').src = this.minusIcon; +} + +WebFXTreeItem.prototype.collapse = function(b) { + if (!b) { this.focus(); } + this.doCollapse(); + document.getElementById(this.id + '-plus').src = this.plusIcon; +} + +WebFXTreeItem.prototype.getFirst = function() { + return this.childNodes[0]; +} + +WebFXTreeItem.prototype.getLast = function() { + if (this.childNodes[this.childNodes.length - 1].open) { return this.childNodes[this.childNodes.length - 1].getLast(); } + else { return this.childNodes[this.childNodes.length - 1]; } +} + +WebFXTreeItem.prototype.getNextSibling = function() { + for (var i = 0; i < this.parentNode.childNodes.length; i++) { + if (this == this.parentNode.childNodes[i]) { break; } + } + if (++i == this.parentNode.childNodes.length) { return this.parentNode.getNextSibling(); } + else { return this.parentNode.childNodes[i]; } +} + +WebFXTreeItem.prototype.getPreviousSibling = function(b) { + for (var i = 0; i < this.parentNode.childNodes.length; i++) { + if (this == this.parentNode.childNodes[i]) { break; } + } + if (i == 0) { return this.parentNode; } + else { + if ((this.parentNode.childNodes[--i].open) || (b && this.parentNode.childNodes[i].folder)) { return this.parentNode.childNodes[i].getLast(); } + else { return this.parentNode.childNodes[i]; } +} } + +WebFXTreeItem.prototype.keydown = function(key) { + if ((key == 39) && (this.folder)) { + if (!this.open) { this.expand(); } + else { this.getFirst().select(); } + return false; + } + else if (key == 37) { + if (this.open) { this.collapse(); } + else { this.parentNode.select(); } + return false; + } + else if (key == 40) { + if (this.open) { this.getFirst().select(); } + else { + var sib = this.getNextSibling(); + if (sib) { sib.select(); } + } + return false; + } + else if (key == 38) { this.getPreviousSibling().select(); return false; } + return true; +} + +WebFXTreeItem.prototype.toString = function (nItem, nItemCount) { + var foo = this.parentNode; + var indent = ''; + if (nItem + 1 == nItemCount) { this.parentNode._last = true; } + var i = 0; + while (foo.parentNode) { + foo = foo.parentNode; + indent = "<img id=\"" + this.id + "-indent-" + i + "\" src=\"" + ((foo._last)?webFXTreeConfig.blankIcon:webFXTreeConfig.iIcon) + "\">" + indent; + i++; + } + this._level = i; + if (this.childNodes.length) { this.folder = 1; } + else { this.open = false; } + if ((this.folder) || (webFXTreeHandler.behavior != 'classic')) { + if (!this.icon) { this.icon = webFXTreeConfig.folderIcon; } + if (!this.openIcon) { this.openIcon = webFXTreeConfig.openFolderIcon; } + } + else if (!this.icon) { this.icon = webFXTreeConfig.fileIcon; } + var label = this.text.replace(/</g, '<').replace(/>/g, '>'); + var str = "<div id=\"" + this.id + "\" ondblclick=\"webFXTreeHandler.toggle(this);\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this, event)\">" + + indent + + "<img id=\"" + this.id + "-plus\" src=\"" + ((this.folder)?((this.open)?((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon):((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon)):((this.parentNode._last)?webFXTreeConfig.lIcon:webFXTreeConfig.tIcon)) + "\" onclick=\"webFXTreeHandler.toggle(this);\">" + + "<img id=\"" + this.id + "-icon\" class=\"webfx-tree-icon\" src=\"" + ((webFXTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"webFXTreeHandler.select(this);\">" + + "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\"" + + (this.target ? " target=\"" + this.target + "\"" : "") + + ">" + label + "</a></div>" + + "<div id=\"" + this.id + "-cont\" class=\"webfx-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">"; + var sb = []; + for (var i = 0; i < this.childNodes.length; i++) { + sb[i] = this.childNodes[i].toString(i,this.childNodes.length); + } + this.plusIcon = ((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon); + this.minusIcon = ((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon); + return str + sb.join("") + "</div>"; +}
\ No newline at end of file |