';
sb[sb.length] = this.getNodeHtml();
@@ -1291,7 +1514,7 @@
* Called when first rendering the tree. We always build the div that will
* contain this nodes children, but we don't render the children themselves
* unless this node is expanded.
- *
+ * @method getChildrenHtml
* @return {string} the children container div html and any expanded children
* @private
*/
@@ -1319,7 +1542,7 @@
/**
* Generates the markup for the child nodes. This is not done until the node
* is expanded.
- *
+ * @method renderChildren
* @return {string} the html for this node's children
* @private
*/
@@ -1336,22 +1559,22 @@
if (this.dataLoader) {
this.logger.log("Using dynamic loader defined for this node");
- setTimeout(
+ setTimeout(
function() {
- node.dataLoader(node,
- function() {
- node.loadComplete();
+ node.dataLoader(node,
+ function() {
+ node.loadComplete();
});
}, 10);
-
+
} else if (this.tree.root.dataLoader) {
this.logger.log("Using the tree-level dynamic loader");
- setTimeout(
+ setTimeout(
function() {
- node.tree.root.dataLoader(node,
- function() {
- node.loadComplete();
+ node.tree.root.dataLoader(node,
+ function() {
+ node.loadComplete();
});
}, 10);
@@ -1369,17 +1592,18 @@
/**
* Called when we know we have all the child data.
+ * @method completeRender
* @return {string} children html
*/
completeRender: function() {
this.logger.log("completeRender: " + this.index + ", # of children: " + this.children.length);
var sb = [];
for (var i=0; i < this.children.length; ++i) {
- this.children[i].childrenRendered = false;
+ // this.children[i].childrenRendered = false;
sb[sb.length] = this.children[i].getHtml();
}
-
+
this.childrenRendered = true;
return sb.join("");
@@ -1388,6 +1612,7 @@
/**
* Load complete is the callback function we pass to the data provider
* in dynamic load situations.
+ * @method loadComplete
*/
loadComplete: function() {
this.logger.log("loadComplete: " + this.index);
@@ -1400,7 +1625,7 @@
/**
* Returns this node's ancestor at the specified depth.
- *
+ * @method getAncestor
* @param {int} depth the depth of the ancestor.
* @return {Node} the ancestor
*/
@@ -1411,7 +1636,7 @@
}
var p = this.parent;
-
+
while (p.depth > depth) {
p = p.parent;
}
@@ -1424,29 +1649,30 @@
* this node. If this node's ancestor at the specified depth
* has a next sibling the presentation is different than if it
* does not have a next sibling
- *
+ * @method getDepthStyle
* @param {int} depth the depth of the ancestor.
* @return {string} the css class for the spacer
*/
getDepthStyle: function(depth) {
- return (this.getAncestor(depth).nextSibling) ?
+ return (this.getAncestor(depth).nextSibling) ?
"ygtvdepthcell" : "ygtvblankdepthcell";
},
/**
* Get the markup for the node. This is designed to be overrided so that we can
* support different types of nodes.
- *
+ * @method getNodeHtml
* @return {string} The HTML that will render this node.
*/
- getNodeHtml: function() {
+ getNodeHtml: function() {
this.logger.log("Generating html");
- return "";
+ return "";
},
/**
* Regenerates the html for this node and its children. To be used when the
* node is expanded and new children have been added.
+ * @method refresh
*/
refresh: function() {
// this.loadComplete();
@@ -1461,7 +1687,8 @@
},
/**
- * toString
+ * Node toString
+ * @method toString
* @return {string} string representation of the node
*/
toString: function() {
@@ -1470,50 +1697,55 @@
};
+YAHOO.augment(YAHOO.widget.Node, YAHOO.util.EventProvider);
+
/**
- * A custom YAHOO.widget.Node that handles the unique nature of
+ * A custom YAHOO.widget.Node that handles the unique nature of
* the virtual, presentationless root node.
- *
+ * @namespace YAHOO.widget
+ * @class RootNode
* @extends YAHOO.widget.Node
+ * @param oTree {YAHOO.widget.TreeView} The tree instance this node belongs to
* @constructor
*/
YAHOO.widget.RootNode = function(oTree) {
// Initialize the node with null params. The root node is a
// special case where the node has no presentation. So we have
// to alter the standard properties a bit.
this.init(null, null, true);
-
- /**
+
+ /*
* For the root node, we get the tree reference from as a param
* to the constructor instead of from the parent element.
- *
- * @type TreeView
*/
this.tree = oTree;
};
-YAHOO.widget.RootNode.prototype = new YAHOO.widget.Node();
+YAHOO.extend(YAHOO.widget.RootNode, YAHOO.widget.Node, {
+
+ // overrides YAHOO.widget.Node
+ getNodeHtml: function() {
+ return "";
+ },
-// overrides YAHOO.widget.Node
-YAHOO.widget.RootNode.prototype.getNodeHtml = function() {
- return "";
-};
+ toString: function() {
+ return "RootNode";
+ },
-YAHOO.widget.RootNode.prototype.toString = function() {
- return "RootNode";
-};
+ loadComplete: function() {
+ this.tree.draw();
+ }
-YAHOO.widget.RootNode.prototype.loadComplete = function() {
- this.tree.draw();
-};
+});
/**
* The default node presentation. The first parameter should be
* either a string that will be used as the node's label, or an object
* that has a string propery called label. By default, the clicking the
* label will toggle the expanded/collapsed state of the node. By
* changing the href property of the instance, this behavior can be
* changed so that the label will go to the specified href.
- *
+ * @namespace YAHOO.widget
+ * @class TextNode
* @extends YAHOO.widget.Node
* @constructor
* @param oData {object} a string or object containing the data that will
@@ -1522,203 +1754,236 @@
* @param expanded {boolean} the initial expanded/collapsed state
*/
YAHOO.widget.TextNode = function(oData, oParent, expanded) {
- // this.type = "TextNode";
- if (oData) {
+ if (oData) {
this.init(oData, oParent, expanded);
this.setUpLabel(oData);
}
- /**
- * @private
- */
this.logger = new YAHOO.widget.LogWriter(this.toString());
};
-YAHOO.widget.TextNode.prototype = new YAHOO.widget.Node();
+YAHOO.extend(YAHOO.widget.TextNode, YAHOO.widget.Node, {
+
+ /**
+ * The CSS class for the label href. Defaults to ygtvlabel, but can be
+ * overridden to provide a custom presentation for a specific node.
+ * @property labelStyle
+ * @type string
+ */
+ labelStyle: "ygtvlabel",
-/**
- * The CSS class for the label href. Defaults to ygtvlabel, but can be
- * overridden to provide a custom presentation for a specific node.
- *
- * @type string
- */
-YAHOO.widget.TextNode.prototype.labelStyle = "ygtvlabel";
+ /**
+ * The derived element id of the label for this node
+ * @property labelElId
+ * @type string
+ */
+ labelElId: null,
-/**
- * The derived element id of the label for this node
- *
- * @type string
- */
-YAHOO.widget.TextNode.prototype.labelElId = null;
+ /**
+ * The text for the label. It is assumed that the oData parameter will
+ * either be a string that will be used as the label, or an object that
+ * has a property called "label" that we will use.
+ * @property label
+ * @type string
+ */
+ label: null,
-/**
- * The text for the label. It is assumed that the oData parameter will
- * either be a string that will be used as the label, or an object that
- * has a property called "label" that we will use.
- *
- * @type string
- */
-YAHOO.widget.TextNode.prototype.label = null;
+ textNodeParentChange: function() {
+
+ /**
+ * Custom event that is fired when the text node label is clicked. The
+ * custom event is defined on the tree instance, so there is a single
+ * event that handles all nodes in the tree. The node clicked is
+ * provided as an argument
+ *
+ * @event labelClick
+ * @for YAHOO.widget.TreeView
+ * @param {YAHOO.widget.Node} node the node clicked
+ */
+ if (this.tree && !this.tree.hasEvent("labelClick")) {
+ this.tree.createEvent("labelClick", this.tree);
+ }
+
+ },
-/**
- * Sets up the node label
- *
- * @param oData string containing the label, or an object with a label property
- */
-YAHOO.widget.TextNode.prototype.setUpLabel = function(oData) {
- if (typeof oData == "string") {
- oData = { label: oData };
- }
- this.label = oData.label;
+ /**
+ * Sets up the node label
+ * @method setUpLabel
+ * @param oData string containing the label, or an object with a label property
+ */
+ setUpLabel: function(oData) {
+
+ // set up the custom event on the tree
+ this.textNodeParentChange();
+ this.subscribe("parentChange", this.textNodeParentChange);
- // update the link
- if (oData.href) {
- this.href = oData.href;
- }
+ if (typeof oData == "string") {
+ oData = { label: oData };
+ }
+ this.label = oData.label;
+
+ // update the link
+ if (oData.href) {
+ this.href = oData.href;
+ }
- // set the target
- if (oData.target) {
- this.target = oData.target;
- }
+ // set the target
+ if (oData.target) {
+ this.target = oData.target;
+ }
- if (oData.style) {
- this.labelStyle = oData.style;
- }
+ if (oData.style) {
+ this.labelStyle = oData.style;
+ }
- this.labelElId = "ygtvlabelel" + this.index;
-};
+ this.labelElId = "ygtvlabelel" + this.index;
+ },
-/**
- * Returns the label element
- *
- * @return {object} the element
- */
-YAHOO.widget.TextNode.prototype.getLabelEl = function() {
- return document.getElementById(this.labelElId);
-};
+ /**
+ * Returns the label element
+ * @for YAHOO.widget.TextNode
+ * @method getLabelEl
+ * @return {object} the element
+ */
+ getLabelEl: function() {
+ return document.getElementById(this.labelElId);
+ },
-// overrides YAHOO.widget.Node
-YAHOO.widget.TextNode.prototype.getNodeHtml = function() {
- this.logger.log("Generating html");
- var sb = [];
+ // overrides YAHOO.widget.Node
+ getNodeHtml: function() {
+ this.logger.log("Generating html");
+ var sb = [];
- sb[sb.length] = '
';
- sb[sb.length] = '';
+ sb[sb.length] = '';
+ sb[sb.length] = '';
+
+ for (var i=0;i
';
+ //sb[sb.length] = ' | ';
+ sb[sb.length] = ' | ';
+ }
- for (i=0;i ';
- sb[sb.length] = ' | ';
- }
+ var getNode = 'YAHOO.widget.TreeView.getNode(\'' +
+ this.tree.id + '\',' + this.index + ')';
- var getNode = 'YAHOO.widget.TreeView.getNode(\'' +
- this.tree.id + '\',' + this.index + ')';
+ sb[sb.length] = '';
- sb[sb.length] = ' | ';
+ sb[sb.length] = '';
- /*
- sb[sb.length] = ' ';
- */
+ /*
+ sb[sb.length] = ' ';
+ */
- sb[sb.length] = ' ';
+ //sb[sb.length] = ' ';
- sb[sb.length] = ' | ';
- sb[sb.length] = '';
- sb[sb.length] = '';
- sb[sb.length] = this.label;
- sb[sb.length] = '';
- sb[sb.length] = ' | ';
- sb[sb.length] = '
';
- sb[sb.length] = '
';
+ sb[sb.length] = '';
+ sb[sb.length] = '';
+ sb[sb.length] = '';
+ sb[sb.length] = '';
+ sb[sb.length] = this.label;
+ sb[sb.length] = '';
+ sb[sb.length] = ' | ';
+ sb[sb.length] = '
';
+ sb[sb.length] = '
';
- return sb.join("");
-};
+ return sb.join("");
+ },
-/**
- * Executed when the label is clicked
- * @param me {Node} this node
- * @scope the anchor tag clicked
- * @return false to cancel the anchor click
- */
-YAHOO.widget.TextNode.prototype.onLabelClick = function(me) {
- me.logger.log("onLabelClick " + this.label);
- //return true;
-};
+ /**
+ * Executed when the label is clicked. Fires the labelClick custom event.
+ * @method onLabelClick
+ * @param me {Node} this node
+ * @scope the anchor tag clicked
+ * @return false to cancel the anchor click
+ */
+ onLabelClick: function(me) {
+ me.logger.log("onLabelClick " + me.label);
+ return me.tree.fireEvent("labelClick", me);
+ //return true;
+ },
-YAHOO.widget.TextNode.prototype.toString = function() {
- return "TextNode (" + this.index + ") " + this.label;
-};
+ toString: function() {
+ return "TextNode (" + this.index + ") " + this.label;
+ }
+});
/**
- * A menu-specific implementation that differs from TextNode in that only
+ * A menu-specific implementation that differs from TextNode in that only
* one sibling can be expanded at a time.
+ * @namespace YAHOO.widget
+ * @class MenuNode
* @extends YAHOO.widget.TextNode
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {YAHOO.widget.Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
* @constructor
*/
YAHOO.widget.MenuNode = function(oData, oParent, expanded) {
- if (oData) {
+ if (oData) {
this.init(oData, oParent, expanded);
this.setUpLabel(oData);
}
- /**
+ /*
* Menus usually allow only one branch to be open at a time.
- * @type boolean
*/
this.multiExpand = false;
- /**
- * @private
- */
this.logger = new YAHOO.widget.LogWriter(this.toString());
};
-YAHOO.widget.MenuNode.prototype = new YAHOO.widget.TextNode();
+YAHOO.extend(YAHOO.widget.MenuNode, YAHOO.widget.TextNode, {
-YAHOO.widget.MenuNode.prototype.toString = function() {
- return "MenuNode (" + this.index + ") " + this.label;
-};
+ toString: function() {
+ return "MenuNode (" + this.index + ") " + this.label;
+ }
+});
/**
* This implementation takes either a string or object for the
* oData argument. If is it a string, we will use it for the display
* of this node (and it can contain any html code). If the parameter
* is an object, we look for a parameter called "html" that will be
* used for this node's display.
- *
+ * @namespace YAHOO.widget
+ * @class HTMLNode
* @extends YAHOO.widget.Node
* @constructor
* @param oData {object} a string or object containing the data that will
@@ -1729,139 +1994,143 @@
* have an icon
*/
YAHOO.widget.HTMLNode = function(oData, oParent, expanded, hasIcon) {
- if (oData) {
+ if (oData) {
this.init(oData, oParent, expanded);
this.initContent(oData, hasIcon);
}
};
-YAHOO.widget.HTMLNode.prototype = new YAHOO.widget.Node();
+YAHOO.extend(YAHOO.widget.HTMLNode, YAHOO.widget.Node, {
-/**
- * The CSS class for the html content container. Defaults to ygtvhtml, but
- * can be overridden to provide a custom presentation for a specific node.
- *
- * @type string
- */
-YAHOO.widget.HTMLNode.prototype.contentStyle = "ygtvhtml";
+ /**
+ * The CSS class for the html content container. Defaults to ygtvhtml, but
+ * can be overridden to provide a custom presentation for a specific node.
+ * @property contentStyle
+ * @type string
+ */
+ contentStyle: "ygtvhtml",
-/**
- * The generated id that will contain the data passed in by the implementer.
- *
- * @type string
- */
-YAHOO.widget.HTMLNode.prototype.contentElId = null;
+ /**
+ * The generated id that will contain the data passed in by the implementer.
+ * @property contentElId
+ * @type string
+ */
+ contentElId: null,
-/**
- * The HTML content to use for this node's display
- *
- * @type string
- */
-YAHOO.widget.HTMLNode.prototype.content = null;
+ /**
+ * The HTML content to use for this node's display
+ * @property content
+ * @type string
+ */
+ content: null,
-/**
- * Sets up the node label
- *
- * @param {object} An html string or object containing an html property
- * @param {boolean} hasIcon determines if the node will be rendered with an
- * icon or not
- */
-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;
-
/**
- * @private
+ * Sets up the node label
+ * @property initContent
+ * @param {object} An html string or object containing an html property
+ * @param {boolean} hasIcon determines if the node will be rendered with an
+ * icon or not
*/
- this.logger = new YAHOO.widget.LogWriter(this.toString());
-};
+ initContent: function(oData, hasIcon) {
+ if (typeof oData == "string") {
+ oData = { html: oData };
+ }
-/**
- * Returns the outer html element for this node's content
- *
- * @return {HTMLElement} the element
- */
-YAHOO.widget.HTMLNode.prototype.getContentEl = function() {
- return document.getElementById(this.contentElId);
-};
+ this.html = oData.html;
+ this.contentElId = "ygtvcontentel" + this.index;
+ this.hasIcon = hasIcon;
-// overrides YAHOO.widget.Node
-YAHOO.widget.HTMLNode.prototype.getNodeHtml = function() {
- this.logger.log("Generating html");
- var sb = [];
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+ },
- sb[sb.length] = '
';
- sb[sb.length] = '';
+ /**
+ * Returns the outer html element for this node's content
+ * @method getContentEl
+ * @return {HTMLElement} the element
+ */
+ getContentEl: function() {
+ return document.getElementById(this.contentElId);
+ },
- for (i=0;i ';
- }
+ // overrides YAHOO.widget.Node
+ getNodeHtml: function() {
+ this.logger.log("Generating html");
+ var sb = [];
- if (this.hasIcon) {
- sb[sb.length] = '';
+ sb[sb.length] = ' | ';
+
+ for (var i=0;i ';
+ sb[sb.length] = ' | ';
}
- sb[sb.length] = '> ';
- }
- sb[sb.length] = '';
- sb[sb.length] = this.html;
- sb[sb.length] = ' | ';
- sb[sb.length] = '
';
- sb[sb.length] = '
';
+ if (this.hasIcon) {
+ sb[sb.length] = '
| ';
+ sb[sb.length] = '>
';
+ }
- return sb.join("");
-};
+ sb[sb.length] = '
';
+ sb[sb.length] = this.html;
+ sb[sb.length] = ' | ';
+ sb[sb.length] = '';
+ sb[sb.length] = '';
-YAHOO.widget.HTMLNode.prototype.toString = function() {
- return "HTMLNode (" + this.index + ")";
-};
+ return sb.join("");
+ },
+ toString: function() {
+ return "HTMLNode (" + this.index + ")";
+ }
+
+});
/**
* A static factory class for tree view expand/collapse animations
- *
- * @constructor
+ * @class TVAnim
+ * @static
*/
YAHOO.widget.TVAnim = function() {
return {
/**
* Constant for the fade in animation
- *
+ * @property FADE_IN
* @type string
+ * @static
*/
FADE_IN: "TVFadeIn",
/**
* Constant for the fade out animation
- *
+ * @property FADE_OUT
* @type string
+ * @static
*/
FADE_OUT: "TVFadeOut",
/**
* Returns a ygAnim instance of the given type
- *
+ * @method getAnim
* @param type {string} the type of animation
* @param el {HTMLElement} the element to element (probably the children div)
* @param callback {function} function to invoke when the animation is done.
* @return {YAHOO.util.Animation} the animation instance
+ * @static
*/
getAnim: function(type, el, callback) {
if (YAHOO.widget[type]) {
@@ -1873,9 +2142,10 @@
/**
* Returns true if the specified animation class is available
- *
+ * @method isValid
* @param type {string} the type of animation
* @return {boolean} true if valid, false if not
+ * @static
*/
isValid: function(type) {
return (YAHOO.widget[type]);
@@ -1885,35 +2155,34 @@
/**
* A 1/2 second fade-in animation.
- *
+ * @class TVFadeIn
* @constructor
* @param el {HTMLElement} the element to animate
* @param callback {function} function to invoke when the animation is finished
*/
YAHOO.widget.TVFadeIn = function(el, callback) {
/**
* The element to animate
+ * @property el
* @type HTMLElement
*/
this.el = el;
/**
* the callback to invoke when the animation is complete
- *
+ * @property callback
* @type function
*/
this.callback = callback;
- /**
- * @private
- */
this.logger = new YAHOO.widget.LogWriter(this.toString());
};
-/**
- * Performs the animation
- */
YAHOO.widget.TVFadeIn.prototype = {
+ /**
+ * Performs the animation
+ * @method animate
+ */
animate: function() {
var tvanim = this;
@@ -1922,78 +2191,71 @@
s.filter = "alpha(opacity=10)";
s.display = "";
- // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
- var dur = 0.4;
- // this.logger.log("duration: " + dur);
- // var a = new ygAnim_Fade(this.el, dur, 1);
- // a.setStart(0.1);
- // a.onComplete = function() { tvanim.onComplete(); };
-
- // var a = new YAHOO.util.Anim(this.el, 'opacity', 0.1, 1);
+ 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();
},
/**
* Clean up and invoke callback
+ * @method onComplete
*/
onComplete: function() {
this.callback();
},
+ /**
+ * toString
+ * @method toString
+ * @return {string} the string representation of the instance
+ */
toString: function() {
return "TVFadeIn";
}
};
/**
* A 1/2 second fade out animation.
- *
+ * @class TVFadeOut
* @constructor
* @param el {HTMLElement} the element to animate
* @param callback {Function} function to invoke when the animation is finished
*/
YAHOO.widget.TVFadeOut = function(el, callback) {
/**
* The element to animate
+ * @property el
* @type HTMLElement
*/
this.el = el;
/**
* the callback to invoke when the animation is complete
- *
+ * @property callback
* @type function
*/
this.callback = callback;
- /**
- * @private
- */
this.logger = new YAHOO.widget.LogWriter(this.toString());
};
-/**
- * Performs the animation
- */
YAHOO.widget.TVFadeOut.prototype = {
+ /**
+ * Performs the animation
+ * @method animate
+ */
animate: function() {
var tvanim = this;
- // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
var dur = 0.4;
- // this.logger.log("duration: " + dur);
- // var a = new ygAnim_Fade(this.el, dur, 0.1);
- // a.onComplete = function() { tvanim.onComplete(); };
-
- // var a = new YAHOO.util.Anim(this.el, 'opacity', 1, 0.1);
var a = new YAHOO.util.Anim(this.el, {opacity: {from: 1, to: 0.1, unit:""}}, dur);
a.onComplete.subscribe( function() { tvanim.onComplete(); } );
a.animate();
},
/**
* Clean up and invoke callback
+ * @method onComplete
*/
onComplete: function() {
var s = this.el.style;
@@ -2003,6 +2265,11 @@
this.callback();
},
+ /**
+ * toString
+ * @method toString
+ * @return {string} the string representation of the instance
+ */
toString: function() {
return "TVFadeOut";
}