📄 treeview.js
字号:
} else {this.dataLoader = null;this._dynLoad = false;}if (iconMode) {this.iconMode = iconMode;}}, isRoot:function () {return (this == this.tree.root);}, isDynamic:function () {var lazy = (!this.isRoot() && (this._dynLoad || this.tree.root._dynLoad));return lazy;}, getIconMode:function () {return (this.iconMode || this.tree.root.iconMode);}, hasChildren:function (checkForLazyLoad) {return (this.children.length > 0 || (checkForLazyLoad && this.isDynamic() && !this.dynamicLoadComplete));}, toggle:function () {if (!this.tree.locked && (this.hasChildren(true) || this.isDynamic())) {if (this.expanded) {this.collapse();} else {this.expand();}}}, getHtml:function () {var sb = [];sb[sb.length] = "<div class=\"ygtvitem\" id=\"" + this.getElId() + "\">";sb[sb.length] = this.getNodeHtml();sb[sb.length] = this.getChildrenHtml();sb[sb.length] = "</div>";return sb.join("");}, getChildrenHtml:function () {var sb = [];sb[sb.length] = "<div class=\"ygtvchildren\"";sb[sb.length] = " id=\"" + this.getChildrenElId() + "\"";if (!this.expanded) {sb[sb.length] = " style=\"display:none;\"";}sb[sb.length] = ">";if ((this.hasChildren(true) && this.expanded) || (this.renderHidden && !this.isDynamic())) {sb[sb.length] = this.renderChildren();}sb[sb.length] = "</div>";return sb.join("");}, renderChildren:function () {var node = this;if (this.isDynamic() && !this.dynamicLoadComplete) {this.isLoading = true;this.tree.locked = true;if (this.dataLoader) {setTimeout(function () {node.dataLoader(node, function () {node.loadComplete();});}, 10);} else {if (this.tree.root.dataLoader) {setTimeout(function () {node.tree.root.dataLoader(node, function () {node.loadComplete();});}, 10);} else {return "Error: data loader not found or not specified.";}}return "";} else {return this.completeRender();}}, completeRender:function () {var sb = [];for (var i = 0; i < this.children.length; ++i) {this.children[i].childrenRendered = false;sb[sb.length] = this.children[i].getHtml();}this.childrenRendered = true;return sb.join("");}, loadComplete:function () {this.getChildrenEl().innerHTML = this.completeRender();this.dynamicLoadComplete = true;this.isLoading = false;this.expand();this.tree.locked = false;}, getAncestor:function (depth) {if (depth >= this.depth || depth < 0) {return null;}var p = this.parent;while (p.depth > depth) {p = p.parent;}return p;}, getDepthStyle:function (depth) {return (this.getAncestor(depth).nextSibling) ? "ygtvdepthcell" : "ygtvblankdepthcell";}, getNodeHtml:function () {return "";}, refresh:function () {this.getChildrenEl().innerHTML = this.completeRender();if (this.hasIcon) {var el = this.getToggleEl();if (el) {el.className = this.getStyle();}}}, toString:function () {return "Node (" + this.index + ")";}};YAHOO.widget.RootNode = function (oTree) {this.init(null, null, true);this.tree = oTree;};YAHOO.widget.RootNode.prototype = new YAHOO.widget.Node();YAHOO.widget.RootNode.prototype.getNodeHtml = function () {return "";};YAHOO.widget.RootNode.prototype.toString = function () {return "RootNode";};YAHOO.widget.RootNode.prototype.loadComplete = function () {this.tree.draw();};YAHOO.widget.TextNode = function (oData, oParent, expanded) {if (oData) {this.init(oData, oParent, expanded);this.setUpLabel(oData);}};YAHOO.widget.TextNode.prototype = new YAHOO.widget.Node();YAHOO.widget.TextNode.prototype.labelStyle = "ygtvlabel";YAHOO.widget.TextNode.prototype.labelElId = null;YAHOO.widget.TextNode.prototype.label = null;YAHOO.widget.TextNode.prototype.setUpLabel = function (oData) {if (typeof oData == "string") {oData = {label:oData};}this.label = oData.label;if (oData.href) {this.href = oData.href;}if (oData.target) {this.target = oData.target;}if (oData.style) {this.labelStyle = oData.style;}this.labelElId = "ygtvlabelel" + this.index;};YAHOO.widget.TextNode.prototype.getLabelEl = function () {return document.getElementById(this.labelElId);};YAHOO.widget.TextNode.prototype.getNodeHtml = function () {var sb = [];sb[sb.length] = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";sb[sb.length] = "<tr>";for (i = 0; i < this.depth; ++i) {sb[sb.length] = "<td class=\"" + this.getDepthStyle(i) + "\"> </td>";}var getNode = "YAHOO.widget.TreeView.getNode('" + this.tree.id + "'," + this.index + ")";sb[sb.length] = "<td";sb[sb.length] = " id=\"" + this.getToggleElId() + "\"";sb[sb.length] = " class=\"" + this.getStyle() + "\"";if (this.hasChildren(true)) {sb[sb.length] = " onmouseover=\"this.className=";sb[sb.length] = getNode + ".getHoverStyle()\"";sb[sb.length] = " onmouseout=\"this.className=";sb[sb.length] = getNode + ".getStyle()\"";}sb[sb.length] = " onclick=\"javascript:" + this.getToggleLink() + "\">";sb[sb.length] = " ";sb[sb.length] = "</td>";sb[sb.length] = "<td>";sb[sb.length] = "<a";sb[sb.length] = " id=\"" + this.labelElId + "\"";sb[sb.length] = " class=\"" + this.labelStyle + "\"";sb[sb.length] = " href=\"" + this.href + "\"";sb[sb.length] = " target=\"" + this.target + "\"";sb[sb.length] = " onclick=\"return " + getNode + ".onLabelClick(" + getNode + ")\"";if (this.hasChildren(true)) {sb[sb.length] = " onmouseover=\"document.getElementById('";sb[sb.length] = this.getToggleElId() + "').className=";sb[sb.length] = getNode + ".getHoverStyle()\"";sb[sb.length] = " onmouseout=\"document.getElementById('";sb[sb.length] = this.getToggleElId() + "').className=";sb[sb.length] = getNode + ".getStyle()\"";}sb[sb.length] = " >";sb[sb.length] = this.label;sb[sb.length] = "</a>";sb[sb.length] = "</td>";sb[sb.length] = "</tr>";sb[sb.length] = "</table>";return sb.join("");};YAHOO.widget.TextNode.prototype.onLabelClick = function (me) {};YAHOO.widget.TextNode.prototype.toString = function () {return "TextNode (" + this.index + ") " + this.label;};YAHOO.widget.MenuNode = function (oData, oParent, expanded) {if (oData) {this.init(oData, oParent, expanded);this.setUpLabel(oData);}this.multiExpand = false;};YAHOO.widget.MenuNode.prototype = new YAHOO.widget.TextNode();YAHOO.widget.MenuNode.prototype.toString = function () {return "MenuNode (" + this.index + ") " + this.label;};YAHOO.widget.HTMLNode = function (oData, oParent, expanded, hasIcon) {if (oData) {this.init(oData, oParent, expanded);this.initContent(oData, hasIcon);}};YAHOO.widget.HTMLNode.prototype = new YAHOO.widget.Node();YAHOO.widget.HTMLNode.prototype.contentStyle = "ygtvhtml";YAHOO.widget.HTMLNode.prototype.contentElId = null;YAHOO.widget.HTMLNode.prototype.content = null;YAHOO.widget.HTMLNode.prototype.initContent = function (oData, hasIcon) {if (typeof oData == "string") {oData = {html:oData};}this.html = oData.html;this.contentElId = "ygtvcontentel" + this.index;this.hasIcon = hasIcon;};YAHOO.widget.HTMLNode.prototype.getContentEl = function () {return document.getElementById(this.contentElId);};YAHOO.widget.HTMLNode.prototype.getNodeHtml = function () {var sb = [];sb[sb.length] = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";sb[sb.length] = "<tr>";for (i = 0; i < this.depth; ++i) {sb[sb.length] = "<td class=\"" + this.getDepthStyle(i) + "\"> </td>";}if (this.hasIcon) {sb[sb.length] = "<td";sb[sb.length] = " id=\"" + this.getToggleElId() + "\"";sb[sb.length] = " class=\"" + this.getStyle() + "\"";sb[sb.length] = " onclick=\"javascript:" + this.getToggleLink() + "\"";if (this.hasChildren(true)) {sb[sb.length] = " onmouseover=\"this.className=";sb[sb.length] = "YAHOO.widget.TreeView.getNode('";sb[sb.length] = this.tree.id + "'," + this.index + ").getHoverStyle()\"";sb[sb.length] = " onmouseout=\"this.className=";sb[sb.length] = "YAHOO.widget.TreeView.getNode('";sb[sb.length] = this.tree.id + "'," + this.index + ").getStyle()\"";}sb[sb.length] = "> </td>";}sb[sb.length] = "<td";sb[sb.length] = " id=\"" + this.contentElId + "\"";sb[sb.length] = " class=\"" + this.contentStyle + "\"";sb[sb.length] = " >";sb[sb.length] = this.html;sb[sb.length] = "</td>";sb[sb.length] = "</tr>";sb[sb.length] = "</table>";return sb.join("");};YAHOO.widget.HTMLNode.prototype.toString = function () {return "HTMLNode (" + this.index + ")";};YAHOO.widget.TVAnim = function () {return {FADE_IN:"TVFadeIn", FADE_OUT:"TVFadeOut", getAnim:function (type, el, callback) {if (YAHOO.widget[type]) {return new YAHOO.widget[type](el, callback);} else {return null;}}, isValid:function (type) {return (YAHOO.widget[type]);}};}();YAHOO.widget.TVFadeIn = function (el, callback) {this.el = el;this.callback = callback;};YAHOO.widget.TVFadeIn.prototype = {animate:function () {var tvanim = this;var s = this.el.style;s.opacity = 0.1;s.filter = "alpha(opacity=10)";s.display = "";var dur = 0.4;var a = new YAHOO.util.Anim(this.el, {opacity:{from:0.1, to:1, unit:""}}, dur);a.onComplete.subscribe(function () {tvanim.onComplete();});a.animate();}, onComplete:function () {this.callback();}, toString:function () {return "TVFadeIn";}};YAHOO.widget.TVFadeOut = function (el, callback) {this.el = el;this.callback = callback;};YAHOO.widget.TVFadeOut.prototype = {animate:function () {var tvanim = this;var dur = 0.4;var a = new YAHOO.util.Anim(this.el, {opacity:{from:1, to:0.1, unit:""}}, dur);a.onComplete.subscribe(function () {tvanim.onComplete();});a.animate();}, onComplete:function () {var s = this.el.style;s.display = "none";s.filter = "alpha(opacity=100)";this.callback();}, toString:function () {return "TVFadeOut";}};});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -