Author: housel
Date: Tue Jun 6 07:55:53 2006
New Revision: 10780
Added:
trunk/documentation/topic/cms/css/
trunk/documentation/topic/cms/css/tree.css (contents, props changed)
trunk/documentation/topic/cms/images/
trunk/documentation/topic/cms/images/treeview/
trunk/documentation/topic/cms/images/treeview/lm.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/lmh.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/ln.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/loading.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/lp.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/lph.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/tm.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/tmh.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/tn.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/tp.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/tph.gif (contents, props
changed)
trunk/documentation/topic/cms/images/treeview/vline.gif (contents, props
changed)
trunk/documentation/topic/cms/js/
trunk/documentation/topic/cms/js/event.js (contents, props changed)
trunk/documentation/topic/cms/js/treeview.js (contents, props changed)
trunk/documentation/topic/cms/js/yahoo.js (contents, props changed)
Log:
Bug: 7249
Import the treeview control, adapted from version 0.10.0 of the Yahoo! User
Interface Library.
Added: trunk/documentation/topic/cms/css/tree.css
==============================================================================
--- (empty file)
+++ trunk/documentation/topic/cms/css/tree.css Tue Jun 6 07:55:53 2006
@@ -0,0 +1,98 @@
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/* first or middle sibling, no children */
+.ygtvtn {
+ width:16px; height:22px;
+ background: url(../images/treeview/tn.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, collapsable */
+.ygtvtm {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../images/treeview/tm.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, collapsable, hover */
+.ygtvtmh {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../images/treeview/tmh.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, expandable */
+.ygtvtp {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../images/treeview/tp.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, expandable, hover */
+.ygtvtph {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../images/treeview/tph.gif) 0 0 no-repeat;
+}
+
+/* last sibling, no children */
+.ygtvln {
+ width:16px; height:22px;
+ background: url(../images/treeview/ln.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, collapsable */
+.ygtvlm {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../images/treeview/lm.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, collapsable, hover */
+.ygtvlmh {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../images/treeview/lmh.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, expandable */
+.ygtvlp {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../images/treeview/lp.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, expandable, hover */
+.ygtvlph {
+ width:16px; height:22px; cursor:pointer ;
+ background: url(../images/treeview/lph.gif) 0 0 no-repeat;
+}
+
+/* Loading icon */
+.ygtvloading {
+ width:16px; height:22px;
+ background: url(../images/treeview/loading.gif) 0 0 no-repeat;
+}
+
+/* the style for the empty cells that are used for rendering the depth
+ * of the node */
+.ygtvdepthcell {
+ width:16px; height:22px;
+ background: url(../images/treeview/vline.gif) 0 0 no-repeat;
+}
+
+.ygtvblankdepthcell { width:16px; height:22px; }
+
+/* the style of the div around each node */
+.ygtvitem { }
+
+/* the style of the div around each node's collection of children */
+.ygtvchildren { }
+* html .ygtvchildren { height:2%; }
+
+/* the style of the text label in ygTextNode */
+.ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover {
+ margin-left:2px;
+ text-decoration: none;
+}
+
+.ygtvspacer { height: 10px; width: 10px; margin: 2px; }
Added: trunk/documentation/topic/cms/images/treeview/lm.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/lmh.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/ln.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/loading.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/lp.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/lph.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/tm.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/tmh.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/tn.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/tp.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/tph.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/images/treeview/vline.gif
==============================================================================
Binary file. No diff available.
Added: trunk/documentation/topic/cms/js/event.js
==============================================================================
--- (empty file)
+++ trunk/documentation/topic/cms/js/event.js Tue Jun 6 07:55:53 2006
@@ -0,0 +1,1096 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.10.0
+*/
+
+/**
+ * The CustomEvent class lets you define events for your application
+ * that can be subscribed to by one or more independent component.
+ *
+ * @param {String} type The type of event, which is passed to the callback
+ * when the event fires
+ * @param {Object} oScope The context the event will fire from. "this" will
+ * refer to this object in the callback. Default value:
+ * the window object. The listener can override this.
+ * @constructor
+ */
+YAHOO.util.CustomEvent = function(type, oScope) {
+ /**
+ * The type of event, returned to subscribers when the event fires
+ * @type string
+ */
+ this.type = type;
+
+ /**
+ * The scope the the event will fire from by default. Defaults to the
window
+ * obj
+ * @type object
+ */
+ this.scope = oScope || window;
+
+ /**
+ * The subscribers to this event
+ * @type Subscriber[]
+ */
+ this.subscribers = [];
+
+ // Register with the event utility for automatic cleanup. Made optional
+ // so that CustomEvent can be used independently of pe.event
+ if (YAHOO.util.Event) {
+ YAHOO.util.Event.regCE(this);
+ }
+};
+
+YAHOO.util.CustomEvent.prototype = {
+ /**
+ * Subscribes the caller to this event
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event
fires
+ * @param {boolean} bOverride If true, the obj passed in becomes the
execution
+ * scope of the listener
+ */
+ subscribe: function(fn, obj, bOverride) {
+ this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, bOverride) );
+ },
+
+ /**
+ * Unsubscribes the caller from this event
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event fires
+ * @return {boolean} True if the subscriber was found and detached.
+ */
+ unsubscribe: function(fn, obj) {
+ var found = false;
+ for (var i=0, len=this.subscribers.length; i<len; ++i) {
+ var s = this.subscribers[i];
+ if (s && s.contains(fn, obj)) {
+ this._delete(i);
+ found = true;
+ }
+ }
+
+ return found;
+ },
+
+ /**
+ * Notifies the subscribers. The callback functions will be executed
+ * from the scope specified when the event was created, and with the
following
+ * parameters:
+ * <pre>
+ * - The type of event
+ * - All of the arguments fire() was executed with as an array
+ * - The custom object (if any) that was passed into the subscribe()
method
+ * </pre>
+ *
+ * @param {Array} an arbitrary set of parameters to pass to the handler
+ */
+ fire: function() {
+ for (var i=0, len=this.subscribers.length; i<len; ++i) {
+ var s = this.subscribers[i];
+ if (s) {
+ var scope = (s.override) ? s.obj : this.scope;
+ s.fn.call(scope, this.type, arguments, s.obj);
+ }
+ }
+ },
+
+ /**
+ * Removes all listeners
+ */
+ unsubscribeAll: function() {
+ for (var i=0, len=this.subscribers.length; i<len; ++i) {
+ this._delete(i);
+ }
+ },
+
+ /**
+ * @private
+ */
+ _delete: function(index) {
+ var s = this.subscribers[index];
+ if (s) {
+ delete s.fn;
+ delete s.obj;
+ }
+
+ delete this.subscribers[index];
+ }
+};
+
+/////////////////////////////////////////////////////////////////////
+
+/**
+ * @class Stores the subscriber information to be used when the event fires.
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event fires
+ * @param {boolean} bOverride If true, the obj passed in becomes the execution
+ * scope of the listener
+ * @constructor
+ */
+YAHOO.util.Subscriber = function(fn, obj, bOverride) {
+ /**
+ * The callback that will be execute when the event fires
+ * @type function
+ */
+ this.fn = fn;
+
+ /**
+ * An optional custom object that will passed to the callback when
+ * the event fires
+ * @type object
+ */
+ this.obj = obj || null;
+
+ /**
+ * The default execution scope for the event listener is defined when the
+ * event is created (usually the object which contains the event).
+ * By setting override to true, the execution scope becomes the custom
+ * object passed in by the subscriber
+ * @type boolean
+ */
+ this.override = (bOverride);
+};
+
+/**
+ * Returns true if the fn and obj match this objects properties.
+ * Used by the unsubscribe method to match the right subscriber.
+ *
+ * @param {Function} fn the function to execute
+ * @param {Object} obj an object to be passed along when the event fires
+ * @return {boolean} true if the supplied arguments match this
+ * subscriber's signature.
+ */
+YAHOO.util.Subscriber.prototype.contains = function(fn, obj) {
+ return (this.fn == fn && this.obj == obj);
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+// Only load this library once. If it is loaded a second time, existing
+// events cannot be detached.
+if (!YAHOO.util.Event) {
+
+/**
+ * @class
+ * The event utility provides functions to add and remove event listeners,
+ * event cleansing. It also tries to automatically remove listeners it
+ * registers during the unload event.
+ * @constructor
+ */
+ YAHOO.util.Event = function() {
+
+ /**
+ * True after the onload event has fired
+ * @type boolean
+ * @private
+ */
+ var loadComplete = false;
+
+ /**
+ * Cache of wrapped listeners
+ * @type array
+ * @private
+ */
+ var listeners = [];
+
+ /**
+ * Listeners that will be attached during the onload event
+ * @type array
+ * @private
+ */
+ var delayedListeners = [];
+
+ /**
+ * User-defined unload function that will be fired before all events
+ * are detached
+ * @type array
+ * @private
+ */
+ var unloadListeners = [];
+
+ /**
+ * Cache of the custom events that have been defined. Used for
+ * automatic cleanup
+ * @type array
+ * @private
+ */
+ var customEvents = [];
+
+ /**
+ * Cache of DOM0 event handlers to work around issues with DOM2 events
+ * in Safari
+ * @private
+ */
+ var legacyEvents = [];
+
+ /**
+ * Listener stack for DOM0 events
+ * @private
+ */
+ var legacyHandlers = [];
+
+ /**
+ * The number of times to poll after window.onload. This number is
+ * increased if additional late-bound handlers are requested after
+ * the page load.
+ * @private
+ */
+ var retryCount = 0;
+
+ /**
+ * onAvailable listeners
+ * @private
+ */
+ var onAvailStack = [];
+
+ /**
+ * Lookup table for legacy events
+ * @private
+ */
+ var legacyMap = [];
+
+ /**
+ * Counter for auto id generation
+ * @private
+ */
+ var counter = 0;
+
+ return { // PREPROCESS
+
+ /**
+ * The number of times we should look for elements that are not
+ * in the DOM at the time the event is requested after the document
+ * has been loaded. The default is 200@50 ms, so it will poll
+ * for 10 seconds or until all outstanding handlers are bound
+ * (whichever comes first).
+ * @type int
+ */
+ POLL_RETRYS: 200,
+
+ /**
+ * The poll interval in milliseconds
+ * @type int
+ */
+ POLL_INTERVAL: 50,
+
+ /**
+ * Element to bind, int constant
+ * @type int
+ */
+ EL: 0,
+
+ /**
+ * Type of event, int constant
+ * @type int
+ */
+ TYPE: 1,
+
+ /**
+ * Function to execute, int constant
+ * @type int
+ */
+ FN: 2,
+
+ /**
+ * Function wrapped for scope correction and cleanup, int constant
+ * @type int
+ */
+ WFN: 3,
+
+ /**
+ * Object passed in by the user that will be returned as a
+ * parameter to the callback, int constant
+ * @type int
+ */
+ SCOPE: 3,
+
+ /**
+ * Adjusted scope, either the element we are registering the event
+ * on or the custom object passed in by the listener, int constant
+ * @type int
+ */
+ ADJ_SCOPE: 4,
+
+ /**
+ * Safari detection is necessary to work around the preventDefault
+ * bug that makes it so you can't cancel a href click from the
+ * handler. There is not a capabilities check we can use here.
+ * @private
+ */
+ isSafari: (/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),
+
+ /**
+ * IE detection needed to properly calculate pageX and pageY.
+ * capabilities checking didn't seem to work because another
+ * browser that does not provide the properties have the values
+ * calculated in a different manner than IE.
+ * @private
+ */
+ isIE: (!this.isSafari && !navigator.userAgent.match(/opera/gi) &&
+ navigator.userAgent.match(/msie/gi)),
+
+ /**
+ * @private
+ */
+ addDelayedListener: function(el, sType, fn, oScope, bOverride) {
+ delayedListeners[delayedListeners.length] =
+ [el, sType, fn, oScope, bOverride];
+
+ // If this happens after the inital page load, we need to
+ // reset the poll counter so that we continue to search for
+ // the element for a fixed period of time.
+ if (loadComplete) {
+ retryCount = this.POLL_RETRYS;
+ this.startTimeout(0);
+ // this._tryPreloadAttach();
+ }
+ },
+
+ /**
+ * @private
+ */
+ startTimeout: function(interval) {
+ var i = (interval || interval === 0) ? interval :
this.POLL_INTERVAL;
+ var self = this;
+ var callback = function() { self._tryPreloadAttach(); };
+ this.timeout = setTimeout(callback, i);
+ },
+
+ /**
+ * Executes the supplied callback when the item with the supplied
+ * id is found. This is meant to be used to execute behavior as
+ * soon as possible as the page loads. If you use this after the
+ * initial page load it will poll for a fixed time for the element.
+ * The number of times it will poll and the frequency are
+ * configurable. By default it will poll for 10 seconds.
+ * @param {string} p_id the id of the element to look for.
+ * @param {function} p_fn what to execute when the element is
found.
+ * @param {object} p_obj an optional object to be passed back as
+ * a parameter to p_fn.
+ * @param {boolean} p_override If set to true, p_fn will execute
+ * in the scope of p_obj
+ *
+ */
+ onAvailable: function(p_id, p_fn, p_obj, p_override) {
+ onAvailStack.push( { id: p_id,
+ fn: p_fn,
+ obj: p_obj,
+ override: p_override } );
+
+ retryCount = this.POLL_RETRYS;
+ this.startTimeout(0);
+ // this._tryPreloadAttach();
+ },
+
+ /**
+ * Appends an event handler
+ *
+ * @param {Object} el The html element to assign the
+ * event to
+ * @param {String} sType The type of event to append
+ * @param {Function} fn The method the event invokes
+ * @param {Object} oScope An arbitrary object that will be
+ * passed as a parameter to the handler
+ * @param {boolean} bOverride If true, the obj passed in becomes
+ * the execution scope of the listener
+ * @return {boolean} True if the action was successful or defered,
+ * false if one or more of the elements
+ * could not have the event bound to it.
+ */
+ addListener: function(el, sType, fn, oScope, bOverride) {
+
+ if (!fn || !fn.call) {
+ return false;
+ }
+
+ // The el argument can be an array of elements or element ids.
+ if ( this._isValidCollection(el)) {
+ var ok = true;
+ for (var i=0,len=el.length; i<len; ++i) {
+ ok = ( this.on(el[i],
+ sType,
+ fn,
+ oScope,
+ bOverride) && ok );
+ }
+ return ok;
+
+ } else if (typeof el == "string") {
+ var oEl = this.getEl(el);
+ // If the el argument is a string, we assume it is
+ // actually the id of the element. If the page is loaded
+ // we convert el to the actual element, otherwise we
+ // defer attaching the event until onload event fires
+
+ // check to see if we need to delay hooking up the event
+ // until after the page loads.
+ if (loadComplete && oEl) {
+ el = oEl;
+ } else {
+ // defer adding the event until onload fires
+ this.addDelayedListener(el,
+ sType,
+ fn,
+ oScope,
+ bOverride);
+
+ return true;
+ }
+ }
+
+ // Element should be an html element or an array if we get
+ // here.
+ if (!el) {
+ return false;
+ }
+
+ // we need to make sure we fire registered unload events
+ // prior to automatically unhooking them. So we hang on to
+ // these instead of attaching them to the window and fire the
+ // handles explicitly during our one unload event.
+ if ("unload" == sType && oScope !== this) {
+ unloadListeners[unloadListeners.length] =
+ [el, sType, fn, oScope, bOverride];
+ return true;
+ }
+
+
+ // if the user chooses to override the scope, we use the custom
+ // object passed in, otherwise the executing scope will be the
+ // HTML element that the event is registered on
+ var scope = (bOverride) ? oScope : el;
+
+ // wrap the function so we can return the oScope object when
+ // the event fires;
+ var wrappedFn = function(e) {
+ return fn.call(scope, YAHOO.util.Event.getEvent(e),
+ oScope);
+ };
+
+ var li = [el, sType, fn, wrappedFn, scope];
+ var index = listeners.length;
+ // cache the listener so we can try to automatically unload
+ listeners[index] = li;
+
+ if (this.useLegacyEvent(el, sType)) {
+ var legacyIndex = this.getLegacyIndex(el, sType);
+ if (legacyIndex == -1) {
+
+ legacyIndex = legacyEvents.length;
+ legacyMap[el.id + sType] = legacyIndex;
+
+ // cache the signature for the DOM0 event, and
+ // include the existing handler for the event, if any
+ legacyEvents[legacyIndex] =
+ [el, sType, el["on" + sType]];
+ legacyHandlers[legacyIndex] = [];
+
+ el["on" + sType] =
+ function(e) {
+ YAHOO.util.Event.fireLegacyEvent(
+ YAHOO.util.Event.getEvent(e), legacyIndex);
+ };
+ }
+
+ // add a reference to the wrapped listener to our custom
+ // stack of events
+ legacyHandlers[legacyIndex].push(index);
+
+ // DOM2 Event model
+ } else if (el.addEventListener) {
+ el.addEventListener(sType, wrappedFn, false);
+ // Internet Explorer abstraction
+ } else if (el.attachEvent) {
+ el.attachEvent("on" + sType, wrappedFn);
+ }
+
+ return true;
+
+ },
+
+ /**
+ * Shorthand for YAHOO.util.Event.addListener
+ * @type function
+ */
+ // on: this.addListener,
+
+ /**
+ * When using legacy events, the handler is routed to this object
+ * so we can fire our custom listener stack.
+ * @private
+ */
+ fireLegacyEvent: function(e, legacyIndex) {
+ var ok = true;
+
+ var le = legacyHandlers[legacyIndex];
+ for (var i=0,len=le.length; i<len; ++i) {
+ var index = le[i];
+ if (index) {
+ var li = listeners[index];
+ if ( li && li[this.WFN] ) {
+ var scope = li[this.ADJ_SCOPE];
+ var ret = li[this.WFN].call(scope, e);
+ ok = (ok && ret);
+ } else {
+ // This listener was removed, so delete it from
+ // the array
+ delete le[i];
+ }
+ }
+ }
+
+ return ok;
+ },
+
+ /**
+ * Returns the legacy event index that matches the supplied
+ * signature
+ * @private
+ */
+ getLegacyIndex: function(el, sType) {
+ /*
+ for (var i=0,len=legacyEvents.length; i<len; ++i) {
+ var le = legacyEvents[i];
+ if (le && le[0] === el && le[1] === sType) {
+ return i;
+ }
+ }
+ return -1;
+ */
+
+ var key = this.generateId(el) + sType;
+ if (typeof legacyMap[key] == "undefined") {
+ return -1;
+ } else {
+ return legacyMap[key];
+ }
+
+ },
+
+ /**
+ * Logic that determines when we should automatically use legacy
+ * events instead of DOM2 events.
+ * @private
+ */
+ useLegacyEvent: function(el, sType) {
+
+ if (!el.addEventListener && !el.attachEvent) {
+ return true;
+ } else if (this.isSafari) {
+ if ("click" == sType || "dblclick" == sType) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ /**
+ * Removes an event handler
+ *
+ * @param {Object} el the html element or the id of the element to
+ * assign the event to.
+ * @param {String} sType the type of event to remove
+ * @param {Function} fn the method the event invokes
+ * @return {boolean} true if the unbind was successful, false
+ * otherwise
+ */
+ removeListener: function(el, sType, fn, index) {
+
+ if (!fn || !fn.call) {
+ return false;
+ }
+
+ // The el argument can be a string
+ if (typeof el == "string") {
+ el = this.getEl(el);
+ // The el argument can be an array of elements or element ids.
+ } else if ( this._isValidCollection(el)) {
+ var ok = true;
+ for (var i=0,len=el.length; i<len; ++i) {
+ ok = ( this.removeListener(el[i], sType, fn) && ok );
+ }
+ return ok;
+ }
+
+ if ("unload" == sType) {
+
+ for (i=0, len=unloadListeners.length; i<len; i++) {
+ var li = unloadListeners[i];
+ if (li &&
+ li[0] == el &&
+ li[1] == sType &&
+ li[2] == fn) {
+ delete unloadListeners[i];
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ var cacheItem = null;
+
+ if ("undefined" == typeof index) {
+ index = this._getCacheIndex(el, sType, fn);
+ }
+
+ if (index >= 0) {
+ cacheItem = listeners[index];
+ }
+
+ if (!el || !cacheItem) {
+ return false;
+ }
+
+
+ if (el.removeEventListener) {
+ el.removeEventListener(sType, cacheItem[this.WFN], false);
+ } else if (el.detachEvent) {
+ el.detachEvent("on" + sType, cacheItem[this.WFN]);
+ }
+
+ // removed the wrapped handler
+ delete listeners[index][this.WFN];
+ delete listeners[index][this.FN];
+ delete listeners[index];
+
+ return true;
+
+ },
+
+ /**
+ * Returns the event's target element
+ * @param {Event} ev the event
+ * @param {boolean} resolveTextNode when set to true the target's
+ * parent will be returned if the target is a
+ * text node
+ * @return {HTMLElement} the event's target
+ */
+ getTarget: function(ev, resolveTextNode) {
+ var t = ev.target || ev.srcElement;
+
+ if (resolveTextNode && t && "#text" == t.nodeName) {
+ return t.parentNode;
+ } else {
+ return t;
+ }
+ },
+
+ /**
+ * Returns the event's pageX
+ * @param {Event} ev the event
+ * @return {int} the event's pageX
+ */
+ getPageX: function(ev) {
+ var x = ev.pageX;
+ if (!x && 0 !== x) {
+ x = ev.clientX || 0;
+
+ if ( this.isIE ) {
+ x += this._getScrollLeft();
+ }
+ }
+
+ return x;
+ },
+
+ /**
+ * Returns the event's pageY
+ * @param {Event} ev the event
+ * @return {int} the event's pageY
+ */
+ getPageY: function(ev) {
+ var y = ev.pageY;
+ if (!y && 0 !== y) {
+ y = ev.clientY || 0;
+
+ if ( this.isIE ) {
+ y += this._getScrollTop();
+ }
+ }
+
+ return y;
+ },
+
+ /**
+ * Returns the pageX and pageY properties as an indexed array.
+ * @type int[]
+ */
+ getXY: function(ev) {
+ return [this.getPageX(ev), this.getPageY(ev)];
+ },
+
+ /**
+ * Returns the event's related target
+ * @param {Event} ev the event
+ * @return {HTMLElement} the event's relatedTarget
+ */
+ getRelatedTarget: function(ev) {
+ var t = ev.relatedTarget;
+ if (!t) {
+ if (ev.type == "mouseout") {
+ t = ev.toElement;
+ } else if (ev.type == "mouseover") {
+ t = ev.fromElement;
+ }
+ }
+
+ return t;
+ },
+
+ /**
+ * Returns the time of the event. If the time is not included, the
+ * event is modified using the current time.
+ * @param {Event} ev the event
+ * @return {Date} the time of the event
+ */
+ getTime: function(ev) {
+ if (!ev.time) {
+ var t = new Date().getTime();
+ try {
+ ev.time = t;
+ } catch(e) {
+ // can't set the time property
+ return t;
+ }
+ }
+
+ return ev.time;
+ },
+
+ /**
+ * Convenience method for stopPropagation + preventDefault
+ * @param {Event} ev the event
+ */
+ stopEvent: function(ev) {
+ this.stopPropagation(ev);
+ this.preventDefault(ev);
+ },
+
+ /**
+ * Stops event propagation
+ * @param {Event} ev the event
+ */
+ stopPropagation: function(ev) {
+ if (ev.stopPropagation) {
+ ev.stopPropagation();
+ } else {
+ ev.cancelBubble = true;
+ }
+ },
+
+ /**
+ * Prevents the default behavior of the event
+ * @param {Event} ev the event
+ */
+ preventDefault: function(ev) {
+ if (ev.preventDefault) {
+ ev.preventDefault();
+ } else {
+ ev.returnValue = false;
+ }
+ },
+
+ /**
+ * Finds the event in the window object, the caller's arguments, or
+ * in the arguments of another method in the callstack. This is
+ * executed automatically for events registered through the event
+ * manager, so the implementer should not normally need to execute
+ * this function at all.
+ * @param {Event} the event parameter from the handler
+ * @return {Event} the event
+ */
+ getEvent: function(e) {
+ var ev = e || window.event;
+
+ if (!ev) {
+ var c = this.getEvent.caller;
+ while (c) {
+ ev = c.arguments[0];
+ if (ev && Event == ev.constructor) {
+ break;
+ }
+ c = c.caller;
+ }
+ }
+
+ return ev;
+ },
+
+ /**
+ * Returns the charcode for an event
+ * @param {Event} ev the event
+ * @return {int} the event's charCode
+ */
+ getCharCode: function(ev) {
+ return ev.charCode || ((ev.type == "keypress") ? ev.keyCode :
0);
+ },
+
+ /**
+ * @private
+ * Locating the saved event handler data by function ref
+ */
+ _getCacheIndex: function(el, sType, fn) {
+ for (var i=0,len=listeners.length; i<len; ++i) {
+ var li = listeners[i];
+ if ( li &&
+ li[this.FN] == fn &&
+ li[this.EL] == el &&
+ li[this.TYPE] == sType ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ /**
+ * Generates an unique ID for the element if it does not already
+ * have one.
+ * @param el the element
+ * @return {string} the id of the element
+ */
+ generateId: function(el) {
+ var id = el.id;
+
+ if (!id) {
+ id = "yuievtautoid-" + (counter++);
+ el.id = id;
+ }
+
+ return id;
+ },
+
+ /**
+ * We want to be able to use getElementsByTagName as a collection
+ * to attach a group of events to. Unfortunately, different
+ * browsers return different types of collections. This function
+ * tests to determine if the object is array-like. It will also
+ * fail if the object is an array, but is empty.
+ * @param o the object to test
+ * @return {boolean} true if the object is array-like and populated
+ * @private
+ */
+ _isValidCollection: function(o) {
+
+ return ( o && // o is something
+ o.length && // o is indexed
+ typeof o != "string" && // o is not a string
+ !o.tagName && // o is not an HTML element
+ !o.alert && // o is not a window
+ typeof o[0] != "undefined" );
+
+ },
+
+ /**
+ * @private
+ * DOM element cache
+ */
+ elCache: {},
+
+ /**
+ * We cache elements bound by id because when the unload event
+ * fires, we can no longer use document.getElementById
+ * @private
+ */
+ getEl: function(id) {
+ return document.getElementById(id);
+ },
+
+ /**
+ * Clears the element cache
+ * @deprecated
+ * @private
+ */
+ clearCache: function() { },
+
+ /**
+ * Called by CustomEvent instances to provide a handle to the
+ * event * that can be removed later on. Should be package
+ * protected.
+ * @private
+ */
+ regCE: function(ce) {
+ customEvents.push(ce);
+ },
+
+ /**
+ * @private
+ * hook up any deferred listeners
+ */
+ _load: function(e) {
+ loadComplete = true;
+ },
+
+ /**
+ * Polling function that runs before the onload event fires,
+ * attempting * to attach to DOM Nodes as soon as they are
+ * available
+ * @private
+ */
+ _tryPreloadAttach: function() {
+
+ if (this.locked) {
+ return false;
+ }
+
+ this.locked = true;
+
+
+ // keep trying until after the page is loaded. We need to
+ // check the page load state prior to trying to bind the
+ // elements so that we can be certain all elements have been
+ // tested appropriately
+ var tryAgain = !loadComplete;
+ if (!tryAgain) {
+ tryAgain = (retryCount > 0);
+ }
+
+ // Delayed listeners
+ var stillDelayed = [];
+
+ for (var i=0,len=delayedListeners.length; i<len; ++i) {
+ var d = delayedListeners[i];
+ // There may be a race condition here, so we need to
+ // verify the array element is usable.
+ if (d) {
+
+ // el will be null if document.getElementById did not
+ // work
+ var el = this.getEl(d[this.EL]);
+
+ if (el) {
+ this.on(el, d[this.TYPE], d[this.FN],
+ d[this.SCOPE], d[this.ADJ_SCOPE]);
+ delete delayedListeners[i];
+ } else {
+ stillDelayed.push(d);
+ }
+ }
+ }
+
+ delayedListeners = stillDelayed;
+
+ // onAvailable
+ notAvail = [];
+ for (i=0,len=onAvailStack.length; i<len ; ++i) {
+ var item = onAvailStack[i];
+ if (item) {
+ el = this.getEl(item.id);
+
+ if (el) {
+ var scope = (item.override) ? item.obj : el;
+ item.fn.call(scope, item.obj);
+ delete onAvailStack[i];
+ } else {
+ notAvail.push(item);
+ }
+ }
+ }
+
+ retryCount = (stillDelayed.length === 0 &&
+ notAvail.length === 0) ? 0 : retryCount -
1;
+
+ if (tryAgain) {
+ this.startTimeout();
+ }
+
+ this.locked = false;
+
+ },
+
+ /**
+ * Removes all listeners registered by pe.event. Called
+ * automatically during the unload event.
+ * @private
+ */
+ _unload: function(e, me) {
+ for (var i=0,len=unloadListeners.length; i<len; ++i) {
+ var l = unloadListeners[i];
+ if (l) {
+ var scope = (l[this.ADJ_SCOPE]) ? l[this.SCOPE]:
window;
+ l[this.FN].call(scope, this.getEvent(e), l[this.SCOPE]
);
+ }
+ }
+
+ if (listeners && listeners.length > 0) {
+ for (i=0,len=listeners.length; i<len ; ++i) {
+ l = listeners[i];
+ if (l) {
+ this.removeListener(l[this.EL], l[this.TYPE],
+ l[this.FN], i);
+ }
+ }
+
+ this.clearCache();
+ }
+
+ for (i=0,len=customEvents.length; i<len; ++i) {
+ customEvents[i].unsubscribeAll();
+ delete customEvents[i];
+ }
+
+ for (i=0,len=legacyEvents.length; i<len; ++i) {
+ // dereference the element
+ delete legacyEvents[i][0];
+ // delete the array item
+ delete legacyEvents[i];
+ }
+ },
+
+ /**
+ * Returns scrollLeft
+ * @private
+ */
+ _getScrollLeft: function() {
+ return this._getScroll()[1];
+ },
+
+ /**
+ * Returns scrollTop
+ * @private
+ */
+ _getScrollTop: function() {
+ return this._getScroll()[0];
+ },
+
+ /**
+ * Returns the scrollTop and scrollLeft. Used to calculate the
+ * pageX and pageY in Internet Explorer
+ * @private
+ */
+ _getScroll: function() {
+ var dd = document.documentElement; db = document.body;
+ if (dd && dd.scrollTop) {
+ return [dd.scrollTop, dd.scrollLeft];
+ } else if (db) {
+ return [db.scrollTop, db.scrollLeft];
+ } else {
+ return [0, 0];
+ }
+ }
+ };
+ } ();
+
+ /**
+ * @private
+ */
+ YAHOO.util.Event.on = YAHOO.util.Event.addListener;
+
+ if (document && document.body) {
+ YAHOO.util.Event._load();
+ } else {
+ YAHOO.util.Event.on(window, "load", YAHOO.util.Event._load,
+ YAHOO.util.Event, true);
+ }
+
+ YAHOO.util.Event.on(window, "unload", YAHOO.util.Event._unload,
+ YAHOO.util.Event, true);
+
+ YAHOO.util.Event._tryPreloadAttach();
+
+}
+
Added: trunk/documentation/topic/cms/js/treeview.js
==============================================================================
--- (empty file)
+++ trunk/documentation/topic/cms/js/treeview.js Tue Jun 6 07:55:53 2006
@@ -0,0 +1,1744 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.10.0
+*/
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * Contains the tree view state data and the root node. This is an
+ * ordered tree; child nodes will be displayed in the order created, and
+ * there currently is no way to change this.
+ *
+ * @constructor
+ * @todo graft (appendBefore, appendAfter)
+ * @param {string} id The id of the element that the tree will be inserted
+ * into.
+ */
+YAHOO.widget.TreeView = function(id) {
+ if (id) { this.init(id); }
+};
+
+/**
+ * Count of all nodes in all trees
+ * @type int
+ */
+YAHOO.widget.TreeView.nodeCount = 0;
+
+YAHOO.widget.TreeView.prototype = {
+
+ /**
+ * The id of tree container element
+ *
+ * @type String
+ */
+ id: null,
+
+ /**
+ * Flat collection of all nodes in this tree
+ *
+ * @type Node[]
+ * @private
+ */
+ _nodes: null,
+
+ /**
+ * We lock the tree control while waiting for the dynamic loader to return
+ *
+ * @type boolean
+ */
+ locked: false,
+
+ /**
+ * The animation to use for expanding children, if any
+ *
+ * @type string
+ * @private
+ */
+ _expandAnim: null,
+
+ /**
+ * The animation to use for collapsing children, if any
+ *
+ * @type string
+ * @private
+ */
+ _collapseAnim: null,
+
+ /**
+ * The current number of animations that are executing
+ *
+ * @type int
+ * @private
+ */
+ _animCount: 0,
+
+ /**
+ * The maximum number of animations to run at one time.
+ *
+ * @type int
+ */
+ maxAnim: 2,
+
+ /**
+ * Sets up the animation for expanding children
+ *
+ * @param {string} the type of animation (acceptable constants in
YAHOO.widget.TVAnim)
+ */
+ setExpandAnim: function(type) {
+ if (YAHOO.widget.TVAnim.isValid(type)) {
+ this._expandAnim = type;
+ }
+ },
+
+ /**
+ * Sets up the animation for collapsing children
+ *
+ * @param {string} the type of animation (acceptable constants in
YAHOO.widget.TVAnim)
+ */
+ setCollapseAnim: function(type) {
+ if (YAHOO.widget.TVAnim.isValid(type)) {
+ this._collapseAnim = type;
+ }
+ },
+
+ /**
+ * Perform the expand animation if configured, or just show the
+ * element if not configured or too many animations are in progress
+ *
+ * @param el {HTMLElement} the element to animate
+ * @return {boolean} true if animation could be invoked, false otherwise
+ */
+ animateExpand: function(el) {
+
+ if (this._expandAnim && this._animCount < this.maxAnim) {
+ // this.locked = true;
+ var tree = this;
+ var a = YAHOO.widget.TVAnim.getAnim(this._expandAnim, el,
+ function() { tree.expandComplete(); });
+ if (a) {
+ ++this._animCount;
+ a.animate();
+ }
+
+ return true;
+ }
+
+ return false;
+ },
+
+ /**
+ * Perform the collapse animation if configured, or just show the
+ * element if not configured or too many animations are in progress
+ *
+ * @param el {HTMLElement} the element to animate
+ * @return {boolean} true if animation could be invoked, false otherwise
+ */
+ animateCollapse: function(el) {
+
+ if (this._collapseAnim && this._animCount < this.maxAnim) {
+ // this.locked = true;
+ var tree = this;
+ var a = YAHOO.widget.TVAnim.getAnim(this._collapseAnim, el,
+ function() { tree.collapseComplete(); });
+ if (a) {
+ ++this._animCount;
+ a.animate();
+ }
+
+ return true;
+ }
+
+ return false;
+ },
+
+ /**
+ * Function executed when the expand animation completes
+ */
+ expandComplete: function() {
+ --this._animCount;
+ // this.locked = false;
+ },
+
+ /**
+ * Function executed when the collapse animation completes
+ */
+ collapseComplete: function() {
+ --this._animCount;
+ // this.locked = false;
+ },
+
+ /**
+ * Initializes the tree
+ *
+ * @parm {string} id the id of the element that will hold the tree
+ * @private
+ */
+ init: function(id) {
+
+ this.id = id;
+ this._nodes = [];
+
+ // store a global reference
+ YAHOO.widget.TreeView.trees[id] = this;
+
+ // Set up the root node
+ this.root = new YAHOO.widget.RootNode(this);
+
+
+ },
+
+ /**
+ * Renders the tree boilerplate and visible nodes
+ */
+ draw: function() {
+ var html = this.root.getHtml();
+ document.getElementById(this.id).innerHTML = html;
+ this.firstDraw = false;
+ },
+
+ /**
+ * Nodes register themselves with the tree instance when they are created.
+ *
+ * @param node {Node} the node to register
+ * @private
+ */
+ regNode: function(node) {
+ this._nodes[node.index] = node;
+ },
+
+ /**
+ * Returns the root node of this tree
+ *
+ * @return {Node} the root node
+ */
+ getRoot: function() {
+ return this.root;
+ },
+
+ /**
+ * Configures this tree to dynamically load all child data
+ *
+ * @param {function} fnDataLoader the function that will be called to get
the data
+ * @param iconMode {int} configures the icon that is displayed when a
dynamic
+ * load node is expanded the first time without children. By default, the
+ * "collapse" icon will be used. If set to 1, the leaf node icon will be
+ * displayed.
+ */
+ setDynamicLoad: function(fnDataLoader, iconMode) {
+ this.root.setDynamicLoad(fnDataLoader, iconMode);
+ },
+
+ /**
+ * Expands all child nodes. Note: this conflicts with the "multiExpand"
+ * node property. If expand all is called in a tree with nodes that
+ * do not allow multiple siblings to be displayed, only the last sibling
+ * will be expanded.
+ */
+ expandAll: function() {
+ if (!this.locked) {
+ this.root.expandAll();
+ }
+ },
+
+ /**
+ * Collapses all expanded child nodes in the entire tree.
+ */
+ collapseAll: function() {
+ if (!this.locked) {
+ this.root.collapseAll();
+ }
+ },
+
+ /**
+ * Returns a node in the tree that has the specified index (this index
+ * is created internally, so this function probably will only be used
+ * in html generated for a given node.)
+ *
+ * @param {int} nodeIndex the index of the node wanted
+ * @return {Node} the node with index=nodeIndex, null if no match
+ */
+ getNodeByIndex: function(nodeIndex) {
+ var n = this._nodes[nodeIndex];
+ return (n) ? n : null;
+ },
+
+ /**
+ * Returns a node that has a matching property and value in the data
+ * object that was passed into its constructor. Provides a flexible
+ * way for the implementer to get a particular node.
+ *
+ * @param {object} property the property to search (usually a string)
+ * @param {object} value the value we want to find (usuall an int or
string)
+ * @return {Node} the matching node, null if no match
+ */
+ getNodeByProperty: function(property, value) {
+ for (var i in this._nodes) {
+ var n = this._nodes[i];
+ if (n.data && value == n.data[property]) {
+ return n;
+ }
+ }
+
+ return null;
+ },
+
+ /**
+ * Removes the node and its children, and optionally refreshes the branch
+ * of the tree that was affected.
+ * @param {Node} The node to remove
+ * @param {boolean} autoRefresh automatically refreshes branch if true
+ * @return {boolean} False is there was a problem, true otherwise.
+ */
+ removeNode: function(node, autoRefresh) {
+
+ // Don't delete the root node
+ if (node.isRoot()) {
+ return false;
+ }
+
+ // Get the branch that we may need to refresh
+ var p = node.parent;
+ if (p.parent) {
+ p = p.parent;
+ }
+
+ // Delete the node and its children
+ this._deleteNode(node);
+
+ // Refresh the parent of the parent
+ if (autoRefresh && p && p.childrenRendered) {
+ p.refresh();
+ }
+
+ return true;
+ },
+
+ /**
+ * Deletes this nodes child collection, recursively. Also collapses
+ * the node, and resets the dynamic load flag. The primary use for
+ * this method is to purge a node and allow it to fetch its data
+ * dynamically again.
+ * @param {Node} node the node to purge
+ */
+ removeChildren: function(node) {
+ for (var i=0, len=node.children.length;i<len;++i) {
+ this._deleteNode(node.children[i]);
+ }
+
+ node.childrenRendered = false;
+ node.dynamicLoadComplete = false;
+ node.collapse();
+ },
+
+ /**
+ * Deletes the node and recurses children
+ * @private
+ */
+ _deleteNode: function(node) {
+ var p = node.parent;
+
+ // Remove all the child nodes first
+ this.removeChildren(node);
+
+ // Update the parent's collection of children
+ var a = [];
+
+ for (i=0, len=p.children.length;i<len;++i) {
+ if (p.children[i] != node) {
+ a[a.length] = p.children[i];
+ }
+ }
+
+ p.children = a;
+
+ // reset the childrenRendered flag for the parent
+ p.childrenRendered = false;
+
+ // Update the sibling relationship
+ if (node.previousSibling) {
+ node.previousSibling.nextSibling = node.nextSibling;
+ }
+
+ if (node.nextSibling) {
+ node.nextSibling.previousSibling = node.previousSibling;
+ }
+
+ // Update the tree's node collection
+ delete this._nodes[node.index];
+ },
+
+ /**
+ * Abstract method that is executed when a node is expanded
+ *
+ * @param node {Node} the node that was expanded
+ */
+ onExpand: function(node) { },
+
+ /**
+ * Abstract method that is executed when a node is collapsed
+ *
+ * @param node {Node} the node that was collapsed.
+ */
+ onCollapse: function(node) { }
+
+};
+
+/**
+ * Global cache of tree instances
+ *
+ * @type Array
+ * @private
+ */
+YAHOO.widget.TreeView.trees = [];
+
+/**
+ * Global method for getting a tree by its id. Used in the generated
+ * tree html.
+ *
+ * @param treeId {String} the id of the tree instance
+ * @return {TreeView} the tree instance requested, null if not found.
+ */
+YAHOO.widget.TreeView.getTree = function(treeId) {
+ var t = YAHOO.widget.TreeView.trees[treeId];
+ return (t) ? t : null;
+};
+
+/**
+ * Global method for getting a node by its id. Used in the generated
+ * tree html.
+ *
+ * @param treeId {String} the id of the tree instance
+ * @param nodeIndex {String} the index of the node to return
+ * @return {Node} the node instance requested, null if not found
+ */
+YAHOO.widget.TreeView.getNode = function(treeId, nodeIndex) {
+ var t = YAHOO.widget.TreeView.getTree(treeId);
+ return (t) ? t.getNodeByIndex(nodeIndex) : null;
+};
+
+/**
+ * Adds an event. Replace with event manager when available
+ *
+ * @param el the elment to bind the handler to
+ * @param {string} sType the type of event handler
+ * @param {function} fn the callback to invoke
+ * @param {boolean} capture if true event is capture phase, bubble otherwise
+ */
+YAHOO.widget.TreeView.addHandler = function (el, sType, fn, capture) {
+ capture = (capture) ? true : false;
+ if (el.addEventListener) {
+ el.addEventListener(sType, fn, capture);
+ } else if (el.attachEvent) {
+ el.attachEvent("on" + sType, fn);
+ } else {
+ el["on" + sType] = fn;
+ }
+};
+
+/**
+ * Attempts to preload the images defined in the styles used to draw the tree
by
+ * rendering off-screen elements that use the styles.
+ */
+YAHOO.widget.TreeView.preload = function() {
+
+ var styles = [
+ "ygtvtn",
+ "ygtvtm",
+ "ygtvtmh",
+ "ygtvtp",
+ "ygtvtph",
+ "ygtvln",
+ "ygtvlm",
+ "ygtvlmh",
+ "ygtvlp",
+ "ygtvlph",
+ "ygtvloading"
+ ];
+
+ var sb = [];
+
+ for (var i = 0; i < styles.length; ++i) {
+ sb[sb.length] = '<span class="' + styles[i] + '"> </span>';
+ }
+
+ var f = document.createElement("div");
+ var s = f.style;
+ s.position = "absolute";
+ s.top = "-1000px";
+ s.left = "-1000px";
+ f.innerHTML = sb.join("");
+
+ document.body.appendChild(f);
+};
+
+YAHOO.widget.TreeView.addHandler(window,
+ "load", YAHOO.widget.TreeView.preload);
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * The base class for all tree nodes. The node's presentation and behavior in
+ * response to mouse events is handled in Node subclasses.
+ *
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ * @constructor
+ */
+YAHOO.widget.Node = function(oData, oParent, expanded) {
+ if (oParent) { this.init(oData, oParent, expanded); }
+};
+
+YAHOO.widget.Node.prototype = {
+
+ /**
+ * The index for this instance obtained from global counter in
YAHOO.widget.TreeView.
+ *
+ * @type int
+ */
+ index: 0,
+
+ /**
+ * This node's child node collection.
+ *
+ * @type Node[]
+ */
+ children: null,
+
+ /**
+ * Tree instance this node is part of
+ *
+ * @type TreeView
+ */
+ tree: null,
+
+ /**
+ * The data linked to this node. This can be any object or primitive
+ * value, and the data can be used in getNodeHtml().
+ *
+ * @type object
+ */
+ data: null,
+
+ /**
+ * Parent node
+ *
+ * @type Node
+ */
+ parent: null,
+
+ /**
+ * The depth of this node. We start at -1 for the root node.
+ *
+ * @type int
+ */
+ depth: -1,
+
+ /**
+ * The href for the node's label. If one is not specified, the href will
+ * be set so that it toggles the node.
+ *
+ * @type string
+ */
+ href: null,
+
+ /**
+ * The label href target, defaults to current window
+ *
+ * @type string
+ */
+ target: "_self",
+
+ /**
+ * The node's expanded/collapsed state
+ *
+ * @type boolean
+ */
+ expanded: false,
+
+ /**
+ * Can multiple children be expanded at once?
+ *
+ * @type boolean
+ */
+ multiExpand: true,
+
+ /**
+ * Should we render children for a collapsed node? It is possible that the
+ * implementer will want to render the hidden data... @todo verify that
we
+ * need this, and implement it if we do.
+ *
+ * @type boolean
+ */
+ renderHidden: false,
+
+ /**
+ * This flag is set to true when the html is generated for this node's
+ * children, and set to false when new children are added.
+ * @type boolean
+ */
+ childrenRendered: false,
+
+ /**
+ * Dynamically loaded nodes only fetch the data the first time they are
+ * expanded. This flag is set to true once the data has been fetched.
+ * @type boolean
+ */
+ dynamicLoadComplete: false,
+
+ /**
+ * This node's previous sibling
+ *
+ * @type Node
+ */
+ previousSibling: null,
+
+ /**
+ * This node's next sibling
+ *
+ * @type Node
+ */
+ nextSibling: null,
+
+ /**
+ * We can set the node up to call an external method to get the child
+ * data dynamically.
+ *
+ * @type boolean
+ * @private
+ */
+ _dynLoad: false,
+
+ /**
+ * Function to execute when we need to get this node's child data.
+ *
+ * @type function
+ */
+ dataLoader: null,
+
+ /**
+ * This is true for dynamically loading nodes while waiting for the
+ * callback to return.
+ *
+ * @type boolean
+ */
+ isLoading: false,
+
+ /**
+ * The toggle/branch icon will not show if this is set to false. This
+ * could be useful if the implementer wants to have the child contain
+ * extra info about the parent, rather than an actual node.
+ *
+ * @type boolean
+ */
+ hasIcon: true,
+
+ /**
+ * Used to configure what happens when a dynamic load node is expanded
+ * and we discover that it does not have children. By default, it is
+ * treated as if it still could have children (plus/minus icon). Set
+ * iconMode to have it display like a leaf node instead.
+ * @type int
+ */
+ iconMode: 0,
+
+ /**
+ * The node type
+ * @private
+ */
+ _type: "Node",
+
+ /*
+ spacerPath: "http://us.i1.yimg.com/us.yimg.com/i/space.gif",
+ expandedText: "Expanded",
+ collapsedText: "Collapsed",
+ loadingText: "Loading",
+ */
+
+ /**
+ * Initializes this node, gets some of the properties from the parent
+ *
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ */
+ init: function(oData, oParent, expanded) {
+ this.data = oData;
+ this.children = [];
+ this.index = YAHOO.widget.TreeView.nodeCount;
+ ++YAHOO.widget.TreeView.nodeCount;
+ this.expanded = expanded;
+
+ // oParent should never be null except when we create the root node.
+ if (oParent) {
+ this.tree = oParent.tree;
+ this.parent = oParent;
+ this.href = "javascript:" + this.getToggleLink();
+ this.depth = oParent.depth + 1;
+ this.multiExpand = oParent.multiExpand;
+
+ oParent.appendChild(this);
+ }
+ },
+
+ /**
+ * Appends a node to the child collection.
+ *
+ * @param node {Node} the new node
+ * @return {Node} the child node
+ * @private
+ * @TODO insertBefore, insertAfter
+ */
+ appendChild: function(node) {
+ if (this.hasChildren()) {
+ var sib = this.children[this.children.length - 1];
+ sib.nextSibling = node;
+ node.previousSibling = sib;
+ }
+
+ this.tree.regNode(node);
+ this.children[this.children.length] = node;
+ this.childrenRendered = false;
+ return node;
+
+ },
+
+ /**
+ * Returns a node array of this node's siblings, null if none.
+ *
+ * @return Node[]
+ */
+ getSiblings: function() {
+ return this.parent.children;
+ },
+
+ /**
+ * Shows this node's children
+ */
+ showChildren: function() {
+ if (!this.tree.animateExpand(this.getChildrenEl())) {
+ if (this.hasChildren()) {
+ this.getChildrenEl().style.display = "";
+ }
+ }
+ },
+
+ /**
+ * Hides this node's children
+ */
+ hideChildren: function() {
+
+ if (!this.tree.animateCollapse(this.getChildrenEl())) {
+ this.getChildrenEl().style.display = "none";
+ }
+ },
+
+ /**
+ * Returns the id for this node's container div
+ *
+ * @return {string} the element id
+ */
+ getElId: function() {
+ return "ygtv" + this.index;
+ },
+
+ /**
+ * Returns the id for this node's children div
+ *
+ * @return {string} the element id for this node's children div
+ */
+ getChildrenElId: function() {
+ return "ygtvc" + this.index;
+ },
+
+ /**
+ * Returns the id for this node's toggle element
+ *
+ * @return {string} the toggel element id
+ */
+ getToggleElId: function() {
+ return "ygtvt" + this.index;
+ },
+
+ /**
+ * Returns the id for this node's spacer image. The spacer is positioned
+ * over the toggle and provides feedback for screen readers.
+ * @return {string} the id for the spacer image
+ */
+ /*
+ getSpacerId: function() {
+ return "ygtvspacer" + this.index;
+ },
+ */
+
+ /**
+ * Returns this node's container html element
+ * @return {HTMLElement} the container html element
+ */
+ getEl: function() {
+ return document.getElementById(this.getElId());
+ },
+
+ /**
+ * Returns the div that was generated for this node's children
+ * @return {HTMLElement} this node's children div
+ */
+ getChildrenEl: function() {
+ return document.getElementById(this.getChildrenElId());
+ },
+
+ /**
+ * Returns the element that is being used for this node's toggle.
+ * @return {HTMLElement} this node's toggle html element
+ */
+ getToggleEl: function() {
+ return document.getElementById(this.getToggleElId());
+ },
+
+ /**
+ * Returns the element that is being used for this node's spacer.
+ * @return {HTMLElement} this node's spacer html element
+ */
+ /*
+ getSpacer: function() {
+ return document.getElementById( this.getSpacerId() ) || {};
+ },
+ */
+
+ /*
+ getStateText: function() {
+ if (this.isLoading) {
+ return this.loadingText;
+ } else if (this.hasChildren(true)) {
+ if (this.expanded) {
+ return this.expandedText;
+ } else {
+ return this.collapsedText;
+ }
+ } else {
+ return "";
+ }
+ },
+ */
+
+ /**
+ * Generates the link that will invoke this node's toggle method
+ * @return {string} the javascript url for toggling this node
+ */
+ getToggleLink: function() {
+ return "YAHOO.widget.TreeView.getNode(\'" + this.tree.id + "\'," +
+ this.index + ").toggle()";
+ },
+
+ /**
+ * Hides this nodes children (creating them if necessary), changes the
+ * toggle style.
+ */
+ collapse: function() {
+ // Only collapse if currently expanded
+ if (!this.expanded) { return; }
+
+ // fire the collapse event handler
+ var ret = this.tree.onCollapse(this);
+
+ if ("undefined" != typeof ret && !ret) {
+ return;
+ }
+
+ if (!this.getEl()) {
+ this.expanded = false;
+ return;
+ }
+
+ // hide the child div
+ this.hideChildren();
+ this.expanded = false;
+
+ if (this.hasIcon) {
+ this.getToggleEl().className = this.getStyle();
+ }
+
+ // this.getSpacer().title = this.getStateText();
+
+ },
+
+ /**
+ * Shows this nodes children (creating them if necessary), changes the
+ * toggle style, and collapses its siblings if multiExpand is not set.
+ */
+ expand: function() {
+ // Only expand if currently collapsed.
+ if (this.expanded) { return; }
+
+ // fire the expand event handler
+ var ret = this.tree.onExpand(this);
+
+ if ("undefined" != typeof ret && !ret) {
+ return;
+ }
+
+ if (!this.getEl()) {
+ this.expanded = true;
+ return;
+ }
+
+ if (! this.childrenRendered) {
+ this.getChildrenEl().innerHTML = this.renderChildren();
+ } else {
+ }
+
+ this.expanded = true;
+ if (this.hasIcon) {
+ this.getToggleEl().className = this.getStyle();
+ }
+
+ // this.getSpacer().title = this.getStateText();
+
+ // We do an extra check for children here because the lazy
+ // load feature can expose nodes that have no children.
+
+ // if (!this.hasChildren()) {
+ if (this.isLoading) {
+ this.expanded = false;
+ return;
+ }
+
+ if (! this.multiExpand) {
+ var sibs = this.getSiblings();
+ for (var i=0; i<sibs.length; ++i) {
+ if (sibs[i] != this && sibs[i].expanded) {
+ sibs[i].collapse();
+ }
+ }
+ }
+
+ this.showChildren();
+ },
+
+ /**
+ * Returns the css style name for the toggle
+ *
+ * @return {string} the css class for this node's toggle
+ */
+ getStyle: function() {
+ if (this.isLoading) {
+ return "ygtvloading";
+ } else {
+ // location top or bottom, middle nodes also get the top style
+ var loc = (this.nextSibling) ? "t" : "l";
+
+ // type p=plus(expand), m=minus(collapase), n=none(no children)
+ var type = "n";
+ if (this.hasChildren(true) || (this.isDynamic() &&
!this.getIconMode())) {
+ // if (this.hasChildren(true)) {
+ type = (this.expanded) ? "m" : "p";
+ }
+
+ return "ygtv" + loc + type;
+ }
+ },
+
+ /**
+ * Returns the hover style for the icon
+ * @return {string} the css class hover state
+ */
+ getHoverStyle: function() {
+ var s = this.getStyle();
+ if (this.hasChildren(true) && !this.isLoading) {
+ s += "h";
+ }
+ return s;
+ },
+
+ /**
+ * Recursively expands all of this node's children.
+ */
+ expandAll: function() {
+ for (var i=0;i<this.children.length;++i) {
+ var c = this.children[i];
+ if (c.isDynamic()) {
+ alert("Not supported (lazy load + expand all)");
+ break;
+ } else if (! c.multiExpand) {
+ alert("Not supported (no multi-expand + expand all)");
+ break;
+ } else {
+ c.expand();
+ c.expandAll();
+ }
+ }
+ },
+
+ /**
+ * Recursively collapses all of this node's children.
+ */
+ collapseAll: function() {
+ for (var i=0;i<this.children.length;++i) {
+ this.children[i].collapse();
+ this.children[i].collapseAll();
+ }
+ },
+
+ /**
+ * Configures this node for dynamically obtaining the child data
+ * when the node is first expanded. Calling it without the callback
+ * will turn off dynamic load for the node.
+ *
+ * @param fmDataLoader {function} the function that will be used to get
the data.
+ * @param iconMode {int} configures the icon that is displayed when a
dynamic
+ * load node is expanded the first time without children. By default, the
+ * "collapse" icon will be used. If set to 1, the leaf node icon will be
+ * displayed.
+ */
+ setDynamicLoad: function(fnDataLoader, iconMode) {
+ if (fnDataLoader) {
+ this.dataLoader = fnDataLoader;
+ this._dynLoad = true;
+ } else {
+ this.dataLoader = null;
+ this._dynLoad = false;
+ }
+
+ if (iconMode) {
+ this.iconMode = iconMode;
+ }
+ },
+
+ /**
+ * Evaluates if this node is the root node of the tree
+ *
+ * @return {boolean} true if this is the root node
+ */
+ isRoot: function() {
+ return (this == this.tree.root);
+ },
+
+ /**
+ * Evaluates if this node's children should be loaded dynamically. Looks
for
+ * the property both in this instance and the root node. If the tree is
+ * defined to load all children dynamically, the data callback function is
+ * defined in the root node
+ *
+ * @return {boolean} true if this node's children are to be loaded
dynamically
+ */
+ isDynamic: function() {
+ var lazy = (!this.isRoot() && (this._dynLoad ||
this.tree.root._dynLoad));
+ return lazy;
+ },
+
+ getIconMode: function() {
+ return (this.iconMode || this.tree.root.iconMode);
+ },
+
+ /**
+ * Checks if this node has children. If this node is lazy-loading and the
+ * children have not been rendered, we do not know whether or not there
+ * are actual children. In most cases, we need to assume that there are
+ * children (for instance, the toggle needs to show the expandable
+ * presentation state). In other times we want to know if there are
rendered
+ * children. For the latter, "checkForLazyLoad" should be false.
+ *
+ * @param checkForLazyLoad {boolean} should we check for unloaded children?
+ * @return {boolean} true if this has children or if it might and we are
+ * checking for this condition.
+ */
+ hasChildren: function(checkForLazyLoad) {
+ return ( this.children.length > 0 ||
+ (checkForLazyLoad && this.isDynamic() &&
!this.dynamicLoadComplete) );
+ },
+
+ /**
+ * Expands if node is collapsed, collapses otherwise.
+ */
+ toggle: function() {
+ if (!this.tree.locked && ( this.hasChildren(true) || this.isDynamic())
) {
+ if (this.expanded) { this.collapse(); } else { this.expand(); }
+ }
+ },
+
+ /**
+ * Returns the markup for this node and its children.
+ *
+ * @return {string} the markup for this node and its expanded children.
+ */
+ 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("");
+ },
+
+ /**
+ * 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.
+ *
+ * @return {string} the children container div html and any expanded
children
+ * @private
+ */
+ 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] = '>';
+
+ // Don't render the actual child node HTML unless this node is
expanded.
+ if ( (this.hasChildren(true) && this.expanded) ||
+ (this.renderHidden && !this.isDynamic()) ) {
+ sb[sb.length] = this.renderChildren();
+ }
+
+ sb[sb.length] = '</div>';
+
+ return sb.join("");
+ },
+
+ /**
+ * Generates the markup for the child nodes. This is not done until the
node
+ * is expanded.
+ *
+ * @return {string} the html for this node's children
+ * @private
+ */
+ 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();
+ }
+ },
+
+ /**
+ * Called when we know we have all the child data.
+ * @return {string} children html
+ */
+ 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("");
+ },
+
+ /**
+ * Load complete is the callback function we pass to the data provider
+ * in dynamic load situations.
+ */
+ loadComplete: function() {
+ this.getChildrenEl().innerHTML = this.completeRender();
+ this.dynamicLoadComplete = true;
+ this.isLoading = false;
+ this.expand();
+ this.tree.locked = false;
+ },
+
+ /**
+ * Returns this node's ancestor at the specified depth.
+ *
+ * @param {int} depth the depth of the ancestor.
+ * @return {Node} the ancestor
+ */
+ getAncestor: function(depth) {
+ if (depth >= this.depth || depth < 0) {
+ return null;
+ }
+
+ var p = this.parent;
+
+ while (p.depth > depth) {
+ p = p.parent;
+ }
+
+ return p;
+ },
+
+ /**
+ * Returns the css class for the spacer at the specified depth for
+ * 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
+ *
+ * @param {int} depth the depth of the ancestor.
+ * @return {string} the css class for the spacer
+ */
+ getDepthStyle: function(depth) {
+ 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.
+ *
+ * @return {string} The HTML that will render this node.
+ */
+ getNodeHtml: function() {
+ return "";
+ },
+
+ /**
+ * Regenerates the html for this node and its children. To be used when
the
+ * node is expanded and new children have been added.
+ */
+ refresh: function() {
+ // this.loadComplete();
+ this.getChildrenEl().innerHTML = this.completeRender();
+
+ if (this.hasIcon) {
+ var el = this.getToggleEl();
+ if (el) {
+ el.className = this.getStyle();
+ }
+ }
+ }
+
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * A custom YAHOO.widget.Node that handles the unique nature of
+ * the virtual, presentationless root node.
+ *
+ * @extends YAHOO.widget.Node
+ * @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();
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.RootNode.prototype.getNodeHtml = function() {
+ return "";
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * 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.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ * @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
+ */
+YAHOO.widget.TextNode = function(oData, oParent, expanded) {
+ this.type = "TextNode";
+
+ if (oParent) {
+ this.init(oData, oParent, expanded);
+ this.setUpLabel(oData);
+ }
+};
+
+YAHOO.widget.TextNode.prototype = new 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.
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.labelStyle = "ygtvlabel";
+
+/**
+ * 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.
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.label = null;
+
+/**
+ * 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;
+
+ // update the link
+ if (oData.href) {
+ this.href = oData.href;
+ }
+
+ // set the target
+ if (oData.target) {
+ this.target = oData.target;
+ }
+
+ if (oData.style) {
+ this.labelStyle = oData.style;
+ }
+
+ this.labelElId = "ygtvlabelel" + this.index;
+};
+
+/**
+ * Returns the label element
+ *
+ * @return {object} the element
+ */
+YAHOO.widget.TextNode.prototype.getLabelEl = function() {
+ return document.getElementById(this.labelElId);
+};
+
+// overrides YAHOO.widget.Node
+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="ygtvdepthcell"> </td>';
+ 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] = ' onselectstart="return false"';
+ 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] = '<img id="' + this.getSpacerId() + '"';
+ sb[sb.length] = ' alt=""';
+ sb[sb.length] = ' tabindex=0';
+ sb[sb.length] = ' src="' + this.spacerPath + '"';
+ sb[sb.length] = ' title="' + this.getStateText() + '"';
+ sb[sb.length] = ' class="ygtvspacer"';
+ // sb[sb.length] = ' onkeypress="return ' + getNode + '".onKeyPress()"';
+ sb[sb.length] = ' />';
+ */
+
+ 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("");
+};
+
+/**
+ * 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) {
+ //return true;
+};
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * A menu-specific implementation that differs from TextNode in that only
+ * one sibling can be expanded at a time.
+ * @extends YAHOO.widget.TextNode
+ * @constructor
+ */
+YAHOO.widget.MenuNode = function(oData, oParent, expanded) {
+ if (oParent) {
+ 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;
+
+};
+
+YAHOO.widget.MenuNode.prototype = new YAHOO.widget.TextNode();
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * 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.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ * @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
+ * @param hasIcon {boolean} specifies whether or not leaf nodes should
+ * have an icon
+ */
+YAHOO.widget.HTMLNode = function(oData, oParent, expanded, hasIcon) {
+ if (oParent) {
+ this.init(oData, oParent, expanded);
+ this.initContent(oData, hasIcon);
+ }
+};
+
+YAHOO.widget.HTMLNode.prototype = new 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.
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.contentStyle = "ygtvhtml";
+
+/**
+ * The generated id that will contain the data passed in by the implementer.
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.contentElId = null;
+
+/**
+ * The HTML content to use for this node's display
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.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;
+};
+
+/**
+ * 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);
+};
+
+// overrides YAHOO.widget.Node
+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("");
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * A static factory class for tree view expand/collapse animations
+ *
+ * @constructor
+ */
+YAHOO.widget.TVAnim = function() {
+ return {
+ /**
+ * Constant for the fade in animation
+ *
+ * @type string
+ */
+ FADE_IN: "TVFadeIn",
+
+ /**
+ * Constant for the fade out animation
+ *
+ * @type string
+ */
+ FADE_OUT: "TVFadeOut",
+
+ /**
+ * Returns a ygAnim instance of the given type
+ *
+ * @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
+ */
+ getAnim: function(type, el, callback) {
+ if (YAHOO.widget[type]) {
+ return new YAHOO.widget[type](el, callback);
+ } else {
+ return null;
+ }
+ },
+
+ /**
+ * Returns true if the specified animation class is available
+ *
+ * @param type {string} the type of animation
+ * @return {boolean} true if valid, false if not
+ */
+ isValid: function(type) {
+ return (YAHOO.widget[type]);
+ }
+ };
+} ();
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * A 1/2 second fade-in animation.
+ *
+ * @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
+ * @type HTMLElement
+ */
+ this.el = el;
+
+ /**
+ * the callback to invoke when the animation is complete
+ *
+ * @type function
+ */
+ this.callback = callback;
+
+ /**
+ * @private
+ */
+};
+
+/**
+ * Performs the animation
+ */
+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 = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
+ var dur = 0.4;
+ // 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 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
+ */
+ onComplete: function() {
+ this.callback();
+ }
+};
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * A 1/2 second fade out animation.
+ *
+ * @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
+ * @type HTMLElement
+ */
+ this.el = el;
+
+ /**
+ * the callback to invoke when the animation is complete
+ *
+ * @type function
+ */
+ this.callback = callback;
+
+ /**
+ * @private
+ */
+};
+
+/**
+ * Performs the animation
+ */
+YAHOO.widget.TVFadeOut.prototype = {
+ animate: function() {
+ var tvanim = this;
+ // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
+ var dur = 0.4;
+ // 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
+ */
+ onComplete: function() {
+ var s = this.el.style;
+ s.display = "none";
+ // s.opacity = 1;
+ s.filter = "alpha(opacity=100)";
+ this.callback();
+ }
+};
+
Added: trunk/documentation/topic/cms/js/yahoo.js
==============================================================================
--- (empty file)
+++ trunk/documentation/topic/cms/js/yahoo.js Tue Jun 6 07:55:53 2006
@@ -0,0 +1,61 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.10.0
+*/
+
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/**
+ * The Yahoo global namespace
+ * @constructor
+ */
+var YAHOO = window.YAHOO || {};
+
+/**
+ * Returns the namespace specified and creates it if it doesn't exist
+ *
+ * YAHOO.namespace("property.package");
+ * YAHOO.namespace("YAHOO.property.package");
+ *
+ * Either of the above would create YAHOO.property, then
+ * YAHOO.property.package
+ *
+ * @param {String} sNameSpace String representation of the desired
+ * namespace
+ * @return {Object} A reference to the namespace object
+ */
+YAHOO.namespace = function( sNameSpace ) {
+
+ if (!sNameSpace || !sNameSpace.length) {
+ return null;
+ }
+
+ var levels = sNameSpace.split(".");
+
+ var currentNS = YAHOO;
+
+ // YAHOO is implied, so it is ignored if it is included
+ for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
+ currentNS[levels[i]] = currentNS[levels[i]] || {};
+ currentNS = currentNS[levels[i]];
+ }
+
+ return currentNS;
+};
+
+/**
+ * Global log method.
+ */
+YAHOO.log = function(sMsg,sCategory) {
+ if(YAHOO.widget.Logger) {
+ YAHOO.widget.Logger.log(null, sMsg, sCategory);
+ } else {
+ return false;
+ }
+};
+
+YAHOO.namespace("util");
+YAHOO.namespace("widget");
+YAHOO.namespace("example");
--
Gd-chatter mailing list
Gd-chatter@xxxxxxxxxxxxxxxx
https://www.gwydiondylan.org/mailman/listinfo/gd-chatter
|