From 01d48661816c7336041f2018e4cbf660476ad19e Mon Sep 17 00:00:00 2001
From: vyshane
Date: Thu, 8 Feb 2007 05:19:36 +0000
Subject: [PATCH] Updated YUI library to 0.12.2
---
lib/yui/README.txt | 1 +
lib/yui/animation/README | 78 +-
lib/yui/animation/animation-debug.js | 2621 ++---
lib/yui/animation/animation-min.js | 123 +-
lib/yui/animation/animation.js | 2613 ++---
lib/yui/autocomplete/README | 136 +-
lib/yui/autocomplete/autocomplete-debug.js | 2191 ++--
lib/yui/autocomplete/autocomplete-min.js | 359 +-
lib/yui/autocomplete/autocomplete.js | 2149 ++--
lib/yui/calendar/README | 150 +-
lib/yui/calendar/assets/calendar.css | 382 +-
lib/yui/calendar/calendar-debug.js | 8565 ++++++++-------
lib/yui/calendar/calendar-min.js | 218 +-
lib/yui/calendar/calendar.js | 8487 ++++++++-------
lib/yui/connection/README | 320 +-
lib/yui/connection/connection-debug.js | 1958 ++--
lib/yui/connection/connection-min.js | 201 +-
lib/yui/connection/connection.js | 1923 ++--
lib/yui/container/README | 217 +-
lib/yui/container/assets/container.css | 422 +-
lib/yui/container/container-debug.js | 9343 +++++++++--------
lib/yui/container/container-min.js | 302 +-
lib/yui/container/container.js | 9262 ++++++++--------
lib/yui/container/container_core-debug.js | 5883 ++++++-----
lib/yui/container/container_core-min.js | 205 +-
lib/yui/container/container_core.js | 5830 +++++-----
lib/yui/dom/README | 147 +-
lib/yui/dom/dom-debug.js | 1855 ++--
lib/yui/dom/dom-min.js | 110 +-
lib/yui/dom/dom.js | 1785 ++--
lib/yui/dragdrop/README | 216 +-
lib/yui/dragdrop/dragdrop-debug.js | 6111 +++++------
lib/yui/dragdrop/dragdrop-min.js | 179 +-
lib/yui/dragdrop/dragdrop.js | 5896 +++++------
lib/yui/event/README | 265 +-
lib/yui/event/event-debug.js | 3592 +++----
lib/yui/event/event-min.js | 129 +-
lib/yui/event/event.js | 3542 +++----
lib/yui/fonts/README | 26 +-
lib/yui/fonts/fonts-min.css | 2 +-
lib/yui/fonts/fonts.css | 54 +-
lib/yui/grids/README | 86 +-
lib/yui/grids/grids-min.css | 1 -
lib/yui/grids/grids.css | 250 +-
lib/yui/logger/README | 82 +-
lib/yui/logger/assets/logger.css | 46 +-
lib/yui/logger/logger-debug.js | 3127 +++---
lib/yui/logger/logger-min.js | 118 +-
lib/yui/logger/logger.js | 3127 +++---
lib/yui/menu/README | 498 +-
lib/yui/menu/assets/menu.css | 592 +-
lib/yui/menu/menu-debug.js | 8551 ++++++++-------
lib/yui/menu/menu-min.js | 432 +-
lib/yui/menu/menu.js | 8463 ++++++++-------
lib/yui/reset-fonts-grids/README | 32 +-
.../reset-fonts-grids/reset-fonts-grids.css | 5 +-
lib/yui/reset/README | 40 +-
lib/yui/reset/reset-min.css | 2 +-
lib/yui/reset/reset.css | 22 +-
lib/yui/slider/README | 122 +-
lib/yui/slider/slider-debug.js | 2505 ++---
lib/yui/slider/slider-min.js | 63 +-
lib/yui/slider/slider.js | 2416 ++---
lib/yui/tabview/README | 27 +-
lib/yui/tabview/assets/border_tabs.css | 94 +-
lib/yui/tabview/assets/tabs.css | 66 -
lib/yui/tabview/tabview-debug.js | 3917 +++----
lib/yui/tabview/tabview-min.js | 113 +-
lib/yui/tabview/tabview.js | 3879 +++----
lib/yui/treeview/README | 254 +-
lib/yui/treeview/assets/tree.css | 201 +-
lib/yui/treeview/treeview-debug.js | 4556 ++++----
lib/yui/treeview/treeview-min.js | 135 +-
lib/yui/treeview/treeview.js | 4463 ++++----
lib/yui/utilities/README | 59 +-
lib/yui/utilities/utilities.js | 734 +-
lib/yui/yahoo-dom-event/README | 62 +-
lib/yui/yahoo-dom-event/yahoo-dom-event.js | 242 +-
lib/yui/yahoo/README | 85 +-
lib/yui/yahoo/yahoo-debug.js | 288 +-
lib/yui/yahoo/yahoo-min.js | 15 +-
lib/yui/yahoo/yahoo.js | 287 +-
82 files changed, 69138 insertions(+), 68767 deletions(-)
delete mode 100755 lib/yui/tabview/assets/tabs.css
diff --git a/lib/yui/README.txt b/lib/yui/README.txt
index 10db7aa9d0..cf4952ba59 100644
--- a/lib/yui/README.txt
+++ b/lib/yui/README.txt
@@ -8,3 +8,4 @@ from:
Added to Moodle 13 July 2006
Updated to YUI 0.12.0, 23 November 2006
Updated to YUI 0.12.1, 8 January 2007
+Updated to YUI 0.12.2, 8 Febuary 2007
\ No newline at end of file
diff --git a/lib/yui/animation/README b/lib/yui/animation/README
index f79c1c30c6..d6ea69a4be 100755
--- a/lib/yui/animation/README
+++ b/lib/yui/animation/README
@@ -1,37 +1,41 @@
-Animation Release Notes
-
-*** version 0.12.1 ***
-* minified version no longer strips line breaks
-
-*** version 0.12.0 ***
-
-* added boolean finish argument to Anim.stop()
-
-*** version 0.11.3 ***
-
-* no changes
-
-*** version 0.11.1 ***
-
-* changed "prototype" shorthand to "proto" (workaround firefox < 1.5 scoping
-bug)
-
-*** version 0.11.0 ***
-
-* ColorAnim subclass added
-* Motion and Scroll now inherit from ColorAnim
-* getDefaultUnit method added
-* defaultUnit and defaultUnits deprecated
-* getDefault and setDefault methods deprecated
-
-*** version 0.10.0 ***
-
-* Scroll now handles relative ("by") animation correctly
-
-* Now converts "auto" values of "from" to appropriate initial values
-
-*** version 0.9.0 ***
-
-* Initial release
-
-
+Animation Release Notes
+
+*** version 0.12.2 ***
+
+* raised AnimMgr.fps to 1000
+
+*** version 0.12.1 ***
+* minified version no longer strips line breaks
+
+*** version 0.12.0 ***
+
+* added boolean finish argument to Anim.stop()
+
+*** version 0.11.3 ***
+
+* no changes
+
+*** version 0.11.1 ***
+
+* changed "prototype" shorthand to "proto" (workaround firefox < 1.5 scoping
+bug)
+
+*** version 0.11.0 ***
+
+* ColorAnim subclass added
+* Motion and Scroll now inherit from ColorAnim
+* getDefaultUnit method added
+* defaultUnit and defaultUnits deprecated
+* getDefault and setDefault methods deprecated
+
+*** version 0.10.0 ***
+
+* Scroll now handles relative ("by") animation correctly
+
+* Now converts "auto" values of "from" to appropriate initial values
+
+*** version 0.9.0 ***
+
+* Initial release
+
+
diff --git a/lib/yui/animation/animation-debug.js b/lib/yui/animation/animation-debug.js
index 915941f403..7745b235b7 100755
--- a/lib/yui/animation/animation-debug.js
+++ b/lib/yui/animation/animation-debug.js
@@ -1,1276 +1,1345 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 0.12.1
-*/
-
-/**
- * The animation module provides allows effects to be added to HTMLElements.
- * @module animation
- */
-
-/**
- *
- * Base animation class that provides the interface for building animated effects.
- * Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);
- * @class Anim
- * @namespace YAHOO.util
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @constructor
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
-
-YAHOO.util.Anim = function(el, attributes, duration, method) {
- if (el) {
- this.init(el, attributes, duration, method);
- }
-};
-
-YAHOO.util.Anim.prototype = {
- /**
- * Provides a readable name for the Anim instance.
- * @method toString
- * @return {String}
- */
- toString: function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("Anim " + id);
- },
-
- patterns: { // cached for performance
- noNegatives: /width|height|opacity|padding/i, // keep at zero or above
- offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default
- defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default
- offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset
- },
-
- /**
- * Returns the value computed by the animation's "method".
- * @method doMethod
- * @param {String} attr The name of the attribute.
- * @param {Number} start The value this attribute should start from for this animation.
- * @param {Number} end The value this attribute should end at for this animation.
- * @return {Number} The Value to be applied to the attribute.
- */
- doMethod: function(attr, start, end) {
- return this.method(this.currentFrame, start, end - start, this.totalFrames);
- },
-
- /**
- * Applies a value to an attribute.
- * @method setAttribute
- * @param {String} attr The name of the attribute.
- * @param {Number} val The value to be applied to the attribute.
- * @param {String} unit The unit ('px', '%', etc.) of the value.
- */
- setAttribute: function(attr, val, unit) {
- if ( this.patterns.noNegatives.test(attr) ) {
- val = (val > 0) ? val : 0;
- }
-
- YAHOO.util.Dom.setStyle(this.getEl(), attr, val + unit);
- },
-
- /**
- * Returns current value of the attribute.
- * @method getAttribute
- * @param {String} attr The name of the attribute.
- * @return {Number} val The current value of the attribute.
- */
- getAttribute: function(attr) {
- var el = this.getEl();
- var val = YAHOO.util.Dom.getStyle(el, attr);
-
- if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
- return parseFloat(val);
- }
-
- var a = this.patterns.offsetAttribute.exec(attr) || [];
- var pos = !!( a[3] ); // top or left
- var box = !!( a[2] ); // width or height
-
- // use offsets for width/height and abs pos top/left
- if ( box || (YAHOO.util.Dom.getStyle(el, 'position') == 'absolute' && pos) ) {
- val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
- } else { // default to zero for other 'auto'
- val = 0;
- }
-
- return val;
- },
-
- /**
- * Returns the unit to use when none is supplied.
- * @method getDefaultUnit
- * @param {attr} attr The name of the attribute.
- * @return {String} The default unit to be used.
- */
- getDefaultUnit: function(attr) {
- if ( this.patterns.defaultUnit.test(attr) ) {
- return 'px';
- }
-
- return '';
- },
-
- /**
- * Sets the actual values to be used during the animation.
- * @method setRuntimeAttribute
- * Should only be needed for subclass use.
- * @param {Object} attr The attribute object
- * @private
- */
- setRuntimeAttribute: function(attr) {
- var start;
- var end;
- var attributes = this.attributes;
-
- this.runtimeAttributes[attr] = {};
-
- var isset = function(prop) {
- return (typeof prop !== 'undefined');
- };
-
- if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) {
- return false; // note return; nothing to animate to
- }
-
- start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
-
- // To beats by, per SMIL 2.1 spec
- if ( isset(attributes[attr]['to']) ) {
- end = attributes[attr]['to'];
- } else if ( isset(attributes[attr]['by']) ) {
- if (start.constructor == Array) {
- end = [];
- for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + attributes[attr]['by'][i];
- }
- } else {
- end = start + attributes[attr]['by'];
- }
- }
-
- this.runtimeAttributes[attr].start = start;
- this.runtimeAttributes[attr].end = end;
-
- // set units if needed
- this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
- },
-
- /**
- * Constructor for Anim instance.
- * @method init
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- init: function(el, attributes, duration, method) {
- /**
- * Whether or not the animation is running.
- * @property isAnimated
- * @private
- * @type Boolean
- */
- var isAnimated = false;
-
- /**
- * A Date object that is created when the animation begins.
- * @property startTime
- * @private
- * @type Date
- */
- var startTime = null;
-
- /**
- * The number of frames this animation was able to execute.
- * @property actualFrames
- * @private
- * @type Int
- */
- var actualFrames = 0;
-
- /**
- * The element to be animated.
- * @property el
- * @private
- * @type HTMLElement
- */
- el = YAHOO.util.Dom.get(el);
-
- /**
- * The collection of attributes to be animated.
- * Each attribute must have at least a "to" or "by" defined in order to animate.
- * If "to" is supplied, the animation will end with the attribute at that value.
- * If "by" is supplied, the animation will end at that value plus its starting value.
- * If both are supplied, "to" is used, and "by" is ignored.
- * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values).
- * @property attributes
- * @type Object
- */
- this.attributes = attributes || {};
-
- /**
- * The length of the animation. Defaults to "1" (second).
- * @property duration
- * @type Number
- */
- this.duration = duration || 1;
-
- /**
- * The method that will provide values to the attribute(s) during the animation.
- * Defaults to "YAHOO.util.Easing.easeNone".
- * @property method
- * @type Function
- */
- this.method = method || YAHOO.util.Easing.easeNone;
-
- /**
- * Whether or not the duration should be treated as seconds.
- * Defaults to true.
- * @property useSeconds
- * @type Boolean
- */
- this.useSeconds = true; // default to seconds
-
- /**
- * The location of the current animation on the timeline.
- * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
- * @property currentFrame
- * @type Int
- */
- this.currentFrame = 0;
-
- /**
- * The total number of frames to be executed.
- * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
- * @property totalFrames
- * @type Int
- */
- this.totalFrames = YAHOO.util.AnimMgr.fps;
-
-
- /**
- * Returns a reference to the animated element.
- * @method getEl
- * @return {HTMLElement}
- */
- this.getEl = function() { return el; };
-
- /**
- * Checks whether the element is currently animated.
- * @method isAnimated
- * @return {Boolean} current value of isAnimated.
- */
- this.isAnimated = function() {
- return isAnimated;
- };
-
- /**
- * Returns the animation start time.
- * @method getStartTime
- * @return {Date} current value of startTime.
- */
- this.getStartTime = function() {
- return startTime;
- };
-
- this.runtimeAttributes = {};
-
- var logger = {};
- logger.log = function() {YAHOO.log.apply(window, arguments)};
-
- logger.log('creating new instance of ' + this);
-
- /**
- * Starts the animation by registering it with the animation manager.
- * @method animate
- */
- this.animate = function() {
- if ( this.isAnimated() ) { return false; }
-
- this.currentFrame = 0;
-
- this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration;
-
- YAHOO.util.AnimMgr.registerElement(this);
- };
-
- /**
- * Stops the animation. Normally called by AnimMgr when animation completes.
- * @method stop
- * @param {Boolean} finish (optional) If true, animation will jump to final frame.
- */
- this.stop = function(finish) {
- if (finish) {
- this.currentFrame = this.totalFrames;
- this._onTween.fire();
- }
- YAHOO.util.AnimMgr.stop(this);
- };
-
- var onStart = function() {
- this.onStart.fire();
-
- this.runtimeAttributes = {};
- for (var attr in this.attributes) {
- this.setRuntimeAttribute(attr);
- }
-
- isAnimated = true;
- actualFrames = 0;
- startTime = new Date();
- };
-
- /**
- * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s).
- * @private
- */
-
- var onTween = function() {
- var data = {
- duration: new Date() - this.getStartTime(),
- currentFrame: this.currentFrame
- };
-
- data.toString = function() {
- return (
- 'duration: ' + data.duration +
- ', currentFrame: ' + data.currentFrame
- );
- };
-
- this.onTween.fire(data);
-
- var runtimeAttributes = this.runtimeAttributes;
-
- for (var attr in runtimeAttributes) {
- this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
- }
-
- actualFrames += 1;
- };
-
- var onComplete = function() {
- var actual_duration = (new Date() - startTime) / 1000 ;
-
- var data = {
- duration: actual_duration,
- frames: actualFrames,
- fps: actualFrames / actual_duration
- };
-
- data.toString = function() {
- return (
- 'duration: ' + data.duration +
- ', frames: ' + data.frames +
- ', fps: ' + data.fps
- );
- };
-
- isAnimated = false;
- actualFrames = 0;
- this.onComplete.fire(data);
- };
-
- /**
- * Custom event that fires after onStart, useful in subclassing
- * @private
- */
- this._onStart = new YAHOO.util.CustomEvent('_start', this, true);
-
- /**
- * Custom event that fires when animation begins
- * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction)
- * @event onStart
- */
- this.onStart = new YAHOO.util.CustomEvent('start', this);
-
- /**
- * Custom event that fires between each frame
- * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction)
- * @event onTween
- */
- this.onTween = new YAHOO.util.CustomEvent('tween', this);
-
- /**
- * Custom event that fires after onTween
- * @private
- */
- this._onTween = new YAHOO.util.CustomEvent('_tween', this, true);
-
- /**
- * Custom event that fires when animation ends
- * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction)
- * @event onComplete
- */
- this.onComplete = new YAHOO.util.CustomEvent('complete', this);
- /**
- * Custom event that fires after onComplete
- * @private
- */
- this._onComplete = new YAHOO.util.CustomEvent('_complete', this, true);
-
- this._onStart.subscribe(onStart);
- this._onTween.subscribe(onTween);
- this._onComplete.subscribe(onComplete);
- }
-};
-
-/**
- * Handles animation queueing and threading.
- * Used by Anim and subclasses.
- * @class AnimMgr
- * @namespace YAHOO.util
- */
-YAHOO.util.AnimMgr = new function() {
- /**
- * Reference to the animation Interval.
- * @property thread
- * @private
- * @type Int
- */
- var thread = null;
-
- /**
- * The current queue of registered animation objects.
- * @property queue
- * @private
- * @type Array
- */
- var queue = [];
-
- /**
- * The number of active animations.
- * @property tweenCount
- * @private
- * @type Int
- */
- var tweenCount = 0;
-
- /**
- * Base frame rate (frames per second).
- * Arbitrarily high for better x-browser calibration (slower browsers drop more frames).
- * @property fps
- * @type Int
- *
- */
- this.fps = 200;
-
- /**
- * Interval delay in milliseconds, defaults to fastest possible.
- * @property delay
- * @type Int
- *
- */
- this.delay = 1;
-
- /**
- * Adds an animation instance to the animation queue.
- * All animation instances must be registered in order to animate.
- * @method registerElement
- * @param {object} tween The Anim instance to be be registered
- */
- this.registerElement = function(tween) {
- queue[queue.length] = tween;
- tweenCount += 1;
- tween._onStart.fire();
- this.start();
- };
-
- /**
- * removes an animation instance from the animation queue.
- * All animation instances must be registered in order to animate.
- * @method unRegister
- * @param {object} tween The Anim instance to be be registered
- * @param {Int} index The index of the Anim instance
- * @private
- */
- this.unRegister = function(tween, index) {
- tween._onComplete.fire();
- index = index || getIndex(tween);
- if (index != -1) { queue.splice(index, 1); }
-
- tweenCount -= 1;
- if (tweenCount <= 0) { this.stop(); }
- };
-
- /**
- * Starts the animation thread.
- * Only one thread can run at a time.
- * @method start
- */
- this.start = function() {
- if (thread === null) { thread = setInterval(this.run, this.delay); }
- };
-
- /**
- * Stops the animation thread or a specific animation instance.
- * @method stop
- * @param {object} tween A specific Anim instance to stop (optional)
- * If no instance given, Manager stops thread and all animations.
- */
- this.stop = function(tween) {
- if (!tween) {
- clearInterval(thread);
- for (var i = 0, len = queue.length; i < len; ++i) {
- if (queue[i].isAnimated()) {
- this.unRegister(tween, i);
- }
- }
- queue = [];
- thread = null;
- tweenCount = 0;
- }
- else {
- this.unRegister(tween);
- }
- };
-
- /**
- * Called per Interval to handle each animation frame.
- * @method run
- */
- this.run = function() {
- for (var i = 0, len = queue.length; i < len; ++i) {
- var tween = queue[i];
- if ( !tween || !tween.isAnimated() ) { continue; }
-
- if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
- {
- tween.currentFrame += 1;
-
- if (tween.useSeconds) {
- correctFrame(tween);
- }
- tween._onTween.fire();
- }
- else { YAHOO.util.AnimMgr.stop(tween, i); }
- }
- };
-
- var getIndex = function(anim) {
- for (var i = 0, len = queue.length; i < len; ++i) {
- if (queue[i] == anim) {
- return i; // note return;
- }
- }
- return -1;
- };
-
- /**
- * On the fly frame correction to keep animation on time.
- * @method correctFrame
- * @private
- * @param {Object} tween The Anim instance being corrected.
- */
- var correctFrame = function(tween) {
- var frames = tween.totalFrames;
- var frame = tween.currentFrame;
- var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
- var elapsed = (new Date() - tween.getStartTime());
- var tweak = 0;
-
- if (elapsed < tween.duration * 1000) { // check if falling behind
- tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
- } else { // went over duration, so jump to end
- tweak = frames - (frame + 1);
- }
- if (tweak > 0 && isFinite(tweak)) { // adjust if needed
- if (tween.currentFrame + tweak >= frames) {// dont go past last frame
- tweak = frames - (frame + 1);
- }
-
- tween.currentFrame += tweak;
- }
- };
-};
-/**
- * Used to calculate Bezier splines for any number of control points.
- * @class Bezier
- * @namespace YAHOO.util
- *
- */
-YAHOO.util.Bezier = new function()
-{
- /**
- * Get the current position of the animated element based on t.
- * Each point is an array of "x" and "y" values (0 = x, 1 = y)
- * At least 2 points are required (start and end).
- * First point is start. Last point is end.
- * Additional control points are optional.
- * @method getPosition
- * @param {Array} points An array containing Bezier points
- * @param {Number} t A number between 0 and 1 which is the basis for determining current position
- * @return {Array} An array containing int x and y member data
- */
- this.getPosition = function(points, t)
- {
- var n = points.length;
- var tmp = [];
-
- for (var i = 0; i < n; ++i){
- tmp[i] = [points[i][0], points[i][1]]; // save input
- }
-
- for (var j = 1; j < n; ++j) {
- for (i = 0; i < n - j; ++i) {
- tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
- tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
- }
- }
-
- return [ tmp[0][0], tmp[0][1] ];
-
- };
-};
-(function() {
-/**
- * Anim subclass for color transitions.
- * Usage: var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);
Color values can be specified with either 112233, #112233,
- * [255,255,255], or rgb(255,255,255)
- * @class ColorAnim
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @constructor
- * @extends YAHOO.util.Anim
- * @param {HTMLElement | String} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- YAHOO.util.ColorAnim = function(el, attributes, duration, method) {
- YAHOO.util.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
- };
-
- YAHOO.extend(YAHOO.util.ColorAnim, YAHOO.util.Anim);
-
- // shorthand
- var Y = YAHOO.util;
- var superclass = Y.ColorAnim.superclass;
- var proto = Y.ColorAnim.prototype;
-
- proto.toString = function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("ColorAnim " + id);
- };
-
- proto.patterns.color = /color$/i;
- proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
- proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
- proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
- proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/; // need rgba for safari
-
- /**
- * Attempts to parse the given string and return a 3-tuple.
- * @method parseColor
- * @param {String} s The string to parse.
- * @return {Array} The 3-tuple of rgb values.
- */
- proto.parseColor = function(s) {
- if (s.length == 3) { return s; }
-
- var c = this.patterns.hex.exec(s);
- if (c && c.length == 4) {
- return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
- }
-
- c = this.patterns.rgb.exec(s);
- if (c && c.length == 4) {
- return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
- }
-
- c = this.patterns.hex3.exec(s);
- if (c && c.length == 4) {
- return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
- }
-
- return null;
- };
-
- proto.getAttribute = function(attr) {
- var el = this.getEl();
- if ( this.patterns.color.test(attr) ) {
- var val = YAHOO.util.Dom.getStyle(el, attr);
-
- if (this.patterns.transparent.test(val)) { // bgcolor default
- var parent = el.parentNode; // try and get from an ancestor
- val = Y.Dom.getStyle(parent, attr);
-
- while (parent && this.patterns.transparent.test(val)) {
- parent = parent.parentNode;
- val = Y.Dom.getStyle(parent, attr);
- if (parent.tagName.toUpperCase() == 'HTML') {
- val = '#fff';
- }
- }
- }
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
-
- return val;
- };
-
- proto.doMethod = function(attr, start, end) {
- var val;
-
- if ( this.patterns.color.test(attr) ) {
- val = [];
- for (var i = 0, len = start.length; i < len; ++i) {
- val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
- }
-
- val = 'rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';
- }
- else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
-
- return val;
- };
-
- proto.setRuntimeAttribute = function(attr) {
- superclass.setRuntimeAttribute.call(this, attr);
-
- if ( this.patterns.color.test(attr) ) {
- var attributes = this.attributes;
- var start = this.parseColor(this.runtimeAttributes[attr].start);
- var end = this.parseColor(this.runtimeAttributes[attr].end);
- // fix colors if going "by"
- if ( typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined' ) {
- end = this.parseColor(attributes[attr].by);
-
- for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + end[i];
- }
- }
-
- this.runtimeAttributes[attr].start = start;
- this.runtimeAttributes[attr].end = end;
- }
- };
-})();/*
-TERMS OF USE - EASING EQUATIONS
-Open source under the BSD License.
-Copyright 2001 Robert Penner All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
- * Singleton that determines how an animation proceeds from start to end.
- * @class Easing
- * @namespace YAHOO.util
-*/
-
-YAHOO.util.Easing = {
-
- /**
- * Uniform speed between points.
- * @method easeNone
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeNone: function (t, b, c, d) {
- return c*t/d + b;
- },
-
- /**
- * Begins slowly and accelerates towards end. (quadratic)
- * @method easeIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeIn: function (t, b, c, d) {
- return c*(t/=d)*t + b;
- },
-
- /**
- * Begins quickly and decelerates towards end. (quadratic)
- * @method easeOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeOut: function (t, b, c, d) {
- return -c *(t/=d)*(t-2) + b;
- },
-
- /**
- * Begins slowly and decelerates towards end. (quadratic)
- * @method easeBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeBoth: function (t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t + b;
- return -c/2 * ((--t)*(t-2) - 1) + b;
- },
-
- /**
- * Begins slowly and accelerates towards end. (quartic)
- * @method easeInStrong
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeInStrong: function (t, b, c, d) {
- return c*(t/=d)*t*t*t + b;
- },
-
- /**
- * Begins quickly and decelerates towards end. (quartic)
- * @method easeOutStrong
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeOutStrong: function (t, b, c, d) {
- return -c * ((t=t/d-1)*t*t*t - 1) + b;
- },
-
- /**
- * Begins slowly and decelerates towards end. (quartic)
- * @method easeBothStrong
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeBothStrong: function (t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
- return -c/2 * ((t-=2)*t*t*t - 2) + b;
- },
-
- /**
- * Snap in elastic effect.
- * @method elasticIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} p Period (optional)
- * @return {Number} The computed value for the current animation frame
- */
-
- elasticIn: function (t, b, c, d, a, p) {
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- },
-
- /**
- * Snap out elastic effect.
- * @method elasticOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} p Period (optional)
- * @return {Number} The computed value for the current animation frame
- */
- elasticOut: function (t, b, c, d, a, p) {
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
- },
-
- /**
- * Snap both elastic effect.
- * @method elasticBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} p Period (optional)
- * @return {Number} The computed value for the current animation frame
- */
- elasticBoth: function (t, b, c, d, a, p) {
- if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
- if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
- },
-
-
- /**
- * Backtracks slightly, then reverses direction and moves to end.
- * @method backIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} s Overshoot (optional)
- * @return {Number} The computed value for the current animation frame
- */
- backIn: function (t, b, c, d, s) {
- if (typeof s == 'undefined') s = 1.70158;
- return c*(t/=d)*t*((s+1)*t - s) + b;
- },
-
- /**
- * Overshoots end, then reverses and comes back to end.
- * @method backOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} s Overshoot (optional)
- * @return {Number} The computed value for the current animation frame
- */
- backOut: function (t, b, c, d, s) {
- if (typeof s == 'undefined') s = 1.70158;
- return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
- },
-
- /**
- * Backtracks slightly, then reverses direction, overshoots end,
- * then reverses and comes back to end.
- * @method backBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} s Overshoot (optional)
- * @return {Number} The computed value for the current animation frame
- */
- backBoth: function (t, b, c, d, s) {
- if (typeof s == 'undefined') s = 1.70158;
- if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
- return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
- },
-
- /**
- * Bounce off of start.
- * @method bounceIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- bounceIn: function (t, b, c, d) {
- return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b;
- },
-
- /**
- * Bounces off end.
- * @method bounceOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- bounceOut: function (t, b, c, d) {
- if ((t/=d) < (1/2.75)) {
- return c*(7.5625*t*t) + b;
- } else if (t < (2/2.75)) {
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
- } else if (t < (2.5/2.75)) {
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
- } else {
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
- }
- },
-
- /**
- * Bounces off start and end.
- * @method bounceBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- bounceBoth: function (t, b, c, d) {
- if (t < d/2) return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b;
- return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
- }
-};
-
-(function() {
-/**
- * Anim subclass for moving elements along a path defined by the "points"
- * member of "attributes". All "points" are arrays with x, y coordinates.
- * Usage: var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);
- * @class Motion
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @constructor
- * @extends YAHOO.util.Anim
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- YAHOO.util.Motion = function(el, attributes, duration, method) {
- if (el) { // dont break existing subclasses not using YAHOO.extend
- YAHOO.util.Motion.superclass.constructor.call(this, el, attributes, duration, method);
- }
- };
-
- YAHOO.extend(YAHOO.util.Motion, YAHOO.util.ColorAnim);
-
- // shorthand
- var Y = YAHOO.util;
- var superclass = Y.Motion.superclass;
- var proto = Y.Motion.prototype;
-
- proto.toString = function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("Motion " + id);
- };
-
- proto.patterns.points = /^points$/i;
-
- proto.setAttribute = function(attr, val, unit) {
- if ( this.patterns.points.test(attr) ) {
- unit = unit || 'px';
- superclass.setAttribute.call(this, 'left', val[0], unit);
- superclass.setAttribute.call(this, 'top', val[1], unit);
- } else {
- superclass.setAttribute.call(this, attr, val, unit);
- }
- };
-
- proto.getAttribute = function(attr) {
- if ( this.patterns.points.test(attr) ) {
- var val = [
- superclass.getAttribute.call(this, 'left'),
- superclass.getAttribute.call(this, 'top')
- ];
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
-
- return val;
- };
-
- proto.doMethod = function(attr, start, end) {
- var val = null;
-
- if ( this.patterns.points.test(attr) ) {
- var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
- val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
- } else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
- return val;
- };
-
- proto.setRuntimeAttribute = function(attr) {
- if ( this.patterns.points.test(attr) ) {
- var el = this.getEl();
- var attributes = this.attributes;
- var start;
- var control = attributes['points']['control'] || [];
- var end;
- var i, len;
-
- if (control.length > 0 && !(control[0] instanceof Array) ) { // could be single point or array of points
- control = [control];
- } else { // break reference to attributes.points.control
- var tmp = [];
- for (i = 0, len = control.length; i< len; ++i) {
- tmp[i] = control[i];
- }
- control = tmp;
- }
-
- if (Y.Dom.getStyle(el, 'position') == 'static') { // default to relative
- Y.Dom.setStyle(el, 'position', 'relative');
- }
-
- if ( isset(attributes['points']['from']) ) {
- Y.Dom.setXY(el, attributes['points']['from']); // set position to from point
- }
- else { Y.Dom.setXY( el, Y.Dom.getXY(el) ); } // set it to current position
-
- start = this.getAttribute('points'); // get actual top & left
-
- // TO beats BY, per SMIL 2.1 spec
- if ( isset(attributes['points']['to']) ) {
- end = translateValues.call(this, attributes['points']['to'], start);
-
- var pageXY = Y.Dom.getXY(this.getEl());
- for (i = 0, len = control.length; i < len; ++i) {
- control[i] = translateValues.call(this, control[i], start);
- }
-
-
- } else if ( isset(attributes['points']['by']) ) {
- end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
-
- for (i = 0, len = control.length; i < len; ++i) {
- control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
- }
- }
-
- this.runtimeAttributes[attr] = [start];
-
- if (control.length > 0) {
- this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
- }
-
- this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
- }
- else {
- superclass.setRuntimeAttribute.call(this, attr);
- }
- };
-
- var translateValues = function(val, start) {
- var pageXY = Y.Dom.getXY(this.getEl());
- val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
-
- return val;
- };
-
- var isset = function(prop) {
- return (typeof prop !== 'undefined');
- };
-})();
-(function() {
-/**
- * Anim subclass for scrolling elements to a position defined by the "scroll"
- * member of "attributes". All "scroll" members are arrays with x, y scroll positions.
- * Usage: var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);
- * @class Scroll
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @extends YAHOO.util.Anim
- * @constructor
- * @param {String or HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- YAHOO.util.Scroll = function(el, attributes, duration, method) {
- if (el) { // dont break existing subclasses not using YAHOO.extend
- YAHOO.util.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
- }
- };
-
- YAHOO.extend(YAHOO.util.Scroll, YAHOO.util.ColorAnim);
-
- // shorthand
- var Y = YAHOO.util;
- var superclass = Y.Scroll.superclass;
- var proto = Y.Scroll.prototype;
-
- proto.toString = function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("Scroll " + id);
- };
-
- proto.doMethod = function(attr, start, end) {
- var val = null;
-
- if (attr == 'scroll') {
- val = [
- this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
- this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
- ];
-
- } else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
- return val;
- };
-
- proto.getAttribute = function(attr) {
- var val = null;
- var el = this.getEl();
-
- if (attr == 'scroll') {
- val = [ el.scrollLeft, el.scrollTop ];
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
-
- return val;
- };
-
- proto.setAttribute = function(attr, val, unit) {
- var el = this.getEl();
-
- if (attr == 'scroll') {
- el.scrollLeft = val[0];
- el.scrollTop = val[1];
- } else {
- superclass.setAttribute.call(this, attr, val, unit);
- }
- };
-})();
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/**
+ * The animation module provides allows effects to be added to HTMLElements.
+ * @module animation
+ * @requires yahoo, event, dom
+ */
+
+/**
+ *
+ * Base animation class that provides the interface for building animated effects.
+ * Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);
+ * @class Anim
+ * @namespace YAHOO.util
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @param {String | HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+
+YAHOO.util.Anim = function(el, attributes, duration, method) {
+ if (el) {
+ this.init(el, attributes, duration, method);
+ }
+};
+
+YAHOO.util.Anim.prototype = {
+ /**
+ * Provides a readable name for the Anim instance.
+ * @method toString
+ * @return {String}
+ */
+ toString: function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Anim " + id);
+ },
+
+ patterns: { // cached for performance
+ noNegatives: /width|height|opacity|padding/i, // keep at zero or above
+ offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default
+ defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default
+ offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset
+ },
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @method doMethod
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ doMethod: function(attr, start, end) {
+ return this.method(this.currentFrame, start, end - start, this.totalFrames);
+ },
+
+ /**
+ * Applies a value to an attribute.
+ * @method setAttribute
+ * @param {String} attr The name of the attribute.
+ * @param {Number} val The value to be applied to the attribute.
+ * @param {String} unit The unit ('px', '%', etc.) of the value.
+ */
+ setAttribute: function(attr, val, unit) {
+ if ( this.patterns.noNegatives.test(attr) ) {
+ val = (val > 0) ? val : 0;
+ }
+
+ YAHOO.util.Dom.setStyle(this.getEl(), attr, val + unit);
+ },
+
+ /**
+ * Returns current value of the attribute.
+ * @method getAttribute
+ * @param {String} attr The name of the attribute.
+ * @return {Number} val The current value of the attribute.
+ */
+ getAttribute: function(attr) {
+ var el = this.getEl();
+ var val = YAHOO.util.Dom.getStyle(el, attr);
+
+ if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
+ return parseFloat(val);
+ }
+
+ var a = this.patterns.offsetAttribute.exec(attr) || [];
+ var pos = !!( a[3] ); // top or left
+ var box = !!( a[2] ); // width or height
+
+ // use offsets for width/height and abs pos top/left
+ if ( box || (YAHOO.util.Dom.getStyle(el, 'position') == 'absolute' && pos) ) {
+ val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
+ } else { // default to zero for other 'auto'
+ val = 0;
+ }
+
+ return val;
+ },
+
+ /**
+ * Returns the unit to use when none is supplied.
+ * @method getDefaultUnit
+ * @param {attr} attr The name of the attribute.
+ * @return {String} The default unit to be used.
+ */
+ getDefaultUnit: function(attr) {
+ if ( this.patterns.defaultUnit.test(attr) ) {
+ return 'px';
+ }
+
+ return '';
+ },
+
+ /**
+ * Sets the actual values to be used during the animation. Should only be needed for subclass use.
+ * @method setRuntimeAttribute
+ * @param {Object} attr The attribute object
+ * @private
+ */
+ setRuntimeAttribute: function(attr) {
+ var start;
+ var end;
+ var attributes = this.attributes;
+
+ this.runtimeAttributes[attr] = {};
+
+ var isset = function(prop) {
+ return (typeof prop !== 'undefined');
+ };
+
+ if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) {
+ return false; // note return; nothing to animate to
+ }
+
+ start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
+
+ // To beats by, per SMIL 2.1 spec
+ if ( isset(attributes[attr]['to']) ) {
+ end = attributes[attr]['to'];
+ } else if ( isset(attributes[attr]['by']) ) {
+ if (start.constructor == Array) {
+ end = [];
+ for (var i = 0, len = start.length; i < len; ++i) {
+ end[i] = start[i] + attributes[attr]['by'][i];
+ }
+ } else {
+ end = start + attributes[attr]['by'];
+ }
+ }
+
+ this.runtimeAttributes[attr].start = start;
+ this.runtimeAttributes[attr].end = end;
+
+ // set units if needed
+ this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
+ },
+
+ /**
+ * Constructor for Anim instance.
+ * @method init
+ * @param {String | HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ init: function(el, attributes, duration, method) {
+ /**
+ * Whether or not the animation is running.
+ * @property isAnimated
+ * @private
+ * @type Boolean
+ */
+ var isAnimated = false;
+
+ /**
+ * A Date object that is created when the animation begins.
+ * @property startTime
+ * @private
+ * @type Date
+ */
+ var startTime = null;
+
+ /**
+ * The number of frames this animation was able to execute.
+ * @property actualFrames
+ * @private
+ * @type Int
+ */
+ var actualFrames = 0;
+
+ /**
+ * The element to be animated.
+ * @property el
+ * @private
+ * @type HTMLElement
+ */
+ el = YAHOO.util.Dom.get(el);
+
+ /**
+ * The collection of attributes to be animated.
+ * Each attribute must have at least a "to" or "by" defined in order to animate.
+ * If "to" is supplied, the animation will end with the attribute at that value.
+ * If "by" is supplied, the animation will end at that value plus its starting value.
+ * If both are supplied, "to" is used, and "by" is ignored.
+ * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values).
+ * @property attributes
+ * @type Object
+ */
+ this.attributes = attributes || {};
+
+ /**
+ * The length of the animation. Defaults to "1" (second).
+ * @property duration
+ * @type Number
+ */
+ this.duration = duration || 1;
+
+ /**
+ * The method that will provide values to the attribute(s) during the animation.
+ * Defaults to "YAHOO.util.Easing.easeNone".
+ * @property method
+ * @type Function
+ */
+ this.method = method || YAHOO.util.Easing.easeNone;
+
+ /**
+ * Whether or not the duration should be treated as seconds.
+ * Defaults to true.
+ * @property useSeconds
+ * @type Boolean
+ */
+ this.useSeconds = true; // default to seconds
+
+ /**
+ * The location of the current animation on the timeline.
+ * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
+ * @property currentFrame
+ * @type Int
+ */
+ this.currentFrame = 0;
+
+ /**
+ * The total number of frames to be executed.
+ * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
+ * @property totalFrames
+ * @type Int
+ */
+ this.totalFrames = YAHOO.util.AnimMgr.fps;
+
+
+ /**
+ * Returns a reference to the animated element.
+ * @method getEl
+ * @return {HTMLElement}
+ */
+ this.getEl = function() { return el; };
+
+ /**
+ * Checks whether the element is currently animated.
+ * @method isAnimated
+ * @return {Boolean} current value of isAnimated.
+ */
+ this.isAnimated = function() {
+ return isAnimated;
+ };
+
+ /**
+ * Returns the animation start time.
+ * @method getStartTime
+ * @return {Date} current value of startTime.
+ */
+ this.getStartTime = function() {
+ return startTime;
+ };
+
+ this.runtimeAttributes = {};
+
+ var logger = {};
+ logger.log = function() {YAHOO.log.apply(window, arguments)};
+
+ logger.log('creating new instance of ' + this);
+
+ /**
+ * Starts the animation by registering it with the animation manager.
+ * @method animate
+ */
+ this.animate = function() {
+ if ( this.isAnimated() ) {
+ return false;
+ }
+
+ this.currentFrame = 0;
+
+ this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration;
+
+ YAHOO.util.AnimMgr.registerElement(this);
+ };
+
+ /**
+ * Stops the animation. Normally called by AnimMgr when animation completes.
+ * @method stop
+ * @param {Boolean} finish (optional) If true, animation will jump to final frame.
+ */
+ this.stop = function(finish) {
+ if (finish) {
+ this.currentFrame = this.totalFrames;
+ this._onTween.fire();
+ }
+ YAHOO.util.AnimMgr.stop(this);
+ };
+
+ var onStart = function() {
+ this.onStart.fire();
+
+ this.runtimeAttributes = {};
+ for (var attr in this.attributes) {
+ this.setRuntimeAttribute(attr);
+ }
+
+ isAnimated = true;
+ actualFrames = 0;
+ startTime = new Date();
+ };
+
+ /**
+ * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s).
+ * @private
+ */
+
+ var onTween = function() {
+ var data = {
+ duration: new Date() - this.getStartTime(),
+ currentFrame: this.currentFrame
+ };
+
+ data.toString = function() {
+ return (
+ 'duration: ' + data.duration +
+ ', currentFrame: ' + data.currentFrame
+ );
+ };
+
+ this.onTween.fire(data);
+
+ var runtimeAttributes = this.runtimeAttributes;
+
+ for (var attr in runtimeAttributes) {
+ this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
+ }
+
+ actualFrames += 1;
+ };
+
+ var onComplete = function() {
+ var actual_duration = (new Date() - startTime) / 1000 ;
+
+ var data = {
+ duration: actual_duration,
+ frames: actualFrames,
+ fps: actualFrames / actual_duration
+ };
+
+ data.toString = function() {
+ return (
+ 'duration: ' + data.duration +
+ ', frames: ' + data.frames +
+ ', fps: ' + data.fps
+ );
+ };
+
+ isAnimated = false;
+ actualFrames = 0;
+ this.onComplete.fire(data);
+ };
+
+ /**
+ * Custom event that fires after onStart, useful in subclassing
+ * @private
+ */
+ this._onStart = new YAHOO.util.CustomEvent('_start', this, true);
+
+ /**
+ * Custom event that fires when animation begins
+ * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction)
+ * @event onStart
+ */
+ this.onStart = new YAHOO.util.CustomEvent('start', this);
+
+ /**
+ * Custom event that fires between each frame
+ * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction)
+ * @event onTween
+ */
+ this.onTween = new YAHOO.util.CustomEvent('tween', this);
+
+ /**
+ * Custom event that fires after onTween
+ * @private
+ */
+ this._onTween = new YAHOO.util.CustomEvent('_tween', this, true);
+
+ /**
+ * Custom event that fires when animation ends
+ * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction)
+ * @event onComplete
+ */
+ this.onComplete = new YAHOO.util.CustomEvent('complete', this);
+ /**
+ * Custom event that fires after onComplete
+ * @private
+ */
+ this._onComplete = new YAHOO.util.CustomEvent('_complete', this, true);
+
+ this._onStart.subscribe(onStart);
+ this._onTween.subscribe(onTween);
+ this._onComplete.subscribe(onComplete);
+ }
+};
+
+/**
+ * Handles animation queueing and threading.
+ * Used by Anim and subclasses.
+ * @class AnimMgr
+ * @namespace YAHOO.util
+ */
+YAHOO.util.AnimMgr = new function() {
+ /**
+ * Reference to the animation Interval.
+ * @property thread
+ * @private
+ * @type Int
+ */
+ var thread = null;
+
+ /**
+ * The current queue of registered animation objects.
+ * @property queue
+ * @private
+ * @type Array
+ */
+ var queue = [];
+
+ /**
+ * The number of active animations.
+ * @property tweenCount
+ * @private
+ * @type Int
+ */
+ var tweenCount = 0;
+
+ /**
+ * Base frame rate (frames per second).
+ * Arbitrarily high for better x-browser calibration (slower browsers drop more frames).
+ * @property fps
+ * @type Int
+ *
+ */
+ this.fps = 1000;
+
+ /**
+ * Interval delay in milliseconds, defaults to fastest possible.
+ * @property delay
+ * @type Int
+ *
+ */
+ this.delay = 1;
+
+ /**
+ * Adds an animation instance to the animation queue.
+ * All animation instances must be registered in order to animate.
+ * @method registerElement
+ * @param {object} tween The Anim instance to be be registered
+ */
+ this.registerElement = function(tween) {
+ queue[queue.length] = tween;
+ tweenCount += 1;
+ tween._onStart.fire();
+ this.start();
+ };
+
+ /**
+ * removes an animation instance from the animation queue.
+ * All animation instances must be registered in order to animate.
+ * @method unRegister
+ * @param {object} tween The Anim instance to be be registered
+ * @param {Int} index The index of the Anim instance
+ * @private
+ */
+ this.unRegister = function(tween, index) {
+ tween._onComplete.fire();
+ index = index || getIndex(tween);
+ if (index != -1) { queue.splice(index, 1); }
+
+ tweenCount -= 1;
+ if (tweenCount <= 0) { this.stop(); }
+ };
+
+ /**
+ * Starts the animation thread.
+ * Only one thread can run at a time.
+ * @method start
+ */
+ this.start = function() {
+ if (thread === null) { thread = setInterval(this.run, this.delay); }
+ };
+
+ /**
+ * Stops the animation thread or a specific animation instance.
+ * @method stop
+ * @param {object} tween A specific Anim instance to stop (optional)
+ * If no instance given, Manager stops thread and all animations.
+ */
+ this.stop = function(tween) {
+ if (!tween) {
+ clearInterval(thread);
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ if (queue[i].isAnimated()) {
+ this.unRegister(tween, i);
+ }
+ }
+ queue = [];
+ thread = null;
+ tweenCount = 0;
+ }
+ else {
+ this.unRegister(tween);
+ }
+ };
+
+ /**
+ * Called per Interval to handle each animation frame.
+ * @method run
+ */
+ this.run = function() {
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ var tween = queue[i];
+ if ( !tween || !tween.isAnimated() ) { continue; }
+
+ if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
+ {
+ tween.currentFrame += 1;
+
+ if (tween.useSeconds) {
+ correctFrame(tween);
+ }
+ tween._onTween.fire();
+ }
+ else { YAHOO.util.AnimMgr.stop(tween, i); }
+ }
+ };
+
+ var getIndex = function(anim) {
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ if (queue[i] == anim) {
+ return i; // note return;
+ }
+ }
+ return -1;
+ };
+
+ /**
+ * On the fly frame correction to keep animation on time.
+ * @method correctFrame
+ * @private
+ * @param {Object} tween The Anim instance being corrected.
+ */
+ var correctFrame = function(tween) {
+ var frames = tween.totalFrames;
+ var frame = tween.currentFrame;
+ var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
+ var elapsed = (new Date() - tween.getStartTime());
+ var tweak = 0;
+
+ if (elapsed < tween.duration * 1000) { // check if falling behind
+ tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
+ } else { // went over duration, so jump to end
+ tweak = frames - (frame + 1);
+ }
+ if (tweak > 0 && isFinite(tweak)) { // adjust if needed
+ if (tween.currentFrame + tweak >= frames) {// dont go past last frame
+ tweak = frames - (frame + 1);
+ }
+
+ tween.currentFrame += tweak;
+ }
+ };
+};
+/**
+ * Used to calculate Bezier splines for any number of control points.
+ * @class Bezier
+ * @namespace YAHOO.util
+ *
+ */
+YAHOO.util.Bezier = new function() {
+ /**
+ * Get the current position of the animated element based on t.
+ * Each point is an array of "x" and "y" values (0 = x, 1 = y)
+ * At least 2 points are required (start and end).
+ * First point is start. Last point is end.
+ * Additional control points are optional.
+ * @method getPosition
+ * @param {Array} points An array containing Bezier points
+ * @param {Number} t A number between 0 and 1 which is the basis for determining current position
+ * @return {Array} An array containing int x and y member data
+ */
+ this.getPosition = function(points, t) {
+ var n = points.length;
+ var tmp = [];
+
+ for (var i = 0; i < n; ++i){
+ tmp[i] = [points[i][0], points[i][1]]; // save input
+ }
+
+ for (var j = 1; j < n; ++j) {
+ for (i = 0; i < n - j; ++i) {
+ tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
+ tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
+ }
+ }
+
+ return [ tmp[0][0], tmp[0][1] ];
+
+ };
+};
+(function() {
+/**
+ * Anim subclass for color transitions.
+ * Usage: var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);
Color values can be specified with either 112233, #112233,
+ * [255,255,255], or rgb(255,255,255)
+ * @class ColorAnim
+ * @namespace YAHOO.util
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @constructor
+ * @extends YAHOO.util.Anim
+ * @param {HTMLElement | String} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ YAHOO.util.ColorAnim = function(el, attributes, duration, method) {
+ YAHOO.util.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
+ };
+
+ YAHOO.extend(YAHOO.util.ColorAnim, YAHOO.util.Anim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.ColorAnim.superclass;
+ var proto = Y.ColorAnim.prototype;
+
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("ColorAnim " + id);
+ };
+
+ proto.patterns.color = /color$/i;
+ proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
+ proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
+ proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
+ proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/; // need rgba for safari
+
+ /**
+ * Attempts to parse the given string and return a 3-tuple.
+ * @method parseColor
+ * @param {String} s The string to parse.
+ * @return {Array} The 3-tuple of rgb values.
+ */
+ proto.parseColor = function(s) {
+ if (s.length == 3) { return s; }
+
+ var c = this.patterns.hex.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
+ }
+
+ c = this.patterns.rgb.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
+ }
+
+ c = this.patterns.hex3.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
+ }
+
+ return null;
+ };
+
+ proto.getAttribute = function(attr) {
+ var el = this.getEl();
+ if ( this.patterns.color.test(attr) ) {
+ var val = YAHOO.util.Dom.getStyle(el, attr);
+
+ if (this.patterns.transparent.test(val)) { // bgcolor default
+ var parent = el.parentNode; // try and get from an ancestor
+ val = Y.Dom.getStyle(parent, attr);
+
+ while (parent && this.patterns.transparent.test(val)) {
+ parent = parent.parentNode;
+ val = Y.Dom.getStyle(parent, attr);
+ if (parent.tagName.toUpperCase() == 'HTML') {
+ val = '#fff';
+ }
+ }
+ }
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ proto.doMethod = function(attr, start, end) {
+ var val;
+
+ if ( this.patterns.color.test(attr) ) {
+ val = [];
+ for (var i = 0, len = start.length; i < len; ++i) {
+ val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
+ }
+
+ val = 'rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';
+ }
+ else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+
+ return val;
+ };
+
+ proto.setRuntimeAttribute = function(attr) {
+ superclass.setRuntimeAttribute.call(this, attr);
+
+ if ( this.patterns.color.test(attr) ) {
+ var attributes = this.attributes;
+ var start = this.parseColor(this.runtimeAttributes[attr].start);
+ var end = this.parseColor(this.runtimeAttributes[attr].end);
+ // fix colors if going "by"
+ if ( typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined' ) {
+ end = this.parseColor(attributes[attr].by);
+
+ for (var i = 0, len = start.length; i < len; ++i) {
+ end[i] = start[i] + end[i];
+ }
+ }
+
+ this.runtimeAttributes[attr].start = start;
+ this.runtimeAttributes[attr].end = end;
+ }
+ };
+})();/*
+TERMS OF USE - EASING EQUATIONS
+Open source under the BSD License.
+Copyright 2001 Robert Penner All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * Singleton that determines how an animation proceeds from start to end.
+ * @class Easing
+ * @namespace YAHOO.util
+*/
+
+YAHOO.util.Easing = {
+
+ /**
+ * Uniform speed between points.
+ * @method easeNone
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeNone: function (t, b, c, d) {
+ return c*t/d + b;
+ },
+
+ /**
+ * Begins slowly and accelerates towards end. (quadratic)
+ * @method easeIn
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeIn: function (t, b, c, d) {
+ return c*(t/=d)*t + b;
+ },
+
+ /**
+ * Begins quickly and decelerates towards end. (quadratic)
+ * @method easeOut
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeOut: function (t, b, c, d) {
+ return -c *(t/=d)*(t-2) + b;
+ },
+
+ /**
+ * Begins slowly and decelerates towards end. (quadratic)
+ * @method easeBoth
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeBoth: function (t, b, c, d) {
+ if ((t/=d/2) < 1) {
+ return c/2*t*t + b;
+ }
+
+ return -c/2 * ((--t)*(t-2) - 1) + b;
+ },
+
+ /**
+ * Begins slowly and accelerates towards end. (quartic)
+ * @method easeInStrong
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeInStrong: function (t, b, c, d) {
+ return c*(t/=d)*t*t*t + b;
+ },
+
+ /**
+ * Begins quickly and decelerates towards end. (quartic)
+ * @method easeOutStrong
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeOutStrong: function (t, b, c, d) {
+ return -c * ((t=t/d-1)*t*t*t - 1) + b;
+ },
+
+ /**
+ * Begins slowly and decelerates towards end. (quartic)
+ * @method easeBothStrong
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeBothStrong: function (t, b, c, d) {
+ if ((t/=d/2) < 1) {
+ return c/2*t*t*t*t + b;
+ }
+
+ return -c/2 * ((t-=2)*t*t*t - 2) + b;
+ },
+
+ /**
+ * Snap in elastic effect.
+ * @method elasticIn
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} a Amplitude (optional)
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+
+ elasticIn: function (t, b, c, d, a, p) {
+ if (t == 0) {
+ return b;
+ }
+ if ( (t /= d) == 1 ) {
+ return b+c;
+ }
+ if (!p) {
+ p=d*.3;
+ }
+
+ if (!a || a < Math.abs(c)) {
+ a = c;
+ var s = p/4;
+ }
+ else {
+ var s = p/(2*Math.PI) * Math.asin (c/a);
+ }
+
+ return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ },
+
+ /**
+ * Snap out elastic effect.
+ * @method elasticOut
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} a Amplitude (optional)
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ elasticOut: function (t, b, c, d, a, p) {
+ if (t == 0) {
+ return b;
+ }
+ if ( (t /= d) == 1 ) {
+ return b+c;
+ }
+ if (!p) {
+ p=d*.3;
+ }
+
+ if (!a || a < Math.abs(c)) {
+ a = c;
+ var s = p / 4;
+ }
+ else {
+ var s = p/(2*Math.PI) * Math.asin (c/a);
+ }
+
+ return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
+ },
+
+ /**
+ * Snap both elastic effect.
+ * @method elasticBoth
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} a Amplitude (optional)
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ elasticBoth: function (t, b, c, d, a, p) {
+ if (t == 0) {
+ return b;
+ }
+
+ if ( (t /= d/2) == 2 ) {
+ return b+c;
+ }
+
+ if (!p) {
+ p = d*(.3*1.5);
+ }
+
+ if ( !a || a < Math.abs(c) ) {
+ a = c;
+ var s = p/4;
+ }
+ else {
+ var s = p/(2*Math.PI) * Math.asin (c/a);
+ }
+
+ if (t < 1) {
+ return -.5*(a*Math.pow(2,10*(t-=1)) *
+ Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ }
+ return a*Math.pow(2,-10*(t-=1)) *
+ Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
+ },
+
+
+ /**
+ * Backtracks slightly, then reverses direction and moves to end.
+ * @method backIn
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ backIn: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') {
+ s = 1.70158;
+ }
+ return c*(t/=d)*t*((s+1)*t - s) + b;
+ },
+
+ /**
+ * Overshoots end, then reverses and comes back to end.
+ * @method backOut
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ backOut: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') {
+ s = 1.70158;
+ }
+ return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
+ },
+
+ /**
+ * Backtracks slightly, then reverses direction, overshoots end,
+ * then reverses and comes back to end.
+ * @method backBoth
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ backBoth: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') {
+ s = 1.70158;
+ }
+
+ if ((t /= d/2 ) < 1) {
+ return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
+ }
+ return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
+ },
+
+ /**
+ * Bounce off of start.
+ * @method bounceIn
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ bounceIn: function (t, b, c, d) {
+ return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b;
+ },
+
+ /**
+ * Bounces off end.
+ * @method bounceOut
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ bounceOut: function (t, b, c, d) {
+ if ((t/=d) < (1/2.75)) {
+ return c*(7.5625*t*t) + b;
+ } else if (t < (2/2.75)) {
+ return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
+ } else if (t < (2.5/2.75)) {
+ return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
+ }
+ return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
+ },
+
+ /**
+ * Bounces off start and end.
+ * @method bounceBoth
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ bounceBoth: function (t, b, c, d) {
+ if (t < d/2) {
+ return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b;
+ }
+ return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
+ }
+};
+
+(function() {
+/**
+ * Anim subclass for moving elements along a path defined by the "points"
+ * member of "attributes". All "points" are arrays with x, y coordinates.
+ * Usage: var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);
+ * @class Motion
+ * @namespace YAHOO.util
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @extends YAHOO.util.Anim
+ * @param {String | HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ YAHOO.util.Motion = function(el, attributes, duration, method) {
+ if (el) { // dont break existing subclasses not using YAHOO.extend
+ YAHOO.util.Motion.superclass.constructor.call(this, el, attributes, duration, method);
+ }
+ };
+
+ YAHOO.extend(YAHOO.util.Motion, YAHOO.util.ColorAnim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.Motion.superclass;
+ var proto = Y.Motion.prototype;
+
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Motion " + id);
+ };
+
+ proto.patterns.points = /^points$/i;
+
+ proto.setAttribute = function(attr, val, unit) {
+ if ( this.patterns.points.test(attr) ) {
+ unit = unit || 'px';
+ superclass.setAttribute.call(this, 'left', val[0], unit);
+ superclass.setAttribute.call(this, 'top', val[1], unit);
+ } else {
+ superclass.setAttribute.call(this, attr, val, unit);
+ }
+ };
+
+ proto.getAttribute = function(attr) {
+ if ( this.patterns.points.test(attr) ) {
+ var val = [
+ superclass.getAttribute.call(this, 'left'),
+ superclass.getAttribute.call(this, 'top')
+ ];
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ proto.doMethod = function(attr, start, end) {
+ var val = null;
+
+ if ( this.patterns.points.test(attr) ) {
+ var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
+ val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
+ } else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+ return val;
+ };
+
+ proto.setRuntimeAttribute = function(attr) {
+ if ( this.patterns.points.test(attr) ) {
+ var el = this.getEl();
+ var attributes = this.attributes;
+ var start;
+ var control = attributes['points']['control'] || [];
+ var end;
+ var i, len;
+
+ if (control.length > 0 && !(control[0] instanceof Array) ) { // could be single point or array of points
+ control = [control];
+ } else { // break reference to attributes.points.control
+ var tmp = [];
+ for (i = 0, len = control.length; i< len; ++i) {
+ tmp[i] = control[i];
+ }
+ control = tmp;
+ }
+
+ if (Y.Dom.getStyle(el, 'position') == 'static') { // default to relative
+ Y.Dom.setStyle(el, 'position', 'relative');
+ }
+
+ if ( isset(attributes['points']['from']) ) {
+ Y.Dom.setXY(el, attributes['points']['from']); // set position to from point
+ }
+ else { Y.Dom.setXY( el, Y.Dom.getXY(el) ); } // set it to current position
+
+ start = this.getAttribute('points'); // get actual top & left
+
+ // TO beats BY, per SMIL 2.1 spec
+ if ( isset(attributes['points']['to']) ) {
+ end = translateValues.call(this, attributes['points']['to'], start);
+
+ var pageXY = Y.Dom.getXY(this.getEl());
+ for (i = 0, len = control.length; i < len; ++i) {
+ control[i] = translateValues.call(this, control[i], start);
+ }
+
+
+ } else if ( isset(attributes['points']['by']) ) {
+ end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
+
+ for (i = 0, len = control.length; i < len; ++i) {
+ control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
+ }
+ }
+
+ this.runtimeAttributes[attr] = [start];
+
+ if (control.length > 0) {
+ this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
+ }
+
+ this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
+ }
+ else {
+ superclass.setRuntimeAttribute.call(this, attr);
+ }
+ };
+
+ var translateValues = function(val, start) {
+ var pageXY = Y.Dom.getXY(this.getEl());
+ val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
+
+ return val;
+ };
+
+ var isset = function(prop) {
+ return (typeof prop !== 'undefined');
+ };
+})();
+(function() {
+/**
+ * Anim subclass for scrolling elements to a position defined by the "scroll"
+ * member of "attributes". All "scroll" members are arrays with x, y scroll positions.
+ * Usage: var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);
+ * @class Scroll
+ * @namespace YAHOO.util
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @extends YAHOO.util.Anim
+ * @constructor
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ YAHOO.util.Scroll = function(el, attributes, duration, method) {
+ if (el) { // dont break existing subclasses not using YAHOO.extend
+ YAHOO.util.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
+ }
+ };
+
+ YAHOO.extend(YAHOO.util.Scroll, YAHOO.util.ColorAnim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.Scroll.superclass;
+ var proto = Y.Scroll.prototype;
+
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Scroll " + id);
+ };
+
+ proto.doMethod = function(attr, start, end) {
+ var val = null;
+
+ if (attr == 'scroll') {
+ val = [
+ this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
+ this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
+ ];
+
+ } else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+ return val;
+ };
+
+ proto.getAttribute = function(attr) {
+ var val = null;
+ var el = this.getEl();
+
+ if (attr == 'scroll') {
+ val = [ el.scrollLeft, el.scrollTop ];
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ proto.setAttribute = function(attr, val, unit) {
+ var el = this.getEl();
+
+ if (attr == 'scroll') {
+ el.scrollLeft = val[0];
+ el.scrollTop = val[1];
+ } else {
+ superclass.setAttribute.call(this, attr, val, unit);
+ }
+ };
+})();
diff --git a/lib/yui/animation/animation-min.js b/lib/yui/animation/animation-min.js
index 87a42cf079..9e1291f510 100755
--- a/lib/yui/animation/animation-min.js
+++ b/lib/yui/animation/animation-min.js
@@ -1,50 +1,75 @@
-/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.12.1 */
-YAHOO.util.Anim=function(el,attributes,duration,method){if(el){this.init(el,attributes,duration,method);}};YAHOO.util.Anim.prototype={toString:function(){var el=this.getEl();var id=el.id||el.tagName;return("Anim "+id);},patterns:{noNegatives:/width|height|opacity|padding/i,offsetAttribute:/^((width|height)|(top|left))$/,defaultUnit:/width|height|top$|bottom$|left$|right$/i,offsetUnit:/\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i},doMethod:function(attr,start,end){return this.method(this.currentFrame,start,end-start,this.totalFrames);},setAttribute:function(attr,val,unit){if(this.patterns.noNegatives.test(attr)){val=(val>0)?val:0;}
-YAHOO.util.Dom.setStyle(this.getEl(),attr,val+unit);},getAttribute:function(attr){var el=this.getEl();var val=YAHOO.util.Dom.getStyle(el,attr);if(val!=='auto'&&!this.patterns.offsetUnit.test(val)){return parseFloat(val);}
-var a=this.patterns.offsetAttribute.exec(attr)||[];var pos=!!(a[3]);var box=!!(a[2]);if(box||(YAHOO.util.Dom.getStyle(el,'position')=='absolute'&&pos)){val=el['offset'+a[0].charAt(0).toUpperCase()+a[0].substr(1)];}else{val=0;}
-return val;},getDefaultUnit:function(attr){if(this.patterns.defaultUnit.test(attr)){return'px';}
-return'';},setRuntimeAttribute:function(attr){var start;var end;var attributes=this.attributes;this.runtimeAttributes[attr]={};var isset=function(prop){return(typeof prop!=='undefined');};if(!isset(attributes[attr]['to'])&&!isset(attributes[attr]['by'])){return false;}
-start=(isset(attributes[attr]['from']))?attributes[attr]['from']:this.getAttribute(attr);if(isset(attributes[attr]['to'])){end=attributes[attr]['to'];}else if(isset(attributes[attr]['by'])){if(start.constructor==Array){end=[];for(var i=0,len=start.length;i0&&isFinite(tweak)){if(tween.currentFrame+tweak>=frames){tweak=frames-(frame+1);}
-tween.currentFrame+=tweak;}};};YAHOO.util.Bezier=new function()
-{this.getPosition=function(points,t)
-{var n=points.length;var tmp=[];for(var i=0;i0&&!(control[0]instanceof Array)){control=[control];}else{var tmp=[];for(i=0,len=control.length;i0){this.runtimeAttributes[attr]=this.runtimeAttributes[attr].concat(control);}
-this.runtimeAttributes[attr][this.runtimeAttributes[attr].length]=end;}
-else{superclass.setRuntimeAttribute.call(this,attr);}};var translateValues=function(val,start){var pageXY=Y.Dom.getXY(this.getEl());val=[val[0]-pageXY[0]+start[0],val[1]-pageXY[1]+start[1]];return val;};var isset=function(prop){return(typeof prop!=='undefined');};})();(function(){YAHOO.util.Scroll=function(el,attributes,duration,method){if(el){YAHOO.util.Scroll.superclass.constructor.call(this,el,attributes,duration,method);}};YAHOO.extend(YAHOO.util.Scroll,YAHOO.util.ColorAnim);var Y=YAHOO.util;var superclass=Y.Scroll.superclass;var proto=Y.Scroll.prototype;proto.toString=function(){var el=this.getEl();var id=el.id||el.tagName;return("Scroll "+id);};proto.doMethod=function(attr,start,end){var val=null;if(attr=='scroll'){val=[this.method(this.currentFrame,start[0],end[0]-start[0],this.totalFrames),this.method(this.currentFrame,start[1],end[1]-start[1],this.totalFrames)];}else{val=superclass.doMethod.call(this,attr,start,end);}
-return val;};proto.getAttribute=function(attr){var val=null;var el=this.getEl();if(attr=='scroll'){val=[el.scrollLeft,el.scrollTop];}else{val=superclass.getAttribute.call(this,attr);}
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+
+YAHOO.util.Anim=function(el,attributes,duration,method){if(el){this.init(el,attributes,duration,method);}};YAHOO.util.Anim.prototype={toString:function(){var el=this.getEl();var id=el.id||el.tagName;return("Anim "+id);},patterns:{noNegatives:/width|height|opacity|padding/i,offsetAttribute:/^((width|height)|(top|left))$/,defaultUnit:/width|height|top$|bottom$|left$|right$/i,offsetUnit:/\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i},doMethod:function(attr,start,end){return this.method(this.currentFrame,start,end-start,this.totalFrames);},setAttribute:function(attr,val,unit){if(this.patterns.noNegatives.test(attr)){val=(val>0)?val:0;}
+YAHOO.util.Dom.setStyle(this.getEl(),attr,val+unit);},getAttribute:function(attr){var el=this.getEl();var val=YAHOO.util.Dom.getStyle(el,attr);if(val!=='auto'&&!this.patterns.offsetUnit.test(val)){return parseFloat(val);}
+var a=this.patterns.offsetAttribute.exec(attr)||[];var pos=!!(a[3]);var box=!!(a[2]);if(box||(YAHOO.util.Dom.getStyle(el,'position')=='absolute'&&pos)){val=el['offset'+a[0].charAt(0).toUpperCase()+a[0].substr(1)];}else{val=0;}
+return val;},getDefaultUnit:function(attr){if(this.patterns.defaultUnit.test(attr)){return'px';}
+return'';},setRuntimeAttribute:function(attr){var start;var end;var attributes=this.attributes;this.runtimeAttributes[attr]={};var isset=function(prop){return(typeof prop!=='undefined');};if(!isset(attributes[attr]['to'])&&!isset(attributes[attr]['by'])){return false;}
+start=(isset(attributes[attr]['from']))?attributes[attr]['from']:this.getAttribute(attr);if(isset(attributes[attr]['to'])){end=attributes[attr]['to'];}else if(isset(attributes[attr]['by'])){if(start.constructor==Array){end=[];for(var i=0,len=start.length;i0&&isFinite(tweak)){if(tween.currentFrame+tweak>=frames){tweak=frames-(frame+1);}
+tween.currentFrame+=tweak;}};};YAHOO.util.Bezier=new function(){this.getPosition=function(points,t){var n=points.length;var tmp=[];for(var i=0;i0&&!(control[0]instanceof Array)){control=[control];}else{var tmp=[];for(i=0,len=control.length;i0){this.runtimeAttributes[attr]=this.runtimeAttributes[attr].concat(control);}
+this.runtimeAttributes[attr][this.runtimeAttributes[attr].length]=end;}
+else{superclass.setRuntimeAttribute.call(this,attr);}};var translateValues=function(val,start){var pageXY=Y.Dom.getXY(this.getEl());val=[val[0]-pageXY[0]+start[0],val[1]-pageXY[1]+start[1]];return val;};var isset=function(prop){return(typeof prop!=='undefined');};})();(function(){YAHOO.util.Scroll=function(el,attributes,duration,method){if(el){YAHOO.util.Scroll.superclass.constructor.call(this,el,attributes,duration,method);}};YAHOO.extend(YAHOO.util.Scroll,YAHOO.util.ColorAnim);var Y=YAHOO.util;var superclass=Y.Scroll.superclass;var proto=Y.Scroll.prototype;proto.toString=function(){var el=this.getEl();var id=el.id||el.tagName;return("Scroll "+id);};proto.doMethod=function(attr,start,end){var val=null;if(attr=='scroll'){val=[this.method(this.currentFrame,start[0],end[0]-start[0],this.totalFrames),this.method(this.currentFrame,start[1],end[1]-start[1],this.totalFrames)];}else{val=superclass.doMethod.call(this,attr,start,end);}
+return val;};proto.getAttribute=function(attr){var val=null;var el=this.getEl();if(attr=='scroll'){val=[el.scrollLeft,el.scrollTop];}else{val=superclass.getAttribute.call(this,attr);}
return val;};proto.setAttribute=function(attr,val,unit){var el=this.getEl();if(attr=='scroll'){el.scrollLeft=val[0];el.scrollTop=val[1];}else{superclass.setAttribute.call(this,attr,val,unit);}};})();
\ No newline at end of file
diff --git a/lib/yui/animation/animation.js b/lib/yui/animation/animation.js
index 79443906a1..3b34cf4af3 100755
--- a/lib/yui/animation/animation.js
+++ b/lib/yui/animation/animation.js
@@ -1,1272 +1,1341 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 0.12.1
-*/
-
-/**
- * The animation module provides allows effects to be added to HTMLElements.
- * @module animation
- */
-
-/**
- *
- * Base animation class that provides the interface for building animated effects.
- * Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);
- * @class Anim
- * @namespace YAHOO.util
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @constructor
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
-
-YAHOO.util.Anim = function(el, attributes, duration, method) {
- if (el) {
- this.init(el, attributes, duration, method);
- }
-};
-
-YAHOO.util.Anim.prototype = {
- /**
- * Provides a readable name for the Anim instance.
- * @method toString
- * @return {String}
- */
- toString: function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("Anim " + id);
- },
-
- patterns: { // cached for performance
- noNegatives: /width|height|opacity|padding/i, // keep at zero or above
- offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default
- defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default
- offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset
- },
-
- /**
- * Returns the value computed by the animation's "method".
- * @method doMethod
- * @param {String} attr The name of the attribute.
- * @param {Number} start The value this attribute should start from for this animation.
- * @param {Number} end The value this attribute should end at for this animation.
- * @return {Number} The Value to be applied to the attribute.
- */
- doMethod: function(attr, start, end) {
- return this.method(this.currentFrame, start, end - start, this.totalFrames);
- },
-
- /**
- * Applies a value to an attribute.
- * @method setAttribute
- * @param {String} attr The name of the attribute.
- * @param {Number} val The value to be applied to the attribute.
- * @param {String} unit The unit ('px', '%', etc.) of the value.
- */
- setAttribute: function(attr, val, unit) {
- if ( this.patterns.noNegatives.test(attr) ) {
- val = (val > 0) ? val : 0;
- }
-
- YAHOO.util.Dom.setStyle(this.getEl(), attr, val + unit);
- },
-
- /**
- * Returns current value of the attribute.
- * @method getAttribute
- * @param {String} attr The name of the attribute.
- * @return {Number} val The current value of the attribute.
- */
- getAttribute: function(attr) {
- var el = this.getEl();
- var val = YAHOO.util.Dom.getStyle(el, attr);
-
- if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
- return parseFloat(val);
- }
-
- var a = this.patterns.offsetAttribute.exec(attr) || [];
- var pos = !!( a[3] ); // top or left
- var box = !!( a[2] ); // width or height
-
- // use offsets for width/height and abs pos top/left
- if ( box || (YAHOO.util.Dom.getStyle(el, 'position') == 'absolute' && pos) ) {
- val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
- } else { // default to zero for other 'auto'
- val = 0;
- }
-
- return val;
- },
-
- /**
- * Returns the unit to use when none is supplied.
- * @method getDefaultUnit
- * @param {attr} attr The name of the attribute.
- * @return {String} The default unit to be used.
- */
- getDefaultUnit: function(attr) {
- if ( this.patterns.defaultUnit.test(attr) ) {
- return 'px';
- }
-
- return '';
- },
-
- /**
- * Sets the actual values to be used during the animation.
- * @method setRuntimeAttribute
- * Should only be needed for subclass use.
- * @param {Object} attr The attribute object
- * @private
- */
- setRuntimeAttribute: function(attr) {
- var start;
- var end;
- var attributes = this.attributes;
-
- this.runtimeAttributes[attr] = {};
-
- var isset = function(prop) {
- return (typeof prop !== 'undefined');
- };
-
- if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) {
- return false; // note return; nothing to animate to
- }
-
- start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
-
- // To beats by, per SMIL 2.1 spec
- if ( isset(attributes[attr]['to']) ) {
- end = attributes[attr]['to'];
- } else if ( isset(attributes[attr]['by']) ) {
- if (start.constructor == Array) {
- end = [];
- for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + attributes[attr]['by'][i];
- }
- } else {
- end = start + attributes[attr]['by'];
- }
- }
-
- this.runtimeAttributes[attr].start = start;
- this.runtimeAttributes[attr].end = end;
-
- // set units if needed
- this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
- },
-
- /**
- * Constructor for Anim instance.
- * @method init
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- init: function(el, attributes, duration, method) {
- /**
- * Whether or not the animation is running.
- * @property isAnimated
- * @private
- * @type Boolean
- */
- var isAnimated = false;
-
- /**
- * A Date object that is created when the animation begins.
- * @property startTime
- * @private
- * @type Date
- */
- var startTime = null;
-
- /**
- * The number of frames this animation was able to execute.
- * @property actualFrames
- * @private
- * @type Int
- */
- var actualFrames = 0;
-
- /**
- * The element to be animated.
- * @property el
- * @private
- * @type HTMLElement
- */
- el = YAHOO.util.Dom.get(el);
-
- /**
- * The collection of attributes to be animated.
- * Each attribute must have at least a "to" or "by" defined in order to animate.
- * If "to" is supplied, the animation will end with the attribute at that value.
- * If "by" is supplied, the animation will end at that value plus its starting value.
- * If both are supplied, "to" is used, and "by" is ignored.
- * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values).
- * @property attributes
- * @type Object
- */
- this.attributes = attributes || {};
-
- /**
- * The length of the animation. Defaults to "1" (second).
- * @property duration
- * @type Number
- */
- this.duration = duration || 1;
-
- /**
- * The method that will provide values to the attribute(s) during the animation.
- * Defaults to "YAHOO.util.Easing.easeNone".
- * @property method
- * @type Function
- */
- this.method = method || YAHOO.util.Easing.easeNone;
-
- /**
- * Whether or not the duration should be treated as seconds.
- * Defaults to true.
- * @property useSeconds
- * @type Boolean
- */
- this.useSeconds = true; // default to seconds
-
- /**
- * The location of the current animation on the timeline.
- * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
- * @property currentFrame
- * @type Int
- */
- this.currentFrame = 0;
-
- /**
- * The total number of frames to be executed.
- * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
- * @property totalFrames
- * @type Int
- */
- this.totalFrames = YAHOO.util.AnimMgr.fps;
-
-
- /**
- * Returns a reference to the animated element.
- * @method getEl
- * @return {HTMLElement}
- */
- this.getEl = function() { return el; };
-
- /**
- * Checks whether the element is currently animated.
- * @method isAnimated
- * @return {Boolean} current value of isAnimated.
- */
- this.isAnimated = function() {
- return isAnimated;
- };
-
- /**
- * Returns the animation start time.
- * @method getStartTime
- * @return {Date} current value of startTime.
- */
- this.getStartTime = function() {
- return startTime;
- };
-
- this.runtimeAttributes = {};
-
-
-
- /**
- * Starts the animation by registering it with the animation manager.
- * @method animate
- */
- this.animate = function() {
- if ( this.isAnimated() ) { return false; }
-
- this.currentFrame = 0;
-
- this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration;
-
- YAHOO.util.AnimMgr.registerElement(this);
- };
-
- /**
- * Stops the animation. Normally called by AnimMgr when animation completes.
- * @method stop
- * @param {Boolean} finish (optional) If true, animation will jump to final frame.
- */
- this.stop = function(finish) {
- if (finish) {
- this.currentFrame = this.totalFrames;
- this._onTween.fire();
- }
- YAHOO.util.AnimMgr.stop(this);
- };
-
- var onStart = function() {
- this.onStart.fire();
-
- this.runtimeAttributes = {};
- for (var attr in this.attributes) {
- this.setRuntimeAttribute(attr);
- }
-
- isAnimated = true;
- actualFrames = 0;
- startTime = new Date();
- };
-
- /**
- * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s).
- * @private
- */
-
- var onTween = function() {
- var data = {
- duration: new Date() - this.getStartTime(),
- currentFrame: this.currentFrame
- };
-
- data.toString = function() {
- return (
- 'duration: ' + data.duration +
- ', currentFrame: ' + data.currentFrame
- );
- };
-
- this.onTween.fire(data);
-
- var runtimeAttributes = this.runtimeAttributes;
-
- for (var attr in runtimeAttributes) {
- this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
- }
-
- actualFrames += 1;
- };
-
- var onComplete = function() {
- var actual_duration = (new Date() - startTime) / 1000 ;
-
- var data = {
- duration: actual_duration,
- frames: actualFrames,
- fps: actualFrames / actual_duration
- };
-
- data.toString = function() {
- return (
- 'duration: ' + data.duration +
- ', frames: ' + data.frames +
- ', fps: ' + data.fps
- );
- };
-
- isAnimated = false;
- actualFrames = 0;
- this.onComplete.fire(data);
- };
-
- /**
- * Custom event that fires after onStart, useful in subclassing
- * @private
- */
- this._onStart = new YAHOO.util.CustomEvent('_start', this, true);
-
- /**
- * Custom event that fires when animation begins
- * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction)
- * @event onStart
- */
- this.onStart = new YAHOO.util.CustomEvent('start', this);
-
- /**
- * Custom event that fires between each frame
- * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction)
- * @event onTween
- */
- this.onTween = new YAHOO.util.CustomEvent('tween', this);
-
- /**
- * Custom event that fires after onTween
- * @private
- */
- this._onTween = new YAHOO.util.CustomEvent('_tween', this, true);
-
- /**
- * Custom event that fires when animation ends
- * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction)
- * @event onComplete
- */
- this.onComplete = new YAHOO.util.CustomEvent('complete', this);
- /**
- * Custom event that fires after onComplete
- * @private
- */
- this._onComplete = new YAHOO.util.CustomEvent('_complete', this, true);
-
- this._onStart.subscribe(onStart);
- this._onTween.subscribe(onTween);
- this._onComplete.subscribe(onComplete);
- }
-};
-
-/**
- * Handles animation queueing and threading.
- * Used by Anim and subclasses.
- * @class AnimMgr
- * @namespace YAHOO.util
- */
-YAHOO.util.AnimMgr = new function() {
- /**
- * Reference to the animation Interval.
- * @property thread
- * @private
- * @type Int
- */
- var thread = null;
-
- /**
- * The current queue of registered animation objects.
- * @property queue
- * @private
- * @type Array
- */
- var queue = [];
-
- /**
- * The number of active animations.
- * @property tweenCount
- * @private
- * @type Int
- */
- var tweenCount = 0;
-
- /**
- * Base frame rate (frames per second).
- * Arbitrarily high for better x-browser calibration (slower browsers drop more frames).
- * @property fps
- * @type Int
- *
- */
- this.fps = 200;
-
- /**
- * Interval delay in milliseconds, defaults to fastest possible.
- * @property delay
- * @type Int
- *
- */
- this.delay = 1;
-
- /**
- * Adds an animation instance to the animation queue.
- * All animation instances must be registered in order to animate.
- * @method registerElement
- * @param {object} tween The Anim instance to be be registered
- */
- this.registerElement = function(tween) {
- queue[queue.length] = tween;
- tweenCount += 1;
- tween._onStart.fire();
- this.start();
- };
-
- /**
- * removes an animation instance from the animation queue.
- * All animation instances must be registered in order to animate.
- * @method unRegister
- * @param {object} tween The Anim instance to be be registered
- * @param {Int} index The index of the Anim instance
- * @private
- */
- this.unRegister = function(tween, index) {
- tween._onComplete.fire();
- index = index || getIndex(tween);
- if (index != -1) { queue.splice(index, 1); }
-
- tweenCount -= 1;
- if (tweenCount <= 0) { this.stop(); }
- };
-
- /**
- * Starts the animation thread.
- * Only one thread can run at a time.
- * @method start
- */
- this.start = function() {
- if (thread === null) { thread = setInterval(this.run, this.delay); }
- };
-
- /**
- * Stops the animation thread or a specific animation instance.
- * @method stop
- * @param {object} tween A specific Anim instance to stop (optional)
- * If no instance given, Manager stops thread and all animations.
- */
- this.stop = function(tween) {
- if (!tween) {
- clearInterval(thread);
- for (var i = 0, len = queue.length; i < len; ++i) {
- if (queue[i].isAnimated()) {
- this.unRegister(tween, i);
- }
- }
- queue = [];
- thread = null;
- tweenCount = 0;
- }
- else {
- this.unRegister(tween);
- }
- };
-
- /**
- * Called per Interval to handle each animation frame.
- * @method run
- */
- this.run = function() {
- for (var i = 0, len = queue.length; i < len; ++i) {
- var tween = queue[i];
- if ( !tween || !tween.isAnimated() ) { continue; }
-
- if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
- {
- tween.currentFrame += 1;
-
- if (tween.useSeconds) {
- correctFrame(tween);
- }
- tween._onTween.fire();
- }
- else { YAHOO.util.AnimMgr.stop(tween, i); }
- }
- };
-
- var getIndex = function(anim) {
- for (var i = 0, len = queue.length; i < len; ++i) {
- if (queue[i] == anim) {
- return i; // note return;
- }
- }
- return -1;
- };
-
- /**
- * On the fly frame correction to keep animation on time.
- * @method correctFrame
- * @private
- * @param {Object} tween The Anim instance being corrected.
- */
- var correctFrame = function(tween) {
- var frames = tween.totalFrames;
- var frame = tween.currentFrame;
- var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
- var elapsed = (new Date() - tween.getStartTime());
- var tweak = 0;
-
- if (elapsed < tween.duration * 1000) { // check if falling behind
- tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
- } else { // went over duration, so jump to end
- tweak = frames - (frame + 1);
- }
- if (tweak > 0 && isFinite(tweak)) { // adjust if needed
- if (tween.currentFrame + tweak >= frames) {// dont go past last frame
- tweak = frames - (frame + 1);
- }
-
- tween.currentFrame += tweak;
- }
- };
-};
-/**
- * Used to calculate Bezier splines for any number of control points.
- * @class Bezier
- * @namespace YAHOO.util
- *
- */
-YAHOO.util.Bezier = new function()
-{
- /**
- * Get the current position of the animated element based on t.
- * Each point is an array of "x" and "y" values (0 = x, 1 = y)
- * At least 2 points are required (start and end).
- * First point is start. Last point is end.
- * Additional control points are optional.
- * @method getPosition
- * @param {Array} points An array containing Bezier points
- * @param {Number} t A number between 0 and 1 which is the basis for determining current position
- * @return {Array} An array containing int x and y member data
- */
- this.getPosition = function(points, t)
- {
- var n = points.length;
- var tmp = [];
-
- for (var i = 0; i < n; ++i){
- tmp[i] = [points[i][0], points[i][1]]; // save input
- }
-
- for (var j = 1; j < n; ++j) {
- for (i = 0; i < n - j; ++i) {
- tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
- tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
- }
- }
-
- return [ tmp[0][0], tmp[0][1] ];
-
- };
-};
-(function() {
-/**
- * Anim subclass for color transitions.
- * Usage: var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);
Color values can be specified with either 112233, #112233,
- * [255,255,255], or rgb(255,255,255)
- * @class ColorAnim
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @constructor
- * @extends YAHOO.util.Anim
- * @param {HTMLElement | String} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- YAHOO.util.ColorAnim = function(el, attributes, duration, method) {
- YAHOO.util.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
- };
-
- YAHOO.extend(YAHOO.util.ColorAnim, YAHOO.util.Anim);
-
- // shorthand
- var Y = YAHOO.util;
- var superclass = Y.ColorAnim.superclass;
- var proto = Y.ColorAnim.prototype;
-
- proto.toString = function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("ColorAnim " + id);
- };
-
- proto.patterns.color = /color$/i;
- proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
- proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
- proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
- proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/; // need rgba for safari
-
- /**
- * Attempts to parse the given string and return a 3-tuple.
- * @method parseColor
- * @param {String} s The string to parse.
- * @return {Array} The 3-tuple of rgb values.
- */
- proto.parseColor = function(s) {
- if (s.length == 3) { return s; }
-
- var c = this.patterns.hex.exec(s);
- if (c && c.length == 4) {
- return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
- }
-
- c = this.patterns.rgb.exec(s);
- if (c && c.length == 4) {
- return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
- }
-
- c = this.patterns.hex3.exec(s);
- if (c && c.length == 4) {
- return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
- }
-
- return null;
- };
-
- proto.getAttribute = function(attr) {
- var el = this.getEl();
- if ( this.patterns.color.test(attr) ) {
- var val = YAHOO.util.Dom.getStyle(el, attr);
-
- if (this.patterns.transparent.test(val)) { // bgcolor default
- var parent = el.parentNode; // try and get from an ancestor
- val = Y.Dom.getStyle(parent, attr);
-
- while (parent && this.patterns.transparent.test(val)) {
- parent = parent.parentNode;
- val = Y.Dom.getStyle(parent, attr);
- if (parent.tagName.toUpperCase() == 'HTML') {
- val = '#fff';
- }
- }
- }
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
-
- return val;
- };
-
- proto.doMethod = function(attr, start, end) {
- var val;
-
- if ( this.patterns.color.test(attr) ) {
- val = [];
- for (var i = 0, len = start.length; i < len; ++i) {
- val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
- }
-
- val = 'rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';
- }
- else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
-
- return val;
- };
-
- proto.setRuntimeAttribute = function(attr) {
- superclass.setRuntimeAttribute.call(this, attr);
-
- if ( this.patterns.color.test(attr) ) {
- var attributes = this.attributes;
- var start = this.parseColor(this.runtimeAttributes[attr].start);
- var end = this.parseColor(this.runtimeAttributes[attr].end);
- // fix colors if going "by"
- if ( typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined' ) {
- end = this.parseColor(attributes[attr].by);
-
- for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + end[i];
- }
- }
-
- this.runtimeAttributes[attr].start = start;
- this.runtimeAttributes[attr].end = end;
- }
- };
-})();/*
-TERMS OF USE - EASING EQUATIONS
-Open source under the BSD License.
-Copyright 2001 Robert Penner All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
- * Singleton that determines how an animation proceeds from start to end.
- * @class Easing
- * @namespace YAHOO.util
-*/
-
-YAHOO.util.Easing = {
-
- /**
- * Uniform speed between points.
- * @method easeNone
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeNone: function (t, b, c, d) {
- return c*t/d + b;
- },
-
- /**
- * Begins slowly and accelerates towards end. (quadratic)
- * @method easeIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeIn: function (t, b, c, d) {
- return c*(t/=d)*t + b;
- },
-
- /**
- * Begins quickly and decelerates towards end. (quadratic)
- * @method easeOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeOut: function (t, b, c, d) {
- return -c *(t/=d)*(t-2) + b;
- },
-
- /**
- * Begins slowly and decelerates towards end. (quadratic)
- * @method easeBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeBoth: function (t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t + b;
- return -c/2 * ((--t)*(t-2) - 1) + b;
- },
-
- /**
- * Begins slowly and accelerates towards end. (quartic)
- * @method easeInStrong
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeInStrong: function (t, b, c, d) {
- return c*(t/=d)*t*t*t + b;
- },
-
- /**
- * Begins quickly and decelerates towards end. (quartic)
- * @method easeOutStrong
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeOutStrong: function (t, b, c, d) {
- return -c * ((t=t/d-1)*t*t*t - 1) + b;
- },
-
- /**
- * Begins slowly and decelerates towards end. (quartic)
- * @method easeBothStrong
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- easeBothStrong: function (t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
- return -c/2 * ((t-=2)*t*t*t - 2) + b;
- },
-
- /**
- * Snap in elastic effect.
- * @method elasticIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} p Period (optional)
- * @return {Number} The computed value for the current animation frame
- */
-
- elasticIn: function (t, b, c, d, a, p) {
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- },
-
- /**
- * Snap out elastic effect.
- * @method elasticOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} p Period (optional)
- * @return {Number} The computed value for the current animation frame
- */
- elasticOut: function (t, b, c, d, a, p) {
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
- },
-
- /**
- * Snap both elastic effect.
- * @method elasticBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} p Period (optional)
- * @return {Number} The computed value for the current animation frame
- */
- elasticBoth: function (t, b, c, d, a, p) {
- if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
- if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
- },
-
- /**
- * Backtracks slightly, then reverses direction and moves to end.
- * @method backIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} s Overshoot (optional)
- * @return {Number} The computed value for the current animation frame
- */
- backIn: function (t, b, c, d, s) {
- if (typeof s == 'undefined') s = 1.70158;
- return c*(t/=d)*t*((s+1)*t - s) + b;
- },
-
- /**
- * Overshoots end, then reverses and comes back to end.
- * @method backOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} s Overshoot (optional)
- * @return {Number} The computed value for the current animation frame
- */
- backOut: function (t, b, c, d, s) {
- if (typeof s == 'undefined') s = 1.70158;
- return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
- },
-
- /**
- * Backtracks slightly, then reverses direction, overshoots end,
- * then reverses and comes back to end.
- * @method backBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @param {Number} s Overshoot (optional)
- * @return {Number} The computed value for the current animation frame
- */
- backBoth: function (t, b, c, d, s) {
- if (typeof s == 'undefined') s = 1.70158;
- if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
- return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
- },
-
- /**
- * Bounce off of start.
- * @method bounceIn
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- bounceIn: function (t, b, c, d) {
- return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b;
- },
-
- /**
- * Bounces off end.
- * @method bounceOut
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- bounceOut: function (t, b, c, d) {
- if ((t/=d) < (1/2.75)) {
- return c*(7.5625*t*t) + b;
- } else if (t < (2/2.75)) {
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
- } else if (t < (2.5/2.75)) {
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
- } else {
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
- }
- },
-
- /**
- * Bounces off start and end.
- * @method bounceBoth
- * @param {Number} t Time value used to compute current value
- * @param {Number} b Starting value
- * @param {Number} c Delta between start and end values
- * @param {Number} d Total length of animation
- * @return {Number} The computed value for the current animation frame
- */
- bounceBoth: function (t, b, c, d) {
- if (t < d/2) return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b;
- return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
- }
-};
-
-(function() {
-/**
- * Anim subclass for moving elements along a path defined by the "points"
- * member of "attributes". All "points" are arrays with x, y coordinates.
- * Usage: var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);
- * @class Motion
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @constructor
- * @extends YAHOO.util.Anim
- * @param {String | HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- YAHOO.util.Motion = function(el, attributes, duration, method) {
- if (el) { // dont break existing subclasses not using YAHOO.extend
- YAHOO.util.Motion.superclass.constructor.call(this, el, attributes, duration, method);
- }
- };
-
- YAHOO.extend(YAHOO.util.Motion, YAHOO.util.ColorAnim);
-
- // shorthand
- var Y = YAHOO.util;
- var superclass = Y.Motion.superclass;
- var proto = Y.Motion.prototype;
-
- proto.toString = function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("Motion " + id);
- };
-
- proto.patterns.points = /^points$/i;
-
- proto.setAttribute = function(attr, val, unit) {
- if ( this.patterns.points.test(attr) ) {
- unit = unit || 'px';
- superclass.setAttribute.call(this, 'left', val[0], unit);
- superclass.setAttribute.call(this, 'top', val[1], unit);
- } else {
- superclass.setAttribute.call(this, attr, val, unit);
- }
- };
-
- proto.getAttribute = function(attr) {
- if ( this.patterns.points.test(attr) ) {
- var val = [
- superclass.getAttribute.call(this, 'left'),
- superclass.getAttribute.call(this, 'top')
- ];
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
-
- return val;
- };
-
- proto.doMethod = function(attr, start, end) {
- var val = null;
-
- if ( this.patterns.points.test(attr) ) {
- var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
- val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
- } else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
- return val;
- };
-
- proto.setRuntimeAttribute = function(attr) {
- if ( this.patterns.points.test(attr) ) {
- var el = this.getEl();
- var attributes = this.attributes;
- var start;
- var control = attributes['points']['control'] || [];
- var end;
- var i, len;
-
- if (control.length > 0 && !(control[0] instanceof Array) ) { // could be single point or array of points
- control = [control];
- } else { // break reference to attributes.points.control
- var tmp = [];
- for (i = 0, len = control.length; i< len; ++i) {
- tmp[i] = control[i];
- }
- control = tmp;
- }
-
- if (Y.Dom.getStyle(el, 'position') == 'static') { // default to relative
- Y.Dom.setStyle(el, 'position', 'relative');
- }
-
- if ( isset(attributes['points']['from']) ) {
- Y.Dom.setXY(el, attributes['points']['from']); // set position to from point
- }
- else { Y.Dom.setXY( el, Y.Dom.getXY(el) ); } // set it to current position
-
- start = this.getAttribute('points'); // get actual top & left
-
- // TO beats BY, per SMIL 2.1 spec
- if ( isset(attributes['points']['to']) ) {
- end = translateValues.call(this, attributes['points']['to'], start);
-
- var pageXY = Y.Dom.getXY(this.getEl());
- for (i = 0, len = control.length; i < len; ++i) {
- control[i] = translateValues.call(this, control[i], start);
- }
-
-
- } else if ( isset(attributes['points']['by']) ) {
- end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
-
- for (i = 0, len = control.length; i < len; ++i) {
- control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
- }
- }
-
- this.runtimeAttributes[attr] = [start];
-
- if (control.length > 0) {
- this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
- }
-
- this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
- }
- else {
- superclass.setRuntimeAttribute.call(this, attr);
- }
- };
-
- var translateValues = function(val, start) {
- var pageXY = Y.Dom.getXY(this.getEl());
- val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
-
- return val;
- };
-
- var isset = function(prop) {
- return (typeof prop !== 'undefined');
- };
-})();
-(function() {
-/**
- * Anim subclass for scrolling elements to a position defined by the "scroll"
- * member of "attributes". All "scroll" members are arrays with x, y scroll positions.
- * Usage: var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);
- * @class Scroll
- * @namespace YAHOO.util
- * @requires YAHOO.util.Anim
- * @requires YAHOO.util.AnimMgr
- * @requires YAHOO.util.Easing
- * @requires YAHOO.util.Bezier
- * @requires YAHOO.util.Dom
- * @requires YAHOO.util.Event
- * @requires YAHOO.util.CustomEvent
- * @extends YAHOO.util.Anim
- * @constructor
- * @param {String or HTMLElement} el Reference to the element that will be animated
- * @param {Object} attributes The attribute(s) to be animated.
- * Each attribute is an object with at minimum a "to" or "by" member defined.
- * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
- * All attribute names use camelCase.
- * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
- * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
- */
- YAHOO.util.Scroll = function(el, attributes, duration, method) {
- if (el) { // dont break existing subclasses not using YAHOO.extend
- YAHOO.util.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
- }
- };
-
- YAHOO.extend(YAHOO.util.Scroll, YAHOO.util.ColorAnim);
-
- // shorthand
- var Y = YAHOO.util;
- var superclass = Y.Scroll.superclass;
- var proto = Y.Scroll.prototype;
-
- proto.toString = function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("Scroll " + id);
- };
-
- proto.doMethod = function(attr, start, end) {
- var val = null;
-
- if (attr == 'scroll') {
- val = [
- this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
- this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
- ];
-
- } else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
- return val;
- };
-
- proto.getAttribute = function(attr) {
- var val = null;
- var el = this.getEl();
-
- if (attr == 'scroll') {
- val = [ el.scrollLeft, el.scrollTop ];
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
-
- return val;
- };
-
- proto.setAttribute = function(attr, val, unit) {
- var el = this.getEl();
-
- if (attr == 'scroll') {
- el.scrollLeft = val[0];
- el.scrollTop = val[1];
- } else {
- superclass.setAttribute.call(this, attr, val, unit);
- }
- };
-})();
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/**
+ * The animation module provides allows effects to be added to HTMLElements.
+ * @module animation
+ * @requires yahoo, event, dom
+ */
+
+/**
+ *
+ * Base animation class that provides the interface for building animated effects.
+ * Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);
+ * @class Anim
+ * @namespace YAHOO.util
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @param {String | HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+
+YAHOO.util.Anim = function(el, attributes, duration, method) {
+ if (el) {
+ this.init(el, attributes, duration, method);
+ }
+};
+
+YAHOO.util.Anim.prototype = {
+ /**
+ * Provides a readable name for the Anim instance.
+ * @method toString
+ * @return {String}
+ */
+ toString: function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Anim " + id);
+ },
+
+ patterns: { // cached for performance
+ noNegatives: /width|height|opacity|padding/i, // keep at zero or above
+ offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default
+ defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default
+ offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset
+ },
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @method doMethod
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ doMethod: function(attr, start, end) {
+ return this.method(this.currentFrame, start, end - start, this.totalFrames);
+ },
+
+ /**
+ * Applies a value to an attribute.
+ * @method setAttribute
+ * @param {String} attr The name of the attribute.
+ * @param {Number} val The value to be applied to the attribute.
+ * @param {String} unit The unit ('px', '%', etc.) of the value.
+ */
+ setAttribute: function(attr, val, unit) {
+ if ( this.patterns.noNegatives.test(attr) ) {
+ val = (val > 0) ? val : 0;
+ }
+
+ YAHOO.util.Dom.setStyle(this.getEl(), attr, val + unit);
+ },
+
+ /**
+ * Returns current value of the attribute.
+ * @method getAttribute
+ * @param {String} attr The name of the attribute.
+ * @return {Number} val The current value of the attribute.
+ */
+ getAttribute: function(attr) {
+ var el = this.getEl();
+ var val = YAHOO.util.Dom.getStyle(el, attr);
+
+ if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
+ return parseFloat(val);
+ }
+
+ var a = this.patterns.offsetAttribute.exec(attr) || [];
+ var pos = !!( a[3] ); // top or left
+ var box = !!( a[2] ); // width or height
+
+ // use offsets for width/height and abs pos top/left
+ if ( box || (YAHOO.util.Dom.getStyle(el, 'position') == 'absolute' && pos) ) {
+ val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
+ } else { // default to zero for other 'auto'
+ val = 0;
+ }
+
+ return val;
+ },
+
+ /**
+ * Returns the unit to use when none is supplied.
+ * @method getDefaultUnit
+ * @param {attr} attr The name of the attribute.
+ * @return {String} The default unit to be used.
+ */
+ getDefaultUnit: function(attr) {
+ if ( this.patterns.defaultUnit.test(attr) ) {
+ return 'px';
+ }
+
+ return '';
+ },
+
+ /**
+ * Sets the actual values to be used during the animation. Should only be needed for subclass use.
+ * @method setRuntimeAttribute
+ * @param {Object} attr The attribute object
+ * @private
+ */
+ setRuntimeAttribute: function(attr) {
+ var start;
+ var end;
+ var attributes = this.attributes;
+
+ this.runtimeAttributes[attr] = {};
+
+ var isset = function(prop) {
+ return (typeof prop !== 'undefined');
+ };
+
+ if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) {
+ return false; // note return; nothing to animate to
+ }
+
+ start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
+
+ // To beats by, per SMIL 2.1 spec
+ if ( isset(attributes[attr]['to']) ) {
+ end = attributes[attr]['to'];
+ } else if ( isset(attributes[attr]['by']) ) {
+ if (start.constructor == Array) {
+ end = [];
+ for (var i = 0, len = start.length; i < len; ++i) {
+ end[i] = start[i] + attributes[attr]['by'][i];
+ }
+ } else {
+ end = start + attributes[attr]['by'];
+ }
+ }
+
+ this.runtimeAttributes[attr].start = start;
+ this.runtimeAttributes[attr].end = end;
+
+ // set units if needed
+ this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
+ },
+
+ /**
+ * Constructor for Anim instance.
+ * @method init
+ * @param {String | HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ init: function(el, attributes, duration, method) {
+ /**
+ * Whether or not the animation is running.
+ * @property isAnimated
+ * @private
+ * @type Boolean
+ */
+ var isAnimated = false;
+
+ /**
+ * A Date object that is created when the animation begins.
+ * @property startTime
+ * @private
+ * @type Date
+ */
+ var startTime = null;
+
+ /**
+ * The number of frames this animation was able to execute.
+ * @property actualFrames
+ * @private
+ * @type Int
+ */
+ var actualFrames = 0;
+
+ /**
+ * The element to be animated.
+ * @property el
+ * @private
+ * @type HTMLElement
+ */
+ el = YAHOO.util.Dom.get(el);
+
+ /**
+ * The collection of attributes to be animated.
+ * Each attribute must have at least a "to" or "by" defined in order to animate.
+ * If "to" is supplied, the animation will end with the attribute at that value.
+ * If "by" is supplied, the animation will end at that value plus its starting value.
+ * If both are supplied, "to" is used, and "by" is ignored.
+ * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values).
+ * @property attributes
+ * @type Object
+ */
+ this.attributes = attributes || {};
+
+ /**
+ * The length of the animation. Defaults to "1" (second).
+ * @property duration
+ * @type Number
+ */
+ this.duration = duration || 1;
+
+ /**
+ * The method that will provide values to the attribute(s) during the animation.
+ * Defaults to "YAHOO.util.Easing.easeNone".
+ * @property method
+ * @type Function
+ */
+ this.method = method || YAHOO.util.Easing.easeNone;
+
+ /**
+ * Whether or not the duration should be treated as seconds.
+ * Defaults to true.
+ * @property useSeconds
+ * @type Boolean
+ */
+ this.useSeconds = true; // default to seconds
+
+ /**
+ * The location of the current animation on the timeline.
+ * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
+ * @property currentFrame
+ * @type Int
+ */
+ this.currentFrame = 0;
+
+ /**
+ * The total number of frames to be executed.
+ * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
+ * @property totalFrames
+ * @type Int
+ */
+ this.totalFrames = YAHOO.util.AnimMgr.fps;
+
+
+ /**
+ * Returns a reference to the animated element.
+ * @method getEl
+ * @return {HTMLElement}
+ */
+ this.getEl = function() { return el; };
+
+ /**
+ * Checks whether the element is currently animated.
+ * @method isAnimated
+ * @return {Boolean} current value of isAnimated.
+ */
+ this.isAnimated = function() {
+ return isAnimated;
+ };
+
+ /**
+ * Returns the animation start time.
+ * @method getStartTime
+ * @return {Date} current value of startTime.
+ */
+ this.getStartTime = function() {
+ return startTime;
+ };
+
+ this.runtimeAttributes = {};
+
+
+
+ /**
+ * Starts the animation by registering it with the animation manager.
+ * @method animate
+ */
+ this.animate = function() {
+ if ( this.isAnimated() ) {
+ return false;
+ }
+
+ this.currentFrame = 0;
+
+ this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration;
+
+ YAHOO.util.AnimMgr.registerElement(this);
+ };
+
+ /**
+ * Stops the animation. Normally called by AnimMgr when animation completes.
+ * @method stop
+ * @param {Boolean} finish (optional) If true, animation will jump to final frame.
+ */
+ this.stop = function(finish) {
+ if (finish) {
+ this.currentFrame = this.totalFrames;
+ this._onTween.fire();
+ }
+ YAHOO.util.AnimMgr.stop(this);
+ };
+
+ var onStart = function() {
+ this.onStart.fire();
+
+ this.runtimeAttributes = {};
+ for (var attr in this.attributes) {
+ this.setRuntimeAttribute(attr);
+ }
+
+ isAnimated = true;
+ actualFrames = 0;
+ startTime = new Date();
+ };
+
+ /**
+ * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s).
+ * @private
+ */
+
+ var onTween = function() {
+ var data = {
+ duration: new Date() - this.getStartTime(),
+ currentFrame: this.currentFrame
+ };
+
+ data.toString = function() {
+ return (
+ 'duration: ' + data.duration +
+ ', currentFrame: ' + data.currentFrame
+ );
+ };
+
+ this.onTween.fire(data);
+
+ var runtimeAttributes = this.runtimeAttributes;
+
+ for (var attr in runtimeAttributes) {
+ this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
+ }
+
+ actualFrames += 1;
+ };
+
+ var onComplete = function() {
+ var actual_duration = (new Date() - startTime) / 1000 ;
+
+ var data = {
+ duration: actual_duration,
+ frames: actualFrames,
+ fps: actualFrames / actual_duration
+ };
+
+ data.toString = function() {
+ return (
+ 'duration: ' + data.duration +
+ ', frames: ' + data.frames +
+ ', fps: ' + data.fps
+ );
+ };
+
+ isAnimated = false;
+ actualFrames = 0;
+ this.onComplete.fire(data);
+ };
+
+ /**
+ * Custom event that fires after onStart, useful in subclassing
+ * @private
+ */
+ this._onStart = new YAHOO.util.CustomEvent('_start', this, true);
+
+ /**
+ * Custom event that fires when animation begins
+ * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction)
+ * @event onStart
+ */
+ this.onStart = new YAHOO.util.CustomEvent('start', this);
+
+ /**
+ * Custom event that fires between each frame
+ * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction)
+ * @event onTween
+ */
+ this.onTween = new YAHOO.util.CustomEvent('tween', this);
+
+ /**
+ * Custom event that fires after onTween
+ * @private
+ */
+ this._onTween = new YAHOO.util.CustomEvent('_tween', this, true);
+
+ /**
+ * Custom event that fires when animation ends
+ * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction)
+ * @event onComplete
+ */
+ this.onComplete = new YAHOO.util.CustomEvent('complete', this);
+ /**
+ * Custom event that fires after onComplete
+ * @private
+ */
+ this._onComplete = new YAHOO.util.CustomEvent('_complete', this, true);
+
+ this._onStart.subscribe(onStart);
+ this._onTween.subscribe(onTween);
+ this._onComplete.subscribe(onComplete);
+ }
+};
+
+/**
+ * Handles animation queueing and threading.
+ * Used by Anim and subclasses.
+ * @class AnimMgr
+ * @namespace YAHOO.util
+ */
+YAHOO.util.AnimMgr = new function() {
+ /**
+ * Reference to the animation Interval.
+ * @property thread
+ * @private
+ * @type Int
+ */
+ var thread = null;
+
+ /**
+ * The current queue of registered animation objects.
+ * @property queue
+ * @private
+ * @type Array
+ */
+ var queue = [];
+
+ /**
+ * The number of active animations.
+ * @property tweenCount
+ * @private
+ * @type Int
+ */
+ var tweenCount = 0;
+
+ /**
+ * Base frame rate (frames per second).
+ * Arbitrarily high for better x-browser calibration (slower browsers drop more frames).
+ * @property fps
+ * @type Int
+ *
+ */
+ this.fps = 1000;
+
+ /**
+ * Interval delay in milliseconds, defaults to fastest possible.
+ * @property delay
+ * @type Int
+ *
+ */
+ this.delay = 1;
+
+ /**
+ * Adds an animation instance to the animation queue.
+ * All animation instances must be registered in order to animate.
+ * @method registerElement
+ * @param {object} tween The Anim instance to be be registered
+ */
+ this.registerElement = function(tween) {
+ queue[queue.length] = tween;
+ tweenCount += 1;
+ tween._onStart.fire();
+ this.start();
+ };
+
+ /**
+ * removes an animation instance from the animation queue.
+ * All animation instances must be registered in order to animate.
+ * @method unRegister
+ * @param {object} tween The Anim instance to be be registered
+ * @param {Int} index The index of the Anim instance
+ * @private
+ */
+ this.unRegister = function(tween, index) {
+ tween._onComplete.fire();
+ index = index || getIndex(tween);
+ if (index != -1) { queue.splice(index, 1); }
+
+ tweenCount -= 1;
+ if (tweenCount <= 0) { this.stop(); }
+ };
+
+ /**
+ * Starts the animation thread.
+ * Only one thread can run at a time.
+ * @method start
+ */
+ this.start = function() {
+ if (thread === null) { thread = setInterval(this.run, this.delay); }
+ };
+
+ /**
+ * Stops the animation thread or a specific animation instance.
+ * @method stop
+ * @param {object} tween A specific Anim instance to stop (optional)
+ * If no instance given, Manager stops thread and all animations.
+ */
+ this.stop = function(tween) {
+ if (!tween) {
+ clearInterval(thread);
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ if (queue[i].isAnimated()) {
+ this.unRegister(tween, i);
+ }
+ }
+ queue = [];
+ thread = null;
+ tweenCount = 0;
+ }
+ else {
+ this.unRegister(tween);
+ }
+ };
+
+ /**
+ * Called per Interval to handle each animation frame.
+ * @method run
+ */
+ this.run = function() {
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ var tween = queue[i];
+ if ( !tween || !tween.isAnimated() ) { continue; }
+
+ if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
+ {
+ tween.currentFrame += 1;
+
+ if (tween.useSeconds) {
+ correctFrame(tween);
+ }
+ tween._onTween.fire();
+ }
+ else { YAHOO.util.AnimMgr.stop(tween, i); }
+ }
+ };
+
+ var getIndex = function(anim) {
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ if (queue[i] == anim) {
+ return i; // note return;
+ }
+ }
+ return -1;
+ };
+
+ /**
+ * On the fly frame correction to keep animation on time.
+ * @method correctFrame
+ * @private
+ * @param {Object} tween The Anim instance being corrected.
+ */
+ var correctFrame = function(tween) {
+ var frames = tween.totalFrames;
+ var frame = tween.currentFrame;
+ var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
+ var elapsed = (new Date() - tween.getStartTime());
+ var tweak = 0;
+
+ if (elapsed < tween.duration * 1000) { // check if falling behind
+ tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
+ } else { // went over duration, so jump to end
+ tweak = frames - (frame + 1);
+ }
+ if (tweak > 0 && isFinite(tweak)) { // adjust if needed
+ if (tween.currentFrame + tweak >= frames) {// dont go past last frame
+ tweak = frames - (frame + 1);
+ }
+
+ tween.currentFrame += tweak;
+ }
+ };
+};
+/**
+ * Used to calculate Bezier splines for any number of control points.
+ * @class Bezier
+ * @namespace YAHOO.util
+ *
+ */
+YAHOO.util.Bezier = new function() {
+ /**
+ * Get the current position of the animated element based on t.
+ * Each point is an array of "x" and "y" values (0 = x, 1 = y)
+ * At least 2 points are required (start and end).
+ * First point is start. Last point is end.
+ * Additional control points are optional.
+ * @method getPosition
+ * @param {Array} points An array containing Bezier points
+ * @param {Number} t A number between 0 and 1 which is the basis for determining current position
+ * @return {Array} An array containing int x and y member data
+ */
+ this.getPosition = function(points, t) {
+ var n = points.length;
+ var tmp = [];
+
+ for (var i = 0; i < n; ++i){
+ tmp[i] = [points[i][0], points[i][1]]; // save input
+ }
+
+ for (var j = 1; j < n; ++j) {
+ for (i = 0; i < n - j; ++i) {
+ tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
+ tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
+ }
+ }
+
+ return [ tmp[0][0], tmp[0][1] ];
+
+ };
+};
+(function() {
+/**
+ * Anim subclass for color transitions.
+ * Usage: var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);
Color values can be specified with either 112233, #112233,
+ * [255,255,255], or rgb(255,255,255)
+ * @class ColorAnim
+ * @namespace YAHOO.util
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @constructor
+ * @extends YAHOO.util.Anim
+ * @param {HTMLElement | String} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ YAHOO.util.ColorAnim = function(el, attributes, duration, method) {
+ YAHOO.util.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
+ };
+
+ YAHOO.extend(YAHOO.util.ColorAnim, YAHOO.util.Anim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.ColorAnim.superclass;
+ var proto = Y.ColorAnim.prototype;
+
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("ColorAnim " + id);
+ };
+
+ proto.patterns.color = /color$/i;
+ proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
+ proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
+ proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
+ proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/; // need rgba for safari
+
+ /**
+ * Attempts to parse the given string and return a 3-tuple.
+ * @method parseColor
+ * @param {String} s The string to parse.
+ * @return {Array} The 3-tuple of rgb values.
+ */
+ proto.parseColor = function(s) {
+ if (s.length == 3) { return s; }
+
+ var c = this.patterns.hex.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
+ }
+
+ c = this.patterns.rgb.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
+ }
+
+ c = this.patterns.hex3.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
+ }
+
+ return null;
+ };
+
+ proto.getAttribute = function(attr) {
+ var el = this.getEl();
+ if ( this.patterns.color.test(attr) ) {
+ var val = YAHOO.util.Dom.getStyle(el, attr);
+
+ if (this.patterns.transparent.test(val)) { // bgcolor default
+ var parent = el.parentNode; // try and get from an ancestor
+ val = Y.Dom.getStyle(parent, attr);
+
+ while (parent && this.patterns.transparent.test(val)) {
+ parent = parent.parentNode;
+ val = Y.Dom.getStyle(parent, attr);
+ if (parent.tagName.toUpperCase() == 'HTML') {
+ val = '#fff';
+ }
+ }
+ }
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ proto.doMethod = function(attr, start, end) {
+ var val;
+
+ if ( this.patterns.color.test(attr) ) {
+ val = [];
+ for (var i = 0, len = start.length; i < len; ++i) {
+ val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
+ }
+
+ val = 'rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';
+ }
+ else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+
+ return val;
+ };
+
+ proto.setRuntimeAttribute = function(attr) {
+ superclass.setRuntimeAttribute.call(this, attr);
+
+ if ( this.patterns.color.test(attr) ) {
+ var attributes = this.attributes;
+ var start = this.parseColor(this.runtimeAttributes[attr].start);
+ var end = this.parseColor(this.runtimeAttributes[attr].end);
+ // fix colors if going "by"
+ if ( typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined' ) {
+ end = this.parseColor(attributes[attr].by);
+
+ for (var i = 0, len = start.length; i < len; ++i) {
+ end[i] = start[i] + end[i];
+ }
+ }
+
+ this.runtimeAttributes[attr].start = start;
+ this.runtimeAttributes[attr].end = end;
+ }
+ };
+})();/*
+TERMS OF USE - EASING EQUATIONS
+Open source under the BSD License.
+Copyright 2001 Robert Penner All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * Singleton that determines how an animation proceeds from start to end.
+ * @class Easing
+ * @namespace YAHOO.util
+*/
+
+YAHOO.util.Easing = {
+
+ /**
+ * Uniform speed between points.
+ * @method easeNone
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeNone: function (t, b, c, d) {
+ return c*t/d + b;
+ },
+
+ /**
+ * Begins slowly and accelerates towards end. (quadratic)
+ * @method easeIn
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeIn: function (t, b, c, d) {
+ return c*(t/=d)*t + b;
+ },
+
+ /**
+ * Begins quickly and decelerates towards end. (quadratic)
+ * @method easeOut
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeOut: function (t, b, c, d) {
+ return -c *(t/=d)*(t-2) + b;
+ },
+
+ /**
+ * Begins slowly and decelerates towards end. (quadratic)
+ * @method easeBoth
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeBoth: function (t, b, c, d) {
+ if ((t/=d/2) < 1) {
+ return c/2*t*t + b;
+ }
+
+ return -c/2 * ((--t)*(t-2) - 1) + b;
+ },
+
+ /**
+ * Begins slowly and accelerates towards end. (quartic)
+ * @method easeInStrong
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeInStrong: function (t, b, c, d) {
+ return c*(t/=d)*t*t*t + b;
+ },
+
+ /**
+ * Begins quickly and decelerates towards end. (quartic)
+ * @method easeOutStrong
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeOutStrong: function (t, b, c, d) {
+ return -c * ((t=t/d-1)*t*t*t - 1) + b;
+ },
+
+ /**
+ * Begins slowly and decelerates towards end. (quartic)
+ * @method easeBothStrong
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ easeBothStrong: function (t, b, c, d) {
+ if ((t/=d/2) < 1) {
+ return c/2*t*t*t*t + b;
+ }
+
+ return -c/2 * ((t-=2)*t*t*t - 2) + b;
+ },
+
+ /**
+ * Snap in elastic effect.
+ * @method elasticIn
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} a Amplitude (optional)
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+
+ elasticIn: function (t, b, c, d, a, p) {
+ if (t == 0) {
+ return b;
+ }
+ if ( (t /= d) == 1 ) {
+ return b+c;
+ }
+ if (!p) {
+ p=d*.3;
+ }
+
+ if (!a || a < Math.abs(c)) {
+ a = c;
+ var s = p/4;
+ }
+ else {
+ var s = p/(2*Math.PI) * Math.asin (c/a);
+ }
+
+ return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ },
+
+ /**
+ * Snap out elastic effect.
+ * @method elasticOut
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} a Amplitude (optional)
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ elasticOut: function (t, b, c, d, a, p) {
+ if (t == 0) {
+ return b;
+ }
+ if ( (t /= d) == 1 ) {
+ return b+c;
+ }
+ if (!p) {
+ p=d*.3;
+ }
+
+ if (!a || a < Math.abs(c)) {
+ a = c;
+ var s = p / 4;
+ }
+ else {
+ var s = p/(2*Math.PI) * Math.asin (c/a);
+ }
+
+ return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
+ },
+
+ /**
+ * Snap both elastic effect.
+ * @method elasticBoth
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} a Amplitude (optional)
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ elasticBoth: function (t, b, c, d, a, p) {
+ if (t == 0) {
+ return b;
+ }
+
+ if ( (t /= d/2) == 2 ) {
+ return b+c;
+ }
+
+ if (!p) {
+ p = d*(.3*1.5);
+ }
+
+ if ( !a || a < Math.abs(c) ) {
+ a = c;
+ var s = p/4;
+ }
+ else {
+ var s = p/(2*Math.PI) * Math.asin (c/a);
+ }
+
+ if (t < 1) {
+ return -.5*(a*Math.pow(2,10*(t-=1)) *
+ Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ }
+ return a*Math.pow(2,-10*(t-=1)) *
+ Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
+ },
+
+ /**
+ * Backtracks slightly, then reverses direction and moves to end.
+ * @method backIn
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ backIn: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') {
+ s = 1.70158;
+ }
+ return c*(t/=d)*t*((s+1)*t - s) + b;
+ },
+
+ /**
+ * Overshoots end, then reverses and comes back to end.
+ * @method backOut
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ backOut: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') {
+ s = 1.70158;
+ }
+ return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
+ },
+
+ /**
+ * Backtracks slightly, then reverses direction, overshoots end,
+ * then reverses and comes back to end.
+ * @method backBoth
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @param {Number} s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame
+ */
+ backBoth: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') {
+ s = 1.70158;
+ }
+
+ if ((t /= d/2 ) < 1) {
+ return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
+ }
+ return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
+ },
+
+ /**
+ * Bounce off of start.
+ * @method bounceIn
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ bounceIn: function (t, b, c, d) {
+ return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b;
+ },
+
+ /**
+ * Bounces off end.
+ * @method bounceOut
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ bounceOut: function (t, b, c, d) {
+ if ((t/=d) < (1/2.75)) {
+ return c*(7.5625*t*t) + b;
+ } else if (t < (2/2.75)) {
+ return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
+ } else if (t < (2.5/2.75)) {
+ return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
+ }
+ return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
+ },
+
+ /**
+ * Bounces off start and end.
+ * @method bounceBoth
+ * @param {Number} t Time value used to compute current value
+ * @param {Number} b Starting value
+ * @param {Number} c Delta between start and end values
+ * @param {Number} d Total length of animation
+ * @return {Number} The computed value for the current animation frame
+ */
+ bounceBoth: function (t, b, c, d) {
+ if (t < d/2) {
+ return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b;
+ }
+ return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
+ }
+};
+
+(function() {
+/**
+ * Anim subclass for moving elements along a path defined by the "points"
+ * member of "attributes". All "points" are arrays with x, y coordinates.
+ * Usage: var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);
+ * @class Motion
+ * @namespace YAHOO.util
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @extends YAHOO.util.Anim
+ * @param {String | HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ YAHOO.util.Motion = function(el, attributes, duration, method) {
+ if (el) { // dont break existing subclasses not using YAHOO.extend
+ YAHOO.util.Motion.superclass.constructor.call(this, el, attributes, duration, method);
+ }
+ };
+
+ YAHOO.extend(YAHOO.util.Motion, YAHOO.util.ColorAnim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.Motion.superclass;
+ var proto = Y.Motion.prototype;
+
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Motion " + id);
+ };
+
+ proto.patterns.points = /^points$/i;
+
+ proto.setAttribute = function(attr, val, unit) {
+ if ( this.patterns.points.test(attr) ) {
+ unit = unit || 'px';
+ superclass.setAttribute.call(this, 'left', val[0], unit);
+ superclass.setAttribute.call(this, 'top', val[1], unit);
+ } else {
+ superclass.setAttribute.call(this, attr, val, unit);
+ }
+ };
+
+ proto.getAttribute = function(attr) {
+ if ( this.patterns.points.test(attr) ) {
+ var val = [
+ superclass.getAttribute.call(this, 'left'),
+ superclass.getAttribute.call(this, 'top')
+ ];
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ proto.doMethod = function(attr, start, end) {
+ var val = null;
+
+ if ( this.patterns.points.test(attr) ) {
+ var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
+ val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
+ } else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+ return val;
+ };
+
+ proto.setRuntimeAttribute = function(attr) {
+ if ( this.patterns.points.test(attr) ) {
+ var el = this.getEl();
+ var attributes = this.attributes;
+ var start;
+ var control = attributes['points']['control'] || [];
+ var end;
+ var i, len;
+
+ if (control.length > 0 && !(control[0] instanceof Array) ) { // could be single point or array of points
+ control = [control];
+ } else { // break reference to attributes.points.control
+ var tmp = [];
+ for (i = 0, len = control.length; i< len; ++i) {
+ tmp[i] = control[i];
+ }
+ control = tmp;
+ }
+
+ if (Y.Dom.getStyle(el, 'position') == 'static') { // default to relative
+ Y.Dom.setStyle(el, 'position', 'relative');
+ }
+
+ if ( isset(attributes['points']['from']) ) {
+ Y.Dom.setXY(el, attributes['points']['from']); // set position to from point
+ }
+ else { Y.Dom.setXY( el, Y.Dom.getXY(el) ); } // set it to current position
+
+ start = this.getAttribute('points'); // get actual top & left
+
+ // TO beats BY, per SMIL 2.1 spec
+ if ( isset(attributes['points']['to']) ) {
+ end = translateValues.call(this, attributes['points']['to'], start);
+
+ var pageXY = Y.Dom.getXY(this.getEl());
+ for (i = 0, len = control.length; i < len; ++i) {
+ control[i] = translateValues.call(this, control[i], start);
+ }
+
+
+ } else if ( isset(attributes['points']['by']) ) {
+ end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
+
+ for (i = 0, len = control.length; i < len; ++i) {
+ control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
+ }
+ }
+
+ this.runtimeAttributes[attr] = [start];
+
+ if (control.length > 0) {
+ this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
+ }
+
+ this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
+ }
+ else {
+ superclass.setRuntimeAttribute.call(this, attr);
+ }
+ };
+
+ var translateValues = function(val, start) {
+ var pageXY = Y.Dom.getXY(this.getEl());
+ val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
+
+ return val;
+ };
+
+ var isset = function(prop) {
+ return (typeof prop !== 'undefined');
+ };
+})();
+(function() {
+/**
+ * Anim subclass for scrolling elements to a position defined by the "scroll"
+ * member of "attributes". All "scroll" members are arrays with x, y scroll positions.
+ * Usage: var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);
+ * @class Scroll
+ * @namespace YAHOO.util
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @extends YAHOO.util.Anim
+ * @constructor
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ YAHOO.util.Scroll = function(el, attributes, duration, method) {
+ if (el) { // dont break existing subclasses not using YAHOO.extend
+ YAHOO.util.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
+ }
+ };
+
+ YAHOO.extend(YAHOO.util.Scroll, YAHOO.util.ColorAnim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.Scroll.superclass;
+ var proto = Y.Scroll.prototype;
+
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Scroll " + id);
+ };
+
+ proto.doMethod = function(attr, start, end) {
+ var val = null;
+
+ if (attr == 'scroll') {
+ val = [
+ this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
+ this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
+ ];
+
+ } else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+ return val;
+ };
+
+ proto.getAttribute = function(attr) {
+ var val = null;
+ var el = this.getEl();
+
+ if (attr == 'scroll') {
+ val = [ el.scrollLeft, el.scrollTop ];
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ proto.setAttribute = function(attr, val, unit) {
+ var el = this.getEl();
+
+ if (attr == 'scroll') {
+ el.scrollLeft = val[0];
+ el.scrollTop = val[1];
+ } else {
+ superclass.setAttribute.call(this, attr, val, unit);
+ }
+ };
+})();
diff --git a/lib/yui/autocomplete/README b/lib/yui/autocomplete/README
index 01cad9d227..39c1cd89cf 100755
--- a/lib/yui/autocomplete/README
+++ b/lib/yui/autocomplete/README
@@ -1,65 +1,71 @@
-AutoComplete Release Notes
-
-*** version 0.12.1 ***
-
-* No longer trigger typeAhead feature when user is backspacing on input text.
-
-
-
-*** version 0.12.0 ***
-
-* The following constants must be defined as static class properties and are no longer
-available as instance properties:
-
-YAHOO.widget.DataSource.ERROR_DATANULL
-YAHOO.widget.DataSource.ERROR_DATAPARSE
-YAHOO.widget.DS_XHR.TYPE_JSON
-YAHOO.widget.DS_XHR.TYPE_XML
-YAHOO.widget.DS_XHR.TYPE_FLAT
-YAHOO.widget.DS_XHR.ERROR_DATAXHR
-
-* The property minQueryLength now supports zero and negative number values for
-DS_JSFunction and DS_XHR objects, to enable null or empty string queries and to disable
-AutoComplete functionality altogether, respectively.
-
-* Enabling the alwaysShowContainer feature will no longer send containerExpandEvent or
-containerCollapseEvent.
-
-
-
-**** version 0.11.3 ***
-
-* The iFrameSrc property has been deprecated. Implementers no longer need to
-specify an https URL to avoid IE security warnings when working with sites over
-SSL.
-
-
-
-*** version 0.11.0 ***
-
-* The method getListIds() has been deprecated for getListItems(), which returns
-an array of DOM references.
-
-* All classnames have been prefixed with "yui-ac-".
-
-* Container elements should no longer have CSS property "display" set to "none".
-
-* The useIFrame property can now be set after instantiation.
-
-* On some browsers, the unmatchedItemSelectEvent may not be fired properly when
-delimiter characters are defined.
-
-* On some browsers, defining delimiter characters while enabling forceSelection
-may result in unexpected behavior.
-
-
-
-*** version 0.10.0 ***
-
-* Initial release
-
-* In order to enable the useIFrame property, it should be set in the
-constructor.
-
-* On some browsers, defining delimiter characters while enabling forceSelection
-may result in unexpected behavior.
+AutoComplete Release Notes
+
+*** version 0.12.2 ***
+
+* No changes.
+
+
+
+*** version 0.12.1 ***
+
+* No longer trigger typeAhead feature when user is backspacing on input text.
+
+
+
+*** version 0.12.0 ***
+
+* The following constants must be defined as static class properties and are no longer
+available as instance properties:
+
+YAHOO.widget.DataSource.ERROR_DATANULL
+YAHOO.widget.DataSource.ERROR_DATAPARSE
+YAHOO.widget.DS_XHR.TYPE_JSON
+YAHOO.widget.DS_XHR.TYPE_XML
+YAHOO.widget.DS_XHR.TYPE_FLAT
+YAHOO.widget.DS_XHR.ERROR_DATAXHR
+
+* The property minQueryLength now supports zero and negative number values for
+DS_JSFunction and DS_XHR objects, to enable null or empty string queries and to disable
+AutoComplete functionality altogether, respectively.
+
+* Enabling the alwaysShowContainer feature will no longer send containerExpandEvent or
+containerCollapseEvent.
+
+
+
+**** version 0.11.3 ***
+
+* The iFrameSrc property has been deprecated. Implementers no longer need to
+specify an https URL to avoid IE security warnings when working with sites over
+SSL.
+
+
+
+*** version 0.11.0 ***
+
+* The method getListIds() has been deprecated for getListItems(), which returns
+an array of DOM references.
+
+* All classnames have been prefixed with "yui-ac-".
+
+* Container elements should no longer have CSS property "display" set to "none".
+
+* The useIFrame property can now be set after instantiation.
+
+* On some browsers, the unmatchedItemSelectEvent may not be fired properly when
+delimiter characters are defined.
+
+* On some browsers, defining delimiter characters while enabling forceSelection
+may result in unexpected behavior.
+
+
+
+*** version 0.10.0 ***
+
+* Initial release
+
+* In order to enable the useIFrame property, it should be set in the
+constructor.
+
+* On some browsers, defining delimiter characters while enabling forceSelection
+may result in unexpected behavior.
diff --git a/lib/yui/autocomplete/autocomplete-debug.js b/lib/yui/autocomplete/autocomplete-debug.js
index d6c3ac3616..45dc20894d 100755
--- a/lib/yui/autocomplete/autocomplete-debug.js
+++ b/lib/yui/autocomplete/autocomplete-debug.js
@@ -1,10 +1,9 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.com/yui/license.txt
-version: 0.12.1
-*/
-
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
/**
* The AutoComplete control provides the front-end logic for text-entry suggestion and
* completion functionality.
@@ -138,7 +137,7 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
this.selectionEnforceEvent = new YAHOO.util.CustomEvent("selectionEnforce", this);
this.containerCollapseEvent = new YAHOO.util.CustomEvent("containerCollapse", this);
this.textboxBlurEvent = new YAHOO.util.CustomEvent("textboxBlur", this);
-
+
// Finish up
oTextbox.setAttribute("autocomplete","off");
YAHOO.widget.AutoComplete._nIndex++;
@@ -516,7 +515,7 @@ YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null;
/**
* Fired when the AutoComplete instance makes a query to the DataSource.
- *
+ *
* @event dataRequestEvent
* @param oSelf {Object} The AutoComplete instance.
* @param sQuery {String} The query string.
@@ -554,7 +553,7 @@ YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
/**
* Fired when the input field has been prefilled by the type-ahead
- * feature.
+ * feature.
*
* @event typeAheadEvent
* @param oSelf {Object} The AutoComplete instance.
@@ -582,7 +581,7 @@ YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
/**
- * Fired when result item has been arrowed to.
+ * Fired when result item has been arrowed to.
*
* @event itemArrowToEvent
* @param oSelf {Object} The AutoComplete instance.
@@ -613,7 +612,7 @@ YAHOO.widget.AutoComplete.prototype.itemSelectEvent = null;
/**
* Fired when a user selection does not match any of the displayed result items.
* Note that this event may not behave as expected when delimiter characters
- * have been defined.
+ * have been defined.
*
* @event unmatchedItemSelectEvent
* @param oSelf {Object} The AutoComplete instance.
@@ -1370,7 +1369,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
if(this.alwaysShowContainer && this._bContainerOpen) {
return;
}
-
+
// Clear contents of container
if(!bShow) {
this._oContainer._oContent.scrollTop = 0;
@@ -2013,1086 +2012,1086 @@ YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
oSelf._oTextbox.setAttribute("autocomplete","off");
}
};
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * The DataSource classes manages sending a request and returning response from a live
- * database. Supported data include local JavaScript arrays and objects and databases
- * accessible via XHR connections. Supported response formats include JavaScript arrays,
- * JSON, XML, and flat-file textual data.
- *
- * @class DataSource
- * @constructor
- */
-YAHOO.widget.DataSource = function() {
- /* abstract class */
-};
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public constants
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Error message for null data responses.
- *
- * @property ERROR_DATANULL
- * @type String
- * @static
- * @final
- */
-YAHOO.widget.DataSource.ERROR_DATANULL = "Response data was null";
-
-/**
- * Error message for data responses with parsing errors.
- *
- * @property ERROR_DATAPARSE
- * @type String
- * @static
- * @final
- */
-YAHOO.widget.DataSource.ERROR_DATAPARSE = "Response data could not be parsed";
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Max size of the local cache. Set to 0 to turn off caching. Caching is
- * useful to reduce the number of server connections. Recommended only for data
- * sources that return comprehensive results for queries or when stale data is
- * not an issue.
- *
- * @property maxCacheEntries
- * @type Number
- * @default 15
- */
-YAHOO.widget.DataSource.prototype.maxCacheEntries = 15;
-
-/**
- * Use this to equate cache matching with the type of matching done by your live
- * data source. If caching is on and queryMatchContains is true, the cache
- * returns results that "contain" the query string. By default,
- * queryMatchContains is set to false, meaning the cache only returns results
- * that "start with" the query string.
- *
- * @property queryMatchContains
- * @type Boolean
- * @default false
- */
-YAHOO.widget.DataSource.prototype.queryMatchContains = false;
-
-/**
- * Enables query subset matching. If caching is on and queryMatchSubset is
- * true, substrings of queries will return matching cached results. For
- * instance, if the first query is for "abc" susequent queries that start with
- * "abc", like "abcd", will be queried against the cache, and not the live data
- * source. Recommended only for DataSources that return comprehensive results
- * for queries with very few characters.
- *
- * @property queryMatchSubset
- * @type Boolean
- * @default false
- *
- */
-YAHOO.widget.DataSource.prototype.queryMatchSubset = false;
-
-/**
- * Enables query case-sensitivity matching. If caching is on and
- * queryMatchCase is true, queries will only return results for case-sensitive
- * matches.
- *
- * @property queryMatchCase
- * @type Boolean
- * @default false
- */
-YAHOO.widget.DataSource.prototype.queryMatchCase = false;
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Public accessor to the unique name of the DataSource instance.
- *
- * @method toString
- * @return {String} Unique name of the DataSource instance
- */
-YAHOO.widget.DataSource.prototype.toString = function() {
- return "DataSource " + this._sName;
-};
-
-/**
- * Retrieves query results, first checking the local cache, then making the
- * query request to the live data source as defined by the function doQuery.
- *
- * @method getResults
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DataSource.prototype.getResults = function(oCallbackFn, sQuery, oParent) {
-
- // First look in cache
- var aResults = this._doQueryCache(oCallbackFn,sQuery,oParent);
-
- // Not in cache, so get results from server
- if(aResults.length === 0) {
- this.queryEvent.fire(this, oParent, sQuery);
- this.doQuery(oCallbackFn, sQuery, oParent);
- }
-};
-
-/**
- * Abstract method implemented by subclasses to make a query to the live data
- * source. Must call the callback function with the response returned from the
- * query. Populates cache (if enabled).
- *
- * @method doQuery
- * @param oCallbackFn {HTMLFunction} Callback function implemented by oParent to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- /* override this */
-};
-
-/**
- * Flushes cache.
- *
- * @method flushCache
- */
-YAHOO.widget.DataSource.prototype.flushCache = function() {
- if(this._aCache) {
- this._aCache = [];
- }
- if(this._aCacheHelper) {
- this._aCacheHelper = [];
- }
- this.cacheFlushEvent.fire(this);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Fired when a query is made to the live data source.
- *
- * @event queryEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.DataSource.prototype.queryEvent = null;
-
-/**
- * Fired when a query is made to the local cache.
- *
- * @event cacheQueryEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.DataSource.prototype.cacheQueryEvent = null;
-
-/**
- * Fired when data is retrieved from the live data source.
- *
- * @event getResultsEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- * @param aResults {Object[]} Array of result objects.
- */
-YAHOO.widget.DataSource.prototype.getResultsEvent = null;
-
-/**
- * Fired when data is retrieved from the local cache.
- *
- * @event getCachedResultsEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- * @param aResults {Object[]} Array of result objects.
- */
-YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null;
-
-/**
- * Fired when an error is encountered with the live data source.
- *
- * @event dataErrorEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- * @param sMsg {String} Error message string
- */
-YAHOO.widget.DataSource.prototype.dataErrorEvent = null;
-
-/**
- * Fired when the local cache is flushed.
- *
- * @event cacheFlushEvent
- * @param oSelf {Object} The DataSource instance
- */
-YAHOO.widget.DataSource.prototype.cacheFlushEvent = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Internal class variable to index multiple DataSource instances.
- *
- * @property _nIndex
- * @type Number
- * @private
- * @static
- */
-YAHOO.widget.DataSource._nIndex = 0;
-
-/**
- * Name of DataSource instance.
- *
- * @property _sName
- * @type String
- * @private
- */
-YAHOO.widget.DataSource.prototype._sName = null;
-
-/**
- * Local cache of data result objects indexed chronologically.
- *
- * @property _aCache
- * @type Object[]
- * @private
- */
-YAHOO.widget.DataSource.prototype._aCache = null;
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Initializes DataSource instance.
- *
- * @method _init
- * @private
- */
-YAHOO.widget.DataSource.prototype._init = function() {
- // Validate and initialize public configs
- var maxCacheEntries = this.maxCacheEntries;
- if(isNaN(maxCacheEntries) || (maxCacheEntries < 0)) {
- maxCacheEntries = 0;
- }
- // Initialize local cache
- if(maxCacheEntries > 0 && !this._aCache) {
- this._aCache = [];
- }
-
- this._sName = "instance" + YAHOO.widget.DataSource._nIndex;
- YAHOO.widget.DataSource._nIndex++;
-
- this.queryEvent = new YAHOO.util.CustomEvent("query", this);
- this.cacheQueryEvent = new YAHOO.util.CustomEvent("cacheQuery", this);
- this.getResultsEvent = new YAHOO.util.CustomEvent("getResults", this);
- this.getCachedResultsEvent = new YAHOO.util.CustomEvent("getCachedResults", this);
- this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
- this.cacheFlushEvent = new YAHOO.util.CustomEvent("cacheFlush", this);
-};
-
-/**
- * Adds a result object to the local cache, evicting the oldest element if the
- * cache is full. Newer items will have higher indexes, the oldest item will have
- * index of 0.
- *
- * @method _addCacheElem
- * @param oResult {Object} Data result object, including array of results.
- * @private
- */
-YAHOO.widget.DataSource.prototype._addCacheElem = function(oResult) {
- var aCache = this._aCache;
- // Don't add if anything important is missing.
- if(!aCache || !oResult || !oResult.query || !oResult.results) {
- return;
- }
-
- // If the cache is full, make room by removing from index=0
- if(aCache.length >= this.maxCacheEntries) {
- aCache.shift();
- }
-
- // Add to cache, at the end of the array
- aCache.push(oResult);
-};
-
-/**
- * Queries the local cache for results. If query has been cached, the callback
- * function is called with the results, and the cached is refreshed so that it
- * is now the newest element.
- *
- * @method _doQueryCache
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- * @return aResults {Object[]} Array of results from local cache if found, otherwise null.
- * @private
- */
-YAHOO.widget.DataSource.prototype._doQueryCache = function(oCallbackFn, sQuery, oParent) {
- var aResults = [];
- var bMatchFound = false;
- var aCache = this._aCache;
- var nCacheLength = (aCache) ? aCache.length : 0;
- var bMatchContains = this.queryMatchContains;
-
- // If cache is enabled...
- if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) {
- this.cacheQueryEvent.fire(this, oParent, sQuery);
- // If case is unimportant, normalize query now instead of in loops
- if(!this.queryMatchCase) {
- var sOrigQuery = sQuery;
- sQuery = sQuery.toLowerCase();
- }
-
- // Loop through each cached element's query property...
- for(var i = nCacheLength-1; i >= 0; i--) {
- var resultObj = aCache[i];
- var aAllResultItems = resultObj.results;
- // If case is unimportant, normalize match key for comparison
- var matchKey = (!this.queryMatchCase) ?
- encodeURIComponent(resultObj.query).toLowerCase():
- encodeURIComponent(resultObj.query);
-
- // If a cached match key exactly matches the query...
- if(matchKey == sQuery) {
- // Stash all result objects into aResult[] and stop looping through the cache.
- bMatchFound = true;
- aResults = aAllResultItems;
-
- // The matching cache element was not the most recent,
- // so now we need to refresh the cache.
- if(i != nCacheLength-1) {
- // Remove element from its original location
- aCache.splice(i,1);
- // Add element as newest
- this._addCacheElem(resultObj);
- }
- break;
- }
- // Else if this query is not an exact match and subset matching is enabled...
- else if(this.queryMatchSubset) {
- // Loop through substrings of each cached element's query property...
- for(var j = sQuery.length-1; j >= 0 ; j--) {
- var subQuery = sQuery.substr(0,j);
-
- // If a substring of a cached sQuery exactly matches the query...
- if(matchKey == subQuery) {
- bMatchFound = true;
-
- // Go through each cached result object to match against the query...
- for(var k = aAllResultItems.length-1; k >= 0; k--) {
- var aRecord = aAllResultItems[k];
- var sKeyIndex = (this.queryMatchCase) ?
- encodeURIComponent(aRecord[0]).indexOf(sQuery):
- encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);
-
- // A STARTSWITH match is when the query is found at the beginning of the key string...
- if((!bMatchContains && (sKeyIndex === 0)) ||
- // A CONTAINS match is when the query is found anywhere within the key string...
- (bMatchContains && (sKeyIndex > -1))) {
- // Stash a match into aResults[].
- aResults.unshift(aRecord);
- }
- }
-
- // Add the subset match result set object as the newest element to cache,
- // and stop looping through the cache.
- resultObj = {};
- resultObj.query = sQuery;
- resultObj.results = aResults;
- this._addCacheElem(resultObj);
- break;
- }
- }
- if(bMatchFound) {
- break;
- }
- }
- }
-
- // If there was a match, send along the results.
- if(bMatchFound) {
- this.getCachedResultsEvent.fire(this, oParent, sOrigQuery, aResults);
- oCallbackFn(sOrigQuery, aResults, oParent);
- }
- }
- return aResults;
-};
-
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using XML HTTP requests that return
- * query results.
- *
- * @class DS_XHR
- * @extends YAHOO.widget.DataSource
- * @requires connection
- * @constructor
- * @param sScriptURI {String} Absolute or relative URI to script that returns query
- * results as JSON, XML, or delimited flat-file data.
- * @param aSchema {String[]} Data schema definition of results.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_XHR = function(sScriptURI, aSchema, oConfigs) {
- // Set any config params passed in to override defaults
- if(typeof oConfigs == "object") {
- for(var sConfig in oConfigs) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
-
- // Initialization sequence
- if(!aSchema || (aSchema.constructor != Array)) {
- YAHOO.log("Could not instantiate XHR DataSource due to invalid arguments", "error", this.toString());
- return;
- }
- else {
- this.schema = aSchema;
- }
- this.scriptURI = sScriptURI;
- this._init();
- YAHOO.log("XHR DataSource initialized","info",this.toString());
-};
-
-YAHOO.widget.DS_XHR.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public constants
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * JSON data type.
- *
- * @property TYPE_JSON
- * @type Number
- * @static
- * @final
- */
-YAHOO.widget.DS_XHR.TYPE_JSON = 0;
-
-/**
- * XML data type.
- *
- * @property TYPE_XML
- * @type Number
- * @static
- * @final
- */
-YAHOO.widget.DS_XHR.TYPE_XML = 1;
-
-/**
- * Flat-file data type.
- *
- * @property TYPE_FLAT
- * @type Number
- * @static
- * @final
- */
-YAHOO.widget.DS_XHR.TYPE_FLAT = 2;
-
-/**
- * Error message for XHR failure.
- *
- * @property ERROR_DATAXHR
- * @type String
- * @static
- * @final
- */
-YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed";
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Alias to YUI Connection Manager. Allows implementers to specify their own
- * subclasses of the YUI Connection Manager utility.
- *
- * @property connMgr
- * @type Object
- * @default YAHOO.util.Connect
- */
-YAHOO.widget.DS_XHR.prototype.connMgr = YAHOO.util.Connect;
-
-/**
- * Number of milliseconds the XHR connection will wait for a server response. A
- * a value of zero indicates the XHR connection will wait forever. Any value
- * greater than zero will use the Connection utility's Auto-Abort feature.
- *
- * @property connTimeout
- * @type Number
- * @default 0
- */
-YAHOO.widget.DS_XHR.prototype.connTimeout = 0;
-
-/**
- * Absolute or relative URI to script that returns query results. For instance,
- * queries will be sent to <scriptURI>?<scriptQueryParam>=userinput
- *
- * @property scriptURI
- * @type String
- */
-YAHOO.widget.DS_XHR.prototype.scriptURI = null;
-
-/**
- * Query string parameter name sent to scriptURI. For instance, queries will be
- * sent to <scriptURI>?<scriptQueryParam>=userinput
- *
- * @property scriptQueryParam
- * @type String
- * @default "query"
- */
-YAHOO.widget.DS_XHR.prototype.scriptQueryParam = "query";
-
-/**
- * String of key/value pairs to append to requests made to scriptURI. Define
- * this string when you want to send additional query parameters to your script.
- * When defined, queries will be sent to
- * <scriptURI>?<scriptQueryParam>=userinput&<scriptQueryAppend>
- *
- * @property scriptQueryAppend
- * @type String
- * @default ""
- */
-YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = "";
-
-/**
- * XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML
- * and YAHOO.widget.DS_XHR.TYPE_FLAT.
- *
- * @property responseType
- * @type String
- * @default YAHOO.widget.DS_XHR.TYPE_JSON
- */
-YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.TYPE_JSON;
-
-/**
- * String after which to strip results. If the results from the XHR are sent
- * back as HTML, the gzip HTML comment appears at the end of the data and should
- * be ignored.
- *
- * @property responseStripAfter
- * @type String
- * @default "\n<!-"
- */
-YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n 0) {
- sUri += "&" + this.scriptQueryAppend;
- }
- YAHOO.log("DataSource is querying URL " + sUri, "info", this.toString());
- var oResponse = null;
-
- var oSelf = this;
- /*
- * Sets up ajax request callback
- *
- * @param {object} oReq HTTPXMLRequest object
- * @private
- */
- var responseSuccess = function(oResp) {
- // Response ID does not match last made request ID.
- if(!oSelf._oConn || (oResp.tId != oSelf._oConn.tId)) {
- oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
- YAHOO.log(YAHOO.widget.DataSource.ERROR_DATANULL, "error", this.toString());
- return;
- }
-//DEBUG
-/*YAHOO.log(oResp.responseXML.getElementsByTagName("Result"),'warn');
-for(var foo in oResp) {
- YAHOO.log(foo + ": "+oResp[foo],'warn');
-}
-YAHOO.log('responseXML.xml: '+oResp.responseXML.xml,'warn');*/
- if(!isXML) {
- oResp = oResp.responseText;
- }
- else {
- oResp = oResp.responseXML;
- }
- if(oResp === null) {
- oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
- YAHOO.log(YAHOO.widget.DataSource.ERROR_DATANULL, "error", oSelf.toString());
- return;
- }
-
- var aResults = oSelf.parseResponse(sQuery, oResp, oParent);
- var resultObj = {};
- resultObj.query = decodeURIComponent(sQuery);
- resultObj.results = aResults;
- if(aResults === null) {
- oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATAPARSE);
- YAHOO.log(YAHOO.widget.DataSource.ERROR_DATAPARSE, "error", oSelf.toString());
- aResults = [];
- }
- else {
- oSelf.getResultsEvent.fire(oSelf, oParent, sQuery, aResults);
- oSelf._addCacheElem(resultObj);
- }
- oCallbackFn(sQuery, aResults, oParent);
- };
-
- var responseFailure = function(oResp) {
- oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DS_XHR.ERROR_DATAXHR);
- YAHOO.log(YAHOO.widget.DS_XHR.ERROR_DATAXHR + ": " + oResp.statusText, "error", oSelf.toString());
- return;
- };
-
- var oCallback = {
- success:responseSuccess,
- failure:responseFailure
- };
-
- if(!isNaN(this.connTimeout) && this.connTimeout > 0) {
- oCallback.timeout = this.connTimeout;
- }
-
- if(this._oConn) {
- this.connMgr.abort(this._oConn);
- }
-
- oSelf._oConn = this.connMgr.asyncRequest("GET", sUri, oCallback, null);
-};
-
-/**
- * Parses raw response data into an array of result objects. The result data key
- * is always stashed in the [0] element of each result object.
- *
- * @method parseResponse
- * @param sQuery {String} Query string.
- * @param oResponse {Object} The raw response data to parse.
- * @param oParent {Object} The object instance that has requested data.
- * @returns {Object[]} Array of result objects.
- */
-YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParent) {
- var aSchema = this.schema;
- var aResults = [];
- var bError = false;
-
- // Strip out comment at the end of results
- var nEnd = ((this.responseStripAfter !== "") && (oResponse.indexOf)) ?
- oResponse.indexOf(this.responseStripAfter) : -1;
- if(nEnd != -1) {
- oResponse = oResponse.substring(0,nEnd);
- }
-
- switch (this.responseType) {
- case YAHOO.widget.DS_XHR.TYPE_JSON:
- var jsonList;
- // Divert KHTML clients from JSON lib
- if(window.JSON && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) {
- // Use the JSON utility if available
- var jsonObjParsed = JSON.parse(oResponse);
- if(!jsonObjParsed) {
- bError = true;
- break;
- }
- else {
- try {
- // eval is necessary here since aSchema[0] is of unknown depth
- jsonList = eval("jsonObjParsed." + aSchema[0]);
- }
- catch(e) {
- bError = true;
- break;
- }
- }
- }
- else {
- // Parse the JSON response as a string
- try {
- // Trim leading spaces
- while (oResponse.substring(0,1) == " ") {
- oResponse = oResponse.substring(1, oResponse.length);
- }
-
- // Invalid JSON response
- if(oResponse.indexOf("{") < 0) {
- bError = true;
- break;
- }
-
- // Empty (but not invalid) JSON response
- if(oResponse.indexOf("{}") === 0) {
- break;
- }
-
- // Turn the string into an object literal...
- // ...eval is necessary here
- var jsonObjRaw = eval("(" + oResponse + ")");
- if(!jsonObjRaw) {
- bError = true;
- break;
- }
-
- // Grab the object member that contains an array of all reponses...
- // ...eval is necessary here since aSchema[0] is of unknown depth
- jsonList = eval("(jsonObjRaw." + aSchema[0]+")");
- }
- catch(e) {
- bError = true;
- break;
- }
- }
-
- if(!jsonList) {
- bError = true;
- break;
- }
-
- if(jsonList.constructor != Array) {
- jsonList = [jsonList];
- }
-
- // Loop through the array of all responses...
- for(var i = jsonList.length-1; i >= 0 ; i--) {
- var aResultItem = [];
- var jsonResult = jsonList[i];
- // ...and loop through each data field value of each response
- for(var j = aSchema.length-1; j >= 1 ; j--) {
- // ...and capture data into an array mapped according to the schema...
- var dataFieldValue = jsonResult[aSchema[j]];
- if(!dataFieldValue) {
- dataFieldValue = "";
- }
- //YAHOO.log("data: " + i + " value:" +j+" = "+dataFieldValue,"debug",this.toString());
- aResultItem.unshift(dataFieldValue);
- }
- // If schema isn't well defined, pass along the entire result object
- if(aResultItem.length == 1) {
- aResultItem.push(jsonResult);
- }
- // Capture the array of data field values in an array of results
- aResults.unshift(aResultItem);
- }
- break;
- case YAHOO.widget.DS_XHR.TYPE_XML:
- // Get the collection of results
- var xmlList = oResponse.getElementsByTagName(aSchema[0]);
- if(!xmlList) {
- bError = true;
- break;
- }
- // Loop through each result
- for(var k = xmlList.length-1; k >= 0 ; k--) {
- var result = xmlList.item(k);
- //YAHOO.log("Result"+k+" is "+result.attributes.item(0).firstChild.nodeValue,"debug",this.toString());
- var aFieldSet = [];
- // Loop through each data field in each result using the schema
- for(var m = aSchema.length-1; m >= 1 ; m--) {
- //YAHOO.log(aSchema[m]+" is "+result.attributes.getNamedItem(aSchema[m]).firstChild.nodeValue);
- var sValue = null;
- // Values may be held in an attribute...
- var xmlAttr = result.attributes.getNamedItem(aSchema[m]);
- if(xmlAttr) {
- sValue = xmlAttr.value;
- //YAHOO.log("Attr value is "+sValue,"debug",this.toString());
- }
- // ...or in a node
- else{
- var xmlNode = result.getElementsByTagName(aSchema[m]);
- if(xmlNode && xmlNode.item(0) && xmlNode.item(0).firstChild) {
- sValue = xmlNode.item(0).firstChild.nodeValue;
- //YAHOO.log("Node value is "+sValue,"debug",this.toString());
- }
- else {
- sValue = "";
- //YAHOO.log("Value not found","debug",this.toString());
- }
- }
- // Capture the schema-mapped data field values into an array
- aFieldSet.unshift(sValue);
- }
- // Capture each array of values into an array of results
- aResults.unshift(aFieldSet);
- }
- break;
- case YAHOO.widget.DS_XHR.TYPE_FLAT:
- if(oResponse.length > 0) {
- // Delete the last line delimiter at the end of the data if it exists
- var newLength = oResponse.length-aSchema[0].length;
- if(oResponse.substr(newLength) == aSchema[0]) {
- oResponse = oResponse.substr(0, newLength);
- }
- var aRecords = oResponse.split(aSchema[0]);
- for(var n = aRecords.length-1; n >= 0; n--) {
- aResults[n] = aRecords[n].split(aSchema[1]);
- }
- }
- break;
- default:
- break;
- }
- sQuery = null;
- oResponse = null;
- oParent = null;
- if(bError) {
- return null;
- }
- else {
- return aResults;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * XHR connection object.
- *
- * @property _oConn
- * @type Object
- * @private
- */
-YAHOO.widget.DS_XHR.prototype._oConn = null;
-
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using a native Javascript function as
- * its live data source.
- *
- * @class DS_JSFunction
- * @constructor
- * @extends YAHOO.widget.DataSource
- * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_JSFunction = function(oFunction, oConfigs) {
- // Set any config params passed in to override defaults
- if(typeof oConfigs == "object") {
- for(var sConfig in oConfigs) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
-
- // Initialization sequence
- if(!oFunction || (oFunction.constructor != Function)) {
- YAHOO.log("Could not instantiate JSFunction DataSource due to invalid arguments", "error", this.toString());
- return;
- }
- else {
- this.dataFunction = oFunction;
- this._init();
- YAHOO.log("JS Function DataSource initialized","info",this.toString());
- }
-};
-
-YAHOO.widget.DS_JSFunction.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * In-memory Javascript function that returns query results.
- *
- * @property dataFunction
- * @type HTMLFunction
- */
-YAHOO.widget.DS_JSFunction.prototype.dataFunction = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source defined by function for results. Results are
- * passed back to a callback function.
- *
- * @method doQuery
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DS_JSFunction.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- var oFunction = this.dataFunction;
- var aResults = [];
-
- aResults = oFunction(sQuery);
- if(aResults === null) {
- this.dataErrorEvent.fire(this, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
- YAHOO.log(YAHOO.widget.DataSource.ERROR_DATANULL, "error", this.toString());
- return;
- }
-
- var resultObj = {};
- resultObj.query = decodeURIComponent(sQuery);
- resultObj.results = aResults;
- this._addCacheElem(resultObj);
-
- this.getResultsEvent.fire(this, oParent, sQuery, aResults);
- oCallbackFn(sQuery, aResults, oParent);
- return;
-};
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using a native Javascript array as
- * its live data source.
- *
- * @class DS_JSArray
- * @constructor
- * @extends YAHOO.widget.DataSource
- * @param aData {String[]} In-memory Javascript array of simple string data.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_JSArray = function(aData, oConfigs) {
- // Set any config params passed in to override defaults
- if(typeof oConfigs == "object") {
- for(var sConfig in oConfigs) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
-
- // Initialization sequence
- if(!aData || (aData.constructor != Array)) {
- YAHOO.log("Could not instantiate JSArray DataSource due to invalid arguments", "error", this.toString());
- return;
- }
- else {
- this.data = aData;
- this._init();
- YAHOO.log("JS Array DataSource initialized","info",this.toString());
- }
-};
-
-YAHOO.widget.DS_JSArray.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * In-memory Javascript array of strings.
- *
- * @property data
- * @type Array
- */
-YAHOO.widget.DS_JSArray.prototype.data = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source defined by data for results. Results are passed
- * back to a callback function.
- *
- * @method doQuery
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- var aData = this.data; // the array
- var aResults = []; // container for results
- var bMatchFound = false;
- var bMatchContains = this.queryMatchContains;
- if(sQuery) {
- if(!this.queryMatchCase) {
- sQuery = sQuery.toLowerCase();
- }
-
- // Loop through each element of the array...
- // which can be a string or an array of strings
- for(var i = aData.length-1; i >= 0; i--) {
- var aDataset = [];
-
- if(aData[i]) {
- if(aData[i].constructor == String) {
- aDataset[0] = aData[i];
- }
- else if(aData[i].constructor == Array) {
- aDataset = aData[i];
- }
- }
-
- if(aDataset[0] && (aDataset[0].constructor == String)) {
- var sKeyIndex = (this.queryMatchCase) ?
- encodeURIComponent(aDataset[0]).indexOf(sQuery):
- encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);
-
- // A STARTSWITH match is when the query is found at the beginning of the key string...
- if((!bMatchContains && (sKeyIndex === 0)) ||
- // A CONTAINS match is when the query is found anywhere within the key string...
- (bMatchContains && (sKeyIndex > -1))) {
- // Stash a match into aResults[].
- aResults.unshift(aDataset);
- }
- }
- }
- }
-
- this.getResultsEvent.fire(this, oParent, sQuery, aResults);
- oCallbackFn(sQuery, aResults, oParent);
-};
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The DataSource classes manages sending a request and returning response from a live
+ * database. Supported data include local JavaScript arrays and objects and databases
+ * accessible via XHR connections. Supported response formats include JavaScript arrays,
+ * JSON, XML, and flat-file textual data.
+ *
+ * @class DataSource
+ * @constructor
+ */
+YAHOO.widget.DataSource = function() {
+ /* abstract class */
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public constants
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Error message for null data responses.
+ *
+ * @property ERROR_DATANULL
+ * @type String
+ * @static
+ * @final
+ */
+YAHOO.widget.DataSource.ERROR_DATANULL = "Response data was null";
+
+/**
+ * Error message for data responses with parsing errors.
+ *
+ * @property ERROR_DATAPARSE
+ * @type String
+ * @static
+ * @final
+ */
+YAHOO.widget.DataSource.ERROR_DATAPARSE = "Response data could not be parsed";
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Max size of the local cache. Set to 0 to turn off caching. Caching is
+ * useful to reduce the number of server connections. Recommended only for data
+ * sources that return comprehensive results for queries or when stale data is
+ * not an issue.
+ *
+ * @property maxCacheEntries
+ * @type Number
+ * @default 15
+ */
+YAHOO.widget.DataSource.prototype.maxCacheEntries = 15;
+
+/**
+ * Use this to equate cache matching with the type of matching done by your live
+ * data source. If caching is on and queryMatchContains is true, the cache
+ * returns results that "contain" the query string. By default,
+ * queryMatchContains is set to false, meaning the cache only returns results
+ * that "start with" the query string.
+ *
+ * @property queryMatchContains
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.DataSource.prototype.queryMatchContains = false;
+
+/**
+ * Enables query subset matching. If caching is on and queryMatchSubset is
+ * true, substrings of queries will return matching cached results. For
+ * instance, if the first query is for "abc" susequent queries that start with
+ * "abc", like "abcd", will be queried against the cache, and not the live data
+ * source. Recommended only for DataSources that return comprehensive results
+ * for queries with very few characters.
+ *
+ * @property queryMatchSubset
+ * @type Boolean
+ * @default false
+ *
+ */
+YAHOO.widget.DataSource.prototype.queryMatchSubset = false;
+
+/**
+ * Enables query case-sensitivity matching. If caching is on and
+ * queryMatchCase is true, queries will only return results for case-sensitive
+ * matches.
+ *
+ * @property queryMatchCase
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.DataSource.prototype.queryMatchCase = false;
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the DataSource instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the DataSource instance
+ */
+YAHOO.widget.DataSource.prototype.toString = function() {
+ return "DataSource " + this._sName;
+};
+
+/**
+ * Retrieves query results, first checking the local cache, then making the
+ * query request to the live data source as defined by the function doQuery.
+ *
+ * @method getResults
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DataSource.prototype.getResults = function(oCallbackFn, sQuery, oParent) {
+
+ // First look in cache
+ var aResults = this._doQueryCache(oCallbackFn,sQuery,oParent);
+
+ // Not in cache, so get results from server
+ if(aResults.length === 0) {
+ this.queryEvent.fire(this, oParent, sQuery);
+ this.doQuery(oCallbackFn, sQuery, oParent);
+ }
+};
+
+/**
+ * Abstract method implemented by subclasses to make a query to the live data
+ * source. Must call the callback function with the response returned from the
+ * query. Populates cache (if enabled).
+ *
+ * @method doQuery
+ * @param oCallbackFn {HTMLFunction} Callback function implemented by oParent to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ /* override this */
+};
+
+/**
+ * Flushes cache.
+ *
+ * @method flushCache
+ */
+YAHOO.widget.DataSource.prototype.flushCache = function() {
+ if(this._aCache) {
+ this._aCache = [];
+ }
+ if(this._aCacheHelper) {
+ this._aCacheHelper = [];
+ }
+ this.cacheFlushEvent.fire(this);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public events
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Fired when a query is made to the live data source.
+ *
+ * @event queryEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ */
+YAHOO.widget.DataSource.prototype.queryEvent = null;
+
+/**
+ * Fired when a query is made to the local cache.
+ *
+ * @event cacheQueryEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ */
+YAHOO.widget.DataSource.prototype.cacheQueryEvent = null;
+
+/**
+ * Fired when data is retrieved from the live data source.
+ *
+ * @event getResultsEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} Array of result objects.
+ */
+YAHOO.widget.DataSource.prototype.getResultsEvent = null;
+
+/**
+ * Fired when data is retrieved from the local cache.
+ *
+ * @event getCachedResultsEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} Array of result objects.
+ */
+YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null;
+
+/**
+ * Fired when an error is encountered with the live data source.
+ *
+ * @event dataErrorEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ * @param sMsg {String} Error message string
+ */
+YAHOO.widget.DataSource.prototype.dataErrorEvent = null;
+
+/**
+ * Fired when the local cache is flushed.
+ *
+ * @event cacheFlushEvent
+ * @param oSelf {Object} The DataSource instance
+ */
+YAHOO.widget.DataSource.prototype.cacheFlushEvent = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Internal class variable to index multiple DataSource instances.
+ *
+ * @property _nIndex
+ * @type Number
+ * @private
+ * @static
+ */
+YAHOO.widget.DataSource._nIndex = 0;
+
+/**
+ * Name of DataSource instance.
+ *
+ * @property _sName
+ * @type String
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._sName = null;
+
+/**
+ * Local cache of data result objects indexed chronologically.
+ *
+ * @property _aCache
+ * @type Object[]
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._aCache = null;
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Initializes DataSource instance.
+ *
+ * @method _init
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._init = function() {
+ // Validate and initialize public configs
+ var maxCacheEntries = this.maxCacheEntries;
+ if(isNaN(maxCacheEntries) || (maxCacheEntries < 0)) {
+ maxCacheEntries = 0;
+ }
+ // Initialize local cache
+ if(maxCacheEntries > 0 && !this._aCache) {
+ this._aCache = [];
+ }
+
+ this._sName = "instance" + YAHOO.widget.DataSource._nIndex;
+ YAHOO.widget.DataSource._nIndex++;
+
+ this.queryEvent = new YAHOO.util.CustomEvent("query", this);
+ this.cacheQueryEvent = new YAHOO.util.CustomEvent("cacheQuery", this);
+ this.getResultsEvent = new YAHOO.util.CustomEvent("getResults", this);
+ this.getCachedResultsEvent = new YAHOO.util.CustomEvent("getCachedResults", this);
+ this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
+ this.cacheFlushEvent = new YAHOO.util.CustomEvent("cacheFlush", this);
+};
+
+/**
+ * Adds a result object to the local cache, evicting the oldest element if the
+ * cache is full. Newer items will have higher indexes, the oldest item will have
+ * index of 0.
+ *
+ * @method _addCacheElem
+ * @param oResult {Object} Data result object, including array of results.
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._addCacheElem = function(oResult) {
+ var aCache = this._aCache;
+ // Don't add if anything important is missing.
+ if(!aCache || !oResult || !oResult.query || !oResult.results) {
+ return;
+ }
+
+ // If the cache is full, make room by removing from index=0
+ if(aCache.length >= this.maxCacheEntries) {
+ aCache.shift();
+ }
+
+ // Add to cache, at the end of the array
+ aCache.push(oResult);
+};
+
+/**
+ * Queries the local cache for results. If query has been cached, the callback
+ * function is called with the results, and the cached is refreshed so that it
+ * is now the newest element.
+ *
+ * @method _doQueryCache
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ * @return aResults {Object[]} Array of results from local cache if found, otherwise null.
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._doQueryCache = function(oCallbackFn, sQuery, oParent) {
+ var aResults = [];
+ var bMatchFound = false;
+ var aCache = this._aCache;
+ var nCacheLength = (aCache) ? aCache.length : 0;
+ var bMatchContains = this.queryMatchContains;
+
+ // If cache is enabled...
+ if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) {
+ this.cacheQueryEvent.fire(this, oParent, sQuery);
+ // If case is unimportant, normalize query now instead of in loops
+ if(!this.queryMatchCase) {
+ var sOrigQuery = sQuery;
+ sQuery = sQuery.toLowerCase();
+ }
+
+ // Loop through each cached element's query property...
+ for(var i = nCacheLength-1; i >= 0; i--) {
+ var resultObj = aCache[i];
+ var aAllResultItems = resultObj.results;
+ // If case is unimportant, normalize match key for comparison
+ var matchKey = (!this.queryMatchCase) ?
+ encodeURIComponent(resultObj.query).toLowerCase():
+ encodeURIComponent(resultObj.query);
+
+ // If a cached match key exactly matches the query...
+ if(matchKey == sQuery) {
+ // Stash all result objects into aResult[] and stop looping through the cache.
+ bMatchFound = true;
+ aResults = aAllResultItems;
+
+ // The matching cache element was not the most recent,
+ // so now we need to refresh the cache.
+ if(i != nCacheLength-1) {
+ // Remove element from its original location
+ aCache.splice(i,1);
+ // Add element as newest
+ this._addCacheElem(resultObj);
+ }
+ break;
+ }
+ // Else if this query is not an exact match and subset matching is enabled...
+ else if(this.queryMatchSubset) {
+ // Loop through substrings of each cached element's query property...
+ for(var j = sQuery.length-1; j >= 0 ; j--) {
+ var subQuery = sQuery.substr(0,j);
+
+ // If a substring of a cached sQuery exactly matches the query...
+ if(matchKey == subQuery) {
+ bMatchFound = true;
+
+ // Go through each cached result object to match against the query...
+ for(var k = aAllResultItems.length-1; k >= 0; k--) {
+ var aRecord = aAllResultItems[k];
+ var sKeyIndex = (this.queryMatchCase) ?
+ encodeURIComponent(aRecord[0]).indexOf(sQuery):
+ encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);
+
+ // A STARTSWITH match is when the query is found at the beginning of the key string...
+ if((!bMatchContains && (sKeyIndex === 0)) ||
+ // A CONTAINS match is when the query is found anywhere within the key string...
+ (bMatchContains && (sKeyIndex > -1))) {
+ // Stash a match into aResults[].
+ aResults.unshift(aRecord);
+ }
+ }
+
+ // Add the subset match result set object as the newest element to cache,
+ // and stop looping through the cache.
+ resultObj = {};
+ resultObj.query = sQuery;
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+ break;
+ }
+ }
+ if(bMatchFound) {
+ break;
+ }
+ }
+ }
+
+ // If there was a match, send along the results.
+ if(bMatchFound) {
+ this.getCachedResultsEvent.fire(this, oParent, sOrigQuery, aResults);
+ oCallbackFn(sOrigQuery, aResults, oParent);
+ }
+ }
+ return aResults;
+};
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using XML HTTP requests that return
+ * query results.
+ *
+ * @class DS_XHR
+ * @extends YAHOO.widget.DataSource
+ * @requires connection
+ * @constructor
+ * @param sScriptURI {String} Absolute or relative URI to script that returns query
+ * results as JSON, XML, or delimited flat-file data.
+ * @param aSchema {String[]} Data schema definition of results.
+ * @param oConfigs {Object} (optional) Object literal of config params.
+ */
+YAHOO.widget.DS_XHR = function(sScriptURI, aSchema, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!aSchema || (aSchema.constructor != Array)) {
+ YAHOO.log("Could not instantiate XHR DataSource due to invalid arguments", "error", this.toString());
+ return;
+ }
+ else {
+ this.schema = aSchema;
+ }
+ this.scriptURI = sScriptURI;
+ this._init();
+ YAHOO.log("XHR DataSource initialized","info",this.toString());
+};
+
+YAHOO.widget.DS_XHR.prototype = new YAHOO.widget.DataSource();
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public constants
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * JSON data type.
+ *
+ * @property TYPE_JSON
+ * @type Number
+ * @static
+ * @final
+ */
+YAHOO.widget.DS_XHR.TYPE_JSON = 0;
+
+/**
+ * XML data type.
+ *
+ * @property TYPE_XML
+ * @type Number
+ * @static
+ * @final
+ */
+YAHOO.widget.DS_XHR.TYPE_XML = 1;
+
+/**
+ * Flat-file data type.
+ *
+ * @property TYPE_FLAT
+ * @type Number
+ * @static
+ * @final
+ */
+YAHOO.widget.DS_XHR.TYPE_FLAT = 2;
+
+/**
+ * Error message for XHR failure.
+ *
+ * @property ERROR_DATAXHR
+ * @type String
+ * @static
+ * @final
+ */
+YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed";
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Alias to YUI Connection Manager. Allows implementers to specify their own
+ * subclasses of the YUI Connection Manager utility.
+ *
+ * @property connMgr
+ * @type Object
+ * @default YAHOO.util.Connect
+ */
+YAHOO.widget.DS_XHR.prototype.connMgr = YAHOO.util.Connect;
+
+/**
+ * Number of milliseconds the XHR connection will wait for a server response. A
+ * a value of zero indicates the XHR connection will wait forever. Any value
+ * greater than zero will use the Connection utility's Auto-Abort feature.
+ *
+ * @property connTimeout
+ * @type Number
+ * @default 0
+ */
+YAHOO.widget.DS_XHR.prototype.connTimeout = 0;
+
+/**
+ * Absolute or relative URI to script that returns query results. For instance,
+ * queries will be sent to <scriptURI>?<scriptQueryParam>=userinput
+ *
+ * @property scriptURI
+ * @type String
+ */
+YAHOO.widget.DS_XHR.prototype.scriptURI = null;
+
+/**
+ * Query string parameter name sent to scriptURI. For instance, queries will be
+ * sent to <scriptURI>?<scriptQueryParam>=userinput
+ *
+ * @property scriptQueryParam
+ * @type String
+ * @default "query"
+ */
+YAHOO.widget.DS_XHR.prototype.scriptQueryParam = "query";
+
+/**
+ * String of key/value pairs to append to requests made to scriptURI. Define
+ * this string when you want to send additional query parameters to your script.
+ * When defined, queries will be sent to
+ * <scriptURI>?<scriptQueryParam>=userinput&<scriptQueryAppend>
+ *
+ * @property scriptQueryAppend
+ * @type String
+ * @default ""
+ */
+YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = "";
+
+/**
+ * XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML
+ * and YAHOO.widget.DS_XHR.TYPE_FLAT.
+ *
+ * @property responseType
+ * @type String
+ * @default YAHOO.widget.DS_XHR.TYPE_JSON
+ */
+YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.TYPE_JSON;
+
+/**
+ * String after which to strip results. If the results from the XHR are sent
+ * back as HTML, the gzip HTML comment appears at the end of the data and should
+ * be ignored.
+ *
+ * @property responseStripAfter
+ * @type String
+ * @default "\n<!-"
+ */
+YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n 0) {
+ sUri += "&" + this.scriptQueryAppend;
+ }
+ YAHOO.log("DataSource is querying URL " + sUri, "info", this.toString());
+ var oResponse = null;
+
+ var oSelf = this;
+ /*
+ * Sets up ajax request callback
+ *
+ * @param {object} oReq HTTPXMLRequest object
+ * @private
+ */
+ var responseSuccess = function(oResp) {
+ // Response ID does not match last made request ID.
+ if(!oSelf._oConn || (oResp.tId != oSelf._oConn.tId)) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
+ YAHOO.log(YAHOO.widget.DataSource.ERROR_DATANULL, "error", this.toString());
+ return;
+ }
+//DEBUG
+/*YAHOO.log(oResp.responseXML.getElementsByTagName("Result"),'warn');
+for(var foo in oResp) {
+ YAHOO.log(foo + ": "+oResp[foo],'warn');
+}
+YAHOO.log('responseXML.xml: '+oResp.responseXML.xml,'warn');*/
+ if(!isXML) {
+ oResp = oResp.responseText;
+ }
+ else {
+ oResp = oResp.responseXML;
+ }
+ if(oResp === null) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
+ YAHOO.log(YAHOO.widget.DataSource.ERROR_DATANULL, "error", oSelf.toString());
+ return;
+ }
+
+ var aResults = oSelf.parseResponse(sQuery, oResp, oParent);
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ if(aResults === null) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATAPARSE);
+ YAHOO.log(YAHOO.widget.DataSource.ERROR_DATAPARSE, "error", oSelf.toString());
+ aResults = [];
+ }
+ else {
+ oSelf.getResultsEvent.fire(oSelf, oParent, sQuery, aResults);
+ oSelf._addCacheElem(resultObj);
+ }
+ oCallbackFn(sQuery, aResults, oParent);
+ };
+
+ var responseFailure = function(oResp) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DS_XHR.ERROR_DATAXHR);
+ YAHOO.log(YAHOO.widget.DS_XHR.ERROR_DATAXHR + ": " + oResp.statusText, "error", oSelf.toString());
+ return;
+ };
+
+ var oCallback = {
+ success:responseSuccess,
+ failure:responseFailure
+ };
+
+ if(!isNaN(this.connTimeout) && this.connTimeout > 0) {
+ oCallback.timeout = this.connTimeout;
+ }
+
+ if(this._oConn) {
+ this.connMgr.abort(this._oConn);
+ }
+
+ oSelf._oConn = this.connMgr.asyncRequest("GET", sUri, oCallback, null);
+};
+
+/**
+ * Parses raw response data into an array of result objects. The result data key
+ * is always stashed in the [0] element of each result object.
+ *
+ * @method parseResponse
+ * @param sQuery {String} Query string.
+ * @param oResponse {Object} The raw response data to parse.
+ * @param oParent {Object} The object instance that has requested data.
+ * @returns {Object[]} Array of result objects.
+ */
+YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParent) {
+ var aSchema = this.schema;
+ var aResults = [];
+ var bError = false;
+
+ // Strip out comment at the end of results
+ var nEnd = ((this.responseStripAfter !== "") && (oResponse.indexOf)) ?
+ oResponse.indexOf(this.responseStripAfter) : -1;
+ if(nEnd != -1) {
+ oResponse = oResponse.substring(0,nEnd);
+ }
+
+ switch (this.responseType) {
+ case YAHOO.widget.DS_XHR.TYPE_JSON:
+ var jsonList;
+ // Divert KHTML clients from JSON lib
+ if(window.JSON && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) {
+ // Use the JSON utility if available
+ var jsonObjParsed = JSON.parse(oResponse);
+ if(!jsonObjParsed) {
+ bError = true;
+ break;
+ }
+ else {
+ try {
+ // eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("jsonObjParsed." + aSchema[0]);
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+ }
+ else {
+ // Parse the JSON response as a string
+ try {
+ // Trim leading spaces
+ while (oResponse.substring(0,1) == " ") {
+ oResponse = oResponse.substring(1, oResponse.length);
+ }
+
+ // Invalid JSON response
+ if(oResponse.indexOf("{") < 0) {
+ bError = true;
+ break;
+ }
+
+ // Empty (but not invalid) JSON response
+ if(oResponse.indexOf("{}") === 0) {
+ break;
+ }
+
+ // Turn the string into an object literal...
+ // ...eval is necessary here
+ var jsonObjRaw = eval("(" + oResponse + ")");
+ if(!jsonObjRaw) {
+ bError = true;
+ break;
+ }
+
+ // Grab the object member that contains an array of all reponses...
+ // ...eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("(jsonObjRaw." + aSchema[0]+")");
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+
+ if(!jsonList) {
+ bError = true;
+ break;
+ }
+
+ if(jsonList.constructor != Array) {
+ jsonList = [jsonList];
+ }
+
+ // Loop through the array of all responses...
+ for(var i = jsonList.length-1; i >= 0 ; i--) {
+ var aResultItem = [];
+ var jsonResult = jsonList[i];
+ // ...and loop through each data field value of each response
+ for(var j = aSchema.length-1; j >= 1 ; j--) {
+ // ...and capture data into an array mapped according to the schema...
+ var dataFieldValue = jsonResult[aSchema[j]];
+ if(!dataFieldValue) {
+ dataFieldValue = "";
+ }
+ //YAHOO.log("data: " + i + " value:" +j+" = "+dataFieldValue,"debug",this.toString());
+ aResultItem.unshift(dataFieldValue);
+ }
+ // If schema isn't well defined, pass along the entire result object
+ if(aResultItem.length == 1) {
+ aResultItem.push(jsonResult);
+ }
+ // Capture the array of data field values in an array of results
+ aResults.unshift(aResultItem);
+ }
+ break;
+ case YAHOO.widget.DS_XHR.TYPE_XML:
+ // Get the collection of results
+ var xmlList = oResponse.getElementsByTagName(aSchema[0]);
+ if(!xmlList) {
+ bError = true;
+ break;
+ }
+ // Loop through each result
+ for(var k = xmlList.length-1; k >= 0 ; k--) {
+ var result = xmlList.item(k);
+ //YAHOO.log("Result"+k+" is "+result.attributes.item(0).firstChild.nodeValue,"debug",this.toString());
+ var aFieldSet = [];
+ // Loop through each data field in each result using the schema
+ for(var m = aSchema.length-1; m >= 1 ; m--) {
+ //YAHOO.log(aSchema[m]+" is "+result.attributes.getNamedItem(aSchema[m]).firstChild.nodeValue);
+ var sValue = null;
+ // Values may be held in an attribute...
+ var xmlAttr = result.attributes.getNamedItem(aSchema[m]);
+ if(xmlAttr) {
+ sValue = xmlAttr.value;
+ //YAHOO.log("Attr value is "+sValue,"debug",this.toString());
+ }
+ // ...or in a node
+ else{
+ var xmlNode = result.getElementsByTagName(aSchema[m]);
+ if(xmlNode && xmlNode.item(0) && xmlNode.item(0).firstChild) {
+ sValue = xmlNode.item(0).firstChild.nodeValue;
+ //YAHOO.log("Node value is "+sValue,"debug",this.toString());
+ }
+ else {
+ sValue = "";
+ //YAHOO.log("Value not found","debug",this.toString());
+ }
+ }
+ // Capture the schema-mapped data field values into an array
+ aFieldSet.unshift(sValue);
+ }
+ // Capture each array of values into an array of results
+ aResults.unshift(aFieldSet);
+ }
+ break;
+ case YAHOO.widget.DS_XHR.TYPE_FLAT:
+ if(oResponse.length > 0) {
+ // Delete the last line delimiter at the end of the data if it exists
+ var newLength = oResponse.length-aSchema[0].length;
+ if(oResponse.substr(newLength) == aSchema[0]) {
+ oResponse = oResponse.substr(0, newLength);
+ }
+ var aRecords = oResponse.split(aSchema[0]);
+ for(var n = aRecords.length-1; n >= 0; n--) {
+ aResults[n] = aRecords[n].split(aSchema[1]);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ sQuery = null;
+ oResponse = null;
+ oParent = null;
+ if(bError) {
+ return null;
+ }
+ else {
+ return aResults;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * XHR connection object.
+ *
+ * @property _oConn
+ * @type Object
+ * @private
+ */
+YAHOO.widget.DS_XHR.prototype._oConn = null;
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using a native Javascript function as
+ * its live data source.
+ *
+ * @class DS_JSFunction
+ * @constructor
+ * @extends YAHOO.widget.DataSource
+ * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects.
+ * @param oConfigs {Object} (optional) Object literal of config params.
+ */
+YAHOO.widget.DS_JSFunction = function(oFunction, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!oFunction || (oFunction.constructor != Function)) {
+ YAHOO.log("Could not instantiate JSFunction DataSource due to invalid arguments", "error", this.toString());
+ return;
+ }
+ else {
+ this.dataFunction = oFunction;
+ this._init();
+ YAHOO.log("JS Function DataSource initialized","info",this.toString());
+ }
+};
+
+YAHOO.widget.DS_JSFunction.prototype = new YAHOO.widget.DataSource();
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * In-memory Javascript function that returns query results.
+ *
+ * @property dataFunction
+ * @type HTMLFunction
+ */
+YAHOO.widget.DS_JSFunction.prototype.dataFunction = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Queries the live data source defined by function for results. Results are
+ * passed back to a callback function.
+ *
+ * @method doQuery
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DS_JSFunction.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var oFunction = this.dataFunction;
+ var aResults = [];
+
+ aResults = oFunction(sQuery);
+ if(aResults === null) {
+ this.dataErrorEvent.fire(this, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
+ YAHOO.log(YAHOO.widget.DataSource.ERROR_DATANULL, "error", this.toString());
+ return;
+ }
+
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ oCallbackFn(sQuery, aResults, oParent);
+ return;
+};
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using a native Javascript array as
+ * its live data source.
+ *
+ * @class DS_JSArray
+ * @constructor
+ * @extends YAHOO.widget.DataSource
+ * @param aData {String[]} In-memory Javascript array of simple string data.
+ * @param oConfigs {Object} (optional) Object literal of config params.
+ */
+YAHOO.widget.DS_JSArray = function(aData, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!aData || (aData.constructor != Array)) {
+ YAHOO.log("Could not instantiate JSArray DataSource due to invalid arguments", "error", this.toString());
+ return;
+ }
+ else {
+ this.data = aData;
+ this._init();
+ YAHOO.log("JS Array DataSource initialized","info",this.toString());
+ }
+};
+
+YAHOO.widget.DS_JSArray.prototype = new YAHOO.widget.DataSource();
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * In-memory Javascript array of strings.
+ *
+ * @property data
+ * @type Array
+ */
+YAHOO.widget.DS_JSArray.prototype.data = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Queries the live data source defined by data for results. Results are passed
+ * back to a callback function.
+ *
+ * @method doQuery
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var aData = this.data; // the array
+ var aResults = []; // container for results
+ var bMatchFound = false;
+ var bMatchContains = this.queryMatchContains;
+ if(sQuery) {
+ if(!this.queryMatchCase) {
+ sQuery = sQuery.toLowerCase();
+ }
+
+ // Loop through each element of the array...
+ // which can be a string or an array of strings
+ for(var i = aData.length-1; i >= 0; i--) {
+ var aDataset = [];
+
+ if(aData[i]) {
+ if(aData[i].constructor == String) {
+ aDataset[0] = aData[i];
+ }
+ else if(aData[i].constructor == Array) {
+ aDataset = aData[i];
+ }
+ }
+
+ if(aDataset[0] && (aDataset[0].constructor == String)) {
+ var sKeyIndex = (this.queryMatchCase) ?
+ encodeURIComponent(aDataset[0]).indexOf(sQuery):
+ encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);
+
+ // A STARTSWITH match is when the query is found at the beginning of the key string...
+ if((!bMatchContains && (sKeyIndex === 0)) ||
+ // A CONTAINS match is when the query is found anywhere within the key string...
+ (bMatchContains && (sKeyIndex > -1))) {
+ // Stash a match into aResults[].
+ aResults.unshift(aDataset);
+ }
+ }
+ }
+ }
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ oCallbackFn(sQuery, aResults, oParent);
+};
diff --git a/lib/yui/autocomplete/autocomplete-min.js b/lib/yui/autocomplete/autocomplete-min.js
index 4d03d7dc74..91bba0312c 100755
--- a/lib/yui/autocomplete/autocomplete-min.js
+++ b/lib/yui/autocomplete/autocomplete-min.js
@@ -1,178 +1,183 @@
-/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.txt version: 0.12.1 */
-
-YAHOO.widget.AutoComplete=function(elInput,elContainer,oDataSource,oConfigs){if(elInput&&elContainer&&oDataSource){if(oDataSource&&(oDataSource instanceof YAHOO.widget.DataSource)){this.dataSource=oDataSource;}
-else{return;}
-if(YAHOO.util.Dom.inDocument(elInput)){if(typeof elInput=="string"){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput;this._oTextbox=document.getElementById(elInput);}
-else{this._sName=(elInput.id)?"instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput.id:"instance"+YAHOO.widget.AutoComplete._nIndex;this._oTextbox=elInput;}}
-else{return;}
-if(YAHOO.util.Dom.inDocument(elContainer)){if(typeof elContainer=="string"){this._oContainer=document.getElementById(elContainer);}
-else{this._oContainer=elContainer;}
-if(this._oContainer.style.display=="none"){}}
-else{return;}
-if(typeof oConfigs=="object"){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}}
-this._initContainer();this._initProps();this._initList();this._initContainerHelpers();var oSelf=this;var oTextbox=this._oTextbox;var oContent=this._oContainer._oContent;YAHOO.util.Event.addListener(oTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);YAHOO.util.Event.addListener(oTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);YAHOO.util.Event.addListener(oTextbox,"focus",oSelf._onTextboxFocus,oSelf);YAHOO.util.Event.addListener(oTextbox,"blur",oSelf._onTextboxBlur,oSelf);YAHOO.util.Event.addListener(oContent,"mouseover",oSelf._onContainerMouseover,oSelf);YAHOO.util.Event.addListener(oContent,"mouseout",oSelf._onContainerMouseout,oSelf);YAHOO.util.Event.addListener(oContent,"scroll",oSelf._onContainerScroll,oSelf);YAHOO.util.Event.addListener(oContent,"resize",oSelf._onContainerResize,oSelf);if(oTextbox.form){YAHOO.util.Event.addListener(oTextbox.form,"submit",oSelf._onFormSubmit,oSelf);}
-YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);this.textboxFocusEvent=new YAHOO.util.CustomEvent("textboxFocus",this);this.textboxKeyEvent=new YAHOO.util.CustomEvent("textboxKey",this);this.dataRequestEvent=new YAHOO.util.CustomEvent("dataRequest",this);this.dataReturnEvent=new YAHOO.util.CustomEvent("dataReturn",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.containerExpandEvent=new YAHOO.util.CustomEvent("containerExpand",this);this.typeAheadEvent=new YAHOO.util.CustomEvent("typeAhead",this);this.itemMouseOverEvent=new YAHOO.util.CustomEvent("itemMouseOver",this);this.itemMouseOutEvent=new YAHOO.util.CustomEvent("itemMouseOut",this);this.itemArrowToEvent=new YAHOO.util.CustomEvent("itemArrowTo",this);this.itemArrowFromEvent=new YAHOO.util.CustomEvent("itemArrowFrom",this);this.itemSelectEvent=new YAHOO.util.CustomEvent("itemSelect",this);this.unmatchedItemSelectEvent=new YAHOO.util.CustomEvent("unmatchedItemSelect",this);this.selectionEnforceEvent=new YAHOO.util.CustomEvent("selectionEnforce",this);this.containerCollapseEvent=new YAHOO.util.CustomEvent("containerCollapse",this);this.textboxBlurEvent=new YAHOO.util.CustomEvent("textboxBlur",this);oTextbox.setAttribute("autocomplete","off");YAHOO.widget.AutoComplete._nIndex++;}
-else{}};YAHOO.widget.AutoComplete.prototype.dataSource=null;YAHOO.widget.AutoComplete.prototype.minQueryLength=1;YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed=10;YAHOO.widget.AutoComplete.prototype.queryDelay=0.5;YAHOO.widget.AutoComplete.prototype.highlightClassName="yui-ac-highlight";YAHOO.widget.AutoComplete.prototype.prehighlightClassName=null;YAHOO.widget.AutoComplete.prototype.delimChar=null;YAHOO.widget.AutoComplete.prototype.autoHighlight=true;YAHOO.widget.AutoComplete.prototype.typeAhead=false;YAHOO.widget.AutoComplete.prototype.animHoriz=false;YAHOO.widget.AutoComplete.prototype.animVert=true;YAHOO.widget.AutoComplete.prototype.animSpeed=0.3;YAHOO.widget.AutoComplete.prototype.forceSelection=false;YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete=true;YAHOO.widget.AutoComplete.prototype.alwaysShowContainer=false;YAHOO.widget.AutoComplete.prototype.useIFrame=false;YAHOO.widget.AutoComplete.prototype.useShadow=false;YAHOO.widget.AutoComplete.prototype.toString=function(){return"AutoComplete "+this._sName;};YAHOO.widget.AutoComplete.prototype.isContainerOpen=function(){return this._bContainerOpen;};YAHOO.widget.AutoComplete.prototype.getListItems=function(){return this._aListItems;};YAHOO.widget.AutoComplete.prototype.getListItemData=function(oListItem){if(oListItem._oResultData){return oListItem._oResultData;}
-else{return false;}};YAHOO.widget.AutoComplete.prototype.setHeader=function(sHeader){if(sHeader){if(this._oContainer._oContent._oHeader){this._oContainer._oContent._oHeader.innerHTML=sHeader;this._oContainer._oContent._oHeader.style.display="block";}}
-else{this._oContainer._oContent._oHeader.innerHTML="";this._oContainer._oContent._oHeader.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setFooter=function(sFooter){if(sFooter){if(this._oContainer._oContent._oFooter){this._oContainer._oContent._oFooter.innerHTML=sFooter;this._oContainer._oContent._oFooter.style.display="block";}}
-else{this._oContainer._oContent._oFooter.innerHTML="";this._oContainer._oContent._oFooter.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setBody=function(sBody){if(sBody){if(this._oContainer._oContent._oBody){this._oContainer._oContent._oBody.innerHTML=sBody;this._oContainer._oContent._oBody.style.display="block";this._oContainer._oContent.style.display="block";}}
-else{this._oContainer._oContent._oBody.innerHTML="";this._oContainer._oContent.style.display="none";}
-this._maxResultsDisplayed=0;};YAHOO.widget.AutoComplete.prototype.formatResult=function(oResultItem,sQuery){var sResult=oResultItem[0];if(sResult){return sResult;}
-else{return"";}};YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer=function(oResultItem,sQuery){return true;};YAHOO.widget.AutoComplete.prototype.sendQuery=function(sQuery){this._sendQuery(sQuery);};YAHOO.widget.AutoComplete.prototype.textboxFocusEvent=null;YAHOO.widget.AutoComplete.prototype.textboxKeyEvent=null;YAHOO.widget.AutoComplete.prototype.dataRequestEvent=null;YAHOO.widget.AutoComplete.prototype.dataReturnEvent=null;YAHOO.widget.AutoComplete.prototype.dataErrorEvent=null;YAHOO.widget.AutoComplete.prototype.containerExpandEvent=null;YAHOO.widget.AutoComplete.prototype.typeAheadEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowToEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent=null;YAHOO.widget.AutoComplete.prototype.itemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent=null;YAHOO.widget.AutoComplete.prototype.containerCollapseEvent=null;YAHOO.widget.AutoComplete.prototype.textboxBlurEvent=null;YAHOO.widget.AutoComplete._nIndex=0;YAHOO.widget.AutoComplete.prototype._sName=null;YAHOO.widget.AutoComplete.prototype._oTextbox=null;YAHOO.widget.AutoComplete.prototype._bFocused=true;YAHOO.widget.AutoComplete.prototype._oAnim=null;YAHOO.widget.AutoComplete.prototype._oContainer=null;YAHOO.widget.AutoComplete.prototype._bContainerOpen=false;YAHOO.widget.AutoComplete.prototype._bOverContainer=false;YAHOO.widget.AutoComplete.prototype._aListItems=null;YAHOO.widget.AutoComplete.prototype._nDisplayedItems=0;YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed=0;YAHOO.widget.AutoComplete.prototype._sCurQuery=null;YAHOO.widget.AutoComplete.prototype._sSavedQuery=null;YAHOO.widget.AutoComplete.prototype._oCurItem=null;YAHOO.widget.AutoComplete.prototype._bItemSelected=false;YAHOO.widget.AutoComplete.prototype._nKeyCode=null;YAHOO.widget.AutoComplete.prototype._nDelayID=-1;YAHOO.widget.AutoComplete.prototype._iFrameSrc="javascript:false;";YAHOO.widget.AutoComplete.prototype._queryInterval=null;YAHOO.widget.AutoComplete.prototype._sLastTextboxValue=null;YAHOO.widget.AutoComplete.prototype._initProps=function(){var minQueryLength=this.minQueryLength;if(isNaN(minQueryLength)||(minQueryLength<1)){minQueryLength=1;}
-var maxResultsDisplayed=this.maxResultsDisplayed;if(isNaN(this.maxResultsDisplayed)||(this.maxResultsDisplayed<1)){this.maxResultsDisplayed=10;}
-var queryDelay=this.queryDelay;if(isNaN(this.queryDelay)||(this.queryDelay<0)){this.queryDelay=0.5;}
-var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){if(typeof aDelimChar=="string"){this.delimChar=[aDelimChar];}
-else if(aDelimChar.constructor!=Array){this.delimChar=null;}}
-var animSpeed=this.animSpeed;if((this.animHoriz||this.animVert)&&YAHOO.util.Anim){if(isNaN(animSpeed)||(animSpeed<0)){animSpeed=0.3;}
-if(!this._oAnim){oAnim=new YAHOO.util.Anim(this._oContainer._oContent,{},this.animSpeed);this._oAnim=oAnim;}
-else{this._oAnim.duration=animSpeed;}}
-if(this.forceSelection&&this.delimChar){}};YAHOO.widget.AutoComplete.prototype._initContainerHelpers=function(){if(this.useShadow&&!this._oContainer._oShadow){var oShadow=document.createElement("div");oShadow.className="yui-ac-shadow";this._oContainer._oShadow=this._oContainer.appendChild(oShadow);}
-if(this.useIFrame&&!this._oContainer._oIFrame){var oIFrame=document.createElement("iframe");oIFrame.src=this._iFrameSrc;oIFrame.frameBorder=0;oIFrame.scrolling="no";oIFrame.style.position="absolute";oIFrame.style.width="100%";oIFrame.style.height="100%";oIFrame.tabIndex=-1;this._oContainer._oIFrame=this._oContainer.appendChild(oIFrame);}};YAHOO.widget.AutoComplete.prototype._initContainer=function(){if(!this._oContainer._oContent){var oContent=document.createElement("div");oContent.className="yui-ac-content";oContent.style.display="none";this._oContainer._oContent=this._oContainer.appendChild(oContent);var oHeader=document.createElement("div");oHeader.className="yui-ac-hd";oHeader.style.display="none";this._oContainer._oContent._oHeader=this._oContainer._oContent.appendChild(oHeader);var oBody=document.createElement("div");oBody.className="yui-ac-bd";this._oContainer._oContent._oBody=this._oContainer._oContent.appendChild(oBody);var oFooter=document.createElement("div");oFooter.className="yui-ac-ft";oFooter.style.display="none";this._oContainer._oContent._oFooter=this._oContainer._oContent.appendChild(oFooter);}
-else{}};YAHOO.widget.AutoComplete.prototype._initList=function(){this._aListItems=[];while(this._oContainer._oContent._oBody.hasChildNodes()){var oldListItems=this.getListItems();if(oldListItems){for(var oldi=oldListItems.length-1;oldi>=0;i--){oldListItems[oldi]=null;}}
-this._oContainer._oContent._oBody.innerHTML="";}
-var oList=document.createElement("ul");oList=this._oContainer._oContent._oBody.appendChild(oList);for(var i=0;i=18&&nKeyCode<=20)||(nKeyCode==27)||(nKeyCode>=33&&nKeyCode<=35)||(nKeyCode>=36&&nKeyCode<=38)||(nKeyCode==40)||(nKeyCode>=44&&nKeyCode<=45)){return true;}
-return false;};YAHOO.widget.AutoComplete.prototype._sendQuery=function(sQuery){if(this.minQueryLength==-1){this._toggleContainer(false);return;}
-var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){var nDelimIndex=-1;for(var i=aDelimChar.length-1;i>=0;i--){var nNewIndex=sQuery.lastIndexOf(aDelimChar[i]);if(nNewIndex>nDelimIndex){nDelimIndex=nNewIndex;}}
-if(aDelimChar[i]==" "){for(var j=aDelimChar.length-1;j>=0;j--){if(sQuery[nDelimIndex-1]==aDelimChar[j]){nDelimIndex--;break;}}}
-if(nDelimIndex>-1){var nQueryStart=nDelimIndex+1;while(sQuery.charAt(nQueryStart)==" "){nQueryStart+=1;}
-this._sSavedQuery=sQuery.substring(0,nQueryStart);sQuery=sQuery.substr(nQueryStart);}
-else if(sQuery.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}}
-if(sQuery&&(sQuery.length0)){if(this._nDelayID!=-1){clearTimeout(this._nDelayID);}
-this._toggleContainer(false);return;}
-sQuery=encodeURIComponent(sQuery);this._nDelayID=-1;this.dataRequestEvent.fire(this,sQuery);this.dataSource.getResults(this._populateList,sQuery,this);};YAHOO.widget.AutoComplete.prototype._populateList=function(sQuery,aResults,oSelf){if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,sQuery);}
-if(!oSelf._bFocused||!aResults){return;}
-var isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);var contentStyle=oSelf._oContainer._oContent.style;contentStyle.width=(!isOpera)?null:"";contentStyle.height=(!isOpera)?null:"";var sCurQuery=decodeURIComponent(sQuery);oSelf._sCurQuery=sCurQuery;oSelf._bItemSelected=false;if(oSelf._maxResultsDisplayed!=oSelf.maxResultsDisplayed){oSelf._initList();}
-var nItems=Math.min(aResults.length,oSelf.maxResultsDisplayed);oSelf._nDisplayedItems=nItems;if(nItems>0){oSelf._initContainerHelpers();var aItems=oSelf._aListItems;for(var i=nItems-1;i>=0;i--){var oItemi=aItems[i];var oResultItemi=aResults[i];oItemi.innerHTML=oSelf.formatResult(oResultItemi,sCurQuery);oItemi.style.display="list-item";oItemi._sResultKey=oResultItemi[0];oItemi._oResultData=oResultItemi;}
-for(var j=aItems.length-1;j>=nItems;j--){var oItemj=aItems[j];oItemj.innerHTML=null;oItemj.style.display="none";oItemj._sResultKey=null;oItemj._oResultData=null;}
-if(oSelf.autoHighlight){var oFirstItem=aItems[0];oSelf._toggleHighlight(oFirstItem,"to");oSelf.itemArrowToEvent.fire(oSelf,oFirstItem);oSelf._typeAhead(oFirstItem,sQuery);}
-else{oSelf._oCurItem=null;}
-var ok=oSelf.doBeforeExpandContainer(oSelf._oTextbox,oSelf._oContainer,sQuery,aResults);oSelf._toggleContainer(ok);}
-else{oSelf._toggleContainer(false);}
-oSelf.dataReturnEvent.fire(oSelf,sQuery,aResults);};YAHOO.widget.AutoComplete.prototype._clearSelection=function(){var sValue=this._oTextbox.value;var sChar=(this.delimChar)?this.delimChar[0]:null;var nIndex=(sChar)?sValue.lastIndexOf(sChar,sValue.length-2):-1;if(nIndex>-1){this._oTextbox.value=sValue.substring(0,nIndex);}
-else{this._oTextbox.value="";}
-this._sSavedQuery=this._oTextbox.value;this.selectionEnforceEvent.fire(this);};YAHOO.widget.AutoComplete.prototype._textMatchesOption=function(){var foundMatch=false;for(var i=this._nDisplayedItems-1;i>=0;i--){var oItem=this._aListItems[i];var sMatch=oItem._sResultKey.toLowerCase();if(sMatch==this._sCurQuery.toLowerCase()){foundMatch=true;break;}}
-return(foundMatch);};YAHOO.widget.AutoComplete.prototype._typeAhead=function(oItem,sQuery){if(!this.typeAhead||(this._nKeyCode==8)){return;}
-var oTextbox=this._oTextbox;var sValue=this._oTextbox.value;if(!oTextbox.setSelectionRange&&!oTextbox.createTextRange){return;}
-var nStart=sValue.length;this._updateValue(oItem);var nEnd=oTextbox.value.length;this._selectText(oTextbox,nStart,nEnd);var sPrefill=oTextbox.value.substr(nStart,nEnd);this.typeAheadEvent.fire(this,sQuery,sPrefill);};YAHOO.widget.AutoComplete.prototype._selectText=function(oTextbox,nStart,nEnd){if(oTextbox.setSelectionRange){oTextbox.setSelectionRange(nStart,nEnd);}
-else if(oTextbox.createTextRange){var oTextRange=oTextbox.createTextRange();oTextRange.moveStart("character",nStart);oTextRange.moveEnd("character",nEnd-oTextbox.value.length);oTextRange.select();}
-else{oTextbox.select();}};YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers=function(bShow){var bFireEvent=false;var width=this._oContainer._oContent.offsetWidth+"px";var height=this._oContainer._oContent.offsetHeight+"px";if(this.useIFrame&&this._oContainer._oIFrame){bFireEvent=true;if(bShow){this._oContainer._oIFrame.style.width=width;this._oContainer._oIFrame.style.height=height;}
-else{this._oContainer._oIFrame.style.width=0;this._oContainer._oIFrame.style.height=0;}}
-if(this.useShadow&&this._oContainer._oShadow){bFireEvent=true;if(bShow){this._oContainer._oShadow.style.width=width;this._oContainer._oShadow.style.height=height;}
-else{this._oContainer._oShadow.style.width=0;this._oContainer._oShadow.style.height=0;}}};YAHOO.widget.AutoComplete.prototype._toggleContainer=function(bShow){var oContainer=this._oContainer;if(this.alwaysShowContainer&&this._bContainerOpen){return;}
-if(!bShow){this._oContainer._oContent.scrollTop=0;var aItems=this._aListItems;if(aItems&&(aItems.length>0)){for(var i=aItems.length-1;i>=0;i--){aItems[i].style.display="none";}}
-if(this._oCurItem){this._toggleHighlight(this._oCurItem,"from");}
-this._oCurItem=null;this._nDisplayedItems=0;this._sCurQuery=null;}
-if(!bShow&&!this._bContainerOpen){oContainer._oContent.style.display="none";return;}
-var oAnim=this._oAnim;if(oAnim&&oAnim.getEl()&&(this.animHoriz||this.animVert)){if(!bShow){this._toggleContainerHelpers(bShow);}
-if(oAnim.isAnimated()){oAnim.stop();}
-var oClone=oContainer._oContent.cloneNode(true);oContainer.appendChild(oClone);oClone.style.top="-9000px";oClone.style.display="block";var wExp=oClone.offsetWidth;var hExp=oClone.offsetHeight;var wColl=(this.animHoriz)?0:wExp;var hColl=(this.animVert)?0:hExp;oAnim.attributes=(bShow)?{width:{to:wExp},height:{to:hExp}}:{width:{to:wColl},height:{to:hColl}};if(bShow&&!this._bContainerOpen){oContainer._oContent.style.width=wColl+"px";oContainer._oContent.style.height=hColl+"px";}
-else{oContainer._oContent.style.width=wExp+"px";oContainer._oContent.style.height=hExp+"px";}
-oContainer.removeChild(oClone);oClone=null;var oSelf=this;var onAnimComplete=function(){oAnim.onComplete.unsubscribeAll();if(bShow){oSelf.containerExpandEvent.fire(oSelf);}
-else{oContainer._oContent.style.display="none";oSelf.containerCollapseEvent.fire(oSelf);}
-oSelf._toggleContainerHelpers(bShow);};oContainer._oContent.style.display="block";oAnim.onComplete.subscribe(onAnimComplete);oAnim.animate();this._bContainerOpen=bShow;}
-else{if(bShow){oContainer._oContent.style.display="block";this.containerExpandEvent.fire(this);}
-else{oContainer._oContent.style.display="none";this.containerCollapseEvent.fire(this);}
-this._toggleContainerHelpers(bShow);this._bContainerOpen=bShow;}};YAHOO.widget.AutoComplete.prototype._toggleHighlight=function(oNewItem,sType){var sHighlight=this.highlightClassName;if(this._oCurItem){YAHOO.util.Dom.removeClass(this._oCurItem,sHighlight);}
-if((sType=="to")&&sHighlight){YAHOO.util.Dom.addClass(oNewItem,sHighlight);this._oCurItem=oNewItem;}};YAHOO.widget.AutoComplete.prototype._togglePrehighlight=function(oNewItem,sType){if(oNewItem==this._oCurItem){return;}
-var sPrehighlight=this.prehighlightClassName;if((sType=="mouseover")&&sPrehighlight){YAHOO.util.Dom.addClass(oNewItem,sPrehighlight);}
-else{YAHOO.util.Dom.removeClass(oNewItem,sPrehighlight);}};YAHOO.widget.AutoComplete.prototype._updateValue=function(oItem){var oTextbox=this._oTextbox;var sDelimChar=(this.delimChar)?(this.delimChar[0]||this.delimChar):null;var sSavedQuery=this._sSavedQuery;var sResultKey=oItem._sResultKey;oTextbox.focus();oTextbox.value="";if(sDelimChar){if(sSavedQuery){oTextbox.value=sSavedQuery;}
-oTextbox.value+=sResultKey+sDelimChar;if(sDelimChar!=" "){oTextbox.value+=" ";}}
-else{oTextbox.value=sResultKey;}
-if(oTextbox.type=="textarea"){oTextbox.scrollTop=oTextbox.scrollHeight;}
-var end=oTextbox.value.length;this._selectText(oTextbox,end,end);this._oCurItem=oItem;};YAHOO.widget.AutoComplete.prototype._selectItem=function(oItem){this._bItemSelected=true;this._updateValue(oItem);this._cancelIntervalDetection(this);this.itemSelectEvent.fire(this,oItem,oItem._oResultData);this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(!this.typeAhead){return;}
-else{this._toggleContainer(false);}};YAHOO.widget.AutoComplete.prototype._moveSelection=function(nKeyCode){if(this._bContainerOpen){var oCurItem=this._oCurItem;var nCurItemIndex=-1;if(oCurItem){nCurItemIndex=oCurItem._nItemIndex;}
-var nNewItemIndex=(nKeyCode==40)?(nCurItemIndex+1):(nCurItemIndex-1);if(nNewItemIndex<-2||nNewItemIndex>=this._nDisplayedItems){return;}
-if(oCurItem){this._toggleHighlight(oCurItem,"from");this.itemArrowFromEvent.fire(this,oCurItem);}
-if(nNewItemIndex==-1){if(this.delimChar&&this._sSavedQuery){if(!this._textMatchesOption()){this._oTextbox.value=this._sSavedQuery;}
-else{this._oTextbox.value=this._sSavedQuery+this._sCurQuery;}}
-else{this._oTextbox.value=this._sCurQuery;}
-this._oCurItem=null;return;}
-if(nNewItemIndex==-2){this._toggleContainer(false);return;}
-var oNewItem=this._aListItems[nNewItemIndex];var oContent=this._oContainer._oContent;var scrollOn=((YAHOO.util.Dom.getStyle(oContent,"overflow")=="auto")||(YAHOO.util.Dom.getStyle(oContent,"overflowY")=="auto"));if(scrollOn&&(nNewItemIndex>-1)&&(nNewItemIndex(oContent.scrollTop+oContent.offsetHeight)){oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;}
-else if((oNewItem.offsetTop+oNewItem.offsetHeight)(oContent.scrollTop+oContent.offsetHeight)){this._oContainer._oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;}}}
-this._toggleHighlight(oNewItem,"to");this.itemArrowToEvent.fire(this,oNewItem);if(this.typeAhead){this._updateValue(oNewItem);}}};YAHOO.widget.AutoComplete.prototype._onItemMouseover=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseover");}
-else{oSelf._toggleHighlight(this,"to");}
-oSelf.itemMouseOverEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseout=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseout");}
-else{oSelf._toggleHighlight(this,"from");}
-oSelf.itemMouseOutEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseclick=function(v,oSelf){oSelf._toggleHighlight(this,"to");oSelf._selectItem(this);};YAHOO.widget.AutoComplete.prototype._onContainerMouseover=function(v,oSelf){oSelf._bOverContainer=true;};YAHOO.widget.AutoComplete.prototype._onContainerMouseout=function(v,oSelf){oSelf._bOverContainer=false;if(oSelf._oCurItem){oSelf._toggleHighlight(oSelf._oCurItem,"to");}};YAHOO.widget.AutoComplete.prototype._onContainerScroll=function(v,oSelf){oSelf._oTextbox.focus();};YAHOO.widget.AutoComplete.prototype._onContainerResize=function(v,oSelf){oSelf._toggleContainerHelpers(oSelf._bContainerOpen);};YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown=function(v,oSelf){var nKeyCode=v.keyCode;switch(nKeyCode){case 9:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
-if(oSelf._oCurItem){oSelf._selectItem(oSelf._oCurItem);}
-else{oSelf._toggleContainer(false);}
-break;case 13:if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
-if(oSelf._oCurItem){oSelf._selectItem(oSelf._oCurItem);}
-else{oSelf._toggleContainer(false);}
-break;case 27:oSelf._toggleContainer(false);return;case 39:oSelf._jumpSelection();break;case 38:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;case 40:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;default:break;}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress=function(v,oSelf){var nKeyCode=v.keyCode;var isMac=(navigator.userAgent.toLowerCase().indexOf("mac")!=-1);if(isMac){switch(nKeyCode){case 9:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
-break;case 13:if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
-break;case 38:case 40:YAHOO.util.Event.stopEvent(v);break;default:break;}}
-else if(nKeyCode==229){oSelf._queryInterval=setInterval(function(){oSelf._onIMEDetected(oSelf);},500);}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp=function(v,oSelf){oSelf._initProps();var nKeyCode=v.keyCode;oSelf._nKeyCode=nKeyCode;var sText=this.value;if(oSelf._isIgnoreKey(nKeyCode)||(sText.toLowerCase()==oSelf._sCurQuery)){return;}
-else{oSelf.textboxKeyEvent.fire(oSelf,nKeyCode);}
-if(oSelf.queryDelay>0){var nDelayID=setTimeout(function(){oSelf._sendQuery(sText);},(oSelf.queryDelay*1000));if(oSelf._nDelayID!=-1){clearTimeout(oSelf._nDelayID);}
-oSelf._nDelayID=nDelayID;}
-else{oSelf._sendQuery(sText);}};YAHOO.widget.AutoComplete.prototype._onTextboxFocus=function(v,oSelf){oSelf._oTextbox.setAttribute("autocomplete","off");oSelf._bFocused=true;oSelf.textboxFocusEvent.fire(oSelf);};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(v,oSelf){if(!oSelf._bOverContainer||(oSelf._nKeyCode==9)){if(!oSelf._bItemSelected){if(!oSelf._bContainerOpen||(oSelf._bContainerOpen&&!oSelf._textMatchesOption())){if(oSelf.forceSelection){oSelf._clearSelection();}
-else{oSelf.unmatchedItemSelectEvent.fire(oSelf,oSelf._sCurQuery);}}}
-if(oSelf._bContainerOpen){oSelf._toggleContainer(false);}
-oSelf._cancelIntervalDetection(oSelf);oSelf._bFocused=false;oSelf.textboxBlurEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onFormSubmit=function(v,oSelf){if(oSelf.allowBrowserAutocomplete){oSelf._oTextbox.setAttribute("autocomplete","on");}
-else{oSelf._oTextbox.setAttribute("autocomplete","off");}};YAHOO.widget.DataSource=function(){};YAHOO.widget.DataSource.ERROR_DATANULL="Response data was null";YAHOO.widget.DataSource.ERROR_DATAPARSE="Response data could not be parsed";YAHOO.widget.DataSource.prototype.maxCacheEntries=15;YAHOO.widget.DataSource.prototype.queryMatchContains=false;YAHOO.widget.DataSource.prototype.queryMatchSubset=false;YAHOO.widget.DataSource.prototype.queryMatchCase=false;YAHOO.widget.DataSource.prototype.toString=function(){return"DataSource "+this._sName;};YAHOO.widget.DataSource.prototype.getResults=function(oCallbackFn,sQuery,oParent){var aResults=this._doQueryCache(oCallbackFn,sQuery,oParent);if(aResults.length===0){this.queryEvent.fire(this,oParent,sQuery);this.doQuery(oCallbackFn,sQuery,oParent);}};YAHOO.widget.DataSource.prototype.doQuery=function(oCallbackFn,sQuery,oParent){};YAHOO.widget.DataSource.prototype.flushCache=function(){if(this._aCache){this._aCache=[];}
-if(this._aCacheHelper){this._aCacheHelper=[];}
-this.cacheFlushEvent.fire(this);};YAHOO.widget.DataSource.prototype.queryEvent=null;YAHOO.widget.DataSource.prototype.cacheQueryEvent=null;YAHOO.widget.DataSource.prototype.getResultsEvent=null;YAHOO.widget.DataSource.prototype.getCachedResultsEvent=null;YAHOO.widget.DataSource.prototype.dataErrorEvent=null;YAHOO.widget.DataSource.prototype.cacheFlushEvent=null;YAHOO.widget.DataSource._nIndex=0;YAHOO.widget.DataSource.prototype._sName=null;YAHOO.widget.DataSource.prototype._aCache=null;YAHOO.widget.DataSource.prototype._init=function(){var maxCacheEntries=this.maxCacheEntries;if(isNaN(maxCacheEntries)||(maxCacheEntries<0)){maxCacheEntries=0;}
-if(maxCacheEntries>0&&!this._aCache){this._aCache=[];}
-this._sName="instance"+YAHOO.widget.DataSource._nIndex;YAHOO.widget.DataSource._nIndex++;this.queryEvent=new YAHOO.util.CustomEvent("query",this);this.cacheQueryEvent=new YAHOO.util.CustomEvent("cacheQuery",this);this.getResultsEvent=new YAHOO.util.CustomEvent("getResults",this);this.getCachedResultsEvent=new YAHOO.util.CustomEvent("getCachedResults",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.cacheFlushEvent=new YAHOO.util.CustomEvent("cacheFlush",this);};YAHOO.widget.DataSource.prototype._addCacheElem=function(oResult){var aCache=this._aCache;if(!aCache||!oResult||!oResult.query||!oResult.results){return;}
-if(aCache.length>=this.maxCacheEntries){aCache.shift();}
-aCache.push(oResult);};YAHOO.widget.DataSource.prototype._doQueryCache=function(oCallbackFn,sQuery,oParent){var aResults=[];var bMatchFound=false;var aCache=this._aCache;var nCacheLength=(aCache)?aCache.length:0;var bMatchContains=this.queryMatchContains;if((this.maxCacheEntries>0)&&aCache&&(nCacheLength>0)){this.cacheQueryEvent.fire(this,oParent,sQuery);if(!this.queryMatchCase){var sOrigQuery=sQuery;sQuery=sQuery.toLowerCase();}
-for(var i=nCacheLength-1;i>=0;i--){var resultObj=aCache[i];var aAllResultItems=resultObj.results;var matchKey=(!this.queryMatchCase)?encodeURIComponent(resultObj.query).toLowerCase():encodeURIComponent(resultObj.query);if(matchKey==sQuery){bMatchFound=true;aResults=aAllResultItems;if(i!=nCacheLength-1){aCache.splice(i,1);this._addCacheElem(resultObj);}
-break;}
-else if(this.queryMatchSubset){for(var j=sQuery.length-1;j>=0;j--){var subQuery=sQuery.substr(0,j);if(matchKey==subQuery){bMatchFound=true;for(var k=aAllResultItems.length-1;k>=0;k--){var aRecord=aAllResultItems[k];var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aRecord[0]).indexOf(sQuery):encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aRecord);}}
-resultObj={};resultObj.query=sQuery;resultObj.results=aResults;this._addCacheElem(resultObj);break;}}
-if(bMatchFound){break;}}}
-if(bMatchFound){this.getCachedResultsEvent.fire(this,oParent,sOrigQuery,aResults);oCallbackFn(sOrigQuery,aResults,oParent);}}
-return aResults;};YAHOO.widget.DS_XHR=function(sScriptURI,aSchema,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
-if(!aSchema||(aSchema.constructor!=Array)){return;}
-else{this.schema=aSchema;}
-this.scriptURI=sScriptURI;this._init();};YAHOO.widget.DS_XHR.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_XHR.TYPE_JSON=0;YAHOO.widget.DS_XHR.TYPE_XML=1;YAHOO.widget.DS_XHR.TYPE_FLAT=2;YAHOO.widget.DS_XHR.ERROR_DATAXHR="XHR response failed";YAHOO.widget.DS_XHR.prototype.connMgr=YAHOO.util.Connect;YAHOO.widget.DS_XHR.prototype.connTimeout=0;YAHOO.widget.DS_XHR.prototype.scriptURI=null;YAHOO.widget.DS_XHR.prototype.scriptQueryParam="query";YAHOO.widget.DS_XHR.prototype.scriptQueryAppend="";YAHOO.widget.DS_XHR.prototype.responseType=YAHOO.widget.DS_XHR.TYPE_JSON;YAHOO.widget.DS_XHR.prototype.responseStripAfter="\n0){sUri+="&"+this.scriptQueryAppend;}
-var oResponse=null;var oSelf=this;var responseSuccess=function(oResp){if(!oSelf._oConn||(oResp.tId!=oSelf._oConn.tId)){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
-for(var foo in oResp){}
-if(!isXML){oResp=oResp.responseText;}
-else{oResp=oResp.responseXML;}
-if(oResp===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
-var aResults=oSelf.parseResponse(sQuery,oResp,oParent);var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATAPARSE);aResults=[];}
-else{oSelf.getResultsEvent.fire(oSelf,oParent,sQuery,aResults);oSelf._addCacheElem(resultObj);}
-oCallbackFn(sQuery,aResults,oParent);};var responseFailure=function(oResp){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DS_XHR.ERROR_DATAXHR);return;};var oCallback={success:responseSuccess,failure:responseFailure};if(!isNaN(this.connTimeout)&&this.connTimeout>0){oCallback.timeout=this.connTimeout;}
-if(this._oConn){this.connMgr.abort(this._oConn);}
-oSelf._oConn=this.connMgr.asyncRequest("GET",sUri,oCallback,null);};YAHOO.widget.DS_XHR.prototype.parseResponse=function(sQuery,oResponse,oParent){var aSchema=this.schema;var aResults=[];var bError=false;var nEnd=((this.responseStripAfter!=="")&&(oResponse.indexOf))?oResponse.indexOf(this.responseStripAfter):-1;if(nEnd!=-1){oResponse=oResponse.substring(0,nEnd);}
-switch(this.responseType){case YAHOO.widget.DS_XHR.TYPE_JSON:var jsonList;if(window.JSON&&(navigator.userAgent.toLowerCase().indexOf('khtml')==-1)){var jsonObjParsed=JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;}
-else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}
-catch(e){bError=true;break;}}}
-else{try{while(oResponse.substring(0,1)==" "){oResponse=oResponse.substring(1,oResponse.length);}
-if(oResponse.indexOf("{")<0){bError=true;break;}
-if(oResponse.indexOf("{}")===0){break;}
-var jsonObjRaw=eval("("+oResponse+")");if(!jsonObjRaw){bError=true;break;}
-jsonList=eval("(jsonObjRaw."+aSchema[0]+")");}
-catch(e){bError=true;break;}}
-if(!jsonList){bError=true;break;}
-if(jsonList.constructor!=Array){jsonList=[jsonList];}
-for(var i=jsonList.length-1;i>=0;i--){var aResultItem=[];var jsonResult=jsonList[i];for(var j=aSchema.length-1;j>=1;j--){var dataFieldValue=jsonResult[aSchema[j]];if(!dataFieldValue){dataFieldValue="";}
-aResultItem.unshift(dataFieldValue);}
-if(aResultItem.length==1){aResultItem.push(jsonResult);}
-aResults.unshift(aResultItem);}
-break;case YAHOO.widget.DS_XHR.TYPE_XML:var xmlList=oResponse.getElementsByTagName(aSchema[0]);if(!xmlList){bError=true;break;}
-for(var k=xmlList.length-1;k>=0;k--){var result=xmlList.item(k);var aFieldSet=[];for(var m=aSchema.length-1;m>=1;m--){var sValue=null;var xmlAttr=result.attributes.getNamedItem(aSchema[m]);if(xmlAttr){sValue=xmlAttr.value;}
-else{var xmlNode=result.getElementsByTagName(aSchema[m]);if(xmlNode&&xmlNode.item(0)&&xmlNode.item(0).firstChild){sValue=xmlNode.item(0).firstChild.nodeValue;}
-else{sValue="";}}
-aFieldSet.unshift(sValue);}
-aResults.unshift(aFieldSet);}
-break;case YAHOO.widget.DS_XHR.TYPE_FLAT:if(oResponse.length>0){var newLength=oResponse.length-aSchema[0].length;if(oResponse.substr(newLength)==aSchema[0]){oResponse=oResponse.substr(0,newLength);}
-var aRecords=oResponse.split(aSchema[0]);for(var n=aRecords.length-1;n>=0;n--){aResults[n]=aRecords[n].split(aSchema[1]);}}
-break;default:break;}
-sQuery=null;oResponse=null;oParent=null;if(bError){return null;}
-else{return aResults;}};YAHOO.widget.DS_XHR.prototype._oConn=null;YAHOO.widget.DS_JSFunction=function(oFunction,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
-if(!oFunction||(oFunction.constructor!=Function)){return;}
-else{this.dataFunction=oFunction;this._init();}};YAHOO.widget.DS_JSFunction.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSFunction.prototype.dataFunction=null;YAHOO.widget.DS_JSFunction.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var oFunction=this.dataFunction;var aResults=[];aResults=oFunction(sQuery);if(aResults===null){this.dataErrorEvent.fire(this,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
-var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;this._addCacheElem(resultObj);this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);return;};YAHOO.widget.DS_JSArray=function(aData,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
-if(!aData||(aData.constructor!=Array)){return;}
-else{this.data=aData;this._init();}};YAHOO.widget.DS_JSArray.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSArray.prototype.data=null;YAHOO.widget.DS_JSArray.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var aData=this.data;var aResults=[];var bMatchFound=false;var bMatchContains=this.queryMatchContains;if(sQuery){if(!this.queryMatchCase){sQuery=sQuery.toLowerCase();}
-for(var i=aData.length-1;i>=0;i--){var aDataset=[];if(aData[i]){if(aData[i].constructor==String){aDataset[0]=aData[i];}
-else if(aData[i].constructor==Array){aDataset=aData[i];}}
-if(aDataset[0]&&(aDataset[0].constructor==String)){var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aDataset[0]).indexOf(sQuery):encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aDataset);}}}}
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+
+YAHOO.widget.AutoComplete=function(elInput,elContainer,oDataSource,oConfigs){if(elInput&&elContainer&&oDataSource){if(oDataSource&&(oDataSource instanceof YAHOO.widget.DataSource)){this.dataSource=oDataSource;}
+else{return;}
+if(YAHOO.util.Dom.inDocument(elInput)){if(typeof elInput=="string"){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput;this._oTextbox=document.getElementById(elInput);}
+else{this._sName=(elInput.id)?"instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput.id:"instance"+YAHOO.widget.AutoComplete._nIndex;this._oTextbox=elInput;}}
+else{return;}
+if(YAHOO.util.Dom.inDocument(elContainer)){if(typeof elContainer=="string"){this._oContainer=document.getElementById(elContainer);}
+else{this._oContainer=elContainer;}
+if(this._oContainer.style.display=="none"){}}
+else{return;}
+if(typeof oConfigs=="object"){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}}
+this._initContainer();this._initProps();this._initList();this._initContainerHelpers();var oSelf=this;var oTextbox=this._oTextbox;var oContent=this._oContainer._oContent;YAHOO.util.Event.addListener(oTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);YAHOO.util.Event.addListener(oTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);YAHOO.util.Event.addListener(oTextbox,"focus",oSelf._onTextboxFocus,oSelf);YAHOO.util.Event.addListener(oTextbox,"blur",oSelf._onTextboxBlur,oSelf);YAHOO.util.Event.addListener(oContent,"mouseover",oSelf._onContainerMouseover,oSelf);YAHOO.util.Event.addListener(oContent,"mouseout",oSelf._onContainerMouseout,oSelf);YAHOO.util.Event.addListener(oContent,"scroll",oSelf._onContainerScroll,oSelf);YAHOO.util.Event.addListener(oContent,"resize",oSelf._onContainerResize,oSelf);if(oTextbox.form){YAHOO.util.Event.addListener(oTextbox.form,"submit",oSelf._onFormSubmit,oSelf);}
+YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);this.textboxFocusEvent=new YAHOO.util.CustomEvent("textboxFocus",this);this.textboxKeyEvent=new YAHOO.util.CustomEvent("textboxKey",this);this.dataRequestEvent=new YAHOO.util.CustomEvent("dataRequest",this);this.dataReturnEvent=new YAHOO.util.CustomEvent("dataReturn",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.containerExpandEvent=new YAHOO.util.CustomEvent("containerExpand",this);this.typeAheadEvent=new YAHOO.util.CustomEvent("typeAhead",this);this.itemMouseOverEvent=new YAHOO.util.CustomEvent("itemMouseOver",this);this.itemMouseOutEvent=new YAHOO.util.CustomEvent("itemMouseOut",this);this.itemArrowToEvent=new YAHOO.util.CustomEvent("itemArrowTo",this);this.itemArrowFromEvent=new YAHOO.util.CustomEvent("itemArrowFrom",this);this.itemSelectEvent=new YAHOO.util.CustomEvent("itemSelect",this);this.unmatchedItemSelectEvent=new YAHOO.util.CustomEvent("unmatchedItemSelect",this);this.selectionEnforceEvent=new YAHOO.util.CustomEvent("selectionEnforce",this);this.containerCollapseEvent=new YAHOO.util.CustomEvent("containerCollapse",this);this.textboxBlurEvent=new YAHOO.util.CustomEvent("textboxBlur",this);oTextbox.setAttribute("autocomplete","off");YAHOO.widget.AutoComplete._nIndex++;}
+else{}};YAHOO.widget.AutoComplete.prototype.dataSource=null;YAHOO.widget.AutoComplete.prototype.minQueryLength=1;YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed=10;YAHOO.widget.AutoComplete.prototype.queryDelay=0.5;YAHOO.widget.AutoComplete.prototype.highlightClassName="yui-ac-highlight";YAHOO.widget.AutoComplete.prototype.prehighlightClassName=null;YAHOO.widget.AutoComplete.prototype.delimChar=null;YAHOO.widget.AutoComplete.prototype.autoHighlight=true;YAHOO.widget.AutoComplete.prototype.typeAhead=false;YAHOO.widget.AutoComplete.prototype.animHoriz=false;YAHOO.widget.AutoComplete.prototype.animVert=true;YAHOO.widget.AutoComplete.prototype.animSpeed=0.3;YAHOO.widget.AutoComplete.prototype.forceSelection=false;YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete=true;YAHOO.widget.AutoComplete.prototype.alwaysShowContainer=false;YAHOO.widget.AutoComplete.prototype.useIFrame=false;YAHOO.widget.AutoComplete.prototype.useShadow=false;YAHOO.widget.AutoComplete.prototype.toString=function(){return"AutoComplete "+this._sName;};YAHOO.widget.AutoComplete.prototype.isContainerOpen=function(){return this._bContainerOpen;};YAHOO.widget.AutoComplete.prototype.getListItems=function(){return this._aListItems;};YAHOO.widget.AutoComplete.prototype.getListItemData=function(oListItem){if(oListItem._oResultData){return oListItem._oResultData;}
+else{return false;}};YAHOO.widget.AutoComplete.prototype.setHeader=function(sHeader){if(sHeader){if(this._oContainer._oContent._oHeader){this._oContainer._oContent._oHeader.innerHTML=sHeader;this._oContainer._oContent._oHeader.style.display="block";}}
+else{this._oContainer._oContent._oHeader.innerHTML="";this._oContainer._oContent._oHeader.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setFooter=function(sFooter){if(sFooter){if(this._oContainer._oContent._oFooter){this._oContainer._oContent._oFooter.innerHTML=sFooter;this._oContainer._oContent._oFooter.style.display="block";}}
+else{this._oContainer._oContent._oFooter.innerHTML="";this._oContainer._oContent._oFooter.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setBody=function(sBody){if(sBody){if(this._oContainer._oContent._oBody){this._oContainer._oContent._oBody.innerHTML=sBody;this._oContainer._oContent._oBody.style.display="block";this._oContainer._oContent.style.display="block";}}
+else{this._oContainer._oContent._oBody.innerHTML="";this._oContainer._oContent.style.display="none";}
+this._maxResultsDisplayed=0;};YAHOO.widget.AutoComplete.prototype.formatResult=function(oResultItem,sQuery){var sResult=oResultItem[0];if(sResult){return sResult;}
+else{return"";}};YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer=function(oResultItem,sQuery){return true;};YAHOO.widget.AutoComplete.prototype.sendQuery=function(sQuery){this._sendQuery(sQuery);};YAHOO.widget.AutoComplete.prototype.textboxFocusEvent=null;YAHOO.widget.AutoComplete.prototype.textboxKeyEvent=null;YAHOO.widget.AutoComplete.prototype.dataRequestEvent=null;YAHOO.widget.AutoComplete.prototype.dataReturnEvent=null;YAHOO.widget.AutoComplete.prototype.dataErrorEvent=null;YAHOO.widget.AutoComplete.prototype.containerExpandEvent=null;YAHOO.widget.AutoComplete.prototype.typeAheadEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowToEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent=null;YAHOO.widget.AutoComplete.prototype.itemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent=null;YAHOO.widget.AutoComplete.prototype.containerCollapseEvent=null;YAHOO.widget.AutoComplete.prototype.textboxBlurEvent=null;YAHOO.widget.AutoComplete._nIndex=0;YAHOO.widget.AutoComplete.prototype._sName=null;YAHOO.widget.AutoComplete.prototype._oTextbox=null;YAHOO.widget.AutoComplete.prototype._bFocused=true;YAHOO.widget.AutoComplete.prototype._oAnim=null;YAHOO.widget.AutoComplete.prototype._oContainer=null;YAHOO.widget.AutoComplete.prototype._bContainerOpen=false;YAHOO.widget.AutoComplete.prototype._bOverContainer=false;YAHOO.widget.AutoComplete.prototype._aListItems=null;YAHOO.widget.AutoComplete.prototype._nDisplayedItems=0;YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed=0;YAHOO.widget.AutoComplete.prototype._sCurQuery=null;YAHOO.widget.AutoComplete.prototype._sSavedQuery=null;YAHOO.widget.AutoComplete.prototype._oCurItem=null;YAHOO.widget.AutoComplete.prototype._bItemSelected=false;YAHOO.widget.AutoComplete.prototype._nKeyCode=null;YAHOO.widget.AutoComplete.prototype._nDelayID=-1;YAHOO.widget.AutoComplete.prototype._iFrameSrc="javascript:false;";YAHOO.widget.AutoComplete.prototype._queryInterval=null;YAHOO.widget.AutoComplete.prototype._sLastTextboxValue=null;YAHOO.widget.AutoComplete.prototype._initProps=function(){var minQueryLength=this.minQueryLength;if(isNaN(minQueryLength)||(minQueryLength<1)){minQueryLength=1;}
+var maxResultsDisplayed=this.maxResultsDisplayed;if(isNaN(this.maxResultsDisplayed)||(this.maxResultsDisplayed<1)){this.maxResultsDisplayed=10;}
+var queryDelay=this.queryDelay;if(isNaN(this.queryDelay)||(this.queryDelay<0)){this.queryDelay=0.5;}
+var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){if(typeof aDelimChar=="string"){this.delimChar=[aDelimChar];}
+else if(aDelimChar.constructor!=Array){this.delimChar=null;}}
+var animSpeed=this.animSpeed;if((this.animHoriz||this.animVert)&&YAHOO.util.Anim){if(isNaN(animSpeed)||(animSpeed<0)){animSpeed=0.3;}
+if(!this._oAnim){oAnim=new YAHOO.util.Anim(this._oContainer._oContent,{},this.animSpeed);this._oAnim=oAnim;}
+else{this._oAnim.duration=animSpeed;}}
+if(this.forceSelection&&this.delimChar){}};YAHOO.widget.AutoComplete.prototype._initContainerHelpers=function(){if(this.useShadow&&!this._oContainer._oShadow){var oShadow=document.createElement("div");oShadow.className="yui-ac-shadow";this._oContainer._oShadow=this._oContainer.appendChild(oShadow);}
+if(this.useIFrame&&!this._oContainer._oIFrame){var oIFrame=document.createElement("iframe");oIFrame.src=this._iFrameSrc;oIFrame.frameBorder=0;oIFrame.scrolling="no";oIFrame.style.position="absolute";oIFrame.style.width="100%";oIFrame.style.height="100%";oIFrame.tabIndex=-1;this._oContainer._oIFrame=this._oContainer.appendChild(oIFrame);}};YAHOO.widget.AutoComplete.prototype._initContainer=function(){if(!this._oContainer._oContent){var oContent=document.createElement("div");oContent.className="yui-ac-content";oContent.style.display="none";this._oContainer._oContent=this._oContainer.appendChild(oContent);var oHeader=document.createElement("div");oHeader.className="yui-ac-hd";oHeader.style.display="none";this._oContainer._oContent._oHeader=this._oContainer._oContent.appendChild(oHeader);var oBody=document.createElement("div");oBody.className="yui-ac-bd";this._oContainer._oContent._oBody=this._oContainer._oContent.appendChild(oBody);var oFooter=document.createElement("div");oFooter.className="yui-ac-ft";oFooter.style.display="none";this._oContainer._oContent._oFooter=this._oContainer._oContent.appendChild(oFooter);}
+else{}};YAHOO.widget.AutoComplete.prototype._initList=function(){this._aListItems=[];while(this._oContainer._oContent._oBody.hasChildNodes()){var oldListItems=this.getListItems();if(oldListItems){for(var oldi=oldListItems.length-1;oldi>=0;i--){oldListItems[oldi]=null;}}
+this._oContainer._oContent._oBody.innerHTML="";}
+var oList=document.createElement("ul");oList=this._oContainer._oContent._oBody.appendChild(oList);for(var i=0;i=18&&nKeyCode<=20)||(nKeyCode==27)||(nKeyCode>=33&&nKeyCode<=35)||(nKeyCode>=36&&nKeyCode<=38)||(nKeyCode==40)||(nKeyCode>=44&&nKeyCode<=45)){return true;}
+return false;};YAHOO.widget.AutoComplete.prototype._sendQuery=function(sQuery){if(this.minQueryLength==-1){this._toggleContainer(false);return;}
+var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){var nDelimIndex=-1;for(var i=aDelimChar.length-1;i>=0;i--){var nNewIndex=sQuery.lastIndexOf(aDelimChar[i]);if(nNewIndex>nDelimIndex){nDelimIndex=nNewIndex;}}
+if(aDelimChar[i]==" "){for(var j=aDelimChar.length-1;j>=0;j--){if(sQuery[nDelimIndex-1]==aDelimChar[j]){nDelimIndex--;break;}}}
+if(nDelimIndex>-1){var nQueryStart=nDelimIndex+1;while(sQuery.charAt(nQueryStart)==" "){nQueryStart+=1;}
+this._sSavedQuery=sQuery.substring(0,nQueryStart);sQuery=sQuery.substr(nQueryStart);}
+else if(sQuery.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}}
+if(sQuery&&(sQuery.length0)){if(this._nDelayID!=-1){clearTimeout(this._nDelayID);}
+this._toggleContainer(false);return;}
+sQuery=encodeURIComponent(sQuery);this._nDelayID=-1;this.dataRequestEvent.fire(this,sQuery);this.dataSource.getResults(this._populateList,sQuery,this);};YAHOO.widget.AutoComplete.prototype._populateList=function(sQuery,aResults,oSelf){if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,sQuery);}
+if(!oSelf._bFocused||!aResults){return;}
+var isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);var contentStyle=oSelf._oContainer._oContent.style;contentStyle.width=(!isOpera)?null:"";contentStyle.height=(!isOpera)?null:"";var sCurQuery=decodeURIComponent(sQuery);oSelf._sCurQuery=sCurQuery;oSelf._bItemSelected=false;if(oSelf._maxResultsDisplayed!=oSelf.maxResultsDisplayed){oSelf._initList();}
+var nItems=Math.min(aResults.length,oSelf.maxResultsDisplayed);oSelf._nDisplayedItems=nItems;if(nItems>0){oSelf._initContainerHelpers();var aItems=oSelf._aListItems;for(var i=nItems-1;i>=0;i--){var oItemi=aItems[i];var oResultItemi=aResults[i];oItemi.innerHTML=oSelf.formatResult(oResultItemi,sCurQuery);oItemi.style.display="list-item";oItemi._sResultKey=oResultItemi[0];oItemi._oResultData=oResultItemi;}
+for(var j=aItems.length-1;j>=nItems;j--){var oItemj=aItems[j];oItemj.innerHTML=null;oItemj.style.display="none";oItemj._sResultKey=null;oItemj._oResultData=null;}
+if(oSelf.autoHighlight){var oFirstItem=aItems[0];oSelf._toggleHighlight(oFirstItem,"to");oSelf.itemArrowToEvent.fire(oSelf,oFirstItem);oSelf._typeAhead(oFirstItem,sQuery);}
+else{oSelf._oCurItem=null;}
+var ok=oSelf.doBeforeExpandContainer(oSelf._oTextbox,oSelf._oContainer,sQuery,aResults);oSelf._toggleContainer(ok);}
+else{oSelf._toggleContainer(false);}
+oSelf.dataReturnEvent.fire(oSelf,sQuery,aResults);};YAHOO.widget.AutoComplete.prototype._clearSelection=function(){var sValue=this._oTextbox.value;var sChar=(this.delimChar)?this.delimChar[0]:null;var nIndex=(sChar)?sValue.lastIndexOf(sChar,sValue.length-2):-1;if(nIndex>-1){this._oTextbox.value=sValue.substring(0,nIndex);}
+else{this._oTextbox.value="";}
+this._sSavedQuery=this._oTextbox.value;this.selectionEnforceEvent.fire(this);};YAHOO.widget.AutoComplete.prototype._textMatchesOption=function(){var foundMatch=false;for(var i=this._nDisplayedItems-1;i>=0;i--){var oItem=this._aListItems[i];var sMatch=oItem._sResultKey.toLowerCase();if(sMatch==this._sCurQuery.toLowerCase()){foundMatch=true;break;}}
+return(foundMatch);};YAHOO.widget.AutoComplete.prototype._typeAhead=function(oItem,sQuery){if(!this.typeAhead||(this._nKeyCode==8)){return;}
+var oTextbox=this._oTextbox;var sValue=this._oTextbox.value;if(!oTextbox.setSelectionRange&&!oTextbox.createTextRange){return;}
+var nStart=sValue.length;this._updateValue(oItem);var nEnd=oTextbox.value.length;this._selectText(oTextbox,nStart,nEnd);var sPrefill=oTextbox.value.substr(nStart,nEnd);this.typeAheadEvent.fire(this,sQuery,sPrefill);};YAHOO.widget.AutoComplete.prototype._selectText=function(oTextbox,nStart,nEnd){if(oTextbox.setSelectionRange){oTextbox.setSelectionRange(nStart,nEnd);}
+else if(oTextbox.createTextRange){var oTextRange=oTextbox.createTextRange();oTextRange.moveStart("character",nStart);oTextRange.moveEnd("character",nEnd-oTextbox.value.length);oTextRange.select();}
+else{oTextbox.select();}};YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers=function(bShow){var bFireEvent=false;var width=this._oContainer._oContent.offsetWidth+"px";var height=this._oContainer._oContent.offsetHeight+"px";if(this.useIFrame&&this._oContainer._oIFrame){bFireEvent=true;if(bShow){this._oContainer._oIFrame.style.width=width;this._oContainer._oIFrame.style.height=height;}
+else{this._oContainer._oIFrame.style.width=0;this._oContainer._oIFrame.style.height=0;}}
+if(this.useShadow&&this._oContainer._oShadow){bFireEvent=true;if(bShow){this._oContainer._oShadow.style.width=width;this._oContainer._oShadow.style.height=height;}
+else{this._oContainer._oShadow.style.width=0;this._oContainer._oShadow.style.height=0;}}};YAHOO.widget.AutoComplete.prototype._toggleContainer=function(bShow){var oContainer=this._oContainer;if(this.alwaysShowContainer&&this._bContainerOpen){return;}
+if(!bShow){this._oContainer._oContent.scrollTop=0;var aItems=this._aListItems;if(aItems&&(aItems.length>0)){for(var i=aItems.length-1;i>=0;i--){aItems[i].style.display="none";}}
+if(this._oCurItem){this._toggleHighlight(this._oCurItem,"from");}
+this._oCurItem=null;this._nDisplayedItems=0;this._sCurQuery=null;}
+if(!bShow&&!this._bContainerOpen){oContainer._oContent.style.display="none";return;}
+var oAnim=this._oAnim;if(oAnim&&oAnim.getEl()&&(this.animHoriz||this.animVert)){if(!bShow){this._toggleContainerHelpers(bShow);}
+if(oAnim.isAnimated()){oAnim.stop();}
+var oClone=oContainer._oContent.cloneNode(true);oContainer.appendChild(oClone);oClone.style.top="-9000px";oClone.style.display="block";var wExp=oClone.offsetWidth;var hExp=oClone.offsetHeight;var wColl=(this.animHoriz)?0:wExp;var hColl=(this.animVert)?0:hExp;oAnim.attributes=(bShow)?{width:{to:wExp},height:{to:hExp}}:{width:{to:wColl},height:{to:hColl}};if(bShow&&!this._bContainerOpen){oContainer._oContent.style.width=wColl+"px";oContainer._oContent.style.height=hColl+"px";}
+else{oContainer._oContent.style.width=wExp+"px";oContainer._oContent.style.height=hExp+"px";}
+oContainer.removeChild(oClone);oClone=null;var oSelf=this;var onAnimComplete=function(){oAnim.onComplete.unsubscribeAll();if(bShow){oSelf.containerExpandEvent.fire(oSelf);}
+else{oContainer._oContent.style.display="none";oSelf.containerCollapseEvent.fire(oSelf);}
+oSelf._toggleContainerHelpers(bShow);};oContainer._oContent.style.display="block";oAnim.onComplete.subscribe(onAnimComplete);oAnim.animate();this._bContainerOpen=bShow;}
+else{if(bShow){oContainer._oContent.style.display="block";this.containerExpandEvent.fire(this);}
+else{oContainer._oContent.style.display="none";this.containerCollapseEvent.fire(this);}
+this._toggleContainerHelpers(bShow);this._bContainerOpen=bShow;}};YAHOO.widget.AutoComplete.prototype._toggleHighlight=function(oNewItem,sType){var sHighlight=this.highlightClassName;if(this._oCurItem){YAHOO.util.Dom.removeClass(this._oCurItem,sHighlight);}
+if((sType=="to")&&sHighlight){YAHOO.util.Dom.addClass(oNewItem,sHighlight);this._oCurItem=oNewItem;}};YAHOO.widget.AutoComplete.prototype._togglePrehighlight=function(oNewItem,sType){if(oNewItem==this._oCurItem){return;}
+var sPrehighlight=this.prehighlightClassName;if((sType=="mouseover")&&sPrehighlight){YAHOO.util.Dom.addClass(oNewItem,sPrehighlight);}
+else{YAHOO.util.Dom.removeClass(oNewItem,sPrehighlight);}};YAHOO.widget.AutoComplete.prototype._updateValue=function(oItem){var oTextbox=this._oTextbox;var sDelimChar=(this.delimChar)?(this.delimChar[0]||this.delimChar):null;var sSavedQuery=this._sSavedQuery;var sResultKey=oItem._sResultKey;oTextbox.focus();oTextbox.value="";if(sDelimChar){if(sSavedQuery){oTextbox.value=sSavedQuery;}
+oTextbox.value+=sResultKey+sDelimChar;if(sDelimChar!=" "){oTextbox.value+=" ";}}
+else{oTextbox.value=sResultKey;}
+if(oTextbox.type=="textarea"){oTextbox.scrollTop=oTextbox.scrollHeight;}
+var end=oTextbox.value.length;this._selectText(oTextbox,end,end);this._oCurItem=oItem;};YAHOO.widget.AutoComplete.prototype._selectItem=function(oItem){this._bItemSelected=true;this._updateValue(oItem);this._cancelIntervalDetection(this);this.itemSelectEvent.fire(this,oItem,oItem._oResultData);this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(!this.typeAhead){return;}
+else{this._toggleContainer(false);}};YAHOO.widget.AutoComplete.prototype._moveSelection=function(nKeyCode){if(this._bContainerOpen){var oCurItem=this._oCurItem;var nCurItemIndex=-1;if(oCurItem){nCurItemIndex=oCurItem._nItemIndex;}
+var nNewItemIndex=(nKeyCode==40)?(nCurItemIndex+1):(nCurItemIndex-1);if(nNewItemIndex<-2||nNewItemIndex>=this._nDisplayedItems){return;}
+if(oCurItem){this._toggleHighlight(oCurItem,"from");this.itemArrowFromEvent.fire(this,oCurItem);}
+if(nNewItemIndex==-1){if(this.delimChar&&this._sSavedQuery){if(!this._textMatchesOption()){this._oTextbox.value=this._sSavedQuery;}
+else{this._oTextbox.value=this._sSavedQuery+this._sCurQuery;}}
+else{this._oTextbox.value=this._sCurQuery;}
+this._oCurItem=null;return;}
+if(nNewItemIndex==-2){this._toggleContainer(false);return;}
+var oNewItem=this._aListItems[nNewItemIndex];var oContent=this._oContainer._oContent;var scrollOn=((YAHOO.util.Dom.getStyle(oContent,"overflow")=="auto")||(YAHOO.util.Dom.getStyle(oContent,"overflowY")=="auto"));if(scrollOn&&(nNewItemIndex>-1)&&(nNewItemIndex(oContent.scrollTop+oContent.offsetHeight)){oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;}
+else if((oNewItem.offsetTop+oNewItem.offsetHeight)(oContent.scrollTop+oContent.offsetHeight)){this._oContainer._oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;}}}
+this._toggleHighlight(oNewItem,"to");this.itemArrowToEvent.fire(this,oNewItem);if(this.typeAhead){this._updateValue(oNewItem);}}};YAHOO.widget.AutoComplete.prototype._onItemMouseover=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseover");}
+else{oSelf._toggleHighlight(this,"to");}
+oSelf.itemMouseOverEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseout=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseout");}
+else{oSelf._toggleHighlight(this,"from");}
+oSelf.itemMouseOutEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseclick=function(v,oSelf){oSelf._toggleHighlight(this,"to");oSelf._selectItem(this);};YAHOO.widget.AutoComplete.prototype._onContainerMouseover=function(v,oSelf){oSelf._bOverContainer=true;};YAHOO.widget.AutoComplete.prototype._onContainerMouseout=function(v,oSelf){oSelf._bOverContainer=false;if(oSelf._oCurItem){oSelf._toggleHighlight(oSelf._oCurItem,"to");}};YAHOO.widget.AutoComplete.prototype._onContainerScroll=function(v,oSelf){oSelf._oTextbox.focus();};YAHOO.widget.AutoComplete.prototype._onContainerResize=function(v,oSelf){oSelf._toggleContainerHelpers(oSelf._bContainerOpen);};YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown=function(v,oSelf){var nKeyCode=v.keyCode;switch(nKeyCode){case 9:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
+if(oSelf._oCurItem){oSelf._selectItem(oSelf._oCurItem);}
+else{oSelf._toggleContainer(false);}
+break;case 13:if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
+if(oSelf._oCurItem){oSelf._selectItem(oSelf._oCurItem);}
+else{oSelf._toggleContainer(false);}
+break;case 27:oSelf._toggleContainer(false);return;case 39:oSelf._jumpSelection();break;case 38:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;case 40:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;default:break;}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress=function(v,oSelf){var nKeyCode=v.keyCode;var isMac=(navigator.userAgent.toLowerCase().indexOf("mac")!=-1);if(isMac){switch(nKeyCode){case 9:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
+break;case 13:if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
+break;case 38:case 40:YAHOO.util.Event.stopEvent(v);break;default:break;}}
+else if(nKeyCode==229){oSelf._queryInterval=setInterval(function(){oSelf._onIMEDetected(oSelf);},500);}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp=function(v,oSelf){oSelf._initProps();var nKeyCode=v.keyCode;oSelf._nKeyCode=nKeyCode;var sText=this.value;if(oSelf._isIgnoreKey(nKeyCode)||(sText.toLowerCase()==oSelf._sCurQuery)){return;}
+else{oSelf.textboxKeyEvent.fire(oSelf,nKeyCode);}
+if(oSelf.queryDelay>0){var nDelayID=setTimeout(function(){oSelf._sendQuery(sText);},(oSelf.queryDelay*1000));if(oSelf._nDelayID!=-1){clearTimeout(oSelf._nDelayID);}
+oSelf._nDelayID=nDelayID;}
+else{oSelf._sendQuery(sText);}};YAHOO.widget.AutoComplete.prototype._onTextboxFocus=function(v,oSelf){oSelf._oTextbox.setAttribute("autocomplete","off");oSelf._bFocused=true;oSelf.textboxFocusEvent.fire(oSelf);};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(v,oSelf){if(!oSelf._bOverContainer||(oSelf._nKeyCode==9)){if(!oSelf._bItemSelected){if(!oSelf._bContainerOpen||(oSelf._bContainerOpen&&!oSelf._textMatchesOption())){if(oSelf.forceSelection){oSelf._clearSelection();}
+else{oSelf.unmatchedItemSelectEvent.fire(oSelf,oSelf._sCurQuery);}}}
+if(oSelf._bContainerOpen){oSelf._toggleContainer(false);}
+oSelf._cancelIntervalDetection(oSelf);oSelf._bFocused=false;oSelf.textboxBlurEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onFormSubmit=function(v,oSelf){if(oSelf.allowBrowserAutocomplete){oSelf._oTextbox.setAttribute("autocomplete","on");}
+else{oSelf._oTextbox.setAttribute("autocomplete","off");}};YAHOO.widget.DataSource=function(){};YAHOO.widget.DataSource.ERROR_DATANULL="Response data was null";YAHOO.widget.DataSource.ERROR_DATAPARSE="Response data could not be parsed";YAHOO.widget.DataSource.prototype.maxCacheEntries=15;YAHOO.widget.DataSource.prototype.queryMatchContains=false;YAHOO.widget.DataSource.prototype.queryMatchSubset=false;YAHOO.widget.DataSource.prototype.queryMatchCase=false;YAHOO.widget.DataSource.prototype.toString=function(){return"DataSource "+this._sName;};YAHOO.widget.DataSource.prototype.getResults=function(oCallbackFn,sQuery,oParent){var aResults=this._doQueryCache(oCallbackFn,sQuery,oParent);if(aResults.length===0){this.queryEvent.fire(this,oParent,sQuery);this.doQuery(oCallbackFn,sQuery,oParent);}};YAHOO.widget.DataSource.prototype.doQuery=function(oCallbackFn,sQuery,oParent){};YAHOO.widget.DataSource.prototype.flushCache=function(){if(this._aCache){this._aCache=[];}
+if(this._aCacheHelper){this._aCacheHelper=[];}
+this.cacheFlushEvent.fire(this);};YAHOO.widget.DataSource.prototype.queryEvent=null;YAHOO.widget.DataSource.prototype.cacheQueryEvent=null;YAHOO.widget.DataSource.prototype.getResultsEvent=null;YAHOO.widget.DataSource.prototype.getCachedResultsEvent=null;YAHOO.widget.DataSource.prototype.dataErrorEvent=null;YAHOO.widget.DataSource.prototype.cacheFlushEvent=null;YAHOO.widget.DataSource._nIndex=0;YAHOO.widget.DataSource.prototype._sName=null;YAHOO.widget.DataSource.prototype._aCache=null;YAHOO.widget.DataSource.prototype._init=function(){var maxCacheEntries=this.maxCacheEntries;if(isNaN(maxCacheEntries)||(maxCacheEntries<0)){maxCacheEntries=0;}
+if(maxCacheEntries>0&&!this._aCache){this._aCache=[];}
+this._sName="instance"+YAHOO.widget.DataSource._nIndex;YAHOO.widget.DataSource._nIndex++;this.queryEvent=new YAHOO.util.CustomEvent("query",this);this.cacheQueryEvent=new YAHOO.util.CustomEvent("cacheQuery",this);this.getResultsEvent=new YAHOO.util.CustomEvent("getResults",this);this.getCachedResultsEvent=new YAHOO.util.CustomEvent("getCachedResults",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.cacheFlushEvent=new YAHOO.util.CustomEvent("cacheFlush",this);};YAHOO.widget.DataSource.prototype._addCacheElem=function(oResult){var aCache=this._aCache;if(!aCache||!oResult||!oResult.query||!oResult.results){return;}
+if(aCache.length>=this.maxCacheEntries){aCache.shift();}
+aCache.push(oResult);};YAHOO.widget.DataSource.prototype._doQueryCache=function(oCallbackFn,sQuery,oParent){var aResults=[];var bMatchFound=false;var aCache=this._aCache;var nCacheLength=(aCache)?aCache.length:0;var bMatchContains=this.queryMatchContains;if((this.maxCacheEntries>0)&&aCache&&(nCacheLength>0)){this.cacheQueryEvent.fire(this,oParent,sQuery);if(!this.queryMatchCase){var sOrigQuery=sQuery;sQuery=sQuery.toLowerCase();}
+for(var i=nCacheLength-1;i>=0;i--){var resultObj=aCache[i];var aAllResultItems=resultObj.results;var matchKey=(!this.queryMatchCase)?encodeURIComponent(resultObj.query).toLowerCase():encodeURIComponent(resultObj.query);if(matchKey==sQuery){bMatchFound=true;aResults=aAllResultItems;if(i!=nCacheLength-1){aCache.splice(i,1);this._addCacheElem(resultObj);}
+break;}
+else if(this.queryMatchSubset){for(var j=sQuery.length-1;j>=0;j--){var subQuery=sQuery.substr(0,j);if(matchKey==subQuery){bMatchFound=true;for(var k=aAllResultItems.length-1;k>=0;k--){var aRecord=aAllResultItems[k];var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aRecord[0]).indexOf(sQuery):encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aRecord);}}
+resultObj={};resultObj.query=sQuery;resultObj.results=aResults;this._addCacheElem(resultObj);break;}}
+if(bMatchFound){break;}}}
+if(bMatchFound){this.getCachedResultsEvent.fire(this,oParent,sOrigQuery,aResults);oCallbackFn(sOrigQuery,aResults,oParent);}}
+return aResults;};YAHOO.widget.DS_XHR=function(sScriptURI,aSchema,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
+if(!aSchema||(aSchema.constructor!=Array)){return;}
+else{this.schema=aSchema;}
+this.scriptURI=sScriptURI;this._init();};YAHOO.widget.DS_XHR.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_XHR.TYPE_JSON=0;YAHOO.widget.DS_XHR.TYPE_XML=1;YAHOO.widget.DS_XHR.TYPE_FLAT=2;YAHOO.widget.DS_XHR.ERROR_DATAXHR="XHR response failed";YAHOO.widget.DS_XHR.prototype.connMgr=YAHOO.util.Connect;YAHOO.widget.DS_XHR.prototype.connTimeout=0;YAHOO.widget.DS_XHR.prototype.scriptURI=null;YAHOO.widget.DS_XHR.prototype.scriptQueryParam="query";YAHOO.widget.DS_XHR.prototype.scriptQueryAppend="";YAHOO.widget.DS_XHR.prototype.responseType=YAHOO.widget.DS_XHR.TYPE_JSON;YAHOO.widget.DS_XHR.prototype.responseStripAfter="\n0){sUri+="&"+this.scriptQueryAppend;}
+var oResponse=null;var oSelf=this;var responseSuccess=function(oResp){if(!oSelf._oConn||(oResp.tId!=oSelf._oConn.tId)){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
+for(var foo in oResp){}
+if(!isXML){oResp=oResp.responseText;}
+else{oResp=oResp.responseXML;}
+if(oResp===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
+var aResults=oSelf.parseResponse(sQuery,oResp,oParent);var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATAPARSE);aResults=[];}
+else{oSelf.getResultsEvent.fire(oSelf,oParent,sQuery,aResults);oSelf._addCacheElem(resultObj);}
+oCallbackFn(sQuery,aResults,oParent);};var responseFailure=function(oResp){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DS_XHR.ERROR_DATAXHR);return;};var oCallback={success:responseSuccess,failure:responseFailure};if(!isNaN(this.connTimeout)&&this.connTimeout>0){oCallback.timeout=this.connTimeout;}
+if(this._oConn){this.connMgr.abort(this._oConn);}
+oSelf._oConn=this.connMgr.asyncRequest("GET",sUri,oCallback,null);};YAHOO.widget.DS_XHR.prototype.parseResponse=function(sQuery,oResponse,oParent){var aSchema=this.schema;var aResults=[];var bError=false;var nEnd=((this.responseStripAfter!=="")&&(oResponse.indexOf))?oResponse.indexOf(this.responseStripAfter):-1;if(nEnd!=-1){oResponse=oResponse.substring(0,nEnd);}
+switch(this.responseType){case YAHOO.widget.DS_XHR.TYPE_JSON:var jsonList;if(window.JSON&&(navigator.userAgent.toLowerCase().indexOf('khtml')==-1)){var jsonObjParsed=JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;}
+else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}
+catch(e){bError=true;break;}}}
+else{try{while(oResponse.substring(0,1)==" "){oResponse=oResponse.substring(1,oResponse.length);}
+if(oResponse.indexOf("{")<0){bError=true;break;}
+if(oResponse.indexOf("{}")===0){break;}
+var jsonObjRaw=eval("("+oResponse+")");if(!jsonObjRaw){bError=true;break;}
+jsonList=eval("(jsonObjRaw."+aSchema[0]+")");}
+catch(e){bError=true;break;}}
+if(!jsonList){bError=true;break;}
+if(jsonList.constructor!=Array){jsonList=[jsonList];}
+for(var i=jsonList.length-1;i>=0;i--){var aResultItem=[];var jsonResult=jsonList[i];for(var j=aSchema.length-1;j>=1;j--){var dataFieldValue=jsonResult[aSchema[j]];if(!dataFieldValue){dataFieldValue="";}
+aResultItem.unshift(dataFieldValue);}
+if(aResultItem.length==1){aResultItem.push(jsonResult);}
+aResults.unshift(aResultItem);}
+break;case YAHOO.widget.DS_XHR.TYPE_XML:var xmlList=oResponse.getElementsByTagName(aSchema[0]);if(!xmlList){bError=true;break;}
+for(var k=xmlList.length-1;k>=0;k--){var result=xmlList.item(k);var aFieldSet=[];for(var m=aSchema.length-1;m>=1;m--){var sValue=null;var xmlAttr=result.attributes.getNamedItem(aSchema[m]);if(xmlAttr){sValue=xmlAttr.value;}
+else{var xmlNode=result.getElementsByTagName(aSchema[m]);if(xmlNode&&xmlNode.item(0)&&xmlNode.item(0).firstChild){sValue=xmlNode.item(0).firstChild.nodeValue;}
+else{sValue="";}}
+aFieldSet.unshift(sValue);}
+aResults.unshift(aFieldSet);}
+break;case YAHOO.widget.DS_XHR.TYPE_FLAT:if(oResponse.length>0){var newLength=oResponse.length-aSchema[0].length;if(oResponse.substr(newLength)==aSchema[0]){oResponse=oResponse.substr(0,newLength);}
+var aRecords=oResponse.split(aSchema[0]);for(var n=aRecords.length-1;n>=0;n--){aResults[n]=aRecords[n].split(aSchema[1]);}}
+break;default:break;}
+sQuery=null;oResponse=null;oParent=null;if(bError){return null;}
+else{return aResults;}};YAHOO.widget.DS_XHR.prototype._oConn=null;YAHOO.widget.DS_JSFunction=function(oFunction,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
+if(!oFunction||(oFunction.constructor!=Function)){return;}
+else{this.dataFunction=oFunction;this._init();}};YAHOO.widget.DS_JSFunction.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSFunction.prototype.dataFunction=null;YAHOO.widget.DS_JSFunction.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var oFunction=this.dataFunction;var aResults=[];aResults=oFunction(sQuery);if(aResults===null){this.dataErrorEvent.fire(this,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
+var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;this._addCacheElem(resultObj);this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);return;};YAHOO.widget.DS_JSArray=function(aData,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
+if(!aData||(aData.constructor!=Array)){return;}
+else{this.data=aData;this._init();}};YAHOO.widget.DS_JSArray.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSArray.prototype.data=null;YAHOO.widget.DS_JSArray.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var aData=this.data;var aResults=[];var bMatchFound=false;var bMatchContains=this.queryMatchContains;if(sQuery){if(!this.queryMatchCase){sQuery=sQuery.toLowerCase();}
+for(var i=aData.length-1;i>=0;i--){var aDataset=[];if(aData[i]){if(aData[i].constructor==String){aDataset[0]=aData[i];}
+else if(aData[i].constructor==Array){aDataset=aData[i];}}
+if(aDataset[0]&&(aDataset[0].constructor==String)){var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aDataset[0]).indexOf(sQuery):encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aDataset);}}}}
this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);};
\ No newline at end of file
diff --git a/lib/yui/autocomplete/autocomplete.js b/lib/yui/autocomplete/autocomplete.js
index 548fff1201..a39a98780b 100755
--- a/lib/yui/autocomplete/autocomplete.js
+++ b/lib/yui/autocomplete/autocomplete.js
@@ -1,10 +1,9 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.com/yui/license.txt
-version: 0.12.1
-*/
-
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
/**
* The AutoComplete control provides the front-end logic for text-entry suggestion and
* completion functionality.
@@ -134,7 +133,7 @@ YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
this.selectionEnforceEvent = new YAHOO.util.CustomEvent("selectionEnforce", this);
this.containerCollapseEvent = new YAHOO.util.CustomEvent("containerCollapse", this);
this.textboxBlurEvent = new YAHOO.util.CustomEvent("textboxBlur", this);
-
+
// Finish up
oTextbox.setAttribute("autocomplete","off");
YAHOO.widget.AutoComplete._nIndex++;
@@ -510,7 +509,7 @@ YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null;
/**
* Fired when the AutoComplete instance makes a query to the DataSource.
- *
+ *
* @event dataRequestEvent
* @param oSelf {Object} The AutoComplete instance.
* @param sQuery {String} The query string.
@@ -548,7 +547,7 @@ YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
/**
* Fired when the input field has been prefilled by the type-ahead
- * feature.
+ * feature.
*
* @event typeAheadEvent
* @param oSelf {Object} The AutoComplete instance.
@@ -576,7 +575,7 @@ YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
/**
- * Fired when result item has been arrowed to.
+ * Fired when result item has been arrowed to.
*
* @event itemArrowToEvent
* @param oSelf {Object} The AutoComplete instance.
@@ -607,7 +606,7 @@ YAHOO.widget.AutoComplete.prototype.itemSelectEvent = null;
/**
* Fired when a user selection does not match any of the displayed result items.
* Note that this event may not behave as expected when delimiter characters
- * have been defined.
+ * have been defined.
*
* @event unmatchedItemSelectEvent
* @param oSelf {Object} The AutoComplete instance.
@@ -1360,7 +1359,7 @@ YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
if(this.alwaysShowContainer && this._bContainerOpen) {
return;
}
-
+
// Clear contents of container
if(!bShow) {
this._oContainer._oContent.scrollTop = 0;
@@ -2002,1065 +2001,1065 @@ YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
oSelf._oTextbox.setAttribute("autocomplete","off");
}
};
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * The DataSource classes manages sending a request and returning response from a live
- * database. Supported data include local JavaScript arrays and objects and databases
- * accessible via XHR connections. Supported response formats include JavaScript arrays,
- * JSON, XML, and flat-file textual data.
- *
- * @class DataSource
- * @constructor
- */
-YAHOO.widget.DataSource = function() {
- /* abstract class */
-};
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public constants
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Error message for null data responses.
- *
- * @property ERROR_DATANULL
- * @type String
- * @static
- * @final
- */
-YAHOO.widget.DataSource.ERROR_DATANULL = "Response data was null";
-
-/**
- * Error message for data responses with parsing errors.
- *
- * @property ERROR_DATAPARSE
- * @type String
- * @static
- * @final
- */
-YAHOO.widget.DataSource.ERROR_DATAPARSE = "Response data could not be parsed";
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Max size of the local cache. Set to 0 to turn off caching. Caching is
- * useful to reduce the number of server connections. Recommended only for data
- * sources that return comprehensive results for queries or when stale data is
- * not an issue.
- *
- * @property maxCacheEntries
- * @type Number
- * @default 15
- */
-YAHOO.widget.DataSource.prototype.maxCacheEntries = 15;
-
-/**
- * Use this to equate cache matching with the type of matching done by your live
- * data source. If caching is on and queryMatchContains is true, the cache
- * returns results that "contain" the query string. By default,
- * queryMatchContains is set to false, meaning the cache only returns results
- * that "start with" the query string.
- *
- * @property queryMatchContains
- * @type Boolean
- * @default false
- */
-YAHOO.widget.DataSource.prototype.queryMatchContains = false;
-
-/**
- * Enables query subset matching. If caching is on and queryMatchSubset is
- * true, substrings of queries will return matching cached results. For
- * instance, if the first query is for "abc" susequent queries that start with
- * "abc", like "abcd", will be queried against the cache, and not the live data
- * source. Recommended only for DataSources that return comprehensive results
- * for queries with very few characters.
- *
- * @property queryMatchSubset
- * @type Boolean
- * @default false
- *
- */
-YAHOO.widget.DataSource.prototype.queryMatchSubset = false;
-
-/**
- * Enables query case-sensitivity matching. If caching is on and
- * queryMatchCase is true, queries will only return results for case-sensitive
- * matches.
- *
- * @property queryMatchCase
- * @type Boolean
- * @default false
- */
-YAHOO.widget.DataSource.prototype.queryMatchCase = false;
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Public accessor to the unique name of the DataSource instance.
- *
- * @method toString
- * @return {String} Unique name of the DataSource instance
- */
-YAHOO.widget.DataSource.prototype.toString = function() {
- return "DataSource " + this._sName;
-};
-
-/**
- * Retrieves query results, first checking the local cache, then making the
- * query request to the live data source as defined by the function doQuery.
- *
- * @method getResults
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DataSource.prototype.getResults = function(oCallbackFn, sQuery, oParent) {
-
- // First look in cache
- var aResults = this._doQueryCache(oCallbackFn,sQuery,oParent);
-
- // Not in cache, so get results from server
- if(aResults.length === 0) {
- this.queryEvent.fire(this, oParent, sQuery);
- this.doQuery(oCallbackFn, sQuery, oParent);
- }
-};
-
-/**
- * Abstract method implemented by subclasses to make a query to the live data
- * source. Must call the callback function with the response returned from the
- * query. Populates cache (if enabled).
- *
- * @method doQuery
- * @param oCallbackFn {HTMLFunction} Callback function implemented by oParent to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- /* override this */
-};
-
-/**
- * Flushes cache.
- *
- * @method flushCache
- */
-YAHOO.widget.DataSource.prototype.flushCache = function() {
- if(this._aCache) {
- this._aCache = [];
- }
- if(this._aCacheHelper) {
- this._aCacheHelper = [];
- }
- this.cacheFlushEvent.fire(this);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Fired when a query is made to the live data source.
- *
- * @event queryEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.DataSource.prototype.queryEvent = null;
-
-/**
- * Fired when a query is made to the local cache.
- *
- * @event cacheQueryEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.DataSource.prototype.cacheQueryEvent = null;
-
-/**
- * Fired when data is retrieved from the live data source.
- *
- * @event getResultsEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- * @param aResults {Object[]} Array of result objects.
- */
-YAHOO.widget.DataSource.prototype.getResultsEvent = null;
-
-/**
- * Fired when data is retrieved from the local cache.
- *
- * @event getCachedResultsEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- * @param aResults {Object[]} Array of result objects.
- */
-YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null;
-
-/**
- * Fired when an error is encountered with the live data source.
- *
- * @event dataErrorEvent
- * @param oSelf {Object} The DataSource instance.
- * @param oParent {Object} The requesting object.
- * @param sQuery {String} The query string.
- * @param sMsg {String} Error message string
- */
-YAHOO.widget.DataSource.prototype.dataErrorEvent = null;
-
-/**
- * Fired when the local cache is flushed.
- *
- * @event cacheFlushEvent
- * @param oSelf {Object} The DataSource instance
- */
-YAHOO.widget.DataSource.prototype.cacheFlushEvent = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Internal class variable to index multiple DataSource instances.
- *
- * @property _nIndex
- * @type Number
- * @private
- * @static
- */
-YAHOO.widget.DataSource._nIndex = 0;
-
-/**
- * Name of DataSource instance.
- *
- * @property _sName
- * @type String
- * @private
- */
-YAHOO.widget.DataSource.prototype._sName = null;
-
-/**
- * Local cache of data result objects indexed chronologically.
- *
- * @property _aCache
- * @type Object[]
- * @private
- */
-YAHOO.widget.DataSource.prototype._aCache = null;
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Initializes DataSource instance.
- *
- * @method _init
- * @private
- */
-YAHOO.widget.DataSource.prototype._init = function() {
- // Validate and initialize public configs
- var maxCacheEntries = this.maxCacheEntries;
- if(isNaN(maxCacheEntries) || (maxCacheEntries < 0)) {
- maxCacheEntries = 0;
- }
- // Initialize local cache
- if(maxCacheEntries > 0 && !this._aCache) {
- this._aCache = [];
- }
-
- this._sName = "instance" + YAHOO.widget.DataSource._nIndex;
- YAHOO.widget.DataSource._nIndex++;
-
- this.queryEvent = new YAHOO.util.CustomEvent("query", this);
- this.cacheQueryEvent = new YAHOO.util.CustomEvent("cacheQuery", this);
- this.getResultsEvent = new YAHOO.util.CustomEvent("getResults", this);
- this.getCachedResultsEvent = new YAHOO.util.CustomEvent("getCachedResults", this);
- this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
- this.cacheFlushEvent = new YAHOO.util.CustomEvent("cacheFlush", this);
-};
-
-/**
- * Adds a result object to the local cache, evicting the oldest element if the
- * cache is full. Newer items will have higher indexes, the oldest item will have
- * index of 0.
- *
- * @method _addCacheElem
- * @param oResult {Object} Data result object, including array of results.
- * @private
- */
-YAHOO.widget.DataSource.prototype._addCacheElem = function(oResult) {
- var aCache = this._aCache;
- // Don't add if anything important is missing.
- if(!aCache || !oResult || !oResult.query || !oResult.results) {
- return;
- }
-
- // If the cache is full, make room by removing from index=0
- if(aCache.length >= this.maxCacheEntries) {
- aCache.shift();
- }
-
- // Add to cache, at the end of the array
- aCache.push(oResult);
-};
-
-/**
- * Queries the local cache for results. If query has been cached, the callback
- * function is called with the results, and the cached is refreshed so that it
- * is now the newest element.
- *
- * @method _doQueryCache
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- * @return aResults {Object[]} Array of results from local cache if found, otherwise null.
- * @private
- */
-YAHOO.widget.DataSource.prototype._doQueryCache = function(oCallbackFn, sQuery, oParent) {
- var aResults = [];
- var bMatchFound = false;
- var aCache = this._aCache;
- var nCacheLength = (aCache) ? aCache.length : 0;
- var bMatchContains = this.queryMatchContains;
-
- // If cache is enabled...
- if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) {
- this.cacheQueryEvent.fire(this, oParent, sQuery);
- // If case is unimportant, normalize query now instead of in loops
- if(!this.queryMatchCase) {
- var sOrigQuery = sQuery;
- sQuery = sQuery.toLowerCase();
- }
-
- // Loop through each cached element's query property...
- for(var i = nCacheLength-1; i >= 0; i--) {
- var resultObj = aCache[i];
- var aAllResultItems = resultObj.results;
- // If case is unimportant, normalize match key for comparison
- var matchKey = (!this.queryMatchCase) ?
- encodeURIComponent(resultObj.query).toLowerCase():
- encodeURIComponent(resultObj.query);
-
- // If a cached match key exactly matches the query...
- if(matchKey == sQuery) {
- // Stash all result objects into aResult[] and stop looping through the cache.
- bMatchFound = true;
- aResults = aAllResultItems;
-
- // The matching cache element was not the most recent,
- // so now we need to refresh the cache.
- if(i != nCacheLength-1) {
- // Remove element from its original location
- aCache.splice(i,1);
- // Add element as newest
- this._addCacheElem(resultObj);
- }
- break;
- }
- // Else if this query is not an exact match and subset matching is enabled...
- else if(this.queryMatchSubset) {
- // Loop through substrings of each cached element's query property...
- for(var j = sQuery.length-1; j >= 0 ; j--) {
- var subQuery = sQuery.substr(0,j);
-
- // If a substring of a cached sQuery exactly matches the query...
- if(matchKey == subQuery) {
- bMatchFound = true;
-
- // Go through each cached result object to match against the query...
- for(var k = aAllResultItems.length-1; k >= 0; k--) {
- var aRecord = aAllResultItems[k];
- var sKeyIndex = (this.queryMatchCase) ?
- encodeURIComponent(aRecord[0]).indexOf(sQuery):
- encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);
-
- // A STARTSWITH match is when the query is found at the beginning of the key string...
- if((!bMatchContains && (sKeyIndex === 0)) ||
- // A CONTAINS match is when the query is found anywhere within the key string...
- (bMatchContains && (sKeyIndex > -1))) {
- // Stash a match into aResults[].
- aResults.unshift(aRecord);
- }
- }
-
- // Add the subset match result set object as the newest element to cache,
- // and stop looping through the cache.
- resultObj = {};
- resultObj.query = sQuery;
- resultObj.results = aResults;
- this._addCacheElem(resultObj);
- break;
- }
- }
- if(bMatchFound) {
- break;
- }
- }
- }
-
- // If there was a match, send along the results.
- if(bMatchFound) {
- this.getCachedResultsEvent.fire(this, oParent, sOrigQuery, aResults);
- oCallbackFn(sOrigQuery, aResults, oParent);
- }
- }
- return aResults;
-};
-
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using XML HTTP requests that return
- * query results.
- *
- * @class DS_XHR
- * @extends YAHOO.widget.DataSource
- * @requires connection
- * @constructor
- * @param sScriptURI {String} Absolute or relative URI to script that returns query
- * results as JSON, XML, or delimited flat-file data.
- * @param aSchema {String[]} Data schema definition of results.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_XHR = function(sScriptURI, aSchema, oConfigs) {
- // Set any config params passed in to override defaults
- if(typeof oConfigs == "object") {
- for(var sConfig in oConfigs) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
-
- // Initialization sequence
- if(!aSchema || (aSchema.constructor != Array)) {
- return;
- }
- else {
- this.schema = aSchema;
- }
- this.scriptURI = sScriptURI;
- this._init();
-};
-
-YAHOO.widget.DS_XHR.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public constants
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * JSON data type.
- *
- * @property TYPE_JSON
- * @type Number
- * @static
- * @final
- */
-YAHOO.widget.DS_XHR.TYPE_JSON = 0;
-
-/**
- * XML data type.
- *
- * @property TYPE_XML
- * @type Number
- * @static
- * @final
- */
-YAHOO.widget.DS_XHR.TYPE_XML = 1;
-
-/**
- * Flat-file data type.
- *
- * @property TYPE_FLAT
- * @type Number
- * @static
- * @final
- */
-YAHOO.widget.DS_XHR.TYPE_FLAT = 2;
-
-/**
- * Error message for XHR failure.
- *
- * @property ERROR_DATAXHR
- * @type String
- * @static
- * @final
- */
-YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed";
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Alias to YUI Connection Manager. Allows implementers to specify their own
- * subclasses of the YUI Connection Manager utility.
- *
- * @property connMgr
- * @type Object
- * @default YAHOO.util.Connect
- */
-YAHOO.widget.DS_XHR.prototype.connMgr = YAHOO.util.Connect;
-
-/**
- * Number of milliseconds the XHR connection will wait for a server response. A
- * a value of zero indicates the XHR connection will wait forever. Any value
- * greater than zero will use the Connection utility's Auto-Abort feature.
- *
- * @property connTimeout
- * @type Number
- * @default 0
- */
-YAHOO.widget.DS_XHR.prototype.connTimeout = 0;
-
-/**
- * Absolute or relative URI to script that returns query results. For instance,
- * queries will be sent to <scriptURI>?<scriptQueryParam>=userinput
- *
- * @property scriptURI
- * @type String
- */
-YAHOO.widget.DS_XHR.prototype.scriptURI = null;
-
-/**
- * Query string parameter name sent to scriptURI. For instance, queries will be
- * sent to <scriptURI>?<scriptQueryParam>=userinput
- *
- * @property scriptQueryParam
- * @type String
- * @default "query"
- */
-YAHOO.widget.DS_XHR.prototype.scriptQueryParam = "query";
-
-/**
- * String of key/value pairs to append to requests made to scriptURI. Define
- * this string when you want to send additional query parameters to your script.
- * When defined, queries will be sent to
- * <scriptURI>?<scriptQueryParam>=userinput&<scriptQueryAppend>
- *
- * @property scriptQueryAppend
- * @type String
- * @default ""
- */
-YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = "";
-
-/**
- * XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML
- * and YAHOO.widget.DS_XHR.TYPE_FLAT.
- *
- * @property responseType
- * @type String
- * @default YAHOO.widget.DS_XHR.TYPE_JSON
- */
-YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.TYPE_JSON;
-
-/**
- * String after which to strip results. If the results from the XHR are sent
- * back as HTML, the gzip HTML comment appears at the end of the data and should
- * be ignored.
- *
- * @property responseStripAfter
- * @type String
- * @default "\n<!-"
- */
-YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n 0) {
- sUri += "&" + this.scriptQueryAppend;
- }
- var oResponse = null;
-
- var oSelf = this;
- /*
- * Sets up ajax request callback
- *
- * @param {object} oReq HTTPXMLRequest object
- * @private
- */
- var responseSuccess = function(oResp) {
- // Response ID does not match last made request ID.
- if(!oSelf._oConn || (oResp.tId != oSelf._oConn.tId)) {
- oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
- return;
- }
-//DEBUG
-for(var foo in oResp) {
-}
- if(!isXML) {
- oResp = oResp.responseText;
- }
- else {
- oResp = oResp.responseXML;
- }
- if(oResp === null) {
- oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
- return;
- }
-
- var aResults = oSelf.parseResponse(sQuery, oResp, oParent);
- var resultObj = {};
- resultObj.query = decodeURIComponent(sQuery);
- resultObj.results = aResults;
- if(aResults === null) {
- oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATAPARSE);
- aResults = [];
- }
- else {
- oSelf.getResultsEvent.fire(oSelf, oParent, sQuery, aResults);
- oSelf._addCacheElem(resultObj);
- }
- oCallbackFn(sQuery, aResults, oParent);
- };
-
- var responseFailure = function(oResp) {
- oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DS_XHR.ERROR_DATAXHR);
- return;
- };
-
- var oCallback = {
- success:responseSuccess,
- failure:responseFailure
- };
-
- if(!isNaN(this.connTimeout) && this.connTimeout > 0) {
- oCallback.timeout = this.connTimeout;
- }
-
- if(this._oConn) {
- this.connMgr.abort(this._oConn);
- }
-
- oSelf._oConn = this.connMgr.asyncRequest("GET", sUri, oCallback, null);
-};
-
-/**
- * Parses raw response data into an array of result objects. The result data key
- * is always stashed in the [0] element of each result object.
- *
- * @method parseResponse
- * @param sQuery {String} Query string.
- * @param oResponse {Object} The raw response data to parse.
- * @param oParent {Object} The object instance that has requested data.
- * @returns {Object[]} Array of result objects.
- */
-YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParent) {
- var aSchema = this.schema;
- var aResults = [];
- var bError = false;
-
- // Strip out comment at the end of results
- var nEnd = ((this.responseStripAfter !== "") && (oResponse.indexOf)) ?
- oResponse.indexOf(this.responseStripAfter) : -1;
- if(nEnd != -1) {
- oResponse = oResponse.substring(0,nEnd);
- }
-
- switch (this.responseType) {
- case YAHOO.widget.DS_XHR.TYPE_JSON:
- var jsonList;
- // Divert KHTML clients from JSON lib
- if(window.JSON && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) {
- // Use the JSON utility if available
- var jsonObjParsed = JSON.parse(oResponse);
- if(!jsonObjParsed) {
- bError = true;
- break;
- }
- else {
- try {
- // eval is necessary here since aSchema[0] is of unknown depth
- jsonList = eval("jsonObjParsed." + aSchema[0]);
- }
- catch(e) {
- bError = true;
- break;
- }
- }
- }
- else {
- // Parse the JSON response as a string
- try {
- // Trim leading spaces
- while (oResponse.substring(0,1) == " ") {
- oResponse = oResponse.substring(1, oResponse.length);
- }
-
- // Invalid JSON response
- if(oResponse.indexOf("{") < 0) {
- bError = true;
- break;
- }
-
- // Empty (but not invalid) JSON response
- if(oResponse.indexOf("{}") === 0) {
- break;
- }
-
- // Turn the string into an object literal...
- // ...eval is necessary here
- var jsonObjRaw = eval("(" + oResponse + ")");
- if(!jsonObjRaw) {
- bError = true;
- break;
- }
-
- // Grab the object member that contains an array of all reponses...
- // ...eval is necessary here since aSchema[0] is of unknown depth
- jsonList = eval("(jsonObjRaw." + aSchema[0]+")");
- }
- catch(e) {
- bError = true;
- break;
- }
- }
-
- if(!jsonList) {
- bError = true;
- break;
- }
-
- if(jsonList.constructor != Array) {
- jsonList = [jsonList];
- }
-
- // Loop through the array of all responses...
- for(var i = jsonList.length-1; i >= 0 ; i--) {
- var aResultItem = [];
- var jsonResult = jsonList[i];
- // ...and loop through each data field value of each response
- for(var j = aSchema.length-1; j >= 1 ; j--) {
- // ...and capture data into an array mapped according to the schema...
- var dataFieldValue = jsonResult[aSchema[j]];
- if(!dataFieldValue) {
- dataFieldValue = "";
- }
- aResultItem.unshift(dataFieldValue);
- }
- // If schema isn't well defined, pass along the entire result object
- if(aResultItem.length == 1) {
- aResultItem.push(jsonResult);
- }
- // Capture the array of data field values in an array of results
- aResults.unshift(aResultItem);
- }
- break;
- case YAHOO.widget.DS_XHR.TYPE_XML:
- // Get the collection of results
- var xmlList = oResponse.getElementsByTagName(aSchema[0]);
- if(!xmlList) {
- bError = true;
- break;
- }
- // Loop through each result
- for(var k = xmlList.length-1; k >= 0 ; k--) {
- var result = xmlList.item(k);
- var aFieldSet = [];
- // Loop through each data field in each result using the schema
- for(var m = aSchema.length-1; m >= 1 ; m--) {
- var sValue = null;
- // Values may be held in an attribute...
- var xmlAttr = result.attributes.getNamedItem(aSchema[m]);
- if(xmlAttr) {
- sValue = xmlAttr.value;
- }
- // ...or in a node
- else{
- var xmlNode = result.getElementsByTagName(aSchema[m]);
- if(xmlNode && xmlNode.item(0) && xmlNode.item(0).firstChild) {
- sValue = xmlNode.item(0).firstChild.nodeValue;
- }
- else {
- sValue = "";
- }
- }
- // Capture the schema-mapped data field values into an array
- aFieldSet.unshift(sValue);
- }
- // Capture each array of values into an array of results
- aResults.unshift(aFieldSet);
- }
- break;
- case YAHOO.widget.DS_XHR.TYPE_FLAT:
- if(oResponse.length > 0) {
- // Delete the last line delimiter at the end of the data if it exists
- var newLength = oResponse.length-aSchema[0].length;
- if(oResponse.substr(newLength) == aSchema[0]) {
- oResponse = oResponse.substr(0, newLength);
- }
- var aRecords = oResponse.split(aSchema[0]);
- for(var n = aRecords.length-1; n >= 0; n--) {
- aResults[n] = aRecords[n].split(aSchema[1]);
- }
- }
- break;
- default:
- break;
- }
- sQuery = null;
- oResponse = null;
- oParent = null;
- if(bError) {
- return null;
- }
- else {
- return aResults;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * XHR connection object.
- *
- * @property _oConn
- * @type Object
- * @private
- */
-YAHOO.widget.DS_XHR.prototype._oConn = null;
-
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using a native Javascript function as
- * its live data source.
- *
- * @class DS_JSFunction
- * @constructor
- * @extends YAHOO.widget.DataSource
- * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_JSFunction = function(oFunction, oConfigs) {
- // Set any config params passed in to override defaults
- if(typeof oConfigs == "object") {
- for(var sConfig in oConfigs) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
-
- // Initialization sequence
- if(!oFunction || (oFunction.constructor != Function)) {
- return;
- }
- else {
- this.dataFunction = oFunction;
- this._init();
- }
-};
-
-YAHOO.widget.DS_JSFunction.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * In-memory Javascript function that returns query results.
- *
- * @property dataFunction
- * @type HTMLFunction
- */
-YAHOO.widget.DS_JSFunction.prototype.dataFunction = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source defined by function for results. Results are
- * passed back to a callback function.
- *
- * @method doQuery
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DS_JSFunction.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- var oFunction = this.dataFunction;
- var aResults = [];
-
- aResults = oFunction(sQuery);
- if(aResults === null) {
- this.dataErrorEvent.fire(this, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
- return;
- }
-
- var resultObj = {};
- resultObj.query = decodeURIComponent(sQuery);
- resultObj.results = aResults;
- this._addCacheElem(resultObj);
-
- this.getResultsEvent.fire(this, oParent, sQuery, aResults);
- oCallbackFn(sQuery, aResults, oParent);
- return;
-};
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * Implementation of YAHOO.widget.DataSource using a native Javascript array as
- * its live data source.
- *
- * @class DS_JSArray
- * @constructor
- * @extends YAHOO.widget.DataSource
- * @param aData {String[]} In-memory Javascript array of simple string data.
- * @param oConfigs {Object} (optional) Object literal of config params.
- */
-YAHOO.widget.DS_JSArray = function(aData, oConfigs) {
- // Set any config params passed in to override defaults
- if(typeof oConfigs == "object") {
- for(var sConfig in oConfigs) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
-
- // Initialization sequence
- if(!aData || (aData.constructor != Array)) {
- return;
- }
- else {
- this.data = aData;
- this._init();
- }
-};
-
-YAHOO.widget.DS_JSArray.prototype = new YAHOO.widget.DataSource();
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * In-memory Javascript array of strings.
- *
- * @property data
- * @type Array
- */
-YAHOO.widget.DS_JSArray.prototype.data = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Queries the live data source defined by data for results. Results are passed
- * back to a callback function.
- *
- * @method doQuery
- * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
- * @param sQuery {String} Query string.
- * @param oParent {Object} The object instance that has requested data.
- */
-YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
- var aData = this.data; // the array
- var aResults = []; // container for results
- var bMatchFound = false;
- var bMatchContains = this.queryMatchContains;
- if(sQuery) {
- if(!this.queryMatchCase) {
- sQuery = sQuery.toLowerCase();
- }
-
- // Loop through each element of the array...
- // which can be a string or an array of strings
- for(var i = aData.length-1; i >= 0; i--) {
- var aDataset = [];
-
- if(aData[i]) {
- if(aData[i].constructor == String) {
- aDataset[0] = aData[i];
- }
- else if(aData[i].constructor == Array) {
- aDataset = aData[i];
- }
- }
-
- if(aDataset[0] && (aDataset[0].constructor == String)) {
- var sKeyIndex = (this.queryMatchCase) ?
- encodeURIComponent(aDataset[0]).indexOf(sQuery):
- encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);
-
- // A STARTSWITH match is when the query is found at the beginning of the key string...
- if((!bMatchContains && (sKeyIndex === 0)) ||
- // A CONTAINS match is when the query is found anywhere within the key string...
- (bMatchContains && (sKeyIndex > -1))) {
- // Stash a match into aResults[].
- aResults.unshift(aDataset);
- }
- }
- }
- }
-
- this.getResultsEvent.fire(this, oParent, sQuery, aResults);
- oCallbackFn(sQuery, aResults, oParent);
-};
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The DataSource classes manages sending a request and returning response from a live
+ * database. Supported data include local JavaScript arrays and objects and databases
+ * accessible via XHR connections. Supported response formats include JavaScript arrays,
+ * JSON, XML, and flat-file textual data.
+ *
+ * @class DataSource
+ * @constructor
+ */
+YAHOO.widget.DataSource = function() {
+ /* abstract class */
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public constants
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Error message for null data responses.
+ *
+ * @property ERROR_DATANULL
+ * @type String
+ * @static
+ * @final
+ */
+YAHOO.widget.DataSource.ERROR_DATANULL = "Response data was null";
+
+/**
+ * Error message for data responses with parsing errors.
+ *
+ * @property ERROR_DATAPARSE
+ * @type String
+ * @static
+ * @final
+ */
+YAHOO.widget.DataSource.ERROR_DATAPARSE = "Response data could not be parsed";
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Max size of the local cache. Set to 0 to turn off caching. Caching is
+ * useful to reduce the number of server connections. Recommended only for data
+ * sources that return comprehensive results for queries or when stale data is
+ * not an issue.
+ *
+ * @property maxCacheEntries
+ * @type Number
+ * @default 15
+ */
+YAHOO.widget.DataSource.prototype.maxCacheEntries = 15;
+
+/**
+ * Use this to equate cache matching with the type of matching done by your live
+ * data source. If caching is on and queryMatchContains is true, the cache
+ * returns results that "contain" the query string. By default,
+ * queryMatchContains is set to false, meaning the cache only returns results
+ * that "start with" the query string.
+ *
+ * @property queryMatchContains
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.DataSource.prototype.queryMatchContains = false;
+
+/**
+ * Enables query subset matching. If caching is on and queryMatchSubset is
+ * true, substrings of queries will return matching cached results. For
+ * instance, if the first query is for "abc" susequent queries that start with
+ * "abc", like "abcd", will be queried against the cache, and not the live data
+ * source. Recommended only for DataSources that return comprehensive results
+ * for queries with very few characters.
+ *
+ * @property queryMatchSubset
+ * @type Boolean
+ * @default false
+ *
+ */
+YAHOO.widget.DataSource.prototype.queryMatchSubset = false;
+
+/**
+ * Enables query case-sensitivity matching. If caching is on and
+ * queryMatchCase is true, queries will only return results for case-sensitive
+ * matches.
+ *
+ * @property queryMatchCase
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.DataSource.prototype.queryMatchCase = false;
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the DataSource instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the DataSource instance
+ */
+YAHOO.widget.DataSource.prototype.toString = function() {
+ return "DataSource " + this._sName;
+};
+
+/**
+ * Retrieves query results, first checking the local cache, then making the
+ * query request to the live data source as defined by the function doQuery.
+ *
+ * @method getResults
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DataSource.prototype.getResults = function(oCallbackFn, sQuery, oParent) {
+
+ // First look in cache
+ var aResults = this._doQueryCache(oCallbackFn,sQuery,oParent);
+
+ // Not in cache, so get results from server
+ if(aResults.length === 0) {
+ this.queryEvent.fire(this, oParent, sQuery);
+ this.doQuery(oCallbackFn, sQuery, oParent);
+ }
+};
+
+/**
+ * Abstract method implemented by subclasses to make a query to the live data
+ * source. Must call the callback function with the response returned from the
+ * query. Populates cache (if enabled).
+ *
+ * @method doQuery
+ * @param oCallbackFn {HTMLFunction} Callback function implemented by oParent to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ /* override this */
+};
+
+/**
+ * Flushes cache.
+ *
+ * @method flushCache
+ */
+YAHOO.widget.DataSource.prototype.flushCache = function() {
+ if(this._aCache) {
+ this._aCache = [];
+ }
+ if(this._aCacheHelper) {
+ this._aCacheHelper = [];
+ }
+ this.cacheFlushEvent.fire(this);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public events
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Fired when a query is made to the live data source.
+ *
+ * @event queryEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ */
+YAHOO.widget.DataSource.prototype.queryEvent = null;
+
+/**
+ * Fired when a query is made to the local cache.
+ *
+ * @event cacheQueryEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ */
+YAHOO.widget.DataSource.prototype.cacheQueryEvent = null;
+
+/**
+ * Fired when data is retrieved from the live data source.
+ *
+ * @event getResultsEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} Array of result objects.
+ */
+YAHOO.widget.DataSource.prototype.getResultsEvent = null;
+
+/**
+ * Fired when data is retrieved from the local cache.
+ *
+ * @event getCachedResultsEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} Array of result objects.
+ */
+YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null;
+
+/**
+ * Fired when an error is encountered with the live data source.
+ *
+ * @event dataErrorEvent
+ * @param oSelf {Object} The DataSource instance.
+ * @param oParent {Object} The requesting object.
+ * @param sQuery {String} The query string.
+ * @param sMsg {String} Error message string
+ */
+YAHOO.widget.DataSource.prototype.dataErrorEvent = null;
+
+/**
+ * Fired when the local cache is flushed.
+ *
+ * @event cacheFlushEvent
+ * @param oSelf {Object} The DataSource instance
+ */
+YAHOO.widget.DataSource.prototype.cacheFlushEvent = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Internal class variable to index multiple DataSource instances.
+ *
+ * @property _nIndex
+ * @type Number
+ * @private
+ * @static
+ */
+YAHOO.widget.DataSource._nIndex = 0;
+
+/**
+ * Name of DataSource instance.
+ *
+ * @property _sName
+ * @type String
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._sName = null;
+
+/**
+ * Local cache of data result objects indexed chronologically.
+ *
+ * @property _aCache
+ * @type Object[]
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._aCache = null;
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Initializes DataSource instance.
+ *
+ * @method _init
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._init = function() {
+ // Validate and initialize public configs
+ var maxCacheEntries = this.maxCacheEntries;
+ if(isNaN(maxCacheEntries) || (maxCacheEntries < 0)) {
+ maxCacheEntries = 0;
+ }
+ // Initialize local cache
+ if(maxCacheEntries > 0 && !this._aCache) {
+ this._aCache = [];
+ }
+
+ this._sName = "instance" + YAHOO.widget.DataSource._nIndex;
+ YAHOO.widget.DataSource._nIndex++;
+
+ this.queryEvent = new YAHOO.util.CustomEvent("query", this);
+ this.cacheQueryEvent = new YAHOO.util.CustomEvent("cacheQuery", this);
+ this.getResultsEvent = new YAHOO.util.CustomEvent("getResults", this);
+ this.getCachedResultsEvent = new YAHOO.util.CustomEvent("getCachedResults", this);
+ this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
+ this.cacheFlushEvent = new YAHOO.util.CustomEvent("cacheFlush", this);
+};
+
+/**
+ * Adds a result object to the local cache, evicting the oldest element if the
+ * cache is full. Newer items will have higher indexes, the oldest item will have
+ * index of 0.
+ *
+ * @method _addCacheElem
+ * @param oResult {Object} Data result object, including array of results.
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._addCacheElem = function(oResult) {
+ var aCache = this._aCache;
+ // Don't add if anything important is missing.
+ if(!aCache || !oResult || !oResult.query || !oResult.results) {
+ return;
+ }
+
+ // If the cache is full, make room by removing from index=0
+ if(aCache.length >= this.maxCacheEntries) {
+ aCache.shift();
+ }
+
+ // Add to cache, at the end of the array
+ aCache.push(oResult);
+};
+
+/**
+ * Queries the local cache for results. If query has been cached, the callback
+ * function is called with the results, and the cached is refreshed so that it
+ * is now the newest element.
+ *
+ * @method _doQueryCache
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ * @return aResults {Object[]} Array of results from local cache if found, otherwise null.
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._doQueryCache = function(oCallbackFn, sQuery, oParent) {
+ var aResults = [];
+ var bMatchFound = false;
+ var aCache = this._aCache;
+ var nCacheLength = (aCache) ? aCache.length : 0;
+ var bMatchContains = this.queryMatchContains;
+
+ // If cache is enabled...
+ if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) {
+ this.cacheQueryEvent.fire(this, oParent, sQuery);
+ // If case is unimportant, normalize query now instead of in loops
+ if(!this.queryMatchCase) {
+ var sOrigQuery = sQuery;
+ sQuery = sQuery.toLowerCase();
+ }
+
+ // Loop through each cached element's query property...
+ for(var i = nCacheLength-1; i >= 0; i--) {
+ var resultObj = aCache[i];
+ var aAllResultItems = resultObj.results;
+ // If case is unimportant, normalize match key for comparison
+ var matchKey = (!this.queryMatchCase) ?
+ encodeURIComponent(resultObj.query).toLowerCase():
+ encodeURIComponent(resultObj.query);
+
+ // If a cached match key exactly matches the query...
+ if(matchKey == sQuery) {
+ // Stash all result objects into aResult[] and stop looping through the cache.
+ bMatchFound = true;
+ aResults = aAllResultItems;
+
+ // The matching cache element was not the most recent,
+ // so now we need to refresh the cache.
+ if(i != nCacheLength-1) {
+ // Remove element from its original location
+ aCache.splice(i,1);
+ // Add element as newest
+ this._addCacheElem(resultObj);
+ }
+ break;
+ }
+ // Else if this query is not an exact match and subset matching is enabled...
+ else if(this.queryMatchSubset) {
+ // Loop through substrings of each cached element's query property...
+ for(var j = sQuery.length-1; j >= 0 ; j--) {
+ var subQuery = sQuery.substr(0,j);
+
+ // If a substring of a cached sQuery exactly matches the query...
+ if(matchKey == subQuery) {
+ bMatchFound = true;
+
+ // Go through each cached result object to match against the query...
+ for(var k = aAllResultItems.length-1; k >= 0; k--) {
+ var aRecord = aAllResultItems[k];
+ var sKeyIndex = (this.queryMatchCase) ?
+ encodeURIComponent(aRecord[0]).indexOf(sQuery):
+ encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);
+
+ // A STARTSWITH match is when the query is found at the beginning of the key string...
+ if((!bMatchContains && (sKeyIndex === 0)) ||
+ // A CONTAINS match is when the query is found anywhere within the key string...
+ (bMatchContains && (sKeyIndex > -1))) {
+ // Stash a match into aResults[].
+ aResults.unshift(aRecord);
+ }
+ }
+
+ // Add the subset match result set object as the newest element to cache,
+ // and stop looping through the cache.
+ resultObj = {};
+ resultObj.query = sQuery;
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+ break;
+ }
+ }
+ if(bMatchFound) {
+ break;
+ }
+ }
+ }
+
+ // If there was a match, send along the results.
+ if(bMatchFound) {
+ this.getCachedResultsEvent.fire(this, oParent, sOrigQuery, aResults);
+ oCallbackFn(sOrigQuery, aResults, oParent);
+ }
+ }
+ return aResults;
+};
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using XML HTTP requests that return
+ * query results.
+ *
+ * @class DS_XHR
+ * @extends YAHOO.widget.DataSource
+ * @requires connection
+ * @constructor
+ * @param sScriptURI {String} Absolute or relative URI to script that returns query
+ * results as JSON, XML, or delimited flat-file data.
+ * @param aSchema {String[]} Data schema definition of results.
+ * @param oConfigs {Object} (optional) Object literal of config params.
+ */
+YAHOO.widget.DS_XHR = function(sScriptURI, aSchema, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!aSchema || (aSchema.constructor != Array)) {
+ return;
+ }
+ else {
+ this.schema = aSchema;
+ }
+ this.scriptURI = sScriptURI;
+ this._init();
+};
+
+YAHOO.widget.DS_XHR.prototype = new YAHOO.widget.DataSource();
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public constants
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * JSON data type.
+ *
+ * @property TYPE_JSON
+ * @type Number
+ * @static
+ * @final
+ */
+YAHOO.widget.DS_XHR.TYPE_JSON = 0;
+
+/**
+ * XML data type.
+ *
+ * @property TYPE_XML
+ * @type Number
+ * @static
+ * @final
+ */
+YAHOO.widget.DS_XHR.TYPE_XML = 1;
+
+/**
+ * Flat-file data type.
+ *
+ * @property TYPE_FLAT
+ * @type Number
+ * @static
+ * @final
+ */
+YAHOO.widget.DS_XHR.TYPE_FLAT = 2;
+
+/**
+ * Error message for XHR failure.
+ *
+ * @property ERROR_DATAXHR
+ * @type String
+ * @static
+ * @final
+ */
+YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed";
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Alias to YUI Connection Manager. Allows implementers to specify their own
+ * subclasses of the YUI Connection Manager utility.
+ *
+ * @property connMgr
+ * @type Object
+ * @default YAHOO.util.Connect
+ */
+YAHOO.widget.DS_XHR.prototype.connMgr = YAHOO.util.Connect;
+
+/**
+ * Number of milliseconds the XHR connection will wait for a server response. A
+ * a value of zero indicates the XHR connection will wait forever. Any value
+ * greater than zero will use the Connection utility's Auto-Abort feature.
+ *
+ * @property connTimeout
+ * @type Number
+ * @default 0
+ */
+YAHOO.widget.DS_XHR.prototype.connTimeout = 0;
+
+/**
+ * Absolute or relative URI to script that returns query results. For instance,
+ * queries will be sent to <scriptURI>?<scriptQueryParam>=userinput
+ *
+ * @property scriptURI
+ * @type String
+ */
+YAHOO.widget.DS_XHR.prototype.scriptURI = null;
+
+/**
+ * Query string parameter name sent to scriptURI. For instance, queries will be
+ * sent to <scriptURI>?<scriptQueryParam>=userinput
+ *
+ * @property scriptQueryParam
+ * @type String
+ * @default "query"
+ */
+YAHOO.widget.DS_XHR.prototype.scriptQueryParam = "query";
+
+/**
+ * String of key/value pairs to append to requests made to scriptURI. Define
+ * this string when you want to send additional query parameters to your script.
+ * When defined, queries will be sent to
+ * <scriptURI>?<scriptQueryParam>=userinput&<scriptQueryAppend>
+ *
+ * @property scriptQueryAppend
+ * @type String
+ * @default ""
+ */
+YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = "";
+
+/**
+ * XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML
+ * and YAHOO.widget.DS_XHR.TYPE_FLAT.
+ *
+ * @property responseType
+ * @type String
+ * @default YAHOO.widget.DS_XHR.TYPE_JSON
+ */
+YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.TYPE_JSON;
+
+/**
+ * String after which to strip results. If the results from the XHR are sent
+ * back as HTML, the gzip HTML comment appears at the end of the data and should
+ * be ignored.
+ *
+ * @property responseStripAfter
+ * @type String
+ * @default "\n<!-"
+ */
+YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n 0) {
+ sUri += "&" + this.scriptQueryAppend;
+ }
+ var oResponse = null;
+
+ var oSelf = this;
+ /*
+ * Sets up ajax request callback
+ *
+ * @param {object} oReq HTTPXMLRequest object
+ * @private
+ */
+ var responseSuccess = function(oResp) {
+ // Response ID does not match last made request ID.
+ if(!oSelf._oConn || (oResp.tId != oSelf._oConn.tId)) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
+ return;
+ }
+//DEBUG
+for(var foo in oResp) {
+}
+ if(!isXML) {
+ oResp = oResp.responseText;
+ }
+ else {
+ oResp = oResp.responseXML;
+ }
+ if(oResp === null) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
+ return;
+ }
+
+ var aResults = oSelf.parseResponse(sQuery, oResp, oParent);
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ if(aResults === null) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATAPARSE);
+ aResults = [];
+ }
+ else {
+ oSelf.getResultsEvent.fire(oSelf, oParent, sQuery, aResults);
+ oSelf._addCacheElem(resultObj);
+ }
+ oCallbackFn(sQuery, aResults, oParent);
+ };
+
+ var responseFailure = function(oResp) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DS_XHR.ERROR_DATAXHR);
+ return;
+ };
+
+ var oCallback = {
+ success:responseSuccess,
+ failure:responseFailure
+ };
+
+ if(!isNaN(this.connTimeout) && this.connTimeout > 0) {
+ oCallback.timeout = this.connTimeout;
+ }
+
+ if(this._oConn) {
+ this.connMgr.abort(this._oConn);
+ }
+
+ oSelf._oConn = this.connMgr.asyncRequest("GET", sUri, oCallback, null);
+};
+
+/**
+ * Parses raw response data into an array of result objects. The result data key
+ * is always stashed in the [0] element of each result object.
+ *
+ * @method parseResponse
+ * @param sQuery {String} Query string.
+ * @param oResponse {Object} The raw response data to parse.
+ * @param oParent {Object} The object instance that has requested data.
+ * @returns {Object[]} Array of result objects.
+ */
+YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParent) {
+ var aSchema = this.schema;
+ var aResults = [];
+ var bError = false;
+
+ // Strip out comment at the end of results
+ var nEnd = ((this.responseStripAfter !== "") && (oResponse.indexOf)) ?
+ oResponse.indexOf(this.responseStripAfter) : -1;
+ if(nEnd != -1) {
+ oResponse = oResponse.substring(0,nEnd);
+ }
+
+ switch (this.responseType) {
+ case YAHOO.widget.DS_XHR.TYPE_JSON:
+ var jsonList;
+ // Divert KHTML clients from JSON lib
+ if(window.JSON && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) {
+ // Use the JSON utility if available
+ var jsonObjParsed = JSON.parse(oResponse);
+ if(!jsonObjParsed) {
+ bError = true;
+ break;
+ }
+ else {
+ try {
+ // eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("jsonObjParsed." + aSchema[0]);
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+ }
+ else {
+ // Parse the JSON response as a string
+ try {
+ // Trim leading spaces
+ while (oResponse.substring(0,1) == " ") {
+ oResponse = oResponse.substring(1, oResponse.length);
+ }
+
+ // Invalid JSON response
+ if(oResponse.indexOf("{") < 0) {
+ bError = true;
+ break;
+ }
+
+ // Empty (but not invalid) JSON response
+ if(oResponse.indexOf("{}") === 0) {
+ break;
+ }
+
+ // Turn the string into an object literal...
+ // ...eval is necessary here
+ var jsonObjRaw = eval("(" + oResponse + ")");
+ if(!jsonObjRaw) {
+ bError = true;
+ break;
+ }
+
+ // Grab the object member that contains an array of all reponses...
+ // ...eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("(jsonObjRaw." + aSchema[0]+")");
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+
+ if(!jsonList) {
+ bError = true;
+ break;
+ }
+
+ if(jsonList.constructor != Array) {
+ jsonList = [jsonList];
+ }
+
+ // Loop through the array of all responses...
+ for(var i = jsonList.length-1; i >= 0 ; i--) {
+ var aResultItem = [];
+ var jsonResult = jsonList[i];
+ // ...and loop through each data field value of each response
+ for(var j = aSchema.length-1; j >= 1 ; j--) {
+ // ...and capture data into an array mapped according to the schema...
+ var dataFieldValue = jsonResult[aSchema[j]];
+ if(!dataFieldValue) {
+ dataFieldValue = "";
+ }
+ aResultItem.unshift(dataFieldValue);
+ }
+ // If schema isn't well defined, pass along the entire result object
+ if(aResultItem.length == 1) {
+ aResultItem.push(jsonResult);
+ }
+ // Capture the array of data field values in an array of results
+ aResults.unshift(aResultItem);
+ }
+ break;
+ case YAHOO.widget.DS_XHR.TYPE_XML:
+ // Get the collection of results
+ var xmlList = oResponse.getElementsByTagName(aSchema[0]);
+ if(!xmlList) {
+ bError = true;
+ break;
+ }
+ // Loop through each result
+ for(var k = xmlList.length-1; k >= 0 ; k--) {
+ var result = xmlList.item(k);
+ var aFieldSet = [];
+ // Loop through each data field in each result using the schema
+ for(var m = aSchema.length-1; m >= 1 ; m--) {
+ var sValue = null;
+ // Values may be held in an attribute...
+ var xmlAttr = result.attributes.getNamedItem(aSchema[m]);
+ if(xmlAttr) {
+ sValue = xmlAttr.value;
+ }
+ // ...or in a node
+ else{
+ var xmlNode = result.getElementsByTagName(aSchema[m]);
+ if(xmlNode && xmlNode.item(0) && xmlNode.item(0).firstChild) {
+ sValue = xmlNode.item(0).firstChild.nodeValue;
+ }
+ else {
+ sValue = "";
+ }
+ }
+ // Capture the schema-mapped data field values into an array
+ aFieldSet.unshift(sValue);
+ }
+ // Capture each array of values into an array of results
+ aResults.unshift(aFieldSet);
+ }
+ break;
+ case YAHOO.widget.DS_XHR.TYPE_FLAT:
+ if(oResponse.length > 0) {
+ // Delete the last line delimiter at the end of the data if it exists
+ var newLength = oResponse.length-aSchema[0].length;
+ if(oResponse.substr(newLength) == aSchema[0]) {
+ oResponse = oResponse.substr(0, newLength);
+ }
+ var aRecords = oResponse.split(aSchema[0]);
+ for(var n = aRecords.length-1; n >= 0; n--) {
+ aResults[n] = aRecords[n].split(aSchema[1]);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ sQuery = null;
+ oResponse = null;
+ oParent = null;
+ if(bError) {
+ return null;
+ }
+ else {
+ return aResults;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * XHR connection object.
+ *
+ * @property _oConn
+ * @type Object
+ * @private
+ */
+YAHOO.widget.DS_XHR.prototype._oConn = null;
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using a native Javascript function as
+ * its live data source.
+ *
+ * @class DS_JSFunction
+ * @constructor
+ * @extends YAHOO.widget.DataSource
+ * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects.
+ * @param oConfigs {Object} (optional) Object literal of config params.
+ */
+YAHOO.widget.DS_JSFunction = function(oFunction, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!oFunction || (oFunction.constructor != Function)) {
+ return;
+ }
+ else {
+ this.dataFunction = oFunction;
+ this._init();
+ }
+};
+
+YAHOO.widget.DS_JSFunction.prototype = new YAHOO.widget.DataSource();
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * In-memory Javascript function that returns query results.
+ *
+ * @property dataFunction
+ * @type HTMLFunction
+ */
+YAHOO.widget.DS_JSFunction.prototype.dataFunction = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Queries the live data source defined by function for results. Results are
+ * passed back to a callback function.
+ *
+ * @method doQuery
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DS_JSFunction.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var oFunction = this.dataFunction;
+ var aResults = [];
+
+ aResults = oFunction(sQuery);
+ if(aResults === null) {
+ this.dataErrorEvent.fire(this, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
+ return;
+ }
+
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ oCallbackFn(sQuery, aResults, oParent);
+ return;
+};
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using a native Javascript array as
+ * its live data source.
+ *
+ * @class DS_JSArray
+ * @constructor
+ * @extends YAHOO.widget.DataSource
+ * @param aData {String[]} In-memory Javascript array of simple string data.
+ * @param oConfigs {Object} (optional) Object literal of config params.
+ */
+YAHOO.widget.DS_JSArray = function(aData, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!aData || (aData.constructor != Array)) {
+ return;
+ }
+ else {
+ this.data = aData;
+ this._init();
+ }
+};
+
+YAHOO.widget.DS_JSArray.prototype = new YAHOO.widget.DataSource();
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * In-memory Javascript array of strings.
+ *
+ * @property data
+ * @type Array
+ */
+YAHOO.widget.DS_JSArray.prototype.data = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Queries the live data source defined by data for results. Results are passed
+ * back to a callback function.
+ *
+ * @method doQuery
+ * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results.
+ * @param sQuery {String} Query string.
+ * @param oParent {Object} The object instance that has requested data.
+ */
+YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var aData = this.data; // the array
+ var aResults = []; // container for results
+ var bMatchFound = false;
+ var bMatchContains = this.queryMatchContains;
+ if(sQuery) {
+ if(!this.queryMatchCase) {
+ sQuery = sQuery.toLowerCase();
+ }
+
+ // Loop through each element of the array...
+ // which can be a string or an array of strings
+ for(var i = aData.length-1; i >= 0; i--) {
+ var aDataset = [];
+
+ if(aData[i]) {
+ if(aData[i].constructor == String) {
+ aDataset[0] = aData[i];
+ }
+ else if(aData[i].constructor == Array) {
+ aDataset = aData[i];
+ }
+ }
+
+ if(aDataset[0] && (aDataset[0].constructor == String)) {
+ var sKeyIndex = (this.queryMatchCase) ?
+ encodeURIComponent(aDataset[0]).indexOf(sQuery):
+ encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);
+
+ // A STARTSWITH match is when the query is found at the beginning of the key string...
+ if((!bMatchContains && (sKeyIndex === 0)) ||
+ // A CONTAINS match is when the query is found anywhere within the key string...
+ (bMatchContains && (sKeyIndex > -1))) {
+ // Stash a match into aResults[].
+ aResults.unshift(aDataset);
+ }
+ }
+ }
+ }
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ oCallbackFn(sQuery, aResults, oParent);
+};
diff --git a/lib/yui/calendar/README b/lib/yui/calendar/README
index eaeb49202c..d4fc65d143 100755
--- a/lib/yui/calendar/README
+++ b/lib/yui/calendar/README
@@ -1,73 +1,77 @@
-Calendar Release Notes
-
-*** version 0.12.1 ***
-
- - Calendar and CalendarGroup now automatically parse the argument passed to setMonth and setYear into an integer, eliminating potential concatenation bugs.
-
-*** version 0.12 ***
-
- - New documentation format implemented
- - Calendar2up and Calendar_Core are now deprecated. Now, Calendar alone represents the single Calendar instance, and CalendarGroup represents an n-up instance, defaulting to 2up
- - Added semantic style classes to Calendar elements to allow for custom styling solely using CSS.
- - Remapped all configuration properties to use the Config object (familiar to those who use the Container collection of controls). Property names are the same as their previous counterparts, but wrapped into Calendar.cfg, allowing for runtime reconfiguration of most properties
- - Added "title" property for setting the Calendar title
- - Added "close" property for enabling and disabling the close icon
- - Added "iframe" property for enabling an iframe shim in Internet Explorer 6 and below to fix the select bleed-through bug
- - pageDate moved to property: "pagedate"
- - selectedDates moved to property: "selected"
- - minDate moved to property : "mindate", which accepts a JavaScript Date object like its predecessor, but also supports string dates
- - maxDate moved to property : "maxdate", which accepts a JavaScript Date object like its predecessor, but also supports string dates
- - Moved style declarations to initStyles function
- - Optimized event handling in doSelectCell/doCellMouseOver/doCellMouseOut by only attaching the listener to the outer Calendar container, and only reacting to events on cells with the "selectable" CSS class.
- - Added domEventMap field for applying DOM event listeners to cells containing specific class and tag combinations.
- - Moved all cell DOM event attachment to applyListeners function
- - Added getDateByCellId / getDateFieldsByCellId helper functions
- - Corrected DateMath.getWeekNumber to comply with ISO week number handling
- - Separated renderCellDefault style portions into styleCellDefault function for easy extension
- - Deprecated onBeforeSelect. Created beforeSelectEvent which automatically subscribes to its deprecated predecessor.
- - Deprecated onSelect. Created selectEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onBeforeDeselect. Created beforeSelectEvent which automatically subscribes to its deprecated predecessor.
- - Deprecated onDeselect. Created beforeDeselectEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onChangePage. Created changePageEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onRender. Created renderEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onReset. Created resetEvent, which automatically subscribes to its deprecated predecessor.
- - Deprecated onClear. Created clearEvent, which automatically subscribes to its deprecated predecessor.
- - Corrected setMonth documentation to refer to 0-11 indexed months.
- - Added show and hide methods to Calendar for setting the Calendar's display property.
- - Optimized internal render classes to use innerHTML and string buffers
- - Removed wireCustomEvents function
- - Removed wireDefaultEvents function
- - Removed doNextMonth / doPreviousMonth
- - Removed all buildShell (header, body, footer) functions, since the Calendar shell is now built dynamically on each render
- - Wired all CalendarGroup events and configuration properties to be properly delegated to Calendar
- - Augmented CalendarGroup with all built-in renderers, label functions, hide, show, and initStyles, creating API transparency between Calendar and CalendarGroup.
- - Made all tagName, createElement, and entity references XHTML compliant
- - Fixed Daylight Saving Time bug for Brazilian time zone
-
-*** version 0.11.3 ***
-
- - Calendar_Core: Added arguments for selected/deselected dates to onSelect/onDeselect
- - CalendarGroup: Fixed bug where selected dates passed to constructor were not represented in selectedDates
- - Calendar2up: Now displays correctly in Opera 9
-
-*** version 0.11.0 ***
-
- - DateMath: DateMath.add now properly adds weeks
- - DateMath: between() function added
- - DateMath: getWeekNumber() fixed to take starting day of week into account
- - All references to Calendar's built in CSS class handlers are removed, replaced with calls to Dom utility (addClass, removeClass)
- - Several CSS class constants now have clearer names
- - All CSS classes are now properly namespaced to avoid CSS conflicts
- - Fixed table:hover bug in CSS
- - Calendar no longer requires the container ID and variable name to match in order for month navigation to function properly
- - Calendar month navigation arrows are now represented as background images
-
-*** version 0.10.0 ***
-
- - Major performance improvements from attaching DOM events to associated table cells only once, when the Calendar shell is built
- - DOM events for mouseover/mouseout are now fired for all browsers (not just Internet Explorer)
- - Reset functionality bug fixed for 2-up Calendar view
-
-*** version 0.9.0 ***
-
-* Initial release
+Calendar Release Notes
+
+*** version 0.12.2 ***
+
+ - Corrected documentation for clearTime function to reflect the change from midnight to noon
+
+*** version 0.12.1 ***
+
+ - Calendar and CalendarGroup now automatically parse the argument passed to setMonth and setYear into an integer, eliminating potential concatenation bugs.
+
+*** version 0.12 ***
+
+ - New documentation format implemented
+ - Calendar2up and Calendar_Core are now deprecated. Now, Calendar alone represents the single Calendar instance, and CalendarGroup represents an n-up instance, defaulting to 2up
+ - Added semantic style classes to Calendar elements to allow for custom styling solely using CSS.
+ - Remapped all configuration properties to use the Config object (familiar to those who use the Container collection of controls). Property names are the same as their previous counterparts, but wrapped into Calendar.cfg, allowing for runtime reconfiguration of most properties
+ - Added "title" property for setting the Calendar title
+ - Added "close" property for enabling and disabling the close icon
+ - Added "iframe" property for enabling an iframe shim in Internet Explorer 6 and below to fix the select bleed-through bug
+ - pageDate moved to property: "pagedate"
+ - selectedDates moved to property: "selected"
+ - minDate moved to property : "mindate", which accepts a JavaScript Date object like its predecessor, but also supports string dates
+ - maxDate moved to property : "maxdate", which accepts a JavaScript Date object like its predecessor, but also supports string dates
+ - Moved style declarations to initStyles function
+ - Optimized event handling in doSelectCell/doCellMouseOver/doCellMouseOut by only attaching the listener to the outer Calendar container, and only reacting to events on cells with the "selectable" CSS class.
+ - Added domEventMap field for applying DOM event listeners to cells containing specific class and tag combinations.
+ - Moved all cell DOM event attachment to applyListeners function
+ - Added getDateByCellId / getDateFieldsByCellId helper functions
+ - Corrected DateMath.getWeekNumber to comply with ISO week number handling
+ - Separated renderCellDefault style portions into styleCellDefault function for easy extension
+ - Deprecated onBeforeSelect. Created beforeSelectEvent which automatically subscribes to its deprecated predecessor.
+ - Deprecated onSelect. Created selectEvent, which automatically subscribes to its deprecated predecessor.
+ - Deprecated onBeforeDeselect. Created beforeSelectEvent which automatically subscribes to its deprecated predecessor.
+ - Deprecated onDeselect. Created beforeDeselectEvent, which automatically subscribes to its deprecated predecessor.
+ - Deprecated onChangePage. Created changePageEvent, which automatically subscribes to its deprecated predecessor.
+ - Deprecated onRender. Created renderEvent, which automatically subscribes to its deprecated predecessor.
+ - Deprecated onReset. Created resetEvent, which automatically subscribes to its deprecated predecessor.
+ - Deprecated onClear. Created clearEvent, which automatically subscribes to its deprecated predecessor.
+ - Corrected setMonth documentation to refer to 0-11 indexed months.
+ - Added show and hide methods to Calendar for setting the Calendar's display property.
+ - Optimized internal render classes to use innerHTML and string buffers
+ - Removed wireCustomEvents function
+ - Removed wireDefaultEvents function
+ - Removed doNextMonth / doPreviousMonth
+ - Removed all buildShell (header, body, footer) functions, since the Calendar shell is now built dynamically on each render
+ - Wired all CalendarGroup events and configuration properties to be properly delegated to Calendar
+ - Augmented CalendarGroup with all built-in renderers, label functions, hide, show, and initStyles, creating API transparency between Calendar and CalendarGroup.
+ - Made all tagName, createElement, and entity references XHTML compliant
+ - Fixed Daylight Saving Time bug for Brazilian time zone
+
+*** version 0.11.3 ***
+
+ - Calendar_Core: Added arguments for selected/deselected dates to onSelect/onDeselect
+ - CalendarGroup: Fixed bug where selected dates passed to constructor were not represented in selectedDates
+ - Calendar2up: Now displays correctly in Opera 9
+
+*** version 0.11.0 ***
+
+ - DateMath: DateMath.add now properly adds weeks
+ - DateMath: between() function added
+ - DateMath: getWeekNumber() fixed to take starting day of week into account
+ - All references to Calendar's built in CSS class handlers are removed, replaced with calls to Dom utility (addClass, removeClass)
+ - Several CSS class constants now have clearer names
+ - All CSS classes are now properly namespaced to avoid CSS conflicts
+ - Fixed table:hover bug in CSS
+ - Calendar no longer requires the container ID and variable name to match in order for month navigation to function properly
+ - Calendar month navigation arrows are now represented as background images
+
+*** version 0.10.0 ***
+
+ - Major performance improvements from attaching DOM events to associated table cells only once, when the Calendar shell is built
+ - DOM events for mouseover/mouseout are now fired for all browsers (not just Internet Explorer)
+ - Reset functionality bug fixed for 2-up Calendar view
+
+*** version 0.9.0 ***
+
+* Initial release
diff --git a/lib/yui/calendar/assets/calendar.css b/lib/yui/calendar/assets/calendar.css
index 79f0a3282e..b97a705362 100755
--- a/lib/yui/calendar/assets/calendar.css
+++ b/lib/yui/calendar/assets/calendar.css
@@ -1,191 +1,191 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version 0.12.1
-*/
-
-.yui-calcontainer {
- position:relative;
- padding:5px;
- background-color:#F7F9FB;
- border:1px solid #7B9EBD;
- float:left;
- overflow:hidden;
-}
-
-.yui-calcontainer iframe {
- position:absolute;
- border:none;
- margin:0;padding:0;
- left:-1px;
- top:-1px;
- z-index:0;
- width:50em;
- height:50em;
-}
-
-.yui-calcontainer.multi {
- padding:0;
-}
-
-.yui-calcontainer.multi .groupcal {
- padding:5px;
- background-color:transparent;
- z-index:1;
- float:left;
- position:relative;
- border:none;
-}
-
-.yui-calcontainer .title {
- font:100% sans-serif;
- color:#000;
- font-weight:bold;
- margin-bottom:5px;
- height:25px;
- position:absolute;
- top:3px;left:5px;
- z-index:1;
-}
-
-.yui-calcontainer .close-icon {
- position:absolute;
- right:3px;
- top:3px;
- border:none;
- z-index:1;
-}
-
-/* Calendar element styles */
-
-.yui-calendar {
- font:100% sans-serif;
- text-align:center;
- border-spacing:0;
- border-collapse:separate;
- position:relative;
-}
-
-.yui-calcontainer.withtitle {
- padding-top:1.5em;
-}
-
-.yui-calendar .calnavleft {
- position:absolute;
- background-repeat:no-repeat;
- cursor:pointer;
- top:2px;
- bottom:0;
- width:9px;
- height:12px;
- left:2px;
- z-index:1;
-}
-
-.yui-calendar .calnavright {
- position:absolute;
- background-repeat:no-repeat;
- cursor:pointer;
- top:2px;
- bottom:0;
- width:9px;
- height:12px;
- right:2px;
- z-index:1;
-}
-
-.yui-calendar td.calcell {
- padding:.1em .2em;
- border:1px solid #E0E0E0;
- text-align:center;
-}
-
-.yui-calendar td.calcell a {
- color:#003DB8;
- text-decoration:none;
-}
-
-.yui-calendar td.calcell.today {
- border:1px solid #000;
-}
-
-.yui-calendar td.calcell.oom {
- cursor:default;
- color:#999;
- background-color:#EEE;
- border:1px solid #E0E0E0;
-}
-
-.yui-calendar td.calcell.selected {
- color:#003DB8;
- background-color:#FFF19F;
- border:1px solid #FF9900;
-}
-
-.yui-calendar td.calcell.calcellhover {
- cursor:pointer;
- color:#FFF;
- background-color:#FF9900;
- border:1px solid #FF9900;
-}
-
-.yui-calendar td.calcell.calcellhover a {
- color:#FFF;
-}
-
-.yui-calendar td.calcell.restricted {
- text-decoration:line-through;
-}
-
-.yui-calendar td.calcell.previous {
- color:#CCC;
-}
-
-.yui-calendar td.calcell.highlight1 { background-color:#CCFF99; }
-.yui-calendar td.calcell.highlight2 { background-color:#99CCFF; }
-.yui-calendar td.calcell.highlight3 { background-color:#FFCCCC; }
-.yui-calendar td.calcell.highlight4 { background-color:#CCFF99; }
-
-.yui-calendar .calhead {
- border:1px solid #E0E0E0;
- vertical-align:middle;
- background-color:#FFF;
-}
-
-.yui-calendar .calheader {
- position:relative;
- width:100%;
- text-align:center;
-}
-
-.yui-calendar .calheader img {
- border:none;
-}
-
-.yui-calendar .calweekdaycell {
- color:#666;
- font-weight:normal;
- text-align:center;
- width:1.5em;
-}
-
-.yui-calendar .calfoot {
- background-color:#EEE;
-}
-
-.yui-calendar .calrowhead, .yui-calendar .calrowfoot {
- color:#666;
- font-size:9px;
- font-style:italic;
- font-weight:normal;
- width:15px;
-}
-
-.yui-calendar .calrowhead {
- border-right-width:2px;
-}
-
-/*Specific changes for calendar running under fonts/reset */
-.yui-calendar a:hover {background:inherit;}
-p#clear {clear:left; padding-top:10px;}
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.12
+*/
+
+.yui-calcontainer {
+ position:relative;
+ padding:5px;
+ background-color:#F7F9FB;
+ border:1px solid #7B9EBD;
+ float:left;
+ overflow:hidden;
+}
+
+.yui-calcontainer iframe {
+ position:absolute;
+ border:none;
+ margin:0;padding:0;
+ left:-1px;
+ top:-1px;
+ z-index:0;
+ width:50em;
+ height:50em;
+}
+
+.yui-calcontainer.multi {
+ padding:0;
+}
+
+.yui-calcontainer.multi .groupcal {
+ padding:5px;
+ background-color:transparent;
+ z-index:1;
+ float:left;
+ position:relative;
+ border:none;
+}
+
+.yui-calcontainer .title {
+ font:100% sans-serif;
+ color:#000;
+ font-weight:bold;
+ margin-bottom:5px;
+ height:25px;
+ position:absolute;
+ top:3px;left:5px;
+ z-index:1;
+}
+
+.yui-calcontainer .close-icon {
+ position:absolute;
+ right:3px;
+ top:3px;
+ border:none;
+ z-index:1;
+}
+
+/* Calendar element styles */
+
+.yui-calendar {
+ font:100% sans-serif;
+ text-align:center;
+ border-spacing:0;
+ border-collapse:separate;
+ position:relative;
+}
+
+.yui-calcontainer.withtitle {
+ padding-top:1.5em;
+}
+
+.yui-calendar .calnavleft {
+ position:absolute;
+ background-repeat:no-repeat;
+ cursor:pointer;
+ top:2px;
+ bottom:0;
+ width:9px;
+ height:12px;
+ left:2px;
+ z-index:1;
+}
+
+.yui-calendar .calnavright {
+ position:absolute;
+ background-repeat:no-repeat;
+ cursor:pointer;
+ top:2px;
+ bottom:0;
+ width:9px;
+ height:12px;
+ right:2px;
+ z-index:1;
+}
+
+.yui-calendar td.calcell {
+ padding:.1em .2em;
+ border:1px solid #E0E0E0;
+ text-align:center;
+}
+
+.yui-calendar td.calcell a {
+ color:#003DB8;
+ text-decoration:none;
+}
+
+.yui-calendar td.calcell.today {
+ border:1px solid #000;
+}
+
+.yui-calendar td.calcell.oom {
+ cursor:default;
+ color:#999;
+ background-color:#EEE;
+ border:1px solid #E0E0E0;
+}
+
+.yui-calendar td.calcell.selected {
+ color:#003DB8;
+ background-color:#FFF19F;
+ border:1px solid #FF9900;
+}
+
+.yui-calendar td.calcell.calcellhover {
+ cursor:pointer;
+ color:#FFF;
+ background-color:#FF9900;
+ border:1px solid #FF9900;
+}
+
+.yui-calendar td.calcell.calcellhover a {
+ color:#FFF;
+}
+
+.yui-calendar td.calcell.restricted {
+ text-decoration:line-through;
+}
+
+.yui-calendar td.calcell.previous {
+ color:#CCC;
+}
+
+.yui-calendar td.calcell.highlight1 { background-color:#CCFF99; }
+.yui-calendar td.calcell.highlight2 { background-color:#99CCFF; }
+.yui-calendar td.calcell.highlight3 { background-color:#FFCCCC; }
+.yui-calendar td.calcell.highlight4 { background-color:#CCFF99; }
+
+.yui-calendar .calhead {
+ border:1px solid #E0E0E0;
+ vertical-align:middle;
+ background-color:#FFF;
+}
+
+.yui-calendar .calheader {
+ position:relative;
+ width:100%;
+ text-align:center;
+}
+
+.yui-calendar .calheader img {
+ border:none;
+}
+
+.yui-calendar .calweekdaycell {
+ color:#666;
+ font-weight:normal;
+ text-align:center;
+ width:1.5em;
+}
+
+.yui-calendar .calfoot {
+ background-color:#EEE;
+}
+
+.yui-calendar .calrowhead, .yui-calendar .calrowfoot {
+ color:#666;
+ font-size:9px;
+ font-style:italic;
+ font-weight:normal;
+ width:15px;
+}
+
+.yui-calendar .calrowhead {
+ border-right-width:2px;
+}
+
+/*Specific changes for calendar running under fonts/reset */
+.yui-calendar a:hover {background:inherit;}
+p#clear {clear:left; padding-top:10px;}
diff --git a/lib/yui/calendar/calendar-debug.js b/lib/yui/calendar/calendar-debug.js
index 5fec1653cd..622feef52e 100755
--- a/lib/yui/calendar/calendar-debug.js
+++ b/lib/yui/calendar/calendar-debug.js
@@ -1,4284 +1,4283 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version 0.12.1
-*/
-
-/**
-* Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
-* @namespace YAHOO.util
-* @class Config
-* @constructor
-* @param {Object} owner The owner Object to which this Config Object belongs
-*/
-YAHOO.util.Config = function(owner) {
- if (owner) {
- this.init(owner);
- } else {
- YAHOO.log("No owner specified for Config object", "error");
- }
-};
-
-YAHOO.util.Config.prototype = {
-
- /**
- * Object reference to the owner of this Config Object
- * @property owner
- * @type Object
- */
- owner : null,
-
- /**
- * Boolean flag that specifies whether a queue is currently being executed
- * @property queueInProgress
- * @type Boolean
- */
- queueInProgress : false,
-
-
- /**
- * Validates that the value passed in is a Boolean.
- * @method checkBoolean
- * @param {Object} val The value to validate
- * @return {Boolean} true, if the value is valid
- */
- checkBoolean: function(val) {
- if (typeof val == 'boolean') {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Validates that the value passed in is a number.
- * @method checkNumber
- * @param {Object} val The value to validate
- * @return {Boolean} true, if the value is valid
- */
- checkNumber: function(val) {
- if (isNaN(val)) {
- return false;
- } else {
- return true;
- }
- }
-};
-
-
-/**
-* Initializes the configuration Object and all of its local members.
-* @method init
-* @param {Object} owner The owner Object to which this Config Object belongs
-*/
-YAHOO.util.Config.prototype.init = function(owner) {
-
- this.owner = owner;
-
- /**
- * Object reference to the owner of this Config Object
- * @event configChangedEvent
- */
- this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
- this.queueInProgress = false;
-
- /* Private Members */
-
- /**
- * Maintains the local collection of configuration property objects and their specified values
- * @property config
- * @private
- * @type Object
- */
- var config = {};
-
- /**
- * Maintains the local collection of configuration property objects as they were initially applied.
- * This object is used when resetting a property.
- * @property initialConfig
- * @private
- * @type Object
- */
- var initialConfig = {};
-
- /**
- * Maintains the local, normalized CustomEvent queue
- * @property eventQueue
- * @private
- * @type Object
- */
- var eventQueue = [];
-
- /**
- * Fires a configuration property event using the specified value.
- * @method fireEvent
- * @private
- * @param {String} key The configuration property's name
- * @param {value} Object The value of the correct type for the property
- */
- var fireEvent = function( key, value ) {
- YAHOO.log("Firing Config event: " + key + "=" + value, "info");
-
- key = key.toLowerCase();
-
- var property = config[key];
-
- if (typeof property != 'undefined' && property.event) {
- property.event.fire(value);
- }
- };
- /* End Private Members */
-
- /**
- * Adds a property to the Config Object's private config hash.
- * @method addProperty
- * @param {String} key The configuration property's name
- * @param {Object} propertyObject The Object containing all of this property's arguments
- */
- this.addProperty = function( key, propertyObject ) {
- key = key.toLowerCase();
-
- YAHOO.log("Added property: " + key, "info");
-
- config[key] = propertyObject;
-
- propertyObject.event = new YAHOO.util.CustomEvent(key);
- propertyObject.key = key;
-
- if (propertyObject.handler) {
- propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
- }
-
- this.setProperty(key, propertyObject.value, true);
-
- if (! propertyObject.suppressEvent) {
- this.queueProperty(key, propertyObject.value);
- }
- };
-
- /**
- * Returns a key-value configuration map of the values currently set in the Config Object.
- * @method getConfig
- * @return {Object} The current config, represented in a key-value map
- */
- this.getConfig = function() {
- var cfg = {};
-
- for (var prop in config) {
- var property = config[prop];
- if (typeof property != 'undefined' && property.event) {
- cfg[prop] = property.value;
- }
- }
-
- return cfg;
- };
-
- /**
- * Returns the value of specified property.
- * @method getProperty
- * @param {String} key The name of the property
- * @return {Object} The value of the specified property
- */
- this.getProperty = function(key) {
- key = key.toLowerCase();
-
- var property = config[key];
- if (typeof property != 'undefined' && property.event) {
- return property.value;
- } else {
- return undefined;
- }
- };
-
- /**
- * Resets the specified property's value to its initial value.
- * @method resetProperty
- * @param {String} key The name of the property
- * @return {Boolean} True is the property was reset, false if not
- */
- this.resetProperty = function(key) {
- key = key.toLowerCase();
-
- var property = config[key];
- if (typeof property != 'undefined' && property.event) {
- if (initialConfig[key] && initialConfig[key] != 'undefined') {
- this.setProperty(key, initialConfig[key]);
- }
- return true;
- } else {
- return false;
- }
- };
-
- /**
- * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
- * @method setProperty
- * @param {String} key The name of the property
- * @param {String} value The value to set the property to
- * @param {Boolean} silent Whether the value should be set silently, without firing the property event.
- * @return {Boolean} True, if the set was successful, false if it failed.
- */
- this.setProperty = function(key, value, silent) {
- key = key.toLowerCase();
-
- YAHOO.log("setProperty: " + key + "=" + value, "info");
-
- if (this.queueInProgress && ! silent) {
- this.queueProperty(key,value); // Currently running through a queue...
- return true;
- } else {
- var property = config[key];
- if (typeof property != 'undefined' && property.event) {
- if (property.validator && ! property.validator(value)) { // validator
- return false;
- } else {
- property.value = value;
- if (! silent) {
- fireEvent(key, value);
- this.configChangedEvent.fire([key, value]);
- }
- return true;
- }
- } else {
- return false;
- }
- }
- };
-
- /**
- * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
- * moved from its current position to the end of the queue.
- * @method queueProperty
- * @param {String} key The name of the property
- * @param {String} value The value to set the property to
- * @return {Boolean} true, if the set was successful, false if it failed.
- */
- this.queueProperty = function(key, value) {
- key = key.toLowerCase();
-
- YAHOO.log("queueProperty: " + key + "=" + value, "info");
-
- var property = config[key];
-
- if (typeof property != 'undefined' && property.event) {
- if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
- return false;
- } else {
-
- if (typeof value != 'undefined') {
- property.value = value;
- } else {
- value = property.value;
- }
-
- var foundDuplicate = false;
-
- for (var i=0;i 11) {
- while (newMonth > 11) {
- newMonth -= 12;
- years += 1;
- }
- }
-
- d.setMonth(newMonth);
- d.setFullYear(date.getFullYear() + years);
- break;
- case this.DAY:
- d.setDate(date.getDate() + amount);
- break;
- case this.YEAR:
- d.setFullYear(date.getFullYear() + amount);
- break;
- case this.WEEK:
- d.setDate(date.getDate() + (amount * 7));
- break;
- }
- return d;
- },
-
- /**
- * Subtracts the specified amount of time from the this instance.
- * @method subtract
- * @param {Date} date The JavaScript Date object to perform subtraction on
- * @param {Number} field The this field constant to be used for performing subtraction.
- * @param {Number} amount The number of units (measured in the field constant) to subtract from the date.
- * @return {Date} The resulting Date object
- */
- subtract : function(date, field, amount) {
- return this.add(date, field, (amount*-1));
- },
-
- /**
- * Determines whether a given date is before another date on the calendar.
- * @method before
- * @param {Date} date The Date object to compare with the compare argument
- * @param {Date} compareTo The Date object to use for the comparison
- * @return {Boolean} true if the date occurs before the compared date; false if not.
- */
- before : function(date, compareTo) {
- var ms = compareTo.getTime();
- if (date.getTime() < ms) {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Determines whether a given date is after another date on the calendar.
- * @method after
- * @param {Date} date The Date object to compare with the compare argument
- * @param {Date} compareTo The Date object to use for the comparison
- * @return {Boolean} true if the date occurs after the compared date; false if not.
- */
- after : function(date, compareTo) {
- var ms = compareTo.getTime();
- if (date.getTime() > ms) {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Determines whether a given date is between two other dates on the calendar.
- * @method between
- * @param {Date} date The date to check for
- * @param {Date} dateBegin The start of the range
- * @param {Date} dateEnd The end of the range
- * @return {Boolean} true if the date occurs between the compared dates; false if not.
- */
- between : function(date, dateBegin, dateEnd) {
- if (this.after(date, dateBegin) && this.before(date, dateEnd)) {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Retrieves a JavaScript Date object representing January 1 of any given year.
- * @method getJan1
- * @param {Number} calendarYear The calendar year for which to retrieve January 1
- * @return {Date} January 1 of the calendar year specified.
- */
- getJan1 : function(calendarYear) {
- return new Date(calendarYear,0,1);
- },
-
- /**
- * Calculates the number of days the specified date is from January 1 of the specified calendar year.
- * Passing January 1 to this function would return an offset value of zero.
- * @method getDayOffset
- * @param {Date} date The JavaScript date for which to find the offset
- * @param {Number} calendarYear The calendar year to use for determining the offset
- * @return {Number} The number of days since January 1 of the given year
- */
- getDayOffset : function(date, calendarYear) {
- var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1.
-
- // Find the number of days the passed in date is away from the calendar year start
- var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS);
- return dayOffset;
- },
-
- /**
- * Calculates the week number for the given date. This function assumes that week 1 is the
- * week in which January 1 appears, regardless of whether the week consists of a full 7 days.
- * The calendar year can be specified to help find what a the week number would be for a given
- * date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or
- * week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction
- * easily.
- * @method getWeekNumber
- * @param {Date} date The JavaScript date for which to find the week number
- * @param {Number} calendarYear OPTIONAL - The calendar year to use for determining the week number. Default is
- * the calendar year of parameter "date".
- * @param {Number} weekStartsOn OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday).
- * @return {Number} The week number of the given date.
- */
- getWeekNumber : function(date, calendarYear) {
- date = this.clearTime(date);
- var nearestThurs = new Date(date.getTime() + (4 * this.ONE_DAY_MS) - ((date.getDay()) * this.ONE_DAY_MS));
-
- var jan1 = new Date(nearestThurs.getFullYear(),0,1);
- var dayOfYear = ((nearestThurs.getTime() - jan1.getTime()) / this.ONE_DAY_MS) - 1;
-
- var weekNum = Math.ceil((dayOfYear)/ 7);
- return weekNum;
- },
-
- /**
- * Determines if a given week overlaps two different years.
- * @method isYearOverlapWeek
- * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
- * @return {Boolean} true if the date overlaps two different years.
- */
- isYearOverlapWeek : function(weekBeginDate) {
- var overlaps = false;
- var nextWeek = this.add(weekBeginDate, this.DAY, 6);
- if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) {
- overlaps = true;
- }
- return overlaps;
- },
-
- /**
- * Determines if a given week overlaps two different months.
- * @method isMonthOverlapWeek
- * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
- * @return {Boolean} true if the date overlaps two different months.
- */
- isMonthOverlapWeek : function(weekBeginDate) {
- var overlaps = false;
- var nextWeek = this.add(weekBeginDate, this.DAY, 6);
- if (nextWeek.getMonth() != weekBeginDate.getMonth()) {
- overlaps = true;
- }
- return overlaps;
- },
-
- /**
- * Gets the first day of a month containing a given date.
- * @method findMonthStart
- * @param {Date} date The JavaScript Date used to calculate the month start
- * @return {Date} The JavaScript Date representing the first day of the month
- */
- findMonthStart : function(date) {
- var start = new Date(date.getFullYear(), date.getMonth(), 1);
- return start;
- },
-
- /**
- * Gets the last day of a month containing a given date.
- * @method findMonthEnd
- * @param {Date} date The JavaScript Date used to calculate the month end
- * @return {Date} The JavaScript Date representing the last day of the month
- */
- findMonthEnd : function(date) {
- var start = this.findMonthStart(date);
- var nextMonth = this.add(start, this.MONTH, 1);
- var end = this.subtract(nextMonth, this.DAY, 1);
- return end;
- },
-
- /**
- * Clears the time fields from a given date, effectively setting the time to midnight.
- * @method clearTime
- * @param {Date} date The JavaScript Date for which the time fields will be cleared
- * @return {Date} The JavaScript Date cleared of all time fields
- */
- clearTime : function(date) {
- date.setHours(12,0,0,0);
- return date;
- }
-};
-
-/**
-* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month ("one-up") or two-month ("two-up") interface. Calendars are generated entirely via script and can be navigated without any page refreshes.
-* @module calendar
-* @title Calendar
-* @namespace YAHOO.widget
-* @requires yahoo,dom,event
-*/
-
-/**
-* Calendar is the base class for the Calendar widget. In its most basic
-* implementation, it has the ability to render a calendar widget on the page
-* that can be manipulated to select a single date, move back and forth between
-* months and years.
-* To construct the placeholder for the calendar widget, the code is as
-* follows:
-*
-*
-*
-* Note that the table can be replaced with any kind of element.
-*
-* @namespace YAHOO.widget
-* @class Calendar
-* @constructor
-* @param {String} id The id of the table element that will represent the calendar widget
-* @param {String} containerId The id of the container div element that will wrap the calendar table
-* @param {Object} config The configuration object containing the Calendar's arguments
-*/
-YAHOO.widget.Calendar = function(id, containerId, config) {
- this.init(id, containerId, config);
-};
-
-/**
-* The path to be used for images loaded for the Calendar
-* @property YAHOO.widget.Calendar.IMG_ROOT
-* @static
-* @type String
-*/
-YAHOO.widget.Calendar.IMG_ROOT = (window.location.href.toLowerCase().indexOf("https") === 0 ? "https://a248.e.akamai.net/sec.yimg.com/i/" : "http://us.i1.yimg.com/us.yimg.com/i/");
-
-/**
-* Type constant used for renderers to represent an individual date (M/D/Y)
-* @property YAHOO.widget.Calendar.DATE
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.DATE = "D";
-
-/**
-* Type constant used for renderers to represent an individual date across any year (M/D)
-* @property YAHOO.widget.Calendar.MONTH_DAY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.MONTH_DAY = "MD";
-
-/**
-* Type constant used for renderers to represent a weekday
-* @property YAHOO.widget.Calendar.WEEKDAY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.WEEKDAY = "WD";
-
-/**
-* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y)
-* @property YAHOO.widget.Calendar.RANGE
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.RANGE = "R";
-
-/**
-* Type constant used for renderers to represent a month across any year
-* @property YAHOO.widget.Calendar.MONTH
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.MONTH = "M";
-
-/**
-* Constant that represents the total number of date cells that are displayed in a given month
-* @property YAHOO.widget.Calendar.DISPLAY_DAYS
-* @static
-* @final
-* @type Number
-*/
-YAHOO.widget.Calendar.DISPLAY_DAYS = 42;
-
-/**
-* Constant used for halting the execution of the remainder of the render stack
-* @property YAHOO.widget.Calendar.STOP_RENDER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.STOP_RENDER = "S";
-
-YAHOO.widget.Calendar.prototype = {
-
- /**
- * The configuration object used to set up the calendars various locale and style options.
- * @property Config
- * @private
- * @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty.
- * @type Object
- */
- Config : null,
-
- /**
- * The parent CalendarGroup, only to be set explicitly by the parent group
- * @property parent
- * @type CalendarGroup
- */
- parent : null,
-
- /**
- * The index of this item in the parent group
- * @property index
- * @type Number
- */
- index : -1,
-
- /**
- * The collection of calendar table cells
- * @property cells
- * @type HTMLTableCellElement[]
- */
- cells : null,
-
- /**
- * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D].
- * @property cellDates
- * @type Array[](Number[])
- */
- cellDates : null,
-
- /**
- * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page.
- * @property id
- * @type String
- */
- id : null,
-
- /**
- * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered.
- * @property oDomContainer
- * @type HTMLElement
- */
- oDomContainer : null,
-
- /**
- * A Date object representing today's date.
- * @property today
- * @type Date
- */
- today : null,
-
- /**
- * The list of render functions, along with required parameters, used to render cells.
- * @property renderStack
- * @type Array[]
- */
- renderStack : null,
-
- /**
- * A copy of the initial render functions created before rendering.
- * @property _renderStack
- * @private
- * @type Array
- */
- _renderStack : null,
-
- /**
- * A Date object representing the month/year that the calendar is initially set to
- * @property _pageDate
- * @private
- * @type Date
- */
- _pageDate : null,
-
- /**
- * The private list of initially selected dates.
- * @property _selectedDates
- * @private
- * @type Array
- */
- _selectedDates : null,
-
- /**
- * A map of DOM event handlers to attach to cells associated with specific CSS class names
- * @property domEventMap
- * @type Object
- */
- domEventMap : null
-};
-
-
-
-/**
-* Initializes the Calendar widget.
-* @method init
-* @param {String} id The id of the table element that will represent the calendar widget
-* @param {String} containerId The id of the container div element that will wrap the calendar table
-* @param {Object} config The configuration object containing the Calendar's arguments
-*/
-YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) {
- this.logger = new YAHOO.widget.LogWriter("Calendar_Core " + id);
-
- this.initEvents();
- this.today = new Date();
- YAHOO.widget.DateMath.clearTime(this.today);
-
- this.id = id;
- this.oDomContainer = document.getElementById(containerId);
- if (! this.oDomContainer) {
- this.logger.log("No valid container present.", "error");
- }
-
- /**
- * The Config object used to hold the configuration variables for the Calendar
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- /**
- * The local object which contains the Calendar's options
- * @property Options
- * @type Object
- */
- this.Options = {};
-
- /**
- * The local object which contains the Calendar's locale settings
- * @property Locale
- * @type Object
- */
- this.Locale = {};
-
- this.initStyles();
-
- YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER);
- YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE);
-
- this.cellDates = [];
- this.cells = [];
- this.renderStack = [];
- this._renderStack = [];
-
- this.setupConfig();
-
- if (config) {
- this.cfg.applyConfig(config, true);
- }
-
- this.cfg.fireQueue();
-};
-
-/**
-* Renders the built-in IFRAME shim for the IE6 and below
-* @method configIframe
-*/
-YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) {
- var useIframe = args[0];
-
- if (YAHOO.util.Dom.inDocument(this.oDomContainer)) {
- if (useIframe) {
- var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position");
-
- if (this.browser == "ie" && (pos == "absolute" || pos == "relative")) {
- if (! YAHOO.util.Dom.inDocument(this.iframe)) {
- this.iframe = document.createElement("iframe");
- this.iframe.src = "javascript:false;";
- YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
- this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild);
- }
- }
- } else {
- if (this.iframe) {
- if (this.iframe.parentNode) {
- this.iframe.parentNode.removeChild(this.iframe);
- }
- this.iframe = null;
- }
- }
- }
-};
-
-/**
-* Default handler for the "title" property
-* @method configTitle
-*/
-YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) {
- var title = args[0];
- var close = this.cfg.getProperty("close");
-
- var titleDiv;
-
- if (title && title !== "") {
- titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || document.createElement("div");
- titleDiv.className = YAHOO.widget.CalendarGroup.CSS_2UPTITLE;
- titleDiv.innerHTML = title;
- this.oDomContainer.insertBefore(titleDiv, this.oDomContainer.firstChild);
- YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
- } else {
- titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || null;
-
- if (titleDiv) {
- YAHOO.util.Event.purgeElement(titleDiv);
- this.oDomContainer.removeChild(titleDiv);
- }
- if (! close) {
- YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
- }
- }
-};
-
-/**
-* Default handler for the "close" property
-* @method configClose
-*/
-YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) {
- var close = args[0];
- var title = this.cfg.getProperty("title");
-
- var linkClose;
-
- if (close === true) {
- linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || document.createElement("a");
- linkClose.href = "javascript:void(null);";
- linkClose.className = "link-close";
- YAHOO.util.Event.addListener(linkClose, "click", this.hide, this, true);
- var imgClose = document.createElement("img");
- imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + "us/my/bn/x_d.gif";
- imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;
- linkClose.appendChild(imgClose);
- this.oDomContainer.appendChild(linkClose);
- YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
- } else {
- linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || null;
-
- if (linkClose) {
- YAHOO.util.Event.purgeElement(linkClose);
- this.oDomContainer.removeChild(linkClose);
- }
- if (! title || title === "") {
- YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
- }
- }
-};
-
-/**
-* Initializes Calendar's built-in CustomEvents
-* @method initEvents
-*/
-YAHOO.widget.Calendar.prototype.initEvents = function() {
-
- /**
- * Fired before a selection is made
- * @event beforeSelectEvent
- */
- this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect");
-
- /**
- * Fired when a selection is made
- * @event selectEvent
- * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
- */
- this.selectEvent = new YAHOO.util.CustomEvent("select");
-
- /**
- * Fired before a selection is made
- * @event beforeDeselectEvent
- */
- this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect");
-
- /**
- * Fired when a selection is made
- * @event deselectEvent
- * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
- */
- this.deselectEvent = new YAHOO.util.CustomEvent("deselect");
-
- /**
- * Fired when the Calendar page is changed
- * @event changePageEvent
- */
- this.changePageEvent = new YAHOO.util.CustomEvent("changePage");
-
- /**
- * Fired before the Calendar is rendered
- * @event beforeRenderEvent
- */
- this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
-
- /**
- * Fired when the Calendar is rendered
- * @event renderEvent
- */
- this.renderEvent = new YAHOO.util.CustomEvent("render");
-
- /**
- * Fired when the Calendar is reset
- * @event resetEvent
- */
- this.resetEvent = new YAHOO.util.CustomEvent("reset");
-
- /**
- * Fired when the Calendar is cleared
- * @event clearEvent
- */
- this.clearEvent = new YAHOO.util.CustomEvent("clear");
-
- this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true);
- this.selectEvent.subscribe(this.onSelect, this, true);
- this.beforeDeselectEvent.subscribe(this.onBeforeDeselect, this, true);
- this.deselectEvent.subscribe(this.onDeselect, this, true);
- this.changePageEvent.subscribe(this.onChangePage, this, true);
- this.renderEvent.subscribe(this.onRender, this, true);
- this.resetEvent.subscribe(this.onReset, this, true);
- this.clearEvent.subscribe(this.onClear, this, true);
-};
-
-
-/**
-* The default event function that is attached to a date link within a calendar cell
-* when the calendar is rendered.
-* @method doSelectCell
-* @param {DOMEvent} e The event
-* @param {Calendar} cal A reference to the calendar passed by the Event utility
-*/
-YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) {
- var target = YAHOO.util.Event.getTarget(e);
-
- var cell,index,d,date;
-
- while (target.tagName.toLowerCase() != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
- target = target.parentNode;
- if (target.tagName.toLowerCase() == "html") {
- return;
- }
- }
-
- cell = target;
-
- if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) {
- index = cell.id.split("cell")[1];
- d = cal.cellDates[index];
- date = new Date(d[0],d[1]-1,d[2]);
-
- var link;
-
- cal.logger.log("Selecting cell " + index + " via click", "info");
-
- if (cal.Options.MULTI_SELECT) {
- link = cell.getElementsByTagName("a")[0];
- if (link) {
- link.blur();
- }
-
- var cellDate = cal.cellDates[index];
- var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate);
-
- if (cellDateIndex > -1) {
- cal.deselectCell(index);
- } else {
- cal.selectCell(index);
- }
-
- } else {
- link = cell.getElementsByTagName("a")[0];
- if (link) {
- link.blur();
- }
- cal.selectCell(index);
- }
- }
-};
-
-/**
-* The event that is executed when the user hovers over a cell
-* @method doCellMouseOver
-* @param {DOMEvent} e The event
-* @param {Calendar} cal A reference to the calendar passed by the Event utility
-*/
-YAHOO.widget.Calendar.prototype.doCellMouseOver = function(e, cal) {
- var target;
- if (e) {
- target = YAHOO.util.Event.getTarget(e);
- } else {
- target = this;
- }
-
- while (target.tagName.toLowerCase() != "td") {
- target = target.parentNode;
- if (target.tagName.toLowerCase() == "html") {
- return;
- }
- }
-
- if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
- YAHOO.util.Dom.addClass(target, cal.Style.CSS_CELL_HOVER);
- }
-};
-
-/**
-* The event that is executed when the user moves the mouse out of a cell
-* @method doCellMouseOut
-* @param {DOMEvent} e The event
-* @param {Calendar} cal A reference to the calendar passed by the Event utility
-*/
-YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) {
- var target;
- if (e) {
- target = YAHOO.util.Event.getTarget(e);
- } else {
- target = this;
- }
-
- while (target.tagName.toLowerCase() != "td") {
- target = target.parentNode;
- if (target.tagName.toLowerCase() == "html") {
- return;
- }
- }
-
- if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
- YAHOO.util.Dom.removeClass(target, cal.Style.CSS_CELL_HOVER);
- }
-};
-
-YAHOO.widget.Calendar.prototype.setupConfig = function() {
-
- /**
- * The month/year representing the current visible Calendar date (mm/yyyy)
- * @config pagedate
- * @type String
- * @default today's date
- */
- this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
-
- /**
- * The date or range of dates representing the current Calendar selection
- * @config selected
- * @type String
- * @default []
- */
- this.cfg.addProperty("selected", { value:[], handler:this.configSelected } );
-
- /**
- * The title to display above the Calendar's month header
- * @config title
- * @type String
- * @default ""
- */
- this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
-
- /**
- * Whether or not a close button should be displayed for this Calendar
- * @config close
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("close", { value:false, handler:this.configClose } );
-
- /**
- * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
- * @config iframe
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } );
-
- /**
- * The minimum selectable date in the current Calendar (mm/dd/yyyy)
- * @config mindate
- * @type String
- * @default null
- */
- this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } );
-
- /**
- * The maximum selectable date in the current Calendar (mm/dd/yyyy)
- * @config maxdate
- * @type String
- * @default null
- */
- this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } );
-
-
- // Options properties
-
- /**
- * True if the Calendar should allow multiple selections. False by default.
- * @config MULTI_SELECT
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * The weekday the week begins on. Default is 0 (Sunday).
- * @config START_WEEKDAY
- * @type number
- * @default 0
- */
- this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.configOptions, validator:this.cfg.checkNumber } );
-
- /**
- * True if the Calendar should show weekday labels. True by default.
- * @config SHOW_WEEKDAYS
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should show week row headers. False by default.
- * @config SHOW_WEEK_HEADER
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should show week row footers. False by default.
- * @config SHOW_WEEK_FOOTER
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should suppress weeks that are not a part of the current month. False by default.
- * @config HIDE_BLANK_WEEKS
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * The image that should be used for the left navigation arrow.
- * @config NAV_ARROW_LEFT
- * @type String
- * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
- */
- this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.configOptions } );
-
- /**
- * The image that should be used for the left navigation arrow.
- * @config NAV_ARROW_RIGHT
- * @type String
- * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
- */
- this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.configOptions } );
-
- // Locale properties
-
- /**
- * The short month labels for the current locale.
- * @config MONTHS_SHORT
- * @type String[]
- * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
- */
- this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.configLocale } );
-
- /**
- * The long month labels for the current locale.
- * @config MONTHS_LONG
- * @type String[]
- * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
- */
- this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.configLocale } );
-
- /**
- * The 1-character weekday labels for the current locale.
- * @config WEEKDAYS_1CHAR
- * @type String[]
- * @default ["S", "M", "T", "W", "T", "F", "S"]
- */
- this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.configLocale } );
-
- /**
- * The short weekday labels for the current locale.
- * @config WEEKDAYS_SHORT
- * @type String[]
- * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
- */
- this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.configLocale } );
-
- /**
- * The medium weekday labels for the current locale.
- * @config WEEKDAYS_MEDIUM
- * @type String[]
- * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
- */
- this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.configLocale } );
-
- /**
- * The long weekday labels for the current locale.
- * @config WEEKDAYS_LONG
- * @type String[]
- * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
- */
- this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.configLocale } );
-
- /**
- * Refreshes the locale values used to build the Calendar.
- * @method refreshLocale
- * @private
- */
- var refreshLocale = function() {
- this.cfg.refireEvent("LOCALE_MONTHS");
- this.cfg.refireEvent("LOCALE_WEEKDAYS");
- };
-
- this.cfg.subscribeToConfigEvent("START_WEEKDAY", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("MONTHS_SHORT", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("MONTHS_LONG", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG", refreshLocale, this, true);
-
- /**
- * The setting that determines which length of month labels should be used. Possible values are "short" and "long".
- * @config LOCALE_MONTHS
- * @type String
- * @default "long"
- */
- this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } );
-
- /**
- * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
- * @config LOCALE_WEEKDAYS
- * @type String
- * @default "short"
- */
- this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } );
-
- /**
- * The value used to delimit individual dates in a date string passed to various Calendar functions.
- * @config DATE_DELIMITER
- * @type String
- * @default ","
- */
- this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } );
-
- /**
- * The value used to delimit date fields in a date string passed to various Calendar functions.
- * @config DATE_FIELD_DELIMITER
- * @type String
- * @default "/"
- */
- this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } );
-
- /**
- * The value used to delimit date ranges in a date string passed to various Calendar functions.
- * @config DATE_RANGE_DELIMITER
- * @type String
- * @default "-"
- */
- this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } );
-
- /**
- * The position of the month in a month/year date string
- * @config MY_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the year in a month/year date string
- * @config MY_YEAR_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the month in a month/day date string
- * @config MD_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the day in a month/year date string
- * @config MD_DAY_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the month in a month/day/year date string
- * @config MDY_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the day in a month/day/year date string
- * @config MDY_DAY_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the year in a month/day/year date string
- * @config MDY_YEAR_POSITION
- * @type Number
- * @default 3
- */
- this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } );
-};
-
-/**
-* The default handler for the "pagedate" property
-* @method configPageDate
-*/
-YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) {
- var val = args[0];
- var month, year, aMonthYear;
-
- if (val) {
- if (val instanceof Date) {
- val = YAHOO.widget.DateMath.findMonthStart(val);
- this.cfg.setProperty("pagedate", val, true);
- if (! this._pageDate) {
- this._pageDate = this.cfg.getProperty("pagedate");
- }
- return;
- } else {
- aMonthYear = val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER"));
- month = parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1], 10)-1;
- year = parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1], 10);
- }
- } else {
- month = this.today.getMonth();
- year = this.today.getFullYear();
- }
-
- this.cfg.setProperty("pagedate", new Date(year, month, 1), true);
-
- this.logger.log("Set month/year to " + month + "/" + year, "info");
-
- if (! this._pageDate) {
- this._pageDate = this.cfg.getProperty("pagedate");
- }
-};
-
-/**
-* The default handler for the "mindate" property
-* @method configMinDate
-*/
-YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) {
- var val = args[0];
- if (typeof val == 'string') {
- val = this._parseDate(val);
- this.cfg.setProperty("mindate", new Date(val[0],(val[1]-1),val[2]));
- }
-};
-
-/**
-* The default handler for the "maxdate" property
-* @method configMaxDate
-*/
-YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) {
- var val = args[0];
- if (typeof val == 'string') {
- val = this._parseDate(val);
- this.cfg.setProperty("maxdate", new Date(val[0],(val[1]-1),val[2]));
- }
-};
-
-/**
-* The default handler for the "selected" property
-* @method configSelected
-*/
-YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) {
- var selected = args[0];
-
- if (selected) {
- if (typeof selected == 'string') {
- this.cfg.setProperty("selected", this._parseDates(selected), true);
- }
- }
- if (! this._selectedDates) {
- this._selectedDates = this.cfg.getProperty("selected");
- }
-};
-
-/**
-* The default handler for all configuration options properties
-* @method configOptions
-*/
-YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) {
- type = type.toUpperCase();
- var val = args[0];
- this.Options[type] = val;
-};
-
-/**
-* The default handler for all configuration locale properties
-* @method configLocale
-*/
-YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) {
- type = type.toUpperCase();
- var val = args[0];
- this.Locale[type] = val;
-
- this.cfg.refireEvent("LOCALE_MONTHS");
- this.cfg.refireEvent("LOCALE_WEEKDAYS");
-
-};
-
-/**
-* The default handler for all configuration locale field length properties
-* @method configLocaleValues
-*/
-YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) {
- type = type.toUpperCase();
- var val = args[0];
-
- switch (type) {
- case "LOCALE_MONTHS":
- switch (val) {
- case "short":
- this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_SHORT").concat();
- break;
- case "long":
- this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_LONG").concat();
- break;
- }
- break;
- case "LOCALE_WEEKDAYS":
- switch (val) {
- case "1char":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_1CHAR").concat();
- break;
- case "short":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_SHORT").concat();
- break;
- case "medium":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_MEDIUM").concat();
- break;
- case "long":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_LONG").concat();
- break;
- }
-
- var START_WEEKDAY = this.cfg.getProperty("START_WEEKDAY");
-
- if (START_WEEKDAY > 0) {
- for (var w=0;w";
- html[html.length] = "";
- html[html.length] = '';
- html[html.length] = ' ';
-
- if (this.cfg.getProperty("SHOW_WEEKDAYS")) {
- html = this.buildWeekdays(html);
- }
-
- html[html.length] = '';
-
- return html;
-};
-
-/**
-* Renders the Calendar's weekday headers.
-* @method buildWeekdays
-* @param {Array} html The current working HTML array
-* @return {Array} The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) {
-
- html[html.length] = '';
-
- if (this.cfg.getProperty("SHOW_WEEK_HEADER")) {
- html[html.length] = ' ';
- }
-
- for(var i=0;i' + this.Locale.LOCALE_WEEKDAYS[i] + '';
- }
-
- if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) {
- html[html.length] = ' ';
- }
-
- html[html.length] = ' ';
-
- return html;
-};
-
-/**
-* Renders the calendar body.
-* @method renderBody
-* @param {Date} workingDate The current working Date being used for the render process
-* @param {Array} html The current working HTML array
-* @return {Array} The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) {
- this.logger.log("Rendering body", "info");
-
- var startDay = this.cfg.getProperty("START_WEEKDAY");
-
- this.preMonthDays = workingDate.getDay();
- if (startDay > 0) {
- this.preMonthDays -= startDay;
- }
- if (this.preMonthDays < 0) {
- this.preMonthDays += 7;
- }
-
- this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
- this.postMonthDays = YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
-
- this.logger.log(this.preMonthDays + " preciding out-of-month days", "info");
- this.logger.log(this.monthDays + " month days", "info");
- this.logger.log(this.postMonthDays + " post-month days", "info");
-
- workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
- this.logger.log("Calendar page starts on " + workingDate, "info");
-
- var useDate,weekNum,weekClass;
- useDate = this.cfg.getProperty("pagedate");
-
- html[html.length] = '';
-
- var i = 0;
-
- var tempDiv = document.createElement("div");
- var cell = document.createElement("td");
- tempDiv.appendChild(cell);
-
- var jan1 = new Date(useDate.getFullYear(),0,1);
-
- var cal = this.parent || this;
-
- for (var r=0;r<6;r++) {
-
- weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useDate.getFullYear(), startDay);
-
- weekClass = "w" + weekNum;
-
- if (r !== 0 && this.isDateOOM(workingDate) && this.cfg.getProperty("HIDE_BLANK_WEEKS") === true) {
- break;
- } else {
-
- html[html.length] = '';
-
- if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { html = this.renderRowHeader(weekNum, html); }
-
- for (var d=0;d<7;d++){ // Render actual days
-
- var cellRenderers = [];
-
- this.clearElement(cell);
-
- YAHOO.util.Dom.addClass(cell, "calcell");
-
- cell.id = this.id + "_cell" + i;
- this.logger.log("Rendering cell " + cell.id + " (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + ")", "cellrender");
-
- cell.innerHTML = i;
-
- var renderer = null;
-
- if (workingDate.getFullYear() == this.today.getFullYear() &&
- workingDate.getMonth() == this.today.getMonth() &&
- workingDate.getDate() == this.today.getDate()) {
- cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;
- }
-
- this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates
-
- if (this.isDateOOM(workingDate)) {
- cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;
- } else {
-
- YAHOO.util.Dom.addClass(cell, "wd" + workingDate.getDay());
- YAHOO.util.Dom.addClass(cell, "d" + workingDate.getDate());
-
- for (var s=0;s= d1.getTime() && workingDate.getTime() <= d2.getTime()) {
- renderer = rArray[2];
-
- if (workingDate.getTime()==d2.getTime()) {
- this.renderStack.splice(s,1);
- }
- }
- break;
- case YAHOO.widget.Calendar.WEEKDAY:
-
- var weekday = rArray[1][0];
- if (workingDate.getDay()+1 == weekday) {
- renderer = rArray[2];
- }
- break;
- case YAHOO.widget.Calendar.MONTH:
-
- month = rArray[1][0];
- if (workingDate.getMonth()+1 == month) {
- renderer = rArray[2];
- }
- break;
- }
-
- if (renderer) {
- cellRenderers[cellRenderers.length]=renderer;
- }
- }
-
- }
-
- if (this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]) > -1) {
- cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected;
- }
-
- var mindate = this.cfg.getProperty("mindate");
- var maxdate = this.cfg.getProperty("maxdate");
-
- if (mindate) {
- mindate = YAHOO.widget.DateMath.clearTime(mindate);
- }
- if (maxdate) {
- maxdate = YAHOO.widget.DateMath.clearTime(maxdate);
- }
-
- if (
- (mindate && (workingDate.getTime() < mindate.getTime())) ||
- (maxdate && (workingDate.getTime() > maxdate.getTime()))
- ) {
- cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate;
- } else {
- cellRenderers[cellRenderers.length]=cal.styleCellDefault;
- cellRenderers[cellRenderers.length]=cal.renderCellDefault;
- }
-
-
-
- for (var x=0;x= 0 && i <= 6) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TOP);
- }
- if ((i % 7) === 0) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_LEFT);
- }
- if (((i+1) % 7) === 0) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RIGHT);
- }
-
- var postDays = this.postMonthDays;
- if (postDays >= 7 && this.cfg.getProperty("HIDE_BLANK_WEEKS")) {
- var blankWeeks = Math.floor(postDays/7);
- for (var p=0;p= ((this.preMonthDays+postDays+this.monthDays)-7)) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM);
- }
-
- html[html.length] = tempDiv.innerHTML;
-
- i++;
- }
-
- if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { html = this.renderRowFooter(weekNum, html); }
-
- html[html.length] = ' ';
- }
- }
-
- html[html.length] = ' ';
-
- return html;
-};
-
-/**
-* Renders the calendar footer. In the default implementation, there is
-* no footer.
-* @method renderFooter
-* @param {Array} html The current working HTML array
-* @return {Array} The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.renderFooter = function(html) { return html; };
-
-/**
-* Renders the calendar after it has been configured. The render() method has a specific call chain that will execute
-* when the method is called: renderHeader, renderBody, renderFooter.
-* Refer to the documentation for those methods for information on
-* individual render tasks.
-* @method render
-*/
-YAHOO.widget.Calendar.prototype.render = function() {
- this.beforeRenderEvent.fire();
-
- // Find starting day of the current month
- var workingDate = YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty("pagedate"));
-
- this.resetRenderers();
- this.cellDates.length = 0;
-
- YAHOO.util.Event.purgeElement(this.oDomContainer, true);
-
- var html = [];
-
- html[html.length] = '';
- html = this.renderHeader(html);
- html = this.renderBody(workingDate, html);
- html = this.renderFooter(html);
- html[html.length] = '
';
-
- this.oDomContainer.innerHTML = html.join("\n");
-
- this.applyListeners();
- this.cells = this.oDomContainer.getElementsByTagName("td");
-
- this.cfg.refireEvent("title");
- this.cfg.refireEvent("close");
- this.cfg.refireEvent("iframe");
-
- this.renderEvent.fire();
-};
-
-/**
-* Applies the Calendar's DOM listeners to applicable elements.
-* @method applyListeners
-*/
-YAHOO.widget.Calendar.prototype.applyListeners = function() {
-
- var root = this.oDomContainer;
- var cal = this.parent || this;
-
- var linkLeft, linkRight;
-
- linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, "a", root);
- linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, "a", root);
-
- if (linkLeft) {
- this.linkLeft = linkLeft[0];
- YAHOO.util.Event.addListener(this.linkLeft, "mousedown", cal.previousMonth, cal, true);
- }
-
- if (linkRight) {
- this.linkRight = linkRight[0];
- YAHOO.util.Event.addListener(this.linkRight, "mousedown", cal.nextMonth, cal, true);
- }
-
- if (this.domEventMap) {
- var el,elements;
- for (var cls in this.domEventMap) {
- if (this.domEventMap.hasOwnProperty(cls)) {
- var items = this.domEventMap[cls];
-
- if (! (items instanceof Array)) {
- items = [items];
- }
-
- for (var i=0;i' + weekNum + '';
- return html;
-};
-
-/**
-* Renders the row footer for a week.
-* @method renderRowFooter
-* @param {Number} weekNum The week number of the current row
-* @param {Array} cell The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) {
- html[html.length] = '';
- return html;
-};
-
-/**
-* Renders a single standard calendar cell in the calendar widget table.
-* All logic for determining how a standard default cell will be rendered is
-* encapsulated in this method, and must be accounted for when extending the
-* widget class.
-* @method renderCellDefault
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) {
- cell.innerHTML = '' + this.buildDayLabel(workingDate) + " ";
-};
-
-/**
-* Styles a selectable cell.
-* @method styleCellDefault
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.styleCellDefault = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE);
-};
-
-
-/**
-* Renders a single standard calendar cell using the CSS hightlight1 style
-* @method renderCellStyleHighlight1
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
-};
-
-/**
-* Renders a single standard calendar cell using the CSS hightlight2 style
-* @method renderCellStyleHighlight2
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
-};
-
-/**
-* Renders a single standard calendar cell using the CSS hightlight3 style
-* @method renderCellStyleHighlight3
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
-};
-
-/**
-* Renders a single standard calendar cell using the CSS hightlight4 style
-* @method renderCellStyleHighlight4
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
-};
-
-/**
-* Applies the default style used for rendering today's date to the current calendar cell
-* @method renderCellStyleToday
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleToday = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY);
-};
-
-/**
-* Applies the default style used for rendering selected dates to the current calendar cell
-* @method renderCellStyleSelected
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
-* should not be terminated
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleSelected = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED);
-};
-
-/**
-* Applies the default style used for rendering dates that are not a part of the current
-* month (preceding or trailing the cells for the current month)
-* @method renderCellNotThisMonth
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
-* should not be terminated
-*/
-YAHOO.widget.Calendar.prototype.renderCellNotThisMonth = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
- cell.innerHTML=workingDate.getDate();
- return YAHOO.widget.Calendar.STOP_RENDER;
-};
-
-/**
-* Renders the current calendar cell as a non-selectable "black-out" date using the default
-* restricted style.
-* @method renderBodyCellRestricted
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
-* should not be terminated
-*/
-YAHOO.widget.Calendar.prototype.renderBodyCellRestricted = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL);
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RESTRICTED);
- cell.innerHTML=workingDate.getDate();
- return YAHOO.widget.Calendar.STOP_RENDER;
-};
-
-// END BUILT-IN TABLE CELL RENDERERS
-
-// BEGIN MONTH NAVIGATION METHODS
-
-/**
-* Adds the designated number of months to the current calendar month, and sets the current
-* calendar page date to the new month.
-* @method addMonths
-* @param {Number} count The number of months to add to the current calendar
-*/
-YAHOO.widget.Calendar.prototype.addMonths = function(count) {
- this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
-
-/**
-* Subtracts the designated number of months from the current calendar month, and sets the current
-* calendar page date to the new month.
-* @method subtractMonths
-* @param {Number} count The number of months to subtract from the current calendar
-*/
-YAHOO.widget.Calendar.prototype.subtractMonths = function(count) {
- this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
-
-/**
-* Adds the designated number of years to the current calendar, and sets the current
-* calendar page date to the new month.
-* @method addYears
-* @param {Number} count The number of years to add to the current calendar
-*/
-YAHOO.widget.Calendar.prototype.addYears = function(count) {
- this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
-
-/**
-* Subtcats the designated number of years from the current calendar, and sets the current
-* calendar page date to the new month.
-* @method subtractYears
-* @param {Number} count The number of years to subtract from the current calendar
-*/
-YAHOO.widget.Calendar.prototype.subtractYears = function(count) {
- this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
-
-/**
-* Navigates to the next month page in the calendar widget.
-* @method nextMonth
-*/
-YAHOO.widget.Calendar.prototype.nextMonth = function() {
- this.addMonths(1);
-};
-
-/**
-* Navigates to the previous month page in the calendar widget.
-* @method previousMonth
-*/
-YAHOO.widget.Calendar.prototype.previousMonth = function() {
- this.subtractMonths(1);
-};
-
-/**
-* Navigates to the next year in the currently selected month in the calendar widget.
-* @method nextYear
-*/
-YAHOO.widget.Calendar.prototype.nextYear = function() {
- this.addYears(1);
-};
-
-/**
-* Navigates to the previous year in the currently selected month in the calendar widget.
-* @method previousYear
-*/
-YAHOO.widget.Calendar.prototype.previousYear = function() {
- this.subtractYears(1);
-};
-
-// END MONTH NAVIGATION METHODS
-
-// BEGIN SELECTION METHODS
-
-/**
-* Resets the calendar widget to the originally selected month and year, and
-* sets the calendar to the initial selection(s).
-* @method reset
-*/
-YAHOO.widget.Calendar.prototype.reset = function() {
- this.cfg.resetProperty("selected");
- this.cfg.resetProperty("pagedate");
- this.resetEvent.fire();
-};
-
-/**
-* Clears the selected dates in the current calendar widget and sets the calendar
-* to the current month and year.
-* @method clear
-*/
-YAHOO.widget.Calendar.prototype.clear = function() {
- this.cfg.setProperty("selected", []);
- this.cfg.setProperty("pagedate", new Date(this.today.getTime()));
- this.clearEvent.fire();
-};
-
-/**
-* Selects a date or a collection of dates on the current calendar. This method, by default,
-* does not call the render method explicitly. Once selection has completed, render must be
-* called for the changes to be reflected visually.
-* @method select
-* @param {String/Date/Date[]} date The date string of dates to select in the current calendar. Valid formats are
-* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
-* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
-* This method can also take a JavaScript Date object or an array of Date objects.
-* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
-*/
-YAHOO.widget.Calendar.prototype.select = function(date) {
- this.logger.log("Select: " + date, "info");
-
- this.beforeSelectEvent.fire();
-
- var selected = this.cfg.getProperty("selected");
- var aToBeSelected = this._toFieldArray(date);
- this.logger.log("Selection field array: " + aToBeSelected, "info");
-
- for (var a=0;a -1) {
- if (this.cfg.getProperty("pagedate").getMonth() == dCellDate.getMonth() &&
- this.cfg.getProperty("pagedate").getFullYear() == dCellDate.getFullYear()) {
- YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED);
- }
-
- selected.splice(cellDateIndex, 1);
- }
-
-
- if (this.parent) {
- this.parent.cfg.setProperty("selected", selected);
- } else {
- this.cfg.setProperty("selected", selected);
- }
-
- this.deselectEvent.fire(selectDate);
- return this.getSelectedDates();
-};
-
-/**
-* Deselects all dates on the current calendar.
-* @method deselectAll
-* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
-* Assuming that this function executes properly, the return value should be an empty array.
-* However, the empty array is returned for the sake of being able to check the selection status
-* of the calendar.
-*/
-YAHOO.widget.Calendar.prototype.deselectAll = function() {
- this.beforeDeselectEvent.fire();
-
- var selected = this.cfg.getProperty("selected");
- var count = selected.length;
- var sel = selected.concat();
-
- if (this.parent) {
- this.parent.cfg.setProperty("selected", []);
- } else {
- this.cfg.setProperty("selected", []);
- }
-
- if (count > 0) {
- this.deselectEvent.fire(sel);
- }
-
- return this.getSelectedDates();
-};
-
-// END SELECTION METHODS
-
-// BEGIN TYPE CONVERSION METHODS
-
-/**
-* Converts a date (either a JavaScript Date object, or a date string) to the internal data structure
-* used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]].
-* @method _toFieldArray
-* @private
-* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
-* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
-* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
-* This method can also take a JavaScript Date object or an array of Date objects.
-* @return {Array[](Number[])} Array of date field arrays
-*/
-YAHOO.widget.Calendar.prototype._toFieldArray = function(date) {
- var returnDate = [];
-
- if (date instanceof Date) {
- returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]];
- } else if (typeof date == 'string') {
- returnDate = this._parseDates(date);
- } else if (date instanceof Array) {
- for (var i=0;i
-*
-*
-*
-* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
-* @namespace YAHOO.widget
-* @class CalendarGroup
-* @constructor
-* @param {String} id The id of the table element that will represent the calendar widget
-* @param {String} containerId The id of the container div element that will wrap the calendar table
-* @param {Object} config The configuration object containing the Calendar's arguments
-*/
-YAHOO.widget.CalendarGroup = function(id, containerId, config) {
- if (arguments.length > 0) {
- this.init(id, containerId, config);
- }
-};
-
-/**
-* Initializes the calendar group. All subclasses must call this method in order for the
-* group to be initialized properly.
-* @method init
-* @param {String} id The id of the table element that will represent the calendar widget
-* @param {String} containerId The id of the container div element that will wrap the calendar table
-* @param {Object} config The configuration object containing the Calendar's arguments
-*/
-YAHOO.widget.CalendarGroup.prototype.init = function(id, containerId, config) {
- this.logger = new YAHOO.widget.LogWriter("CalendarGroup " + id);
-
- this.initEvents();
- this.initStyles();
-
- /**
- * The collection of Calendar pages contained within the CalendarGroup
- * @property pages
- * @type YAHOO.widget.Calendar[]
- */
- this.pages = [];
-
- /**
- * The unique id associated with the CalendarGroup
- * @property id
- * @type String
- */
- this.id = id;
-
- /**
- * The unique id associated with the CalendarGroup container
- * @property containerId
- * @type String
- */
- this.containerId = containerId;
-
- /**
- * The outer containing element for the CalendarGroup
- * @property oDomContainer
- * @type HTMLElement
- */
- this.oDomContainer = document.getElementById(containerId);
-
- YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_CONTAINER);
- YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_MULTI_UP);
-
- /**
- * The Config object used to hold the configuration variables for the CalendarGroup
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- /**
- * The local object which contains the CalendarGroup's options
- * @property Options
- * @type Object
- */
- this.Options = {};
-
- /**
- * The local object which contains the CalendarGroup's locale settings
- * @property Locale
- * @type Object
- */
- this.Locale = {};
-
- this.setupConfig();
-
- if (config) {
- this.cfg.applyConfig(config, true);
- }
-
- this.cfg.fireQueue();
-
- // OPERA HACK FOR MISWRAPPED FLOATS
- if (this.browser == "opera"){
- var fixWidth = function() {
- var startW = this.oDomContainer.offsetWidth;
- var w = 0;
- for (var p=0;p 0) {
- this.oDomContainer.style.width = w + "px";
- }
- };
- this.renderEvent.subscribe(fixWidth,this,true);
- }
-
- this.logger.log("Initialized " + pageCount + "-page CalendarGroup", "info");
-};
-
-
-YAHOO.widget.CalendarGroup.prototype.setupConfig = function() {
- /**
- * The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments.
- * @config pages
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("pages", { value:2, validator:this.cfg.checkNumber, handler:this.configPages } );
-
- /**
- * The month/year representing the current visible Calendar date (mm/yyyy)
- * @config pagedate
- * @type String
- * @default today's date
- */
- this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
-
- /**
- * The date or range of dates representing the current Calendar selection
- * @config selected
- * @type String
- * @default []
- */
- this.cfg.addProperty("selected", { value:[], handler:this.delegateConfig } );
-
- /**
- * The title to display above the CalendarGroup's month header
- * @config title
- * @type String
- * @default ""
- */
- this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
-
- /**
- * Whether or not a close button should be displayed for this CalendarGroup
- * @config close
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("close", { value:false, handler:this.configClose } );
-
- /**
- * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
- * @config iframe
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("iframe", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * The minimum selectable date in the current Calendar (mm/dd/yyyy)
- * @config mindate
- * @type String
- * @default null
- */
- this.cfg.addProperty("mindate", { value:null, handler:this.delegateConfig } );
-
- /**
- * The maximum selectable date in the current Calendar (mm/dd/yyyy)
- * @config maxdate
- * @type String
- * @default null
- */
- this.cfg.addProperty("maxdate", { value:null, handler:this.delegateConfig } );
-
- // Options properties
-
- /**
- * True if the Calendar should allow multiple selections. False by default.
- * @config MULTI_SELECT
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * The weekday the week begins on. Default is 0 (Sunday).
- * @config START_WEEKDAY
- * @type number
- * @default 0
- */
- this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * True if the Calendar should show weekday labels. True by default.
- * @config SHOW_WEEKDAYS
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should show week row headers. False by default.
- * @config SHOW_WEEK_HEADER
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should show week row footers. False by default.
- * @config SHOW_WEEK_FOOTER
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should suppress weeks that are not a part of the current month. False by default.
- * @config HIDE_BLANK_WEEKS
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * The image that should be used for the left navigation arrow.
- * @config NAV_ARROW_LEFT
- * @type String
- * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
- */
- this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.delegateConfig } );
-
- /**
- * The image that should be used for the left navigation arrow.
- * @config NAV_ARROW_RIGHT
- * @type String
- * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
- */
- this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.delegateConfig } );
-
- // Locale properties
-
- /**
- * The short month labels for the current locale.
- * @config MONTHS_SHORT
- * @type String[]
- * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
- */
- this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.delegateConfig } );
-
- /**
- * The long month labels for the current locale.
- * @config MONTHS_LONG
- * @type String[]
- * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
- */
- this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.delegateConfig } );
-
- /**
- * The 1-character weekday labels for the current locale.
- * @config WEEKDAYS_1CHAR
- * @type String[]
- * @default ["S", "M", "T", "W", "T", "F", "S"]
- */
- this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.delegateConfig } );
-
- /**
- * The short weekday labels for the current locale.
- * @config WEEKDAYS_SHORT
- * @type String[]
- * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
- */
- this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.delegateConfig } );
-
- /**
- * The medium weekday labels for the current locale.
- * @config WEEKDAYS_MEDIUM
- * @type String[]
- * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
- */
- this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.delegateConfig } );
-
- /**
- * The long weekday labels for the current locale.
- * @config WEEKDAYS_LONG
- * @type String[]
- * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
- */
- this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.delegateConfig } );
-
- /**
- * The setting that determines which length of month labels should be used. Possible values are "short" and "long".
- * @config LOCALE_MONTHS
- * @type String
- * @default "long"
- */
- this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.delegateConfig } );
-
- /**
- * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
- * @config LOCALE_WEEKDAYS
- * @type String
- * @default "short"
- */
- this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.delegateConfig } );
-
- /**
- * The value used to delimit individual dates in a date string passed to various Calendar functions.
- * @config DATE_DELIMITER
- * @type String
- * @default ","
- */
- this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.delegateConfig } );
-
- /**
- * The value used to delimit date fields in a date string passed to various Calendar functions.
- * @config DATE_FIELD_DELIMITER
- * @type String
- * @default "/"
- */
- this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.delegateConfig } );
-
- /**
- * The value used to delimit date ranges in a date string passed to various Calendar functions.
- * @config DATE_RANGE_DELIMITER
- * @type String
- * @default "-"
- */
- this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.delegateConfig } );
-
- /**
- * The position of the month in a month/year date string
- * @config MY_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the year in a month/year date string
- * @config MY_YEAR_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the month in a month/day date string
- * @config MD_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the day in a month/year date string
- * @config MD_DAY_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the month in a month/day/year date string
- * @config MDY_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the day in a month/day/year date string
- * @config MDY_DAY_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the year in a month/day/year date string
- * @config MDY_YEAR_POSITION
- * @type Number
- * @default 3
- */
- this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
-};
-
-/**
-* Initializes CalendarGroup's built-in CustomEvents
-* @method initEvents
-*/
-YAHOO.widget.CalendarGroup.prototype.initEvents = function() {
- var me = this;
-
- /**
- * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents
- * @method sub
- * @private
- * @param {Function} fn The function to subscribe to this CustomEvent
- * @param {Object} obj The CustomEvent's scope object
- * @param {Boolean} bOverride Whether or not to apply scope correction
- */
- var sub = function(fn, obj, bOverride) {
- for (var p=0;p0) {
- year+=1;
- }
- cal.setYear(year);
- }
-};
-/**
-* Calls the render function of all child calendars within the group.
-* @method render
-*/
-YAHOO.widget.CalendarGroup.prototype.render = function() {
- this.renderHeader();
- for (var p=0;p=0;--p) {
- var cal = this.pages[p];
- cal.previousMonth();
- }
-};
-
-/**
-* Navigates to the next year in the currently selected month in the calendar widget.
-* @method nextYear
-*/
-YAHOO.widget.CalendarGroup.prototype.nextYear = function() {
- for (var p=0;p 11) {
+ while (newMonth > 11) {
+ newMonth -= 12;
+ years += 1;
+ }
+ }
+
+ d.setMonth(newMonth);
+ d.setFullYear(date.getFullYear() + years);
+ break;
+ case this.DAY:
+ d.setDate(date.getDate() + amount);
+ break;
+ case this.YEAR:
+ d.setFullYear(date.getFullYear() + amount);
+ break;
+ case this.WEEK:
+ d.setDate(date.getDate() + (amount * 7));
+ break;
+ }
+ return d;
+ },
+
+ /**
+ * Subtracts the specified amount of time from the this instance.
+ * @method subtract
+ * @param {Date} date The JavaScript Date object to perform subtraction on
+ * @param {Number} field The this field constant to be used for performing subtraction.
+ * @param {Number} amount The number of units (measured in the field constant) to subtract from the date.
+ * @return {Date} The resulting Date object
+ */
+ subtract : function(date, field, amount) {
+ return this.add(date, field, (amount*-1));
+ },
+
+ /**
+ * Determines whether a given date is before another date on the calendar.
+ * @method before
+ * @param {Date} date The Date object to compare with the compare argument
+ * @param {Date} compareTo The Date object to use for the comparison
+ * @return {Boolean} true if the date occurs before the compared date; false if not.
+ */
+ before : function(date, compareTo) {
+ var ms = compareTo.getTime();
+ if (date.getTime() < ms) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Determines whether a given date is after another date on the calendar.
+ * @method after
+ * @param {Date} date The Date object to compare with the compare argument
+ * @param {Date} compareTo The Date object to use for the comparison
+ * @return {Boolean} true if the date occurs after the compared date; false if not.
+ */
+ after : function(date, compareTo) {
+ var ms = compareTo.getTime();
+ if (date.getTime() > ms) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Determines whether a given date is between two other dates on the calendar.
+ * @method between
+ * @param {Date} date The date to check for
+ * @param {Date} dateBegin The start of the range
+ * @param {Date} dateEnd The end of the range
+ * @return {Boolean} true if the date occurs between the compared dates; false if not.
+ */
+ between : function(date, dateBegin, dateEnd) {
+ if (this.after(date, dateBegin) && this.before(date, dateEnd)) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Retrieves a JavaScript Date object representing January 1 of any given year.
+ * @method getJan1
+ * @param {Number} calendarYear The calendar year for which to retrieve January 1
+ * @return {Date} January 1 of the calendar year specified.
+ */
+ getJan1 : function(calendarYear) {
+ return new Date(calendarYear,0,1);
+ },
+
+ /**
+ * Calculates the number of days the specified date is from January 1 of the specified calendar year.
+ * Passing January 1 to this function would return an offset value of zero.
+ * @method getDayOffset
+ * @param {Date} date The JavaScript date for which to find the offset
+ * @param {Number} calendarYear The calendar year to use for determining the offset
+ * @return {Number} The number of days since January 1 of the given year
+ */
+ getDayOffset : function(date, calendarYear) {
+ var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1.
+
+ // Find the number of days the passed in date is away from the calendar year start
+ var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS);
+ return dayOffset;
+ },
+
+ /**
+ * Calculates the week number for the given date. This function assumes that week 1 is the
+ * week in which January 1 appears, regardless of whether the week consists of a full 7 days.
+ * The calendar year can be specified to help find what a the week number would be for a given
+ * date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or
+ * week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction
+ * easily.
+ * @method getWeekNumber
+ * @param {Date} date The JavaScript date for which to find the week number
+ * @param {Number} calendarYear OPTIONAL - The calendar year to use for determining the week number. Default is
+ * the calendar year of parameter "date".
+ * @param {Number} weekStartsOn OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday).
+ * @return {Number} The week number of the given date.
+ */
+ getWeekNumber : function(date, calendarYear) {
+ date = this.clearTime(date);
+ var nearestThurs = new Date(date.getTime() + (4 * this.ONE_DAY_MS) - ((date.getDay()) * this.ONE_DAY_MS));
+
+ var jan1 = new Date(nearestThurs.getFullYear(),0,1);
+ var dayOfYear = ((nearestThurs.getTime() - jan1.getTime()) / this.ONE_DAY_MS) - 1;
+
+ var weekNum = Math.ceil((dayOfYear)/ 7);
+ return weekNum;
+ },
+
+ /**
+ * Determines if a given week overlaps two different years.
+ * @method isYearOverlapWeek
+ * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
+ * @return {Boolean} true if the date overlaps two different years.
+ */
+ isYearOverlapWeek : function(weekBeginDate) {
+ var overlaps = false;
+ var nextWeek = this.add(weekBeginDate, this.DAY, 6);
+ if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) {
+ overlaps = true;
+ }
+ return overlaps;
+ },
+
+ /**
+ * Determines if a given week overlaps two different months.
+ * @method isMonthOverlapWeek
+ * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
+ * @return {Boolean} true if the date overlaps two different months.
+ */
+ isMonthOverlapWeek : function(weekBeginDate) {
+ var overlaps = false;
+ var nextWeek = this.add(weekBeginDate, this.DAY, 6);
+ if (nextWeek.getMonth() != weekBeginDate.getMonth()) {
+ overlaps = true;
+ }
+ return overlaps;
+ },
+
+ /**
+ * Gets the first day of a month containing a given date.
+ * @method findMonthStart
+ * @param {Date} date The JavaScript Date used to calculate the month start
+ * @return {Date} The JavaScript Date representing the first day of the month
+ */
+ findMonthStart : function(date) {
+ var start = new Date(date.getFullYear(), date.getMonth(), 1);
+ return start;
+ },
+
+ /**
+ * Gets the last day of a month containing a given date.
+ * @method findMonthEnd
+ * @param {Date} date The JavaScript Date used to calculate the month end
+ * @return {Date} The JavaScript Date representing the last day of the month
+ */
+ findMonthEnd : function(date) {
+ var start = this.findMonthStart(date);
+ var nextMonth = this.add(start, this.MONTH, 1);
+ var end = this.subtract(nextMonth, this.DAY, 1);
+ return end;
+ },
+
+ /**
+ * Clears the time fields from a given date, effectively setting the time to 12 noon.
+ * @method clearTime
+ * @param {Date} date The JavaScript Date for which the time fields will be cleared
+ * @return {Date} The JavaScript Date cleared of all time fields
+ */
+ clearTime : function(date) {
+ date.setHours(12,0,0,0);
+ return date;
+ }
+};
+
+/**
+* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month ("one-up") or two-month ("two-up") interface. Calendars are generated entirely via script and can be navigated without any page refreshes.
+* @module calendar
+* @title Calendar
+* @namespace YAHOO.widget
+* @requires yahoo,dom,event
+*/
+
+/**
+* Calendar is the base class for the Calendar widget. In its most basic
+* implementation, it has the ability to render a calendar widget on the page
+* that can be manipulated to select a single date, move back and forth between
+* months and years.
+* To construct the placeholder for the calendar widget, the code is as
+* follows:
+*
+*
+*
+* Note that the table can be replaced with any kind of element.
+*
+* @namespace YAHOO.widget
+* @class Calendar
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container div element that will wrap the calendar table
+* @param {Object} config The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.Calendar = function(id, containerId, config) {
+ this.init(id, containerId, config);
+};
+
+/**
+* The path to be used for images loaded for the Calendar
+* @property YAHOO.widget.Calendar.IMG_ROOT
+* @static
+* @type String
+*/
+YAHOO.widget.Calendar.IMG_ROOT = (window.location.href.toLowerCase().indexOf("https") === 0 ? "https://a248.e.akamai.net/sec.yimg.com/i/" : "http://us.i1.yimg.com/us.yimg.com/i/");
+
+/**
+* Type constant used for renderers to represent an individual date (M/D/Y)
+* @property YAHOO.widget.Calendar.DATE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.DATE = "D";
+
+/**
+* Type constant used for renderers to represent an individual date across any year (M/D)
+* @property YAHOO.widget.Calendar.MONTH_DAY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.MONTH_DAY = "MD";
+
+/**
+* Type constant used for renderers to represent a weekday
+* @property YAHOO.widget.Calendar.WEEKDAY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.WEEKDAY = "WD";
+
+/**
+* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y)
+* @property YAHOO.widget.Calendar.RANGE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.RANGE = "R";
+
+/**
+* Type constant used for renderers to represent a month across any year
+* @property YAHOO.widget.Calendar.MONTH
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.MONTH = "M";
+
+/**
+* Constant that represents the total number of date cells that are displayed in a given month
+* @property YAHOO.widget.Calendar.DISPLAY_DAYS
+* @static
+* @final
+* @type Number
+*/
+YAHOO.widget.Calendar.DISPLAY_DAYS = 42;
+
+/**
+* Constant used for halting the execution of the remainder of the render stack
+* @property YAHOO.widget.Calendar.STOP_RENDER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.STOP_RENDER = "S";
+
+YAHOO.widget.Calendar.prototype = {
+
+ /**
+ * The configuration object used to set up the calendars various locale and style options.
+ * @property Config
+ * @private
+ * @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty.
+ * @type Object
+ */
+ Config : null,
+
+ /**
+ * The parent CalendarGroup, only to be set explicitly by the parent group
+ * @property parent
+ * @type CalendarGroup
+ */
+ parent : null,
+
+ /**
+ * The index of this item in the parent group
+ * @property index
+ * @type Number
+ */
+ index : -1,
+
+ /**
+ * The collection of calendar table cells
+ * @property cells
+ * @type HTMLTableCellElement[]
+ */
+ cells : null,
+
+ /**
+ * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D].
+ * @property cellDates
+ * @type Array[](Number[])
+ */
+ cellDates : null,
+
+ /**
+ * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page.
+ * @property id
+ * @type String
+ */
+ id : null,
+
+ /**
+ * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered.
+ * @property oDomContainer
+ * @type HTMLElement
+ */
+ oDomContainer : null,
+
+ /**
+ * A Date object representing today's date.
+ * @property today
+ * @type Date
+ */
+ today : null,
+
+ /**
+ * The list of render functions, along with required parameters, used to render cells.
+ * @property renderStack
+ * @type Array[]
+ */
+ renderStack : null,
+
+ /**
+ * A copy of the initial render functions created before rendering.
+ * @property _renderStack
+ * @private
+ * @type Array
+ */
+ _renderStack : null,
+
+ /**
+ * A Date object representing the month/year that the calendar is initially set to
+ * @property _pageDate
+ * @private
+ * @type Date
+ */
+ _pageDate : null,
+
+ /**
+ * The private list of initially selected dates.
+ * @property _selectedDates
+ * @private
+ * @type Array
+ */
+ _selectedDates : null,
+
+ /**
+ * A map of DOM event handlers to attach to cells associated with specific CSS class names
+ * @property domEventMap
+ * @type Object
+ */
+ domEventMap : null
+};
+
+
+
+/**
+* Initializes the Calendar widget.
+* @method init
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container div element that will wrap the calendar table
+* @param {Object} config The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) {
+ this.logger = new YAHOO.widget.LogWriter("Calendar_Core " + id);
+
+ this.initEvents();
+ this.today = new Date();
+ YAHOO.widget.DateMath.clearTime(this.today);
+
+ this.id = id;
+ this.oDomContainer = document.getElementById(containerId);
+ if (! this.oDomContainer) {
+ this.logger.log("No valid container present.", "error");
+ }
+
+ /**
+ * The Config object used to hold the configuration variables for the Calendar
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ /**
+ * The local object which contains the Calendar's options
+ * @property Options
+ * @type Object
+ */
+ this.Options = {};
+
+ /**
+ * The local object which contains the Calendar's locale settings
+ * @property Locale
+ * @type Object
+ */
+ this.Locale = {};
+
+ this.initStyles();
+
+ YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER);
+ YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE);
+
+ this.cellDates = [];
+ this.cells = [];
+ this.renderStack = [];
+ this._renderStack = [];
+
+ this.setupConfig();
+
+ if (config) {
+ this.cfg.applyConfig(config, true);
+ }
+
+ this.cfg.fireQueue();
+};
+
+/**
+* Renders the built-in IFRAME shim for the IE6 and below
+* @method configIframe
+*/
+YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) {
+ var useIframe = args[0];
+
+ if (YAHOO.util.Dom.inDocument(this.oDomContainer)) {
+ if (useIframe) {
+ var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position");
+
+ if (this.browser == "ie" && (pos == "absolute" || pos == "relative")) {
+ if (! YAHOO.util.Dom.inDocument(this.iframe)) {
+ this.iframe = document.createElement("iframe");
+ this.iframe.src = "javascript:false;";
+ YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
+ this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild);
+ }
+ }
+ } else {
+ if (this.iframe) {
+ if (this.iframe.parentNode) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+ this.iframe = null;
+ }
+ }
+ }
+};
+
+/**
+* Default handler for the "title" property
+* @method configTitle
+*/
+YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) {
+ var title = args[0];
+ var close = this.cfg.getProperty("close");
+
+ var titleDiv;
+
+ if (title && title !== "") {
+ titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || document.createElement("div");
+ titleDiv.className = YAHOO.widget.CalendarGroup.CSS_2UPTITLE;
+ titleDiv.innerHTML = title;
+ this.oDomContainer.insertBefore(titleDiv, this.oDomContainer.firstChild);
+ YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
+ } else {
+ titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || null;
+
+ if (titleDiv) {
+ YAHOO.util.Event.purgeElement(titleDiv);
+ this.oDomContainer.removeChild(titleDiv);
+ }
+ if (! close) {
+ YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
+ }
+ }
+};
+
+/**
+* Default handler for the "close" property
+* @method configClose
+*/
+YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) {
+ var close = args[0];
+ var title = this.cfg.getProperty("title");
+
+ var linkClose;
+
+ if (close === true) {
+ linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || document.createElement("a");
+ linkClose.href = "javascript:void(null);";
+ linkClose.className = "link-close";
+ YAHOO.util.Event.addListener(linkClose, "click", this.hide, this, true);
+ var imgClose = document.createElement("img");
+ imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + "us/my/bn/x_d.gif";
+ imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;
+ linkClose.appendChild(imgClose);
+ this.oDomContainer.appendChild(linkClose);
+ YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
+ } else {
+ linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || null;
+
+ if (linkClose) {
+ YAHOO.util.Event.purgeElement(linkClose);
+ this.oDomContainer.removeChild(linkClose);
+ }
+ if (! title || title === "") {
+ YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
+ }
+ }
+};
+
+/**
+* Initializes Calendar's built-in CustomEvents
+* @method initEvents
+*/
+YAHOO.widget.Calendar.prototype.initEvents = function() {
+
+ /**
+ * Fired before a selection is made
+ * @event beforeSelectEvent
+ */
+ this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect");
+
+ /**
+ * Fired when a selection is made
+ * @event selectEvent
+ * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
+ */
+ this.selectEvent = new YAHOO.util.CustomEvent("select");
+
+ /**
+ * Fired before a selection is made
+ * @event beforeDeselectEvent
+ */
+ this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect");
+
+ /**
+ * Fired when a selection is made
+ * @event deselectEvent
+ * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
+ */
+ this.deselectEvent = new YAHOO.util.CustomEvent("deselect");
+
+ /**
+ * Fired when the Calendar page is changed
+ * @event changePageEvent
+ */
+ this.changePageEvent = new YAHOO.util.CustomEvent("changePage");
+
+ /**
+ * Fired before the Calendar is rendered
+ * @event beforeRenderEvent
+ */
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+
+ /**
+ * Fired when the Calendar is rendered
+ * @event renderEvent
+ */
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ /**
+ * Fired when the Calendar is reset
+ * @event resetEvent
+ */
+ this.resetEvent = new YAHOO.util.CustomEvent("reset");
+
+ /**
+ * Fired when the Calendar is cleared
+ * @event clearEvent
+ */
+ this.clearEvent = new YAHOO.util.CustomEvent("clear");
+
+ this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true);
+ this.selectEvent.subscribe(this.onSelect, this, true);
+ this.beforeDeselectEvent.subscribe(this.onBeforeDeselect, this, true);
+ this.deselectEvent.subscribe(this.onDeselect, this, true);
+ this.changePageEvent.subscribe(this.onChangePage, this, true);
+ this.renderEvent.subscribe(this.onRender, this, true);
+ this.resetEvent.subscribe(this.onReset, this, true);
+ this.clearEvent.subscribe(this.onClear, this, true);
+};
+
+
+/**
+* The default event function that is attached to a date link within a calendar cell
+* when the calendar is rendered.
+* @method doSelectCell
+* @param {DOMEvent} e The event
+* @param {Calendar} cal A reference to the calendar passed by the Event utility
+*/
+YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) {
+ var target = YAHOO.util.Event.getTarget(e);
+
+ var cell,index,d,date;
+
+ while (target.tagName.toLowerCase() != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+ target = target.parentNode;
+ if (target.tagName.toLowerCase() == "html") {
+ return;
+ }
+ }
+
+ cell = target;
+
+ if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) {
+ index = cell.id.split("cell")[1];
+ d = cal.cellDates[index];
+ date = new Date(d[0],d[1]-1,d[2]);
+
+ var link;
+
+ cal.logger.log("Selecting cell " + index + " via click", "info");
+
+ if (cal.Options.MULTI_SELECT) {
+ link = cell.getElementsByTagName("a")[0];
+ if (link) {
+ link.blur();
+ }
+
+ var cellDate = cal.cellDates[index];
+ var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate);
+
+ if (cellDateIndex > -1) {
+ cal.deselectCell(index);
+ } else {
+ cal.selectCell(index);
+ }
+
+ } else {
+ link = cell.getElementsByTagName("a")[0];
+ if (link) {
+ link.blur();
+ }
+ cal.selectCell(index);
+ }
+ }
+};
+
+/**
+* The event that is executed when the user hovers over a cell
+* @method doCellMouseOver
+* @param {DOMEvent} e The event
+* @param {Calendar} cal A reference to the calendar passed by the Event utility
+*/
+YAHOO.widget.Calendar.prototype.doCellMouseOver = function(e, cal) {
+ var target;
+ if (e) {
+ target = YAHOO.util.Event.getTarget(e);
+ } else {
+ target = this;
+ }
+
+ while (target.tagName.toLowerCase() != "td") {
+ target = target.parentNode;
+ if (target.tagName.toLowerCase() == "html") {
+ return;
+ }
+ }
+
+ if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+ YAHOO.util.Dom.addClass(target, cal.Style.CSS_CELL_HOVER);
+ }
+};
+
+/**
+* The event that is executed when the user moves the mouse out of a cell
+* @method doCellMouseOut
+* @param {DOMEvent} e The event
+* @param {Calendar} cal A reference to the calendar passed by the Event utility
+*/
+YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) {
+ var target;
+ if (e) {
+ target = YAHOO.util.Event.getTarget(e);
+ } else {
+ target = this;
+ }
+
+ while (target.tagName.toLowerCase() != "td") {
+ target = target.parentNode;
+ if (target.tagName.toLowerCase() == "html") {
+ return;
+ }
+ }
+
+ if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+ YAHOO.util.Dom.removeClass(target, cal.Style.CSS_CELL_HOVER);
+ }
+};
+
+YAHOO.widget.Calendar.prototype.setupConfig = function() {
+
+ /**
+ * The month/year representing the current visible Calendar date (mm/yyyy)
+ * @config pagedate
+ * @type String
+ * @default today's date
+ */
+ this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
+
+ /**
+ * The date or range of dates representing the current Calendar selection
+ * @config selected
+ * @type String
+ * @default []
+ */
+ this.cfg.addProperty("selected", { value:[], handler:this.configSelected } );
+
+ /**
+ * The title to display above the Calendar's month header
+ * @config title
+ * @type String
+ * @default ""
+ */
+ this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
+
+ /**
+ * Whether or not a close button should be displayed for this Calendar
+ * @config close
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("close", { value:false, handler:this.configClose } );
+
+ /**
+ * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
+ * @config iframe
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The minimum selectable date in the current Calendar (mm/dd/yyyy)
+ * @config mindate
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } );
+
+ /**
+ * The maximum selectable date in the current Calendar (mm/dd/yyyy)
+ * @config maxdate
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } );
+
+
+ // Options properties
+
+ /**
+ * True if the Calendar should allow multiple selections. False by default.
+ * @config MULTI_SELECT
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The weekday the week begins on. Default is 0 (Sunday).
+ * @config START_WEEKDAY
+ * @type number
+ * @default 0
+ */
+ this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.configOptions, validator:this.cfg.checkNumber } );
+
+ /**
+ * True if the Calendar should show weekday labels. True by default.
+ * @config SHOW_WEEKDAYS
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should show week row headers. False by default.
+ * @config SHOW_WEEK_HEADER
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should show week row footers. False by default.
+ * @config SHOW_WEEK_FOOTER
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should suppress weeks that are not a part of the current month. False by default.
+ * @config HIDE_BLANK_WEEKS
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The image that should be used for the left navigation arrow.
+ * @config NAV_ARROW_LEFT
+ * @type String
+ * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
+ */
+ this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.configOptions } );
+
+ /**
+ * The image that should be used for the left navigation arrow.
+ * @config NAV_ARROW_RIGHT
+ * @type String
+ * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
+ */
+ this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.configOptions } );
+
+ // Locale properties
+
+ /**
+ * The short month labels for the current locale.
+ * @config MONTHS_SHORT
+ * @type String[]
+ * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+ */
+ this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.configLocale } );
+
+ /**
+ * The long month labels for the current locale.
+ * @config MONTHS_LONG
+ * @type String[]
+ * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
+ */
+ this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.configLocale } );
+
+ /**
+ * The 1-character weekday labels for the current locale.
+ * @config WEEKDAYS_1CHAR
+ * @type String[]
+ * @default ["S", "M", "T", "W", "T", "F", "S"]
+ */
+ this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.configLocale } );
+
+ /**
+ * The short weekday labels for the current locale.
+ * @config WEEKDAYS_SHORT
+ * @type String[]
+ * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
+ */
+ this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.configLocale } );
+
+ /**
+ * The medium weekday labels for the current locale.
+ * @config WEEKDAYS_MEDIUM
+ * @type String[]
+ * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
+ */
+ this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.configLocale } );
+
+ /**
+ * The long weekday labels for the current locale.
+ * @config WEEKDAYS_LONG
+ * @type String[]
+ * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
+ */
+ this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.configLocale } );
+
+ /**
+ * Refreshes the locale values used to build the Calendar.
+ * @method refreshLocale
+ * @private
+ */
+ var refreshLocale = function() {
+ this.cfg.refireEvent("LOCALE_MONTHS");
+ this.cfg.refireEvent("LOCALE_WEEKDAYS");
+ };
+
+ this.cfg.subscribeToConfigEvent("START_WEEKDAY", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("MONTHS_SHORT", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("MONTHS_LONG", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG", refreshLocale, this, true);
+
+ /**
+ * The setting that determines which length of month labels should be used. Possible values are "short" and "long".
+ * @config LOCALE_MONTHS
+ * @type String
+ * @default "long"
+ */
+ this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } );
+
+ /**
+ * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
+ * @config LOCALE_WEEKDAYS
+ * @type String
+ * @default "short"
+ */
+ this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } );
+
+ /**
+ * The value used to delimit individual dates in a date string passed to various Calendar functions.
+ * @config DATE_DELIMITER
+ * @type String
+ * @default ","
+ */
+ this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } );
+
+ /**
+ * The value used to delimit date fields in a date string passed to various Calendar functions.
+ * @config DATE_FIELD_DELIMITER
+ * @type String
+ * @default "/"
+ */
+ this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } );
+
+ /**
+ * The value used to delimit date ranges in a date string passed to various Calendar functions.
+ * @config DATE_RANGE_DELIMITER
+ * @type String
+ * @default "-"
+ */
+ this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } );
+
+ /**
+ * The position of the month in a month/year date string
+ * @config MY_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the year in a month/year date string
+ * @config MY_YEAR_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the month in a month/day date string
+ * @config MD_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the day in a month/year date string
+ * @config MD_DAY_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the month in a month/day/year date string
+ * @config MDY_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the day in a month/day/year date string
+ * @config MDY_DAY_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the year in a month/day/year date string
+ * @config MDY_YEAR_POSITION
+ * @type Number
+ * @default 3
+ */
+ this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } );
+};
+
+/**
+* The default handler for the "pagedate" property
+* @method configPageDate
+*/
+YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) {
+ var val = args[0];
+ var month, year, aMonthYear;
+
+ if (val) {
+ if (val instanceof Date) {
+ val = YAHOO.widget.DateMath.findMonthStart(val);
+ this.cfg.setProperty("pagedate", val, true);
+ if (! this._pageDate) {
+ this._pageDate = this.cfg.getProperty("pagedate");
+ }
+ return;
+ } else {
+ aMonthYear = val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER"));
+ month = parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1], 10)-1;
+ year = parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1], 10);
+ }
+ } else {
+ month = this.today.getMonth();
+ year = this.today.getFullYear();
+ }
+
+ this.cfg.setProperty("pagedate", new Date(year, month, 1), true);
+
+ this.logger.log("Set month/year to " + month + "/" + year, "info");
+
+ if (! this._pageDate) {
+ this._pageDate = this.cfg.getProperty("pagedate");
+ }
+};
+
+/**
+* The default handler for the "mindate" property
+* @method configMinDate
+*/
+YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) {
+ var val = args[0];
+ if (typeof val == 'string') {
+ val = this._parseDate(val);
+ this.cfg.setProperty("mindate", new Date(val[0],(val[1]-1),val[2]));
+ }
+};
+
+/**
+* The default handler for the "maxdate" property
+* @method configMaxDate
+*/
+YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) {
+ var val = args[0];
+ if (typeof val == 'string') {
+ val = this._parseDate(val);
+ this.cfg.setProperty("maxdate", new Date(val[0],(val[1]-1),val[2]));
+ }
+};
+
+/**
+* The default handler for the "selected" property
+* @method configSelected
+*/
+YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) {
+ var selected = args[0];
+
+ if (selected) {
+ if (typeof selected == 'string') {
+ this.cfg.setProperty("selected", this._parseDates(selected), true);
+ }
+ }
+ if (! this._selectedDates) {
+ this._selectedDates = this.cfg.getProperty("selected");
+ }
+};
+
+/**
+* The default handler for all configuration options properties
+* @method configOptions
+*/
+YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) {
+ type = type.toUpperCase();
+ var val = args[0];
+ this.Options[type] = val;
+};
+
+/**
+* The default handler for all configuration locale properties
+* @method configLocale
+*/
+YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) {
+ type = type.toUpperCase();
+ var val = args[0];
+ this.Locale[type] = val;
+
+ this.cfg.refireEvent("LOCALE_MONTHS");
+ this.cfg.refireEvent("LOCALE_WEEKDAYS");
+
+};
+
+/**
+* The default handler for all configuration locale field length properties
+* @method configLocaleValues
+*/
+YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) {
+ type = type.toUpperCase();
+ var val = args[0];
+
+ switch (type) {
+ case "LOCALE_MONTHS":
+ switch (val) {
+ case "short":
+ this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_SHORT").concat();
+ break;
+ case "long":
+ this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_LONG").concat();
+ break;
+ }
+ break;
+ case "LOCALE_WEEKDAYS":
+ switch (val) {
+ case "1char":
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_1CHAR").concat();
+ break;
+ case "short":
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_SHORT").concat();
+ break;
+ case "medium":
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_MEDIUM").concat();
+ break;
+ case "long":
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_LONG").concat();
+ break;
+ }
+
+ var START_WEEKDAY = this.cfg.getProperty("START_WEEKDAY");
+
+ if (START_WEEKDAY > 0) {
+ for (var w=0;w";
+ html[html.length] = "";
+ html[html.length] = '';
+ html[html.length] = ' ';
+
+ if (this.cfg.getProperty("SHOW_WEEKDAYS")) {
+ html = this.buildWeekdays(html);
+ }
+
+ html[html.length] = '';
+
+ return html;
+};
+
+/**
+* Renders the Calendar's weekday headers.
+* @method buildWeekdays
+* @param {Array} html The current working HTML array
+* @return {Array} The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) {
+
+ html[html.length] = '';
+
+ if (this.cfg.getProperty("SHOW_WEEK_HEADER")) {
+ html[html.length] = ' ';
+ }
+
+ for(var i=0;i' + this.Locale.LOCALE_WEEKDAYS[i] + '';
+ }
+
+ if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) {
+ html[html.length] = ' ';
+ }
+
+ html[html.length] = ' ';
+
+ return html;
+};
+
+/**
+* Renders the calendar body.
+* @method renderBody
+* @param {Date} workingDate The current working Date being used for the render process
+* @param {Array} html The current working HTML array
+* @return {Array} The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) {
+ this.logger.log("Rendering body", "info");
+
+ var startDay = this.cfg.getProperty("START_WEEKDAY");
+
+ this.preMonthDays = workingDate.getDay();
+ if (startDay > 0) {
+ this.preMonthDays -= startDay;
+ }
+ if (this.preMonthDays < 0) {
+ this.preMonthDays += 7;
+ }
+
+ this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
+ this.postMonthDays = YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
+
+ this.logger.log(this.preMonthDays + " preciding out-of-month days", "info");
+ this.logger.log(this.monthDays + " month days", "info");
+ this.logger.log(this.postMonthDays + " post-month days", "info");
+
+ workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
+ this.logger.log("Calendar page starts on " + workingDate, "info");
+
+ var useDate,weekNum,weekClass;
+ useDate = this.cfg.getProperty("pagedate");
+
+ html[html.length] = '';
+
+ var i = 0;
+
+ var tempDiv = document.createElement("div");
+ var cell = document.createElement("td");
+ tempDiv.appendChild(cell);
+
+ var jan1 = new Date(useDate.getFullYear(),0,1);
+
+ var cal = this.parent || this;
+
+ for (var r=0;r<6;r++) {
+
+ weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useDate.getFullYear(), startDay);
+
+ weekClass = "w" + weekNum;
+
+ if (r !== 0 && this.isDateOOM(workingDate) && this.cfg.getProperty("HIDE_BLANK_WEEKS") === true) {
+ break;
+ } else {
+
+ html[html.length] = '';
+
+ if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { html = this.renderRowHeader(weekNum, html); }
+
+ for (var d=0;d<7;d++){ // Render actual days
+
+ var cellRenderers = [];
+
+ this.clearElement(cell);
+
+ YAHOO.util.Dom.addClass(cell, "calcell");
+
+ cell.id = this.id + "_cell" + i;
+ this.logger.log("Rendering cell " + cell.id + " (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + ")", "cellrender");
+
+ cell.innerHTML = i;
+
+ var renderer = null;
+
+ if (workingDate.getFullYear() == this.today.getFullYear() &&
+ workingDate.getMonth() == this.today.getMonth() &&
+ workingDate.getDate() == this.today.getDate()) {
+ cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;
+ }
+
+ this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates
+
+ if (this.isDateOOM(workingDate)) {
+ cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;
+ } else {
+
+ YAHOO.util.Dom.addClass(cell, "wd" + workingDate.getDay());
+ YAHOO.util.Dom.addClass(cell, "d" + workingDate.getDate());
+
+ for (var s=0;s= d1.getTime() && workingDate.getTime() <= d2.getTime()) {
+ renderer = rArray[2];
+
+ if (workingDate.getTime()==d2.getTime()) {
+ this.renderStack.splice(s,1);
+ }
+ }
+ break;
+ case YAHOO.widget.Calendar.WEEKDAY:
+
+ var weekday = rArray[1][0];
+ if (workingDate.getDay()+1 == weekday) {
+ renderer = rArray[2];
+ }
+ break;
+ case YAHOO.widget.Calendar.MONTH:
+
+ month = rArray[1][0];
+ if (workingDate.getMonth()+1 == month) {
+ renderer = rArray[2];
+ }
+ break;
+ }
+
+ if (renderer) {
+ cellRenderers[cellRenderers.length]=renderer;
+ }
+ }
+
+ }
+
+ if (this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]) > -1) {
+ cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected;
+ }
+
+ var mindate = this.cfg.getProperty("mindate");
+ var maxdate = this.cfg.getProperty("maxdate");
+
+ if (mindate) {
+ mindate = YAHOO.widget.DateMath.clearTime(mindate);
+ }
+ if (maxdate) {
+ maxdate = YAHOO.widget.DateMath.clearTime(maxdate);
+ }
+
+ if (
+ (mindate && (workingDate.getTime() < mindate.getTime())) ||
+ (maxdate && (workingDate.getTime() > maxdate.getTime()))
+ ) {
+ cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate;
+ } else {
+ cellRenderers[cellRenderers.length]=cal.styleCellDefault;
+ cellRenderers[cellRenderers.length]=cal.renderCellDefault;
+ }
+
+
+
+ for (var x=0;x= 0 && i <= 6) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TOP);
+ }
+ if ((i % 7) === 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_LEFT);
+ }
+ if (((i+1) % 7) === 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RIGHT);
+ }
+
+ var postDays = this.postMonthDays;
+ if (postDays >= 7 && this.cfg.getProperty("HIDE_BLANK_WEEKS")) {
+ var blankWeeks = Math.floor(postDays/7);
+ for (var p=0;p= ((this.preMonthDays+postDays+this.monthDays)-7)) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM);
+ }
+
+ html[html.length] = tempDiv.innerHTML;
+
+ i++;
+ }
+
+ if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { html = this.renderRowFooter(weekNum, html); }
+
+ html[html.length] = ' ';
+ }
+ }
+
+ html[html.length] = ' ';
+
+ return html;
+};
+
+/**
+* Renders the calendar footer. In the default implementation, there is
+* no footer.
+* @method renderFooter
+* @param {Array} html The current working HTML array
+* @return {Array} The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.renderFooter = function(html) { return html; };
+
+/**
+* Renders the calendar after it has been configured. The render() method has a specific call chain that will execute
+* when the method is called: renderHeader, renderBody, renderFooter.
+* Refer to the documentation for those methods for information on
+* individual render tasks.
+* @method render
+*/
+YAHOO.widget.Calendar.prototype.render = function() {
+ this.beforeRenderEvent.fire();
+
+ // Find starting day of the current month
+ var workingDate = YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty("pagedate"));
+
+ this.resetRenderers();
+ this.cellDates.length = 0;
+
+ YAHOO.util.Event.purgeElement(this.oDomContainer, true);
+
+ var html = [];
+
+ html[html.length] = '';
+ html = this.renderHeader(html);
+ html = this.renderBody(workingDate, html);
+ html = this.renderFooter(html);
+ html[html.length] = '
';
+
+ this.oDomContainer.innerHTML = html.join("\n");
+
+ this.applyListeners();
+ this.cells = this.oDomContainer.getElementsByTagName("td");
+
+ this.cfg.refireEvent("title");
+ this.cfg.refireEvent("close");
+ this.cfg.refireEvent("iframe");
+
+ this.renderEvent.fire();
+};
+
+/**
+* Applies the Calendar's DOM listeners to applicable elements.
+* @method applyListeners
+*/
+YAHOO.widget.Calendar.prototype.applyListeners = function() {
+
+ var root = this.oDomContainer;
+ var cal = this.parent || this;
+
+ var linkLeft, linkRight;
+
+ linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, "a", root);
+ linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, "a", root);
+
+ if (linkLeft) {
+ this.linkLeft = linkLeft[0];
+ YAHOO.util.Event.addListener(this.linkLeft, "mousedown", cal.previousMonth, cal, true);
+ }
+
+ if (linkRight) {
+ this.linkRight = linkRight[0];
+ YAHOO.util.Event.addListener(this.linkRight, "mousedown", cal.nextMonth, cal, true);
+ }
+
+ if (this.domEventMap) {
+ var el,elements;
+ for (var cls in this.domEventMap) {
+ if (this.domEventMap.hasOwnProperty(cls)) {
+ var items = this.domEventMap[cls];
+
+ if (! (items instanceof Array)) {
+ items = [items];
+ }
+
+ for (var i=0;i' + weekNum + '';
+ return html;
+};
+
+/**
+* Renders the row footer for a week.
+* @method renderRowFooter
+* @param {Number} weekNum The week number of the current row
+* @param {Array} cell The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) {
+ html[html.length] = '';
+ return html;
+};
+
+/**
+* Renders a single standard calendar cell in the calendar widget table.
+* All logic for determining how a standard default cell will be rendered is
+* encapsulated in this method, and must be accounted for when extending the
+* widget class.
+* @method renderCellDefault
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) {
+ cell.innerHTML = '' + this.buildDayLabel(workingDate) + " ";
+};
+
+/**
+* Styles a selectable cell.
+* @method styleCellDefault
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.styleCellDefault = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE);
+};
+
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight1 style
+* @method renderCellStyleHighlight1
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight2 style
+* @method renderCellStyleHighlight2
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight3 style
+* @method renderCellStyleHighlight3
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight4 style
+* @method renderCellStyleHighlight4
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
+};
+
+/**
+* Applies the default style used for rendering today's date to the current calendar cell
+* @method renderCellStyleToday
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleToday = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY);
+};
+
+/**
+* Applies the default style used for rendering selected dates to the current calendar cell
+* @method renderCellStyleSelected
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleSelected = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED);
+};
+
+/**
+* Applies the default style used for rendering dates that are not a part of the current
+* month (preceding or trailing the cells for the current month)
+* @method renderCellNotThisMonth
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+*/
+YAHOO.widget.Calendar.prototype.renderCellNotThisMonth = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar.STOP_RENDER;
+};
+
+/**
+* Renders the current calendar cell as a non-selectable "black-out" date using the default
+* restricted style.
+* @method renderBodyCellRestricted
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+*/
+YAHOO.widget.Calendar.prototype.renderBodyCellRestricted = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL);
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RESTRICTED);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar.STOP_RENDER;
+};
+
+// END BUILT-IN TABLE CELL RENDERERS
+
+// BEGIN MONTH NAVIGATION METHODS
+
+/**
+* Adds the designated number of months to the current calendar month, and sets the current
+* calendar page date to the new month.
+* @method addMonths
+* @param {Number} count The number of months to add to the current calendar
+*/
+YAHOO.widget.Calendar.prototype.addMonths = function(count) {
+ this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+};
+
+/**
+* Subtracts the designated number of months from the current calendar month, and sets the current
+* calendar page date to the new month.
+* @method subtractMonths
+* @param {Number} count The number of months to subtract from the current calendar
+*/
+YAHOO.widget.Calendar.prototype.subtractMonths = function(count) {
+ this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+};
+
+/**
+* Adds the designated number of years to the current calendar, and sets the current
+* calendar page date to the new month.
+* @method addYears
+* @param {Number} count The number of years to add to the current calendar
+*/
+YAHOO.widget.Calendar.prototype.addYears = function(count) {
+ this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+};
+
+/**
+* Subtcats the designated number of years from the current calendar, and sets the current
+* calendar page date to the new month.
+* @method subtractYears
+* @param {Number} count The number of years to subtract from the current calendar
+*/
+YAHOO.widget.Calendar.prototype.subtractYears = function(count) {
+ this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+};
+
+/**
+* Navigates to the next month page in the calendar widget.
+* @method nextMonth
+*/
+YAHOO.widget.Calendar.prototype.nextMonth = function() {
+ this.addMonths(1);
+};
+
+/**
+* Navigates to the previous month page in the calendar widget.
+* @method previousMonth
+*/
+YAHOO.widget.Calendar.prototype.previousMonth = function() {
+ this.subtractMonths(1);
+};
+
+/**
+* Navigates to the next year in the currently selected month in the calendar widget.
+* @method nextYear
+*/
+YAHOO.widget.Calendar.prototype.nextYear = function() {
+ this.addYears(1);
+};
+
+/**
+* Navigates to the previous year in the currently selected month in the calendar widget.
+* @method previousYear
+*/
+YAHOO.widget.Calendar.prototype.previousYear = function() {
+ this.subtractYears(1);
+};
+
+// END MONTH NAVIGATION METHODS
+
+// BEGIN SELECTION METHODS
+
+/**
+* Resets the calendar widget to the originally selected month and year, and
+* sets the calendar to the initial selection(s).
+* @method reset
+*/
+YAHOO.widget.Calendar.prototype.reset = function() {
+ this.cfg.resetProperty("selected");
+ this.cfg.resetProperty("pagedate");
+ this.resetEvent.fire();
+};
+
+/**
+* Clears the selected dates in the current calendar widget and sets the calendar
+* to the current month and year.
+* @method clear
+*/
+YAHOO.widget.Calendar.prototype.clear = function() {
+ this.cfg.setProperty("selected", []);
+ this.cfg.setProperty("pagedate", new Date(this.today.getTime()));
+ this.clearEvent.fire();
+};
+
+/**
+* Selects a date or a collection of dates on the current calendar. This method, by default,
+* does not call the render method explicitly. Once selection has completed, render must be
+* called for the changes to be reflected visually.
+* @method select
+* @param {String/Date/Date[]} date The date string of dates to select in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+*/
+YAHOO.widget.Calendar.prototype.select = function(date) {
+ this.logger.log("Select: " + date, "info");
+
+ this.beforeSelectEvent.fire();
+
+ var selected = this.cfg.getProperty("selected");
+ var aToBeSelected = this._toFieldArray(date);
+ this.logger.log("Selection field array: " + aToBeSelected, "info");
+
+ for (var a=0;a -1) {
+ if (this.cfg.getProperty("pagedate").getMonth() == dCellDate.getMonth() &&
+ this.cfg.getProperty("pagedate").getFullYear() == dCellDate.getFullYear()) {
+ YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED);
+ }
+
+ selected.splice(cellDateIndex, 1);
+ }
+
+
+ if (this.parent) {
+ this.parent.cfg.setProperty("selected", selected);
+ } else {
+ this.cfg.setProperty("selected", selected);
+ }
+
+ this.deselectEvent.fire(selectDate);
+ return this.getSelectedDates();
+};
+
+/**
+* Deselects all dates on the current calendar.
+* @method deselectAll
+* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+* Assuming that this function executes properly, the return value should be an empty array.
+* However, the empty array is returned for the sake of being able to check the selection status
+* of the calendar.
+*/
+YAHOO.widget.Calendar.prototype.deselectAll = function() {
+ this.beforeDeselectEvent.fire();
+
+ var selected = this.cfg.getProperty("selected");
+ var count = selected.length;
+ var sel = selected.concat();
+
+ if (this.parent) {
+ this.parent.cfg.setProperty("selected", []);
+ } else {
+ this.cfg.setProperty("selected", []);
+ }
+
+ if (count > 0) {
+ this.deselectEvent.fire(sel);
+ }
+
+ return this.getSelectedDates();
+};
+
+// END SELECTION METHODS
+
+// BEGIN TYPE CONVERSION METHODS
+
+/**
+* Converts a date (either a JavaScript Date object, or a date string) to the internal data structure
+* used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]].
+* @method _toFieldArray
+* @private
+* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return {Array[](Number[])} Array of date field arrays
+*/
+YAHOO.widget.Calendar.prototype._toFieldArray = function(date) {
+ var returnDate = [];
+
+ if (date instanceof Date) {
+ returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]];
+ } else if (typeof date == 'string') {
+ returnDate = this._parseDates(date);
+ } else if (date instanceof Array) {
+ for (var i=0;i
+*
+*
+*
+* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
+* @namespace YAHOO.widget
+* @class CalendarGroup
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container div element that will wrap the calendar table
+* @param {Object} config The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.CalendarGroup = function(id, containerId, config) {
+ if (arguments.length > 0) {
+ this.init(id, containerId, config);
+ }
+};
+
+/**
+* Initializes the calendar group. All subclasses must call this method in order for the
+* group to be initialized properly.
+* @method init
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container div element that will wrap the calendar table
+* @param {Object} config The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.CalendarGroup.prototype.init = function(id, containerId, config) {
+ this.logger = new YAHOO.widget.LogWriter("CalendarGroup " + id);
+
+ this.initEvents();
+ this.initStyles();
+
+ /**
+ * The collection of Calendar pages contained within the CalendarGroup
+ * @property pages
+ * @type YAHOO.widget.Calendar[]
+ */
+ this.pages = [];
+
+ /**
+ * The unique id associated with the CalendarGroup
+ * @property id
+ * @type String
+ */
+ this.id = id;
+
+ /**
+ * The unique id associated with the CalendarGroup container
+ * @property containerId
+ * @type String
+ */
+ this.containerId = containerId;
+
+ /**
+ * The outer containing element for the CalendarGroup
+ * @property oDomContainer
+ * @type HTMLElement
+ */
+ this.oDomContainer = document.getElementById(containerId);
+
+ YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_CONTAINER);
+ YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_MULTI_UP);
+
+ /**
+ * The Config object used to hold the configuration variables for the CalendarGroup
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ /**
+ * The local object which contains the CalendarGroup's options
+ * @property Options
+ * @type Object
+ */
+ this.Options = {};
+
+ /**
+ * The local object which contains the CalendarGroup's locale settings
+ * @property Locale
+ * @type Object
+ */
+ this.Locale = {};
+
+ this.setupConfig();
+
+ if (config) {
+ this.cfg.applyConfig(config, true);
+ }
+
+ this.cfg.fireQueue();
+
+ // OPERA HACK FOR MISWRAPPED FLOATS
+ if (this.browser == "opera"){
+ var fixWidth = function() {
+ var startW = this.oDomContainer.offsetWidth;
+ var w = 0;
+ for (var p=0;p 0) {
+ this.oDomContainer.style.width = w + "px";
+ }
+ };
+ this.renderEvent.subscribe(fixWidth,this,true);
+ }
+
+ this.logger.log("Initialized " + pageCount + "-page CalendarGroup", "info");
+};
+
+
+YAHOO.widget.CalendarGroup.prototype.setupConfig = function() {
+ /**
+ * The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments.
+ * @config pages
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("pages", { value:2, validator:this.cfg.checkNumber, handler:this.configPages } );
+
+ /**
+ * The month/year representing the current visible Calendar date (mm/yyyy)
+ * @config pagedate
+ * @type String
+ * @default today's date
+ */
+ this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
+
+ /**
+ * The date or range of dates representing the current Calendar selection
+ * @config selected
+ * @type String
+ * @default []
+ */
+ this.cfg.addProperty("selected", { value:[], handler:this.delegateConfig } );
+
+ /**
+ * The title to display above the CalendarGroup's month header
+ * @config title
+ * @type String
+ * @default ""
+ */
+ this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
+
+ /**
+ * Whether or not a close button should be displayed for this CalendarGroup
+ * @config close
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("close", { value:false, handler:this.configClose } );
+
+ /**
+ * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
+ * @config iframe
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("iframe", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The minimum selectable date in the current Calendar (mm/dd/yyyy)
+ * @config mindate
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("mindate", { value:null, handler:this.delegateConfig } );
+
+ /**
+ * The maximum selectable date in the current Calendar (mm/dd/yyyy)
+ * @config maxdate
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("maxdate", { value:null, handler:this.delegateConfig } );
+
+ // Options properties
+
+ /**
+ * True if the Calendar should allow multiple selections. False by default.
+ * @config MULTI_SELECT
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The weekday the week begins on. Default is 0 (Sunday).
+ * @config START_WEEKDAY
+ * @type number
+ * @default 0
+ */
+ this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * True if the Calendar should show weekday labels. True by default.
+ * @config SHOW_WEEKDAYS
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should show week row headers. False by default.
+ * @config SHOW_WEEK_HEADER
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should show week row footers. False by default.
+ * @config SHOW_WEEK_FOOTER
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should suppress weeks that are not a part of the current month. False by default.
+ * @config HIDE_BLANK_WEEKS
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The image that should be used for the left navigation arrow.
+ * @config NAV_ARROW_LEFT
+ * @type String
+ * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
+ */
+ this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.delegateConfig } );
+
+ /**
+ * The image that should be used for the left navigation arrow.
+ * @config NAV_ARROW_RIGHT
+ * @type String
+ * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
+ */
+ this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.delegateConfig } );
+
+ // Locale properties
+
+ /**
+ * The short month labels for the current locale.
+ * @config MONTHS_SHORT
+ * @type String[]
+ * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+ */
+ this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.delegateConfig } );
+
+ /**
+ * The long month labels for the current locale.
+ * @config MONTHS_LONG
+ * @type String[]
+ * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
+ */
+ this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.delegateConfig } );
+
+ /**
+ * The 1-character weekday labels for the current locale.
+ * @config WEEKDAYS_1CHAR
+ * @type String[]
+ * @default ["S", "M", "T", "W", "T", "F", "S"]
+ */
+ this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.delegateConfig } );
+
+ /**
+ * The short weekday labels for the current locale.
+ * @config WEEKDAYS_SHORT
+ * @type String[]
+ * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
+ */
+ this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.delegateConfig } );
+
+ /**
+ * The medium weekday labels for the current locale.
+ * @config WEEKDAYS_MEDIUM
+ * @type String[]
+ * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
+ */
+ this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.delegateConfig } );
+
+ /**
+ * The long weekday labels for the current locale.
+ * @config WEEKDAYS_LONG
+ * @type String[]
+ * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
+ */
+ this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.delegateConfig } );
+
+ /**
+ * The setting that determines which length of month labels should be used. Possible values are "short" and "long".
+ * @config LOCALE_MONTHS
+ * @type String
+ * @default "long"
+ */
+ this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.delegateConfig } );
+
+ /**
+ * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
+ * @config LOCALE_WEEKDAYS
+ * @type String
+ * @default "short"
+ */
+ this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.delegateConfig } );
+
+ /**
+ * The value used to delimit individual dates in a date string passed to various Calendar functions.
+ * @config DATE_DELIMITER
+ * @type String
+ * @default ","
+ */
+ this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.delegateConfig } );
+
+ /**
+ * The value used to delimit date fields in a date string passed to various Calendar functions.
+ * @config DATE_FIELD_DELIMITER
+ * @type String
+ * @default "/"
+ */
+ this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.delegateConfig } );
+
+ /**
+ * The value used to delimit date ranges in a date string passed to various Calendar functions.
+ * @config DATE_RANGE_DELIMITER
+ * @type String
+ * @default "-"
+ */
+ this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.delegateConfig } );
+
+ /**
+ * The position of the month in a month/year date string
+ * @config MY_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the year in a month/year date string
+ * @config MY_YEAR_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the month in a month/day date string
+ * @config MD_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the day in a month/year date string
+ * @config MD_DAY_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the month in a month/day/year date string
+ * @config MDY_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the day in a month/day/year date string
+ * @config MDY_DAY_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the year in a month/day/year date string
+ * @config MDY_YEAR_POSITION
+ * @type Number
+ * @default 3
+ */
+ this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+};
+
+/**
+* Initializes CalendarGroup's built-in CustomEvents
+* @method initEvents
+*/
+YAHOO.widget.CalendarGroup.prototype.initEvents = function() {
+ var me = this;
+
+ /**
+ * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents
+ * @method sub
+ * @private
+ * @param {Function} fn The function to subscribe to this CustomEvent
+ * @param {Object} obj The CustomEvent's scope object
+ * @param {Boolean} bOverride Whether or not to apply scope correction
+ */
+ var sub = function(fn, obj, bOverride) {
+ for (var p=0;p0) {
+ year+=1;
+ }
+ cal.setYear(year);
+ }
+};
+/**
+* Calls the render function of all child calendars within the group.
+* @method render
+*/
+YAHOO.widget.CalendarGroup.prototype.render = function() {
+ this.renderHeader();
+ for (var p=0;p=0;--p) {
+ var cal = this.pages[p];
+ cal.previousMonth();
+ }
+};
+
+/**
+* Navigates to the next year in the currently selected month in the calendar widget.
+* @method nextYear
+*/
+YAHOO.widget.CalendarGroup.prototype.nextYear = function() {
+ for (var p=0;p11){while(newMonth>11){newMonth-=12;years+=1;}}
-d.setMonth(newMonth);d.setFullYear(date.getFullYear()+years);break;case this.DAY:d.setDate(date.getDate()+amount);break;case this.YEAR:d.setFullYear(date.getFullYear()+amount);break;case this.WEEK:d.setDate(date.getDate()+(amount*7));break;}
-return d;},subtract:function(date,field,amount){return this.add(date,field,(amount*-1));},before:function(date,compareTo){var ms=compareTo.getTime();if(date.getTime()ms){return true;}else{return false;}},between:function(date,dateBegin,dateEnd){if(this.after(date,dateBegin)&&this.before(date,dateEnd)){return true;}else{return false;}},getJan1:function(calendarYear){return new Date(calendarYear,0,1);},getDayOffset:function(date,calendarYear){var beginYear=this.getJan1(calendarYear);var dayOffset=Math.ceil((date.getTime()-beginYear.getTime())/this.ONE_DAY_MS);return dayOffset;},getWeekNumber:function(date,calendarYear){date=this.clearTime(date);var nearestThurs=new Date(date.getTime()+(4*this.ONE_DAY_MS)-((date.getDay())*this.ONE_DAY_MS));var jan1=new Date(nearestThurs.getFullYear(),0,1);var dayOfYear=((nearestThurs.getTime()-jan1.getTime())/this.ONE_DAY_MS)-1;var weekNum=Math.ceil((dayOfYear)/7);return weekNum;},isYearOverlapWeek:function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getFullYear()!=weekBeginDate.getFullYear()){overlaps=true;}
-return overlaps;},isMonthOverlapWeek:function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getMonth()!=weekBeginDate.getMonth()){overlaps=true;}
-return overlaps;},findMonthStart:function(date){var start=new Date(date.getFullYear(),date.getMonth(),1);return start;},findMonthEnd:function(date){var start=this.findMonthStart(date);var nextMonth=this.add(start,this.MONTH,1);var end=this.subtract(nextMonth,this.DAY,1);return end;},clearTime:function(date){date.setHours(12,0,0,0);return date;}};YAHOO.widget.Calendar=function(id,containerId,config){this.init(id,containerId,config);};YAHOO.widget.Calendar.IMG_ROOT=(window.location.href.toLowerCase().indexOf("https")===0?"https://a248.e.akamai.net/sec.yimg.com/i/":"http://us.i1.yimg.com/us.yimg.com/i/");YAHOO.widget.Calendar.DATE="D";YAHOO.widget.Calendar.MONTH_DAY="MD";YAHOO.widget.Calendar.WEEKDAY="WD";YAHOO.widget.Calendar.RANGE="R";YAHOO.widget.Calendar.MONTH="M";YAHOO.widget.Calendar.DISPLAY_DAYS=42;YAHOO.widget.Calendar.STOP_RENDER="S";YAHOO.widget.Calendar.prototype={Config:null,parent:null,index:-1,cells:null,cellDates:null,id:null,oDomContainer:null,today:null,renderStack:null,_renderStack:null,_pageDate:null,_selectedDates:null,domEventMap:null};YAHOO.widget.Calendar.prototype.init=function(id,containerId,config){this.initEvents();this.today=new Date();YAHOO.widget.DateMath.clearTime(this.today);this.id=id;this.oDomContainer=document.getElementById(containerId);this.cfg=new YAHOO.util.Config(this);this.Options={};this.Locale={};this.initStyles();YAHOO.util.Dom.addClass(this.oDomContainer,this.Style.CSS_CONTAINER);YAHOO.util.Dom.addClass(this.oDomContainer,this.Style.CSS_SINGLE);this.cellDates=[];this.cells=[];this.renderStack=[];this._renderStack=[];this.setupConfig();if(config){this.cfg.applyConfig(config,true);}
-this.cfg.fireQueue();};YAHOO.widget.Calendar.prototype.configIframe=function(type,args,obj){var useIframe=args[0];if(YAHOO.util.Dom.inDocument(this.oDomContainer)){if(useIframe){var pos=YAHOO.util.Dom.getStyle(this.oDomContainer,"position");if(this.browser=="ie"&&(pos=="absolute"||pos=="relative")){if(!YAHOO.util.Dom.inDocument(this.iframe)){this.iframe=document.createElement("iframe");this.iframe.src="javascript:false;";YAHOO.util.Dom.setStyle(this.iframe,"opacity","0");this.oDomContainer.insertBefore(this.iframe,this.oDomContainer.firstChild);}}}else{if(this.iframe){if(this.iframe.parentNode){this.iframe.parentNode.removeChild(this.iframe);}
-this.iframe=null;}}}};YAHOO.widget.Calendar.prototype.configTitle=function(type,args,obj){var title=args[0];var close=this.cfg.getProperty("close");var titleDiv;if(title&&title!==""){titleDiv=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE,"div",this.oDomContainer)[0]||document.createElement("div");titleDiv.className=YAHOO.widget.CalendarGroup.CSS_2UPTITLE;titleDiv.innerHTML=title;this.oDomContainer.insertBefore(titleDiv,this.oDomContainer.firstChild);YAHOO.util.Dom.addClass(this.oDomContainer,"withtitle");}else{titleDiv=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE,"div",this.oDomContainer)[0]||null;if(titleDiv){YAHOO.util.Event.purgeElement(titleDiv);this.oDomContainer.removeChild(titleDiv);}
-if(!close){YAHOO.util.Dom.removeClass(this.oDomContainer,"withtitle");}}};YAHOO.widget.Calendar.prototype.configClose=function(type,args,obj){var close=args[0];var title=this.cfg.getProperty("title");var linkClose;if(close===true){linkClose=YAHOO.util.Dom.getElementsByClassName("link-close","a",this.oDomContainer)[0]||document.createElement("a");linkClose.href="javascript:void(null);";linkClose.className="link-close";YAHOO.util.Event.addListener(linkClose,"click",this.hide,this,true);var imgClose=document.createElement("img");imgClose.src=YAHOO.widget.Calendar.IMG_ROOT+"us/my/bn/x_d.gif";imgClose.className=YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;linkClose.appendChild(imgClose);this.oDomContainer.appendChild(linkClose);YAHOO.util.Dom.addClass(this.oDomContainer,"withtitle");}else{linkClose=YAHOO.util.Dom.getElementsByClassName("link-close","a",this.oDomContainer)[0]||null;if(linkClose){YAHOO.util.Event.purgeElement(linkClose);this.oDomContainer.removeChild(linkClose);}
-if(!title||title===""){YAHOO.util.Dom.removeClass(this.oDomContainer,"withtitle");}}};YAHOO.widget.Calendar.prototype.initEvents=function(){this.beforeSelectEvent=new YAHOO.util.CustomEvent("beforeSelect");this.selectEvent=new YAHOO.util.CustomEvent("select");this.beforeDeselectEvent=new YAHOO.util.CustomEvent("beforeDeselect");this.deselectEvent=new YAHOO.util.CustomEvent("deselect");this.changePageEvent=new YAHOO.util.CustomEvent("changePage");this.beforeRenderEvent=new YAHOO.util.CustomEvent("beforeRender");this.renderEvent=new YAHOO.util.CustomEvent("render");this.resetEvent=new YAHOO.util.CustomEvent("reset");this.clearEvent=new YAHOO.util.CustomEvent("clear");this.beforeSelectEvent.subscribe(this.onBeforeSelect,this,true);this.selectEvent.subscribe(this.onSelect,this,true);this.beforeDeselectEvent.subscribe(this.onBeforeDeselect,this,true);this.deselectEvent.subscribe(this.onDeselect,this,true);this.changePageEvent.subscribe(this.onChangePage,this,true);this.renderEvent.subscribe(this.onRender,this,true);this.resetEvent.subscribe(this.onReset,this,true);this.clearEvent.subscribe(this.onClear,this,true);};YAHOO.widget.Calendar.prototype.doSelectCell=function(e,cal){var target=YAHOO.util.Event.getTarget(e);var cell,index,d,date;while(target.tagName.toLowerCase()!="td"&&!YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){target=target.parentNode;if(target.tagName.toLowerCase()=="html"){return;}}
-cell=target;if(YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_SELECTABLE)){index=cell.id.split("cell")[1];d=cal.cellDates[index];date=new Date(d[0],d[1]-1,d[2]);var link;if(cal.Options.MULTI_SELECT){link=cell.getElementsByTagName("a")[0];if(link){link.blur();}
-var cellDate=cal.cellDates[index];var cellDateIndex=cal._indexOfSelectedFieldArray(cellDate);if(cellDateIndex>-1){cal.deselectCell(index);}else{cal.selectCell(index);}}else{link=cell.getElementsByTagName("a")[0];if(link){link.blur();}
-cal.selectCell(index);}}};YAHOO.widget.Calendar.prototype.doCellMouseOver=function(e,cal){var target;if(e){target=YAHOO.util.Event.getTarget(e);}else{target=this;}
-while(target.tagName.toLowerCase()!="td"){target=target.parentNode;if(target.tagName.toLowerCase()=="html"){return;}}
-if(YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){YAHOO.util.Dom.addClass(target,cal.Style.CSS_CELL_HOVER);}};YAHOO.widget.Calendar.prototype.doCellMouseOut=function(e,cal){var target;if(e){target=YAHOO.util.Event.getTarget(e);}else{target=this;}
-while(target.tagName.toLowerCase()!="td"){target=target.parentNode;if(target.tagName.toLowerCase()=="html"){return;}}
-if(YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){YAHOO.util.Dom.removeClass(target,cal.Style.CSS_CELL_HOVER);}};YAHOO.widget.Calendar.prototype.setupConfig=function(){this.cfg.addProperty("pagedate",{value:new Date(),handler:this.configPageDate});this.cfg.addProperty("selected",{value:[],handler:this.configSelected});this.cfg.addProperty("title",{value:"",handler:this.configTitle});this.cfg.addProperty("close",{value:false,handler:this.configClose});this.cfg.addProperty("iframe",{value:true,handler:this.configIframe,validator:this.cfg.checkBoolean});this.cfg.addProperty("mindate",{value:null,handler:this.configMinDate});this.cfg.addProperty("maxdate",{value:null,handler:this.configMaxDate});this.cfg.addProperty("MULTI_SELECT",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("START_WEEKDAY",{value:0,handler:this.configOptions,validator:this.cfg.checkNumber});this.cfg.addProperty("SHOW_WEEKDAYS",{value:true,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_HEADER",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_FOOTER",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("HIDE_BLANK_WEEKS",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("NAV_ARROW_LEFT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/callt.gif",handler:this.configOptions});this.cfg.addProperty("NAV_ARROW_RIGHT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/calrt.gif",handler:this.configOptions});this.cfg.addProperty("MONTHS_SHORT",{value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],handler:this.configLocale});this.cfg.addProperty("MONTHS_LONG",{value:["January","February","March","April","May","June","July","August","September","October","November","December"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_1CHAR",{value:["S","M","T","W","T","F","S"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_SHORT",{value:["Su","Mo","Tu","We","Th","Fr","Sa"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_MEDIUM",{value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_LONG",{value:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],handler:this.configLocale});var refreshLocale=function(){this.cfg.refireEvent("LOCALE_MONTHS");this.cfg.refireEvent("LOCALE_WEEKDAYS");};this.cfg.subscribeToConfigEvent("START_WEEKDAY",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("MONTHS_SHORT",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("MONTHS_LONG",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG",refreshLocale,this,true);this.cfg.addProperty("LOCALE_MONTHS",{value:"long",handler:this.configLocaleValues});this.cfg.addProperty("LOCALE_WEEKDAYS",{value:"short",handler:this.configLocaleValues});this.cfg.addProperty("DATE_DELIMITER",{value:",",handler:this.configLocale});this.cfg.addProperty("DATE_FIELD_DELIMITER",{value:"/",handler:this.configLocale});this.cfg.addProperty("DATE_RANGE_DELIMITER",{value:"-",handler:this.configLocale});this.cfg.addProperty("MY_MONTH_POSITION",{value:1,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MY_YEAR_POSITION",{value:2,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_MONTH_POSITION",{value:1,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_DAY_POSITION",{value:2,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_MONTH_POSITION",{value:1,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_DAY_POSITION",{value:2,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_YEAR_POSITION",{value:3,handler:this.configLocale,validator:this.cfg.checkNumber});};YAHOO.widget.Calendar.prototype.configPageDate=function(type,args,obj){var val=args[0];var month,year,aMonthYear;if(val){if(val instanceof Date){val=YAHOO.widget.DateMath.findMonthStart(val);this.cfg.setProperty("pagedate",val,true);if(!this._pageDate){this._pageDate=this.cfg.getProperty("pagedate");}
-return;}else{aMonthYear=val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER"));month=parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1],10)-1;year=parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1],10);}}else{month=this.today.getMonth();year=this.today.getFullYear();}
-this.cfg.setProperty("pagedate",new Date(year,month,1),true);if(!this._pageDate){this._pageDate=this.cfg.getProperty("pagedate");}};YAHOO.widget.Calendar.prototype.configMinDate=function(type,args,obj){var val=args[0];if(typeof val=='string'){val=this._parseDate(val);this.cfg.setProperty("mindate",new Date(val[0],(val[1]-1),val[2]));}};YAHOO.widget.Calendar.prototype.configMaxDate=function(type,args,obj){var val=args[0];if(typeof val=='string'){val=this._parseDate(val);this.cfg.setProperty("maxdate",new Date(val[0],(val[1]-1),val[2]));}};YAHOO.widget.Calendar.prototype.configSelected=function(type,args,obj){var selected=args[0];if(selected){if(typeof selected=='string'){this.cfg.setProperty("selected",this._parseDates(selected),true);}}
-if(!this._selectedDates){this._selectedDates=this.cfg.getProperty("selected");}};YAHOO.widget.Calendar.prototype.configOptions=function(type,args,obj){type=type.toUpperCase();var val=args[0];this.Options[type]=val;};YAHOO.widget.Calendar.prototype.configLocale=function(type,args,obj){type=type.toUpperCase();var val=args[0];this.Locale[type]=val;this.cfg.refireEvent("LOCALE_MONTHS");this.cfg.refireEvent("LOCALE_WEEKDAYS");};YAHOO.widget.Calendar.prototype.configLocaleValues=function(type,args,obj){type=type.toUpperCase();var val=args[0];switch(type){case"LOCALE_MONTHS":switch(val){case"short":this.Locale.LOCALE_MONTHS=this.cfg.getProperty("MONTHS_SHORT").concat();break;case"long":this.Locale.LOCALE_MONTHS=this.cfg.getProperty("MONTHS_LONG").concat();break;}
-break;case"LOCALE_WEEKDAYS":switch(val){case"1char":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_1CHAR").concat();break;case"short":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_SHORT").concat();break;case"medium":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_MEDIUM").concat();break;case"long":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_LONG").concat();break;}
-var START_WEEKDAY=this.cfg.getProperty("START_WEEKDAY");if(START_WEEKDAY>0){for(var w=0;w";html[html.length]="";html[html.length]='';html[html.length]=' ';if(this.cfg.getProperty("SHOW_WEEKDAYS")){html=this.buildWeekdays(html);}
-html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.buildWeekdays=function(html){html[html.length]='';if(this.cfg.getProperty("SHOW_WEEK_HEADER")){html[html.length]=' ';}
-for(var i=0;i'+this.Locale.LOCALE_WEEKDAYS[i]+'';}
-if(this.cfg.getProperty("SHOW_WEEK_FOOTER")){html[html.length]=' ';}
-html[html.length]=' ';return html;};YAHOO.widget.Calendar.prototype.renderBody=function(workingDate,html){var startDay=this.cfg.getProperty("START_WEEKDAY");this.preMonthDays=workingDate.getDay();if(startDay>0){this.preMonthDays-=startDay;}
-if(this.preMonthDays<0){this.preMonthDays+=7;}
-this.monthDays=YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();this.postMonthDays=YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;workingDate=YAHOO.widget.DateMath.subtract(workingDate,YAHOO.widget.DateMath.DAY,this.preMonthDays);var useDate,weekNum,weekClass;useDate=this.cfg.getProperty("pagedate");html[html.length]='';var i=0;var tempDiv=document.createElement("div");var cell=document.createElement("td");tempDiv.appendChild(cell);var jan1=new Date(useDate.getFullYear(),0,1);var cal=this.parent||this;for(var r=0;r<6;r++){weekNum=YAHOO.widget.DateMath.getWeekNumber(workingDate,useDate.getFullYear(),startDay);weekClass="w"+weekNum;if(r!==0&&this.isDateOOM(workingDate)&&this.cfg.getProperty("HIDE_BLANK_WEEKS")===true){break;}else{html[html.length]='';if(this.cfg.getProperty("SHOW_WEEK_HEADER")){html=this.renderRowHeader(weekNum,html);}
-for(var d=0;d<7;d++){var cellRenderers=[];this.clearElement(cell);YAHOO.util.Dom.addClass(cell,"calcell");cell.id=this.id+"_cell"+i;cell.innerHTML=i;var renderer=null;if(workingDate.getFullYear()==this.today.getFullYear()&&workingDate.getMonth()==this.today.getMonth()&&workingDate.getDate()==this.today.getDate()){cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;}
-this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()];if(this.isDateOOM(workingDate)){cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;}else{YAHOO.util.Dom.addClass(cell,"wd"+workingDate.getDay());YAHOO.util.Dom.addClass(cell,"d"+workingDate.getDate());for(var s=0;s=d1.getTime()&&workingDate.getTime()<=d2.getTime()){renderer=rArray[2];if(workingDate.getTime()==d2.getTime()){this.renderStack.splice(s,1);}}
-break;case YAHOO.widget.Calendar.WEEKDAY:var weekday=rArray[1][0];if(workingDate.getDay()+1==weekday){renderer=rArray[2];}
-break;case YAHOO.widget.Calendar.MONTH:month=rArray[1][0];if(workingDate.getMonth()+1==month){renderer=rArray[2];}
-break;}
-if(renderer){cellRenderers[cellRenderers.length]=renderer;}}}
-if(this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()])>-1){cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected;}
-var mindate=this.cfg.getProperty("mindate");var maxdate=this.cfg.getProperty("maxdate");if(mindate){mindate=YAHOO.widget.DateMath.clearTime(mindate);}
-if(maxdate){maxdate=YAHOO.widget.DateMath.clearTime(maxdate);}
-if((mindate&&(workingDate.getTime()maxdate.getTime()))){cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate;}else{cellRenderers[cellRenderers.length]=cal.styleCellDefault;cellRenderers[cellRenderers.length]=cal.renderCellDefault;}
-for(var x=0;x=0&&i<=6){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_TOP);}
-if((i%7)===0){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_LEFT);}
-if(((i+1)%7)===0){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_RIGHT);}
-var postDays=this.postMonthDays;if(postDays>=7&&this.cfg.getProperty("HIDE_BLANK_WEEKS")){var blankWeeks=Math.floor(postDays/7);for(var p=0;p=((this.preMonthDays+postDays+this.monthDays)-7)){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_BOTTOM);}
-html[html.length]=tempDiv.innerHTML;i++;}
-if(this.cfg.getProperty("SHOW_WEEK_FOOTER")){html=this.renderRowFooter(weekNum,html);}
-html[html.length]=' ';}}
-html[html.length]=' ';return html;};YAHOO.widget.Calendar.prototype.renderFooter=function(html){return html;};YAHOO.widget.Calendar.prototype.render=function(){this.beforeRenderEvent.fire();var workingDate=YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty("pagedate"));this.resetRenderers();this.cellDates.length=0;YAHOO.util.Event.purgeElement(this.oDomContainer,true);var html=[];html[html.length]='';html=this.renderHeader(html);html=this.renderBody(workingDate,html);html=this.renderFooter(html);html[html.length]='
';this.oDomContainer.innerHTML=html.join("\n");this.applyListeners();this.cells=this.oDomContainer.getElementsByTagName("td");this.cfg.refireEvent("title");this.cfg.refireEvent("close");this.cfg.refireEvent("iframe");this.renderEvent.fire();};YAHOO.widget.Calendar.prototype.applyListeners=function(){var root=this.oDomContainer;var cal=this.parent||this;var linkLeft,linkRight;linkLeft=YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT,"a",root);linkRight=YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT,"a",root);if(linkLeft){this.linkLeft=linkLeft[0];YAHOO.util.Event.addListener(this.linkLeft,"mousedown",cal.previousMonth,cal,true);}
-if(linkRight){this.linkRight=linkRight[0];YAHOO.util.Event.addListener(this.linkRight,"mousedown",cal.nextMonth,cal,true);}
-if(this.domEventMap){var el,elements;for(var cls in this.domEventMap){if(this.domEventMap.hasOwnProperty(cls)){var items=this.domEventMap[cls];if(!(items instanceof Array)){items=[items];}
-for(var i=0;i'+weekNum+'';return html;};YAHOO.widget.Calendar.prototype.renderRowFooter=function(weekNum,html){html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.renderCellDefault=function(workingDate,cell){cell.innerHTML=''+this.buildDayLabel(workingDate)+" ";};YAHOO.widget.Calendar.prototype.styleCellDefault=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_SELECTABLE);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT1);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT2);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT3);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT4);};YAHOO.widget.Calendar.prototype.renderCellStyleToday=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_TODAY);};YAHOO.widget.Calendar.prototype.renderCellStyleSelected=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_SELECTED);};YAHOO.widget.Calendar.prototype.renderCellNotThisMonth=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_OOM);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar.STOP_RENDER;};YAHOO.widget.Calendar.prototype.renderBodyCellRestricted=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL);YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_RESTRICTED);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar.STOP_RENDER;};YAHOO.widget.Calendar.prototype.addMonths=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.MONTH,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.subtractMonths=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.MONTH,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.addYears=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.YEAR,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.subtractYears=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.YEAR,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.nextMonth=function(){this.addMonths(1);};YAHOO.widget.Calendar.prototype.previousMonth=function(){this.subtractMonths(1);};YAHOO.widget.Calendar.prototype.nextYear=function(){this.addYears(1);};YAHOO.widget.Calendar.prototype.previousYear=function(){this.subtractYears(1);};YAHOO.widget.Calendar.prototype.reset=function(){this.cfg.resetProperty("selected");this.cfg.resetProperty("pagedate");this.resetEvent.fire();};YAHOO.widget.Calendar.prototype.clear=function(){this.cfg.setProperty("selected",[]);this.cfg.setProperty("pagedate",new Date(this.today.getTime()));this.clearEvent.fire();};YAHOO.widget.Calendar.prototype.select=function(date){this.beforeSelectEvent.fire();var selected=this.cfg.getProperty("selected");var aToBeSelected=this._toFieldArray(date);for(var a=0;a-1){if(this.cfg.getProperty("pagedate").getMonth()==dCellDate.getMonth()&&this.cfg.getProperty("pagedate").getFullYear()==dCellDate.getFullYear()){YAHOO.util.Dom.removeClass(cell,this.Style.CSS_CELL_SELECTED);}
-selected.splice(cellDateIndex,1);}
-if(this.parent){this.parent.cfg.setProperty("selected",selected);}else{this.cfg.setProperty("selected",selected);}
-this.deselectEvent.fire(selectDate);return this.getSelectedDates();};YAHOO.widget.Calendar.prototype.deselectAll=function(){this.beforeDeselectEvent.fire();var selected=this.cfg.getProperty("selected");var count=selected.length;var sel=selected.concat();if(this.parent){this.parent.cfg.setProperty("selected",[]);}else{this.cfg.setProperty("selected",[]);}
-if(count>0){this.deselectEvent.fire(sel);}
-return this.getSelectedDates();};YAHOO.widget.Calendar.prototype._toFieldArray=function(date){var returnDate=[];if(date instanceof Date){returnDate=[[date.getFullYear(),date.getMonth()+1,date.getDate()]];}else if(typeof date=='string'){returnDate=this._parseDates(date);}else if(date instanceof Array){for(var i=0;i0){this.init(id,containerId,config);}};YAHOO.widget.CalendarGroup.prototype.init=function(id,containerId,config){this.initEvents();this.initStyles();this.pages=[];this.id=id;this.containerId=containerId;this.oDomContainer=document.getElementById(containerId);YAHOO.util.Dom.addClass(this.oDomContainer,YAHOO.widget.CalendarGroup.CSS_CONTAINER);YAHOO.util.Dom.addClass(this.oDomContainer,YAHOO.widget.CalendarGroup.CSS_MULTI_UP);this.cfg=new YAHOO.util.Config(this);this.Options={};this.Locale={};this.setupConfig();if(config){this.cfg.applyConfig(config,true);}
-this.cfg.fireQueue();if(this.browser=="opera"){var fixWidth=function(){var startW=this.oDomContainer.offsetWidth;var w=0;for(var p=0;p0){this.oDomContainer.style.width=w+"px";}};this.renderEvent.subscribe(fixWidth,this,true);}};YAHOO.widget.CalendarGroup.prototype.setupConfig=function(){this.cfg.addProperty("pages",{value:2,validator:this.cfg.checkNumber,handler:this.configPages});this.cfg.addProperty("pagedate",{value:new Date(),handler:this.configPageDate});this.cfg.addProperty("selected",{value:[],handler:this.delegateConfig});this.cfg.addProperty("title",{value:"",handler:this.configTitle});this.cfg.addProperty("close",{value:false,handler:this.configClose});this.cfg.addProperty("iframe",{value:true,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("mindate",{value:null,handler:this.delegateConfig});this.cfg.addProperty("maxdate",{value:null,handler:this.delegateConfig});this.cfg.addProperty("MULTI_SELECT",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("START_WEEKDAY",{value:0,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("SHOW_WEEKDAYS",{value:true,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_HEADER",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_FOOTER",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("HIDE_BLANK_WEEKS",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("NAV_ARROW_LEFT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/callt.gif",handler:this.delegateConfig});this.cfg.addProperty("NAV_ARROW_RIGHT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/calrt.gif",handler:this.delegateConfig});this.cfg.addProperty("MONTHS_SHORT",{value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],handler:this.delegateConfig});this.cfg.addProperty("MONTHS_LONG",{value:["January","February","March","April","May","June","July","August","September","October","November","December"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_1CHAR",{value:["S","M","T","W","T","F","S"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_SHORT",{value:["Su","Mo","Tu","We","Th","Fr","Sa"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_MEDIUM",{value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_LONG",{value:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],handler:this.delegateConfig});this.cfg.addProperty("LOCALE_MONTHS",{value:"long",handler:this.delegateConfig});this.cfg.addProperty("LOCALE_WEEKDAYS",{value:"short",handler:this.delegateConfig});this.cfg.addProperty("DATE_DELIMITER",{value:",",handler:this.delegateConfig});this.cfg.addProperty("DATE_FIELD_DELIMITER",{value:"/",handler:this.delegateConfig});this.cfg.addProperty("DATE_RANGE_DELIMITER",{value:"-",handler:this.delegateConfig});this.cfg.addProperty("MY_MONTH_POSITION",{value:1,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MY_YEAR_POSITION",{value:2,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_MONTH_POSITION",{value:1,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_DAY_POSITION",{value:2,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_MONTH_POSITION",{value:1,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_DAY_POSITION",{value:2,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_YEAR_POSITION",{value:3,handler:this.delegateConfig,validator:this.cfg.checkNumber});};YAHOO.widget.CalendarGroup.prototype.initEvents=function(){var me=this;var sub=function(fn,obj,bOverride){for(var p=0;p0){year+=1;}
-cal.setYear(year);}};YAHOO.widget.CalendarGroup.prototype.render=function(){this.renderHeader();for(var p=0;p=0;--p){var cal=this.pages[p];cal.previousMonth();}};YAHOO.widget.CalendarGroup.prototype.nextYear=function(){for(var p=0;p11){while(newMonth>11){newMonth-=12;years+=1;}}
+d.setMonth(newMonth);d.setFullYear(date.getFullYear()+years);break;case this.DAY:d.setDate(date.getDate()+amount);break;case this.YEAR:d.setFullYear(date.getFullYear()+amount);break;case this.WEEK:d.setDate(date.getDate()+(amount*7));break;}
+return d;},subtract:function(date,field,amount){return this.add(date,field,(amount*-1));},before:function(date,compareTo){var ms=compareTo.getTime();if(date.getTime()ms){return true;}else{return false;}},between:function(date,dateBegin,dateEnd){if(this.after(date,dateBegin)&&this.before(date,dateEnd)){return true;}else{return false;}},getJan1:function(calendarYear){return new Date(calendarYear,0,1);},getDayOffset:function(date,calendarYear){var beginYear=this.getJan1(calendarYear);var dayOffset=Math.ceil((date.getTime()-beginYear.getTime())/this.ONE_DAY_MS);return dayOffset;},getWeekNumber:function(date,calendarYear){date=this.clearTime(date);var nearestThurs=new Date(date.getTime()+(4*this.ONE_DAY_MS)-((date.getDay())*this.ONE_DAY_MS));var jan1=new Date(nearestThurs.getFullYear(),0,1);var dayOfYear=((nearestThurs.getTime()-jan1.getTime())/this.ONE_DAY_MS)-1;var weekNum=Math.ceil((dayOfYear)/7);return weekNum;},isYearOverlapWeek:function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getFullYear()!=weekBeginDate.getFullYear()){overlaps=true;}
+return overlaps;},isMonthOverlapWeek:function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getMonth()!=weekBeginDate.getMonth()){overlaps=true;}
+return overlaps;},findMonthStart:function(date){var start=new Date(date.getFullYear(),date.getMonth(),1);return start;},findMonthEnd:function(date){var start=this.findMonthStart(date);var nextMonth=this.add(start,this.MONTH,1);var end=this.subtract(nextMonth,this.DAY,1);return end;},clearTime:function(date){date.setHours(12,0,0,0);return date;}};YAHOO.widget.Calendar=function(id,containerId,config){this.init(id,containerId,config);};YAHOO.widget.Calendar.IMG_ROOT=(window.location.href.toLowerCase().indexOf("https")===0?"https://a248.e.akamai.net/sec.yimg.com/i/":"http://us.i1.yimg.com/us.yimg.com/i/");YAHOO.widget.Calendar.DATE="D";YAHOO.widget.Calendar.MONTH_DAY="MD";YAHOO.widget.Calendar.WEEKDAY="WD";YAHOO.widget.Calendar.RANGE="R";YAHOO.widget.Calendar.MONTH="M";YAHOO.widget.Calendar.DISPLAY_DAYS=42;YAHOO.widget.Calendar.STOP_RENDER="S";YAHOO.widget.Calendar.prototype={Config:null,parent:null,index:-1,cells:null,cellDates:null,id:null,oDomContainer:null,today:null,renderStack:null,_renderStack:null,_pageDate:null,_selectedDates:null,domEventMap:null};YAHOO.widget.Calendar.prototype.init=function(id,containerId,config){this.initEvents();this.today=new Date();YAHOO.widget.DateMath.clearTime(this.today);this.id=id;this.oDomContainer=document.getElementById(containerId);this.cfg=new YAHOO.util.Config(this);this.Options={};this.Locale={};this.initStyles();YAHOO.util.Dom.addClass(this.oDomContainer,this.Style.CSS_CONTAINER);YAHOO.util.Dom.addClass(this.oDomContainer,this.Style.CSS_SINGLE);this.cellDates=[];this.cells=[];this.renderStack=[];this._renderStack=[];this.setupConfig();if(config){this.cfg.applyConfig(config,true);}
+this.cfg.fireQueue();};YAHOO.widget.Calendar.prototype.configIframe=function(type,args,obj){var useIframe=args[0];if(YAHOO.util.Dom.inDocument(this.oDomContainer)){if(useIframe){var pos=YAHOO.util.Dom.getStyle(this.oDomContainer,"position");if(this.browser=="ie"&&(pos=="absolute"||pos=="relative")){if(!YAHOO.util.Dom.inDocument(this.iframe)){this.iframe=document.createElement("iframe");this.iframe.src="javascript:false;";YAHOO.util.Dom.setStyle(this.iframe,"opacity","0");this.oDomContainer.insertBefore(this.iframe,this.oDomContainer.firstChild);}}}else{if(this.iframe){if(this.iframe.parentNode){this.iframe.parentNode.removeChild(this.iframe);}
+this.iframe=null;}}}};YAHOO.widget.Calendar.prototype.configTitle=function(type,args,obj){var title=args[0];var close=this.cfg.getProperty("close");var titleDiv;if(title&&title!==""){titleDiv=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE,"div",this.oDomContainer)[0]||document.createElement("div");titleDiv.className=YAHOO.widget.CalendarGroup.CSS_2UPTITLE;titleDiv.innerHTML=title;this.oDomContainer.insertBefore(titleDiv,this.oDomContainer.firstChild);YAHOO.util.Dom.addClass(this.oDomContainer,"withtitle");}else{titleDiv=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE,"div",this.oDomContainer)[0]||null;if(titleDiv){YAHOO.util.Event.purgeElement(titleDiv);this.oDomContainer.removeChild(titleDiv);}
+if(!close){YAHOO.util.Dom.removeClass(this.oDomContainer,"withtitle");}}};YAHOO.widget.Calendar.prototype.configClose=function(type,args,obj){var close=args[0];var title=this.cfg.getProperty("title");var linkClose;if(close===true){linkClose=YAHOO.util.Dom.getElementsByClassName("link-close","a",this.oDomContainer)[0]||document.createElement("a");linkClose.href="javascript:void(null);";linkClose.className="link-close";YAHOO.util.Event.addListener(linkClose,"click",this.hide,this,true);var imgClose=document.createElement("img");imgClose.src=YAHOO.widget.Calendar.IMG_ROOT+"us/my/bn/x_d.gif";imgClose.className=YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;linkClose.appendChild(imgClose);this.oDomContainer.appendChild(linkClose);YAHOO.util.Dom.addClass(this.oDomContainer,"withtitle");}else{linkClose=YAHOO.util.Dom.getElementsByClassName("link-close","a",this.oDomContainer)[0]||null;if(linkClose){YAHOO.util.Event.purgeElement(linkClose);this.oDomContainer.removeChild(linkClose);}
+if(!title||title===""){YAHOO.util.Dom.removeClass(this.oDomContainer,"withtitle");}}};YAHOO.widget.Calendar.prototype.initEvents=function(){this.beforeSelectEvent=new YAHOO.util.CustomEvent("beforeSelect");this.selectEvent=new YAHOO.util.CustomEvent("select");this.beforeDeselectEvent=new YAHOO.util.CustomEvent("beforeDeselect");this.deselectEvent=new YAHOO.util.CustomEvent("deselect");this.changePageEvent=new YAHOO.util.CustomEvent("changePage");this.beforeRenderEvent=new YAHOO.util.CustomEvent("beforeRender");this.renderEvent=new YAHOO.util.CustomEvent("render");this.resetEvent=new YAHOO.util.CustomEvent("reset");this.clearEvent=new YAHOO.util.CustomEvent("clear");this.beforeSelectEvent.subscribe(this.onBeforeSelect,this,true);this.selectEvent.subscribe(this.onSelect,this,true);this.beforeDeselectEvent.subscribe(this.onBeforeDeselect,this,true);this.deselectEvent.subscribe(this.onDeselect,this,true);this.changePageEvent.subscribe(this.onChangePage,this,true);this.renderEvent.subscribe(this.onRender,this,true);this.resetEvent.subscribe(this.onReset,this,true);this.clearEvent.subscribe(this.onClear,this,true);};YAHOO.widget.Calendar.prototype.doSelectCell=function(e,cal){var target=YAHOO.util.Event.getTarget(e);var cell,index,d,date;while(target.tagName.toLowerCase()!="td"&&!YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){target=target.parentNode;if(target.tagName.toLowerCase()=="html"){return;}}
+cell=target;if(YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_SELECTABLE)){index=cell.id.split("cell")[1];d=cal.cellDates[index];date=new Date(d[0],d[1]-1,d[2]);var link;if(cal.Options.MULTI_SELECT){link=cell.getElementsByTagName("a")[0];if(link){link.blur();}
+var cellDate=cal.cellDates[index];var cellDateIndex=cal._indexOfSelectedFieldArray(cellDate);if(cellDateIndex>-1){cal.deselectCell(index);}else{cal.selectCell(index);}}else{link=cell.getElementsByTagName("a")[0];if(link){link.blur();}
+cal.selectCell(index);}}};YAHOO.widget.Calendar.prototype.doCellMouseOver=function(e,cal){var target;if(e){target=YAHOO.util.Event.getTarget(e);}else{target=this;}
+while(target.tagName.toLowerCase()!="td"){target=target.parentNode;if(target.tagName.toLowerCase()=="html"){return;}}
+if(YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){YAHOO.util.Dom.addClass(target,cal.Style.CSS_CELL_HOVER);}};YAHOO.widget.Calendar.prototype.doCellMouseOut=function(e,cal){var target;if(e){target=YAHOO.util.Event.getTarget(e);}else{target=this;}
+while(target.tagName.toLowerCase()!="td"){target=target.parentNode;if(target.tagName.toLowerCase()=="html"){return;}}
+if(YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){YAHOO.util.Dom.removeClass(target,cal.Style.CSS_CELL_HOVER);}};YAHOO.widget.Calendar.prototype.setupConfig=function(){this.cfg.addProperty("pagedate",{value:new Date(),handler:this.configPageDate});this.cfg.addProperty("selected",{value:[],handler:this.configSelected});this.cfg.addProperty("title",{value:"",handler:this.configTitle});this.cfg.addProperty("close",{value:false,handler:this.configClose});this.cfg.addProperty("iframe",{value:true,handler:this.configIframe,validator:this.cfg.checkBoolean});this.cfg.addProperty("mindate",{value:null,handler:this.configMinDate});this.cfg.addProperty("maxdate",{value:null,handler:this.configMaxDate});this.cfg.addProperty("MULTI_SELECT",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("START_WEEKDAY",{value:0,handler:this.configOptions,validator:this.cfg.checkNumber});this.cfg.addProperty("SHOW_WEEKDAYS",{value:true,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_HEADER",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_FOOTER",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("HIDE_BLANK_WEEKS",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("NAV_ARROW_LEFT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/callt.gif",handler:this.configOptions});this.cfg.addProperty("NAV_ARROW_RIGHT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/calrt.gif",handler:this.configOptions});this.cfg.addProperty("MONTHS_SHORT",{value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],handler:this.configLocale});this.cfg.addProperty("MONTHS_LONG",{value:["January","February","March","April","May","June","July","August","September","October","November","December"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_1CHAR",{value:["S","M","T","W","T","F","S"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_SHORT",{value:["Su","Mo","Tu","We","Th","Fr","Sa"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_MEDIUM",{value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_LONG",{value:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],handler:this.configLocale});var refreshLocale=function(){this.cfg.refireEvent("LOCALE_MONTHS");this.cfg.refireEvent("LOCALE_WEEKDAYS");};this.cfg.subscribeToConfigEvent("START_WEEKDAY",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("MONTHS_SHORT",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("MONTHS_LONG",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG",refreshLocale,this,true);this.cfg.addProperty("LOCALE_MONTHS",{value:"long",handler:this.configLocaleValues});this.cfg.addProperty("LOCALE_WEEKDAYS",{value:"short",handler:this.configLocaleValues});this.cfg.addProperty("DATE_DELIMITER",{value:",",handler:this.configLocale});this.cfg.addProperty("DATE_FIELD_DELIMITER",{value:"/",handler:this.configLocale});this.cfg.addProperty("DATE_RANGE_DELIMITER",{value:"-",handler:this.configLocale});this.cfg.addProperty("MY_MONTH_POSITION",{value:1,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MY_YEAR_POSITION",{value:2,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_MONTH_POSITION",{value:1,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_DAY_POSITION",{value:2,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_MONTH_POSITION",{value:1,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_DAY_POSITION",{value:2,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_YEAR_POSITION",{value:3,handler:this.configLocale,validator:this.cfg.checkNumber});};YAHOO.widget.Calendar.prototype.configPageDate=function(type,args,obj){var val=args[0];var month,year,aMonthYear;if(val){if(val instanceof Date){val=YAHOO.widget.DateMath.findMonthStart(val);this.cfg.setProperty("pagedate",val,true);if(!this._pageDate){this._pageDate=this.cfg.getProperty("pagedate");}
+return;}else{aMonthYear=val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER"));month=parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1],10)-1;year=parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1],10);}}else{month=this.today.getMonth();year=this.today.getFullYear();}
+this.cfg.setProperty("pagedate",new Date(year,month,1),true);if(!this._pageDate){this._pageDate=this.cfg.getProperty("pagedate");}};YAHOO.widget.Calendar.prototype.configMinDate=function(type,args,obj){var val=args[0];if(typeof val=='string'){val=this._parseDate(val);this.cfg.setProperty("mindate",new Date(val[0],(val[1]-1),val[2]));}};YAHOO.widget.Calendar.prototype.configMaxDate=function(type,args,obj){var val=args[0];if(typeof val=='string'){val=this._parseDate(val);this.cfg.setProperty("maxdate",new Date(val[0],(val[1]-1),val[2]));}};YAHOO.widget.Calendar.prototype.configSelected=function(type,args,obj){var selected=args[0];if(selected){if(typeof selected=='string'){this.cfg.setProperty("selected",this._parseDates(selected),true);}}
+if(!this._selectedDates){this._selectedDates=this.cfg.getProperty("selected");}};YAHOO.widget.Calendar.prototype.configOptions=function(type,args,obj){type=type.toUpperCase();var val=args[0];this.Options[type]=val;};YAHOO.widget.Calendar.prototype.configLocale=function(type,args,obj){type=type.toUpperCase();var val=args[0];this.Locale[type]=val;this.cfg.refireEvent("LOCALE_MONTHS");this.cfg.refireEvent("LOCALE_WEEKDAYS");};YAHOO.widget.Calendar.prototype.configLocaleValues=function(type,args,obj){type=type.toUpperCase();var val=args[0];switch(type){case"LOCALE_MONTHS":switch(val){case"short":this.Locale.LOCALE_MONTHS=this.cfg.getProperty("MONTHS_SHORT").concat();break;case"long":this.Locale.LOCALE_MONTHS=this.cfg.getProperty("MONTHS_LONG").concat();break;}
+break;case"LOCALE_WEEKDAYS":switch(val){case"1char":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_1CHAR").concat();break;case"short":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_SHORT").concat();break;case"medium":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_MEDIUM").concat();break;case"long":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_LONG").concat();break;}
+var START_WEEKDAY=this.cfg.getProperty("START_WEEKDAY");if(START_WEEKDAY>0){for(var w=0;w";html[html.length]="";html[html.length]='';html[html.length]=' ';if(this.cfg.getProperty("SHOW_WEEKDAYS")){html=this.buildWeekdays(html);}
+html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.buildWeekdays=function(html){html[html.length]='';if(this.cfg.getProperty("SHOW_WEEK_HEADER")){html[html.length]=' ';}
+for(var i=0;i'+this.Locale.LOCALE_WEEKDAYS[i]+'';}
+if(this.cfg.getProperty("SHOW_WEEK_FOOTER")){html[html.length]=' ';}
+html[html.length]=' ';return html;};YAHOO.widget.Calendar.prototype.renderBody=function(workingDate,html){var startDay=this.cfg.getProperty("START_WEEKDAY");this.preMonthDays=workingDate.getDay();if(startDay>0){this.preMonthDays-=startDay;}
+if(this.preMonthDays<0){this.preMonthDays+=7;}
+this.monthDays=YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();this.postMonthDays=YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;workingDate=YAHOO.widget.DateMath.subtract(workingDate,YAHOO.widget.DateMath.DAY,this.preMonthDays);var useDate,weekNum,weekClass;useDate=this.cfg.getProperty("pagedate");html[html.length]='';var i=0;var tempDiv=document.createElement("div");var cell=document.createElement("td");tempDiv.appendChild(cell);var jan1=new Date(useDate.getFullYear(),0,1);var cal=this.parent||this;for(var r=0;r<6;r++){weekNum=YAHOO.widget.DateMath.getWeekNumber(workingDate,useDate.getFullYear(),startDay);weekClass="w"+weekNum;if(r!==0&&this.isDateOOM(workingDate)&&this.cfg.getProperty("HIDE_BLANK_WEEKS")===true){break;}else{html[html.length]='';if(this.cfg.getProperty("SHOW_WEEK_HEADER")){html=this.renderRowHeader(weekNum,html);}
+for(var d=0;d<7;d++){var cellRenderers=[];this.clearElement(cell);YAHOO.util.Dom.addClass(cell,"calcell");cell.id=this.id+"_cell"+i;cell.innerHTML=i;var renderer=null;if(workingDate.getFullYear()==this.today.getFullYear()&&workingDate.getMonth()==this.today.getMonth()&&workingDate.getDate()==this.today.getDate()){cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;}
+this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()];if(this.isDateOOM(workingDate)){cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;}else{YAHOO.util.Dom.addClass(cell,"wd"+workingDate.getDay());YAHOO.util.Dom.addClass(cell,"d"+workingDate.getDate());for(var s=0;s=d1.getTime()&&workingDate.getTime()<=d2.getTime()){renderer=rArray[2];if(workingDate.getTime()==d2.getTime()){this.renderStack.splice(s,1);}}
+break;case YAHOO.widget.Calendar.WEEKDAY:var weekday=rArray[1][0];if(workingDate.getDay()+1==weekday){renderer=rArray[2];}
+break;case YAHOO.widget.Calendar.MONTH:month=rArray[1][0];if(workingDate.getMonth()+1==month){renderer=rArray[2];}
+break;}
+if(renderer){cellRenderers[cellRenderers.length]=renderer;}}}
+if(this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()])>-1){cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected;}
+var mindate=this.cfg.getProperty("mindate");var maxdate=this.cfg.getProperty("maxdate");if(mindate){mindate=YAHOO.widget.DateMath.clearTime(mindate);}
+if(maxdate){maxdate=YAHOO.widget.DateMath.clearTime(maxdate);}
+if((mindate&&(workingDate.getTime()maxdate.getTime()))){cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate;}else{cellRenderers[cellRenderers.length]=cal.styleCellDefault;cellRenderers[cellRenderers.length]=cal.renderCellDefault;}
+for(var x=0;x=0&&i<=6){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_TOP);}
+if((i%7)===0){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_LEFT);}
+if(((i+1)%7)===0){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_RIGHT);}
+var postDays=this.postMonthDays;if(postDays>=7&&this.cfg.getProperty("HIDE_BLANK_WEEKS")){var blankWeeks=Math.floor(postDays/7);for(var p=0;p=((this.preMonthDays+postDays+this.monthDays)-7)){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_BOTTOM);}
+html[html.length]=tempDiv.innerHTML;i++;}
+if(this.cfg.getProperty("SHOW_WEEK_FOOTER")){html=this.renderRowFooter(weekNum,html);}
+html[html.length]=' ';}}
+html[html.length]=' ';return html;};YAHOO.widget.Calendar.prototype.renderFooter=function(html){return html;};YAHOO.widget.Calendar.prototype.render=function(){this.beforeRenderEvent.fire();var workingDate=YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty("pagedate"));this.resetRenderers();this.cellDates.length=0;YAHOO.util.Event.purgeElement(this.oDomContainer,true);var html=[];html[html.length]='';html=this.renderHeader(html);html=this.renderBody(workingDate,html);html=this.renderFooter(html);html[html.length]='
';this.oDomContainer.innerHTML=html.join("\n");this.applyListeners();this.cells=this.oDomContainer.getElementsByTagName("td");this.cfg.refireEvent("title");this.cfg.refireEvent("close");this.cfg.refireEvent("iframe");this.renderEvent.fire();};YAHOO.widget.Calendar.prototype.applyListeners=function(){var root=this.oDomContainer;var cal=this.parent||this;var linkLeft,linkRight;linkLeft=YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT,"a",root);linkRight=YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT,"a",root);if(linkLeft){this.linkLeft=linkLeft[0];YAHOO.util.Event.addListener(this.linkLeft,"mousedown",cal.previousMonth,cal,true);}
+if(linkRight){this.linkRight=linkRight[0];YAHOO.util.Event.addListener(this.linkRight,"mousedown",cal.nextMonth,cal,true);}
+if(this.domEventMap){var el,elements;for(var cls in this.domEventMap){if(this.domEventMap.hasOwnProperty(cls)){var items=this.domEventMap[cls];if(!(items instanceof Array)){items=[items];}
+for(var i=0;i'+weekNum+'';return html;};YAHOO.widget.Calendar.prototype.renderRowFooter=function(weekNum,html){html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.renderCellDefault=function(workingDate,cell){cell.innerHTML=''+this.buildDayLabel(workingDate)+" ";};YAHOO.widget.Calendar.prototype.styleCellDefault=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_SELECTABLE);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT1);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT2);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT3);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT4);};YAHOO.widget.Calendar.prototype.renderCellStyleToday=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_TODAY);};YAHOO.widget.Calendar.prototype.renderCellStyleSelected=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_SELECTED);};YAHOO.widget.Calendar.prototype.renderCellNotThisMonth=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_OOM);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar.STOP_RENDER;};YAHOO.widget.Calendar.prototype.renderBodyCellRestricted=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL);YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_RESTRICTED);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar.STOP_RENDER;};YAHOO.widget.Calendar.prototype.addMonths=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.MONTH,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.subtractMonths=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.MONTH,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.addYears=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.YEAR,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.subtractYears=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.YEAR,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.nextMonth=function(){this.addMonths(1);};YAHOO.widget.Calendar.prototype.previousMonth=function(){this.subtractMonths(1);};YAHOO.widget.Calendar.prototype.nextYear=function(){this.addYears(1);};YAHOO.widget.Calendar.prototype.previousYear=function(){this.subtractYears(1);};YAHOO.widget.Calendar.prototype.reset=function(){this.cfg.resetProperty("selected");this.cfg.resetProperty("pagedate");this.resetEvent.fire();};YAHOO.widget.Calendar.prototype.clear=function(){this.cfg.setProperty("selected",[]);this.cfg.setProperty("pagedate",new Date(this.today.getTime()));this.clearEvent.fire();};YAHOO.widget.Calendar.prototype.select=function(date){this.beforeSelectEvent.fire();var selected=this.cfg.getProperty("selected");var aToBeSelected=this._toFieldArray(date);for(var a=0;a-1){if(this.cfg.getProperty("pagedate").getMonth()==dCellDate.getMonth()&&this.cfg.getProperty("pagedate").getFullYear()==dCellDate.getFullYear()){YAHOO.util.Dom.removeClass(cell,this.Style.CSS_CELL_SELECTED);}
+selected.splice(cellDateIndex,1);}
+if(this.parent){this.parent.cfg.setProperty("selected",selected);}else{this.cfg.setProperty("selected",selected);}
+this.deselectEvent.fire(selectDate);return this.getSelectedDates();};YAHOO.widget.Calendar.prototype.deselectAll=function(){this.beforeDeselectEvent.fire();var selected=this.cfg.getProperty("selected");var count=selected.length;var sel=selected.concat();if(this.parent){this.parent.cfg.setProperty("selected",[]);}else{this.cfg.setProperty("selected",[]);}
+if(count>0){this.deselectEvent.fire(sel);}
+return this.getSelectedDates();};YAHOO.widget.Calendar.prototype._toFieldArray=function(date){var returnDate=[];if(date instanceof Date){returnDate=[[date.getFullYear(),date.getMonth()+1,date.getDate()]];}else if(typeof date=='string'){returnDate=this._parseDates(date);}else if(date instanceof Array){for(var i=0;i0){this.init(id,containerId,config);}};YAHOO.widget.CalendarGroup.prototype.init=function(id,containerId,config){this.initEvents();this.initStyles();this.pages=[];this.id=id;this.containerId=containerId;this.oDomContainer=document.getElementById(containerId);YAHOO.util.Dom.addClass(this.oDomContainer,YAHOO.widget.CalendarGroup.CSS_CONTAINER);YAHOO.util.Dom.addClass(this.oDomContainer,YAHOO.widget.CalendarGroup.CSS_MULTI_UP);this.cfg=new YAHOO.util.Config(this);this.Options={};this.Locale={};this.setupConfig();if(config){this.cfg.applyConfig(config,true);}
+this.cfg.fireQueue();if(this.browser=="opera"){var fixWidth=function(){var startW=this.oDomContainer.offsetWidth;var w=0;for(var p=0;p0){this.oDomContainer.style.width=w+"px";}};this.renderEvent.subscribe(fixWidth,this,true);}};YAHOO.widget.CalendarGroup.prototype.setupConfig=function(){this.cfg.addProperty("pages",{value:2,validator:this.cfg.checkNumber,handler:this.configPages});this.cfg.addProperty("pagedate",{value:new Date(),handler:this.configPageDate});this.cfg.addProperty("selected",{value:[],handler:this.delegateConfig});this.cfg.addProperty("title",{value:"",handler:this.configTitle});this.cfg.addProperty("close",{value:false,handler:this.configClose});this.cfg.addProperty("iframe",{value:true,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("mindate",{value:null,handler:this.delegateConfig});this.cfg.addProperty("maxdate",{value:null,handler:this.delegateConfig});this.cfg.addProperty("MULTI_SELECT",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("START_WEEKDAY",{value:0,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("SHOW_WEEKDAYS",{value:true,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_HEADER",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_FOOTER",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("HIDE_BLANK_WEEKS",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("NAV_ARROW_LEFT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/callt.gif",handler:this.delegateConfig});this.cfg.addProperty("NAV_ARROW_RIGHT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/calrt.gif",handler:this.delegateConfig});this.cfg.addProperty("MONTHS_SHORT",{value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],handler:this.delegateConfig});this.cfg.addProperty("MONTHS_LONG",{value:["January","February","March","April","May","June","July","August","September","October","November","December"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_1CHAR",{value:["S","M","T","W","T","F","S"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_SHORT",{value:["Su","Mo","Tu","We","Th","Fr","Sa"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_MEDIUM",{value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_LONG",{value:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],handler:this.delegateConfig});this.cfg.addProperty("LOCALE_MONTHS",{value:"long",handler:this.delegateConfig});this.cfg.addProperty("LOCALE_WEEKDAYS",{value:"short",handler:this.delegateConfig});this.cfg.addProperty("DATE_DELIMITER",{value:",",handler:this.delegateConfig});this.cfg.addProperty("DATE_FIELD_DELIMITER",{value:"/",handler:this.delegateConfig});this.cfg.addProperty("DATE_RANGE_DELIMITER",{value:"-",handler:this.delegateConfig});this.cfg.addProperty("MY_MONTH_POSITION",{value:1,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MY_YEAR_POSITION",{value:2,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_MONTH_POSITION",{value:1,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_DAY_POSITION",{value:2,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_MONTH_POSITION",{value:1,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_DAY_POSITION",{value:2,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_YEAR_POSITION",{value:3,handler:this.delegateConfig,validator:this.cfg.checkNumber});};YAHOO.widget.CalendarGroup.prototype.initEvents=function(){var me=this;var sub=function(fn,obj,bOverride){for(var p=0;p0){year+=1;}
+cal.setYear(year);}};YAHOO.widget.CalendarGroup.prototype.render=function(){this.renderHeader();for(var p=0;p=0;--p){var cal=this.pages[p];cal.previousMonth();}};YAHOO.widget.CalendarGroup.prototype.nextYear=function(){for(var p=0;p 11) {
- while (newMonth > 11) {
- newMonth -= 12;
- years += 1;
- }
- }
-
- d.setMonth(newMonth);
- d.setFullYear(date.getFullYear() + years);
- break;
- case this.DAY:
- d.setDate(date.getDate() + amount);
- break;
- case this.YEAR:
- d.setFullYear(date.getFullYear() + amount);
- break;
- case this.WEEK:
- d.setDate(date.getDate() + (amount * 7));
- break;
- }
- return d;
- },
-
- /**
- * Subtracts the specified amount of time from the this instance.
- * @method subtract
- * @param {Date} date The JavaScript Date object to perform subtraction on
- * @param {Number} field The this field constant to be used for performing subtraction.
- * @param {Number} amount The number of units (measured in the field constant) to subtract from the date.
- * @return {Date} The resulting Date object
- */
- subtract : function(date, field, amount) {
- return this.add(date, field, (amount*-1));
- },
-
- /**
- * Determines whether a given date is before another date on the calendar.
- * @method before
- * @param {Date} date The Date object to compare with the compare argument
- * @param {Date} compareTo The Date object to use for the comparison
- * @return {Boolean} true if the date occurs before the compared date; false if not.
- */
- before : function(date, compareTo) {
- var ms = compareTo.getTime();
- if (date.getTime() < ms) {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Determines whether a given date is after another date on the calendar.
- * @method after
- * @param {Date} date The Date object to compare with the compare argument
- * @param {Date} compareTo The Date object to use for the comparison
- * @return {Boolean} true if the date occurs after the compared date; false if not.
- */
- after : function(date, compareTo) {
- var ms = compareTo.getTime();
- if (date.getTime() > ms) {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Determines whether a given date is between two other dates on the calendar.
- * @method between
- * @param {Date} date The date to check for
- * @param {Date} dateBegin The start of the range
- * @param {Date} dateEnd The end of the range
- * @return {Boolean} true if the date occurs between the compared dates; false if not.
- */
- between : function(date, dateBegin, dateEnd) {
- if (this.after(date, dateBegin) && this.before(date, dateEnd)) {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Retrieves a JavaScript Date object representing January 1 of any given year.
- * @method getJan1
- * @param {Number} calendarYear The calendar year for which to retrieve January 1
- * @return {Date} January 1 of the calendar year specified.
- */
- getJan1 : function(calendarYear) {
- return new Date(calendarYear,0,1);
- },
-
- /**
- * Calculates the number of days the specified date is from January 1 of the specified calendar year.
- * Passing January 1 to this function would return an offset value of zero.
- * @method getDayOffset
- * @param {Date} date The JavaScript date for which to find the offset
- * @param {Number} calendarYear The calendar year to use for determining the offset
- * @return {Number} The number of days since January 1 of the given year
- */
- getDayOffset : function(date, calendarYear) {
- var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1.
-
- // Find the number of days the passed in date is away from the calendar year start
- var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS);
- return dayOffset;
- },
-
- /**
- * Calculates the week number for the given date. This function assumes that week 1 is the
- * week in which January 1 appears, regardless of whether the week consists of a full 7 days.
- * The calendar year can be specified to help find what a the week number would be for a given
- * date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or
- * week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction
- * easily.
- * @method getWeekNumber
- * @param {Date} date The JavaScript date for which to find the week number
- * @param {Number} calendarYear OPTIONAL - The calendar year to use for determining the week number. Default is
- * the calendar year of parameter "date".
- * @param {Number} weekStartsOn OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday).
- * @return {Number} The week number of the given date.
- */
- getWeekNumber : function(date, calendarYear) {
- date = this.clearTime(date);
- var nearestThurs = new Date(date.getTime() + (4 * this.ONE_DAY_MS) - ((date.getDay()) * this.ONE_DAY_MS));
-
- var jan1 = new Date(nearestThurs.getFullYear(),0,1);
- var dayOfYear = ((nearestThurs.getTime() - jan1.getTime()) / this.ONE_DAY_MS) - 1;
-
- var weekNum = Math.ceil((dayOfYear)/ 7);
- return weekNum;
- },
-
- /**
- * Determines if a given week overlaps two different years.
- * @method isYearOverlapWeek
- * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
- * @return {Boolean} true if the date overlaps two different years.
- */
- isYearOverlapWeek : function(weekBeginDate) {
- var overlaps = false;
- var nextWeek = this.add(weekBeginDate, this.DAY, 6);
- if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) {
- overlaps = true;
- }
- return overlaps;
- },
-
- /**
- * Determines if a given week overlaps two different months.
- * @method isMonthOverlapWeek
- * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
- * @return {Boolean} true if the date overlaps two different months.
- */
- isMonthOverlapWeek : function(weekBeginDate) {
- var overlaps = false;
- var nextWeek = this.add(weekBeginDate, this.DAY, 6);
- if (nextWeek.getMonth() != weekBeginDate.getMonth()) {
- overlaps = true;
- }
- return overlaps;
- },
-
- /**
- * Gets the first day of a month containing a given date.
- * @method findMonthStart
- * @param {Date} date The JavaScript Date used to calculate the month start
- * @return {Date} The JavaScript Date representing the first day of the month
- */
- findMonthStart : function(date) {
- var start = new Date(date.getFullYear(), date.getMonth(), 1);
- return start;
- },
-
- /**
- * Gets the last day of a month containing a given date.
- * @method findMonthEnd
- * @param {Date} date The JavaScript Date used to calculate the month end
- * @return {Date} The JavaScript Date representing the last day of the month
- */
- findMonthEnd : function(date) {
- var start = this.findMonthStart(date);
- var nextMonth = this.add(start, this.MONTH, 1);
- var end = this.subtract(nextMonth, this.DAY, 1);
- return end;
- },
-
- /**
- * Clears the time fields from a given date, effectively setting the time to midnight.
- * @method clearTime
- * @param {Date} date The JavaScript Date for which the time fields will be cleared
- * @return {Date} The JavaScript Date cleared of all time fields
- */
- clearTime : function(date) {
- date.setHours(12,0,0,0);
- return date;
- }
-};
-
-/**
-* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month ("one-up") or two-month ("two-up") interface. Calendars are generated entirely via script and can be navigated without any page refreshes.
-* @module calendar
-* @title Calendar
-* @namespace YAHOO.widget
-* @requires yahoo,dom,event
-*/
-
-/**
-* Calendar is the base class for the Calendar widget. In its most basic
-* implementation, it has the ability to render a calendar widget on the page
-* that can be manipulated to select a single date, move back and forth between
-* months and years.
-* To construct the placeholder for the calendar widget, the code is as
-* follows:
-*
-*
-*
-* Note that the table can be replaced with any kind of element.
-*
-* @namespace YAHOO.widget
-* @class Calendar
-* @constructor
-* @param {String} id The id of the table element that will represent the calendar widget
-* @param {String} containerId The id of the container div element that will wrap the calendar table
-* @param {Object} config The configuration object containing the Calendar's arguments
-*/
-YAHOO.widget.Calendar = function(id, containerId, config) {
- this.init(id, containerId, config);
-};
-
-/**
-* The path to be used for images loaded for the Calendar
-* @property YAHOO.widget.Calendar.IMG_ROOT
-* @static
-* @type String
-*/
-YAHOO.widget.Calendar.IMG_ROOT = (window.location.href.toLowerCase().indexOf("https") === 0 ? "https://a248.e.akamai.net/sec.yimg.com/i/" : "http://us.i1.yimg.com/us.yimg.com/i/");
-
-/**
-* Type constant used for renderers to represent an individual date (M/D/Y)
-* @property YAHOO.widget.Calendar.DATE
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.DATE = "D";
-
-/**
-* Type constant used for renderers to represent an individual date across any year (M/D)
-* @property YAHOO.widget.Calendar.MONTH_DAY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.MONTH_DAY = "MD";
-
-/**
-* Type constant used for renderers to represent a weekday
-* @property YAHOO.widget.Calendar.WEEKDAY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.WEEKDAY = "WD";
-
-/**
-* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y)
-* @property YAHOO.widget.Calendar.RANGE
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.RANGE = "R";
-
-/**
-* Type constant used for renderers to represent a month across any year
-* @property YAHOO.widget.Calendar.MONTH
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.MONTH = "M";
-
-/**
-* Constant that represents the total number of date cells that are displayed in a given month
-* @property YAHOO.widget.Calendar.DISPLAY_DAYS
-* @static
-* @final
-* @type Number
-*/
-YAHOO.widget.Calendar.DISPLAY_DAYS = 42;
-
-/**
-* Constant used for halting the execution of the remainder of the render stack
-* @property YAHOO.widget.Calendar.STOP_RENDER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Calendar.STOP_RENDER = "S";
-
-YAHOO.widget.Calendar.prototype = {
-
- /**
- * The configuration object used to set up the calendars various locale and style options.
- * @property Config
- * @private
- * @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty.
- * @type Object
- */
- Config : null,
-
- /**
- * The parent CalendarGroup, only to be set explicitly by the parent group
- * @property parent
- * @type CalendarGroup
- */
- parent : null,
-
- /**
- * The index of this item in the parent group
- * @property index
- * @type Number
- */
- index : -1,
-
- /**
- * The collection of calendar table cells
- * @property cells
- * @type HTMLTableCellElement[]
- */
- cells : null,
-
- /**
- * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D].
- * @property cellDates
- * @type Array[](Number[])
- */
- cellDates : null,
-
- /**
- * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page.
- * @property id
- * @type String
- */
- id : null,
-
- /**
- * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered.
- * @property oDomContainer
- * @type HTMLElement
- */
- oDomContainer : null,
-
- /**
- * A Date object representing today's date.
- * @property today
- * @type Date
- */
- today : null,
-
- /**
- * The list of render functions, along with required parameters, used to render cells.
- * @property renderStack
- * @type Array[]
- */
- renderStack : null,
-
- /**
- * A copy of the initial render functions created before rendering.
- * @property _renderStack
- * @private
- * @type Array
- */
- _renderStack : null,
-
- /**
- * A Date object representing the month/year that the calendar is initially set to
- * @property _pageDate
- * @private
- * @type Date
- */
- _pageDate : null,
-
- /**
- * The private list of initially selected dates.
- * @property _selectedDates
- * @private
- * @type Array
- */
- _selectedDates : null,
-
- /**
- * A map of DOM event handlers to attach to cells associated with specific CSS class names
- * @property domEventMap
- * @type Object
- */
- domEventMap : null
-};
-
-
-
-/**
-* Initializes the Calendar widget.
-* @method init
-* @param {String} id The id of the table element that will represent the calendar widget
-* @param {String} containerId The id of the container div element that will wrap the calendar table
-* @param {Object} config The configuration object containing the Calendar's arguments
-*/
-YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) {
- this.initEvents();
- this.today = new Date();
- YAHOO.widget.DateMath.clearTime(this.today);
-
- this.id = id;
- this.oDomContainer = document.getElementById(containerId);
-
- /**
- * The Config object used to hold the configuration variables for the Calendar
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- /**
- * The local object which contains the Calendar's options
- * @property Options
- * @type Object
- */
- this.Options = {};
-
- /**
- * The local object which contains the Calendar's locale settings
- * @property Locale
- * @type Object
- */
- this.Locale = {};
-
- this.initStyles();
-
- YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER);
- YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE);
-
- this.cellDates = [];
- this.cells = [];
- this.renderStack = [];
- this._renderStack = [];
-
- this.setupConfig();
-
- if (config) {
- this.cfg.applyConfig(config, true);
- }
-
- this.cfg.fireQueue();
-};
-
-/**
-* Renders the built-in IFRAME shim for the IE6 and below
-* @method configIframe
-*/
-YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) {
- var useIframe = args[0];
-
- if (YAHOO.util.Dom.inDocument(this.oDomContainer)) {
- if (useIframe) {
- var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position");
-
- if (this.browser == "ie" && (pos == "absolute" || pos == "relative")) {
- if (! YAHOO.util.Dom.inDocument(this.iframe)) {
- this.iframe = document.createElement("iframe");
- this.iframe.src = "javascript:false;";
- YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
- this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild);
- }
- }
- } else {
- if (this.iframe) {
- if (this.iframe.parentNode) {
- this.iframe.parentNode.removeChild(this.iframe);
- }
- this.iframe = null;
- }
- }
- }
-};
-
-/**
-* Default handler for the "title" property
-* @method configTitle
-*/
-YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) {
- var title = args[0];
- var close = this.cfg.getProperty("close");
-
- var titleDiv;
-
- if (title && title !== "") {
- titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || document.createElement("div");
- titleDiv.className = YAHOO.widget.CalendarGroup.CSS_2UPTITLE;
- titleDiv.innerHTML = title;
- this.oDomContainer.insertBefore(titleDiv, this.oDomContainer.firstChild);
- YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
- } else {
- titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || null;
-
- if (titleDiv) {
- YAHOO.util.Event.purgeElement(titleDiv);
- this.oDomContainer.removeChild(titleDiv);
- }
- if (! close) {
- YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
- }
- }
-};
-
-/**
-* Default handler for the "close" property
-* @method configClose
-*/
-YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) {
- var close = args[0];
- var title = this.cfg.getProperty("title");
-
- var linkClose;
-
- if (close === true) {
- linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || document.createElement("a");
- linkClose.href = "javascript:void(null);";
- linkClose.className = "link-close";
- YAHOO.util.Event.addListener(linkClose, "click", this.hide, this, true);
- var imgClose = document.createElement("img");
- imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + "us/my/bn/x_d.gif";
- imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;
- linkClose.appendChild(imgClose);
- this.oDomContainer.appendChild(linkClose);
- YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
- } else {
- linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || null;
-
- if (linkClose) {
- YAHOO.util.Event.purgeElement(linkClose);
- this.oDomContainer.removeChild(linkClose);
- }
- if (! title || title === "") {
- YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
- }
- }
-};
-
-/**
-* Initializes Calendar's built-in CustomEvents
-* @method initEvents
-*/
-YAHOO.widget.Calendar.prototype.initEvents = function() {
-
- /**
- * Fired before a selection is made
- * @event beforeSelectEvent
- */
- this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect");
-
- /**
- * Fired when a selection is made
- * @event selectEvent
- * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
- */
- this.selectEvent = new YAHOO.util.CustomEvent("select");
-
- /**
- * Fired before a selection is made
- * @event beforeDeselectEvent
- */
- this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect");
-
- /**
- * Fired when a selection is made
- * @event deselectEvent
- * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
- */
- this.deselectEvent = new YAHOO.util.CustomEvent("deselect");
-
- /**
- * Fired when the Calendar page is changed
- * @event changePageEvent
- */
- this.changePageEvent = new YAHOO.util.CustomEvent("changePage");
-
- /**
- * Fired before the Calendar is rendered
- * @event beforeRenderEvent
- */
- this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
-
- /**
- * Fired when the Calendar is rendered
- * @event renderEvent
- */
- this.renderEvent = new YAHOO.util.CustomEvent("render");
-
- /**
- * Fired when the Calendar is reset
- * @event resetEvent
- */
- this.resetEvent = new YAHOO.util.CustomEvent("reset");
-
- /**
- * Fired when the Calendar is cleared
- * @event clearEvent
- */
- this.clearEvent = new YAHOO.util.CustomEvent("clear");
-
- this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true);
- this.selectEvent.subscribe(this.onSelect, this, true);
- this.beforeDeselectEvent.subscribe(this.onBeforeDeselect, this, true);
- this.deselectEvent.subscribe(this.onDeselect, this, true);
- this.changePageEvent.subscribe(this.onChangePage, this, true);
- this.renderEvent.subscribe(this.onRender, this, true);
- this.resetEvent.subscribe(this.onReset, this, true);
- this.clearEvent.subscribe(this.onClear, this, true);
-};
-
-
-/**
-* The default event function that is attached to a date link within a calendar cell
-* when the calendar is rendered.
-* @method doSelectCell
-* @param {DOMEvent} e The event
-* @param {Calendar} cal A reference to the calendar passed by the Event utility
-*/
-YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) {
- var target = YAHOO.util.Event.getTarget(e);
-
- var cell,index,d,date;
-
- while (target.tagName.toLowerCase() != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
- target = target.parentNode;
- if (target.tagName.toLowerCase() == "html") {
- return;
- }
- }
-
- cell = target;
-
- if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) {
- index = cell.id.split("cell")[1];
- d = cal.cellDates[index];
- date = new Date(d[0],d[1]-1,d[2]);
-
- var link;
-
- if (cal.Options.MULTI_SELECT) {
- link = cell.getElementsByTagName("a")[0];
- if (link) {
- link.blur();
- }
-
- var cellDate = cal.cellDates[index];
- var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate);
-
- if (cellDateIndex > -1) {
- cal.deselectCell(index);
- } else {
- cal.selectCell(index);
- }
-
- } else {
- link = cell.getElementsByTagName("a")[0];
- if (link) {
- link.blur();
- }
- cal.selectCell(index);
- }
- }
-};
-
-/**
-* The event that is executed when the user hovers over a cell
-* @method doCellMouseOver
-* @param {DOMEvent} e The event
-* @param {Calendar} cal A reference to the calendar passed by the Event utility
-*/
-YAHOO.widget.Calendar.prototype.doCellMouseOver = function(e, cal) {
- var target;
- if (e) {
- target = YAHOO.util.Event.getTarget(e);
- } else {
- target = this;
- }
-
- while (target.tagName.toLowerCase() != "td") {
- target = target.parentNode;
- if (target.tagName.toLowerCase() == "html") {
- return;
- }
- }
-
- if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
- YAHOO.util.Dom.addClass(target, cal.Style.CSS_CELL_HOVER);
- }
-};
-
-/**
-* The event that is executed when the user moves the mouse out of a cell
-* @method doCellMouseOut
-* @param {DOMEvent} e The event
-* @param {Calendar} cal A reference to the calendar passed by the Event utility
-*/
-YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) {
- var target;
- if (e) {
- target = YAHOO.util.Event.getTarget(e);
- } else {
- target = this;
- }
-
- while (target.tagName.toLowerCase() != "td") {
- target = target.parentNode;
- if (target.tagName.toLowerCase() == "html") {
- return;
- }
- }
-
- if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
- YAHOO.util.Dom.removeClass(target, cal.Style.CSS_CELL_HOVER);
- }
-};
-
-YAHOO.widget.Calendar.prototype.setupConfig = function() {
-
- /**
- * The month/year representing the current visible Calendar date (mm/yyyy)
- * @config pagedate
- * @type String
- * @default today's date
- */
- this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
-
- /**
- * The date or range of dates representing the current Calendar selection
- * @config selected
- * @type String
- * @default []
- */
- this.cfg.addProperty("selected", { value:[], handler:this.configSelected } );
-
- /**
- * The title to display above the Calendar's month header
- * @config title
- * @type String
- * @default ""
- */
- this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
-
- /**
- * Whether or not a close button should be displayed for this Calendar
- * @config close
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("close", { value:false, handler:this.configClose } );
-
- /**
- * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
- * @config iframe
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } );
-
- /**
- * The minimum selectable date in the current Calendar (mm/dd/yyyy)
- * @config mindate
- * @type String
- * @default null
- */
- this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } );
-
- /**
- * The maximum selectable date in the current Calendar (mm/dd/yyyy)
- * @config maxdate
- * @type String
- * @default null
- */
- this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } );
-
-
- // Options properties
-
- /**
- * True if the Calendar should allow multiple selections. False by default.
- * @config MULTI_SELECT
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * The weekday the week begins on. Default is 0 (Sunday).
- * @config START_WEEKDAY
- * @type number
- * @default 0
- */
- this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.configOptions, validator:this.cfg.checkNumber } );
-
- /**
- * True if the Calendar should show weekday labels. True by default.
- * @config SHOW_WEEKDAYS
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should show week row headers. False by default.
- * @config SHOW_WEEK_HEADER
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should show week row footers. False by default.
- * @config SHOW_WEEK_FOOTER
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should suppress weeks that are not a part of the current month. False by default.
- * @config HIDE_BLANK_WEEKS
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
- /**
- * The image that should be used for the left navigation arrow.
- * @config NAV_ARROW_LEFT
- * @type String
- * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
- */
- this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.configOptions } );
-
- /**
- * The image that should be used for the left navigation arrow.
- * @config NAV_ARROW_RIGHT
- * @type String
- * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
- */
- this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.configOptions } );
-
- // Locale properties
-
- /**
- * The short month labels for the current locale.
- * @config MONTHS_SHORT
- * @type String[]
- * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
- */
- this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.configLocale } );
-
- /**
- * The long month labels for the current locale.
- * @config MONTHS_LONG
- * @type String[]
- * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
- */
- this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.configLocale } );
-
- /**
- * The 1-character weekday labels for the current locale.
- * @config WEEKDAYS_1CHAR
- * @type String[]
- * @default ["S", "M", "T", "W", "T", "F", "S"]
- */
- this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.configLocale } );
-
- /**
- * The short weekday labels for the current locale.
- * @config WEEKDAYS_SHORT
- * @type String[]
- * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
- */
- this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.configLocale } );
-
- /**
- * The medium weekday labels for the current locale.
- * @config WEEKDAYS_MEDIUM
- * @type String[]
- * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
- */
- this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.configLocale } );
-
- /**
- * The long weekday labels for the current locale.
- * @config WEEKDAYS_LONG
- * @type String[]
- * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
- */
- this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.configLocale } );
-
- /**
- * Refreshes the locale values used to build the Calendar.
- * @method refreshLocale
- * @private
- */
- var refreshLocale = function() {
- this.cfg.refireEvent("LOCALE_MONTHS");
- this.cfg.refireEvent("LOCALE_WEEKDAYS");
- };
-
- this.cfg.subscribeToConfigEvent("START_WEEKDAY", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("MONTHS_SHORT", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("MONTHS_LONG", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM", refreshLocale, this, true);
- this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG", refreshLocale, this, true);
-
- /**
- * The setting that determines which length of month labels should be used. Possible values are "short" and "long".
- * @config LOCALE_MONTHS
- * @type String
- * @default "long"
- */
- this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } );
-
- /**
- * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
- * @config LOCALE_WEEKDAYS
- * @type String
- * @default "short"
- */
- this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } );
-
- /**
- * The value used to delimit individual dates in a date string passed to various Calendar functions.
- * @config DATE_DELIMITER
- * @type String
- * @default ","
- */
- this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } );
-
- /**
- * The value used to delimit date fields in a date string passed to various Calendar functions.
- * @config DATE_FIELD_DELIMITER
- * @type String
- * @default "/"
- */
- this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } );
-
- /**
- * The value used to delimit date ranges in a date string passed to various Calendar functions.
- * @config DATE_RANGE_DELIMITER
- * @type String
- * @default "-"
- */
- this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } );
-
- /**
- * The position of the month in a month/year date string
- * @config MY_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the year in a month/year date string
- * @config MY_YEAR_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the month in a month/day date string
- * @config MD_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the day in a month/year date string
- * @config MD_DAY_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the month in a month/day/year date string
- * @config MDY_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the day in a month/day/year date string
- * @config MDY_DAY_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the year in a month/day/year date string
- * @config MDY_YEAR_POSITION
- * @type Number
- * @default 3
- */
- this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } );
-};
-
-/**
-* The default handler for the "pagedate" property
-* @method configPageDate
-*/
-YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) {
- var val = args[0];
- var month, year, aMonthYear;
-
- if (val) {
- if (val instanceof Date) {
- val = YAHOO.widget.DateMath.findMonthStart(val);
- this.cfg.setProperty("pagedate", val, true);
- if (! this._pageDate) {
- this._pageDate = this.cfg.getProperty("pagedate");
- }
- return;
- } else {
- aMonthYear = val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER"));
- month = parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1], 10)-1;
- year = parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1], 10);
- }
- } else {
- month = this.today.getMonth();
- year = this.today.getFullYear();
- }
-
- this.cfg.setProperty("pagedate", new Date(year, month, 1), true);
- if (! this._pageDate) {
- this._pageDate = this.cfg.getProperty("pagedate");
- }
-};
-
-/**
-* The default handler for the "mindate" property
-* @method configMinDate
-*/
-YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) {
- var val = args[0];
- if (typeof val == 'string') {
- val = this._parseDate(val);
- this.cfg.setProperty("mindate", new Date(val[0],(val[1]-1),val[2]));
- }
-};
-
-/**
-* The default handler for the "maxdate" property
-* @method configMaxDate
-*/
-YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) {
- var val = args[0];
- if (typeof val == 'string') {
- val = this._parseDate(val);
- this.cfg.setProperty("maxdate", new Date(val[0],(val[1]-1),val[2]));
- }
-};
-
-/**
-* The default handler for the "selected" property
-* @method configSelected
-*/
-YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) {
- var selected = args[0];
-
- if (selected) {
- if (typeof selected == 'string') {
- this.cfg.setProperty("selected", this._parseDates(selected), true);
- }
- }
- if (! this._selectedDates) {
- this._selectedDates = this.cfg.getProperty("selected");
- }
-};
-
-/**
-* The default handler for all configuration options properties
-* @method configOptions
-*/
-YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) {
- type = type.toUpperCase();
- var val = args[0];
- this.Options[type] = val;
-};
-
-/**
-* The default handler for all configuration locale properties
-* @method configLocale
-*/
-YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) {
- type = type.toUpperCase();
- var val = args[0];
- this.Locale[type] = val;
-
- this.cfg.refireEvent("LOCALE_MONTHS");
- this.cfg.refireEvent("LOCALE_WEEKDAYS");
-
-};
-
-/**
-* The default handler for all configuration locale field length properties
-* @method configLocaleValues
-*/
-YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) {
- type = type.toUpperCase();
- var val = args[0];
-
- switch (type) {
- case "LOCALE_MONTHS":
- switch (val) {
- case "short":
- this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_SHORT").concat();
- break;
- case "long":
- this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_LONG").concat();
- break;
- }
- break;
- case "LOCALE_WEEKDAYS":
- switch (val) {
- case "1char":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_1CHAR").concat();
- break;
- case "short":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_SHORT").concat();
- break;
- case "medium":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_MEDIUM").concat();
- break;
- case "long":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_LONG").concat();
- break;
- }
-
- var START_WEEKDAY = this.cfg.getProperty("START_WEEKDAY");
-
- if (START_WEEKDAY > 0) {
- for (var w=0;w";
- html[html.length] = "";
- html[html.length] = '';
- html[html.length] = ' ';
-
- if (this.cfg.getProperty("SHOW_WEEKDAYS")) {
- html = this.buildWeekdays(html);
- }
-
- html[html.length] = '';
-
- return html;
-};
-
-/**
-* Renders the Calendar's weekday headers.
-* @method buildWeekdays
-* @param {Array} html The current working HTML array
-* @return {Array} The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) {
-
- html[html.length] = '';
-
- if (this.cfg.getProperty("SHOW_WEEK_HEADER")) {
- html[html.length] = ' ';
- }
-
- for(var i=0;i' + this.Locale.LOCALE_WEEKDAYS[i] + '';
- }
-
- if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) {
- html[html.length] = ' ';
- }
-
- html[html.length] = ' ';
-
- return html;
-};
-
-/**
-* Renders the calendar body.
-* @method renderBody
-* @param {Date} workingDate The current working Date being used for the render process
-* @param {Array} html The current working HTML array
-* @return {Array} The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) {
-
- var startDay = this.cfg.getProperty("START_WEEKDAY");
-
- this.preMonthDays = workingDate.getDay();
- if (startDay > 0) {
- this.preMonthDays -= startDay;
- }
- if (this.preMonthDays < 0) {
- this.preMonthDays += 7;
- }
-
- this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
- this.postMonthDays = YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
-
- workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
-
- var useDate,weekNum,weekClass;
- useDate = this.cfg.getProperty("pagedate");
-
- html[html.length] = '';
-
- var i = 0;
-
- var tempDiv = document.createElement("div");
- var cell = document.createElement("td");
- tempDiv.appendChild(cell);
-
- var jan1 = new Date(useDate.getFullYear(),0,1);
-
- var cal = this.parent || this;
-
- for (var r=0;r<6;r++) {
-
- weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useDate.getFullYear(), startDay);
-
- weekClass = "w" + weekNum;
-
- if (r !== 0 && this.isDateOOM(workingDate) && this.cfg.getProperty("HIDE_BLANK_WEEKS") === true) {
- break;
- } else {
-
- html[html.length] = '';
-
- if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { html = this.renderRowHeader(weekNum, html); }
-
- for (var d=0;d<7;d++){ // Render actual days
-
- var cellRenderers = [];
-
- this.clearElement(cell);
-
- YAHOO.util.Dom.addClass(cell, "calcell");
-
- cell.id = this.id + "_cell" + i;
-
- cell.innerHTML = i;
-
- var renderer = null;
-
- if (workingDate.getFullYear() == this.today.getFullYear() &&
- workingDate.getMonth() == this.today.getMonth() &&
- workingDate.getDate() == this.today.getDate()) {
- cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;
- }
-
- this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates
-
- if (this.isDateOOM(workingDate)) {
- cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;
- } else {
-
- YAHOO.util.Dom.addClass(cell, "wd" + workingDate.getDay());
- YAHOO.util.Dom.addClass(cell, "d" + workingDate.getDate());
-
- for (var s=0;s= d1.getTime() && workingDate.getTime() <= d2.getTime()) {
- renderer = rArray[2];
-
- if (workingDate.getTime()==d2.getTime()) {
- this.renderStack.splice(s,1);
- }
- }
- break;
- case YAHOO.widget.Calendar.WEEKDAY:
-
- var weekday = rArray[1][0];
- if (workingDate.getDay()+1 == weekday) {
- renderer = rArray[2];
- }
- break;
- case YAHOO.widget.Calendar.MONTH:
-
- month = rArray[1][0];
- if (workingDate.getMonth()+1 == month) {
- renderer = rArray[2];
- }
- break;
- }
-
- if (renderer) {
- cellRenderers[cellRenderers.length]=renderer;
- }
- }
-
- }
-
- if (this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]) > -1) {
- cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected;
- }
-
- var mindate = this.cfg.getProperty("mindate");
- var maxdate = this.cfg.getProperty("maxdate");
-
- if (mindate) {
- mindate = YAHOO.widget.DateMath.clearTime(mindate);
- }
- if (maxdate) {
- maxdate = YAHOO.widget.DateMath.clearTime(maxdate);
- }
-
- if (
- (mindate && (workingDate.getTime() < mindate.getTime())) ||
- (maxdate && (workingDate.getTime() > maxdate.getTime()))
- ) {
- cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate;
- } else {
- cellRenderers[cellRenderers.length]=cal.styleCellDefault;
- cellRenderers[cellRenderers.length]=cal.renderCellDefault;
- }
-
-
-
- for (var x=0;x= 0 && i <= 6) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TOP);
- }
- if ((i % 7) === 0) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_LEFT);
- }
- if (((i+1) % 7) === 0) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RIGHT);
- }
-
- var postDays = this.postMonthDays;
- if (postDays >= 7 && this.cfg.getProperty("HIDE_BLANK_WEEKS")) {
- var blankWeeks = Math.floor(postDays/7);
- for (var p=0;p= ((this.preMonthDays+postDays+this.monthDays)-7)) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM);
- }
-
- html[html.length] = tempDiv.innerHTML;
-
- i++;
- }
-
- if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { html = this.renderRowFooter(weekNum, html); }
-
- html[html.length] = ' ';
- }
- }
-
- html[html.length] = ' ';
-
- return html;
-};
-
-/**
-* Renders the calendar footer. In the default implementation, there is
-* no footer.
-* @method renderFooter
-* @param {Array} html The current working HTML array
-* @return {Array} The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.renderFooter = function(html) { return html; };
-
-/**
-* Renders the calendar after it has been configured. The render() method has a specific call chain that will execute
-* when the method is called: renderHeader, renderBody, renderFooter.
-* Refer to the documentation for those methods for information on
-* individual render tasks.
-* @method render
-*/
-YAHOO.widget.Calendar.prototype.render = function() {
- this.beforeRenderEvent.fire();
-
- // Find starting day of the current month
- var workingDate = YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty("pagedate"));
-
- this.resetRenderers();
- this.cellDates.length = 0;
-
- YAHOO.util.Event.purgeElement(this.oDomContainer, true);
-
- var html = [];
-
- html[html.length] = '';
- html = this.renderHeader(html);
- html = this.renderBody(workingDate, html);
- html = this.renderFooter(html);
- html[html.length] = '
';
-
- this.oDomContainer.innerHTML = html.join("\n");
-
- this.applyListeners();
- this.cells = this.oDomContainer.getElementsByTagName("td");
-
- this.cfg.refireEvent("title");
- this.cfg.refireEvent("close");
- this.cfg.refireEvent("iframe");
-
- this.renderEvent.fire();
-};
-
-/**
-* Applies the Calendar's DOM listeners to applicable elements.
-* @method applyListeners
-*/
-YAHOO.widget.Calendar.prototype.applyListeners = function() {
-
- var root = this.oDomContainer;
- var cal = this.parent || this;
-
- var linkLeft, linkRight;
-
- linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, "a", root);
- linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, "a", root);
-
- if (linkLeft) {
- this.linkLeft = linkLeft[0];
- YAHOO.util.Event.addListener(this.linkLeft, "mousedown", cal.previousMonth, cal, true);
- }
-
- if (linkRight) {
- this.linkRight = linkRight[0];
- YAHOO.util.Event.addListener(this.linkRight, "mousedown", cal.nextMonth, cal, true);
- }
-
- if (this.domEventMap) {
- var el,elements;
- for (var cls in this.domEventMap) {
- if (this.domEventMap.hasOwnProperty(cls)) {
- var items = this.domEventMap[cls];
-
- if (! (items instanceof Array)) {
- items = [items];
- }
-
- for (var i=0;i' + weekNum + '';
- return html;
-};
-
-/**
-* Renders the row footer for a week.
-* @method renderRowFooter
-* @param {Number} weekNum The week number of the current row
-* @param {Array} cell The current working HTML array
-*/
-YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) {
- html[html.length] = '';
- return html;
-};
-
-/**
-* Renders a single standard calendar cell in the calendar widget table.
-* All logic for determining how a standard default cell will be rendered is
-* encapsulated in this method, and must be accounted for when extending the
-* widget class.
-* @method renderCellDefault
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) {
- cell.innerHTML = '' + this.buildDayLabel(workingDate) + " ";
-};
-
-/**
-* Styles a selectable cell.
-* @method styleCellDefault
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.styleCellDefault = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE);
-};
-
-
-/**
-* Renders a single standard calendar cell using the CSS hightlight1 style
-* @method renderCellStyleHighlight1
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
-};
-
-/**
-* Renders a single standard calendar cell using the CSS hightlight2 style
-* @method renderCellStyleHighlight2
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
-};
-
-/**
-* Renders a single standard calendar cell using the CSS hightlight3 style
-* @method renderCellStyleHighlight3
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
-};
-
-/**
-* Renders a single standard calendar cell using the CSS hightlight4 style
-* @method renderCellStyleHighlight4
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4 = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
-};
-
-/**
-* Applies the default style used for rendering today's date to the current calendar cell
-* @method renderCellStyleToday
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleToday = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY);
-};
-
-/**
-* Applies the default style used for rendering selected dates to the current calendar cell
-* @method renderCellStyleSelected
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
-* should not be terminated
-*/
-YAHOO.widget.Calendar.prototype.renderCellStyleSelected = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED);
-};
-
-/**
-* Applies the default style used for rendering dates that are not a part of the current
-* month (preceding or trailing the cells for the current month)
-* @method renderCellNotThisMonth
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
-* should not be terminated
-*/
-YAHOO.widget.Calendar.prototype.renderCellNotThisMonth = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
- cell.innerHTML=workingDate.getDate();
- return YAHOO.widget.Calendar.STOP_RENDER;
-};
-
-/**
-* Renders the current calendar cell as a non-selectable "black-out" date using the default
-* restricted style.
-* @method renderBodyCellRestricted
-* @param {Date} workingDate The current working Date object being used to generate the calendar
-* @param {HTMLTableCellElement} cell The current working cell in the calendar
-* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
-* should not be terminated
-*/
-YAHOO.widget.Calendar.prototype.renderBodyCellRestricted = function(workingDate, cell) {
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL);
- YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RESTRICTED);
- cell.innerHTML=workingDate.getDate();
- return YAHOO.widget.Calendar.STOP_RENDER;
-};
-
-// END BUILT-IN TABLE CELL RENDERERS
-
-// BEGIN MONTH NAVIGATION METHODS
-
-/**
-* Adds the designated number of months to the current calendar month, and sets the current
-* calendar page date to the new month.
-* @method addMonths
-* @param {Number} count The number of months to add to the current calendar
-*/
-YAHOO.widget.Calendar.prototype.addMonths = function(count) {
- this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
-
-/**
-* Subtracts the designated number of months from the current calendar month, and sets the current
-* calendar page date to the new month.
-* @method subtractMonths
-* @param {Number} count The number of months to subtract from the current calendar
-*/
-YAHOO.widget.Calendar.prototype.subtractMonths = function(count) {
- this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
-
-/**
-* Adds the designated number of years to the current calendar, and sets the current
-* calendar page date to the new month.
-* @method addYears
-* @param {Number} count The number of years to add to the current calendar
-*/
-YAHOO.widget.Calendar.prototype.addYears = function(count) {
- this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
-
-/**
-* Subtcats the designated number of years from the current calendar, and sets the current
-* calendar page date to the new month.
-* @method subtractYears
-* @param {Number} count The number of years to subtract from the current calendar
-*/
-YAHOO.widget.Calendar.prototype.subtractYears = function(count) {
- this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
- this.resetRenderers();
- this.changePageEvent.fire();
-};
-
-/**
-* Navigates to the next month page in the calendar widget.
-* @method nextMonth
-*/
-YAHOO.widget.Calendar.prototype.nextMonth = function() {
- this.addMonths(1);
-};
-
-/**
-* Navigates to the previous month page in the calendar widget.
-* @method previousMonth
-*/
-YAHOO.widget.Calendar.prototype.previousMonth = function() {
- this.subtractMonths(1);
-};
-
-/**
-* Navigates to the next year in the currently selected month in the calendar widget.
-* @method nextYear
-*/
-YAHOO.widget.Calendar.prototype.nextYear = function() {
- this.addYears(1);
-};
-
-/**
-* Navigates to the previous year in the currently selected month in the calendar widget.
-* @method previousYear
-*/
-YAHOO.widget.Calendar.prototype.previousYear = function() {
- this.subtractYears(1);
-};
-
-// END MONTH NAVIGATION METHODS
-
-// BEGIN SELECTION METHODS
-
-/**
-* Resets the calendar widget to the originally selected month and year, and
-* sets the calendar to the initial selection(s).
-* @method reset
-*/
-YAHOO.widget.Calendar.prototype.reset = function() {
- this.cfg.resetProperty("selected");
- this.cfg.resetProperty("pagedate");
- this.resetEvent.fire();
-};
-
-/**
-* Clears the selected dates in the current calendar widget and sets the calendar
-* to the current month and year.
-* @method clear
-*/
-YAHOO.widget.Calendar.prototype.clear = function() {
- this.cfg.setProperty("selected", []);
- this.cfg.setProperty("pagedate", new Date(this.today.getTime()));
- this.clearEvent.fire();
-};
-
-/**
-* Selects a date or a collection of dates on the current calendar. This method, by default,
-* does not call the render method explicitly. Once selection has completed, render must be
-* called for the changes to be reflected visually.
-* @method select
-* @param {String/Date/Date[]} date The date string of dates to select in the current calendar. Valid formats are
-* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
-* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
-* This method can also take a JavaScript Date object or an array of Date objects.
-* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
-*/
-YAHOO.widget.Calendar.prototype.select = function(date) {
- this.beforeSelectEvent.fire();
-
- var selected = this.cfg.getProperty("selected");
- var aToBeSelected = this._toFieldArray(date);
-
- for (var a=0;a -1) {
- if (this.cfg.getProperty("pagedate").getMonth() == dCellDate.getMonth() &&
- this.cfg.getProperty("pagedate").getFullYear() == dCellDate.getFullYear()) {
- YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED);
- }
-
- selected.splice(cellDateIndex, 1);
- }
-
-
- if (this.parent) {
- this.parent.cfg.setProperty("selected", selected);
- } else {
- this.cfg.setProperty("selected", selected);
- }
-
- this.deselectEvent.fire(selectDate);
- return this.getSelectedDates();
-};
-
-/**
-* Deselects all dates on the current calendar.
-* @method deselectAll
-* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
-* Assuming that this function executes properly, the return value should be an empty array.
-* However, the empty array is returned for the sake of being able to check the selection status
-* of the calendar.
-*/
-YAHOO.widget.Calendar.prototype.deselectAll = function() {
- this.beforeDeselectEvent.fire();
-
- var selected = this.cfg.getProperty("selected");
- var count = selected.length;
- var sel = selected.concat();
-
- if (this.parent) {
- this.parent.cfg.setProperty("selected", []);
- } else {
- this.cfg.setProperty("selected", []);
- }
-
- if (count > 0) {
- this.deselectEvent.fire(sel);
- }
-
- return this.getSelectedDates();
-};
-
-// END SELECTION METHODS
-
-// BEGIN TYPE CONVERSION METHODS
-
-/**
-* Converts a date (either a JavaScript Date object, or a date string) to the internal data structure
-* used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]].
-* @method _toFieldArray
-* @private
-* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
-* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
-* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
-* This method can also take a JavaScript Date object or an array of Date objects.
-* @return {Array[](Number[])} Array of date field arrays
-*/
-YAHOO.widget.Calendar.prototype._toFieldArray = function(date) {
- var returnDate = [];
-
- if (date instanceof Date) {
- returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]];
- } else if (typeof date == 'string') {
- returnDate = this._parseDates(date);
- } else if (date instanceof Array) {
- for (var i=0;i
-*
-*
-*
-* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
-* @namespace YAHOO.widget
-* @class CalendarGroup
-* @constructor
-* @param {String} id The id of the table element that will represent the calendar widget
-* @param {String} containerId The id of the container div element that will wrap the calendar table
-* @param {Object} config The configuration object containing the Calendar's arguments
-*/
-YAHOO.widget.CalendarGroup = function(id, containerId, config) {
- if (arguments.length > 0) {
- this.init(id, containerId, config);
- }
-};
-
-/**
-* Initializes the calendar group. All subclasses must call this method in order for the
-* group to be initialized properly.
-* @method init
-* @param {String} id The id of the table element that will represent the calendar widget
-* @param {String} containerId The id of the container div element that will wrap the calendar table
-* @param {Object} config The configuration object containing the Calendar's arguments
-*/
-YAHOO.widget.CalendarGroup.prototype.init = function(id, containerId, config) {
- this.initEvents();
- this.initStyles();
-
- /**
- * The collection of Calendar pages contained within the CalendarGroup
- * @property pages
- * @type YAHOO.widget.Calendar[]
- */
- this.pages = [];
-
- /**
- * The unique id associated with the CalendarGroup
- * @property id
- * @type String
- */
- this.id = id;
-
- /**
- * The unique id associated with the CalendarGroup container
- * @property containerId
- * @type String
- */
- this.containerId = containerId;
-
- /**
- * The outer containing element for the CalendarGroup
- * @property oDomContainer
- * @type HTMLElement
- */
- this.oDomContainer = document.getElementById(containerId);
-
- YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_CONTAINER);
- YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_MULTI_UP);
-
- /**
- * The Config object used to hold the configuration variables for the CalendarGroup
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- /**
- * The local object which contains the CalendarGroup's options
- * @property Options
- * @type Object
- */
- this.Options = {};
-
- /**
- * The local object which contains the CalendarGroup's locale settings
- * @property Locale
- * @type Object
- */
- this.Locale = {};
-
- this.setupConfig();
-
- if (config) {
- this.cfg.applyConfig(config, true);
- }
-
- this.cfg.fireQueue();
-
- // OPERA HACK FOR MISWRAPPED FLOATS
- if (this.browser == "opera"){
- var fixWidth = function() {
- var startW = this.oDomContainer.offsetWidth;
- var w = 0;
- for (var p=0;p 0) {
- this.oDomContainer.style.width = w + "px";
- }
- };
- this.renderEvent.subscribe(fixWidth,this,true);
- }
-};
-
-
-YAHOO.widget.CalendarGroup.prototype.setupConfig = function() {
- /**
- * The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments.
- * @config pages
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("pages", { value:2, validator:this.cfg.checkNumber, handler:this.configPages } );
-
- /**
- * The month/year representing the current visible Calendar date (mm/yyyy)
- * @config pagedate
- * @type String
- * @default today's date
- */
- this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
-
- /**
- * The date or range of dates representing the current Calendar selection
- * @config selected
- * @type String
- * @default []
- */
- this.cfg.addProperty("selected", { value:[], handler:this.delegateConfig } );
-
- /**
- * The title to display above the CalendarGroup's month header
- * @config title
- * @type String
- * @default ""
- */
- this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
-
- /**
- * Whether or not a close button should be displayed for this CalendarGroup
- * @config close
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("close", { value:false, handler:this.configClose } );
-
- /**
- * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
- * @config iframe
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("iframe", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * The minimum selectable date in the current Calendar (mm/dd/yyyy)
- * @config mindate
- * @type String
- * @default null
- */
- this.cfg.addProperty("mindate", { value:null, handler:this.delegateConfig } );
-
- /**
- * The maximum selectable date in the current Calendar (mm/dd/yyyy)
- * @config maxdate
- * @type String
- * @default null
- */
- this.cfg.addProperty("maxdate", { value:null, handler:this.delegateConfig } );
-
- // Options properties
-
- /**
- * True if the Calendar should allow multiple selections. False by default.
- * @config MULTI_SELECT
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * The weekday the week begins on. Default is 0 (Sunday).
- * @config START_WEEKDAY
- * @type number
- * @default 0
- */
- this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * True if the Calendar should show weekday labels. True by default.
- * @config SHOW_WEEKDAYS
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should show week row headers. False by default.
- * @config SHOW_WEEK_HEADER
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should show week row footers. False by default.
- * @config SHOW_WEEK_FOOTER
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * True if the Calendar should suppress weeks that are not a part of the current month. False by default.
- * @config HIDE_BLANK_WEEKS
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
-
- /**
- * The image that should be used for the left navigation arrow.
- * @config NAV_ARROW_LEFT
- * @type String
- * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
- */
- this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.delegateConfig } );
-
- /**
- * The image that should be used for the left navigation arrow.
- * @config NAV_ARROW_RIGHT
- * @type String
- * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
- */
- this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.delegateConfig } );
-
- // Locale properties
-
- /**
- * The short month labels for the current locale.
- * @config MONTHS_SHORT
- * @type String[]
- * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
- */
- this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.delegateConfig } );
-
- /**
- * The long month labels for the current locale.
- * @config MONTHS_LONG
- * @type String[]
- * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
- */
- this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.delegateConfig } );
-
- /**
- * The 1-character weekday labels for the current locale.
- * @config WEEKDAYS_1CHAR
- * @type String[]
- * @default ["S", "M", "T", "W", "T", "F", "S"]
- */
- this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.delegateConfig } );
-
- /**
- * The short weekday labels for the current locale.
- * @config WEEKDAYS_SHORT
- * @type String[]
- * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
- */
- this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.delegateConfig } );
-
- /**
- * The medium weekday labels for the current locale.
- * @config WEEKDAYS_MEDIUM
- * @type String[]
- * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
- */
- this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.delegateConfig } );
-
- /**
- * The long weekday labels for the current locale.
- * @config WEEKDAYS_LONG
- * @type String[]
- * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
- */
- this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.delegateConfig } );
-
- /**
- * The setting that determines which length of month labels should be used. Possible values are "short" and "long".
- * @config LOCALE_MONTHS
- * @type String
- * @default "long"
- */
- this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.delegateConfig } );
-
- /**
- * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
- * @config LOCALE_WEEKDAYS
- * @type String
- * @default "short"
- */
- this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.delegateConfig } );
-
- /**
- * The value used to delimit individual dates in a date string passed to various Calendar functions.
- * @config DATE_DELIMITER
- * @type String
- * @default ","
- */
- this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.delegateConfig } );
-
- /**
- * The value used to delimit date fields in a date string passed to various Calendar functions.
- * @config DATE_FIELD_DELIMITER
- * @type String
- * @default "/"
- */
- this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.delegateConfig } );
-
- /**
- * The value used to delimit date ranges in a date string passed to various Calendar functions.
- * @config DATE_RANGE_DELIMITER
- * @type String
- * @default "-"
- */
- this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.delegateConfig } );
-
- /**
- * The position of the month in a month/year date string
- * @config MY_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the year in a month/year date string
- * @config MY_YEAR_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the month in a month/day date string
- * @config MD_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the day in a month/year date string
- * @config MD_DAY_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the month in a month/day/year date string
- * @config MDY_MONTH_POSITION
- * @type Number
- * @default 1
- */
- this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the day in a month/day/year date string
- * @config MDY_DAY_POSITION
- * @type Number
- * @default 2
- */
- this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
- /**
- * The position of the year in a month/day/year date string
- * @config MDY_YEAR_POSITION
- * @type Number
- * @default 3
- */
- this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
-
-};
-
-/**
-* Initializes CalendarGroup's built-in CustomEvents
-* @method initEvents
-*/
-YAHOO.widget.CalendarGroup.prototype.initEvents = function() {
- var me = this;
-
- /**
- * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents
- * @method sub
- * @private
- * @param {Function} fn The function to subscribe to this CustomEvent
- * @param {Object} obj The CustomEvent's scope object
- * @param {Boolean} bOverride Whether or not to apply scope correction
- */
- var sub = function(fn, obj, bOverride) {
- for (var p=0;p0) {
- year+=1;
- }
- cal.setYear(year);
- }
-};
-/**
-* Calls the render function of all child calendars within the group.
-* @method render
-*/
-YAHOO.widget.CalendarGroup.prototype.render = function() {
- this.renderHeader();
- for (var p=0;p=0;--p) {
- var cal = this.pages[p];
- cal.previousMonth();
- }
-};
-
-/**
-* Navigates to the next year in the currently selected month in the calendar widget.
-* @method nextYear
-*/
-YAHOO.widget.CalendarGroup.prototype.nextYear = function() {
- for (var p=0;p 11) {
+ while (newMonth > 11) {
+ newMonth -= 12;
+ years += 1;
+ }
+ }
+
+ d.setMonth(newMonth);
+ d.setFullYear(date.getFullYear() + years);
+ break;
+ case this.DAY:
+ d.setDate(date.getDate() + amount);
+ break;
+ case this.YEAR:
+ d.setFullYear(date.getFullYear() + amount);
+ break;
+ case this.WEEK:
+ d.setDate(date.getDate() + (amount * 7));
+ break;
+ }
+ return d;
+ },
+
+ /**
+ * Subtracts the specified amount of time from the this instance.
+ * @method subtract
+ * @param {Date} date The JavaScript Date object to perform subtraction on
+ * @param {Number} field The this field constant to be used for performing subtraction.
+ * @param {Number} amount The number of units (measured in the field constant) to subtract from the date.
+ * @return {Date} The resulting Date object
+ */
+ subtract : function(date, field, amount) {
+ return this.add(date, field, (amount*-1));
+ },
+
+ /**
+ * Determines whether a given date is before another date on the calendar.
+ * @method before
+ * @param {Date} date The Date object to compare with the compare argument
+ * @param {Date} compareTo The Date object to use for the comparison
+ * @return {Boolean} true if the date occurs before the compared date; false if not.
+ */
+ before : function(date, compareTo) {
+ var ms = compareTo.getTime();
+ if (date.getTime() < ms) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Determines whether a given date is after another date on the calendar.
+ * @method after
+ * @param {Date} date The Date object to compare with the compare argument
+ * @param {Date} compareTo The Date object to use for the comparison
+ * @return {Boolean} true if the date occurs after the compared date; false if not.
+ */
+ after : function(date, compareTo) {
+ var ms = compareTo.getTime();
+ if (date.getTime() > ms) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Determines whether a given date is between two other dates on the calendar.
+ * @method between
+ * @param {Date} date The date to check for
+ * @param {Date} dateBegin The start of the range
+ * @param {Date} dateEnd The end of the range
+ * @return {Boolean} true if the date occurs between the compared dates; false if not.
+ */
+ between : function(date, dateBegin, dateEnd) {
+ if (this.after(date, dateBegin) && this.before(date, dateEnd)) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Retrieves a JavaScript Date object representing January 1 of any given year.
+ * @method getJan1
+ * @param {Number} calendarYear The calendar year for which to retrieve January 1
+ * @return {Date} January 1 of the calendar year specified.
+ */
+ getJan1 : function(calendarYear) {
+ return new Date(calendarYear,0,1);
+ },
+
+ /**
+ * Calculates the number of days the specified date is from January 1 of the specified calendar year.
+ * Passing January 1 to this function would return an offset value of zero.
+ * @method getDayOffset
+ * @param {Date} date The JavaScript date for which to find the offset
+ * @param {Number} calendarYear The calendar year to use for determining the offset
+ * @return {Number} The number of days since January 1 of the given year
+ */
+ getDayOffset : function(date, calendarYear) {
+ var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1.
+
+ // Find the number of days the passed in date is away from the calendar year start
+ var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS);
+ return dayOffset;
+ },
+
+ /**
+ * Calculates the week number for the given date. This function assumes that week 1 is the
+ * week in which January 1 appears, regardless of whether the week consists of a full 7 days.
+ * The calendar year can be specified to help find what a the week number would be for a given
+ * date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or
+ * week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction
+ * easily.
+ * @method getWeekNumber
+ * @param {Date} date The JavaScript date for which to find the week number
+ * @param {Number} calendarYear OPTIONAL - The calendar year to use for determining the week number. Default is
+ * the calendar year of parameter "date".
+ * @param {Number} weekStartsOn OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday).
+ * @return {Number} The week number of the given date.
+ */
+ getWeekNumber : function(date, calendarYear) {
+ date = this.clearTime(date);
+ var nearestThurs = new Date(date.getTime() + (4 * this.ONE_DAY_MS) - ((date.getDay()) * this.ONE_DAY_MS));
+
+ var jan1 = new Date(nearestThurs.getFullYear(),0,1);
+ var dayOfYear = ((nearestThurs.getTime() - jan1.getTime()) / this.ONE_DAY_MS) - 1;
+
+ var weekNum = Math.ceil((dayOfYear)/ 7);
+ return weekNum;
+ },
+
+ /**
+ * Determines if a given week overlaps two different years.
+ * @method isYearOverlapWeek
+ * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
+ * @return {Boolean} true if the date overlaps two different years.
+ */
+ isYearOverlapWeek : function(weekBeginDate) {
+ var overlaps = false;
+ var nextWeek = this.add(weekBeginDate, this.DAY, 6);
+ if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) {
+ overlaps = true;
+ }
+ return overlaps;
+ },
+
+ /**
+ * Determines if a given week overlaps two different months.
+ * @method isMonthOverlapWeek
+ * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
+ * @return {Boolean} true if the date overlaps two different months.
+ */
+ isMonthOverlapWeek : function(weekBeginDate) {
+ var overlaps = false;
+ var nextWeek = this.add(weekBeginDate, this.DAY, 6);
+ if (nextWeek.getMonth() != weekBeginDate.getMonth()) {
+ overlaps = true;
+ }
+ return overlaps;
+ },
+
+ /**
+ * Gets the first day of a month containing a given date.
+ * @method findMonthStart
+ * @param {Date} date The JavaScript Date used to calculate the month start
+ * @return {Date} The JavaScript Date representing the first day of the month
+ */
+ findMonthStart : function(date) {
+ var start = new Date(date.getFullYear(), date.getMonth(), 1);
+ return start;
+ },
+
+ /**
+ * Gets the last day of a month containing a given date.
+ * @method findMonthEnd
+ * @param {Date} date The JavaScript Date used to calculate the month end
+ * @return {Date} The JavaScript Date representing the last day of the month
+ */
+ findMonthEnd : function(date) {
+ var start = this.findMonthStart(date);
+ var nextMonth = this.add(start, this.MONTH, 1);
+ var end = this.subtract(nextMonth, this.DAY, 1);
+ return end;
+ },
+
+ /**
+ * Clears the time fields from a given date, effectively setting the time to 12 noon.
+ * @method clearTime
+ * @param {Date} date The JavaScript Date for which the time fields will be cleared
+ * @return {Date} The JavaScript Date cleared of all time fields
+ */
+ clearTime : function(date) {
+ date.setHours(12,0,0,0);
+ return date;
+ }
+};
+
+/**
+* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month ("one-up") or two-month ("two-up") interface. Calendars are generated entirely via script and can be navigated without any page refreshes.
+* @module calendar
+* @title Calendar
+* @namespace YAHOO.widget
+* @requires yahoo,dom,event
+*/
+
+/**
+* Calendar is the base class for the Calendar widget. In its most basic
+* implementation, it has the ability to render a calendar widget on the page
+* that can be manipulated to select a single date, move back and forth between
+* months and years.
+* To construct the placeholder for the calendar widget, the code is as
+* follows:
+*
+*
+*
+* Note that the table can be replaced with any kind of element.
+*
+* @namespace YAHOO.widget
+* @class Calendar
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container div element that will wrap the calendar table
+* @param {Object} config The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.Calendar = function(id, containerId, config) {
+ this.init(id, containerId, config);
+};
+
+/**
+* The path to be used for images loaded for the Calendar
+* @property YAHOO.widget.Calendar.IMG_ROOT
+* @static
+* @type String
+*/
+YAHOO.widget.Calendar.IMG_ROOT = (window.location.href.toLowerCase().indexOf("https") === 0 ? "https://a248.e.akamai.net/sec.yimg.com/i/" : "http://us.i1.yimg.com/us.yimg.com/i/");
+
+/**
+* Type constant used for renderers to represent an individual date (M/D/Y)
+* @property YAHOO.widget.Calendar.DATE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.DATE = "D";
+
+/**
+* Type constant used for renderers to represent an individual date across any year (M/D)
+* @property YAHOO.widget.Calendar.MONTH_DAY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.MONTH_DAY = "MD";
+
+/**
+* Type constant used for renderers to represent a weekday
+* @property YAHOO.widget.Calendar.WEEKDAY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.WEEKDAY = "WD";
+
+/**
+* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y)
+* @property YAHOO.widget.Calendar.RANGE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.RANGE = "R";
+
+/**
+* Type constant used for renderers to represent a month across any year
+* @property YAHOO.widget.Calendar.MONTH
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.MONTH = "M";
+
+/**
+* Constant that represents the total number of date cells that are displayed in a given month
+* @property YAHOO.widget.Calendar.DISPLAY_DAYS
+* @static
+* @final
+* @type Number
+*/
+YAHOO.widget.Calendar.DISPLAY_DAYS = 42;
+
+/**
+* Constant used for halting the execution of the remainder of the render stack
+* @property YAHOO.widget.Calendar.STOP_RENDER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.STOP_RENDER = "S";
+
+YAHOO.widget.Calendar.prototype = {
+
+ /**
+ * The configuration object used to set up the calendars various locale and style options.
+ * @property Config
+ * @private
+ * @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty.
+ * @type Object
+ */
+ Config : null,
+
+ /**
+ * The parent CalendarGroup, only to be set explicitly by the parent group
+ * @property parent
+ * @type CalendarGroup
+ */
+ parent : null,
+
+ /**
+ * The index of this item in the parent group
+ * @property index
+ * @type Number
+ */
+ index : -1,
+
+ /**
+ * The collection of calendar table cells
+ * @property cells
+ * @type HTMLTableCellElement[]
+ */
+ cells : null,
+
+ /**
+ * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D].
+ * @property cellDates
+ * @type Array[](Number[])
+ */
+ cellDates : null,
+
+ /**
+ * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page.
+ * @property id
+ * @type String
+ */
+ id : null,
+
+ /**
+ * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered.
+ * @property oDomContainer
+ * @type HTMLElement
+ */
+ oDomContainer : null,
+
+ /**
+ * A Date object representing today's date.
+ * @property today
+ * @type Date
+ */
+ today : null,
+
+ /**
+ * The list of render functions, along with required parameters, used to render cells.
+ * @property renderStack
+ * @type Array[]
+ */
+ renderStack : null,
+
+ /**
+ * A copy of the initial render functions created before rendering.
+ * @property _renderStack
+ * @private
+ * @type Array
+ */
+ _renderStack : null,
+
+ /**
+ * A Date object representing the month/year that the calendar is initially set to
+ * @property _pageDate
+ * @private
+ * @type Date
+ */
+ _pageDate : null,
+
+ /**
+ * The private list of initially selected dates.
+ * @property _selectedDates
+ * @private
+ * @type Array
+ */
+ _selectedDates : null,
+
+ /**
+ * A map of DOM event handlers to attach to cells associated with specific CSS class names
+ * @property domEventMap
+ * @type Object
+ */
+ domEventMap : null
+};
+
+
+
+/**
+* Initializes the Calendar widget.
+* @method init
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container div element that will wrap the calendar table
+* @param {Object} config The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) {
+ this.initEvents();
+ this.today = new Date();
+ YAHOO.widget.DateMath.clearTime(this.today);
+
+ this.id = id;
+ this.oDomContainer = document.getElementById(containerId);
+
+ /**
+ * The Config object used to hold the configuration variables for the Calendar
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ /**
+ * The local object which contains the Calendar's options
+ * @property Options
+ * @type Object
+ */
+ this.Options = {};
+
+ /**
+ * The local object which contains the Calendar's locale settings
+ * @property Locale
+ * @type Object
+ */
+ this.Locale = {};
+
+ this.initStyles();
+
+ YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER);
+ YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE);
+
+ this.cellDates = [];
+ this.cells = [];
+ this.renderStack = [];
+ this._renderStack = [];
+
+ this.setupConfig();
+
+ if (config) {
+ this.cfg.applyConfig(config, true);
+ }
+
+ this.cfg.fireQueue();
+};
+
+/**
+* Renders the built-in IFRAME shim for the IE6 and below
+* @method configIframe
+*/
+YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) {
+ var useIframe = args[0];
+
+ if (YAHOO.util.Dom.inDocument(this.oDomContainer)) {
+ if (useIframe) {
+ var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position");
+
+ if (this.browser == "ie" && (pos == "absolute" || pos == "relative")) {
+ if (! YAHOO.util.Dom.inDocument(this.iframe)) {
+ this.iframe = document.createElement("iframe");
+ this.iframe.src = "javascript:false;";
+ YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
+ this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild);
+ }
+ }
+ } else {
+ if (this.iframe) {
+ if (this.iframe.parentNode) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+ this.iframe = null;
+ }
+ }
+ }
+};
+
+/**
+* Default handler for the "title" property
+* @method configTitle
+*/
+YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) {
+ var title = args[0];
+ var close = this.cfg.getProperty("close");
+
+ var titleDiv;
+
+ if (title && title !== "") {
+ titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || document.createElement("div");
+ titleDiv.className = YAHOO.widget.CalendarGroup.CSS_2UPTITLE;
+ titleDiv.innerHTML = title;
+ this.oDomContainer.insertBefore(titleDiv, this.oDomContainer.firstChild);
+ YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
+ } else {
+ titleDiv = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || null;
+
+ if (titleDiv) {
+ YAHOO.util.Event.purgeElement(titleDiv);
+ this.oDomContainer.removeChild(titleDiv);
+ }
+ if (! close) {
+ YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
+ }
+ }
+};
+
+/**
+* Default handler for the "close" property
+* @method configClose
+*/
+YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) {
+ var close = args[0];
+ var title = this.cfg.getProperty("title");
+
+ var linkClose;
+
+ if (close === true) {
+ linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || document.createElement("a");
+ linkClose.href = "javascript:void(null);";
+ linkClose.className = "link-close";
+ YAHOO.util.Event.addListener(linkClose, "click", this.hide, this, true);
+ var imgClose = document.createElement("img");
+ imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + "us/my/bn/x_d.gif";
+ imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;
+ linkClose.appendChild(imgClose);
+ this.oDomContainer.appendChild(linkClose);
+ YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle");
+ } else {
+ linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || null;
+
+ if (linkClose) {
+ YAHOO.util.Event.purgeElement(linkClose);
+ this.oDomContainer.removeChild(linkClose);
+ }
+ if (! title || title === "") {
+ YAHOO.util.Dom.removeClass(this.oDomContainer, "withtitle");
+ }
+ }
+};
+
+/**
+* Initializes Calendar's built-in CustomEvents
+* @method initEvents
+*/
+YAHOO.widget.Calendar.prototype.initEvents = function() {
+
+ /**
+ * Fired before a selection is made
+ * @event beforeSelectEvent
+ */
+ this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect");
+
+ /**
+ * Fired when a selection is made
+ * @event selectEvent
+ * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
+ */
+ this.selectEvent = new YAHOO.util.CustomEvent("select");
+
+ /**
+ * Fired before a selection is made
+ * @event beforeDeselectEvent
+ */
+ this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect");
+
+ /**
+ * Fired when a selection is made
+ * @event deselectEvent
+ * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
+ */
+ this.deselectEvent = new YAHOO.util.CustomEvent("deselect");
+
+ /**
+ * Fired when the Calendar page is changed
+ * @event changePageEvent
+ */
+ this.changePageEvent = new YAHOO.util.CustomEvent("changePage");
+
+ /**
+ * Fired before the Calendar is rendered
+ * @event beforeRenderEvent
+ */
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+
+ /**
+ * Fired when the Calendar is rendered
+ * @event renderEvent
+ */
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ /**
+ * Fired when the Calendar is reset
+ * @event resetEvent
+ */
+ this.resetEvent = new YAHOO.util.CustomEvent("reset");
+
+ /**
+ * Fired when the Calendar is cleared
+ * @event clearEvent
+ */
+ this.clearEvent = new YAHOO.util.CustomEvent("clear");
+
+ this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true);
+ this.selectEvent.subscribe(this.onSelect, this, true);
+ this.beforeDeselectEvent.subscribe(this.onBeforeDeselect, this, true);
+ this.deselectEvent.subscribe(this.onDeselect, this, true);
+ this.changePageEvent.subscribe(this.onChangePage, this, true);
+ this.renderEvent.subscribe(this.onRender, this, true);
+ this.resetEvent.subscribe(this.onReset, this, true);
+ this.clearEvent.subscribe(this.onClear, this, true);
+};
+
+
+/**
+* The default event function that is attached to a date link within a calendar cell
+* when the calendar is rendered.
+* @method doSelectCell
+* @param {DOMEvent} e The event
+* @param {Calendar} cal A reference to the calendar passed by the Event utility
+*/
+YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) {
+ var target = YAHOO.util.Event.getTarget(e);
+
+ var cell,index,d,date;
+
+ while (target.tagName.toLowerCase() != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+ target = target.parentNode;
+ if (target.tagName.toLowerCase() == "html") {
+ return;
+ }
+ }
+
+ cell = target;
+
+ if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) {
+ index = cell.id.split("cell")[1];
+ d = cal.cellDates[index];
+ date = new Date(d[0],d[1]-1,d[2]);
+
+ var link;
+
+ if (cal.Options.MULTI_SELECT) {
+ link = cell.getElementsByTagName("a")[0];
+ if (link) {
+ link.blur();
+ }
+
+ var cellDate = cal.cellDates[index];
+ var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate);
+
+ if (cellDateIndex > -1) {
+ cal.deselectCell(index);
+ } else {
+ cal.selectCell(index);
+ }
+
+ } else {
+ link = cell.getElementsByTagName("a")[0];
+ if (link) {
+ link.blur();
+ }
+ cal.selectCell(index);
+ }
+ }
+};
+
+/**
+* The event that is executed when the user hovers over a cell
+* @method doCellMouseOver
+* @param {DOMEvent} e The event
+* @param {Calendar} cal A reference to the calendar passed by the Event utility
+*/
+YAHOO.widget.Calendar.prototype.doCellMouseOver = function(e, cal) {
+ var target;
+ if (e) {
+ target = YAHOO.util.Event.getTarget(e);
+ } else {
+ target = this;
+ }
+
+ while (target.tagName.toLowerCase() != "td") {
+ target = target.parentNode;
+ if (target.tagName.toLowerCase() == "html") {
+ return;
+ }
+ }
+
+ if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+ YAHOO.util.Dom.addClass(target, cal.Style.CSS_CELL_HOVER);
+ }
+};
+
+/**
+* The event that is executed when the user moves the mouse out of a cell
+* @method doCellMouseOut
+* @param {DOMEvent} e The event
+* @param {Calendar} cal A reference to the calendar passed by the Event utility
+*/
+YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) {
+ var target;
+ if (e) {
+ target = YAHOO.util.Event.getTarget(e);
+ } else {
+ target = this;
+ }
+
+ while (target.tagName.toLowerCase() != "td") {
+ target = target.parentNode;
+ if (target.tagName.toLowerCase() == "html") {
+ return;
+ }
+ }
+
+ if (YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+ YAHOO.util.Dom.removeClass(target, cal.Style.CSS_CELL_HOVER);
+ }
+};
+
+YAHOO.widget.Calendar.prototype.setupConfig = function() {
+
+ /**
+ * The month/year representing the current visible Calendar date (mm/yyyy)
+ * @config pagedate
+ * @type String
+ * @default today's date
+ */
+ this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
+
+ /**
+ * The date or range of dates representing the current Calendar selection
+ * @config selected
+ * @type String
+ * @default []
+ */
+ this.cfg.addProperty("selected", { value:[], handler:this.configSelected } );
+
+ /**
+ * The title to display above the Calendar's month header
+ * @config title
+ * @type String
+ * @default ""
+ */
+ this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
+
+ /**
+ * Whether or not a close button should be displayed for this Calendar
+ * @config close
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("close", { value:false, handler:this.configClose } );
+
+ /**
+ * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
+ * @config iframe
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The minimum selectable date in the current Calendar (mm/dd/yyyy)
+ * @config mindate
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } );
+
+ /**
+ * The maximum selectable date in the current Calendar (mm/dd/yyyy)
+ * @config maxdate
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } );
+
+
+ // Options properties
+
+ /**
+ * True if the Calendar should allow multiple selections. False by default.
+ * @config MULTI_SELECT
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The weekday the week begins on. Default is 0 (Sunday).
+ * @config START_WEEKDAY
+ * @type number
+ * @default 0
+ */
+ this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.configOptions, validator:this.cfg.checkNumber } );
+
+ /**
+ * True if the Calendar should show weekday labels. True by default.
+ * @config SHOW_WEEKDAYS
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should show week row headers. False by default.
+ * @config SHOW_WEEK_HEADER
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should show week row footers. False by default.
+ * @config SHOW_WEEK_FOOTER
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should suppress weeks that are not a part of the current month. False by default.
+ * @config HIDE_BLANK_WEEKS
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The image that should be used for the left navigation arrow.
+ * @config NAV_ARROW_LEFT
+ * @type String
+ * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
+ */
+ this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.configOptions } );
+
+ /**
+ * The image that should be used for the left navigation arrow.
+ * @config NAV_ARROW_RIGHT
+ * @type String
+ * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
+ */
+ this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.configOptions } );
+
+ // Locale properties
+
+ /**
+ * The short month labels for the current locale.
+ * @config MONTHS_SHORT
+ * @type String[]
+ * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+ */
+ this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.configLocale } );
+
+ /**
+ * The long month labels for the current locale.
+ * @config MONTHS_LONG
+ * @type String[]
+ * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
+ */
+ this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.configLocale } );
+
+ /**
+ * The 1-character weekday labels for the current locale.
+ * @config WEEKDAYS_1CHAR
+ * @type String[]
+ * @default ["S", "M", "T", "W", "T", "F", "S"]
+ */
+ this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.configLocale } );
+
+ /**
+ * The short weekday labels for the current locale.
+ * @config WEEKDAYS_SHORT
+ * @type String[]
+ * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
+ */
+ this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.configLocale } );
+
+ /**
+ * The medium weekday labels for the current locale.
+ * @config WEEKDAYS_MEDIUM
+ * @type String[]
+ * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
+ */
+ this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.configLocale } );
+
+ /**
+ * The long weekday labels for the current locale.
+ * @config WEEKDAYS_LONG
+ * @type String[]
+ * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
+ */
+ this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.configLocale } );
+
+ /**
+ * Refreshes the locale values used to build the Calendar.
+ * @method refreshLocale
+ * @private
+ */
+ var refreshLocale = function() {
+ this.cfg.refireEvent("LOCALE_MONTHS");
+ this.cfg.refireEvent("LOCALE_WEEKDAYS");
+ };
+
+ this.cfg.subscribeToConfigEvent("START_WEEKDAY", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("MONTHS_SHORT", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("MONTHS_LONG", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM", refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG", refreshLocale, this, true);
+
+ /**
+ * The setting that determines which length of month labels should be used. Possible values are "short" and "long".
+ * @config LOCALE_MONTHS
+ * @type String
+ * @default "long"
+ */
+ this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } );
+
+ /**
+ * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
+ * @config LOCALE_WEEKDAYS
+ * @type String
+ * @default "short"
+ */
+ this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } );
+
+ /**
+ * The value used to delimit individual dates in a date string passed to various Calendar functions.
+ * @config DATE_DELIMITER
+ * @type String
+ * @default ","
+ */
+ this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } );
+
+ /**
+ * The value used to delimit date fields in a date string passed to various Calendar functions.
+ * @config DATE_FIELD_DELIMITER
+ * @type String
+ * @default "/"
+ */
+ this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } );
+
+ /**
+ * The value used to delimit date ranges in a date string passed to various Calendar functions.
+ * @config DATE_RANGE_DELIMITER
+ * @type String
+ * @default "-"
+ */
+ this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } );
+
+ /**
+ * The position of the month in a month/year date string
+ * @config MY_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the year in a month/year date string
+ * @config MY_YEAR_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the month in a month/day date string
+ * @config MD_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the day in a month/year date string
+ * @config MD_DAY_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the month in a month/day/year date string
+ * @config MDY_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the day in a month/day/year date string
+ * @config MDY_DAY_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the year in a month/day/year date string
+ * @config MDY_YEAR_POSITION
+ * @type Number
+ * @default 3
+ */
+ this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } );
+};
+
+/**
+* The default handler for the "pagedate" property
+* @method configPageDate
+*/
+YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) {
+ var val = args[0];
+ var month, year, aMonthYear;
+
+ if (val) {
+ if (val instanceof Date) {
+ val = YAHOO.widget.DateMath.findMonthStart(val);
+ this.cfg.setProperty("pagedate", val, true);
+ if (! this._pageDate) {
+ this._pageDate = this.cfg.getProperty("pagedate");
+ }
+ return;
+ } else {
+ aMonthYear = val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER"));
+ month = parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1], 10)-1;
+ year = parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1], 10);
+ }
+ } else {
+ month = this.today.getMonth();
+ year = this.today.getFullYear();
+ }
+
+ this.cfg.setProperty("pagedate", new Date(year, month, 1), true);
+ if (! this._pageDate) {
+ this._pageDate = this.cfg.getProperty("pagedate");
+ }
+};
+
+/**
+* The default handler for the "mindate" property
+* @method configMinDate
+*/
+YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) {
+ var val = args[0];
+ if (typeof val == 'string') {
+ val = this._parseDate(val);
+ this.cfg.setProperty("mindate", new Date(val[0],(val[1]-1),val[2]));
+ }
+};
+
+/**
+* The default handler for the "maxdate" property
+* @method configMaxDate
+*/
+YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) {
+ var val = args[0];
+ if (typeof val == 'string') {
+ val = this._parseDate(val);
+ this.cfg.setProperty("maxdate", new Date(val[0],(val[1]-1),val[2]));
+ }
+};
+
+/**
+* The default handler for the "selected" property
+* @method configSelected
+*/
+YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) {
+ var selected = args[0];
+
+ if (selected) {
+ if (typeof selected == 'string') {
+ this.cfg.setProperty("selected", this._parseDates(selected), true);
+ }
+ }
+ if (! this._selectedDates) {
+ this._selectedDates = this.cfg.getProperty("selected");
+ }
+};
+
+/**
+* The default handler for all configuration options properties
+* @method configOptions
+*/
+YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) {
+ type = type.toUpperCase();
+ var val = args[0];
+ this.Options[type] = val;
+};
+
+/**
+* The default handler for all configuration locale properties
+* @method configLocale
+*/
+YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) {
+ type = type.toUpperCase();
+ var val = args[0];
+ this.Locale[type] = val;
+
+ this.cfg.refireEvent("LOCALE_MONTHS");
+ this.cfg.refireEvent("LOCALE_WEEKDAYS");
+
+};
+
+/**
+* The default handler for all configuration locale field length properties
+* @method configLocaleValues
+*/
+YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) {
+ type = type.toUpperCase();
+ var val = args[0];
+
+ switch (type) {
+ case "LOCALE_MONTHS":
+ switch (val) {
+ case "short":
+ this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_SHORT").concat();
+ break;
+ case "long":
+ this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_LONG").concat();
+ break;
+ }
+ break;
+ case "LOCALE_WEEKDAYS":
+ switch (val) {
+ case "1char":
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_1CHAR").concat();
+ break;
+ case "short":
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_SHORT").concat();
+ break;
+ case "medium":
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_MEDIUM").concat();
+ break;
+ case "long":
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_LONG").concat();
+ break;
+ }
+
+ var START_WEEKDAY = this.cfg.getProperty("START_WEEKDAY");
+
+ if (START_WEEKDAY > 0) {
+ for (var w=0;w";
+ html[html.length] = "";
+ html[html.length] = '';
+ html[html.length] = ' ';
+
+ if (this.cfg.getProperty("SHOW_WEEKDAYS")) {
+ html = this.buildWeekdays(html);
+ }
+
+ html[html.length] = '';
+
+ return html;
+};
+
+/**
+* Renders the Calendar's weekday headers.
+* @method buildWeekdays
+* @param {Array} html The current working HTML array
+* @return {Array} The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) {
+
+ html[html.length] = '';
+
+ if (this.cfg.getProperty("SHOW_WEEK_HEADER")) {
+ html[html.length] = ' ';
+ }
+
+ for(var i=0;i' + this.Locale.LOCALE_WEEKDAYS[i] + '';
+ }
+
+ if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) {
+ html[html.length] = ' ';
+ }
+
+ html[html.length] = ' ';
+
+ return html;
+};
+
+/**
+* Renders the calendar body.
+* @method renderBody
+* @param {Date} workingDate The current working Date being used for the render process
+* @param {Array} html The current working HTML array
+* @return {Array} The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) {
+
+ var startDay = this.cfg.getProperty("START_WEEKDAY");
+
+ this.preMonthDays = workingDate.getDay();
+ if (startDay > 0) {
+ this.preMonthDays -= startDay;
+ }
+ if (this.preMonthDays < 0) {
+ this.preMonthDays += 7;
+ }
+
+ this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
+ this.postMonthDays = YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
+
+ workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
+
+ var useDate,weekNum,weekClass;
+ useDate = this.cfg.getProperty("pagedate");
+
+ html[html.length] = '';
+
+ var i = 0;
+
+ var tempDiv = document.createElement("div");
+ var cell = document.createElement("td");
+ tempDiv.appendChild(cell);
+
+ var jan1 = new Date(useDate.getFullYear(),0,1);
+
+ var cal = this.parent || this;
+
+ for (var r=0;r<6;r++) {
+
+ weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useDate.getFullYear(), startDay);
+
+ weekClass = "w" + weekNum;
+
+ if (r !== 0 && this.isDateOOM(workingDate) && this.cfg.getProperty("HIDE_BLANK_WEEKS") === true) {
+ break;
+ } else {
+
+ html[html.length] = '';
+
+ if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { html = this.renderRowHeader(weekNum, html); }
+
+ for (var d=0;d<7;d++){ // Render actual days
+
+ var cellRenderers = [];
+
+ this.clearElement(cell);
+
+ YAHOO.util.Dom.addClass(cell, "calcell");
+
+ cell.id = this.id + "_cell" + i;
+
+ cell.innerHTML = i;
+
+ var renderer = null;
+
+ if (workingDate.getFullYear() == this.today.getFullYear() &&
+ workingDate.getMonth() == this.today.getMonth() &&
+ workingDate.getDate() == this.today.getDate()) {
+ cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;
+ }
+
+ this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates
+
+ if (this.isDateOOM(workingDate)) {
+ cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;
+ } else {
+
+ YAHOO.util.Dom.addClass(cell, "wd" + workingDate.getDay());
+ YAHOO.util.Dom.addClass(cell, "d" + workingDate.getDate());
+
+ for (var s=0;s= d1.getTime() && workingDate.getTime() <= d2.getTime()) {
+ renderer = rArray[2];
+
+ if (workingDate.getTime()==d2.getTime()) {
+ this.renderStack.splice(s,1);
+ }
+ }
+ break;
+ case YAHOO.widget.Calendar.WEEKDAY:
+
+ var weekday = rArray[1][0];
+ if (workingDate.getDay()+1 == weekday) {
+ renderer = rArray[2];
+ }
+ break;
+ case YAHOO.widget.Calendar.MONTH:
+
+ month = rArray[1][0];
+ if (workingDate.getMonth()+1 == month) {
+ renderer = rArray[2];
+ }
+ break;
+ }
+
+ if (renderer) {
+ cellRenderers[cellRenderers.length]=renderer;
+ }
+ }
+
+ }
+
+ if (this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]) > -1) {
+ cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected;
+ }
+
+ var mindate = this.cfg.getProperty("mindate");
+ var maxdate = this.cfg.getProperty("maxdate");
+
+ if (mindate) {
+ mindate = YAHOO.widget.DateMath.clearTime(mindate);
+ }
+ if (maxdate) {
+ maxdate = YAHOO.widget.DateMath.clearTime(maxdate);
+ }
+
+ if (
+ (mindate && (workingDate.getTime() < mindate.getTime())) ||
+ (maxdate && (workingDate.getTime() > maxdate.getTime()))
+ ) {
+ cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate;
+ } else {
+ cellRenderers[cellRenderers.length]=cal.styleCellDefault;
+ cellRenderers[cellRenderers.length]=cal.renderCellDefault;
+ }
+
+
+
+ for (var x=0;x= 0 && i <= 6) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TOP);
+ }
+ if ((i % 7) === 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_LEFT);
+ }
+ if (((i+1) % 7) === 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RIGHT);
+ }
+
+ var postDays = this.postMonthDays;
+ if (postDays >= 7 && this.cfg.getProperty("HIDE_BLANK_WEEKS")) {
+ var blankWeeks = Math.floor(postDays/7);
+ for (var p=0;p= ((this.preMonthDays+postDays+this.monthDays)-7)) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM);
+ }
+
+ html[html.length] = tempDiv.innerHTML;
+
+ i++;
+ }
+
+ if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { html = this.renderRowFooter(weekNum, html); }
+
+ html[html.length] = ' ';
+ }
+ }
+
+ html[html.length] = ' ';
+
+ return html;
+};
+
+/**
+* Renders the calendar footer. In the default implementation, there is
+* no footer.
+* @method renderFooter
+* @param {Array} html The current working HTML array
+* @return {Array} The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.renderFooter = function(html) { return html; };
+
+/**
+* Renders the calendar after it has been configured. The render() method has a specific call chain that will execute
+* when the method is called: renderHeader, renderBody, renderFooter.
+* Refer to the documentation for those methods for information on
+* individual render tasks.
+* @method render
+*/
+YAHOO.widget.Calendar.prototype.render = function() {
+ this.beforeRenderEvent.fire();
+
+ // Find starting day of the current month
+ var workingDate = YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty("pagedate"));
+
+ this.resetRenderers();
+ this.cellDates.length = 0;
+
+ YAHOO.util.Event.purgeElement(this.oDomContainer, true);
+
+ var html = [];
+
+ html[html.length] = '';
+ html = this.renderHeader(html);
+ html = this.renderBody(workingDate, html);
+ html = this.renderFooter(html);
+ html[html.length] = '
';
+
+ this.oDomContainer.innerHTML = html.join("\n");
+
+ this.applyListeners();
+ this.cells = this.oDomContainer.getElementsByTagName("td");
+
+ this.cfg.refireEvent("title");
+ this.cfg.refireEvent("close");
+ this.cfg.refireEvent("iframe");
+
+ this.renderEvent.fire();
+};
+
+/**
+* Applies the Calendar's DOM listeners to applicable elements.
+* @method applyListeners
+*/
+YAHOO.widget.Calendar.prototype.applyListeners = function() {
+
+ var root = this.oDomContainer;
+ var cal = this.parent || this;
+
+ var linkLeft, linkRight;
+
+ linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, "a", root);
+ linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, "a", root);
+
+ if (linkLeft) {
+ this.linkLeft = linkLeft[0];
+ YAHOO.util.Event.addListener(this.linkLeft, "mousedown", cal.previousMonth, cal, true);
+ }
+
+ if (linkRight) {
+ this.linkRight = linkRight[0];
+ YAHOO.util.Event.addListener(this.linkRight, "mousedown", cal.nextMonth, cal, true);
+ }
+
+ if (this.domEventMap) {
+ var el,elements;
+ for (var cls in this.domEventMap) {
+ if (this.domEventMap.hasOwnProperty(cls)) {
+ var items = this.domEventMap[cls];
+
+ if (! (items instanceof Array)) {
+ items = [items];
+ }
+
+ for (var i=0;i' + weekNum + '';
+ return html;
+};
+
+/**
+* Renders the row footer for a week.
+* @method renderRowFooter
+* @param {Number} weekNum The week number of the current row
+* @param {Array} cell The current working HTML array
+*/
+YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) {
+ html[html.length] = '';
+ return html;
+};
+
+/**
+* Renders a single standard calendar cell in the calendar widget table.
+* All logic for determining how a standard default cell will be rendered is
+* encapsulated in this method, and must be accounted for when extending the
+* widget class.
+* @method renderCellDefault
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) {
+ cell.innerHTML = '' + this.buildDayLabel(workingDate) + " ";
+};
+
+/**
+* Styles a selectable cell.
+* @method styleCellDefault
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.styleCellDefault = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE);
+};
+
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight1 style
+* @method renderCellStyleHighlight1
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight2 style
+* @method renderCellStyleHighlight2
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight3 style
+* @method renderCellStyleHighlight3
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight4 style
+* @method renderCellStyleHighlight4
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
+};
+
+/**
+* Applies the default style used for rendering today's date to the current calendar cell
+* @method renderCellStyleToday
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleToday = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY);
+};
+
+/**
+* Applies the default style used for rendering selected dates to the current calendar cell
+* @method renderCellStyleSelected
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+*/
+YAHOO.widget.Calendar.prototype.renderCellStyleSelected = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED);
+};
+
+/**
+* Applies the default style used for rendering dates that are not a part of the current
+* month (preceding or trailing the cells for the current month)
+* @method renderCellNotThisMonth
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+*/
+YAHOO.widget.Calendar.prototype.renderCellNotThisMonth = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar.STOP_RENDER;
+};
+
+/**
+* Renders the current calendar cell as a non-selectable "black-out" date using the default
+* restricted style.
+* @method renderBodyCellRestricted
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+*/
+YAHOO.widget.Calendar.prototype.renderBodyCellRestricted = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL);
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RESTRICTED);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar.STOP_RENDER;
+};
+
+// END BUILT-IN TABLE CELL RENDERERS
+
+// BEGIN MONTH NAVIGATION METHODS
+
+/**
+* Adds the designated number of months to the current calendar month, and sets the current
+* calendar page date to the new month.
+* @method addMonths
+* @param {Number} count The number of months to add to the current calendar
+*/
+YAHOO.widget.Calendar.prototype.addMonths = function(count) {
+ this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+};
+
+/**
+* Subtracts the designated number of months from the current calendar month, and sets the current
+* calendar page date to the new month.
+* @method subtractMonths
+* @param {Number} count The number of months to subtract from the current calendar
+*/
+YAHOO.widget.Calendar.prototype.subtractMonths = function(count) {
+ this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+};
+
+/**
+* Adds the designated number of years to the current calendar, and sets the current
+* calendar page date to the new month.
+* @method addYears
+* @param {Number} count The number of years to add to the current calendar
+*/
+YAHOO.widget.Calendar.prototype.addYears = function(count) {
+ this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+};
+
+/**
+* Subtcats the designated number of years from the current calendar, and sets the current
+* calendar page date to the new month.
+* @method subtractYears
+* @param {Number} count The number of years to subtract from the current calendar
+*/
+YAHOO.widget.Calendar.prototype.subtractYears = function(count) {
+ this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count));
+ this.resetRenderers();
+ this.changePageEvent.fire();
+};
+
+/**
+* Navigates to the next month page in the calendar widget.
+* @method nextMonth
+*/
+YAHOO.widget.Calendar.prototype.nextMonth = function() {
+ this.addMonths(1);
+};
+
+/**
+* Navigates to the previous month page in the calendar widget.
+* @method previousMonth
+*/
+YAHOO.widget.Calendar.prototype.previousMonth = function() {
+ this.subtractMonths(1);
+};
+
+/**
+* Navigates to the next year in the currently selected month in the calendar widget.
+* @method nextYear
+*/
+YAHOO.widget.Calendar.prototype.nextYear = function() {
+ this.addYears(1);
+};
+
+/**
+* Navigates to the previous year in the currently selected month in the calendar widget.
+* @method previousYear
+*/
+YAHOO.widget.Calendar.prototype.previousYear = function() {
+ this.subtractYears(1);
+};
+
+// END MONTH NAVIGATION METHODS
+
+// BEGIN SELECTION METHODS
+
+/**
+* Resets the calendar widget to the originally selected month and year, and
+* sets the calendar to the initial selection(s).
+* @method reset
+*/
+YAHOO.widget.Calendar.prototype.reset = function() {
+ this.cfg.resetProperty("selected");
+ this.cfg.resetProperty("pagedate");
+ this.resetEvent.fire();
+};
+
+/**
+* Clears the selected dates in the current calendar widget and sets the calendar
+* to the current month and year.
+* @method clear
+*/
+YAHOO.widget.Calendar.prototype.clear = function() {
+ this.cfg.setProperty("selected", []);
+ this.cfg.setProperty("pagedate", new Date(this.today.getTime()));
+ this.clearEvent.fire();
+};
+
+/**
+* Selects a date or a collection of dates on the current calendar. This method, by default,
+* does not call the render method explicitly. Once selection has completed, render must be
+* called for the changes to be reflected visually.
+* @method select
+* @param {String/Date/Date[]} date The date string of dates to select in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+*/
+YAHOO.widget.Calendar.prototype.select = function(date) {
+ this.beforeSelectEvent.fire();
+
+ var selected = this.cfg.getProperty("selected");
+ var aToBeSelected = this._toFieldArray(date);
+
+ for (var a=0;a -1) {
+ if (this.cfg.getProperty("pagedate").getMonth() == dCellDate.getMonth() &&
+ this.cfg.getProperty("pagedate").getFullYear() == dCellDate.getFullYear()) {
+ YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED);
+ }
+
+ selected.splice(cellDateIndex, 1);
+ }
+
+
+ if (this.parent) {
+ this.parent.cfg.setProperty("selected", selected);
+ } else {
+ this.cfg.setProperty("selected", selected);
+ }
+
+ this.deselectEvent.fire(selectDate);
+ return this.getSelectedDates();
+};
+
+/**
+* Deselects all dates on the current calendar.
+* @method deselectAll
+* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected.
+* Assuming that this function executes properly, the return value should be an empty array.
+* However, the empty array is returned for the sake of being able to check the selection status
+* of the calendar.
+*/
+YAHOO.widget.Calendar.prototype.deselectAll = function() {
+ this.beforeDeselectEvent.fire();
+
+ var selected = this.cfg.getProperty("selected");
+ var count = selected.length;
+ var sel = selected.concat();
+
+ if (this.parent) {
+ this.parent.cfg.setProperty("selected", []);
+ } else {
+ this.cfg.setProperty("selected", []);
+ }
+
+ if (count > 0) {
+ this.deselectEvent.fire(sel);
+ }
+
+ return this.getSelectedDates();
+};
+
+// END SELECTION METHODS
+
+// BEGIN TYPE CONVERSION METHODS
+
+/**
+* Converts a date (either a JavaScript Date object, or a date string) to the internal data structure
+* used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]].
+* @method _toFieldArray
+* @private
+* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return {Array[](Number[])} Array of date field arrays
+*/
+YAHOO.widget.Calendar.prototype._toFieldArray = function(date) {
+ var returnDate = [];
+
+ if (date instanceof Date) {
+ returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]];
+ } else if (typeof date == 'string') {
+ returnDate = this._parseDates(date);
+ } else if (date instanceof Array) {
+ for (var i=0;i
+*
+*
+*
+* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
+* @namespace YAHOO.widget
+* @class CalendarGroup
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container div element that will wrap the calendar table
+* @param {Object} config The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.CalendarGroup = function(id, containerId, config) {
+ if (arguments.length > 0) {
+ this.init(id, containerId, config);
+ }
+};
+
+/**
+* Initializes the calendar group. All subclasses must call this method in order for the
+* group to be initialized properly.
+* @method init
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container div element that will wrap the calendar table
+* @param {Object} config The configuration object containing the Calendar's arguments
+*/
+YAHOO.widget.CalendarGroup.prototype.init = function(id, containerId, config) {
+ this.initEvents();
+ this.initStyles();
+
+ /**
+ * The collection of Calendar pages contained within the CalendarGroup
+ * @property pages
+ * @type YAHOO.widget.Calendar[]
+ */
+ this.pages = [];
+
+ /**
+ * The unique id associated with the CalendarGroup
+ * @property id
+ * @type String
+ */
+ this.id = id;
+
+ /**
+ * The unique id associated with the CalendarGroup container
+ * @property containerId
+ * @type String
+ */
+ this.containerId = containerId;
+
+ /**
+ * The outer containing element for the CalendarGroup
+ * @property oDomContainer
+ * @type HTMLElement
+ */
+ this.oDomContainer = document.getElementById(containerId);
+
+ YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_CONTAINER);
+ YAHOO.util.Dom.addClass(this.oDomContainer, YAHOO.widget.CalendarGroup.CSS_MULTI_UP);
+
+ /**
+ * The Config object used to hold the configuration variables for the CalendarGroup
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ /**
+ * The local object which contains the CalendarGroup's options
+ * @property Options
+ * @type Object
+ */
+ this.Options = {};
+
+ /**
+ * The local object which contains the CalendarGroup's locale settings
+ * @property Locale
+ * @type Object
+ */
+ this.Locale = {};
+
+ this.setupConfig();
+
+ if (config) {
+ this.cfg.applyConfig(config, true);
+ }
+
+ this.cfg.fireQueue();
+
+ // OPERA HACK FOR MISWRAPPED FLOATS
+ if (this.browser == "opera"){
+ var fixWidth = function() {
+ var startW = this.oDomContainer.offsetWidth;
+ var w = 0;
+ for (var p=0;p 0) {
+ this.oDomContainer.style.width = w + "px";
+ }
+ };
+ this.renderEvent.subscribe(fixWidth,this,true);
+ }
+};
+
+
+YAHOO.widget.CalendarGroup.prototype.setupConfig = function() {
+ /**
+ * The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments.
+ * @config pages
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("pages", { value:2, validator:this.cfg.checkNumber, handler:this.configPages } );
+
+ /**
+ * The month/year representing the current visible Calendar date (mm/yyyy)
+ * @config pagedate
+ * @type String
+ * @default today's date
+ */
+ this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } );
+
+ /**
+ * The date or range of dates representing the current Calendar selection
+ * @config selected
+ * @type String
+ * @default []
+ */
+ this.cfg.addProperty("selected", { value:[], handler:this.delegateConfig } );
+
+ /**
+ * The title to display above the CalendarGroup's month header
+ * @config title
+ * @type String
+ * @default ""
+ */
+ this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
+
+ /**
+ * Whether or not a close button should be displayed for this CalendarGroup
+ * @config close
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("close", { value:false, handler:this.configClose } );
+
+ /**
+ * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below.
+ * @config iframe
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("iframe", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The minimum selectable date in the current Calendar (mm/dd/yyyy)
+ * @config mindate
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("mindate", { value:null, handler:this.delegateConfig } );
+
+ /**
+ * The maximum selectable date in the current Calendar (mm/dd/yyyy)
+ * @config maxdate
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("maxdate", { value:null, handler:this.delegateConfig } );
+
+ // Options properties
+
+ /**
+ * True if the Calendar should allow multiple selections. False by default.
+ * @config MULTI_SELECT
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The weekday the week begins on. Default is 0 (Sunday).
+ * @config START_WEEKDAY
+ * @type number
+ * @default 0
+ */
+ this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * True if the Calendar should show weekday labels. True by default.
+ * @config SHOW_WEEKDAYS
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should show week row headers. False by default.
+ * @config SHOW_WEEK_HEADER
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should show week row footers. False by default.
+ * @config SHOW_WEEK_FOOTER
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * True if the Calendar should suppress weeks that are not a part of the current month. False by default.
+ * @config HIDE_BLANK_WEEKS
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } );
+
+ /**
+ * The image that should be used for the left navigation arrow.
+ * @config NAV_ARROW_LEFT
+ * @type String
+ * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif"
+ */
+ this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.delegateConfig } );
+
+ /**
+ * The image that should be used for the left navigation arrow.
+ * @config NAV_ARROW_RIGHT
+ * @type String
+ * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
+ */
+ this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.delegateConfig } );
+
+ // Locale properties
+
+ /**
+ * The short month labels for the current locale.
+ * @config MONTHS_SHORT
+ * @type String[]
+ * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+ */
+ this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.delegateConfig } );
+
+ /**
+ * The long month labels for the current locale.
+ * @config MONTHS_LONG
+ * @type String[]
+ * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
+ */
+ this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.delegateConfig } );
+
+ /**
+ * The 1-character weekday labels for the current locale.
+ * @config WEEKDAYS_1CHAR
+ * @type String[]
+ * @default ["S", "M", "T", "W", "T", "F", "S"]
+ */
+ this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.delegateConfig } );
+
+ /**
+ * The short weekday labels for the current locale.
+ * @config WEEKDAYS_SHORT
+ * @type String[]
+ * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
+ */
+ this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.delegateConfig } );
+
+ /**
+ * The medium weekday labels for the current locale.
+ * @config WEEKDAYS_MEDIUM
+ * @type String[]
+ * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
+ */
+ this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.delegateConfig } );
+
+ /**
+ * The long weekday labels for the current locale.
+ * @config WEEKDAYS_LONG
+ * @type String[]
+ * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
+ */
+ this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.delegateConfig } );
+
+ /**
+ * The setting that determines which length of month labels should be used. Possible values are "short" and "long".
+ * @config LOCALE_MONTHS
+ * @type String
+ * @default "long"
+ */
+ this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.delegateConfig } );
+
+ /**
+ * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
+ * @config LOCALE_WEEKDAYS
+ * @type String
+ * @default "short"
+ */
+ this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.delegateConfig } );
+
+ /**
+ * The value used to delimit individual dates in a date string passed to various Calendar functions.
+ * @config DATE_DELIMITER
+ * @type String
+ * @default ","
+ */
+ this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.delegateConfig } );
+
+ /**
+ * The value used to delimit date fields in a date string passed to various Calendar functions.
+ * @config DATE_FIELD_DELIMITER
+ * @type String
+ * @default "/"
+ */
+ this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.delegateConfig } );
+
+ /**
+ * The value used to delimit date ranges in a date string passed to various Calendar functions.
+ * @config DATE_RANGE_DELIMITER
+ * @type String
+ * @default "-"
+ */
+ this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.delegateConfig } );
+
+ /**
+ * The position of the month in a month/year date string
+ * @config MY_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the year in a month/year date string
+ * @config MY_YEAR_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the month in a month/day date string
+ * @config MD_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the day in a month/year date string
+ * @config MD_DAY_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the month in a month/day/year date string
+ * @config MDY_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the day in a month/day/year date string
+ * @config MDY_DAY_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the year in a month/day/year date string
+ * @config MDY_YEAR_POSITION
+ * @type Number
+ * @default 3
+ */
+ this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.delegateConfig, validator:this.cfg.checkNumber } );
+
+};
+
+/**
+* Initializes CalendarGroup's built-in CustomEvents
+* @method initEvents
+*/
+YAHOO.widget.CalendarGroup.prototype.initEvents = function() {
+ var me = this;
+
+ /**
+ * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents
+ * @method sub
+ * @private
+ * @param {Function} fn The function to subscribe to this CustomEvent
+ * @param {Object} obj The CustomEvent's scope object
+ * @param {Boolean} bOverride Whether or not to apply scope correction
+ */
+ var sub = function(fn, obj, bOverride) {
+ for (var p=0;p0) {
+ year+=1;
+ }
+ cal.setYear(year);
+ }
+};
+/**
+* Calls the render function of all child calendars within the group.
+* @method render
+*/
+YAHOO.widget.CalendarGroup.prototype.render = function() {
+ this.renderHeader();
+ for (var p=0;p=0;--p) {
+ var cal = this.pages[p];
+ cal.previousMonth();
+ }
+};
+
+/**
+* Navigates to the next year in the currently selected month in the calendar widget.
+* @method nextYear
+*/
+YAHOO.widget.CalendarGroup.prototype.nextYear = function() {
+ for (var p=0;p 13, Opera 9.02 will crash. Connection manager objects count n must be <=
-12 at all times. This condition was not present in Opera version 9.01.
-
-This condition does not apply to other A-Grade browsers (
-http://developer.yahoo.com/yui/articles/gbs/gbs_browser-chart.html)
-
-*** version 0.11.3 ***
-
-* YUI Event dependency for file uploading is now optional.
-
-* uploadFile() now sets unique IDs for each file upload transaction to prevent
-iframe collisions with parallel uploads.
-
-* The callback object now has property responseXML to provide support for file
-upload transactions that return an XML document.
-
-* setForm() will verify if a select option value attribute is present and use
-its value, including empty string, before using the text node value.
-
-* Modified polling mechanism in handleReadyState() and
-handleTransactionResponse() to prevent infinite polling if JavaScript errors
-occur in the user-defined callback.
-
-* createFrame() will now accept a boolean argument of true to set the frame
-source to "javascript:false" to prevent IE from throwing security warnings in an
-HTTPS environment.
-
-* setHeader() now enumerates through the _http_header object using
-hasOwnProperty() to prevent collisions with members added to Object via
-prototype.
-
-* If using setForm() and asyncRequest includes a POST data argument, the data
-will be concatenated to the HTML form POST message.
-
-*** version 0.11.2 ***
-
-* No revisions.
-
-*** version 0.11.1 ***
-
-* uploadFile() now verifies the existence of callback.upload before invoking
-callback, with or without object scope.
-
-*** version 0.11.0 ***
-
-* Each transaction can be defined with a timeout threshold, in milliseconds,
-through the callback object. If the threshold is reached, and the transaction
-hasn't yet completed, the transaction will call abort().
-
-* abort() will now accept a callback object as the second argument. The
-failure callback will receive a response object to indicate the transaction was
-aborted.
-
-* setForm() will now support file uploads by setting the second argument to
-true (e.g., YAHOO.util.Connect.setForm(formObject, true). File upload does not
-use the callback success or failure handler. Instead, it uses a new callback
-object handler: upload.
-
-* HTML form submit will no longer submit form fields without a defined name
-attribute.
-
-* The default POST header of 'Content-Type','application/x-www-form-urlencoded'
-can be overridden by calling setDefaultPostHeader(false). This
-will remove the default header from non-HTML form, POST submissions.
-
-* setHeader() now enumerates through the _http_header object with
-propertyIsEnumerable to prevent collisions with members added to Object via
-prototype.
-
-*** version 0.10.0 ***
-
-* handleTransactionResponse() now treats the full HTTP 2xx range as a success
-case, instead of just HTTP 200.
-
-* To accommodate multiple field values in Mozilla/Firefox, multiple initHeader
-calls with the same label will now result in the values concatenated to a
-comma- delimited string value.
-Example:
-Setting Content-Type:'application/x-www-form-urlencoded' and Content-
-Type:'text/xml' will result in Content-Type:'application/x-www-form-urlencoded,
-text/xml'.
-
-* Default polling interval lowered to 50ms.
-
-* YAHOO.util.Connect.setPollingInterval() will allow you to set a polling
-interval -- in milliseconds -- to override the default value.
-
-* YAHOO.util.Connect.getResponseHeader[headerLabel] now supported as a response
-object property to provide symmetry with the native XHR object's property.
-Example:
-YAHOO.util.Connect.getResponseHeader['Content-Length'] will return the value
-for the Content-Length header, if the header is available.
-
-* YAHOO.util.Connect.allResponseHeaders property renamed to
-getAllResponseHeaders to provide symmetry with the native XHR object's
-property.
-
-* YAHOO.util.Connect.setForm() now supports HTTP GET as well as HTTP POST.
-
-* YAHOO.util.Connect.setForm() now accepts an HTML form object as well as its
-name attribute value.
-
-* YAHOO.util.Connect.setForm() will not submit HTML form fields that are
-disabled or do not have a name attribute value.
-
-* [FIXED] Response exceptions result in infinite callback loop in
-Mozilla/Firefox.
-
-* [FIXED] YAHOO.util.Connect.abort() now properly clears polling interval.
-
-* [FIXED] isCallInProgress() now verifies whether XHR instance still exists,
-and returns false if the connection object is no longer available.
-
-*** version 0.9.0 ***
-
-* Initial release
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+Connection Manager Release Notes
+
+*** version 0.12.2 ***
+
+* The Opera/Connection Manager concurrent object condition, described in version
+0.12.0, no longer tests applies for Opera, version 9.10.
+
+*** version 0.12.1 ***
+
+* connection-debug.js corrected and synchronized with connection.js. Code
+inconsistencies between the two files existed in 0.12.0.
+
+*** version 0.12.0 ***
+
+* When uploading files via setForm() and asyncRequest includes a POST data
+argument, appendPostData() will create hidden input fields for each postData
+label/value and append each field to the form object.
+
+* setForm() returns the assembled label/value string of the parsed HTML form
+fields.
+
+* NOTE: Opera 9.02 does not allow for more than 12 concurrent Connection Manager
+objects.
+
+The following example creates 12 requests in a loop:
+for(var n=0; n<=12; i++){
+ conn[n] = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
+}
+
+If n > 13, Opera 9.02 will crash. Connection manager objects count n must be <=
+12 at all times. This condition was not present in Opera version 9.01.
+
+This condition does not apply to other A-Grade browsers (
+http://developer.yahoo.com/yui/articles/gbs/gbs_browser-chart.html)
+
+*** version 0.11.3 ***
+
+* YUI Event dependency for file uploading is now optional.
+
+* uploadFile() now sets unique IDs for each file upload transaction to prevent
+iframe collisions with parallel uploads.
+
+* The callback object now has property responseXML to provide support for file
+upload transactions that return an XML document.
+
+* setForm() will verify if a select option value attribute is present and use
+its value, including empty string, before using the text node value.
+
+* Modified polling mechanism in handleReadyState() and
+handleTransactionResponse() to prevent infinite polling if JavaScript errors
+occur in the user-defined callback.
+
+* createFrame() will now accept a boolean argument of true to set the frame
+source to "javascript:false" to prevent IE from throwing security warnings in an
+HTTPS environment.
+
+* setHeader() now enumerates through the _http_header object using
+hasOwnProperty() to prevent collisions with members added to Object via
+prototype.
+
+* If using setForm() and asyncRequest includes a POST data argument, the data
+will be concatenated to the HTML form POST message.
+
+*** version 0.11.2 ***
+
+* No revisions.
+
+*** version 0.11.1 ***
+
+* uploadFile() now verifies the existence of callback.upload before invoking
+callback, with or without object scope.
+
+*** version 0.11.0 ***
+
+* Each transaction can be defined with a timeout threshold, in milliseconds,
+through the callback object. If the threshold is reached, and the transaction
+hasn't yet completed, the transaction will call abort().
+
+* abort() will now accept a callback object as the second argument. The
+failure callback will receive a response object to indicate the transaction was
+aborted.
+
+* setForm() will now support file uploads by setting the second argument to
+true (e.g., YAHOO.util.Connect.setForm(formObject, true). File upload does not
+use the callback success or failure handler. Instead, it uses a new callback
+object handler: upload.
+
+* HTML form submit will no longer submit form fields without a defined name
+attribute.
+
+* The default POST header of 'Content-Type','application/x-www-form-urlencoded'
+can be overridden by calling setDefaultPostHeader(false). This
+will remove the default header from non-HTML form, POST submissions.
+
+* setHeader() now enumerates through the _http_header object with
+propertyIsEnumerable to prevent collisions with members added to Object via
+prototype.
+
+*** version 0.10.0 ***
+
+* handleTransactionResponse() now treats the full HTTP 2xx range as a success
+case, instead of just HTTP 200.
+
+* To accommodate multiple field values in Mozilla/Firefox, multiple initHeader
+calls with the same label will now result in the values concatenated to a
+comma- delimited string value.
+Example:
+Setting Content-Type:'application/x-www-form-urlencoded' and Content-
+Type:'text/xml' will result in Content-Type:'application/x-www-form-urlencoded,
+text/xml'.
+
+* Default polling interval lowered to 50ms.
+
+* YAHOO.util.Connect.setPollingInterval() will allow you to set a polling
+interval -- in milliseconds -- to override the default value.
+
+* YAHOO.util.Connect.getResponseHeader[headerLabel] now supported as a response
+object property to provide symmetry with the native XHR object's property.
+Example:
+YAHOO.util.Connect.getResponseHeader['Content-Length'] will return the value
+for the Content-Length header, if the header is available.
+
+* YAHOO.util.Connect.allResponseHeaders property renamed to
+getAllResponseHeaders to provide symmetry with the native XHR object's
+property.
+
+* YAHOO.util.Connect.setForm() now supports HTTP GET as well as HTTP POST.
+
+* YAHOO.util.Connect.setForm() now accepts an HTML form object as well as its
+name attribute value.
+
+* YAHOO.util.Connect.setForm() will not submit HTML form fields that are
+disabled or do not have a name attribute value.
+
+* [FIXED] Response exceptions result in infinite callback loop in
+Mozilla/Firefox.
+
+* [FIXED] YAHOO.util.Connect.abort() now properly clears polling interval.
+
+* [FIXED] isCallInProgress() now verifies whether XHR instance still exists,
+and returns false if the connection object is no longer available.
+
+*** version 0.9.0 ***
+
+* Initial release
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/yui/connection/connection-debug.js b/lib/yui/connection/connection-debug.js
index 5731c0c8c7..78cda4a855 100755
--- a/lib/yui/connection/connection-debug.js
+++ b/lib/yui/connection/connection-debug.js
@@ -1,977 +1,983 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 0.12.1
-*/
-
-/**
- * @description
- * The Connection Manager provides a simplified interface to the XMLHttpRequest
- * object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the
- * interactive states and server response, returning the results to a pre-defined
- * callback you create.
- *
- * @namespace YAHOO.util
- * @module Connection
- * @Class Connect
- */
-YAHOO.util.Connect =
-{
- /**
- * @description Array of MSFT ActiveX ids for XMLHttpRequest.
- * @property _msxml_progid
- * @private
- * @static
- * @type array
- */
- _msxml_progid:[
- 'MSXML2.XMLHTTP.3.0',
- 'MSXML2.XMLHTTP',
- 'Microsoft.XMLHTTP'
- ],
-
- /**
- * @description Object literal of HTTP header(s)
- * @property _http_header
- * @private
- * @static
- * @type object
- */
- _http_header:{},
-
- /**
- * @description Determines if HTTP headers are set.
- * @property _has_http_headers
- * @private
- * @static
- * @type boolean
- */
- _has_http_headers:false,
-
- /**
- * @description Determines if a default header of
- * Content-Type of 'application/x-www-form-urlencoded'
- * will be added to any client HTTP headers sent for POST
- * transactions.
- * @property _use_default_post_header
- * @private
- * @static
- * @type boolean
- */
- _use_default_post_header:true,
-
- /**
- * @description Determines if a default header of
- * Content-Type of 'application/x-www-form-urlencoded'
- * will be added to any client HTTP headers sent for POST
- * transactions.
- * @property _default_post_header
- * @private
- * @static
- * @type boolean
- */
- _default_post_header:'application/x-www-form-urlencoded',
-
- /**
- * @description Property modified by setForm() to determine if the data
- * should be submitted as an HTML form.
- * @property _isFormSubmit
- * @private
- * @static
- * @type boolean
- */
- _isFormSubmit:false,
-
- /**
- * @description Property modified by setForm() to determine if a file(s)
- * upload is expected.
- * @property _isFileUpload
- * @private
- * @static
- * @type boolean
- */
- _isFileUpload:false,
-
- /**
- * @description Property modified by setForm() to set a reference to the HTML
- * form node if the desired action is file upload.
- * @property _formNode
- * @private
- * @static
- * @type object
- */
- _formNode:null,
-
- /**
- * @description Property modified by setForm() to set the HTML form data
- * for each transaction.
- * @property _sFormData
- * @private
- * @static
- * @type string
- */
- _sFormData:null,
-
- /**
- * @description Collection of polling references to the polling mechanism in handleReadyState.
- * @property _poll
- * @private
- * @static
- * @type object
- */
- _poll:{},
-
- /**
- * @description Queue of timeout values for each transaction callback with a defined timeout value.
- * @property _timeOut
- * @private
- * @static
- * @type object
- */
- _timeOut:{},
-
- /**
- * @description The polling frequency, in milliseconds, for HandleReadyState.
- * when attempting to determine a transaction's XHR readyState.
- * The default is 50 milliseconds.
- * @property _polling_interval
- * @private
- * @static
- * @type int
- */
- _polling_interval:50,
-
- /**
- * @description A transaction counter that increments the transaction id for each transaction.
- * @property _transaction_id
- * @private
- * @static
- * @type int
- */
- _transaction_id:0,
-
- /**
- * @description Member to add an ActiveX id to the existing xml_progid array.
- * In the event(unlikely) a new ActiveX id is introduced, it can be added
- * without internal code modifications.
- * @method setProgId
- * @public
- * @static
- * @param {string} id The ActiveX id to be added to initialize the XHR object.
- * @return void
- */
- setProgId:function(id)
- {
- this._msxml_progid.unshift(id);
- YAHOO.log('ActiveX Program Id ' + id + ' added to _msxml_progid.', 'info', 'Connection');
- },
-
- /**
- * @description Member to enable or disable the default POST header.
- * @method setDefaultPostHeader
- * @public
- * @static
- * @param {boolean} b Set and use default header - true or false .
- * @return void
- */
- setDefaultPostHeader:function(b)
- {
- this._use_default_post_header = b;
- YAHOO.log('Use default POST header set to ' + b, 'info', 'Connection');
- },
-
- /**
- * @description Member to modify the default polling interval.
- * @method setPollingInterval
- * @public
- * @static
- * @param {int} i The polling interval in milliseconds.
- * @return void
- */
- setPollingInterval:function(i)
- {
- if(typeof i == 'number' && isFinite(i)){
- this._polling_interval = i;
- YAHOO.log('Default polling interval set to ' + i +'ms', 'info', 'Connection');
- }
- },
-
- /**
- * @description Instantiates a XMLHttpRequest object and returns an object with two properties:
- * the XMLHttpRequest instance and the transaction id.
- * @method createXhrObject
- * @private
- * @static
- * @param {int} transactionId Property containing the transaction id for this transaction.
- * @return object
- */
- createXhrObject:function(transactionId)
- {
- var obj,http;
- try
- {
- // Instantiates XMLHttpRequest in non-IE browsers and assigns to http.
- http = new XMLHttpRequest();
- // Object literal with http and tId properties
- obj = { conn:http, tId:transactionId };
- YAHOO.log('XHR object created for transaction ' + transactionId, 'info', 'Connection');
- }
- catch(e)
- {
- for(var i=0; i= 200 && httpStatus < 300){
- responseObject = this.createResponseObject(o, callback.argument);
- if(callback.success){
- if(!callback.scope){
- callback.success(responseObject);
- YAHOO.log('Success callback. HTTP code is ' + httpStatus, 'info', 'Connection');
- }
- else{
- // If a scope property is defined, the callback will be fired from
- // the context of the object.
- callback.success.apply(callback.scope, [responseObject]);
- YAHOO.log('Success callback with scope. HTTP code is ' + httpStatus, 'info', 'Connection');
- }
- }
- }
- else{
- switch(httpStatus){
- // The following cases are wininet.dll error codes that may be encountered.
- case 12002: // Server timeout
- case 12029: // 12029 to 12031 correspond to dropped connections.
- case 12030:
- case 12031:
- case 12152: // Connection closed by server.
- case 13030: // See above comments for variable status.
- responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort?isAbort:false));
- if(callback.failure){
- if(!callback.scope){
- callback.failure(responseObject);
- YAHOO.log('Failure callback. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection');
- }
- else{
- callback.failure.apply(callback.scope, [responseObject]);
- YAHOO.log('Failure callback with scope. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection');
- }
- }
- break;
- default:
- responseObject = this.createResponseObject(o, callback.argument);
- if(callback.failure){
- if(!callback.scope){
- callback.failure(responseObject);
- YAHOO.log('Failure callback. HTTP status code is ' + httpStatus, 'warn', 'Connection');
- }
- else{
- callback.failure.apply(callback.scope, [responseObject]);
- YAHOO.log('Failure callback with scope. HTTP status code is ' + httpStatus, 'warn', 'Connection');
- }
- }
- }
- }
-
- this.releaseObject(o);
- responseObject = null;
- },
-
- /**
- * @description This method evaluates the server response, creates and returns the results via
- * its properties. Success and failure cases will differ in the response
- * object's property values.
- * @method createResponseObject
- * @private
- * @static
- * @param {object} o The connection object
- * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
- * @return {object}
- */
- createResponseObject:function(o, callbackArg)
- {
- var obj = {};
- var headerObj = {};
-
- try
- {
- var headerStr = o.conn.getAllResponseHeaders();
- var header = headerStr.split('\n');
- for(var i=0; i ');
-
- // IE will throw a security exception in an SSL environment if the
- // iframe source is undefined.
- if(typeof secureUri == 'boolean'){
- io.src = 'javascript:false';
- }
- else if(typeof secureURI == 'string'){
- // Deprecated
- io.src = secureUri;
- }
- }
- else{
- var io = document.createElement('iframe');
- io.id = frameId;
- io.name = frameId;
- }
-
- io.style.position = 'absolute';
- io.style.top = '-1000px';
- io.style.left = '-1000px';
-
- document.body.appendChild(io);
- YAHOO.log('File upload iframe created. Id is:' + frameId, 'info', 'Connection');
- },
-
- /**
- * @description Parses the POST data and creates hidden form elements
- * for each key-value, and appends them to the HTML form object.
- * @method appendPostData
- * @private
- * @static
- * @param {string} postData The HTTP POST data
- * @return {array} formElements Collection of hidden fields.
- */
- appendPostData:function(postData)
- {
- var formElements = [];
- var postMessage = postData.split('&');
- for(var i=0; i < postMessage.length; i++){
- var delimitPos = postMessage[i].indexOf('=');
- if(delimitPos != -1){
- formElements[i] = document.createElement('input');
- formElements[i].type = 'hidden';
- formElements[i].name = postMessage[i].substring(0,delimitPos);
- formElements[i].value = postMessage[i].substring(delimitPos+1);
- this._formNode.appendChild(formElements[i]);
- }
- }
-
- return formElements;
- },
-
- /**
- * @description Uploads HTML form, including files/attachments, to the
- * iframe created in createFrame.
- * @method uploadFile
- * @private
- * @static
- * @param {int} id The transaction id.
- * @param {object} callback - User-defined callback object.
- * @param {string} uri Fully qualified path of resource.
- * @return {void}
- */
- uploadFile:function(id, callback, uri, postData){
-
- // Each iframe has an id prefix of "yuiIO" followed
- // by the unique transaction id.
- var frameId = 'yuiIO' + id;
- var io = document.getElementById(frameId);
-
- // Initialize the HTML form properties in case they are
- // not defined in the HTML form.
- this._formNode.action = uri;
- this._formNode.method = 'POST';
- this._formNode.target = frameId;
-
- if(this._formNode.encoding){
- // IE does not respect property enctype for HTML forms.
- // Instead use property encoding.
- this._formNode.encoding = 'multipart/form-data';
- }
- else{
- this._formNode.enctype = 'multipart/form-data';
- }
-
-
- if(postData){
- var oElements = this.appendPostData(postData);
- }
-
- this._formNode.submit();
-
- if(oElements && oElements.length > 0){
- for(var i=0; i < oElements.length; i++){
- this._formNode.removeChild(oElements[i]);
- }
- }
-
- // Reset HTML form status properties.
- this.resetFormState();
-
- // Create the upload callback handler that fires when the iframe
- // receives the load event. Subsequently, the event handler is detached
- // and the iframe removed from the document.
-
- var uploadCallback = function()
- {
- var obj = {};
- obj.tId = id;
- obj.argument = callback.argument;
-
- try
- {
- obj.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
- obj.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
- }
- catch(e){}
-
- if(callback.upload){
- if(!callback.scope){
- callback.upload(obj);
- YAHOO.log('Upload callback.', 'info', 'Connection');
- }
- else{
- callback.upload.apply(callback.scope, [obj]);
- YAHOO.log('Upload callback with scope.', 'info', 'Connection');
- }
- }
-
- if(YAHOO.util.Event){
- YAHOO.util.Event.removeListener(io, "load", uploadCallback);
- }
- else if(window.detachEvent){
- io.detachEvent('onload', uploadCallback);
- }
- else{
- io.removeEventListener('load', uploadCallback, false);
- }
- setTimeout(
- function(){
- document.body.removeChild(io);
- YAHOO.log('File upload iframe destroyed. Id is:' + frameId, 'info', 'Connection');
- }, 100);
- };
-
-
- // Bind the onload handler to the iframe to detect the file upload response.
- if(YAHOO.util.Event){
- YAHOO.util.Event.addListener(io, "load", uploadCallback);
- }
- else if(window.attachEvent){
- io.attachEvent('onload', uploadCallback);
- }
- else{
- io.addEventListener('load', uploadCallback, false);
- }
- },
-
- /**
- * @description Method to terminate a transaction, if it has not reached readyState 4.
- * @method abort
- * @public
- * @static
- * @param {object} o The connection object returned by asyncRequest.
- * @param {object} callback User-defined callback object.
- * @param {string} isTimeout boolean to indicate if abort was a timeout.
- * @return {boolean}
- */
- abort:function(o, callback, isTimeout)
- {
- if(this.isCallInProgress(o)){
- o.conn.abort();
- window.clearInterval(this._poll[o.tId]);
- delete this._poll[o.tId];
- if(isTimeout){
- delete this._timeOut[o.tId];
- }
-
- this.handleTransactionResponse(o, callback, true);
- YAHOO.log('Transaction ' + o.tId + ' aborted.', 'info', 'Connection');
-
- return true;
- }
- else{
- YAHOO.log('Transaction ' + o.tId + ' abort call failed.', 'warn', 'Connection');
- return false;
- }
- },
-
- /**
- * Public method to check if the transaction is still being processed.
- *
- * @method isCallInProgress
- * @public
- * @static
- * @param {object} o The connection object returned by asyncRequest
- * @return {boolean}
- */
- isCallInProgress:function(o)
- {
- // if the XHR object assigned to the transaction has not been dereferenced,
- // then check its readyState status. Otherwise, return false.
- if(o.conn){
- return o.conn.readyState != 4 && o.conn.readyState != 0;
- }
- else{
- //The XHR object has been destroyed.
- return false;
- }
- },
-
- /**
- * @description Dereference the XHR instance and the connection object after the transaction is completed.
- * @method releaseObject
- * @private
- * @static
- * @param {object} o The connection object
- * @return {void}
- */
- releaseObject:function(o)
- {
- //dereference the XHR instance.
- o.conn = null;
- YAHOO.log('Connection object for transaction ' + o.tId + ' destroyed.', 'info', 'Connection');
- //dereference the connection object.
- o = null;
- }
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/**
+ * The Connection Manager provides a simplified interface to the XMLHttpRequest
+ * object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the
+ * interactive states and server response, returning the results to a pre-defined
+ * callback you create.
+ *
+ * @namespace YAHOO.util
+ * @module connection
+ * @requires yahoo
+ */
+
+/**
+ * The Connection Manager singleton provides methods for creating and managing
+ * asynchronous transactions.
+ *
+ * @class Connect
+ */
+
+YAHOO.util.Connect =
+{
+ /**
+ * @description Array of MSFT ActiveX ids for XMLHttpRequest.
+ * @property _msxml_progid
+ * @private
+ * @static
+ * @type array
+ */
+ _msxml_progid:[
+ 'MSXML2.XMLHTTP.3.0',
+ 'MSXML2.XMLHTTP',
+ 'Microsoft.XMLHTTP'
+ ],
+
+ /**
+ * @description Object literal of HTTP header(s)
+ * @property _http_header
+ * @private
+ * @static
+ * @type object
+ */
+ _http_header:{},
+
+ /**
+ * @description Determines if HTTP headers are set.
+ * @property _has_http_headers
+ * @private
+ * @static
+ * @type boolean
+ */
+ _has_http_headers:false,
+
+ /**
+ * @description Determines if a default header of
+ * Content-Type of 'application/x-www-form-urlencoded'
+ * will be added to any client HTTP headers sent for POST
+ * transactions.
+ * @property _use_default_post_header
+ * @private
+ * @static
+ * @type boolean
+ */
+ _use_default_post_header:true,
+
+ /**
+ * @description Determines if a default header of
+ * Content-Type of 'application/x-www-form-urlencoded'
+ * will be added to any client HTTP headers sent for POST
+ * transactions.
+ * @property _default_post_header
+ * @private
+ * @static
+ * @type boolean
+ */
+ _default_post_header:'application/x-www-form-urlencoded',
+
+ /**
+ * @description Property modified by setForm() to determine if the data
+ * should be submitted as an HTML form.
+ * @property _isFormSubmit
+ * @private
+ * @static
+ * @type boolean
+ */
+ _isFormSubmit:false,
+
+ /**
+ * @description Property modified by setForm() to determine if a file(s)
+ * upload is expected.
+ * @property _isFileUpload
+ * @private
+ * @static
+ * @type boolean
+ */
+ _isFileUpload:false,
+
+ /**
+ * @description Property modified by setForm() to set a reference to the HTML
+ * form node if the desired action is file upload.
+ * @property _formNode
+ * @private
+ * @static
+ * @type object
+ */
+ _formNode:null,
+
+ /**
+ * @description Property modified by setForm() to set the HTML form data
+ * for each transaction.
+ * @property _sFormData
+ * @private
+ * @static
+ * @type string
+ */
+ _sFormData:null,
+
+ /**
+ * @description Collection of polling references to the polling mechanism in handleReadyState.
+ * @property _poll
+ * @private
+ * @static
+ * @type object
+ */
+ _poll:{},
+
+ /**
+ * @description Queue of timeout values for each transaction callback with a defined timeout value.
+ * @property _timeOut
+ * @private
+ * @static
+ * @type object
+ */
+ _timeOut:{},
+
+ /**
+ * @description The polling frequency, in milliseconds, for HandleReadyState.
+ * when attempting to determine a transaction's XHR readyState.
+ * The default is 50 milliseconds.
+ * @property _polling_interval
+ * @private
+ * @static
+ * @type int
+ */
+ _polling_interval:50,
+
+ /**
+ * @description A transaction counter that increments the transaction id for each transaction.
+ * @property _transaction_id
+ * @private
+ * @static
+ * @type int
+ */
+ _transaction_id:0,
+
+ /**
+ * @description Member to add an ActiveX id to the existing xml_progid array.
+ * In the event(unlikely) a new ActiveX id is introduced, it can be added
+ * without internal code modifications.
+ * @method setProgId
+ * @public
+ * @static
+ * @param {string} id The ActiveX id to be added to initialize the XHR object.
+ * @return void
+ */
+ setProgId:function(id)
+ {
+ this._msxml_progid.unshift(id);
+ YAHOO.log('ActiveX Program Id ' + id + ' added to _msxml_progid.', 'info', 'Connection');
+ },
+
+ /**
+ * @description Member to enable or disable the default POST header.
+ * @method setDefaultPostHeader
+ * @public
+ * @static
+ * @param {boolean} b Set and use default header - true or false .
+ * @return void
+ */
+ setDefaultPostHeader:function(b)
+ {
+ this._use_default_post_header = b;
+ YAHOO.log('Use default POST header set to ' + b, 'info', 'Connection');
+ },
+
+ /**
+ * @description Member to modify the default polling interval.
+ * @method setPollingInterval
+ * @public
+ * @static
+ * @param {int} i The polling interval in milliseconds.
+ * @return void
+ */
+ setPollingInterval:function(i)
+ {
+ if(typeof i == 'number' && isFinite(i)){
+ this._polling_interval = i;
+ YAHOO.log('Default polling interval set to ' + i +'ms', 'info', 'Connection');
+ }
+ },
+
+ /**
+ * @description Instantiates a XMLHttpRequest object and returns an object with two properties:
+ * the XMLHttpRequest instance and the transaction id.
+ * @method createXhrObject
+ * @private
+ * @static
+ * @param {int} transactionId Property containing the transaction id for this transaction.
+ * @return object
+ */
+ createXhrObject:function(transactionId)
+ {
+ var obj,http;
+ try
+ {
+ // Instantiates XMLHttpRequest in non-IE browsers and assigns to http.
+ http = new XMLHttpRequest();
+ // Object literal with http and tId properties
+ obj = { conn:http, tId:transactionId };
+ YAHOO.log('XHR object created for transaction ' + transactionId, 'info', 'Connection');
+ }
+ catch(e)
+ {
+ for(var i=0; i= 200 && httpStatus < 300){
+ responseObject = this.createResponseObject(o, callback.argument);
+ if(callback.success){
+ if(!callback.scope){
+ callback.success(responseObject);
+ YAHOO.log('Success callback. HTTP code is ' + httpStatus, 'info', 'Connection');
+ }
+ else{
+ // If a scope property is defined, the callback will be fired from
+ // the context of the object.
+ callback.success.apply(callback.scope, [responseObject]);
+ YAHOO.log('Success callback with scope. HTTP code is ' + httpStatus, 'info', 'Connection');
+ }
+ }
+ }
+ else{
+ switch(httpStatus){
+ // The following cases are wininet.dll error codes that may be encountered.
+ case 12002: // Server timeout
+ case 12029: // 12029 to 12031 correspond to dropped connections.
+ case 12030:
+ case 12031:
+ case 12152: // Connection closed by server.
+ case 13030: // See above comments for variable status.
+ responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort?isAbort:false));
+ if(callback.failure){
+ if(!callback.scope){
+ callback.failure(responseObject);
+ YAHOO.log('Failure callback. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection');
+ }
+ else{
+ callback.failure.apply(callback.scope, [responseObject]);
+ YAHOO.log('Failure callback with scope. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection');
+ }
+ }
+ break;
+ default:
+ responseObject = this.createResponseObject(o, callback.argument);
+ if(callback.failure){
+ if(!callback.scope){
+ callback.failure(responseObject);
+ YAHOO.log('Failure callback. HTTP status code is ' + httpStatus, 'warn', 'Connection');
+ }
+ else{
+ callback.failure.apply(callback.scope, [responseObject]);
+ YAHOO.log('Failure callback with scope. HTTP status code is ' + httpStatus, 'warn', 'Connection');
+ }
+ }
+ }
+ }
+
+ this.releaseObject(o);
+ responseObject = null;
+ },
+
+ /**
+ * @description This method evaluates the server response, creates and returns the results via
+ * its properties. Success and failure cases will differ in the response
+ * object's property values.
+ * @method createResponseObject
+ * @private
+ * @static
+ * @param {object} o The connection object
+ * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
+ * @return {object}
+ */
+ createResponseObject:function(o, callbackArg)
+ {
+ var obj = {};
+ var headerObj = {};
+
+ try
+ {
+ var headerStr = o.conn.getAllResponseHeaders();
+ var header = headerStr.split('\n');
+ for(var i=0; i ');
+
+ // IE will throw a security exception in an SSL environment if the
+ // iframe source is undefined.
+ if(typeof secureUri == 'boolean'){
+ io.src = 'javascript:false';
+ }
+ else if(typeof secureURI == 'string'){
+ // Deprecated
+ io.src = secureUri;
+ }
+ }
+ else{
+ var io = document.createElement('iframe');
+ io.id = frameId;
+ io.name = frameId;
+ }
+
+ io.style.position = 'absolute';
+ io.style.top = '-1000px';
+ io.style.left = '-1000px';
+
+ document.body.appendChild(io);
+ YAHOO.log('File upload iframe created. Id is:' + frameId, 'info', 'Connection');
+ },
+
+ /**
+ * @description Parses the POST data and creates hidden form elements
+ * for each key-value, and appends them to the HTML form object.
+ * @method appendPostData
+ * @private
+ * @static
+ * @param {string} postData The HTTP POST data
+ * @return {array} formElements Collection of hidden fields.
+ */
+ appendPostData:function(postData)
+ {
+ var formElements = [];
+ var postMessage = postData.split('&');
+ for(var i=0; i < postMessage.length; i++){
+ var delimitPos = postMessage[i].indexOf('=');
+ if(delimitPos != -1){
+ formElements[i] = document.createElement('input');
+ formElements[i].type = 'hidden';
+ formElements[i].name = postMessage[i].substring(0,delimitPos);
+ formElements[i].value = postMessage[i].substring(delimitPos+1);
+ this._formNode.appendChild(formElements[i]);
+ }
+ }
+
+ return formElements;
+ },
+
+ /**
+ * @description Uploads HTML form, including files/attachments, to the
+ * iframe created in createFrame.
+ * @method uploadFile
+ * @private
+ * @static
+ * @param {int} id The transaction id.
+ * @param {object} callback - User-defined callback object.
+ * @param {string} uri Fully qualified path of resource.
+ * @return {void}
+ */
+ uploadFile:function(id, callback, uri, postData){
+
+ // Each iframe has an id prefix of "yuiIO" followed
+ // by the unique transaction id.
+ var frameId = 'yuiIO' + id;
+ var io = document.getElementById(frameId);
+
+ // Initialize the HTML form properties in case they are
+ // not defined in the HTML form.
+ this._formNode.action = uri;
+ this._formNode.method = 'POST';
+ this._formNode.target = frameId;
+
+ if(this._formNode.encoding){
+ // IE does not respect property enctype for HTML forms.
+ // Instead use property encoding.
+ this._formNode.encoding = 'multipart/form-data';
+ }
+ else{
+ this._formNode.enctype = 'multipart/form-data';
+ }
+
+
+ if(postData){
+ var oElements = this.appendPostData(postData);
+ }
+
+ this._formNode.submit();
+
+ if(oElements && oElements.length > 0){
+ for(var i=0; i < oElements.length; i++){
+ this._formNode.removeChild(oElements[i]);
+ }
+ }
+
+ // Reset HTML form status properties.
+ this.resetFormState();
+
+ // Create the upload callback handler that fires when the iframe
+ // receives the load event. Subsequently, the event handler is detached
+ // and the iframe removed from the document.
+
+ var uploadCallback = function()
+ {
+ var obj = {};
+ obj.tId = id;
+ obj.argument = callback.argument;
+
+ try
+ {
+ obj.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
+ obj.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
+ }
+ catch(e){}
+
+ if(callback.upload){
+ if(!callback.scope){
+ callback.upload(obj);
+ YAHOO.log('Upload callback.', 'info', 'Connection');
+ }
+ else{
+ callback.upload.apply(callback.scope, [obj]);
+ YAHOO.log('Upload callback with scope.', 'info', 'Connection');
+ }
+ }
+
+ if(YAHOO.util.Event){
+ YAHOO.util.Event.removeListener(io, "load", uploadCallback);
+ }
+ else if(window.detachEvent){
+ io.detachEvent('onload', uploadCallback);
+ }
+ else{
+ io.removeEventListener('load', uploadCallback, false);
+ }
+ setTimeout(
+ function(){
+ document.body.removeChild(io);
+ YAHOO.log('File upload iframe destroyed. Id is:' + frameId, 'info', 'Connection');
+ }, 100);
+ };
+
+
+ // Bind the onload handler to the iframe to detect the file upload response.
+ if(YAHOO.util.Event){
+ YAHOO.util.Event.addListener(io, "load", uploadCallback);
+ }
+ else if(window.attachEvent){
+ io.attachEvent('onload', uploadCallback);
+ }
+ else{
+ io.addEventListener('load', uploadCallback, false);
+ }
+ },
+
+ /**
+ * @description Method to terminate a transaction, if it has not reached readyState 4.
+ * @method abort
+ * @public
+ * @static
+ * @param {object} o The connection object returned by asyncRequest.
+ * @param {object} callback User-defined callback object.
+ * @param {string} isTimeout boolean to indicate if abort was a timeout.
+ * @return {boolean}
+ */
+ abort:function(o, callback, isTimeout)
+ {
+ if(this.isCallInProgress(o)){
+ o.conn.abort();
+ window.clearInterval(this._poll[o.tId]);
+ delete this._poll[o.tId];
+ if(isTimeout){
+ delete this._timeOut[o.tId];
+ }
+
+ this.handleTransactionResponse(o, callback, true);
+ YAHOO.log('Transaction ' + o.tId + ' aborted.', 'info', 'Connection');
+
+ return true;
+ }
+ else{
+ YAHOO.log('Transaction ' + o.tId + ' abort call failed.', 'warn', 'Connection');
+ return false;
+ }
+ },
+
+ /**
+ * Public method to check if the transaction is still being processed.
+ *
+ * @method isCallInProgress
+ * @public
+ * @static
+ * @param {object} o The connection object returned by asyncRequest
+ * @return {boolean}
+ */
+ isCallInProgress:function(o)
+ {
+ // if the XHR object assigned to the transaction has not been dereferenced,
+ // then check its readyState status. Otherwise, return false.
+ if(o.conn){
+ return o.conn.readyState != 4 && o.conn.readyState != 0;
+ }
+ else{
+ //The XHR object has been destroyed.
+ return false;
+ }
+ },
+
+ /**
+ * @description Dereference the XHR instance and the connection object after the transaction is completed.
+ * @method releaseObject
+ * @private
+ * @static
+ * @param {object} o The connection object
+ * @return {void}
+ */
+ releaseObject:function(o)
+ {
+ //dereference the XHR instance.
+ o.conn = null;
+ YAHOO.log('Connection object for transaction ' + o.tId + ' destroyed.', 'info', 'Connection');
+ //dereference the connection object.
+ o = null;
+ }
};
\ No newline at end of file
diff --git a/lib/yui/connection/connection-min.js b/lib/yui/connection/connection-min.js
index dbdef3bdcd..7d44fbac29 100755
--- a/lib/yui/connection/connection-min.js
+++ b/lib/yui/connection/connection-min.js
@@ -1,99 +1,104 @@
-/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.12.1 */
-YAHOO.util.Connect={_msxml_progid:['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'],_http_header:{},_has_http_headers:false,_use_default_post_header:true,_default_post_header:'application/x-www-form-urlencoded',_isFormSubmit:false,_isFileUpload:false,_formNode:null,_sFormData:null,_poll:{},_timeOut:{},_polling_interval:50,_transaction_id:0,setProgId:function(id)
-{this._msxml_progid.unshift(id);},setDefaultPostHeader:function(b)
-{this._use_default_post_header=b;},setPollingInterval:function(i)
-{if(typeof i=='number'&&isFinite(i)){this._polling_interval=i;}},createXhrObject:function(transactionId)
-{var obj,http;try
-{http=new XMLHttpRequest();obj={conn:http,tId:transactionId};}
-catch(e)
-{for(var i=0;i=200&&httpStatus<300){try
-{responseObject=this.createResponseObject(o,callback.argument);if(callback.success){if(!callback.scope){callback.success(responseObject);}
-else{callback.success.apply(callback.scope,[responseObject]);}}}
-catch(e){}}
-else{try
-{switch(httpStatus){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:responseObject=this.createExceptionObject(o.tId,callback.argument,(isAbort?isAbort:false));if(callback.failure){if(!callback.scope){callback.failure(responseObject);}
-else{callback.failure.apply(callback.scope,[responseObject]);}}
-break;default:responseObject=this.createResponseObject(o,callback.argument);if(callback.failure){if(!callback.scope){callback.failure(responseObject);}
-else{callback.failure.apply(callback.scope,[responseObject]);}}}}
-catch(e){}}
-this.releaseObject(o);responseObject=null;},createResponseObject:function(o,callbackArg)
-{var obj={};var headerObj={};try
-{var headerStr=o.conn.getAllResponseHeaders();var header=headerStr.split('\n');for(var i=0;i ');if(typeof secureUri=='boolean'){io.src='javascript:false';}
-else if(typeof secureURI=='string'){io.src=secureUri;}}
-else{var io=document.createElement('iframe');io.id=frameId;io.name=frameId;}
-io.style.position='absolute';io.style.top='-1000px';io.style.left='-1000px';document.body.appendChild(io);},appendPostData:function(postData)
-{var formElements=[];var postMessage=postData.split('&');for(var i=0;i0){try
-{for(var i=0;i=200&&httpStatus<300){try
+{responseObject=this.createResponseObject(o,callback.argument);if(callback.success){if(!callback.scope){callback.success(responseObject);}
+else{callback.success.apply(callback.scope,[responseObject]);}}}
+catch(e){}}
+else{try
+{switch(httpStatus){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:responseObject=this.createExceptionObject(o.tId,callback.argument,(isAbort?isAbort:false));if(callback.failure){if(!callback.scope){callback.failure(responseObject);}
+else{callback.failure.apply(callback.scope,[responseObject]);}}
+break;default:responseObject=this.createResponseObject(o,callback.argument);if(callback.failure){if(!callback.scope){callback.failure(responseObject);}
+else{callback.failure.apply(callback.scope,[responseObject]);}}}}
+catch(e){}}
+this.releaseObject(o);responseObject=null;},createResponseObject:function(o,callbackArg)
+{var obj={};var headerObj={};try
+{var headerStr=o.conn.getAllResponseHeaders();var header=headerStr.split('\n');for(var i=0;i ');if(typeof secureUri=='boolean'){io.src='javascript:false';}
+else if(typeof secureURI=='string'){io.src=secureUri;}}
+else{var io=document.createElement('iframe');io.id=frameId;io.name=frameId;}
+io.style.position='absolute';io.style.top='-1000px';io.style.left='-1000px';document.body.appendChild(io);},appendPostData:function(postData)
+{var formElements=[];var postMessage=postData.split('&');for(var i=0;i0){try
+{for(var i=0;i= 200 && httpStatus < 300){
- try
- {
- responseObject = this.createResponseObject(o, callback.argument);
- if(callback.success){
- if(!callback.scope){
- callback.success(responseObject);
- }
- else{
- // If a scope property is defined, the callback will be fired from
- // the context of the object.
- callback.success.apply(callback.scope, [responseObject]);
- }
- }
- }
- catch(e){}
- }
- else{
- try
- {
- switch(httpStatus){
- // The following cases are wininet.dll error codes that may be encountered.
- case 12002: // Server timeout
- case 12029: // 12029 to 12031 correspond to dropped connections.
- case 12030:
- case 12031:
- case 12152: // Connection closed by server.
- case 13030: // See above comments for variable status.
- responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort?isAbort:false));
- if(callback.failure){
- if(!callback.scope){
- callback.failure(responseObject);
- }
- else{
- callback.failure.apply(callback.scope, [responseObject]);
- }
- }
- break;
- default:
- responseObject = this.createResponseObject(o, callback.argument);
- if(callback.failure){
- if(!callback.scope){
- callback.failure(responseObject);
- }
- else{
- callback.failure.apply(callback.scope, [responseObject]);
- }
- }
- }
- }
- catch(e){}
- }
-
- this.releaseObject(o);
- responseObject = null;
- },
-
- /**
- * @description This method evaluates the server response, creates and returns the results via
- * its properties. Success and failure cases will differ in the response
- * object's property values.
- * @method createResponseObject
- * @private
- * @static
- * @param {object} o The connection object
- * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
- * @return {object}
- */
- createResponseObject:function(o, callbackArg)
- {
- var obj = {};
- var headerObj = {};
-
- try
- {
- var headerStr = o.conn.getAllResponseHeaders();
- var header = headerStr.split('\n');
- for(var i=0; i ');
-
- // IE will throw a security exception in an SSL environment if the
- // iframe source is undefined.
- if(typeof secureUri == 'boolean'){
- io.src = 'javascript:false';
- }
- else if(typeof secureURI == 'string'){
- // Deprecated
- io.src = secureUri;
- }
- }
- else{
- var io = document.createElement('iframe');
- io.id = frameId;
- io.name = frameId;
- }
-
- io.style.position = 'absolute';
- io.style.top = '-1000px';
- io.style.left = '-1000px';
-
- document.body.appendChild(io);
- },
-
- /**
- * @description Parses the POST data and creates hidden form elements
- * for each key-value, and appends them to the HTML form object.
- * @method appendPostData
- * @private
- * @static
- * @param {string} postData The HTTP POST data
- * @return {array} formElements Collection of hidden fields.
- */
- appendPostData:function(postData)
- {
- var formElements = [];
- var postMessage = postData.split('&');
- for(var i=0; i < postMessage.length; i++){
- var delimitPos = postMessage[i].indexOf('=');
- if(delimitPos != -1){
- formElements[i] = document.createElement('input');
- formElements[i].type = 'hidden';
- formElements[i].name = postMessage[i].substring(0,delimitPos);
- formElements[i].value = postMessage[i].substring(delimitPos+1);
- this._formNode.appendChild(formElements[i]);
- }
- }
-
- return formElements;
- },
-
- /**
- * @description Uploads HTML form, including files/attachments, to the
- * iframe created in createFrame.
- * @method uploadFile
- * @private
- * @static
- * @param {int} id The transaction id.
- * @param {object} callback - User-defined callback object.
- * @param {string} uri Fully qualified path of resource.
- * @return {void}
- */
- uploadFile:function(id, callback, uri, postData){
-
- // Each iframe has an id prefix of "yuiIO" followed
- // by the unique transaction id.
- var frameId = 'yuiIO' + id;
- var io = document.getElementById(frameId);
-
- // Initialize the HTML form properties in case they are
- // not defined in the HTML form.
- this._formNode.action = uri;
- this._formNode.method = 'POST';
- this._formNode.target = frameId;
-
- if(this._formNode.encoding){
- // IE does not respect property enctype for HTML forms.
- // Instead use property encoding.
- this._formNode.encoding = 'multipart/form-data';
- }
- else{
- this._formNode.enctype = 'multipart/form-data';
- }
-
- if(postData){
- var oElements = this.appendPostData(postData);
- }
-
- this._formNode.submit();
-
- if(oElements && oElements.length > 0){
- try
- {
- for(var i=0; i < oElements.length; i++){
- this._formNode.removeChild(oElements[i]);
- }
- }
- catch(e){}
- }
-
- // Reset HTML form status properties.
- this.resetFormState();
-
- // Create the upload callback handler that fires when the iframe
- // receives the load event. Subsequently, the event handler is detached
- // and the iframe removed from the document.
-
- var uploadCallback = function()
- {
- var obj = {};
- obj.tId = id;
- obj.argument = callback.argument;
-
- try
- {
- obj.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
- obj.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
- }
- catch(e){}
-
- if(callback.upload){
- if(!callback.scope){
- callback.upload(obj);
- }
- else{
- callback.upload.apply(callback.scope, [obj]);
- }
- }
-
- if(YAHOO.util.Event){
- YAHOO.util.Event.removeListener(io, "load", uploadCallback);
- }
- else if(window.detachEvent){
- io.detachEvent('onload', uploadCallback);
- }
- else{
- io.removeEventListener('load', uploadCallback, false);
- }
- setTimeout(function(){ document.body.removeChild(io); }, 100);
- };
-
-
- // Bind the onload handler to the iframe to detect the file upload response.
- if(YAHOO.util.Event){
- YAHOO.util.Event.addListener(io, "load", uploadCallback);
- }
- else if(window.attachEvent){
- io.attachEvent('onload', uploadCallback);
- }
- else{
- io.addEventListener('load', uploadCallback, false);
- }
- },
-
- /**
- * @description Method to terminate a transaction, if it has not reached readyState 4.
- * @method abort
- * @public
- * @static
- * @param {object} o The connection object returned by asyncRequest.
- * @param {object} callback User-defined callback object.
- * @param {string} isTimeout boolean to indicate if abort was a timeout.
- * @return {boolean}
- */
- abort:function(o, callback, isTimeout)
- {
- if(this.isCallInProgress(o)){
- o.conn.abort();
- window.clearInterval(this._poll[o.tId]);
- delete this._poll[o.tId];
- if(isTimeout){
- delete this._timeOut[o.tId];
- }
-
- this.handleTransactionResponse(o, callback, true);
-
- return true;
- }
- else{
- return false;
- }
- },
-
- /**
- * Public method to check if the transaction is still being processed.
- *
- * @method isCallInProgress
- * @public
- * @static
- * @param {object} o The connection object returned by asyncRequest
- * @return {boolean}
- */
- isCallInProgress:function(o)
- {
- // if the XHR object assigned to the transaction has not been dereferenced,
- // then check its readyState status. Otherwise, return false.
- if(o.conn){
- return o.conn.readyState != 4 && o.conn.readyState != 0;
- }
- else{
- //The XHR object has been destroyed.
- return false;
- }
- },
-
- /**
- * @description Dereference the XHR instance and the connection object after the transaction is completed.
- * @method releaseObject
- * @private
- * @static
- * @param {object} o The connection object
- * @return {void}
- */
- releaseObject:function(o)
- {
- //dereference the XHR instance.
- o.conn = null;
- //dereference the connection object.
- o = null;
- }
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/**
+ * The Connection Manager provides a simplified interface to the XMLHttpRequest
+ * object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the
+ * interactive states and server response, returning the results to a pre-defined
+ * callback you create.
+ *
+ * @namespace YAHOO.util
+ * @module connection
+ * @requires yahoo
+ */
+
+/**
+ * The Connection Manager singleton provides methods for creating and managing
+ * asynchronous transactions.
+ *
+ * @class Connect
+ */
+YAHOO.util.Connect =
+{
+ /**
+ * @description Array of MSFT ActiveX ids for XMLHttpRequest.
+ * @property _msxml_progid
+ * @private
+ * @static
+ * @type array
+ */
+ _msxml_progid:[
+ 'MSXML2.XMLHTTP.3.0',
+ 'MSXML2.XMLHTTP',
+ 'Microsoft.XMLHTTP'
+ ],
+
+ /**
+ * @description Object literal of HTTP header(s)
+ * @property _http_header
+ * @private
+ * @static
+ * @type object
+ */
+ _http_header:{},
+
+ /**
+ * @description Determines if HTTP headers are set.
+ * @property _has_http_headers
+ * @private
+ * @static
+ * @type boolean
+ */
+ _has_http_headers:false,
+
+ /**
+ * @description Determines if a default header of
+ * Content-Type of 'application/x-www-form-urlencoded'
+ * will be added to any client HTTP headers sent for POST
+ * transactions.
+ * @property _use_default_post_header
+ * @private
+ * @static
+ * @type boolean
+ */
+ _use_default_post_header:true,
+
+ /**
+ * @description Determines if a default header of
+ * Content-Type of 'application/x-www-form-urlencoded'
+ * will be added to any client HTTP headers sent for POST
+ * transactions.
+ * @property _default_post_header
+ * @private
+ * @static
+ * @type boolean
+ */
+ _default_post_header:'application/x-www-form-urlencoded',
+
+ /**
+ * @description Property modified by setForm() to determine if the data
+ * should be submitted as an HTML form.
+ * @property _isFormSubmit
+ * @private
+ * @static
+ * @type boolean
+ */
+ _isFormSubmit:false,
+
+ /**
+ * @description Property modified by setForm() to determine if a file(s)
+ * upload is expected.
+ * @property _isFileUpload
+ * @private
+ * @static
+ * @type boolean
+ */
+ _isFileUpload:false,
+
+ /**
+ * @description Property modified by setForm() to set a reference to the HTML
+ * form node if the desired action is file upload.
+ * @property _formNode
+ * @private
+ * @static
+ * @type object
+ */
+ _formNode:null,
+
+ /**
+ * @description Property modified by setForm() to set the HTML form data
+ * for each transaction.
+ * @property _sFormData
+ * @private
+ * @static
+ * @type string
+ */
+ _sFormData:null,
+
+ /**
+ * @description Collection of polling references to the polling mechanism in handleReadyState.
+ * @property _poll
+ * @private
+ * @static
+ * @type object
+ */
+ _poll:{},
+
+ /**
+ * @description Queue of timeout values for each transaction callback with a defined timeout value.
+ * @property _timeOut
+ * @private
+ * @static
+ * @type object
+ */
+ _timeOut:{},
+
+ /**
+ * @description The polling frequency, in milliseconds, for HandleReadyState.
+ * when attempting to determine a transaction's XHR readyState.
+ * The default is 50 milliseconds.
+ * @property _polling_interval
+ * @private
+ * @static
+ * @type int
+ */
+ _polling_interval:50,
+
+ /**
+ * @description A transaction counter that increments the transaction id for each transaction.
+ * @property _transaction_id
+ * @private
+ * @static
+ * @type int
+ */
+ _transaction_id:0,
+
+ /**
+ * @description Member to add an ActiveX id to the existing xml_progid array.
+ * In the event(unlikely) a new ActiveX id is introduced, it can be added
+ * without internal code modifications.
+ * @method setProgId
+ * @public
+ * @static
+ * @param {string} id The ActiveX id to be added to initialize the XHR object.
+ * @return void
+ */
+ setProgId:function(id)
+ {
+ this._msxml_progid.unshift(id);
+ },
+
+ /**
+ * @description Member to enable or disable the default POST header.
+ * @method setDefaultPostHeader
+ * @public
+ * @static
+ * @param {boolean} b Set and use default header - true or false .
+ * @return void
+ */
+ setDefaultPostHeader:function(b)
+ {
+ this._use_default_post_header = b;
+ },
+
+ /**
+ * @description Member to modify the default polling interval.
+ * @method setPollingInterval
+ * @public
+ * @static
+ * @param {int} i The polling interval in milliseconds.
+ * @return void
+ */
+ setPollingInterval:function(i)
+ {
+ if(typeof i == 'number' && isFinite(i)){
+ this._polling_interval = i;
+ }
+ },
+
+ /**
+ * @description Instantiates a XMLHttpRequest object and returns an object with two properties:
+ * the XMLHttpRequest instance and the transaction id.
+ * @method createXhrObject
+ * @private
+ * @static
+ * @param {int} transactionId Property containing the transaction id for this transaction.
+ * @return object
+ */
+ createXhrObject:function(transactionId)
+ {
+ var obj,http;
+ try
+ {
+ // Instantiates XMLHttpRequest in non-IE browsers and assigns to http.
+ http = new XMLHttpRequest();
+ // Object literal with http and tId properties
+ obj = { conn:http, tId:transactionId };
+ }
+ catch(e)
+ {
+ for(var i=0; i= 200 && httpStatus < 300){
+ try
+ {
+ responseObject = this.createResponseObject(o, callback.argument);
+ if(callback.success){
+ if(!callback.scope){
+ callback.success(responseObject);
+ }
+ else{
+ // If a scope property is defined, the callback will be fired from
+ // the context of the object.
+ callback.success.apply(callback.scope, [responseObject]);
+ }
+ }
+ }
+ catch(e){}
+ }
+ else{
+ try
+ {
+ switch(httpStatus){
+ // The following cases are wininet.dll error codes that may be encountered.
+ case 12002: // Server timeout
+ case 12029: // 12029 to 12031 correspond to dropped connections.
+ case 12030:
+ case 12031:
+ case 12152: // Connection closed by server.
+ case 13030: // See above comments for variable status.
+ responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort?isAbort:false));
+ if(callback.failure){
+ if(!callback.scope){
+ callback.failure(responseObject);
+ }
+ else{
+ callback.failure.apply(callback.scope, [responseObject]);
+ }
+ }
+ break;
+ default:
+ responseObject = this.createResponseObject(o, callback.argument);
+ if(callback.failure){
+ if(!callback.scope){
+ callback.failure(responseObject);
+ }
+ else{
+ callback.failure.apply(callback.scope, [responseObject]);
+ }
+ }
+ }
+ }
+ catch(e){}
+ }
+
+ this.releaseObject(o);
+ responseObject = null;
+ },
+
+ /**
+ * @description This method evaluates the server response, creates and returns the results via
+ * its properties. Success and failure cases will differ in the response
+ * object's property values.
+ * @method createResponseObject
+ * @private
+ * @static
+ * @param {object} o The connection object
+ * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
+ * @return {object}
+ */
+ createResponseObject:function(o, callbackArg)
+ {
+ var obj = {};
+ var headerObj = {};
+
+ try
+ {
+ var headerStr = o.conn.getAllResponseHeaders();
+ var header = headerStr.split('\n');
+ for(var i=0; i ');
+
+ // IE will throw a security exception in an SSL environment if the
+ // iframe source is undefined.
+ if(typeof secureUri == 'boolean'){
+ io.src = 'javascript:false';
+ }
+ else if(typeof secureURI == 'string'){
+ // Deprecated
+ io.src = secureUri;
+ }
+ }
+ else{
+ var io = document.createElement('iframe');
+ io.id = frameId;
+ io.name = frameId;
+ }
+
+ io.style.position = 'absolute';
+ io.style.top = '-1000px';
+ io.style.left = '-1000px';
+
+ document.body.appendChild(io);
+ },
+
+ /**
+ * @description Parses the POST data and creates hidden form elements
+ * for each key-value, and appends them to the HTML form object.
+ * @method appendPostData
+ * @private
+ * @static
+ * @param {string} postData The HTTP POST data
+ * @return {array} formElements Collection of hidden fields.
+ */
+ appendPostData:function(postData)
+ {
+ var formElements = [];
+ var postMessage = postData.split('&');
+ for(var i=0; i < postMessage.length; i++){
+ var delimitPos = postMessage[i].indexOf('=');
+ if(delimitPos != -1){
+ formElements[i] = document.createElement('input');
+ formElements[i].type = 'hidden';
+ formElements[i].name = postMessage[i].substring(0,delimitPos);
+ formElements[i].value = postMessage[i].substring(delimitPos+1);
+ this._formNode.appendChild(formElements[i]);
+ }
+ }
+
+ return formElements;
+ },
+
+ /**
+ * @description Uploads HTML form, including files/attachments, to the
+ * iframe created in createFrame.
+ * @method uploadFile
+ * @private
+ * @static
+ * @param {int} id The transaction id.
+ * @param {object} callback - User-defined callback object.
+ * @param {string} uri Fully qualified path of resource.
+ * @return {void}
+ */
+ uploadFile:function(id, callback, uri, postData){
+
+ // Each iframe has an id prefix of "yuiIO" followed
+ // by the unique transaction id.
+ var frameId = 'yuiIO' + id;
+ var io = document.getElementById(frameId);
+
+ // Initialize the HTML form properties in case they are
+ // not defined in the HTML form.
+ this._formNode.action = uri;
+ this._formNode.method = 'POST';
+ this._formNode.target = frameId;
+
+ if(this._formNode.encoding){
+ // IE does not respect property enctype for HTML forms.
+ // Instead use property encoding.
+ this._formNode.encoding = 'multipart/form-data';
+ }
+ else{
+ this._formNode.enctype = 'multipart/form-data';
+ }
+
+ if(postData){
+ var oElements = this.appendPostData(postData);
+ }
+
+ this._formNode.submit();
+
+ if(oElements && oElements.length > 0){
+ try
+ {
+ for(var i=0; i < oElements.length; i++){
+ this._formNode.removeChild(oElements[i]);
+ }
+ }
+ catch(e){}
+ }
+
+ // Reset HTML form status properties.
+ this.resetFormState();
+
+ // Create the upload callback handler that fires when the iframe
+ // receives the load event. Subsequently, the event handler is detached
+ // and the iframe removed from the document.
+
+ var uploadCallback = function()
+ {
+ var obj = {};
+ obj.tId = id;
+ obj.argument = callback.argument;
+
+ try
+ {
+ obj.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
+ obj.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
+ }
+ catch(e){}
+
+ if(callback.upload){
+ if(!callback.scope){
+ callback.upload(obj);
+ }
+ else{
+ callback.upload.apply(callback.scope, [obj]);
+ }
+ }
+
+ if(YAHOO.util.Event){
+ YAHOO.util.Event.removeListener(io, "load", uploadCallback);
+ }
+ else if(window.detachEvent){
+ io.detachEvent('onload', uploadCallback);
+ }
+ else{
+ io.removeEventListener('load', uploadCallback, false);
+ }
+ setTimeout(function(){ document.body.removeChild(io); }, 100);
+ };
+
+
+ // Bind the onload handler to the iframe to detect the file upload response.
+ if(YAHOO.util.Event){
+ YAHOO.util.Event.addListener(io, "load", uploadCallback);
+ }
+ else if(window.attachEvent){
+ io.attachEvent('onload', uploadCallback);
+ }
+ else{
+ io.addEventListener('load', uploadCallback, false);
+ }
+ },
+
+ /**
+ * @description Method to terminate a transaction, if it has not reached readyState 4.
+ * @method abort
+ * @public
+ * @static
+ * @param {object} o The connection object returned by asyncRequest.
+ * @param {object} callback User-defined callback object.
+ * @param {string} isTimeout boolean to indicate if abort was a timeout.
+ * @return {boolean}
+ */
+ abort:function(o, callback, isTimeout)
+ {
+ if(this.isCallInProgress(o)){
+ o.conn.abort();
+ window.clearInterval(this._poll[o.tId]);
+ delete this._poll[o.tId];
+ if(isTimeout){
+ delete this._timeOut[o.tId];
+ }
+
+ this.handleTransactionResponse(o, callback, true);
+
+ return true;
+ }
+ else{
+ return false;
+ }
+ },
+
+ /**
+ * Public method to check if the transaction is still being processed.
+ *
+ * @method isCallInProgress
+ * @public
+ * @static
+ * @param {object} o The connection object returned by asyncRequest
+ * @return {boolean}
+ */
+ isCallInProgress:function(o)
+ {
+ // if the XHR object assigned to the transaction has not been dereferenced,
+ // then check its readyState status. Otherwise, return false.
+ if(o.conn){
+ return o.conn.readyState != 4 && o.conn.readyState != 0;
+ }
+ else{
+ //The XHR object has been destroyed.
+ return false;
+ }
+ },
+
+ /**
+ * @description Dereference the XHR instance and the connection object after the transaction is completed.
+ * @method releaseObject
+ * @private
+ * @static
+ * @param {object} o The connection object
+ * @return {void}
+ */
+ releaseObject:function(o)
+ {
+ //dereference the XHR instance.
+ o.conn = null;
+ //dereference the connection object.
+ o = null;
+ }
};
\ No newline at end of file
diff --git a/lib/yui/container/README b/lib/yui/container/README
index 3aa36b889c..c3801da657 100755
--- a/lib/yui/container/README
+++ b/lib/yui/container/README
@@ -1,103 +1,114 @@
-Container Release Notes
-
-*** version 0.12.1 ***
-
- All Classes
- - "monitorresize" property now functions in situations where document.domain has been modified.
- - YAHOO.widget.Module.textResizeEvent now fires when the font size is changed (except for Opera, which uses "zoom" functionality that prevents this)
- - Event listeners attached to container elements are now properly purged on destroy using YAHOO.util.Event.purgeElement
-
- Panel
- - Fixed issue where focus events were broken on the page when a modal Panel was created
-
- Dialog
- - Fixed bug where hitting "enter" on a Dialog was forcing the default submission behavior of the form's action to execute
- - Dialog no longer tries to give focus to hidden form elements.
- - Replaced references in Panel with for XHTML compliance.
- - Fixed issue that was preventing Safari from successfully using the getData() function
-
-*** version 0.12 ***
-
- All Classes
- - New documentation format implemented, and removed unnecessary prototype null references previously used for generating documentation
- - Modified the
-
- Config
- - Added 'undefined' check when reading initial properties for .reset()
- - Fixed Firefox warning on .resetProperty()
- - Fixed issue preventing resetProperty() from resetting values correctly
-
- Module
- - Removed unused "childNodesInDom" property
-
- Overlay
- - Converted center() to use Dom utility
- - Fixed configVisible() to properly detect actual visible/hidden status in Internet Explorer, which reports "inherit" for all elements by default.
- - Updated onDomResize to properly reapply "context" property
- - Unified scroll/resize handlers so that they fire properly (when the event has completed) as opposed to constantly (as seen in Mozilla-based browsers)
-
- Panel
- - Modified modality mask to show before Panel is shown (prior to any animation)
- - Modified buildWrapper to eliminate cloning of the initial markup module, which fixes issues with select options not maintaining their default selections in IE
- - Modality mask is now z-indexed properly so that the mask z-index is always one less than the Panel z-index
-
- Dialog
- - Fixed Connection to get "action" attribute using getAttribute, to allow for form fields named "action"
- - Added support for "GET" by retrieving the form "method" rather than always defaulting to "POST"
-
- KeyListener
- - Fixed to work properly with Safari 2.0 by matching against keyCode or charCode
-
-*** version 0.11.4 ***
-
- - Panel: Modality mask is now properly removed from DOM on Panel destroy.
-
-*** version 0.11.3 ***
-
- - Module: Fixed SSL warning issue in IE
- - Overlay: Fixed memory leak related to iframe shim in IE
- - Panel: No focusable elements under the mask can now be tabbed to
- - Panel: Set Panel container overflow to hidden to fix scrolling issue in Opera 9
-
-*** version 0.11.2 ***
-
- - All: JsLint optimization
- - Overlay: Fixed SSL issues with monitorresize property
- - OverlayManager: Fixed z-index incrementing issues
- - Dialog: Form elements called "name" will now function properly
- - Dialog: Removed unnecessary scope:this reference
-
-*** version 0.11.1 ***
-
- - Tooltip: Removed incorrect logger statement
- - Dialog: Corrected logic that was causing browser lockup in IE for SimpleDialog
- - Dialog: Fixed "firstButtom" typo
-
-*** version 0.11.0 ***
-
- - toString function added to all classes for easy logging
- - YAHOO.extend is now being used for inheritance on all container classes
- - Module: monitorresize feature now works on all browsers
- - Module: Fixed bug with image root and isSecure
- - Overlay: Fixed bugs related to IFRAME shim positioning
- - Overlay: center() now works in quirks mode
- - Overlay: Overlay now has a custom destroy() method that also removes the IFRAME shim
- - OverlayManager: Fixed bug in the prototype that was preventing multiple Managers on one page
- - OverlayManager: focusEvent now fires at all appropriate times
- - Tooltip: context can now be specified as an array, so Tooltips can be reused across multiple context elements
- - Tooltip: preventoverlap now functions properly for large context elements (i.e, images)
- - Tooltip: fixed bugs regarding setTimeout
- - Tooltip: added mousemove event to allow for more accurate Tooltip positioning
- - Panel: added dragEvent for monitoring all event handlers for drag and drop
- - Panel: modality mask is now resized on scroll
- - Panel: KeyListeners are now properly destroyed when the Panel is destroyed
- - Panel: Header is now sized properly in quirks mode
- - Dialog: Blinking cursor issue is fixed for Firefox
- - Dialog: callback object for Connection is now public (this.callback)
- - Dialog: onsuccess/onfailure properties removed (as a result of the public callback object)
- - Dialog: Dialog is now invisible by default
- - Dialog: Buttons are now properly cleaned up on destroy
-
-*** version 0.10.0 ***
-
-* Initial release
+Container Release Notes
+
+*** version 0.12.2 ***
+
+ Module
+ - Corrected issue where listener was not properly removed from resize monitor element when "monitorresize" is disabled
+
+ Panel
+ - Fixed issue that would sometimes prevent select lists from working properly in Firefox
+
+ Dialog
+ - Fixed error that would occur when trying to create a Dialog where the first form element is set to "disabled"
+ - Modified "close" property handler for Dialog/SimpleDialog to call "cancel" instead of "hide"
+
+*** version 0.12.1 ***
+
+ All Classes
+ - "monitorresize" property now functions in situations where document.domain has been modified.
+ - YAHOO.widget.Module.textResizeEvent now fires when the font size is changed (except for Opera, which uses "zoom" functionality that prevents this)
+ - Event listeners attached to container elements are now properly purged on destroy using YAHOO.util.Event.purgeElement
+
+ Panel
+ - Fixed issue where focus events were broken on the page when a modal Panel was created
+
+ Dialog
+ - Fixed bug where hitting "enter" on a Dialog was forcing the default submission behavior of the form's action to execute
+ - Dialog no longer tries to give focus to hidden form elements.
+ - Replaced references in Panel with for XHTML compliance.
+ - Fixed issue that was preventing Safari from successfully using the getData() function
+
+*** version 0.12 ***
+
+ All Classes
+ - New documentation format implemented, and removed unnecessary prototype null references previously used for generating documentation
+
+ Config
+ - Added 'undefined' check when reading initial properties for .reset()
+ - Fixed Firefox warning on .resetProperty()
+ - Fixed issue preventing resetProperty() from resetting values correctly
+
+ Module
+ - Removed unused "childNodesInDom" property
+
+ Overlay
+ - Converted center() to use Dom utility
+ - Fixed configVisible() to properly detect actual visible/hidden status in Internet Explorer, which reports "inherit" for all elements by default.
+ - Updated onDomResize to properly reapply "context" property
+ - Unified scroll/resize handlers so that they fire properly (when the event has completed) as opposed to constantly (as seen in Mozilla-based browsers)
+
+ Panel
+ - Modified modality mask to show before Panel is shown (prior to any animation)
+ - Modified buildWrapper to eliminate cloning of the initial markup module, which fixes issues with select options not maintaining their default selections in IE
+ - Modality mask is now z-indexed properly so that the mask z-index is always one less than the Panel z-index
+
+ Dialog
+ - Fixed Connection to get "action" attribute using getAttribute, to allow for form fields named "action"
+ - Added support for "GET" by retrieving the form "method" rather than always defaulting to "POST"
+
+ KeyListener
+ - Fixed to work properly with Safari 2.0 by matching against keyCode or charCode
+
+*** version 0.11.4 ***
+
+ - Panel: Modality mask is now properly removed from DOM on Panel destroy.
+
+*** version 0.11.3 ***
+
+ - Module: Fixed SSL warning issue in IE
+ - Overlay: Fixed memory leak related to iframe shim in IE
+ - Panel: No focusable elements under the mask can now be tabbed to
+ - Panel: Set Panel container overflow to hidden to fix scrolling issue in Opera 9
+
+*** version 0.11.2 ***
+
+ - All: JsLint optimization
+ - Overlay: Fixed SSL issues with monitorresize property
+ - OverlayManager: Fixed z-index incrementing issues
+ - Dialog: Form elements called "name" will now function properly
+ - Dialog: Removed unnecessary scope:this reference
+
+*** version 0.11.1 ***
+
+ - Tooltip: Removed incorrect logger statement
+ - Dialog: Corrected logic that was causing browser lockup in IE for SimpleDialog
+ - Dialog: Fixed "firstButtom" typo
+
+*** version 0.11.0 ***
+
+ - toString function added to all classes for easy logging
+ - YAHOO.extend is now being used for inheritance on all container classes
+ - Module: monitorresize feature now works on all browsers
+ - Module: Fixed bug with image root and isSecure
+ - Overlay: Fixed bugs related to IFRAME shim positioning
+ - Overlay: center() now works in quirks mode
+ - Overlay: Overlay now has a custom destroy() method that also removes the IFRAME shim
+ - OverlayManager: Fixed bug in the prototype that was preventing multiple Managers on one page
+ - OverlayManager: focusEvent now fires at all appropriate times
+ - Tooltip: context can now be specified as an array, so Tooltips can be reused across multiple context elements
+ - Tooltip: preventoverlap now functions properly for large context elements (i.e, images)
+ - Tooltip: fixed bugs regarding setTimeout
+ - Tooltip: added mousemove event to allow for more accurate Tooltip positioning
+ - Panel: added dragEvent for monitoring all event handlers for drag and drop
+ - Panel: modality mask is now resized on scroll
+ - Panel: KeyListeners are now properly destroyed when the Panel is destroyed
+ - Panel: Header is now sized properly in quirks mode
+ - Dialog: Blinking cursor issue is fixed for Firefox
+ - Dialog: callback object for Connection is now public (this.callback)
+ - Dialog: onsuccess/onfailure properties removed (as a result of the public callback object)
+ - Dialog: Dialog is now invisible by default
+ - Dialog: Buttons are now properly cleaned up on destroy
+
+*** version 0.10.0 ***
+
+* Initial release
diff --git a/lib/yui/container/assets/container.css b/lib/yui/container/assets/container.css
index 5a7bf411ec..ee5da15078 100755
--- a/lib/yui/container/assets/container.css
+++ b/lib/yui/container/assets/container.css
@@ -1,211 +1,211 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version 0.12.1
-*/
-
-.overlay {
- position:absolute;
- display:block;
-}
-
-.tt {
- visibility:hidden;
- position:absolute;
- color:#333;
- background-color:#FDFFB4;
- font-family:arial,helvetica,verdana,sans-serif;
- padding:2px;
- border:1px solid #FCC90D;
- font:100% sans-serif;
- width:auto;
-}
-
-* html body.masked select {
- visibility:hidden;
-}
-
-* html div.panel-container select {
- visibility:inherit;
-}
-
-* html div.drag select {
- visibility:hidden;
-}
-
-* html div.hide-select select {
- visibility:hidden;
-}
-
-.mask {
- z-index:0;
- display:none;
- position:absolute;
- top:0;
- left:0;
- -moz-opacity: 0.5;
- opacity:.50;
- filter: alpha(opacity=50);
- background-color:#CCC;
-}
-
-.hide-scrollbars * {
- overflow:hidden;
-}
-
-.hide-scrollbars textarea, .hide-scrollbars select {
- overflow:hidden;
- display:none;
-}
-
-.show-scrollbars textarea, .show-scrollbars select {
- overflow:visible;
-}
-
-.panel-container {
- position:absolute;
- background-color:transparent;
- z-index:6;
- visibility:hidden;
- overflow:visible;
- width:auto;
-}
-
-.panel-container.matte {
- padding:3px;
- background-color:#FFF;
-}
-
-.panel-container.matte .underlay {
- display:none;
-}
-
-.panel-container.shadow {
- padding:0px;
- background-color:transparent;
-}
-
-.panel-container.shadow .underlay {
- visibility:inherit;
- position:absolute;
- background-color:#CCC;
- top:3px;left:3px;
- z-index:0;
- width:100%;
- height:100%;
- -moz-opacity: 0.7;
- opacity:.70;
- filter:alpha(opacity=70);
- zoom:1;
-}
-
-.panel {
- visibility:hidden;
- border-collapse:separate;
- position:relative;
- left:0px;top:0px;
- font:1em Arial;
- background-color:#FFF;
- border:1px solid #000;
- z-index:1;
- overflow:hidden;
-}
-
-.panel .hd {
- background-color:#3d77cb;
- color:#FFF;
- font-size:100%;
- line-height:100%;
- border:1px solid #FFF;
- border-bottom:1px solid #000;
- font-weight:bold;
- overflow:hidden;
- padding:4px;
-}
-
-.panel .bd {
- overflow:hidden;
- padding:4px;
-}
-
-.panel .bd p {
- margin:0 0 1em;
-}
-
-.panel .close {
- position:absolute;
- top:5px;
- right:4px;
- z-index:6;
- height:12px;
- width:12px;
- margin:0px;
- padding:0px;
- background-repeat:no-repeat;
- cursor:pointer;
- visibility:inherit;
-}
-
-.panel .close.nonsecure {
- background-image:url(http://us.i1.yimg.com/us.yimg.com/i/nt/ic/ut/alt3/close12_1.gif);
-}
-
-.panel .close.secure {
- background-image:url(https://a248.e.akamai.net/sec.yimg.com/i/nt/ic/ut/alt3/close12_1.gif);
-}
-
-.panel .ft {
- padding:4px;
- overflow:hidden;
-}
-
-.simple-dialog .bd .icon {
- background-repeat:no-repeat;
- width:16px;
- height:16px;
- margin-right:10px;
- float:left;
-}
-
-.dialog .ft, .simple-dialog .ft {
- padding-bottom:5px;
- padding-right:5px;
- text-align:right;
-}
-
-.dialog form, .simple-dialog form {
- margin:0;
-}
-
-.button-group button {
- font:100 76% verdana;
- text-decoration:none;
- background-color: #E4E4E4;
- color: #333;
- cursor: hand;
- vertical-align: middle;
- border: 2px solid #797979;
- border-top-color:#FFF;
- border-left-color:#FFF;
- margin:2px;
- padding:2px;
-}
-
-.button-group button.default {
- font-weight:bold;
-}
-
-.button-group button:hover, .button-group button.hover {
- border:2px solid #90A029;
- background-color:#EBF09E;
- border-top-color:#FFF;
- border-left-color:#FFF;
-}
-
-.button-group button:active {
- border:2px solid #E4E4E4;
- background-color:#BBB;
- border-top-color:#333;
- border-left-color:#333;
-}
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.0
+*/
+
+.overlay {
+ position:absolute;
+ display:block;
+}
+
+.tt {
+ visibility:hidden;
+ position:absolute;
+ color:#333;
+ background-color:#FDFFB4;
+ font-family:arial,helvetica,verdana,sans-serif;
+ padding:2px;
+ border:1px solid #FCC90D;
+ font:100% sans-serif;
+ width:auto;
+}
+
+* html body.masked select {
+ visibility:hidden;
+}
+
+* html div.panel-container select {
+ visibility:inherit;
+}
+
+* html div.drag select {
+ visibility:hidden;
+}
+
+* html div.hide-select select {
+ visibility:hidden;
+}
+
+.mask {
+ z-index:0;
+ display:none;
+ position:absolute;
+ top:0;
+ left:0;
+ -moz-opacity: 0.5;
+ opacity:.50;
+ filter: alpha(opacity=50);
+ background-color:#CCC;
+}
+
+.hide-scrollbars * {
+ overflow:hidden;
+}
+
+.hide-scrollbars textarea, .hide-scrollbars select {
+ overflow:hidden;
+ display:none;
+}
+
+.show-scrollbars textarea, .show-scrollbars select {
+ overflow:visible;
+}
+
+.panel-container {
+ position:absolute;
+ background-color:transparent;
+ z-index:6;
+ visibility:hidden;
+ overflow:visible;
+ width:auto;
+}
+
+.panel-container.matte {
+ padding:3px;
+ background-color:#FFF;
+}
+
+.panel-container.matte .underlay {
+ display:none;
+}
+
+.panel-container.shadow {
+ padding:0px;
+ background-color:transparent;
+}
+
+.panel-container.shadow .underlay {
+ visibility:inherit;
+ position:absolute;
+ background-color:#CCC;
+ top:3px;left:3px;
+ z-index:0;
+ width:100%;
+ height:100%;
+ -moz-opacity: 0.7;
+ opacity:.70;
+ filter:alpha(opacity=70);
+ zoom:1;
+}
+
+.panel {
+ visibility:hidden;
+ border-collapse:separate;
+ position:relative;
+ left:0px;top:0px;
+ font:1em Arial;
+ background-color:#FFF;
+ border:1px solid #000;
+ z-index:1;
+ overflow:hidden;
+}
+
+.panel .hd {
+ background-color:#3d77cb;
+ color:#FFF;
+ font-size:100%;
+ line-height:100%;
+ border:1px solid #FFF;
+ border-bottom:1px solid #000;
+ font-weight:bold;
+ overflow:hidden;
+ padding:4px;
+}
+
+.panel .bd {
+ overflow:hidden;
+ padding:4px;
+}
+
+.panel .bd p {
+ margin:0 0 1em;
+}
+
+.panel .close {
+ position:absolute;
+ top:5px;
+ right:4px;
+ z-index:6;
+ height:12px;
+ width:12px;
+ margin:0px;
+ padding:0px;
+ background-repeat:no-repeat;
+ cursor:pointer;
+ visibility:inherit;
+}
+
+.panel .close.nonsecure {
+ background-image:url(http://us.i1.yimg.com/us.yimg.com/i/nt/ic/ut/alt3/close12_1.gif);
+}
+
+.panel .close.secure {
+ background-image:url(https://a248.e.akamai.net/sec.yimg.com/i/nt/ic/ut/alt3/close12_1.gif);
+}
+
+.panel .ft {
+ padding:4px;
+ overflow:hidden;
+}
+
+.simple-dialog .bd .icon {
+ background-repeat:no-repeat;
+ width:16px;
+ height:16px;
+ margin-right:10px;
+ float:left;
+}
+
+.dialog .ft, .simple-dialog .ft {
+ padding-bottom:5px;
+ padding-right:5px;
+ text-align:right;
+}
+
+.dialog form, .simple-dialog form {
+ margin:0;
+}
+
+.button-group button {
+ font:100 76% verdana;
+ text-decoration:none;
+ background-color: #E4E4E4;
+ color: #333;
+ cursor: hand;
+ vertical-align: middle;
+ border: 2px solid #797979;
+ border-top-color:#FFF;
+ border-left-color:#FFF;
+ margin:2px;
+ padding:2px;
+}
+
+.button-group button.default {
+ font-weight:bold;
+}
+
+.button-group button:hover, .button-group button.hover {
+ border:2px solid #90A029;
+ background-color:#EBF09E;
+ border-top-color:#FFF;
+ border-left-color:#FFF;
+}
+
+.button-group button:active {
+ border:2px solid #E4E4E4;
+ background-color:#BBB;
+ border-top-color:#333;
+ border-left-color:#333;
+}
diff --git a/lib/yui/container/container-debug.js b/lib/yui/container/container-debug.js
index c495accc2d..23bf045703 100755
--- a/lib/yui/container/container-debug.js
+++ b/lib/yui/container/container-debug.js
@@ -1,4654 +1,4691 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version 0.12.1
-*/
-
-/**
-* Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
-* @namespace YAHOO.util
-* @class Config
-* @constructor
-* @param {Object} owner The owner Object to which this Config Object belongs
-*/
-YAHOO.util.Config = function(owner) {
- if (owner) {
- this.init(owner);
- } else {
- YAHOO.log("No owner specified for Config object", "error");
- }
-};
-
-YAHOO.util.Config.prototype = {
-
- /**
- * Object reference to the owner of this Config Object
- * @property owner
- * @type Object
- */
- owner : null,
-
- /**
- * Boolean flag that specifies whether a queue is currently being executed
- * @property queueInProgress
- * @type Boolean
- */
- queueInProgress : false,
-
-
- /**
- * Validates that the value passed in is a Boolean.
- * @method checkBoolean
- * @param {Object} val The value to validate
- * @return {Boolean} true, if the value is valid
- */
- checkBoolean: function(val) {
- if (typeof val == 'boolean') {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Validates that the value passed in is a number.
- * @method checkNumber
- * @param {Object} val The value to validate
- * @return {Boolean} true, if the value is valid
- */
- checkNumber: function(val) {
- if (isNaN(val)) {
- return false;
- } else {
- return true;
- }
- }
-};
-
-
-/**
-* Initializes the configuration Object and all of its local members.
-* @method init
-* @param {Object} owner The owner Object to which this Config Object belongs
-*/
-YAHOO.util.Config.prototype.init = function(owner) {
-
- this.owner = owner;
-
- /**
- * Object reference to the owner of this Config Object
- * @event configChangedEvent
- */
- this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
- this.queueInProgress = false;
-
- /* Private Members */
-
- /**
- * Maintains the local collection of configuration property objects and their specified values
- * @property config
- * @private
- * @type Object
- */
- var config = {};
-
- /**
- * Maintains the local collection of configuration property objects as they were initially applied.
- * This object is used when resetting a property.
- * @property initialConfig
- * @private
- * @type Object
- */
- var initialConfig = {};
-
- /**
- * Maintains the local, normalized CustomEvent queue
- * @property eventQueue
- * @private
- * @type Object
- */
- var eventQueue = [];
-
- /**
- * Fires a configuration property event using the specified value.
- * @method fireEvent
- * @private
- * @param {String} key The configuration property's name
- * @param {value} Object The value of the correct type for the property
- */
- var fireEvent = function( key, value ) {
- YAHOO.log("Firing Config event: " + key + "=" + value, "info");
-
- key = key.toLowerCase();
-
- var property = config[key];
-
- if (typeof property != 'undefined' && property.event) {
- property.event.fire(value);
- }
- };
- /* End Private Members */
-
- /**
- * Adds a property to the Config Object's private config hash.
- * @method addProperty
- * @param {String} key The configuration property's name
- * @param {Object} propertyObject The Object containing all of this property's arguments
- */
- this.addProperty = function( key, propertyObject ) {
- key = key.toLowerCase();
-
- YAHOO.log("Added property: " + key, "info");
-
- config[key] = propertyObject;
-
- propertyObject.event = new YAHOO.util.CustomEvent(key);
- propertyObject.key = key;
-
- if (propertyObject.handler) {
- propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
- }
-
- this.setProperty(key, propertyObject.value, true);
-
- if (! propertyObject.suppressEvent) {
- this.queueProperty(key, propertyObject.value);
- }
- };
-
- /**
- * Returns a key-value configuration map of the values currently set in the Config Object.
- * @method getConfig
- * @return {Object} The current config, represented in a key-value map
- */
- this.getConfig = function() {
- var cfg = {};
-
- for (var prop in config) {
- var property = config[prop];
- if (typeof property != 'undefined' && property.event) {
- cfg[prop] = property.value;
- }
- }
-
- return cfg;
- };
-
- /**
- * Returns the value of specified property.
- * @method getProperty
- * @param {String} key The name of the property
- * @return {Object} The value of the specified property
- */
- this.getProperty = function(key) {
- key = key.toLowerCase();
-
- var property = config[key];
- if (typeof property != 'undefined' && property.event) {
- return property.value;
- } else {
- return undefined;
- }
- };
-
- /**
- * Resets the specified property's value to its initial value.
- * @method resetProperty
- * @param {String} key The name of the property
- * @return {Boolean} True is the property was reset, false if not
- */
- this.resetProperty = function(key) {
- key = key.toLowerCase();
-
- var property = config[key];
- if (typeof property != 'undefined' && property.event) {
- if (initialConfig[key] && initialConfig[key] != 'undefined') {
- this.setProperty(key, initialConfig[key]);
- }
- return true;
- } else {
- return false;
- }
- };
-
- /**
- * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
- * @method setProperty
- * @param {String} key The name of the property
- * @param {String} value The value to set the property to
- * @param {Boolean} silent Whether the value should be set silently, without firing the property event.
- * @return {Boolean} True, if the set was successful, false if it failed.
- */
- this.setProperty = function(key, value, silent) {
- key = key.toLowerCase();
-
- YAHOO.log("setProperty: " + key + "=" + value, "info");
-
- if (this.queueInProgress && ! silent) {
- this.queueProperty(key,value); // Currently running through a queue...
- return true;
- } else {
- var property = config[key];
- if (typeof property != 'undefined' && property.event) {
- if (property.validator && ! property.validator(value)) { // validator
- return false;
- } else {
- property.value = value;
- if (! silent) {
- fireEvent(key, value);
- this.configChangedEvent.fire([key, value]);
- }
- return true;
- }
- } else {
- return false;
- }
- }
- };
-
- /**
- * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
- * moved from its current position to the end of the queue.
- * @method queueProperty
- * @param {String} key The name of the property
- * @param {String} value The value to set the property to
- * @return {Boolean} true, if the set was successful, false if it failed.
- */
- this.queueProperty = function(key, value) {
- key = key.toLowerCase();
-
- YAHOO.log("queueProperty: " + key + "=" + value, "info");
-
- var property = config[key];
-
- if (typeof property != 'undefined' && property.event) {
- if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
- return false;
- } else {
-
- if (typeof value != 'undefined') {
- property.value = value;
- } else {
- value = property.value;
- }
-
- var foundDuplicate = false;
-
- for (var i=0;iOR
-* @param {HTMLElement} el The element representing the Module
-* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
-*/
-YAHOO.widget.Module = function(el, userConfig) {
- if (el) {
- this.init(el, userConfig);
- } else {
- YAHOO.log("No element or element ID specified for Module instantiation", "error");
- }
-};
-
-/**
-* Constant representing the prefix path to use for non-secure images
-* @property YAHOO.widget.Module.IMG_ROOT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
-
-/**
-* Constant representing the prefix path to use for securely served images
-* @property YAHOO.widget.Module.IMG_ROOT_SSL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
-
-/**
-* Constant for the default CSS class name that represents a Module
-* @property YAHOO.widget.Module.CSS_MODULE
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_MODULE = "module";
-
-/**
-* Constant representing the module header
-* @property YAHOO.widget.Module.CSS_HEADER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_HEADER = "hd";
-
-/**
-* Constant representing the module body
-* @property YAHOO.widget.Module.CSS_BODY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_BODY = "bd";
-
-/**
-* Constant representing the module footer
-* @property YAHOO.widget.Module.CSS_FOOTER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_FOOTER = "ft";
-
-/**
-* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
-* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";
-
-/**
-* Singleton CustomEvent fired when the font size is changed in the browser.
-* Opera's "zoom" functionality currently does not support text size detection.
-* @event YAHOO.widget.Module.textResizeEvent
-*/
-YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");
-
-YAHOO.widget.Module.prototype = {
- /**
- * The class's constructor function
- * @property contructor
- * @type Function
- */
- constructor : YAHOO.widget.Module,
-
- /**
- * The main module element that contains the header, body, and footer
- * @property element
- * @type HTMLElement
- */
- element : null,
-
- /**
- * The header element, denoted with CSS class "hd"
- * @property header
- * @type HTMLElement
- */
- header : null,
-
- /**
- * The body element, denoted with CSS class "bd"
- * @property body
- * @type HTMLElement
- */
- body : null,
-
- /**
- * The footer element, denoted with CSS class "ft"
- * @property footer
- * @type HTMLElement
- */
- footer : null,
-
- /**
- * The id of the element
- * @property id
- * @type String
- */
- id : null,
-
- /**
- * The String representing the image root
- * @property imageRoot
- * @type String
- */
- imageRoot : YAHOO.widget.Module.IMG_ROOT,
-
- /**
- * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
- * @method initEvents
- */
- initEvents : function() {
-
- /**
- * CustomEvent fired prior to class initalization.
- * @event beforeInitEvent
- * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
- */
- this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
-
- /**
- * CustomEvent fired after class initalization.
- * @event initEvent
- * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
- */
- this.initEvent = new YAHOO.util.CustomEvent("init");
-
- /**
- * CustomEvent fired when the Module is appended to the DOM
- * @event appendEvent
- */
- this.appendEvent = new YAHOO.util.CustomEvent("append");
-
- /**
- * CustomEvent fired before the Module is rendered
- * @event beforeRenderEvent
- */
- this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
-
- /**
- * CustomEvent fired after the Module is rendered
- * @event renderEvent
- */
- this.renderEvent = new YAHOO.util.CustomEvent("render");
-
- /**
- * CustomEvent fired when the header content of the Module is modified
- * @event changeHeaderEvent
- * @param {String/HTMLElement} content String/element representing the new header content
- */
- this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
-
- /**
- * CustomEvent fired when the body content of the Module is modified
- * @event changeBodyEvent
- * @param {String/HTMLElement} content String/element representing the new body content
- */
- this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
-
- /**
- * CustomEvent fired when the footer content of the Module is modified
- * @event changeFooterEvent
- * @param {String/HTMLElement} content String/element representing the new footer content
- */
- this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
-
- /**
- * CustomEvent fired when the content of the Module is modified
- * @event changeContentEvent
- */
- this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
-
- /**
- * CustomEvent fired when the Module is destroyed
- * @event destroyEvent
- */
- this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
-
- /**
- * CustomEvent fired before the Module is shown
- * @event beforeShowEvent
- */
- this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
-
- /**
- * CustomEvent fired after the Module is shown
- * @event showEvent
- */
- this.showEvent = new YAHOO.util.CustomEvent("show");
-
- /**
- * CustomEvent fired before the Module is hidden
- * @event beforeHideEvent
- */
- this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
-
- /**
- * CustomEvent fired after the Module is hidden
- * @event hideEvent
- */
- this.hideEvent = new YAHOO.util.CustomEvent("hide");
- },
-
- /**
- * String representing the current user-agent platform
- * @property platform
- * @type String
- */
- platform : function() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
- return "windows";
- } else if (ua.indexOf("macintosh") != -1) {
- return "mac";
- } else {
- return false;
- }
- }(),
-
- /**
- * String representing the current user-agent browser
- * @property browser
- * @type String
- */
- browser : function() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
- return 'opera';
- } else if (ua.indexOf('msie 7')!=-1) { // IE7
- return 'ie7';
- } else if (ua.indexOf('msie') !=-1) { // IE
- return 'ie';
- } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
- return 'safari';
- } else if (ua.indexOf('gecko') != -1) { // Gecko
- return 'gecko';
- } else {
- return false;
- }
- }(),
-
- /**
- * Boolean representing whether or not the current browsing context is secure (https)
- * @property isSecure
- * @type Boolean
- */
- isSecure : function() {
- if (window.location.href.toLowerCase().indexOf("https") === 0) {
- return true;
- } else {
- return false;
- }
- }(),
-
- /**
- * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
- */
- initDefaultConfig : function() {
- // Add properties //
-
- /**
- * Specifies whether the Module is visible on the page.
- * @config visible
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
-
- /**
- * Object or array of objects representing the ContainerEffect classes that are active for animating the container.
- * @config effect
- * @type Object
- * @default null
- */
- this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
-
- /**
- * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document
- * @config monitorresize
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
- },
-
- /**
- * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
- * @method init
- * @param {String} el The element ID representing the Module OR
- * @param {HTMLElement} el The element representing the Module
- * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
- */
- init : function(el, userConfig) {
-
- this.initEvents();
-
- this.beforeInitEvent.fire(YAHOO.widget.Module);
-
- /**
- * The Module's Config object used for monitoring configuration properties.
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- if (this.isSecure) {
- this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
- }
-
- if (typeof el == "string") {
- var elId = el;
-
- el = document.getElementById(el);
- if (! el) {
- el = document.createElement("DIV");
- el.id = elId;
- }
- }
-
- this.element = el;
-
- if (el.id) {
- this.id = el.id;
- }
-
- var childNodes = this.element.childNodes;
-
- if (childNodes) {
- for (var i=0;iOR
- * @param {HTMLElement} headerContent The HTMLElement to append to the header
- */
- setHeader : function(headerContent) {
- if (! this.header) {
- this.header = document.createElement("DIV");
- this.header.className = YAHOO.widget.Module.CSS_HEADER;
- }
-
- if (typeof headerContent == "string") {
- this.header.innerHTML = headerContent;
- } else {
- this.header.innerHTML = "";
- this.header.appendChild(headerContent);
- }
-
- this.changeHeaderEvent.fire(headerContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the header. If no header is present, one will be automatically created.
- * @method appendToHeader
- * @param {HTMLElement} element The element to append to the header
- */
- appendToHeader : function(element) {
- if (! this.header) {
- this.header = document.createElement("DIV");
- this.header.className = YAHOO.widget.Module.CSS_HEADER;
- }
-
- this.header.appendChild(element);
- this.changeHeaderEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
- * @method setBody
- * @param {String} bodyContent The HTML used to set the body OR
- * @param {HTMLElement} bodyContent The HTMLElement to append to the body
- */
- setBody : function(bodyContent) {
- if (! this.body) {
- this.body = document.createElement("DIV");
- this.body.className = YAHOO.widget.Module.CSS_BODY;
- }
-
- if (typeof bodyContent == "string")
- {
- this.body.innerHTML = bodyContent;
- } else {
- this.body.innerHTML = "";
- this.body.appendChild(bodyContent);
- }
-
- this.changeBodyEvent.fire(bodyContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the body. If no body is present, one will be automatically created.
- * @method appendToBody
- * @param {HTMLElement} element The element to append to the body
- */
- appendToBody : function(element) {
- if (! this.body) {
- this.body = document.createElement("DIV");
- this.body.className = YAHOO.widget.Module.CSS_BODY;
- }
-
- this.body.appendChild(element);
- this.changeBodyEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
- * @method setFooter
- * @param {String} footerContent The HTML used to set the footer OR
- * @param {HTMLElement} footerContent The HTMLElement to append to the footer
- */
- setFooter : function(footerContent) {
- if (! this.footer) {
- this.footer = document.createElement("DIV");
- this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
- }
-
- if (typeof footerContent == "string") {
- this.footer.innerHTML = footerContent;
- } else {
- this.footer.innerHTML = "";
- this.footer.appendChild(footerContent);
- }
-
- this.changeFooterEvent.fire(footerContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the footer. If no footer is present, one will be automatically created.
- * @method appendToFooter
- * @param {HTMLElement} element The element to append to the footer
- */
- appendToFooter : function(element) {
- if (! this.footer) {
- this.footer = document.createElement("DIV");
- this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
- }
-
- this.footer.appendChild(element);
- this.changeFooterEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
- * @method render
- * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering OR
- * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
- * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
- * @return {Boolean} Success or failure of the render
- */
- render : function(appendToNode, moduleElement) {
- this.beforeRenderEvent.fire();
-
- if (! moduleElement) {
- moduleElement = this.element;
- }
-
- var me = this;
- var appendTo = function(element) {
- if (typeof element == "string") {
- element = document.getElementById(element);
- }
-
- if (element) {
- element.appendChild(me.element);
- me.appendEvent.fire();
- }
- };
-
- if (appendToNode) {
- appendTo(appendToNode);
- } else { // No node was passed in. If the element is not pre-marked up, this fails
- if (! YAHOO.util.Dom.inDocument(this.element)) {
- YAHOO.log("Render failed. Must specify appendTo node if Module isn't already in the DOM.", "error");
- return false;
- }
- }
-
- // Need to get everything into the DOM if it isn't already
-
- if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
- // There is a header, but it's not in the DOM yet... need to add it
- var firstChild = moduleElement.firstChild;
- if (firstChild) { // Insert before first child if exists
- moduleElement.insertBefore(this.header, firstChild);
- } else { // Append to empty body because there are no children
- moduleElement.appendChild(this.header);
- }
- }
-
- if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
- // There is a body, but it's not in the DOM yet... need to add it
- if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
- moduleElement.insertBefore(this.body, this.footer);
- } else { // Append to element because there is no footer
- moduleElement.appendChild(this.body);
- }
- }
-
- if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
- // There is a footer, but it's not in the DOM yet... need to add it
- moduleElement.appendChild(this.footer);
- }
-
- this.renderEvent.fire();
- return true;
- },
-
- /**
- * Removes the Module element from the DOM and sets all child elements to null.
- * @method destroy
- */
- destroy : function() {
- var parent;
-
- if (this.element) {
- YAHOO.util.Event.purgeElement(this.element, true);
- parent = this.element.parentNode;
- }
- if (parent) {
- parent.removeChild(this.element);
- }
-
- this.element = null;
- this.header = null;
- this.body = null;
- this.footer = null;
-
- for (var e in this) {
- if (e instanceof YAHOO.util.CustomEvent) {
- e.unsubscribeAll();
- }
- }
-
- YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this);
-
- this.destroyEvent.fire();
- },
-
- /**
- * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
- * @method show
- */
- show : function() {
- this.cfg.setProperty("visible", true);
- },
-
- /**
- * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
- * @method hide
- */
- hide : function() {
- this.cfg.setProperty("visible", false);
- },
-
- // BUILT-IN EVENT HANDLERS FOR MODULE //
-
- /**
- * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
- * This method is responsible for firing showEvent and hideEvent.
- * @param {String} type The CustomEvent type (usually the property name)
- * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
- * @method configVisible
- */
- configVisible : function(type, args, obj) {
- var visible = args[0];
- if (visible) {
- this.beforeShowEvent.fire();
- YAHOO.util.Dom.setStyle(this.element, "display", "block");
- this.showEvent.fire();
- } else {
- this.beforeHideEvent.fire();
- YAHOO.util.Dom.setStyle(this.element, "display", "none");
- this.hideEvent.fire();
- }
- },
-
- /**
- * Default event handler for the "monitorresize" configuration property
- * @param {String} type The CustomEvent type (usually the property name)
- * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
- * @method configMonitorResize
- */
- configMonitorResize : function(type, args, obj) {
- var monitor = args[0];
- if (monitor) {
- this.initResizeMonitor();
- } else {
- YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize);
- this.resizeMonitor = null;
- }
- }
-};
-
-/**
-* Returns a String representation of the Object.
-* @method toString
-* @return {String} The string representation of the Module
-*/
-YAHOO.widget.Module.prototype.toString = function() {
- return "Module " + this.id;
-};
-
-/**
-* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
-* @namespace YAHOO.widget
-* @class Overlay
-* @extends YAHOO.widget.Module
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details.
-* @constructor
-*/
-YAHOO.widget.Overlay = function(el, userConfig) {
- YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
-
-/**
-* The URL that will be placed in the iframe
-* @property YAHOO.widget.Overlay.IFRAME_SRC
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;";
-
-/**
-* Constant representing the top left corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.TOP_LEFT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.TOP_LEFT = "tl";
-
-/**
-* Constant representing the top right corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.TOP_RIGHT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.TOP_RIGHT = "tr";
-
-/**
-* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.BOTTOM_LEFT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
-
-/**
-* Constant representing the bottom right corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.BOTTOM_RIGHT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
-
-/**
-* Constant representing the default CSS class used for an Overlay
-* @property YAHOO.widget.Overlay.CSS_OVERLAY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
-
-/**
-* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
-*/
-YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
- YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.Overlay);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- if (this.platform == "mac" && this.browser == "gecko") {
- if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
- this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
- }
- if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
- this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
- }
- }
-
- this.initEvent.fire(YAHOO.widget.Overlay);
-
-};
-
-/**
-* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
-* @method initEvents
-*/
-YAHOO.widget.Overlay.prototype.initEvents = function() {
- YAHOO.widget.Overlay.superclass.initEvents.call(this);
-
- /**
- * CustomEvent fired before the Overlay is moved.
- * @event beforeMoveEvent
- * @param {Number} x x coordinate
- * @param {Number} y y coordinate
- */
- this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
-
- /**
- * CustomEvent fired after the Overlay is moved.
- * @event moveEvent
- * @param {Number} x x coordinate
- * @param {Number} y y coordinate
- */
- this.moveEvent = new YAHOO.util.CustomEvent("move", this);
-};
-
-/**
-* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
- YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
-
- // Add overlay config properties //
-
- /**
- * The absolute x-coordinate position of the Overlay
- * @config x
- * @type Number
- * @default null
- */
- this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * The absolute y-coordinate position of the Overlay
- * @config y
- * @type Number
- * @default null
- */
- this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * An array with the absolute x and y positions of the Overlay
- * @config xy
- * @type Number[]
- * @default null
- */
- this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner.
- * @config context
- * @type Array
- * @default null
- */
- this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * True if the Overlay should be anchored to the center of the viewport.
- * @config fixedcenter
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
-
- /**
- * CSS width of the Overlay.
- * @config width
- * @type String
- * @default null
- */
- this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * CSS height of the Overlay.
- * @config height
- * @type String
- * @default null
- */
- this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * CSS z-index of the Overlay.
- * @config zIndex
- * @type Number
- * @default null
- */
- this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
-
- /**
- * True if the Overlay should be prevented from being positioned out of the viewport.
- * @config constraintoviewport
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
-
- /**
- * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below).
- * @config iframe
- * @type Boolean
- * @default true for IE6 and below, false for all others
- */
- this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
-};
-
-/**
-* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
-* @method moveTo
-* @param {Number} x The Overlay's new x position
-* @param {Number} y The Overlay's new y position
-*/
-YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
- this.cfg.setProperty("xy",[x,y]);
-};
-
-/**
-* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
-* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
-* @method hideMacGeckoScrollbars
-*/
-YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
- YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
- YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
-};
-
-/**
-* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
-* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
-* @method showMacGeckoScrollbars
-*/
-YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
- YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
- YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
-* @method configVisible
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
- var visible = args[0];
- var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
-
- if (currentVis == "inherit") {
- var e = this.element.parentNode;
- while (e.nodeType != 9 && e.nodeType != 11) {
- currentVis = YAHOO.util.Dom.getStyle(e, "visibility");
- if (currentVis != "inherit") { break; }
- e = e.parentNode;
- }
- if (currentVis == "inherit") {
- currentVis = "visible";
- }
- }
-
- var effect = this.cfg.getProperty("effect");
-
- var effectInstances = [];
- if (effect) {
- if (effect instanceof Array) {
- for (var i=0;i rightConstraint) {
- x = rightConstraint;
- }
-
- if (y < topConstraint) {
- y = topConstraint;
- } else if (y > bottomConstraint) {
- y = bottomConstraint;
- }
-
- this.cfg.setProperty("x", x, true);
- this.cfg.setProperty("y", y, true);
- this.cfg.setProperty("xy", [x,y], true);
-};
-
-/**
-* Centers the container in the viewport.
-* @method center
-*/
-YAHOO.widget.Overlay.prototype.center = function() {
- var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
- var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
-
- var viewPortWidth = YAHOO.util.Dom.getClientWidth();
- var viewPortHeight = YAHOO.util.Dom.getClientHeight();
-
- var elementWidth = this.element.offsetWidth;
- var elementHeight = this.element.offsetHeight;
-
- var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
- var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
-
- this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
-
- this.cfg.refireEvent("iframe");
-};
-
-/**
-* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
-* @method syncPosition
-*/
-YAHOO.widget.Overlay.prototype.syncPosition = function() {
- var pos = YAHOO.util.Dom.getXY(this.element);
- this.cfg.setProperty("x", pos[0], true);
- this.cfg.setProperty("y", pos[1], true);
- this.cfg.setProperty("xy", pos, true);
-};
-
-/**
-* Event handler fired when the resize monitor element is resized.
-* @method onDomResize
-* @param {DOMEvent} e The resize DOM event
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
- YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
- var me = this;
- setTimeout(function() {
- me.syncPosition();
- me.cfg.refireEvent("iframe");
- me.cfg.refireEvent("context");
- }, 0);
-};
-
-/**
-* Removes the Overlay element from the DOM and sets all child elements to null.
-* @method destroy
-*/
-YAHOO.widget.Overlay.prototype.destroy = function() {
- if (this.iframe) {
- this.iframe.parentNode.removeChild(this.iframe);
- }
-
- this.iframe = null;
-
- YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
- YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
-
- YAHOO.widget.Overlay.superclass.destroy.call(this);
-};
-
-/**
-* Returns a String representation of the object.
-* @method toString
-* @return {String} The string representation of the Overlay.
-*/
-YAHOO.widget.Overlay.prototype.toString = function() {
- return "Overlay " + this.id;
-};
-
-/**
-* A singleton CustomEvent used for reacting to the DOM event for window scroll
-* @event YAHOO.widget.Overlay.windowScrollEvent
-*/
-YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
-
-/**
-* A singleton CustomEvent used for reacting to the DOM event for window resize
-* @event YAHOO.widget.Overlay.windowResizeEvent
-*/
-YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
-
-/**
-* The DOM event handler used to fire the CustomEvent for window scroll
-* @method YAHOO.widget.Overlay.windowScrollHandler
-* @static
-* @param {DOMEvent} e The DOM scroll event
-*/
-YAHOO.widget.Overlay.windowScrollHandler = function(e) {
- if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
- if (! window.scrollEnd) {
- window.scrollEnd = -1;
- }
- clearTimeout(window.scrollEnd);
- window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1);
- } else {
- YAHOO.widget.Overlay.windowScrollEvent.fire();
- }
-};
-
-/**
-* The DOM event handler used to fire the CustomEvent for window resize
-* @method YAHOO.widget.Overlay.windowResizeHandler
-* @static
-* @param {DOMEvent} e The DOM resize event
-*/
-YAHOO.widget.Overlay.windowResizeHandler = function(e) {
- if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
- if (! window.resizeEnd) {
- window.resizeEnd = -1;
- }
- clearTimeout(window.resizeEnd);
- window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100);
- } else {
- YAHOO.widget.Overlay.windowResizeEvent.fire();
- }
-};
-
-/**
-* A boolean that indicated whether the window resize and scroll events have already been subscribed to.
-* @property YAHOO.widget.Overlay._initialized
-* @private
-* @type Boolean
-*/
-YAHOO.widget.Overlay._initialized = null;
-
-if (YAHOO.widget.Overlay._initialized === null) {
- YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
- YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
-
- YAHOO.widget.Overlay._initialized = true;
-}
-
-/**
-* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget
-* @namespace YAHOO.widget
-* @class OverlayManager
-* @constructor
-* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
-* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
-*/
-YAHOO.widget.OverlayManager = function(userConfig) {
- this.init(userConfig);
-};
-
-/**
-* The CSS class representing a focused Overlay
-* @property YAHOO.widget.OverlayManager.CSS_FOCUSED
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
-
-YAHOO.widget.OverlayManager.prototype = {
- /**
- * The class's constructor function
- * @property contructor
- * @type Function
- */
- constructor : YAHOO.widget.OverlayManager,
-
- /**
- * The array of Overlays that are currently registered
- * @property overlays
- * @type YAHOO.widget.Overlay[]
- */
- overlays : null,
-
- /**
- * Initializes the default configuration of the OverlayManager
- * @method initDefaultConfig
- */
- initDefaultConfig : function() {
- /**
- * The collection of registered Overlays in use by the OverlayManager
- * @config overlays
- * @type YAHOO.widget.Overlay[]
- * @default null
- */
- this.cfg.addProperty("overlays", { suppressEvent:true } );
-
- /**
- * The default DOM event that should be used to focus an Overlay
- * @config focusevent
- * @type String
- * @default "mousedown"
- */
- this.cfg.addProperty("focusevent", { value:"mousedown" } );
- },
-
- /**
- * Initializes the OverlayManager
- * @method init
- * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager.
- * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
- */
- init : function(userConfig) {
- /**
- * The OverlayManager's Config object used for monitoring configuration properties.
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- this.initDefaultConfig();
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
- this.cfg.fireQueue();
-
- /**
- * The currently activated Overlay
- * @property activeOverlay
- * @private
- * @type YAHOO.widget.Overlay
- */
- var activeOverlay = null;
-
- /**
- * Returns the currently focused Overlay
- * @method getActive
- * @return {YAHOO.widget.Overlay} The currently focused Overlay
- */
- this.getActive = function() {
- return activeOverlay;
- };
-
- /**
- * Focuses the specified Overlay
- * @method focus
- * @param {YAHOO.widget.Overlay} overlay The Overlay to focus
- * @param {String} overlay The id of the Overlay to focus
- */
- this.focus = function(overlay) {
- var o = this.find(overlay);
- if (o) {
- this.blurAll();
- activeOverlay = o;
- YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
- this.overlays.sort(this.compareZIndexDesc);
- var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
- if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
- activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2));
- }
- this.overlays.sort(this.compareZIndexDesc);
- }
- };
-
- /**
- * Removes the specified Overlay from the manager
- * @method remove
- * @param {YAHOO.widget.Overlay} overlay The Overlay to remove
- * @param {String} overlay The id of the Overlay to remove
- */
- this.remove = function(overlay) {
- var o = this.find(overlay);
- if (o) {
- var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
- o.cfg.setProperty("zIndex", -1000, true);
- this.overlays.sort(this.compareZIndexDesc);
- this.overlays = this.overlays.slice(0, this.overlays.length-1);
- o.cfg.setProperty("zIndex", originalZ, true);
-
- o.cfg.setProperty("manager", null);
- o.focusEvent = null;
- o.blurEvent = null;
- o.focus = null;
- o.blur = null;
- }
- };
-
- /**
- * Removes focus from all registered Overlays in the manager
- * @method blurAll
- */
- this.blurAll = function() {
- activeOverlay = null;
- for (var o=0;o 0) {
- return true;
- }
- } else {
- return false;
- }
- },
-
- /**
- * Attempts to locate an Overlay by instance or ID.
- * @method find
- * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager
- * @param {String} overlay An Overlay id to locate within the manager
- * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located.
- */
- find : function(overlay) {
- if (overlay instanceof YAHOO.widget.Overlay) {
- for (var o=0;o zIndex2) {
- return -1;
- } else if (zIndex1 < zIndex2) {
- return 1;
- } else {
- return 0;
- }
- },
-
- /**
- * Shows all Overlays in the manager.
- * @method showAll
- */
- showAll : function() {
- for (var o=0;oOR
-* @param {HTMLElement} el The element representing the Tooltip
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
-*/
-YAHOO.widget.Tooltip = function(el, userConfig) {
- YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay);
-
-/**
-* Constant representing the Tooltip CSS class
-* @property YAHOO.widget.Tooltip.CSS_TOOLTIP
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Tooltip.CSS_TOOLTIP = "tt";
-
-/**
-* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well.
-* @method init
-* @param {String} el The element ID representing the Tooltip OR
-* @param {HTMLElement} el The element representing the Tooltip
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details.
-*/
-YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) {
- this.logger = YAHOO.widget.Tooltip.logger;
-
- if (document.readyState && document.readyState != "complete") {
- var deferredInit = function() {
- this.init(el, userConfig);
- };
- YAHOO.util.Event.addListener(window, "load", deferredInit, this, true);
- } else {
- YAHOO.widget.Tooltip.superclass.init.call(this, el);
-
- this.beforeInitEvent.fire(YAHOO.widget.Tooltip);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP);
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- this.cfg.queueProperty("visible",false);
- this.cfg.queueProperty("constraintoviewport",true);
-
- this.setBody("");
- this.render(this.cfg.getProperty("container"));
-
- this.initEvent.fire(YAHOO.widget.Tooltip);
- }
-};
-
-/**
-* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() {
- YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);
-
- /**
- * Specifies whether the Tooltip should be kept from overlapping its context element.
- * @config preventoverlap
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } );
-
- /**
- * The number of milliseconds to wait before showing a Tooltip on mouseover.
- * @config showdelay
- * @type Number
- * @default 200
- */
- this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } );
-
- /**
- * The number of milliseconds to wait before automatically dismissing a Tooltip after the mouse has been resting on the context element.
- * @config autodismissdelay
- * @type Number
- * @default 5000
- */
- this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } );
-
- /**
- * The number of milliseconds to wait before hiding a Tooltip on mouseover.
- * @config hidedelay
- * @type Number
- * @default 250
- */
- this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } );
-
- /**
- * Specifies the Tooltip's text.
- * @config text
- * @type String
- * @default null
- */
- this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } );
-
- /**
- * Specifies the container element that the Tooltip's markup should be rendered into.
- * @config container
- * @type HTMLElement/String
- * @default document.body
- */
- this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } );
-
- /**
- * Specifies the element or elements that the Tooltip should be anchored to on mouseover.
- * @config context
- * @type HTMLElement[]/String[]
- * @default null
- */
-
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* The default event handler fired when the "text" property is changed.
-* @method configText
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) {
- var text = args[0];
- if (text) {
- this.setBody(text);
- }
-};
-
-/**
-* The default event handler fired when the "container" property is changed.
-* @method configContainer
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) {
- var container = args[0];
- if (typeof container == 'string') {
- this.cfg.setProperty("container", document.getElementById(container), true);
- }
-};
-
-/**
-* The default event handler fired when the "context" property is changed.
-* @method configContext
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) {
- var context = args[0];
- if (context) {
-
- // Normalize parameter into an array
- if (! (context instanceof Array)) {
- if (typeof context == "string") {
- this.cfg.setProperty("context", [document.getElementById(context)], true);
- } else { // Assuming this is an element
- this.cfg.setProperty("context", [context], true);
- }
- context = this.cfg.getProperty("context");
- }
-
-
- // Remove any existing mouseover/mouseout listeners
- if (this._context) {
- for (var c=0;cOR
-* @param {HTMLElement} el The element representing the Panel
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details.
-*/
-YAHOO.widget.Panel = function(el, userConfig) {
- YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay);
-
-/**
-* Constant representing the default CSS class used for a Panel
-* @property YAHOO.widget.Panel.CSS_PANEL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Panel.CSS_PANEL = "panel";
-
-/**
-* Constant representing the default CSS class used for a Panel's wrapping container
-* @property YAHOO.widget.Panel.CSS_PANEL_CONTAINER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "panel-container";
-
-/**
-* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
-*/
-YAHOO.widget.Panel.prototype.init = function(el, userConfig) {
- YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.Panel);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL);
-
- this.buildWrapper();
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- this.beforeRenderEvent.subscribe(function() {
- var draggable = this.cfg.getProperty("draggable");
- if (draggable) {
- if (! this.header) {
- this.setHeader(" ");
- }
- }
- }, this, true);
-
- var me = this;
-
- var doBlur = function() {
- this.blur();
- };
-
- this.showMaskEvent.subscribe(function() {
- var checkFocusable = function(el) {
- if ((el.tagName == "A" || el.tagName == "BUTTON" || el.tagName == "SELECT" || el.tagName == "INPUT" || el.tagName == "TEXTAREA" || el.tagName == "FORM") && el.type != "hidden") {
- if (! YAHOO.util.Dom.isAncestor(me.element, el)) {
- YAHOO.util.Event.addListener(el, "focus", doBlur, el, true);
- return true;
- }
- } else {
- return false;
- }
- };
-
- this.focusableElements = YAHOO.util.Dom.getElementsBy(checkFocusable);
- }, this, true);
-
- this.hideMaskEvent.subscribe(function() {
- for (var i=0;iOR
-* @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
-* @return {boolean} Success or failure of the render
-*/
-YAHOO.widget.Panel.prototype.render = function(appendToNode) {
- return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement);
-};
-
-/**
-* Returns a String representation of the object.
-* @method toString
-* @return {String} The string representation of the Panel.
-*/
-YAHOO.widget.Panel.prototype.toString = function() {
- return "Panel " + this.id;
-};
-
-/**
-* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
-* @namespace YAHOO.widget
-* @class Dialog
-* @extends YAHOO.widget.Panel
-* @constructor
-* @param {String} el The element ID representing the Dialog OR
-* @param {HTMLElement} el The element representing the Dialog
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
-*/
-YAHOO.widget.Dialog = function(el, userConfig) {
- YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel);
-
-/**
-* Constant representing the default CSS class used for a Dialog
-* @property YAHOO.widget.Dialog.CSS_DIALOG
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Dialog.CSS_DIALOG = "dialog";
-
-/**
-* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.Dialog.prototype.initDefaultConfig = function() {
- YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this);
-
- /**
- * The internally maintained callback object for use with the Connection utility
- * @property callback
- * @type Object
- */
- this.callback = {
- /**
- * The function to execute upon success of the Connection submission
- * @property callback.success
- * @type Function
- */
- success : null,
- /**
- * The function to execute upon failure of the Connection submission
- * @property callback.failure
- * @type Function
- */
- failure : null,
- /**
- * The arbitraty argument or arguments to pass to the Connection callback functions
- * @property callback.argument
- * @type Object
- */
- argument: null
- };
-
- // Add form dialog config properties //
-
- /**
- * The method to use for posting the Dialog's form. Possible values are "async", "form", and "manual".
- * @config postmethod
- * @type String
- * @default async
- */
- this.cfg.addProperty("postmethod", { value:"async", handler:this.configPostMethod, validator:function(val) {
- if (val != "form" && val != "async" && val != "none" && val != "manual") {
- return false;
- } else {
- return true;
- }
- } });
-
- /**
- * Object literal(s) defining the buttons for the Dialog's footer.
- * @config buttons
- * @type Object[]
- * @default "none"
- */
- this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } );
-};
-
-/**
-* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class.
-* @method initEvents
-*/
-YAHOO.widget.Dialog.prototype.initEvents = function() {
- YAHOO.widget.Dialog.superclass.initEvents.call(this);
-
- /**
- * CustomEvent fired prior to submission
- * @event beforeSumitEvent
- */
- this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit");
-
- /**
- * CustomEvent fired after submission
- * @event submitEvent
- */
- this.submitEvent = new YAHOO.util.CustomEvent("submit");
-
- /**
- * CustomEvent fired prior to manual submission
- * @event manualSubmitEvent
- */
- this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit");
-
- /**
- * CustomEvent fired prior to asynchronous submission
- * @event asyncSubmitEvent
- */
- this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit");
-
- /**
- * CustomEvent fired prior to form-based submission
- * @event formSubmitEvent
- */
- this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit");
-
- /**
- * CustomEvent fired after cancel
- * @event cancelEvent
- */
- this.cancelEvent = new YAHOO.util.CustomEvent("cancel");
-};
-
-/**
-* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the Dialog OR
-* @param {HTMLElement} el The element representing the Dialog
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
-*/
-YAHOO.widget.Dialog.prototype.init = function(el, userConfig) {
- YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.Dialog);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG);
-
- this.cfg.setProperty("visible", false);
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- this.showEvent.subscribe(this.focusFirst, this, true);
- this.beforeHideEvent.subscribe(this.blurButtons, this, true);
-
- this.beforeRenderEvent.subscribe(function() {
- var buttonCfg = this.cfg.getProperty("buttons");
- if (buttonCfg && buttonCfg != "none") {
- if (! this.footer) {
- this.setFooter("");
- }
- }
- }, this, true);
-
- this.initEvent.fire(YAHOO.widget.Dialog);
-};
-
-/**
-* Performs the submission of the Dialog form depending on the value of "postmethod" property.
-* @method doSubmit
-*/
-YAHOO.widget.Dialog.prototype.doSubmit = function() {
- var pm = this.cfg.getProperty("postmethod");
- switch (pm) {
- case "async":
- var method = this.form.getAttribute("method") || 'POST';
- method = method.toUpperCase();
- YAHOO.util.Connect.setForm(this.form);
- var cObj = YAHOO.util.Connect.asyncRequest(method, this.form.getAttribute("action"), this.callback);
- this.asyncSubmitEvent.fire();
- break;
- case "form":
- this.form.submit();
- this.formSubmitEvent.fire();
- break;
- case "none":
- case "manual":
- this.manualSubmitEvent.fire();
- break;
- }
-};
-
-/**
-* Prepares the Dialog's internal FORM object, creating one if one is not currently present.
-* @method registerForm
-*/
-YAHOO.widget.Dialog.prototype.registerForm = function() {
- var form = this.element.getElementsByTagName("FORM")[0];
-
- if (! form) {
- var formHTML = "";
- this.body.innerHTML += formHTML;
- form = this.element.getElementsByTagName("FORM")[0];
- }
-
- this.firstFormElement = function() {
- for (var f=0;f=0;f-- ) {
- var el = form.elements[f];
- if (el.focus) {
- if (el.type && el.type != "hidden") {
- return el;
- }
- }
- }
- return null;
- }();
-
- this.form = form;
-
- if (this.cfg.getProperty("modal") && this.form) {
-
- var me = this;
-
- var firstElement = this.firstFormElement || this.firstButton;
- if (firstElement) {
- this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} );
- this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true);
- this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true);
- }
-
- var lastElement = this.lastButton || this.lastFormElement;
- if (lastElement) {
- this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} );
- this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true);
- this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true);
- }
- }
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* The default event handler for the "buttons" configuration property
-* @method configButtons
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) {
- var buttons = args[0];
- if (buttons != "none") {
- this.buttonSpan = null;
- this.buttonSpan = document.createElement("SPAN");
- this.buttonSpan.className = "button-group";
-
- for (var b=0;bOR
-* @param {HTMLElement} el The element representing the SimpleDialog
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
-*/
-YAHOO.widget.SimpleDialog = function(el, userConfig) {
- YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog);
-
-/**
-* Constant for the standard network icon for a blocking action
-* @property YAHOO.widget.SimpleDialog.ICON_BLOCK
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_BLOCK = "nt/ic/ut/bsc/blck16_1.gif";
-
-/**
-* Constant for the standard network icon for alarm
-* @property YAHOO.widget.SimpleDialog.ICON_ALARM
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_ALARM = "nt/ic/ut/bsc/alrt16_1.gif";
-
-/**
-* Constant for the standard network icon for help
-* @property YAHOO.widget.SimpleDialog.ICON_HELP
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_HELP = "nt/ic/ut/bsc/hlp16_1.gif";
-
-/**
-* Constant for the standard network icon for info
-* @property YAHOO.widget.SimpleDialog.ICON_INFO
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_INFO = "nt/ic/ut/bsc/info16_1.gif";
-
-/**
-* Constant for the standard network icon for warn
-* @property YAHOO.widget.SimpleDialog.ICON_WARN
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_WARN = "nt/ic/ut/bsc/warn16_1.gif";
-
-/**
-* Constant for the standard network icon for a tip
-* @property YAHOO.widget.SimpleDialog.ICON_TIP
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_TIP = "nt/ic/ut/bsc/tip16_1.gif";
-
-/**
-* Constant representing the default CSS class used for a SimpleDialog
-* @property YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "simple-dialog";
-
-/**
-* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() {
- YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this);
-
- // Add dialog config properties //
-
- /**
- * Sets the informational icon for the SimpleDialog
- * @config icon
- * @type String
- * @default "none"
- */
- this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } );
-
- /**
- * Sets the text for the SimpleDialog
- * @config text
- * @type String
- * @default ""
- */
- this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } );
-};
-
-
-/**
-* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the SimpleDialog OR
-* @param {HTMLElement} el The element representing the SimpleDialog
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
-*/
-YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) {
- YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG);
-
- this.cfg.queueProperty("postmethod", "manual");
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- this.beforeRenderEvent.subscribe(function() {
- if (! this.body) {
- this.setBody("");
- }
- }, this, true);
-
- this.initEvent.fire(YAHOO.widget.SimpleDialog);
-
-};
-/**
-* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field.
-* @method registerForm
-*/
-YAHOO.widget.SimpleDialog.prototype.registerForm = function() {
- YAHOO.widget.SimpleDialog.superclass.registerForm.call(this);
- this.form.innerHTML += " ";
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* Fired when the "icon" property is set.
-* @method configIcon
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) {
- var icon = args[0];
- if (icon && icon != "none") {
- var iconHTML = " ";
- this.body.innerHTML = iconHTML + this.body.innerHTML;
- }
-};
-
-/**
-* Fired when the "text" property is set.
-* @method configText
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) {
- var text = args[0];
- if (text) {
- this.setBody(text);
- this.cfg.refireEvent("icon");
- }
-};
-// END BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* Returns a string representation of the object.
-* @method toString
-* @return {String} The string representation of the SimpleDialog
-*/
-YAHOO.widget.SimpleDialog.prototype.toString = function() {
- return "SimpleDialog " + this.id;
-};
-
-/**
-* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden.
-* @namespace YAHOO.widget
-* @class ContainerEffect
-* @constructor
-* @param {YAHOO.widget.Overlay} overlay The Overlay that the animation should be associated with
-* @param {Object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
-* @param {Object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
-* @param {HTMLElement} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element.
-* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion.
-*/
-YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) {
- if (! animClass) {
- animClass = YAHOO.util.Anim;
- }
-
- /**
- * The overlay to animate
- * @property overlay
- * @type YAHOO.widget.Overlay
- */
- this.overlay = overlay;
- /**
- * The animation attributes to use when transitioning into view
- * @property attrIn
- * @type Object
- */
- this.attrIn = attrIn;
- /**
- * The animation attributes to use when transitioning out of view
- * @property attrOut
- * @type Object
- */
- this.attrOut = attrOut;
- /**
- * The target element to be animated
- * @property targetElement
- * @type HTMLElement
- */
- this.targetElement = targetElement || overlay.element;
- /**
- * The animation class to use for animating the overlay
- * @property animClass
- * @type class
- */
- this.animClass = animClass;
-};
-
-/**
-* Initializes the animation classes and events.
-* @method init
-*/
-YAHOO.widget.ContainerEffect.prototype.init = function() {
- this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn");
- this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut");
-
- this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete");
- this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete");
-
- this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method);
- this.animIn.onStart.subscribe(this.handleStartAnimateIn, this);
- this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this);
- this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this);
-
- this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method);
- this.animOut.onStart.subscribe(this.handleStartAnimateOut, this);
- this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this);
- this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this);
-};
-
-/**
-* Triggers the in-animation.
-* @method animateIn
-*/
-YAHOO.widget.ContainerEffect.prototype.animateIn = function() {
- this.beforeAnimateInEvent.fire();
- this.animIn.animate();
-};
-
-/**
-* Triggers the out-animation.
-* @method animateOut
-*/
-YAHOO.widget.ContainerEffect.prototype.animateOut = function() {
- this.beforeAnimateOutEvent.fire();
- this.animOut.animate();
-};
-
-/**
-* The default onStart handler for the in-animation.
-* @method handleStartAnimateIn
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { };
-/**
-* The default onTween handler for the in-animation.
-* @method handleTweenAnimateIn
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { };
-/**
-* The default onComplete handler for the in-animation.
-* @method handleCompleteAnimateIn
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { };
-
-/**
-* The default onStart handler for the out-animation.
-* @method handleStartAnimateOut
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { };
-/**
-* The default onTween handler for the out-animation.
-* @method handleTweenAnimateOut
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { };
-/**
-* The default onComplete handler for the out-animation.
-* @method handleCompleteAnimateOut
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { };
-
-/**
-* Returns a string representation of the object.
-* @method toString
-* @return {String} The string representation of the ContainerEffect
-*/
-YAHOO.widget.ContainerEffect.prototype.toString = function() {
- var output = "ContainerEffect";
- if (this.overlay) {
- output += " [" + this.overlay.toString() + "]";
- }
- return output;
-};
-
-/**
-* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out.
-* @method FADE
-* @static
-* @param {Overlay} overlay The Overlay object to animate
-* @param {Number} dur The duration of the animation
-* @return {ContainerEffect} The configured ContainerEffect object
-*/
-YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) {
- var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element );
-
- fade.handleStartAnimateIn = function(type,args,obj) {
- YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
-
- if (! obj.overlay.underlay) {
- obj.overlay.cfg.refireEvent("underlay");
- }
-
- if (obj.overlay.underlay) {
- obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity");
- obj.overlay.underlay.style.filter = null;
- }
-
- YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
- YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0);
- };
-
- fade.handleCompleteAnimateIn = function(type,args,obj) {
- YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
-
- if (obj.overlay.element.style.filter) {
- obj.overlay.element.style.filter = null;
- }
-
- if (obj.overlay.underlay) {
- YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity);
- }
-
- obj.overlay.cfg.refireEvent("iframe");
- obj.animateInCompleteEvent.fire();
- };
-
- fade.handleStartAnimateOut = function(type, args, obj) {
- YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
-
- if (obj.overlay.underlay) {
- obj.overlay.underlay.style.filter = null;
- }
- };
-
- fade.handleCompleteAnimateOut = function(type, args, obj) {
- YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
- if (obj.overlay.element.style.filter) {
- obj.overlay.element.style.filter = null;
- }
- YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
- YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1);
-
- obj.overlay.cfg.refireEvent("iframe");
-
- obj.animateOutCompleteEvent.fire();
- };
-
- fade.init();
- return fade;
-};
-
-
-/**
-* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out.
-* @method SLIDE
-* @static
-* @param {Overlay} overlay The Overlay object to animate
-* @param {Number} dur The duration of the animation
-* @return {ContainerEffect} The configured ContainerEffect object
-*/
-YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) {
- var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element);
- var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element);
-
- var clientWidth = YAHOO.util.Dom.getClientWidth();
- var offsetWidth = overlay.element.offsetWidth;
-
- var slide = new YAHOO.widget.ContainerEffect(overlay, {
- attributes:{ points: { to:[x, y] } },
- duration:dur,
- method:YAHOO.util.Easing.easeIn
- },
- {
- attributes:{ points: { to:[(clientWidth+25), y] } },
- duration:dur,
- method:YAHOO.util.Easing.easeOut
- },
- overlay.element,
- YAHOO.util.Motion);
-
-
- slide.handleStartAnimateIn = function(type,args,obj) {
- obj.overlay.element.style.left = (-25-offsetWidth) + "px";
- obj.overlay.element.style.top = y + "px";
- };
-
- slide.handleTweenAnimateIn = function(type, args, obj) {
-
-
- var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
-
- var currentX = pos[0];
- var currentY = pos[1];
-
- if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) {
- YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
- }
-
- obj.overlay.cfg.setProperty("xy", [currentX,currentY], true);
- obj.overlay.cfg.refireEvent("iframe");
- };
-
- slide.handleCompleteAnimateIn = function(type, args, obj) {
- obj.overlay.cfg.setProperty("xy", [x,y], true);
- obj.startX = x;
- obj.startY = y;
- obj.overlay.cfg.refireEvent("iframe");
- obj.animateInCompleteEvent.fire();
- };
-
- slide.handleStartAnimateOut = function(type, args, obj) {
- var vw = YAHOO.util.Dom.getViewportWidth();
-
- var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
-
- var yso = pos[1];
-
- var currentTo = obj.animOut.attributes.points.to;
- obj.animOut.attributes.points.to = [(vw+25), yso];
- };
-
- slide.handleTweenAnimateOut = function(type, args, obj) {
- var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
-
- var xto = pos[0];
- var yto = pos[1];
-
- obj.overlay.cfg.setProperty("xy", [xto,yto], true);
- obj.overlay.cfg.refireEvent("iframe");
- };
-
- slide.handleCompleteAnimateOut = function(type, args, obj) {
- YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
-
- obj.overlay.cfg.setProperty("xy", [x,y]);
- obj.animateOutCompleteEvent.fire();
- };
-
- slide.init();
- return slide;
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/**
+* Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
+* @namespace YAHOO.util
+* @class Config
+* @constructor
+* @param {Object} owner The owner Object to which this Config Object belongs
+*/
+YAHOO.util.Config = function(owner) {
+ if (owner) {
+ this.init(owner);
+ } else {
+ YAHOO.log("No owner specified for Config object", "error");
+ }
+};
+
+YAHOO.util.Config.prototype = {
+
+ /**
+ * Object reference to the owner of this Config Object
+ * @property owner
+ * @type Object
+ */
+ owner : null,
+
+ /**
+ * Boolean flag that specifies whether a queue is currently being executed
+ * @property queueInProgress
+ * @type Boolean
+ */
+ queueInProgress : false,
+
+
+ /**
+ * Validates that the value passed in is a Boolean.
+ * @method checkBoolean
+ * @param {Object} val The value to validate
+ * @return {Boolean} true, if the value is valid
+ */
+ checkBoolean: function(val) {
+ if (typeof val == 'boolean') {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Validates that the value passed in is a number.
+ * @method checkNumber
+ * @param {Object} val The value to validate
+ * @return {Boolean} true, if the value is valid
+ */
+ checkNumber: function(val) {
+ if (isNaN(val)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+};
+
+
+/**
+* Initializes the configuration Object and all of its local members.
+* @method init
+* @param {Object} owner The owner Object to which this Config Object belongs
+*/
+YAHOO.util.Config.prototype.init = function(owner) {
+
+ this.owner = owner;
+
+ /**
+ * Object reference to the owner of this Config Object
+ * @event configChangedEvent
+ */
+ this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
+ this.queueInProgress = false;
+
+ /* Private Members */
+
+ /**
+ * Maintains the local collection of configuration property objects and their specified values
+ * @property config
+ * @private
+ * @type Object
+ */
+ var config = {};
+
+ /**
+ * Maintains the local collection of configuration property objects as they were initially applied.
+ * This object is used when resetting a property.
+ * @property initialConfig
+ * @private
+ * @type Object
+ */
+ var initialConfig = {};
+
+ /**
+ * Maintains the local, normalized CustomEvent queue
+ * @property eventQueue
+ * @private
+ * @type Object
+ */
+ var eventQueue = [];
+
+ /**
+ * Fires a configuration property event using the specified value.
+ * @method fireEvent
+ * @private
+ * @param {String} key The configuration property's name
+ * @param {value} Object The value of the correct type for the property
+ */
+ var fireEvent = function( key, value ) {
+ YAHOO.log("Firing Config event: " + key + "=" + value, "info");
+
+ key = key.toLowerCase();
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ property.event.fire(value);
+ }
+ };
+ /* End Private Members */
+
+ /**
+ * Adds a property to the Config Object's private config hash.
+ * @method addProperty
+ * @param {String} key The configuration property's name
+ * @param {Object} propertyObject The Object containing all of this property's arguments
+ */
+ this.addProperty = function( key, propertyObject ) {
+ key = key.toLowerCase();
+
+ YAHOO.log("Added property: " + key, "info");
+
+ config[key] = propertyObject;
+
+ propertyObject.event = new YAHOO.util.CustomEvent(key);
+ propertyObject.key = key;
+
+ if (propertyObject.handler) {
+ propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
+ }
+
+ this.setProperty(key, propertyObject.value, true);
+
+ if (! propertyObject.suppressEvent) {
+ this.queueProperty(key, propertyObject.value);
+ }
+ };
+
+ /**
+ * Returns a key-value configuration map of the values currently set in the Config Object.
+ * @method getConfig
+ * @return {Object} The current config, represented in a key-value map
+ */
+ this.getConfig = function() {
+ var cfg = {};
+
+ for (var prop in config) {
+ var property = config[prop];
+ if (typeof property != 'undefined' && property.event) {
+ cfg[prop] = property.value;
+ }
+ }
+
+ return cfg;
+ };
+
+ /**
+ * Returns the value of specified property.
+ * @method getProperty
+ * @param {String} key The name of the property
+ * @return {Object} The value of the specified property
+ */
+ this.getProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.value;
+ } else {
+ return undefined;
+ }
+ };
+
+ /**
+ * Resets the specified property's value to its initial value.
+ * @method resetProperty
+ * @param {String} key The name of the property
+ * @return {Boolean} True is the property was reset, false if not
+ */
+ this.resetProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (initialConfig[key] && initialConfig[key] != 'undefined') {
+ this.setProperty(key, initialConfig[key]);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
+ * @method setProperty
+ * @param {String} key The name of the property
+ * @param {String} value The value to set the property to
+ * @param {Boolean} silent Whether the value should be set silently, without firing the property event.
+ * @return {Boolean} True, if the set was successful, false if it failed.
+ */
+ this.setProperty = function(key, value, silent) {
+ key = key.toLowerCase();
+
+ YAHOO.log("setProperty: " + key + "=" + value, "info");
+
+ if (this.queueInProgress && ! silent) {
+ this.queueProperty(key,value); // Currently running through a queue...
+ return true;
+ } else {
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+ property.value = value;
+ if (! silent) {
+ fireEvent(key, value);
+ this.configChangedEvent.fire([key, value]);
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+ };
+
+ /**
+ * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
+ * moved from its current position to the end of the queue.
+ * @method queueProperty
+ * @param {String} key The name of the property
+ * @param {String} value The value to set the property to
+ * @return {Boolean} true, if the set was successful, false if it failed.
+ */
+ this.queueProperty = function(key, value) {
+ key = key.toLowerCase();
+
+ YAHOO.log("queueProperty: " + key + "=" + value, "info");
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+
+ if (typeof value != 'undefined') {
+ property.value = value;
+ } else {
+ value = property.value;
+ }
+
+ var foundDuplicate = false;
+
+ for (var i=0;iOR
+* @param {HTMLElement} el The element representing the Module
+* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+*/
+YAHOO.widget.Module = function(el, userConfig) {
+ if (el) {
+ this.init(el, userConfig);
+ } else {
+ YAHOO.log("No element or element ID specified for Module instantiation", "error");
+ }
+};
+
+/**
+* Constant representing the prefix path to use for non-secure images
+* @property YAHOO.widget.Module.IMG_ROOT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
+
+/**
+* Constant representing the prefix path to use for securely served images
+* @property YAHOO.widget.Module.IMG_ROOT_SSL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
+
+/**
+* Constant for the default CSS class name that represents a Module
+* @property YAHOO.widget.Module.CSS_MODULE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_MODULE = "module";
+
+/**
+* Constant representing the module header
+* @property YAHOO.widget.Module.CSS_HEADER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_HEADER = "hd";
+
+/**
+* Constant representing the module body
+* @property YAHOO.widget.Module.CSS_BODY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_BODY = "bd";
+
+/**
+* Constant representing the module footer
+* @property YAHOO.widget.Module.CSS_FOOTER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_FOOTER = "ft";
+
+/**
+* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
+* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";
+
+/**
+* Singleton CustomEvent fired when the font size is changed in the browser.
+* Opera's "zoom" functionality currently does not support text size detection.
+* @event YAHOO.widget.Module.textResizeEvent
+*/
+YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");
+
+YAHOO.widget.Module.prototype = {
+ /**
+ * The class's constructor function
+ * @property contructor
+ * @type Function
+ */
+ constructor : YAHOO.widget.Module,
+
+ /**
+ * The main module element that contains the header, body, and footer
+ * @property element
+ * @type HTMLElement
+ */
+ element : null,
+
+ /**
+ * The header element, denoted with CSS class "hd"
+ * @property header
+ * @type HTMLElement
+ */
+ header : null,
+
+ /**
+ * The body element, denoted with CSS class "bd"
+ * @property body
+ * @type HTMLElement
+ */
+ body : null,
+
+ /**
+ * The footer element, denoted with CSS class "ft"
+ * @property footer
+ * @type HTMLElement
+ */
+ footer : null,
+
+ /**
+ * The id of the element
+ * @property id
+ * @type String
+ */
+ id : null,
+
+ /**
+ * The String representing the image root
+ * @property imageRoot
+ * @type String
+ */
+ imageRoot : YAHOO.widget.Module.IMG_ROOT,
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ * @method initEvents
+ */
+ initEvents : function() {
+
+ /**
+ * CustomEvent fired prior to class initalization.
+ * @event beforeInitEvent
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ */
+ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
+
+ /**
+ * CustomEvent fired after class initalization.
+ * @event initEvent
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ */
+ this.initEvent = new YAHOO.util.CustomEvent("init");
+
+ /**
+ * CustomEvent fired when the Module is appended to the DOM
+ * @event appendEvent
+ */
+ this.appendEvent = new YAHOO.util.CustomEvent("append");
+
+ /**
+ * CustomEvent fired before the Module is rendered
+ * @event beforeRenderEvent
+ */
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+
+ /**
+ * CustomEvent fired after the Module is rendered
+ * @event renderEvent
+ */
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ /**
+ * CustomEvent fired when the header content of the Module is modified
+ * @event changeHeaderEvent
+ * @param {String/HTMLElement} content String/element representing the new header content
+ */
+ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
+
+ /**
+ * CustomEvent fired when the body content of the Module is modified
+ * @event changeBodyEvent
+ * @param {String/HTMLElement} content String/element representing the new body content
+ */
+ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
+
+ /**
+ * CustomEvent fired when the footer content of the Module is modified
+ * @event changeFooterEvent
+ * @param {String/HTMLElement} content String/element representing the new footer content
+ */
+ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
+
+ /**
+ * CustomEvent fired when the content of the Module is modified
+ * @event changeContentEvent
+ */
+ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
+
+ /**
+ * CustomEvent fired when the Module is destroyed
+ * @event destroyEvent
+ */
+ this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
+
+ /**
+ * CustomEvent fired before the Module is shown
+ * @event beforeShowEvent
+ */
+ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
+
+ /**
+ * CustomEvent fired after the Module is shown
+ * @event showEvent
+ */
+ this.showEvent = new YAHOO.util.CustomEvent("show");
+
+ /**
+ * CustomEvent fired before the Module is hidden
+ * @event beforeHideEvent
+ */
+ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
+
+ /**
+ * CustomEvent fired after the Module is hidden
+ * @event hideEvent
+ */
+ this.hideEvent = new YAHOO.util.CustomEvent("hide");
+ },
+
+ /**
+ * String representing the current user-agent platform
+ * @property platform
+ * @type String
+ */
+ platform : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
+ return "windows";
+ } else if (ua.indexOf("macintosh") != -1) {
+ return "mac";
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * String representing the current user-agent browser
+ * @property browser
+ * @type String
+ */
+ browser : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
+ return 'opera';
+ } else if (ua.indexOf('msie 7')!=-1) { // IE7
+ return 'ie7';
+ } else if (ua.indexOf('msie') !=-1) { // IE
+ return 'ie';
+ } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ } else if (ua.indexOf('gecko') != -1) { // Gecko
+ return 'gecko';
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Boolean representing whether or not the current browsing context is secure (https)
+ * @property isSecure
+ * @type Boolean
+ */
+ isSecure : function() {
+ if (window.location.href.toLowerCase().indexOf("https") === 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initDefaultConfig : function() {
+ // Add properties //
+
+ /**
+ * Specifies whether the Module is visible on the page.
+ * @config visible
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
+
+ /**
+ * Object or array of objects representing the ContainerEffect classes that are active for animating the container.
+ * @config effect
+ * @type Object
+ * @default null
+ */
+ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
+
+ /**
+ * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document
+ * @config monitorresize
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
+ },
+
+ /**
+ * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+ * @method init
+ * @param {String} el The element ID representing the Module OR
+ * @param {HTMLElement} el The element representing the Module
+ * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+ */
+ init : function(el, userConfig) {
+
+ this.initEvents();
+
+ this.beforeInitEvent.fire(YAHOO.widget.Module);
+
+ /**
+ * The Module's Config object used for monitoring configuration properties.
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ if (this.isSecure) {
+ this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
+ }
+
+ if (typeof el == "string") {
+ var elId = el;
+
+ el = document.getElementById(el);
+ if (! el) {
+ el = document.createElement("DIV");
+ el.id = elId;
+ }
+ }
+
+ this.element = el;
+
+ if (el.id) {
+ this.id = el.id;
+ }
+
+ var childNodes = this.element.childNodes;
+
+ if (childNodes) {
+ for (var i=0;iOR
+ * @param {HTMLElement} headerContent The HTMLElement to append to the header
+ */
+ setHeader : function(headerContent) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ if (typeof headerContent == "string") {
+ this.header.innerHTML = headerContent;
+ } else {
+ this.header.innerHTML = "";
+ this.header.appendChild(headerContent);
+ }
+
+ this.changeHeaderEvent.fire(headerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the header. If no header is present, one will be automatically created.
+ * @method appendToHeader
+ * @param {HTMLElement} element The element to append to the header
+ */
+ appendToHeader : function(element) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ this.header.appendChild(element);
+ this.changeHeaderEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
+ * @method setBody
+ * @param {String} bodyContent The HTML used to set the body OR
+ * @param {HTMLElement} bodyContent The HTMLElement to append to the body
+ */
+ setBody : function(bodyContent) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ if (typeof bodyContent == "string")
+ {
+ this.body.innerHTML = bodyContent;
+ } else {
+ this.body.innerHTML = "";
+ this.body.appendChild(bodyContent);
+ }
+
+ this.changeBodyEvent.fire(bodyContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the body. If no body is present, one will be automatically created.
+ * @method appendToBody
+ * @param {HTMLElement} element The element to append to the body
+ */
+ appendToBody : function(element) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ this.body.appendChild(element);
+ this.changeBodyEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @method setFooter
+ * @param {String} footerContent The HTML used to set the footer OR
+ * @param {HTMLElement} footerContent The HTMLElement to append to the footer
+ */
+ setFooter : function(footerContent) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ if (typeof footerContent == "string") {
+ this.footer.innerHTML = footerContent;
+ } else {
+ this.footer.innerHTML = "";
+ this.footer.appendChild(footerContent);
+ }
+
+ this.changeFooterEvent.fire(footerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @method appendToFooter
+ * @param {HTMLElement} element The element to append to the footer
+ */
+ appendToFooter : function(element) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ this.footer.appendChild(element);
+ this.changeFooterEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+ * @method render
+ * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering OR
+ * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
+ * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
+ * @return {Boolean} Success or failure of the render
+ */
+ render : function(appendToNode, moduleElement) {
+ this.beforeRenderEvent.fire();
+
+ if (! moduleElement) {
+ moduleElement = this.element;
+ }
+
+ var me = this;
+ var appendTo = function(element) {
+ if (typeof element == "string") {
+ element = document.getElementById(element);
+ }
+
+ if (element) {
+ element.appendChild(me.element);
+ me.appendEvent.fire();
+ }
+ };
+
+ if (appendToNode) {
+ appendTo(appendToNode);
+ } else { // No node was passed in. If the element is not pre-marked up, this fails
+ if (! YAHOO.util.Dom.inDocument(this.element)) {
+ YAHOO.log("Render failed. Must specify appendTo node if Module isn't already in the DOM.", "error");
+ return false;
+ }
+ }
+
+ // Need to get everything into the DOM if it isn't already
+
+ if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
+ // There is a header, but it's not in the DOM yet... need to add it
+ var firstChild = moduleElement.firstChild;
+ if (firstChild) { // Insert before first child if exists
+ moduleElement.insertBefore(this.header, firstChild);
+ } else { // Append to empty body because there are no children
+ moduleElement.appendChild(this.header);
+ }
+ }
+
+ if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
+ // There is a body, but it's not in the DOM yet... need to add it
+ if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
+ moduleElement.insertBefore(this.body, this.footer);
+ } else { // Append to element because there is no footer
+ moduleElement.appendChild(this.body);
+ }
+ }
+
+ if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
+ // There is a footer, but it's not in the DOM yet... need to add it
+ moduleElement.appendChild(this.footer);
+ }
+
+ this.renderEvent.fire();
+ return true;
+ },
+
+ /**
+ * Removes the Module element from the DOM and sets all child elements to null.
+ * @method destroy
+ */
+ destroy : function() {
+ var parent;
+
+ if (this.element) {
+ YAHOO.util.Event.purgeElement(this.element, true);
+ parent = this.element.parentNode;
+ }
+ if (parent) {
+ parent.removeChild(this.element);
+ }
+
+ this.element = null;
+ this.header = null;
+ this.body = null;
+ this.footer = null;
+
+ for (var e in this) {
+ if (e instanceof YAHOO.util.CustomEvent) {
+ e.unsubscribeAll();
+ }
+ }
+
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this);
+
+ this.destroyEvent.fire();
+ },
+
+ /**
+ * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
+ * @method show
+ */
+ show : function() {
+ this.cfg.setProperty("visible", true);
+ },
+
+ /**
+ * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
+ * @method hide
+ */
+ hide : function() {
+ this.cfg.setProperty("visible", false);
+ },
+
+ // BUILT-IN EVENT HANDLERS FOR MODULE //
+
+ /**
+ * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
+ * This method is responsible for firing showEvent and hideEvent.
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ * @method configVisible
+ */
+ configVisible : function(type, args, obj) {
+ var visible = args[0];
+ if (visible) {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "block");
+ this.showEvent.fire();
+ } else {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "none");
+ this.hideEvent.fire();
+ }
+ },
+
+ /**
+ * Default event handler for the "monitorresize" configuration property
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ * @method configMonitorResize
+ */
+ configMonitorResize : function(type, args, obj) {
+ var monitor = args[0];
+ if (monitor) {
+ this.initResizeMonitor();
+ } else {
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this, true);
+ this.resizeMonitor = null;
+ }
+ }
+};
+
+/**
+* Returns a String representation of the Object.
+* @method toString
+* @return {String} The string representation of the Module
+*/
+YAHOO.widget.Module.prototype.toString = function() {
+ return "Module " + this.id;
+};
+
+/**
+* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
+* @namespace YAHOO.widget
+* @class Overlay
+* @extends YAHOO.widget.Module
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Overlay = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
+
+/**
+* The URL that will be placed in the iframe
+* @property YAHOO.widget.Overlay.IFRAME_SRC
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;";
+
+/**
+* Constant representing the top left corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.TOP_LEFT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.TOP_LEFT = "tl";
+
+/**
+* Constant representing the top right corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.TOP_RIGHT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.TOP_RIGHT = "tr";
+
+/**
+* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.BOTTOM_LEFT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
+
+/**
+* Constant representing the bottom right corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.BOTTOM_RIGHT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
+
+/**
+* Constant representing the default CSS class used for an Overlay
+* @property YAHOO.widget.Overlay.CSS_OVERLAY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Overlay);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ if (this.platform == "mac" && this.browser == "gecko") {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
+ this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
+ this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
+ }
+ }
+
+ this.initEvent.fire(YAHOO.widget.Overlay);
+
+};
+
+/**
+* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
+* @method initEvents
+*/
+YAHOO.widget.Overlay.prototype.initEvents = function() {
+ YAHOO.widget.Overlay.superclass.initEvents.call(this);
+
+ /**
+ * CustomEvent fired before the Overlay is moved.
+ * @event beforeMoveEvent
+ * @param {Number} x x coordinate
+ * @param {Number} y y coordinate
+ */
+ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
+
+ /**
+ * CustomEvent fired after the Overlay is moved.
+ * @event moveEvent
+ * @param {Number} x x coordinate
+ * @param {Number} y y coordinate
+ */
+ this.moveEvent = new YAHOO.util.CustomEvent("move", this);
+};
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
+
+ // Add overlay config properties //
+
+ /**
+ * The absolute x-coordinate position of the Overlay
+ * @config x
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * The absolute y-coordinate position of the Overlay
+ * @config y
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * An array with the absolute x and y positions of the Overlay
+ * @config xy
+ * @type Number[]
+ * @default null
+ */
+ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner.
+ * @config context
+ * @type Array
+ * @default null
+ */
+ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * True if the Overlay should be anchored to the center of the viewport.
+ * @config fixedcenter
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
+
+ /**
+ * CSS width of the Overlay.
+ * @config width
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * CSS height of the Overlay.
+ * @config height
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * CSS z-index of the Overlay.
+ * @config zIndex
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
+
+ /**
+ * True if the Overlay should be prevented from being positioned out of the viewport.
+ * @config constraintoviewport
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
+
+ /**
+ * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below).
+ * @config iframe
+ * @type Boolean
+ * @default true for IE6 and below, false for all others
+ */
+ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
+};
+
+/**
+* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
+* @method moveTo
+* @param {Number} x The Overlay's new x position
+* @param {Number} y The Overlay's new y position
+*/
+YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
+ this.cfg.setProperty("xy",[x,y]);
+};
+
+/**
+* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+* @method hideMacGeckoScrollbars
+*/
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
+};
+
+/**
+* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+* @method showMacGeckoScrollbars
+*/
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
+* @method configVisible
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
+ var visible = args[0];
+ var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
+
+ if (currentVis == "inherit") {
+ var e = this.element.parentNode;
+ while (e.nodeType != 9 && e.nodeType != 11) {
+ currentVis = YAHOO.util.Dom.getStyle(e, "visibility");
+ if (currentVis != "inherit") { break; }
+ e = e.parentNode;
+ }
+ if (currentVis == "inherit") {
+ currentVis = "visible";
+ }
+ }
+
+ var effect = this.cfg.getProperty("effect");
+
+ var effectInstances = [];
+ if (effect) {
+ if (effect instanceof Array) {
+ for (var i=0;i rightConstraint) {
+ x = rightConstraint;
+ }
+
+ if (y < topConstraint) {
+ y = topConstraint;
+ } else if (y > bottomConstraint) {
+ y = bottomConstraint;
+ }
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+ this.cfg.setProperty("xy", [x,y], true);
+};
+
+/**
+* Centers the container in the viewport.
+* @method center
+*/
+YAHOO.widget.Overlay.prototype.center = function() {
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+
+ var viewPortWidth = YAHOO.util.Dom.getClientWidth();
+ var viewPortHeight = YAHOO.util.Dom.getClientHeight();
+
+ var elementWidth = this.element.offsetWidth;
+ var elementHeight = this.element.offsetHeight;
+
+ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
+ var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
+
+ this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
+
+ this.cfg.refireEvent("iframe");
+};
+
+/**
+* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
+* @method syncPosition
+*/
+YAHOO.widget.Overlay.prototype.syncPosition = function() {
+ var pos = YAHOO.util.Dom.getXY(this.element);
+ this.cfg.setProperty("x", pos[0], true);
+ this.cfg.setProperty("y", pos[1], true);
+ this.cfg.setProperty("xy", pos, true);
+};
+
+/**
+* Event handler fired when the resize monitor element is resized.
+* @method onDomResize
+* @param {DOMEvent} e The resize DOM event
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
+ var me = this;
+ setTimeout(function() {
+ me.syncPosition();
+ me.cfg.refireEvent("iframe");
+ me.cfg.refireEvent("context");
+ }, 0);
+};
+
+/**
+* Removes the Overlay element from the DOM and sets all child elements to null.
+* @method destroy
+*/
+YAHOO.widget.Overlay.prototype.destroy = function() {
+ if (this.iframe) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+
+ this.iframe = null;
+
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+
+ YAHOO.widget.Overlay.superclass.destroy.call(this);
+};
+
+/**
+* Returns a String representation of the object.
+* @method toString
+* @return {String} The string representation of the Overlay.
+*/
+YAHOO.widget.Overlay.prototype.toString = function() {
+ return "Overlay " + this.id;
+};
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window scroll
+* @event YAHOO.widget.Overlay.windowScrollEvent
+*/
+YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window resize
+* @event YAHOO.widget.Overlay.windowResizeEvent
+*/
+YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
+
+/**
+* The DOM event handler used to fire the CustomEvent for window scroll
+* @method YAHOO.widget.Overlay.windowScrollHandler
+* @static
+* @param {DOMEvent} e The DOM scroll event
+*/
+YAHOO.widget.Overlay.windowScrollHandler = function(e) {
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
+ if (! window.scrollEnd) {
+ window.scrollEnd = -1;
+ }
+ clearTimeout(window.scrollEnd);
+ window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1);
+ } else {
+ YAHOO.widget.Overlay.windowScrollEvent.fire();
+ }
+};
+
+/**
+* The DOM event handler used to fire the CustomEvent for window resize
+* @method YAHOO.widget.Overlay.windowResizeHandler
+* @static
+* @param {DOMEvent} e The DOM resize event
+*/
+YAHOO.widget.Overlay.windowResizeHandler = function(e) {
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
+ if (! window.resizeEnd) {
+ window.resizeEnd = -1;
+ }
+ clearTimeout(window.resizeEnd);
+ window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100);
+ } else {
+ YAHOO.widget.Overlay.windowResizeEvent.fire();
+ }
+};
+
+/**
+* A boolean that indicated whether the window resize and scroll events have already been subscribed to.
+* @property YAHOO.widget.Overlay._initialized
+* @private
+* @type Boolean
+*/
+YAHOO.widget.Overlay._initialized = null;
+
+if (YAHOO.widget.Overlay._initialized === null) {
+ YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
+ YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
+
+ YAHOO.widget.Overlay._initialized = true;
+}
+
+/**
+* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget
+* @namespace YAHOO.widget
+* @class OverlayManager
+* @constructor
+* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
+*/
+YAHOO.widget.OverlayManager = function(userConfig) {
+ this.init(userConfig);
+};
+
+/**
+* The CSS class representing a focused Overlay
+* @property YAHOO.widget.OverlayManager.CSS_FOCUSED
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
+
+YAHOO.widget.OverlayManager.prototype = {
+ /**
+ * The class's constructor function
+ * @property contructor
+ * @type Function
+ */
+ constructor : YAHOO.widget.OverlayManager,
+
+ /**
+ * The array of Overlays that are currently registered
+ * @property overlays
+ * @type YAHOO.widget.Overlay[]
+ */
+ overlays : null,
+
+ /**
+ * Initializes the default configuration of the OverlayManager
+ * @method initDefaultConfig
+ */
+ initDefaultConfig : function() {
+ /**
+ * The collection of registered Overlays in use by the OverlayManager
+ * @config overlays
+ * @type YAHOO.widget.Overlay[]
+ * @default null
+ */
+ this.cfg.addProperty("overlays", { suppressEvent:true } );
+
+ /**
+ * The default DOM event that should be used to focus an Overlay
+ * @config focusevent
+ * @type String
+ * @default "mousedown"
+ */
+ this.cfg.addProperty("focusevent", { value:"mousedown" } );
+ },
+
+ /**
+ * Initializes the OverlayManager
+ * @method init
+ * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager.
+ * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
+ */
+ init : function(userConfig) {
+ /**
+ * The OverlayManager's Config object used for monitoring configuration properties.
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+ this.cfg.fireQueue();
+
+ /**
+ * The currently activated Overlay
+ * @property activeOverlay
+ * @private
+ * @type YAHOO.widget.Overlay
+ */
+ var activeOverlay = null;
+
+ /**
+ * Returns the currently focused Overlay
+ * @method getActive
+ * @return {YAHOO.widget.Overlay} The currently focused Overlay
+ */
+ this.getActive = function() {
+ return activeOverlay;
+ };
+
+ /**
+ * Focuses the specified Overlay
+ * @method focus
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to focus
+ * @param {String} overlay The id of the Overlay to focus
+ */
+ this.focus = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ this.blurAll();
+ activeOverlay = o;
+ YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ this.overlays.sort(this.compareZIndexDesc);
+ var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
+ if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
+ activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2));
+ }
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ };
+
+ /**
+ * Removes the specified Overlay from the manager
+ * @method remove
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to remove
+ * @param {String} overlay The id of the Overlay to remove
+ */
+ this.remove = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
+ o.cfg.setProperty("zIndex", -1000, true);
+ this.overlays.sort(this.compareZIndexDesc);
+ this.overlays = this.overlays.slice(0, this.overlays.length-1);
+ o.cfg.setProperty("zIndex", originalZ, true);
+
+ o.cfg.setProperty("manager", null);
+ o.focusEvent = null;
+ o.blurEvent = null;
+ o.focus = null;
+ o.blur = null;
+ }
+ };
+
+ /**
+ * Removes focus from all registered Overlays in the manager
+ * @method blurAll
+ */
+ this.blurAll = function() {
+ activeOverlay = null;
+ for (var o=0;o 0) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Attempts to locate an Overlay by instance or ID.
+ * @method find
+ * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager
+ * @param {String} overlay An Overlay id to locate within the manager
+ * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located.
+ */
+ find : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ for (var o=0;o zIndex2) {
+ return -1;
+ } else if (zIndex1 < zIndex2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ },
+
+ /**
+ * Shows all Overlays in the manager.
+ * @method showAll
+ */
+ showAll : function() {
+ for (var o=0;oOR
+* @param {HTMLElement} el The element representing the Tooltip
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Tooltip = function(el, userConfig) {
+ YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay);
+
+/**
+* Constant representing the Tooltip CSS class
+* @property YAHOO.widget.Tooltip.CSS_TOOLTIP
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Tooltip.CSS_TOOLTIP = "tt";
+
+/**
+* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well.
+* @method init
+* @param {String} el The element ID representing the Tooltip OR
+* @param {HTMLElement} el The element representing the Tooltip
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details.
+*/
+YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) {
+ this.logger = YAHOO.widget.Tooltip.logger;
+
+ if (document.readyState && document.readyState != "complete") {
+ var deferredInit = function() {
+ this.init(el, userConfig);
+ };
+ YAHOO.util.Event.addListener(window, "load", deferredInit, this, true);
+ } else {
+ YAHOO.widget.Tooltip.superclass.init.call(this, el);
+
+ this.beforeInitEvent.fire(YAHOO.widget.Tooltip);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.cfg.queueProperty("visible",false);
+ this.cfg.queueProperty("constraintoviewport",true);
+
+ this.setBody("");
+ this.render(this.cfg.getProperty("container"));
+
+ this.initEvent.fire(YAHOO.widget.Tooltip);
+ }
+};
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);
+
+ /**
+ * Specifies whether the Tooltip should be kept from overlapping its context element.
+ * @config preventoverlap
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } );
+
+ /**
+ * The number of milliseconds to wait before showing a Tooltip on mouseover.
+ * @config showdelay
+ * @type Number
+ * @default 200
+ */
+ this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } );
+
+ /**
+ * The number of milliseconds to wait before automatically dismissing a Tooltip after the mouse has been resting on the context element.
+ * @config autodismissdelay
+ * @type Number
+ * @default 5000
+ */
+ this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } );
+
+ /**
+ * The number of milliseconds to wait before hiding a Tooltip on mouseover.
+ * @config hidedelay
+ * @type Number
+ * @default 250
+ */
+ this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } );
+
+ /**
+ * Specifies the Tooltip's text.
+ * @config text
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } );
+
+ /**
+ * Specifies the container element that the Tooltip's markup should be rendered into.
+ * @config container
+ * @type HTMLElement/String
+ * @default document.body
+ */
+ this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } );
+
+ /**
+ * Specifies the element or elements that the Tooltip should be anchored to on mouseover.
+ * @config context
+ * @type HTMLElement[]/String[]
+ * @default null
+ */
+
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "text" property is changed.
+* @method configText
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) {
+ var text = args[0];
+ if (text) {
+ this.setBody(text);
+ }
+};
+
+/**
+* The default event handler fired when the "container" property is changed.
+* @method configContainer
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) {
+ var container = args[0];
+ if (typeof container == 'string') {
+ this.cfg.setProperty("container", document.getElementById(container), true);
+ }
+};
+
+/**
+* The default event handler fired when the "context" property is changed.
+* @method configContext
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) {
+ var context = args[0];
+ if (context) {
+
+ // Normalize parameter into an array
+ if (! (context instanceof Array)) {
+ if (typeof context == "string") {
+ this.cfg.setProperty("context", [document.getElementById(context)], true);
+ } else { // Assuming this is an element
+ this.cfg.setProperty("context", [context], true);
+ }
+ context = this.cfg.getProperty("context");
+ }
+
+
+ // Remove any existing mouseover/mouseout listeners
+ if (this._context) {
+ for (var c=0;cOR
+* @param {HTMLElement} el The element representing the Panel
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details.
+*/
+YAHOO.widget.Panel = function(el, userConfig) {
+ YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay);
+
+/**
+* Constant representing the default CSS class used for a Panel
+* @property YAHOO.widget.Panel.CSS_PANEL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Panel.CSS_PANEL = "panel";
+
+/**
+* Constant representing the default CSS class used for a Panel's wrapping container
+* @property YAHOO.widget.Panel.CSS_PANEL_CONTAINER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "panel-container";
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Panel.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Panel);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL);
+
+ this.buildWrapper();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.beforeRenderEvent.subscribe(function() {
+ var draggable = this.cfg.getProperty("draggable");
+ if (draggable) {
+ if (! this.header) {
+ this.setHeader(" ");
+ }
+ }
+ }, this, true);
+
+ var me = this;
+
+ var doBlur = function() {
+ this.blur();
+ };
+
+ this.showMaskEvent.subscribe(function() {
+ var checkFocusable = function(el) {
+ if ((el.tagName == "A" || el.tagName == "BUTTON" || el.tagName == "SELECT" || el.tagName == "INPUT" || el.tagName == "TEXTAREA") && el.type != "hidden") {
+ if (! YAHOO.util.Dom.isAncestor(me.element, el)) {
+ YAHOO.util.Event.addListener(el, "focus", doBlur, el, true);
+ return true;
+ }
+ } else {
+ return false;
+ }
+ };
+
+ this.focusableElements = YAHOO.util.Dom.getElementsBy(checkFocusable);
+ }, this, true);
+
+ this.hideMaskEvent.subscribe(function() {
+ for (var i=0;iOR
+* @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
+* @return {boolean} Success or failure of the render
+*/
+YAHOO.widget.Panel.prototype.render = function(appendToNode) {
+ return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement);
+};
+
+/**
+* Returns a String representation of the object.
+* @method toString
+* @return {String} The string representation of the Panel.
+*/
+YAHOO.widget.Panel.prototype.toString = function() {
+ return "Panel " + this.id;
+};
+
+/**
+* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
+* @namespace YAHOO.widget
+* @class Dialog
+* @extends YAHOO.widget.Panel
+* @constructor
+* @param {String} el The element ID representing the Dialog OR
+* @param {HTMLElement} el The element representing the Dialog
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
+*/
+YAHOO.widget.Dialog = function(el, userConfig) {
+ YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel);
+
+/**
+* Constant representing the default CSS class used for a Dialog
+* @property YAHOO.widget.Dialog.CSS_DIALOG
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Dialog.CSS_DIALOG = "dialog";
+
+/**
+* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.Dialog.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this);
+
+ /**
+ * The internally maintained callback object for use with the Connection utility
+ * @property callback
+ * @type Object
+ */
+ this.callback = {
+ /**
+ * The function to execute upon success of the Connection submission
+ * @property callback.success
+ * @type Function
+ */
+ success : null,
+ /**
+ * The function to execute upon failure of the Connection submission
+ * @property callback.failure
+ * @type Function
+ */
+ failure : null,
+ /**
+ * The arbitraty argument or arguments to pass to the Connection callback functions
+ * @property callback.argument
+ * @type Object
+ */
+ argument: null
+ };
+
+ // Add form dialog config properties //
+
+ /**
+ * The method to use for posting the Dialog's form. Possible values are "async", "form", and "manual".
+ * @config postmethod
+ * @type String
+ * @default async
+ */
+ this.cfg.addProperty("postmethod", { value:"async", handler:this.configPostMethod, validator:function(val) {
+ if (val != "form" && val != "async" && val != "none" && val != "manual") {
+ return false;
+ } else {
+ return true;
+ }
+ } });
+
+ /**
+ * Object literal(s) defining the buttons for the Dialog's footer.
+ * @config buttons
+ * @type Object[]
+ * @default "none"
+ */
+ this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } );
+};
+
+/**
+* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class.
+* @method initEvents
+*/
+YAHOO.widget.Dialog.prototype.initEvents = function() {
+ YAHOO.widget.Dialog.superclass.initEvents.call(this);
+
+ /**
+ * CustomEvent fired prior to submission
+ * @event beforeSumitEvent
+ */
+ this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit");
+
+ /**
+ * CustomEvent fired after submission
+ * @event submitEvent
+ */
+ this.submitEvent = new YAHOO.util.CustomEvent("submit");
+
+ /**
+ * CustomEvent fired prior to manual submission
+ * @event manualSubmitEvent
+ */
+ this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit");
+
+ /**
+ * CustomEvent fired prior to asynchronous submission
+ * @event asyncSubmitEvent
+ */
+ this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit");
+
+ /**
+ * CustomEvent fired prior to form-based submission
+ * @event formSubmitEvent
+ */
+ this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit");
+
+ /**
+ * CustomEvent fired after cancel
+ * @event cancelEvent
+ */
+ this.cancelEvent = new YAHOO.util.CustomEvent("cancel");
+};
+
+/**
+* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the Dialog OR
+* @param {HTMLElement} el The element representing the Dialog
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
+*/
+YAHOO.widget.Dialog.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Dialog);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG);
+
+ this.cfg.setProperty("visible", false);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.showEvent.subscribe(this.focusFirst, this, true);
+ this.beforeHideEvent.subscribe(this.blurButtons, this, true);
+
+ this.beforeRenderEvent.subscribe(function() {
+ var buttonCfg = this.cfg.getProperty("buttons");
+ if (buttonCfg && buttonCfg != "none") {
+ if (! this.footer) {
+ this.setFooter("");
+ }
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.Dialog);
+};
+
+/**
+* Performs the submission of the Dialog form depending on the value of "postmethod" property.
+* @method doSubmit
+*/
+YAHOO.widget.Dialog.prototype.doSubmit = function() {
+ var pm = this.cfg.getProperty("postmethod");
+ switch (pm) {
+ case "async":
+ var method = this.form.getAttribute("method") || 'POST';
+ method = method.toUpperCase();
+ YAHOO.util.Connect.setForm(this.form);
+ var cObj = YAHOO.util.Connect.asyncRequest(method, this.form.getAttribute("action"), this.callback);
+ this.asyncSubmitEvent.fire();
+ break;
+ case "form":
+ this.form.submit();
+ this.formSubmitEvent.fire();
+ break;
+ case "none":
+ case "manual":
+ this.manualSubmitEvent.fire();
+ break;
+ }
+};
+
+/**
+* Prepares the Dialog's internal FORM object, creating one if one is not currently present.
+* @method registerForm
+*/
+YAHOO.widget.Dialog.prototype.registerForm = function() {
+ var form = this.element.getElementsByTagName("FORM")[0];
+
+ if (! form) {
+ var formHTML = "";
+ this.body.innerHTML += formHTML;
+ form = this.element.getElementsByTagName("FORM")[0];
+ }
+
+ this.firstFormElement = function() {
+ for (var f=0;f=0;f-- ) {
+ var el = form.elements[f];
+ if (el.focus && ! el.disabled) {
+ if (el.type && el.type != "hidden") {
+ return el;
+ }
+ }
+ }
+ return null;
+ }();
+
+ this.form = form;
+
+ if (this.cfg.getProperty("modal") && this.form) {
+
+ var me = this;
+
+ var firstElement = this.firstFormElement || this.firstButton;
+ if (firstElement) {
+ this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} );
+ this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true);
+ this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true);
+ }
+
+ var lastElement = this.lastButton || this.lastFormElement;
+ if (lastElement) {
+ this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} );
+ this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true);
+ this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true);
+ }
+ }
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Dialog.
+* @method configClose
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Dialog.prototype.configClose = function(type, args, obj) {
+ var val = args[0];
+
+ var doCancel = function(e, obj) {
+ obj.cancel();
+ };
+
+ if (val) {
+ if (! this.close) {
+ this.close = document.createElement("DIV");
+ YAHOO.util.Dom.addClass(this.close, "close");
+
+ if (this.isSecure) {
+ YAHOO.util.Dom.addClass(this.close, "secure");
+ } else {
+ YAHOO.util.Dom.addClass(this.close, "nonsecure");
+ }
+
+ this.close.innerHTML = " ";
+ this.innerElement.appendChild(this.close);
+ YAHOO.util.Event.addListener(this.close, "click", doCancel, this);
+ } else {
+ this.close.style.display = "block";
+ }
+ } else {
+ if (this.close) {
+ this.close.style.display = "none";
+ }
+ }
+};
+
+/**
+* The default event handler for the "buttons" configuration property
+* @method configButtons
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) {
+ var buttons = args[0];
+ if (buttons != "none") {
+ this.buttonSpan = null;
+ this.buttonSpan = document.createElement("SPAN");
+ this.buttonSpan.className = "button-group";
+
+ for (var b=0;bOR
+* @param {HTMLElement} el The element representing the SimpleDialog
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
+*/
+YAHOO.widget.SimpleDialog = function(el, userConfig) {
+ YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog);
+
+/**
+* Constant for the standard network icon for a blocking action
+* @property YAHOO.widget.SimpleDialog.ICON_BLOCK
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_BLOCK = "nt/ic/ut/bsc/blck16_1.gif";
+
+/**
+* Constant for the standard network icon for alarm
+* @property YAHOO.widget.SimpleDialog.ICON_ALARM
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_ALARM = "nt/ic/ut/bsc/alrt16_1.gif";
+
+/**
+* Constant for the standard network icon for help
+* @property YAHOO.widget.SimpleDialog.ICON_HELP
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_HELP = "nt/ic/ut/bsc/hlp16_1.gif";
+
+/**
+* Constant for the standard network icon for info
+* @property YAHOO.widget.SimpleDialog.ICON_INFO
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_INFO = "nt/ic/ut/bsc/info16_1.gif";
+
+/**
+* Constant for the standard network icon for warn
+* @property YAHOO.widget.SimpleDialog.ICON_WARN
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_WARN = "nt/ic/ut/bsc/warn16_1.gif";
+
+/**
+* Constant for the standard network icon for a tip
+* @property YAHOO.widget.SimpleDialog.ICON_TIP
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_TIP = "nt/ic/ut/bsc/tip16_1.gif";
+
+/**
+* Constant representing the default CSS class used for a SimpleDialog
+* @property YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "simple-dialog";
+
+/**
+* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() {
+ YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this);
+
+ // Add dialog config properties //
+
+ /**
+ * Sets the informational icon for the SimpleDialog
+ * @config icon
+ * @type String
+ * @default "none"
+ */
+ this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } );
+
+ /**
+ * Sets the text for the SimpleDialog
+ * @config text
+ * @type String
+ * @default ""
+ */
+ this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } );
+};
+
+
+/**
+* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the SimpleDialog OR
+* @param {HTMLElement} el The element representing the SimpleDialog
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
+*/
+YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) {
+ YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG);
+
+ this.cfg.queueProperty("postmethod", "manual");
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.beforeRenderEvent.subscribe(function() {
+ if (! this.body) {
+ this.setBody("");
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.SimpleDialog);
+
+};
+/**
+* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field.
+* @method registerForm
+*/
+YAHOO.widget.SimpleDialog.prototype.registerForm = function() {
+ YAHOO.widget.SimpleDialog.superclass.registerForm.call(this);
+ this.form.innerHTML += " ";
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Fired when the "icon" property is set.
+* @method configIcon
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) {
+ var icon = args[0];
+ if (icon && icon != "none") {
+ var iconHTML = " ";
+ this.body.innerHTML = iconHTML + this.body.innerHTML;
+ }
+};
+
+/**
+* Fired when the "text" property is set.
+* @method configText
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) {
+ var text = args[0];
+ if (text) {
+ this.setBody(text);
+ this.cfg.refireEvent("icon");
+ }
+};
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Returns a string representation of the object.
+* @method toString
+* @return {String} The string representation of the SimpleDialog
+*/
+YAHOO.widget.SimpleDialog.prototype.toString = function() {
+ return "SimpleDialog " + this.id;
+};
+
+/**
+* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden.
+* @namespace YAHOO.widget
+* @class ContainerEffect
+* @constructor
+* @param {YAHOO.widget.Overlay} overlay The Overlay that the animation should be associated with
+* @param {Object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
+* @param {Object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
+* @param {HTMLElement} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element.
+* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion.
+*/
+YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) {
+ if (! animClass) {
+ animClass = YAHOO.util.Anim;
+ }
+
+ /**
+ * The overlay to animate
+ * @property overlay
+ * @type YAHOO.widget.Overlay
+ */
+ this.overlay = overlay;
+ /**
+ * The animation attributes to use when transitioning into view
+ * @property attrIn
+ * @type Object
+ */
+ this.attrIn = attrIn;
+ /**
+ * The animation attributes to use when transitioning out of view
+ * @property attrOut
+ * @type Object
+ */
+ this.attrOut = attrOut;
+ /**
+ * The target element to be animated
+ * @property targetElement
+ * @type HTMLElement
+ */
+ this.targetElement = targetElement || overlay.element;
+ /**
+ * The animation class to use for animating the overlay
+ * @property animClass
+ * @type class
+ */
+ this.animClass = animClass;
+};
+
+/**
+* Initializes the animation classes and events.
+* @method init
+*/
+YAHOO.widget.ContainerEffect.prototype.init = function() {
+ this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn");
+ this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut");
+
+ this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete");
+ this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete");
+
+ this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method);
+ this.animIn.onStart.subscribe(this.handleStartAnimateIn, this);
+ this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this);
+ this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this);
+
+ this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method);
+ this.animOut.onStart.subscribe(this.handleStartAnimateOut, this);
+ this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this);
+ this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this);
+};
+
+/**
+* Triggers the in-animation.
+* @method animateIn
+*/
+YAHOO.widget.ContainerEffect.prototype.animateIn = function() {
+ this.beforeAnimateInEvent.fire();
+ this.animIn.animate();
+};
+
+/**
+* Triggers the out-animation.
+* @method animateOut
+*/
+YAHOO.widget.ContainerEffect.prototype.animateOut = function() {
+ this.beforeAnimateOutEvent.fire();
+ this.animOut.animate();
+};
+
+/**
+* The default onStart handler for the in-animation.
+* @method handleStartAnimateIn
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { };
+/**
+* The default onTween handler for the in-animation.
+* @method handleTweenAnimateIn
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { };
+/**
+* The default onComplete handler for the in-animation.
+* @method handleCompleteAnimateIn
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { };
+
+/**
+* The default onStart handler for the out-animation.
+* @method handleStartAnimateOut
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { };
+/**
+* The default onTween handler for the out-animation.
+* @method handleTweenAnimateOut
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { };
+/**
+* The default onComplete handler for the out-animation.
+* @method handleCompleteAnimateOut
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { };
+
+/**
+* Returns a string representation of the object.
+* @method toString
+* @return {String} The string representation of the ContainerEffect
+*/
+YAHOO.widget.ContainerEffect.prototype.toString = function() {
+ var output = "ContainerEffect";
+ if (this.overlay) {
+ output += " [" + this.overlay.toString() + "]";
+ }
+ return output;
+};
+
+/**
+* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out.
+* @method FADE
+* @static
+* @param {Overlay} overlay The Overlay object to animate
+* @param {Number} dur The duration of the animation
+* @return {ContainerEffect} The configured ContainerEffect object
+*/
+YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) {
+ var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element );
+
+ fade.handleStartAnimateIn = function(type,args,obj) {
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
+
+ if (! obj.overlay.underlay) {
+ obj.overlay.cfg.refireEvent("underlay");
+ }
+
+ if (obj.overlay.underlay) {
+ obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity");
+ obj.overlay.underlay.style.filter = null;
+ }
+
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0);
+ };
+
+ fade.handleCompleteAnimateIn = function(type,args,obj) {
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
+
+ if (obj.overlay.element.style.filter) {
+ obj.overlay.element.style.filter = null;
+ }
+
+ if (obj.overlay.underlay) {
+ YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity);
+ }
+
+ obj.overlay.cfg.refireEvent("iframe");
+ obj.animateInCompleteEvent.fire();
+ };
+
+ fade.handleStartAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
+
+ if (obj.overlay.underlay) {
+ obj.overlay.underlay.style.filter = null;
+ }
+ };
+
+ fade.handleCompleteAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
+ if (obj.overlay.element.style.filter) {
+ obj.overlay.element.style.filter = null;
+ }
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1);
+
+ obj.overlay.cfg.refireEvent("iframe");
+
+ obj.animateOutCompleteEvent.fire();
+ };
+
+ fade.init();
+ return fade;
+};
+
+
+/**
+* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out.
+* @method SLIDE
+* @static
+* @param {Overlay} overlay The Overlay object to animate
+* @param {Number} dur The duration of the animation
+* @return {ContainerEffect} The configured ContainerEffect object
+*/
+YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) {
+ var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element);
+ var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element);
+
+ var clientWidth = YAHOO.util.Dom.getClientWidth();
+ var offsetWidth = overlay.element.offsetWidth;
+
+ var slide = new YAHOO.widget.ContainerEffect(overlay, {
+ attributes:{ points: { to:[x, y] } },
+ duration:dur,
+ method:YAHOO.util.Easing.easeIn
+ },
+ {
+ attributes:{ points: { to:[(clientWidth+25), y] } },
+ duration:dur,
+ method:YAHOO.util.Easing.easeOut
+ },
+ overlay.element,
+ YAHOO.util.Motion);
+
+
+ slide.handleStartAnimateIn = function(type,args,obj) {
+ obj.overlay.element.style.left = (-25-offsetWidth) + "px";
+ obj.overlay.element.style.top = y + "px";
+ };
+
+ slide.handleTweenAnimateIn = function(type, args, obj) {
+
+
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var currentX = pos[0];
+ var currentY = pos[1];
+
+ if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) {
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
+ }
+
+ obj.overlay.cfg.setProperty("xy", [currentX,currentY], true);
+ obj.overlay.cfg.refireEvent("iframe");
+ };
+
+ slide.handleCompleteAnimateIn = function(type, args, obj) {
+ obj.overlay.cfg.setProperty("xy", [x,y], true);
+ obj.startX = x;
+ obj.startY = y;
+ obj.overlay.cfg.refireEvent("iframe");
+ obj.animateInCompleteEvent.fire();
+ };
+
+ slide.handleStartAnimateOut = function(type, args, obj) {
+ var vw = YAHOO.util.Dom.getViewportWidth();
+
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var yso = pos[1];
+
+ var currentTo = obj.animOut.attributes.points.to;
+ obj.animOut.attributes.points.to = [(vw+25), yso];
+ };
+
+ slide.handleTweenAnimateOut = function(type, args, obj) {
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var xto = pos[0];
+ var yto = pos[1];
+
+ obj.overlay.cfg.setProperty("xy", [xto,yto], true);
+ obj.overlay.cfg.refireEvent("iframe");
+ };
+
+ slide.handleCompleteAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
+
+ obj.overlay.cfg.setProperty("xy", [x,y]);
+ obj.animateOutCompleteEvent.fire();
+ };
+
+ slide.init();
+ return slide;
};
\ No newline at end of file
diff --git a/lib/yui/container/container-min.js b/lib/yui/container/container-min.js
index 83d72cf962..bcdd712216 100755
--- a/lib/yui/container/container-min.js
+++ b/lib/yui/container/container-min.js
@@ -1,149 +1,155 @@
-/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version 0.12.1 */
-YAHOO.util.Config=function(owner){if(owner){this.init(owner);}};YAHOO.util.Config.prototype={owner:null,queueInProgress:false,checkBoolean:function(val){if(typeof val=='boolean'){return true;}else{return false;}},checkNumber:function(val){if(isNaN(val)){return false;}else{return true;}}};YAHOO.util.Config.prototype.init=function(owner){this.owner=owner;this.configChangedEvent=new YAHOO.util.CustomEvent("configChanged");this.queueInProgress=false;var config={};var initialConfig={};var eventQueue=[];var fireEvent=function(key,value){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){property.event.fire(value);}};this.addProperty=function(key,propertyObject){key=key.toLowerCase();config[key]=propertyObject;propertyObject.event=new YAHOO.util.CustomEvent(key);propertyObject.key=key;if(propertyObject.handler){propertyObject.event.subscribe(propertyObject.handler,this.owner,true);}
-this.setProperty(key,propertyObject.value,true);if(!propertyObject.suppressEvent){this.queueProperty(key,propertyObject.value);}};this.getConfig=function(){var cfg={};for(var prop in config){var property=config[prop];if(typeof property!='undefined'&&property.event){cfg[prop]=property.value;}}
-return cfg;};this.getProperty=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){return property.value;}else{return undefined;}};this.resetProperty=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){if(initialConfig[key]&&initialConfig[key]!='undefined'){this.setProperty(key,initialConfig[key]);}
-return true;}else{return false;}};this.setProperty=function(key,value,silent){key=key.toLowerCase();if(this.queueInProgress&&!silent){this.queueProperty(key,value);return true;}else{var property=config[key];if(typeof property!='undefined'&&property.event){if(property.validator&&!property.validator(value)){return false;}else{property.value=value;if(!silent){fireEvent(key,value);this.configChangedEvent.fire([key,value]);}
-return true;}}else{return false;}}};this.queueProperty=function(key,value){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){if(typeof value!='undefined'&&property.validator&&!property.validator(value)){return false;}else{if(typeof value!='undefined'){property.value=value;}else{value=property.value;}
-var foundDuplicate=false;for(var i=0;irightConstraint){x=rightConstraint;}
-if(ybottomConstraint){y=bottomConstraint;}
-this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.cfg.setProperty("xy",[x,y],true);};YAHOO.widget.Overlay.prototype.center=function(){var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var viewPortWidth=YAHOO.util.Dom.getClientWidth();var viewPortHeight=YAHOO.util.Dom.getClientHeight();var elementWidth=this.element.offsetWidth;var elementHeight=this.element.offsetHeight;var x=(viewPortWidth/2)-(elementWidth/2)+scrollX;var y=(viewPortHeight/2)-(elementHeight/2)+scrollY;this.cfg.setProperty("xy",[parseInt(x,10),parseInt(y,10)]);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.syncPosition=function(){var pos=YAHOO.util.Dom.getXY(this.element);this.cfg.setProperty("x",pos[0],true);this.cfg.setProperty("y",pos[1],true);this.cfg.setProperty("xy",pos,true);};YAHOO.widget.Overlay.prototype.onDomResize=function(e,obj){YAHOO.widget.Overlay.superclass.onDomResize.call(this,e,obj);var me=this;setTimeout(function(){me.syncPosition();me.cfg.refireEvent("iframe");me.cfg.refireEvent("context");},0);};YAHOO.widget.Overlay.prototype.destroy=function(){if(this.iframe){this.iframe.parentNode.removeChild(this.iframe);}
-this.iframe=null;YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.superclass.destroy.call(this);};YAHOO.widget.Overlay.prototype.toString=function(){return"Overlay "+this.id;};YAHOO.widget.Overlay.windowScrollEvent=new YAHOO.util.CustomEvent("windowScroll");YAHOO.widget.Overlay.windowResizeEvent=new YAHOO.util.CustomEvent("windowResize");YAHOO.widget.Overlay.windowScrollHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.scrollEnd){window.scrollEnd=-1;}
-clearTimeout(window.scrollEnd);window.scrollEnd=setTimeout(function(){YAHOO.widget.Overlay.windowScrollEvent.fire();},1);}else{YAHOO.widget.Overlay.windowScrollEvent.fire();}};YAHOO.widget.Overlay.windowResizeHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.resizeEnd){window.resizeEnd=-1;}
-clearTimeout(window.resizeEnd);window.resizeEnd=setTimeout(function(){YAHOO.widget.Overlay.windowResizeEvent.fire();},100);}else{YAHOO.widget.Overlay.windowResizeEvent.fire();}};YAHOO.widget.Overlay._initialized=null;if(YAHOO.widget.Overlay._initialized===null){YAHOO.util.Event.addListener(window,"scroll",YAHOO.widget.Overlay.windowScrollHandler);YAHOO.util.Event.addListener(window,"resize",YAHOO.widget.Overlay.windowResizeHandler);YAHOO.widget.Overlay._initialized=true;}
-YAHOO.widget.OverlayManager=function(userConfig){this.init(userConfig);};YAHOO.widget.OverlayManager.CSS_FOCUSED="focused";YAHOO.widget.OverlayManager.prototype={constructor:YAHOO.widget.OverlayManager,overlays:null,initDefaultConfig:function(){this.cfg.addProperty("overlays",{suppressEvent:true});this.cfg.addProperty("focusevent",{value:"mousedown"});},init:function(userConfig){this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();if(userConfig){this.cfg.applyConfig(userConfig,true);}
-this.cfg.fireQueue();var activeOverlay=null;this.getActive=function(){return activeOverlay;};this.focus=function(overlay){var o=this.find(overlay);if(o){this.blurAll();activeOverlay=o;YAHOO.util.Dom.addClass(activeOverlay.element,YAHOO.widget.OverlayManager.CSS_FOCUSED);this.overlays.sort(this.compareZIndexDesc);var topZIndex=YAHOO.util.Dom.getStyle(this.overlays[0].element,"zIndex");if(!isNaN(topZIndex)&&this.overlays[0]!=overlay){activeOverlay.cfg.setProperty("zIndex",(parseInt(topZIndex,10)+2));}
-this.overlays.sort(this.compareZIndexDesc);}};this.remove=function(overlay){var o=this.find(overlay);if(o){var originalZ=YAHOO.util.Dom.getStyle(o.element,"zIndex");o.cfg.setProperty("zIndex",-1000,true);this.overlays.sort(this.compareZIndexDesc);this.overlays=this.overlays.slice(0,this.overlays.length-1);o.cfg.setProperty("zIndex",originalZ,true);o.cfg.setProperty("manager",null);o.focusEvent=null;o.blurEvent=null;o.focus=null;o.blur=null;}};this.blurAll=function(){activeOverlay=null;for(var o=0;o0){return true;}}else{return false;}},find:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){for(var o=0;ozIndex2){return-1;}else if(zIndex1";this.body.innerHTML+=formHTML;form=this.element.getElementsByTagName("FORM")[0];}
-this.firstFormElement=function(){for(var f=0;f=0;f--){var el=form.elements[f];if(el.focus){if(el.type&&el.type!="hidden"){return el;}}}
-return null;}();this.form=form;if(this.cfg.getProperty("modal")&&this.form){var me=this;var firstElement=this.firstFormElement||this.firstButton;if(firstElement){this.preventBackTab=new YAHOO.util.KeyListener(firstElement,{shift:true,keys:9},{fn:me.focusLast,scope:me,correctScope:true});this.showEvent.subscribe(this.preventBackTab.enable,this.preventBackTab,true);this.hideEvent.subscribe(this.preventBackTab.disable,this.preventBackTab,true);}
-var lastElement=this.lastButton||this.lastFormElement;if(lastElement){this.preventTabOut=new YAHOO.util.KeyListener(lastElement,{shift:false,keys:9},{fn:me.focusFirst,scope:me,correctScope:true});this.showEvent.subscribe(this.preventTabOut.enable,this.preventTabOut,true);this.hideEvent.subscribe(this.preventTabOut.disable,this.preventTabOut,true);}}};YAHOO.widget.Dialog.prototype.configButtons=function(type,args,obj){var buttons=args[0];if(buttons!="none"){this.buttonSpan=null;this.buttonSpan=document.createElement("SPAN");this.buttonSpan.className="button-group";for(var b=0;b";};YAHOO.widget.SimpleDialog.prototype.configIcon=function(type,args,obj){var icon=args[0];if(icon&&icon!="none"){var iconHTML=" ";this.body.innerHTML=iconHTML+this.body.innerHTML;}};YAHOO.widget.SimpleDialog.prototype.configText=function(type,args,obj){var text=args[0];if(text){this.setBody(text);this.cfg.refireEvent("icon");}};YAHOO.widget.SimpleDialog.prototype.toString=function(){return"SimpleDialog "+this.id;};YAHOO.widget.ContainerEffect=function(overlay,attrIn,attrOut,targetElement,animClass){if(!animClass){animClass=YAHOO.util.Anim;}
-this.overlay=overlay;this.attrIn=attrIn;this.attrOut=attrOut;this.targetElement=targetElement||overlay.element;this.animClass=animClass;};YAHOO.widget.ContainerEffect.prototype.init=function(){this.beforeAnimateInEvent=new YAHOO.util.CustomEvent("beforeAnimateIn");this.beforeAnimateOutEvent=new YAHOO.util.CustomEvent("beforeAnimateOut");this.animateInCompleteEvent=new YAHOO.util.CustomEvent("animateInComplete");this.animateOutCompleteEvent=new YAHOO.util.CustomEvent("animateOutComplete");this.animIn=new this.animClass(this.targetElement,this.attrIn.attributes,this.attrIn.duration,this.attrIn.method);this.animIn.onStart.subscribe(this.handleStartAnimateIn,this);this.animIn.onTween.subscribe(this.handleTweenAnimateIn,this);this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn,this);this.animOut=new this.animClass(this.targetElement,this.attrOut.attributes,this.attrOut.duration,this.attrOut.method);this.animOut.onStart.subscribe(this.handleStartAnimateOut,this);this.animOut.onTween.subscribe(this.handleTweenAnimateOut,this);this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut,this);};YAHOO.widget.ContainerEffect.prototype.animateIn=function(){this.beforeAnimateInEvent.fire();this.animIn.animate();};YAHOO.widget.ContainerEffect.prototype.animateOut=function(){this.beforeAnimateOutEvent.fire();this.animOut.animate();};YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.toString=function(){var output="ContainerEffect";if(this.overlay){output+=" ["+this.overlay.toString()+"]";}
-return output;};YAHOO.widget.ContainerEffect.FADE=function(overlay,dur){var fade=new YAHOO.widget.ContainerEffect(overlay,{attributes:{opacity:{from:0,to:1}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{opacity:{to:0}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element);fade.handleStartAnimateIn=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(!obj.overlay.underlay){obj.overlay.cfg.refireEvent("underlay");}
-if(obj.overlay.underlay){obj.initialUnderlayOpacity=YAHOO.util.Dom.getStyle(obj.overlay.underlay,"opacity");obj.overlay.underlay.style.filter=null;}
-YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","visible");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",0);};fade.handleCompleteAnimateIn=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;}
-if(obj.overlay.underlay){YAHOO.util.Dom.setStyle(obj.overlay.underlay,"opacity",obj.initialUnderlayOpacity);}
-obj.overlay.cfg.refireEvent("iframe");obj.animateInCompleteEvent.fire();};fade.handleStartAnimateOut=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(obj.overlay.underlay){obj.overlay.underlay.style.filter=null;}};fade.handleCompleteAnimateOut=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;}
-YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","hidden");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",1);obj.overlay.cfg.refireEvent("iframe");obj.animateOutCompleteEvent.fire();};fade.init();return fade;};YAHOO.widget.ContainerEffect.SLIDE=function(overlay,dur){var x=overlay.cfg.getProperty("x")||YAHOO.util.Dom.getX(overlay.element);var y=overlay.cfg.getProperty("y")||YAHOO.util.Dom.getY(overlay.element);var clientWidth=YAHOO.util.Dom.getClientWidth();var offsetWidth=overlay.element.offsetWidth;var slide=new YAHOO.widget.ContainerEffect(overlay,{attributes:{points:{to:[x,y]}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{points:{to:[(clientWidth+25),y]}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element,YAHOO.util.Motion);slide.handleStartAnimateIn=function(type,args,obj){obj.overlay.element.style.left=(-25-offsetWidth)+"px";obj.overlay.element.style.top=y+"px";};slide.handleTweenAnimateIn=function(type,args,obj){var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var currentX=pos[0];var currentY=pos[1];if(YAHOO.util.Dom.getStyle(obj.overlay.element,"visibility")=="hidden"&¤tXrightConstraint){x=rightConstraint;}
+if(ybottomConstraint){y=bottomConstraint;}
+this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.cfg.setProperty("xy",[x,y],true);};YAHOO.widget.Overlay.prototype.center=function(){var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var viewPortWidth=YAHOO.util.Dom.getClientWidth();var viewPortHeight=YAHOO.util.Dom.getClientHeight();var elementWidth=this.element.offsetWidth;var elementHeight=this.element.offsetHeight;var x=(viewPortWidth/2)-(elementWidth/2)+scrollX;var y=(viewPortHeight/2)-(elementHeight/2)+scrollY;this.cfg.setProperty("xy",[parseInt(x,10),parseInt(y,10)]);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.syncPosition=function(){var pos=YAHOO.util.Dom.getXY(this.element);this.cfg.setProperty("x",pos[0],true);this.cfg.setProperty("y",pos[1],true);this.cfg.setProperty("xy",pos,true);};YAHOO.widget.Overlay.prototype.onDomResize=function(e,obj){YAHOO.widget.Overlay.superclass.onDomResize.call(this,e,obj);var me=this;setTimeout(function(){me.syncPosition();me.cfg.refireEvent("iframe");me.cfg.refireEvent("context");},0);};YAHOO.widget.Overlay.prototype.destroy=function(){if(this.iframe){this.iframe.parentNode.removeChild(this.iframe);}
+this.iframe=null;YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.superclass.destroy.call(this);};YAHOO.widget.Overlay.prototype.toString=function(){return"Overlay "+this.id;};YAHOO.widget.Overlay.windowScrollEvent=new YAHOO.util.CustomEvent("windowScroll");YAHOO.widget.Overlay.windowResizeEvent=new YAHOO.util.CustomEvent("windowResize");YAHOO.widget.Overlay.windowScrollHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.scrollEnd){window.scrollEnd=-1;}
+clearTimeout(window.scrollEnd);window.scrollEnd=setTimeout(function(){YAHOO.widget.Overlay.windowScrollEvent.fire();},1);}else{YAHOO.widget.Overlay.windowScrollEvent.fire();}};YAHOO.widget.Overlay.windowResizeHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.resizeEnd){window.resizeEnd=-1;}
+clearTimeout(window.resizeEnd);window.resizeEnd=setTimeout(function(){YAHOO.widget.Overlay.windowResizeEvent.fire();},100);}else{YAHOO.widget.Overlay.windowResizeEvent.fire();}};YAHOO.widget.Overlay._initialized=null;if(YAHOO.widget.Overlay._initialized===null){YAHOO.util.Event.addListener(window,"scroll",YAHOO.widget.Overlay.windowScrollHandler);YAHOO.util.Event.addListener(window,"resize",YAHOO.widget.Overlay.windowResizeHandler);YAHOO.widget.Overlay._initialized=true;}
+YAHOO.widget.OverlayManager=function(userConfig){this.init(userConfig);};YAHOO.widget.OverlayManager.CSS_FOCUSED="focused";YAHOO.widget.OverlayManager.prototype={constructor:YAHOO.widget.OverlayManager,overlays:null,initDefaultConfig:function(){this.cfg.addProperty("overlays",{suppressEvent:true});this.cfg.addProperty("focusevent",{value:"mousedown"});},init:function(userConfig){this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();if(userConfig){this.cfg.applyConfig(userConfig,true);}
+this.cfg.fireQueue();var activeOverlay=null;this.getActive=function(){return activeOverlay;};this.focus=function(overlay){var o=this.find(overlay);if(o){this.blurAll();activeOverlay=o;YAHOO.util.Dom.addClass(activeOverlay.element,YAHOO.widget.OverlayManager.CSS_FOCUSED);this.overlays.sort(this.compareZIndexDesc);var topZIndex=YAHOO.util.Dom.getStyle(this.overlays[0].element,"zIndex");if(!isNaN(topZIndex)&&this.overlays[0]!=overlay){activeOverlay.cfg.setProperty("zIndex",(parseInt(topZIndex,10)+2));}
+this.overlays.sort(this.compareZIndexDesc);}};this.remove=function(overlay){var o=this.find(overlay);if(o){var originalZ=YAHOO.util.Dom.getStyle(o.element,"zIndex");o.cfg.setProperty("zIndex",-1000,true);this.overlays.sort(this.compareZIndexDesc);this.overlays=this.overlays.slice(0,this.overlays.length-1);o.cfg.setProperty("zIndex",originalZ,true);o.cfg.setProperty("manager",null);o.focusEvent=null;o.blurEvent=null;o.focus=null;o.blur=null;}};this.blurAll=function(){activeOverlay=null;for(var o=0;o0){return true;}}else{return false;}},find:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){for(var o=0;ozIndex2){return-1;}else if(zIndex1";this.body.innerHTML+=formHTML;form=this.element.getElementsByTagName("FORM")[0];}
+this.firstFormElement=function(){for(var f=0;f=0;f--){var el=form.elements[f];if(el.focus&&!el.disabled){if(el.type&&el.type!="hidden"){return el;}}}
+return null;}();this.form=form;if(this.cfg.getProperty("modal")&&this.form){var me=this;var firstElement=this.firstFormElement||this.firstButton;if(firstElement){this.preventBackTab=new YAHOO.util.KeyListener(firstElement,{shift:true,keys:9},{fn:me.focusLast,scope:me,correctScope:true});this.showEvent.subscribe(this.preventBackTab.enable,this.preventBackTab,true);this.hideEvent.subscribe(this.preventBackTab.disable,this.preventBackTab,true);}
+var lastElement=this.lastButton||this.lastFormElement;if(lastElement){this.preventTabOut=new YAHOO.util.KeyListener(lastElement,{shift:false,keys:9},{fn:me.focusFirst,scope:me,correctScope:true});this.showEvent.subscribe(this.preventTabOut.enable,this.preventTabOut,true);this.hideEvent.subscribe(this.preventTabOut.disable,this.preventTabOut,true);}}};YAHOO.widget.Dialog.prototype.configClose=function(type,args,obj){var val=args[0];var doCancel=function(e,obj){obj.cancel();};if(val){if(!this.close){this.close=document.createElement("DIV");YAHOO.util.Dom.addClass(this.close,"close");if(this.isSecure){YAHOO.util.Dom.addClass(this.close,"secure");}else{YAHOO.util.Dom.addClass(this.close,"nonsecure");}
+this.close.innerHTML=" ";this.innerElement.appendChild(this.close);YAHOO.util.Event.addListener(this.close,"click",doCancel,this);}else{this.close.style.display="block";}}else{if(this.close){this.close.style.display="none";}}};YAHOO.widget.Dialog.prototype.configButtons=function(type,args,obj){var buttons=args[0];if(buttons!="none"){this.buttonSpan=null;this.buttonSpan=document.createElement("SPAN");this.buttonSpan.className="button-group";for(var b=0;b";};YAHOO.widget.SimpleDialog.prototype.configIcon=function(type,args,obj){var icon=args[0];if(icon&&icon!="none"){var iconHTML=" ";this.body.innerHTML=iconHTML+this.body.innerHTML;}};YAHOO.widget.SimpleDialog.prototype.configText=function(type,args,obj){var text=args[0];if(text){this.setBody(text);this.cfg.refireEvent("icon");}};YAHOO.widget.SimpleDialog.prototype.toString=function(){return"SimpleDialog "+this.id;};YAHOO.widget.ContainerEffect=function(overlay,attrIn,attrOut,targetElement,animClass){if(!animClass){animClass=YAHOO.util.Anim;}
+this.overlay=overlay;this.attrIn=attrIn;this.attrOut=attrOut;this.targetElement=targetElement||overlay.element;this.animClass=animClass;};YAHOO.widget.ContainerEffect.prototype.init=function(){this.beforeAnimateInEvent=new YAHOO.util.CustomEvent("beforeAnimateIn");this.beforeAnimateOutEvent=new YAHOO.util.CustomEvent("beforeAnimateOut");this.animateInCompleteEvent=new YAHOO.util.CustomEvent("animateInComplete");this.animateOutCompleteEvent=new YAHOO.util.CustomEvent("animateOutComplete");this.animIn=new this.animClass(this.targetElement,this.attrIn.attributes,this.attrIn.duration,this.attrIn.method);this.animIn.onStart.subscribe(this.handleStartAnimateIn,this);this.animIn.onTween.subscribe(this.handleTweenAnimateIn,this);this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn,this);this.animOut=new this.animClass(this.targetElement,this.attrOut.attributes,this.attrOut.duration,this.attrOut.method);this.animOut.onStart.subscribe(this.handleStartAnimateOut,this);this.animOut.onTween.subscribe(this.handleTweenAnimateOut,this);this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut,this);};YAHOO.widget.ContainerEffect.prototype.animateIn=function(){this.beforeAnimateInEvent.fire();this.animIn.animate();};YAHOO.widget.ContainerEffect.prototype.animateOut=function(){this.beforeAnimateOutEvent.fire();this.animOut.animate();};YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.toString=function(){var output="ContainerEffect";if(this.overlay){output+=" ["+this.overlay.toString()+"]";}
+return output;};YAHOO.widget.ContainerEffect.FADE=function(overlay,dur){var fade=new YAHOO.widget.ContainerEffect(overlay,{attributes:{opacity:{from:0,to:1}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{opacity:{to:0}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element);fade.handleStartAnimateIn=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(!obj.overlay.underlay){obj.overlay.cfg.refireEvent("underlay");}
+if(obj.overlay.underlay){obj.initialUnderlayOpacity=YAHOO.util.Dom.getStyle(obj.overlay.underlay,"opacity");obj.overlay.underlay.style.filter=null;}
+YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","visible");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",0);};fade.handleCompleteAnimateIn=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;}
+if(obj.overlay.underlay){YAHOO.util.Dom.setStyle(obj.overlay.underlay,"opacity",obj.initialUnderlayOpacity);}
+obj.overlay.cfg.refireEvent("iframe");obj.animateInCompleteEvent.fire();};fade.handleStartAnimateOut=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(obj.overlay.underlay){obj.overlay.underlay.style.filter=null;}};fade.handleCompleteAnimateOut=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;}
+YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","hidden");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",1);obj.overlay.cfg.refireEvent("iframe");obj.animateOutCompleteEvent.fire();};fade.init();return fade;};YAHOO.widget.ContainerEffect.SLIDE=function(overlay,dur){var x=overlay.cfg.getProperty("x")||YAHOO.util.Dom.getX(overlay.element);var y=overlay.cfg.getProperty("y")||YAHOO.util.Dom.getY(overlay.element);var clientWidth=YAHOO.util.Dom.getClientWidth();var offsetWidth=overlay.element.offsetWidth;var slide=new YAHOO.widget.ContainerEffect(overlay,{attributes:{points:{to:[x,y]}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{points:{to:[(clientWidth+25),y]}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element,YAHOO.util.Motion);slide.handleStartAnimateIn=function(type,args,obj){obj.overlay.element.style.left=(-25-offsetWidth)+"px";obj.overlay.element.style.top=y+"px";};slide.handleTweenAnimateIn=function(type,args,obj){var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var currentX=pos[0];var currentY=pos[1];if(YAHOO.util.Dom.getStyle(obj.overlay.element,"visibility")=="hidden"&¤tXOR
-* @param {HTMLElement} el The element representing the Module
-* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
-*/
-YAHOO.widget.Module = function(el, userConfig) {
- if (el) {
- this.init(el, userConfig);
- }
-};
-
-/**
-* Constant representing the prefix path to use for non-secure images
-* @property YAHOO.widget.Module.IMG_ROOT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
-
-/**
-* Constant representing the prefix path to use for securely served images
-* @property YAHOO.widget.Module.IMG_ROOT_SSL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
-
-/**
-* Constant for the default CSS class name that represents a Module
-* @property YAHOO.widget.Module.CSS_MODULE
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_MODULE = "module";
-
-/**
-* Constant representing the module header
-* @property YAHOO.widget.Module.CSS_HEADER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_HEADER = "hd";
-
-/**
-* Constant representing the module body
-* @property YAHOO.widget.Module.CSS_BODY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_BODY = "bd";
-
-/**
-* Constant representing the module footer
-* @property YAHOO.widget.Module.CSS_FOOTER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_FOOTER = "ft";
-
-/**
-* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
-* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";
-
-/**
-* Singleton CustomEvent fired when the font size is changed in the browser.
-* Opera's "zoom" functionality currently does not support text size detection.
-* @event YAHOO.widget.Module.textResizeEvent
-*/
-YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");
-
-YAHOO.widget.Module.prototype = {
- /**
- * The class's constructor function
- * @property contructor
- * @type Function
- */
- constructor : YAHOO.widget.Module,
-
- /**
- * The main module element that contains the header, body, and footer
- * @property element
- * @type HTMLElement
- */
- element : null,
-
- /**
- * The header element, denoted with CSS class "hd"
- * @property header
- * @type HTMLElement
- */
- header : null,
-
- /**
- * The body element, denoted with CSS class "bd"
- * @property body
- * @type HTMLElement
- */
- body : null,
-
- /**
- * The footer element, denoted with CSS class "ft"
- * @property footer
- * @type HTMLElement
- */
- footer : null,
-
- /**
- * The id of the element
- * @property id
- * @type String
- */
- id : null,
-
- /**
- * The String representing the image root
- * @property imageRoot
- * @type String
- */
- imageRoot : YAHOO.widget.Module.IMG_ROOT,
-
- /**
- * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
- * @method initEvents
- */
- initEvents : function() {
-
- /**
- * CustomEvent fired prior to class initalization.
- * @event beforeInitEvent
- * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
- */
- this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
-
- /**
- * CustomEvent fired after class initalization.
- * @event initEvent
- * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
- */
- this.initEvent = new YAHOO.util.CustomEvent("init");
-
- /**
- * CustomEvent fired when the Module is appended to the DOM
- * @event appendEvent
- */
- this.appendEvent = new YAHOO.util.CustomEvent("append");
-
- /**
- * CustomEvent fired before the Module is rendered
- * @event beforeRenderEvent
- */
- this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
-
- /**
- * CustomEvent fired after the Module is rendered
- * @event renderEvent
- */
- this.renderEvent = new YAHOO.util.CustomEvent("render");
-
- /**
- * CustomEvent fired when the header content of the Module is modified
- * @event changeHeaderEvent
- * @param {String/HTMLElement} content String/element representing the new header content
- */
- this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
-
- /**
- * CustomEvent fired when the body content of the Module is modified
- * @event changeBodyEvent
- * @param {String/HTMLElement} content String/element representing the new body content
- */
- this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
-
- /**
- * CustomEvent fired when the footer content of the Module is modified
- * @event changeFooterEvent
- * @param {String/HTMLElement} content String/element representing the new footer content
- */
- this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
-
- /**
- * CustomEvent fired when the content of the Module is modified
- * @event changeContentEvent
- */
- this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
-
- /**
- * CustomEvent fired when the Module is destroyed
- * @event destroyEvent
- */
- this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
-
- /**
- * CustomEvent fired before the Module is shown
- * @event beforeShowEvent
- */
- this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
-
- /**
- * CustomEvent fired after the Module is shown
- * @event showEvent
- */
- this.showEvent = new YAHOO.util.CustomEvent("show");
-
- /**
- * CustomEvent fired before the Module is hidden
- * @event beforeHideEvent
- */
- this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
-
- /**
- * CustomEvent fired after the Module is hidden
- * @event hideEvent
- */
- this.hideEvent = new YAHOO.util.CustomEvent("hide");
- },
-
- /**
- * String representing the current user-agent platform
- * @property platform
- * @type String
- */
- platform : function() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
- return "windows";
- } else if (ua.indexOf("macintosh") != -1) {
- return "mac";
- } else {
- return false;
- }
- }(),
-
- /**
- * String representing the current user-agent browser
- * @property browser
- * @type String
- */
- browser : function() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
- return 'opera';
- } else if (ua.indexOf('msie 7')!=-1) { // IE7
- return 'ie7';
- } else if (ua.indexOf('msie') !=-1) { // IE
- return 'ie';
- } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
- return 'safari';
- } else if (ua.indexOf('gecko') != -1) { // Gecko
- return 'gecko';
- } else {
- return false;
- }
- }(),
-
- /**
- * Boolean representing whether or not the current browsing context is secure (https)
- * @property isSecure
- * @type Boolean
- */
- isSecure : function() {
- if (window.location.href.toLowerCase().indexOf("https") === 0) {
- return true;
- } else {
- return false;
- }
- }(),
-
- /**
- * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
- */
- initDefaultConfig : function() {
- // Add properties //
-
- /**
- * Specifies whether the Module is visible on the page.
- * @config visible
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
-
- /**
- * Object or array of objects representing the ContainerEffect classes that are active for animating the container.
- * @config effect
- * @type Object
- * @default null
- */
- this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
-
- /**
- * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document
- * @config monitorresize
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
- },
-
- /**
- * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
- * @method init
- * @param {String} el The element ID representing the Module OR
- * @param {HTMLElement} el The element representing the Module
- * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
- */
- init : function(el, userConfig) {
-
- this.initEvents();
-
- this.beforeInitEvent.fire(YAHOO.widget.Module);
-
- /**
- * The Module's Config object used for monitoring configuration properties.
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- if (this.isSecure) {
- this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
- }
-
- if (typeof el == "string") {
- var elId = el;
-
- el = document.getElementById(el);
- if (! el) {
- el = document.createElement("DIV");
- el.id = elId;
- }
- }
-
- this.element = el;
-
- if (el.id) {
- this.id = el.id;
- }
-
- var childNodes = this.element.childNodes;
-
- if (childNodes) {
- for (var i=0;iOR
- * @param {HTMLElement} headerContent The HTMLElement to append to the header
- */
- setHeader : function(headerContent) {
- if (! this.header) {
- this.header = document.createElement("DIV");
- this.header.className = YAHOO.widget.Module.CSS_HEADER;
- }
-
- if (typeof headerContent == "string") {
- this.header.innerHTML = headerContent;
- } else {
- this.header.innerHTML = "";
- this.header.appendChild(headerContent);
- }
-
- this.changeHeaderEvent.fire(headerContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the header. If no header is present, one will be automatically created.
- * @method appendToHeader
- * @param {HTMLElement} element The element to append to the header
- */
- appendToHeader : function(element) {
- if (! this.header) {
- this.header = document.createElement("DIV");
- this.header.className = YAHOO.widget.Module.CSS_HEADER;
- }
-
- this.header.appendChild(element);
- this.changeHeaderEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
- * @method setBody
- * @param {String} bodyContent The HTML used to set the body OR
- * @param {HTMLElement} bodyContent The HTMLElement to append to the body
- */
- setBody : function(bodyContent) {
- if (! this.body) {
- this.body = document.createElement("DIV");
- this.body.className = YAHOO.widget.Module.CSS_BODY;
- }
-
- if (typeof bodyContent == "string")
- {
- this.body.innerHTML = bodyContent;
- } else {
- this.body.innerHTML = "";
- this.body.appendChild(bodyContent);
- }
-
- this.changeBodyEvent.fire(bodyContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the body. If no body is present, one will be automatically created.
- * @method appendToBody
- * @param {HTMLElement} element The element to append to the body
- */
- appendToBody : function(element) {
- if (! this.body) {
- this.body = document.createElement("DIV");
- this.body.className = YAHOO.widget.Module.CSS_BODY;
- }
-
- this.body.appendChild(element);
- this.changeBodyEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
- * @method setFooter
- * @param {String} footerContent The HTML used to set the footer OR
- * @param {HTMLElement} footerContent The HTMLElement to append to the footer
- */
- setFooter : function(footerContent) {
- if (! this.footer) {
- this.footer = document.createElement("DIV");
- this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
- }
-
- if (typeof footerContent == "string") {
- this.footer.innerHTML = footerContent;
- } else {
- this.footer.innerHTML = "";
- this.footer.appendChild(footerContent);
- }
-
- this.changeFooterEvent.fire(footerContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the footer. If no footer is present, one will be automatically created.
- * @method appendToFooter
- * @param {HTMLElement} element The element to append to the footer
- */
- appendToFooter : function(element) {
- if (! this.footer) {
- this.footer = document.createElement("DIV");
- this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
- }
-
- this.footer.appendChild(element);
- this.changeFooterEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
- * @method render
- * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering OR
- * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
- * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
- * @return {Boolean} Success or failure of the render
- */
- render : function(appendToNode, moduleElement) {
- this.beforeRenderEvent.fire();
-
- if (! moduleElement) {
- moduleElement = this.element;
- }
-
- var me = this;
- var appendTo = function(element) {
- if (typeof element == "string") {
- element = document.getElementById(element);
- }
-
- if (element) {
- element.appendChild(me.element);
- me.appendEvent.fire();
- }
- };
-
- if (appendToNode) {
- appendTo(appendToNode);
- } else { // No node was passed in. If the element is not pre-marked up, this fails
- if (! YAHOO.util.Dom.inDocument(this.element)) {
- return false;
- }
- }
-
- // Need to get everything into the DOM if it isn't already
-
- if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
- // There is a header, but it's not in the DOM yet... need to add it
- var firstChild = moduleElement.firstChild;
- if (firstChild) { // Insert before first child if exists
- moduleElement.insertBefore(this.header, firstChild);
- } else { // Append to empty body because there are no children
- moduleElement.appendChild(this.header);
- }
- }
-
- if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
- // There is a body, but it's not in the DOM yet... need to add it
- if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
- moduleElement.insertBefore(this.body, this.footer);
- } else { // Append to element because there is no footer
- moduleElement.appendChild(this.body);
- }
- }
-
- if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
- // There is a footer, but it's not in the DOM yet... need to add it
- moduleElement.appendChild(this.footer);
- }
-
- this.renderEvent.fire();
- return true;
- },
-
- /**
- * Removes the Module element from the DOM and sets all child elements to null.
- * @method destroy
- */
- destroy : function() {
- var parent;
-
- if (this.element) {
- YAHOO.util.Event.purgeElement(this.element, true);
- parent = this.element.parentNode;
- }
- if (parent) {
- parent.removeChild(this.element);
- }
-
- this.element = null;
- this.header = null;
- this.body = null;
- this.footer = null;
-
- for (var e in this) {
- if (e instanceof YAHOO.util.CustomEvent) {
- e.unsubscribeAll();
- }
- }
-
- YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this);
-
- this.destroyEvent.fire();
- },
-
- /**
- * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
- * @method show
- */
- show : function() {
- this.cfg.setProperty("visible", true);
- },
-
- /**
- * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
- * @method hide
- */
- hide : function() {
- this.cfg.setProperty("visible", false);
- },
-
- // BUILT-IN EVENT HANDLERS FOR MODULE //
-
- /**
- * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
- * This method is responsible for firing showEvent and hideEvent.
- * @param {String} type The CustomEvent type (usually the property name)
- * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
- * @method configVisible
- */
- configVisible : function(type, args, obj) {
- var visible = args[0];
- if (visible) {
- this.beforeShowEvent.fire();
- YAHOO.util.Dom.setStyle(this.element, "display", "block");
- this.showEvent.fire();
- } else {
- this.beforeHideEvent.fire();
- YAHOO.util.Dom.setStyle(this.element, "display", "none");
- this.hideEvent.fire();
- }
- },
-
- /**
- * Default event handler for the "monitorresize" configuration property
- * @param {String} type The CustomEvent type (usually the property name)
- * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
- * @method configMonitorResize
- */
- configMonitorResize : function(type, args, obj) {
- var monitor = args[0];
- if (monitor) {
- this.initResizeMonitor();
- } else {
- YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize);
- this.resizeMonitor = null;
- }
- }
-};
-
-/**
-* Returns a String representation of the Object.
-* @method toString
-* @return {String} The string representation of the Module
-*/
-YAHOO.widget.Module.prototype.toString = function() {
- return "Module " + this.id;
-};
-
-/**
-* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
-* @namespace YAHOO.widget
-* @class Overlay
-* @extends YAHOO.widget.Module
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details.
-* @constructor
-*/
-YAHOO.widget.Overlay = function(el, userConfig) {
- YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
-
-/**
-* The URL that will be placed in the iframe
-* @property YAHOO.widget.Overlay.IFRAME_SRC
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;";
-
-/**
-* Constant representing the top left corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.TOP_LEFT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.TOP_LEFT = "tl";
-
-/**
-* Constant representing the top right corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.TOP_RIGHT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.TOP_RIGHT = "tr";
-
-/**
-* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.BOTTOM_LEFT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
-
-/**
-* Constant representing the bottom right corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.BOTTOM_RIGHT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
-
-/**
-* Constant representing the default CSS class used for an Overlay
-* @property YAHOO.widget.Overlay.CSS_OVERLAY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
-
-/**
-* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
-*/
-YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
- YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.Overlay);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- if (this.platform == "mac" && this.browser == "gecko") {
- if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
- this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
- }
- if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
- this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
- }
- }
-
- this.initEvent.fire(YAHOO.widget.Overlay);
-};
-
-/**
-* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
-* @method initEvents
-*/
-YAHOO.widget.Overlay.prototype.initEvents = function() {
- YAHOO.widget.Overlay.superclass.initEvents.call(this);
-
- /**
- * CustomEvent fired before the Overlay is moved.
- * @event beforeMoveEvent
- * @param {Number} x x coordinate
- * @param {Number} y y coordinate
- */
- this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
-
- /**
- * CustomEvent fired after the Overlay is moved.
- * @event moveEvent
- * @param {Number} x x coordinate
- * @param {Number} y y coordinate
- */
- this.moveEvent = new YAHOO.util.CustomEvent("move", this);
-};
-
-/**
-* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
- YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
-
- // Add overlay config properties //
-
- /**
- * The absolute x-coordinate position of the Overlay
- * @config x
- * @type Number
- * @default null
- */
- this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * The absolute y-coordinate position of the Overlay
- * @config y
- * @type Number
- * @default null
- */
- this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * An array with the absolute x and y positions of the Overlay
- * @config xy
- * @type Number[]
- * @default null
- */
- this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner.
- * @config context
- * @type Array
- * @default null
- */
- this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * True if the Overlay should be anchored to the center of the viewport.
- * @config fixedcenter
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
-
- /**
- * CSS width of the Overlay.
- * @config width
- * @type String
- * @default null
- */
- this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * CSS height of the Overlay.
- * @config height
- * @type String
- * @default null
- */
- this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * CSS z-index of the Overlay.
- * @config zIndex
- * @type Number
- * @default null
- */
- this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
-
- /**
- * True if the Overlay should be prevented from being positioned out of the viewport.
- * @config constraintoviewport
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
-
- /**
- * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below).
- * @config iframe
- * @type Boolean
- * @default true for IE6 and below, false for all others
- */
- this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
-};
-
-/**
-* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
-* @method moveTo
-* @param {Number} x The Overlay's new x position
-* @param {Number} y The Overlay's new y position
-*/
-YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
- this.cfg.setProperty("xy",[x,y]);
-};
-
-/**
-* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
-* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
-* @method hideMacGeckoScrollbars
-*/
-YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
- YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
- YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
-};
-
-/**
-* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
-* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
-* @method showMacGeckoScrollbars
-*/
-YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
- YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
- YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
-* @method configVisible
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
- var visible = args[0];
-
- var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
-
- if (currentVis == "inherit") {
- var e = this.element.parentNode;
- while (e.nodeType != 9 && e.nodeType != 11) {
- currentVis = YAHOO.util.Dom.getStyle(e, "visibility");
- if (currentVis != "inherit") { break; }
- e = e.parentNode;
- }
- if (currentVis == "inherit") {
- currentVis = "visible";
- }
- }
-
- var effect = this.cfg.getProperty("effect");
-
- var effectInstances = [];
- if (effect) {
- if (effect instanceof Array) {
- for (var i=0;i rightConstraint) {
- x = rightConstraint;
- }
-
- if (y < topConstraint) {
- y = topConstraint;
- } else if (y > bottomConstraint) {
- y = bottomConstraint;
- }
-
- this.cfg.setProperty("x", x, true);
- this.cfg.setProperty("y", y, true);
- this.cfg.setProperty("xy", [x,y], true);
-};
-
-/**
-* Centers the container in the viewport.
-* @method center
-*/
-YAHOO.widget.Overlay.prototype.center = function() {
- var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
- var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
-
- var viewPortWidth = YAHOO.util.Dom.getClientWidth();
- var viewPortHeight = YAHOO.util.Dom.getClientHeight();
-
- var elementWidth = this.element.offsetWidth;
- var elementHeight = this.element.offsetHeight;
-
- var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
- var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
-
- this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
-
- this.cfg.refireEvent("iframe");
-};
-
-/**
-* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
-* @method syncPosition
-*/
-YAHOO.widget.Overlay.prototype.syncPosition = function() {
- var pos = YAHOO.util.Dom.getXY(this.element);
- this.cfg.setProperty("x", pos[0], true);
- this.cfg.setProperty("y", pos[1], true);
- this.cfg.setProperty("xy", pos, true);
-};
-
-/**
-* Event handler fired when the resize monitor element is resized.
-* @method onDomResize
-* @param {DOMEvent} e The resize DOM event
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
- YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
- var me = this;
- setTimeout(function() {
- me.syncPosition();
- me.cfg.refireEvent("iframe");
- me.cfg.refireEvent("context");
- }, 0);
-};
-
-/**
-* Removes the Overlay element from the DOM and sets all child elements to null.
-* @method destroy
-*/
-YAHOO.widget.Overlay.prototype.destroy = function() {
- if (this.iframe) {
- this.iframe.parentNode.removeChild(this.iframe);
- }
-
- this.iframe = null;
-
- YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
- YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
-
- YAHOO.widget.Overlay.superclass.destroy.call(this);
-};
-
-/**
-* Returns a String representation of the object.
-* @method toString
-* @return {String} The string representation of the Overlay.
-*/
-YAHOO.widget.Overlay.prototype.toString = function() {
- return "Overlay " + this.id;
-};
-
-/**
-* A singleton CustomEvent used for reacting to the DOM event for window scroll
-* @event YAHOO.widget.Overlay.windowScrollEvent
-*/
-YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
-
-/**
-* A singleton CustomEvent used for reacting to the DOM event for window resize
-* @event YAHOO.widget.Overlay.windowResizeEvent
-*/
-YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
-
-/**
-* The DOM event handler used to fire the CustomEvent for window scroll
-* @method YAHOO.widget.Overlay.windowScrollHandler
-* @static
-* @param {DOMEvent} e The DOM scroll event
-*/
-YAHOO.widget.Overlay.windowScrollHandler = function(e) {
- if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
- if (! window.scrollEnd) {
- window.scrollEnd = -1;
- }
- clearTimeout(window.scrollEnd);
- window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1);
- } else {
- YAHOO.widget.Overlay.windowScrollEvent.fire();
- }
-};
-
-/**
-* The DOM event handler used to fire the CustomEvent for window resize
-* @method YAHOO.widget.Overlay.windowResizeHandler
-* @static
-* @param {DOMEvent} e The DOM resize event
-*/
-YAHOO.widget.Overlay.windowResizeHandler = function(e) {
- if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
- if (! window.resizeEnd) {
- window.resizeEnd = -1;
- }
- clearTimeout(window.resizeEnd);
- window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100);
- } else {
- YAHOO.widget.Overlay.windowResizeEvent.fire();
- }
-};
-
-/**
-* A boolean that indicated whether the window resize and scroll events have already been subscribed to.
-* @property YAHOO.widget.Overlay._initialized
-* @private
-* @type Boolean
-*/
-YAHOO.widget.Overlay._initialized = null;
-
-if (YAHOO.widget.Overlay._initialized === null) {
- YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
- YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
-
- YAHOO.widget.Overlay._initialized = true;
-}
-
-/**
-* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget
-* @namespace YAHOO.widget
-* @class OverlayManager
-* @constructor
-* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
-* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
-*/
-YAHOO.widget.OverlayManager = function(userConfig) {
- this.init(userConfig);
-};
-
-/**
-* The CSS class representing a focused Overlay
-* @property YAHOO.widget.OverlayManager.CSS_FOCUSED
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
-
-YAHOO.widget.OverlayManager.prototype = {
- /**
- * The class's constructor function
- * @property contructor
- * @type Function
- */
- constructor : YAHOO.widget.OverlayManager,
-
- /**
- * The array of Overlays that are currently registered
- * @property overlays
- * @type YAHOO.widget.Overlay[]
- */
- overlays : null,
-
- /**
- * Initializes the default configuration of the OverlayManager
- * @method initDefaultConfig
- */
- initDefaultConfig : function() {
- /**
- * The collection of registered Overlays in use by the OverlayManager
- * @config overlays
- * @type YAHOO.widget.Overlay[]
- * @default null
- */
- this.cfg.addProperty("overlays", { suppressEvent:true } );
-
- /**
- * The default DOM event that should be used to focus an Overlay
- * @config focusevent
- * @type String
- * @default "mousedown"
- */
- this.cfg.addProperty("focusevent", { value:"mousedown" } );
- },
-
- /**
- * Initializes the OverlayManager
- * @method init
- * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager.
- * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
- */
- init : function(userConfig) {
- /**
- * The OverlayManager's Config object used for monitoring configuration properties.
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- this.initDefaultConfig();
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
- this.cfg.fireQueue();
-
- /**
- * The currently activated Overlay
- * @property activeOverlay
- * @private
- * @type YAHOO.widget.Overlay
- */
- var activeOverlay = null;
-
- /**
- * Returns the currently focused Overlay
- * @method getActive
- * @return {YAHOO.widget.Overlay} The currently focused Overlay
- */
- this.getActive = function() {
- return activeOverlay;
- };
-
- /**
- * Focuses the specified Overlay
- * @method focus
- * @param {YAHOO.widget.Overlay} overlay The Overlay to focus
- * @param {String} overlay The id of the Overlay to focus
- */
- this.focus = function(overlay) {
- var o = this.find(overlay);
- if (o) {
- this.blurAll();
- activeOverlay = o;
- YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
- this.overlays.sort(this.compareZIndexDesc);
- var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
- if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
- activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2));
- }
- this.overlays.sort(this.compareZIndexDesc);
- }
- };
-
- /**
- * Removes the specified Overlay from the manager
- * @method remove
- * @param {YAHOO.widget.Overlay} overlay The Overlay to remove
- * @param {String} overlay The id of the Overlay to remove
- */
- this.remove = function(overlay) {
- var o = this.find(overlay);
- if (o) {
- var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
- o.cfg.setProperty("zIndex", -1000, true);
- this.overlays.sort(this.compareZIndexDesc);
- this.overlays = this.overlays.slice(0, this.overlays.length-1);
- o.cfg.setProperty("zIndex", originalZ, true);
-
- o.cfg.setProperty("manager", null);
- o.focusEvent = null;
- o.blurEvent = null;
- o.focus = null;
- o.blur = null;
- }
- };
-
- /**
- * Removes focus from all registered Overlays in the manager
- * @method blurAll
- */
- this.blurAll = function() {
- activeOverlay = null;
- for (var o=0;o 0) {
- return true;
- }
- } else {
- return false;
- }
- },
-
- /**
- * Attempts to locate an Overlay by instance or ID.
- * @method find
- * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager
- * @param {String} overlay An Overlay id to locate within the manager
- * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located.
- */
- find : function(overlay) {
- if (overlay instanceof YAHOO.widget.Overlay) {
- for (var o=0;o zIndex2) {
- return -1;
- } else if (zIndex1 < zIndex2) {
- return 1;
- } else {
- return 0;
- }
- },
-
- /**
- * Shows all Overlays in the manager.
- * @method showAll
- */
- showAll : function() {
- for (var o=0;oOR
-* @param {HTMLElement} el The element representing the Tooltip
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
-*/
-YAHOO.widget.Tooltip = function(el, userConfig) {
- YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay);
-
-/**
-* Constant representing the Tooltip CSS class
-* @property YAHOO.widget.Tooltip.CSS_TOOLTIP
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Tooltip.CSS_TOOLTIP = "tt";
-
-/**
-* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well.
-* @method init
-* @param {String} el The element ID representing the Tooltip OR
-* @param {HTMLElement} el The element representing the Tooltip
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details.
-*/
-YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) {
- if (document.readyState && document.readyState != "complete") {
- var deferredInit = function() {
- this.init(el, userConfig);
- };
- YAHOO.util.Event.addListener(window, "load", deferredInit, this, true);
- } else {
- YAHOO.widget.Tooltip.superclass.init.call(this, el);
-
- this.beforeInitEvent.fire(YAHOO.widget.Tooltip);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP);
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- this.cfg.queueProperty("visible",false);
- this.cfg.queueProperty("constraintoviewport",true);
-
- this.setBody("");
- this.render(this.cfg.getProperty("container"));
-
- this.initEvent.fire(YAHOO.widget.Tooltip);
- }
-};
-
-/**
-* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() {
- YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);
-
- /**
- * Specifies whether the Tooltip should be kept from overlapping its context element.
- * @config preventoverlap
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } );
-
- /**
- * The number of milliseconds to wait before showing a Tooltip on mouseover.
- * @config showdelay
- * @type Number
- * @default 200
- */
- this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } );
-
- /**
- * The number of milliseconds to wait before automatically dismissing a Tooltip after the mouse has been resting on the context element.
- * @config autodismissdelay
- * @type Number
- * @default 5000
- */
- this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } );
-
- /**
- * The number of milliseconds to wait before hiding a Tooltip on mouseover.
- * @config hidedelay
- * @type Number
- * @default 250
- */
- this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } );
-
- /**
- * Specifies the Tooltip's text.
- * @config text
- * @type String
- * @default null
- */
- this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } );
-
- /**
- * Specifies the container element that the Tooltip's markup should be rendered into.
- * @config container
- * @type HTMLElement/String
- * @default document.body
- */
- this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } );
-
- /**
- * Specifies the element or elements that the Tooltip should be anchored to on mouseover.
- * @config context
- * @type HTMLElement[]/String[]
- * @default null
- */
-
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* The default event handler fired when the "text" property is changed.
-* @method configText
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) {
- var text = args[0];
- if (text) {
- this.setBody(text);
- }
-};
-
-/**
-* The default event handler fired when the "container" property is changed.
-* @method configContainer
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) {
- var container = args[0];
- if (typeof container == 'string') {
- this.cfg.setProperty("container", document.getElementById(container), true);
- }
-};
-
-/**
-* The default event handler fired when the "context" property is changed.
-* @method configContext
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) {
- var context = args[0];
- if (context) {
-
- // Normalize parameter into an array
- if (! (context instanceof Array)) {
- if (typeof context == "string") {
- this.cfg.setProperty("context", [document.getElementById(context)], true);
- } else { // Assuming this is an element
- this.cfg.setProperty("context", [context], true);
- }
- context = this.cfg.getProperty("context");
- }
-
-
- // Remove any existing mouseover/mouseout listeners
- if (this._context) {
- for (var c=0;cOR
-* @param {HTMLElement} el The element representing the Panel
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details.
-*/
-YAHOO.widget.Panel = function(el, userConfig) {
- YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay);
-
-/**
-* Constant representing the default CSS class used for a Panel
-* @property YAHOO.widget.Panel.CSS_PANEL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Panel.CSS_PANEL = "panel";
-
-/**
-* Constant representing the default CSS class used for a Panel's wrapping container
-* @property YAHOO.widget.Panel.CSS_PANEL_CONTAINER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "panel-container";
-
-/**
-* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
-*/
-YAHOO.widget.Panel.prototype.init = function(el, userConfig) {
- YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.Panel);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL);
-
- this.buildWrapper();
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- this.beforeRenderEvent.subscribe(function() {
- var draggable = this.cfg.getProperty("draggable");
- if (draggable) {
- if (! this.header) {
- this.setHeader(" ");
- }
- }
- }, this, true);
-
- var me = this;
-
- var doBlur = function() {
- this.blur();
- };
-
- this.showMaskEvent.subscribe(function() {
- var checkFocusable = function(el) {
- if ((el.tagName == "A" || el.tagName == "BUTTON" || el.tagName == "SELECT" || el.tagName == "INPUT" || el.tagName == "TEXTAREA" || el.tagName == "FORM") && el.type != "hidden") {
- if (! YAHOO.util.Dom.isAncestor(me.element, el)) {
- YAHOO.util.Event.addListener(el, "focus", doBlur, el, true);
- return true;
- }
- } else {
- return false;
- }
- };
-
- this.focusableElements = YAHOO.util.Dom.getElementsBy(checkFocusable);
- }, this, true);
-
- this.hideMaskEvent.subscribe(function() {
- for (var i=0;iOR
-* @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
-* @return {boolean} Success or failure of the render
-*/
-YAHOO.widget.Panel.prototype.render = function(appendToNode) {
- return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement);
-};
-
-/**
-* Returns a String representation of the object.
-* @method toString
-* @return {String} The string representation of the Panel.
-*/
-YAHOO.widget.Panel.prototype.toString = function() {
- return "Panel " + this.id;
-};
-
-/**
-* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
-* @namespace YAHOO.widget
-* @class Dialog
-* @extends YAHOO.widget.Panel
-* @constructor
-* @param {String} el The element ID representing the Dialog OR
-* @param {HTMLElement} el The element representing the Dialog
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
-*/
-YAHOO.widget.Dialog = function(el, userConfig) {
- YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel);
-
-/**
-* Constant representing the default CSS class used for a Dialog
-* @property YAHOO.widget.Dialog.CSS_DIALOG
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Dialog.CSS_DIALOG = "dialog";
-
-/**
-* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.Dialog.prototype.initDefaultConfig = function() {
- YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this);
-
- /**
- * The internally maintained callback object for use with the Connection utility
- * @property callback
- * @type Object
- */
- this.callback = {
- /**
- * The function to execute upon success of the Connection submission
- * @property callback.success
- * @type Function
- */
- success : null,
- /**
- * The function to execute upon failure of the Connection submission
- * @property callback.failure
- * @type Function
- */
- failure : null,
- /**
- * The arbitraty argument or arguments to pass to the Connection callback functions
- * @property callback.argument
- * @type Object
- */
- argument: null
- };
-
- // Add form dialog config properties //
-
- /**
- * The method to use for posting the Dialog's form. Possible values are "async", "form", and "manual".
- * @config postmethod
- * @type String
- * @default async
- */
- this.cfg.addProperty("postmethod", { value:"async", handler:this.configPostMethod, validator:function(val) {
- if (val != "form" && val != "async" && val != "none" && val != "manual") {
- return false;
- } else {
- return true;
- }
- } });
-
- /**
- * Object literal(s) defining the buttons for the Dialog's footer.
- * @config buttons
- * @type Object[]
- * @default "none"
- */
- this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } );
-};
-
-/**
-* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class.
-* @method initEvents
-*/
-YAHOO.widget.Dialog.prototype.initEvents = function() {
- YAHOO.widget.Dialog.superclass.initEvents.call(this);
-
- /**
- * CustomEvent fired prior to submission
- * @event beforeSumitEvent
- */
- this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit");
-
- /**
- * CustomEvent fired after submission
- * @event submitEvent
- */
- this.submitEvent = new YAHOO.util.CustomEvent("submit");
-
- /**
- * CustomEvent fired prior to manual submission
- * @event manualSubmitEvent
- */
- this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit");
-
- /**
- * CustomEvent fired prior to asynchronous submission
- * @event asyncSubmitEvent
- */
- this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit");
-
- /**
- * CustomEvent fired prior to form-based submission
- * @event formSubmitEvent
- */
- this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit");
-
- /**
- * CustomEvent fired after cancel
- * @event cancelEvent
- */
- this.cancelEvent = new YAHOO.util.CustomEvent("cancel");
-};
-
-/**
-* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the Dialog OR
-* @param {HTMLElement} el The element representing the Dialog
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
-*/
-YAHOO.widget.Dialog.prototype.init = function(el, userConfig) {
- YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.Dialog);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG);
-
- this.cfg.setProperty("visible", false);
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- this.showEvent.subscribe(this.focusFirst, this, true);
- this.beforeHideEvent.subscribe(this.blurButtons, this, true);
-
- this.beforeRenderEvent.subscribe(function() {
- var buttonCfg = this.cfg.getProperty("buttons");
- if (buttonCfg && buttonCfg != "none") {
- if (! this.footer) {
- this.setFooter("");
- }
- }
- }, this, true);
-
- this.initEvent.fire(YAHOO.widget.Dialog);
-};
-
-/**
-* Performs the submission of the Dialog form depending on the value of "postmethod" property.
-* @method doSubmit
-*/
-YAHOO.widget.Dialog.prototype.doSubmit = function() {
- var pm = this.cfg.getProperty("postmethod");
- switch (pm) {
- case "async":
- var method = this.form.getAttribute("method") || 'POST';
- method = method.toUpperCase();
- YAHOO.util.Connect.setForm(this.form);
- var cObj = YAHOO.util.Connect.asyncRequest(method, this.form.getAttribute("action"), this.callback);
- this.asyncSubmitEvent.fire();
- break;
- case "form":
- this.form.submit();
- this.formSubmitEvent.fire();
- break;
- case "none":
- case "manual":
- this.manualSubmitEvent.fire();
- break;
- }
-};
-
-/**
-* Prepares the Dialog's internal FORM object, creating one if one is not currently present.
-* @method registerForm
-*/
-YAHOO.widget.Dialog.prototype.registerForm = function() {
- var form = this.element.getElementsByTagName("FORM")[0];
-
- if (! form) {
- var formHTML = "";
- this.body.innerHTML += formHTML;
- form = this.element.getElementsByTagName("FORM")[0];
- }
-
- this.firstFormElement = function() {
- for (var f=0;f=0;f-- ) {
- var el = form.elements[f];
- if (el.focus) {
- if (el.type && el.type != "hidden") {
- return el;
- }
- }
- }
- return null;
- }();
-
- this.form = form;
-
- if (this.cfg.getProperty("modal") && this.form) {
-
- var me = this;
-
- var firstElement = this.firstFormElement || this.firstButton;
- if (firstElement) {
- this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} );
- this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true);
- this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true);
- }
-
- var lastElement = this.lastButton || this.lastFormElement;
- if (lastElement) {
- this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} );
- this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true);
- this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true);
- }
- }
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* The default event handler for the "buttons" configuration property
-* @method configButtons
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) {
- var buttons = args[0];
- if (buttons != "none") {
- this.buttonSpan = null;
- this.buttonSpan = document.createElement("SPAN");
- this.buttonSpan.className = "button-group";
-
- for (var b=0;bOR
-* @param {HTMLElement} el The element representing the SimpleDialog
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
-*/
-YAHOO.widget.SimpleDialog = function(el, userConfig) {
- YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog);
-
-/**
-* Constant for the standard network icon for a blocking action
-* @property YAHOO.widget.SimpleDialog.ICON_BLOCK
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_BLOCK = "nt/ic/ut/bsc/blck16_1.gif";
-
-/**
-* Constant for the standard network icon for alarm
-* @property YAHOO.widget.SimpleDialog.ICON_ALARM
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_ALARM = "nt/ic/ut/bsc/alrt16_1.gif";
-
-/**
-* Constant for the standard network icon for help
-* @property YAHOO.widget.SimpleDialog.ICON_HELP
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_HELP = "nt/ic/ut/bsc/hlp16_1.gif";
-
-/**
-* Constant for the standard network icon for info
-* @property YAHOO.widget.SimpleDialog.ICON_INFO
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_INFO = "nt/ic/ut/bsc/info16_1.gif";
-
-/**
-* Constant for the standard network icon for warn
-* @property YAHOO.widget.SimpleDialog.ICON_WARN
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_WARN = "nt/ic/ut/bsc/warn16_1.gif";
-
-/**
-* Constant for the standard network icon for a tip
-* @property YAHOO.widget.SimpleDialog.ICON_TIP
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.ICON_TIP = "nt/ic/ut/bsc/tip16_1.gif";
-
-/**
-* Constant representing the default CSS class used for a SimpleDialog
-* @property YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "simple-dialog";
-
-/**
-* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() {
- YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this);
-
- // Add dialog config properties //
-
- /**
- * Sets the informational icon for the SimpleDialog
- * @config icon
- * @type String
- * @default "none"
- */
- this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } );
-
- /**
- * Sets the text for the SimpleDialog
- * @config text
- * @type String
- * @default ""
- */
- this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } );
-};
-
-
-/**
-* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the SimpleDialog OR
-* @param {HTMLElement} el The element representing the SimpleDialog
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
-*/
-YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) {
- YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG);
-
- this.cfg.queueProperty("postmethod", "manual");
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- this.beforeRenderEvent.subscribe(function() {
- if (! this.body) {
- this.setBody("");
- }
- }, this, true);
-
- this.initEvent.fire(YAHOO.widget.SimpleDialog);
-
-};
-/**
-* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field.
-* @method registerForm
-*/
-YAHOO.widget.SimpleDialog.prototype.registerForm = function() {
- YAHOO.widget.SimpleDialog.superclass.registerForm.call(this);
- this.form.innerHTML += " ";
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* Fired when the "icon" property is set.
-* @method configIcon
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) {
- var icon = args[0];
- if (icon && icon != "none") {
- var iconHTML = " ";
- this.body.innerHTML = iconHTML + this.body.innerHTML;
- }
-};
-
-/**
-* Fired when the "text" property is set.
-* @method configText
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) {
- var text = args[0];
- if (text) {
- this.setBody(text);
- this.cfg.refireEvent("icon");
- }
-};
-// END BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* Returns a string representation of the object.
-* @method toString
-* @return {String} The string representation of the SimpleDialog
-*/
-YAHOO.widget.SimpleDialog.prototype.toString = function() {
- return "SimpleDialog " + this.id;
-};
-
-/**
-* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden.
-* @namespace YAHOO.widget
-* @class ContainerEffect
-* @constructor
-* @param {YAHOO.widget.Overlay} overlay The Overlay that the animation should be associated with
-* @param {Object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
-* @param {Object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
-* @param {HTMLElement} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element.
-* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion.
-*/
-YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) {
- if (! animClass) {
- animClass = YAHOO.util.Anim;
- }
-
- /**
- * The overlay to animate
- * @property overlay
- * @type YAHOO.widget.Overlay
- */
- this.overlay = overlay;
- /**
- * The animation attributes to use when transitioning into view
- * @property attrIn
- * @type Object
- */
- this.attrIn = attrIn;
- /**
- * The animation attributes to use when transitioning out of view
- * @property attrOut
- * @type Object
- */
- this.attrOut = attrOut;
- /**
- * The target element to be animated
- * @property targetElement
- * @type HTMLElement
- */
- this.targetElement = targetElement || overlay.element;
- /**
- * The animation class to use for animating the overlay
- * @property animClass
- * @type class
- */
- this.animClass = animClass;
-};
-
-/**
-* Initializes the animation classes and events.
-* @method init
-*/
-YAHOO.widget.ContainerEffect.prototype.init = function() {
- this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn");
- this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut");
-
- this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete");
- this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete");
-
- this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method);
- this.animIn.onStart.subscribe(this.handleStartAnimateIn, this);
- this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this);
- this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this);
-
- this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method);
- this.animOut.onStart.subscribe(this.handleStartAnimateOut, this);
- this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this);
- this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this);
-};
-
-/**
-* Triggers the in-animation.
-* @method animateIn
-*/
-YAHOO.widget.ContainerEffect.prototype.animateIn = function() {
- this.beforeAnimateInEvent.fire();
- this.animIn.animate();
-};
-
-/**
-* Triggers the out-animation.
-* @method animateOut
-*/
-YAHOO.widget.ContainerEffect.prototype.animateOut = function() {
- this.beforeAnimateOutEvent.fire();
- this.animOut.animate();
-};
-
-/**
-* The default onStart handler for the in-animation.
-* @method handleStartAnimateIn
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { };
-/**
-* The default onTween handler for the in-animation.
-* @method handleTweenAnimateIn
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { };
-/**
-* The default onComplete handler for the in-animation.
-* @method handleCompleteAnimateIn
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { };
-
-/**
-* The default onStart handler for the out-animation.
-* @method handleStartAnimateOut
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { };
-/**
-* The default onTween handler for the out-animation.
-* @method handleTweenAnimateOut
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { };
-/**
-* The default onComplete handler for the out-animation.
-* @method handleCompleteAnimateOut
-* @param {String} type The CustomEvent type
-* @param {Object[]} args The CustomEvent arguments
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { };
-
-/**
-* Returns a string representation of the object.
-* @method toString
-* @return {String} The string representation of the ContainerEffect
-*/
-YAHOO.widget.ContainerEffect.prototype.toString = function() {
- var output = "ContainerEffect";
- if (this.overlay) {
- output += " [" + this.overlay.toString() + "]";
- }
- return output;
-};
-
-/**
-* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out.
-* @method FADE
-* @static
-* @param {Overlay} overlay The Overlay object to animate
-* @param {Number} dur The duration of the animation
-* @return {ContainerEffect} The configured ContainerEffect object
-*/
-YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) {
- var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element );
-
- fade.handleStartAnimateIn = function(type,args,obj) {
- YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
-
- if (! obj.overlay.underlay) {
- obj.overlay.cfg.refireEvent("underlay");
- }
-
- if (obj.overlay.underlay) {
- obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity");
- obj.overlay.underlay.style.filter = null;
- }
-
- YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
- YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0);
- };
-
- fade.handleCompleteAnimateIn = function(type,args,obj) {
- YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
-
- if (obj.overlay.element.style.filter) {
- obj.overlay.element.style.filter = null;
- }
-
- if (obj.overlay.underlay) {
- YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity);
- }
-
- obj.overlay.cfg.refireEvent("iframe");
- obj.animateInCompleteEvent.fire();
- };
-
- fade.handleStartAnimateOut = function(type, args, obj) {
- YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
-
- if (obj.overlay.underlay) {
- obj.overlay.underlay.style.filter = null;
- }
- };
-
- fade.handleCompleteAnimateOut = function(type, args, obj) {
- YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
- if (obj.overlay.element.style.filter) {
- obj.overlay.element.style.filter = null;
- }
- YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
- YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1);
-
- obj.overlay.cfg.refireEvent("iframe");
-
- obj.animateOutCompleteEvent.fire();
- };
-
- fade.init();
- return fade;
-};
-
-
-/**
-* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out.
-* @method SLIDE
-* @static
-* @param {Overlay} overlay The Overlay object to animate
-* @param {Number} dur The duration of the animation
-* @return {ContainerEffect} The configured ContainerEffect object
-*/
-YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) {
- var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element);
- var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element);
-
- var clientWidth = YAHOO.util.Dom.getClientWidth();
- var offsetWidth = overlay.element.offsetWidth;
-
- var slide = new YAHOO.widget.ContainerEffect(overlay, {
- attributes:{ points: { to:[x, y] } },
- duration:dur,
- method:YAHOO.util.Easing.easeIn
- },
- {
- attributes:{ points: { to:[(clientWidth+25), y] } },
- duration:dur,
- method:YAHOO.util.Easing.easeOut
- },
- overlay.element,
- YAHOO.util.Motion);
-
-
- slide.handleStartAnimateIn = function(type,args,obj) {
- obj.overlay.element.style.left = (-25-offsetWidth) + "px";
- obj.overlay.element.style.top = y + "px";
- };
-
- slide.handleTweenAnimateIn = function(type, args, obj) {
-
-
- var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
-
- var currentX = pos[0];
- var currentY = pos[1];
-
- if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) {
- YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
- }
-
- obj.overlay.cfg.setProperty("xy", [currentX,currentY], true);
- obj.overlay.cfg.refireEvent("iframe");
- };
-
- slide.handleCompleteAnimateIn = function(type, args, obj) {
- obj.overlay.cfg.setProperty("xy", [x,y], true);
- obj.startX = x;
- obj.startY = y;
- obj.overlay.cfg.refireEvent("iframe");
- obj.animateInCompleteEvent.fire();
- };
-
- slide.handleStartAnimateOut = function(type, args, obj) {
- var vw = YAHOO.util.Dom.getViewportWidth();
-
- var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
-
- var yso = pos[1];
-
- var currentTo = obj.animOut.attributes.points.to;
- obj.animOut.attributes.points.to = [(vw+25), yso];
- };
-
- slide.handleTweenAnimateOut = function(type, args, obj) {
- var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
-
- var xto = pos[0];
- var yto = pos[1];
-
- obj.overlay.cfg.setProperty("xy", [xto,yto], true);
- obj.overlay.cfg.refireEvent("iframe");
- };
-
- slide.handleCompleteAnimateOut = function(type, args, obj) {
- YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
-
- obj.overlay.cfg.setProperty("xy", [x,y]);
- obj.animateOutCompleteEvent.fire();
- };
-
- slide.init();
- return slide;
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/**
+* Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
+* @namespace YAHOO.util
+* @class Config
+* @constructor
+* @param {Object} owner The owner Object to which this Config Object belongs
+*/
+YAHOO.util.Config = function(owner) {
+ if (owner) {
+ this.init(owner);
+ }
+};
+
+YAHOO.util.Config.prototype = {
+
+ /**
+ * Object reference to the owner of this Config Object
+ * @property owner
+ * @type Object
+ */
+ owner : null,
+
+ /**
+ * Boolean flag that specifies whether a queue is currently being executed
+ * @property queueInProgress
+ * @type Boolean
+ */
+ queueInProgress : false,
+
+
+ /**
+ * Validates that the value passed in is a Boolean.
+ * @method checkBoolean
+ * @param {Object} val The value to validate
+ * @return {Boolean} true, if the value is valid
+ */
+ checkBoolean: function(val) {
+ if (typeof val == 'boolean') {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Validates that the value passed in is a number.
+ * @method checkNumber
+ * @param {Object} val The value to validate
+ * @return {Boolean} true, if the value is valid
+ */
+ checkNumber: function(val) {
+ if (isNaN(val)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+};
+
+
+/**
+* Initializes the configuration Object and all of its local members.
+* @method init
+* @param {Object} owner The owner Object to which this Config Object belongs
+*/
+YAHOO.util.Config.prototype.init = function(owner) {
+
+ this.owner = owner;
+
+ /**
+ * Object reference to the owner of this Config Object
+ * @event configChangedEvent
+ */
+ this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
+
+ this.queueInProgress = false;
+
+ /* Private Members */
+
+ /**
+ * Maintains the local collection of configuration property objects and their specified values
+ * @property config
+ * @private
+ * @type Object
+ */
+ var config = {};
+
+ /**
+ * Maintains the local collection of configuration property objects as they were initially applied.
+ * This object is used when resetting a property.
+ * @property initialConfig
+ * @private
+ * @type Object
+ */
+ var initialConfig = {};
+
+ /**
+ * Maintains the local, normalized CustomEvent queue
+ * @property eventQueue
+ * @private
+ * @type Object
+ */
+ var eventQueue = [];
+
+ /**
+ * Fires a configuration property event using the specified value.
+ * @method fireEvent
+ * @private
+ * @param {String} key The configuration property's name
+ * @param {value} Object The value of the correct type for the property
+ */
+ var fireEvent = function( key, value ) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ property.event.fire(value);
+ }
+ };
+ /* End Private Members */
+
+ /**
+ * Adds a property to the Config Object's private config hash.
+ * @method addProperty
+ * @param {String} key The configuration property's name
+ * @param {Object} propertyObject The Object containing all of this property's arguments
+ */
+ this.addProperty = function( key, propertyObject ) {
+ key = key.toLowerCase();
+
+ config[key] = propertyObject;
+
+ propertyObject.event = new YAHOO.util.CustomEvent(key);
+ propertyObject.key = key;
+
+ if (propertyObject.handler) {
+ propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
+ }
+
+ this.setProperty(key, propertyObject.value, true);
+
+ if (! propertyObject.suppressEvent) {
+ this.queueProperty(key, propertyObject.value);
+ }
+ };
+
+ /**
+ * Returns a key-value configuration map of the values currently set in the Config Object.
+ * @method getConfig
+ * @return {Object} The current config, represented in a key-value map
+ */
+ this.getConfig = function() {
+ var cfg = {};
+
+ for (var prop in config) {
+ var property = config[prop];
+ if (typeof property != 'undefined' && property.event) {
+ cfg[prop] = property.value;
+ }
+ }
+
+ return cfg;
+ };
+
+ /**
+ * Returns the value of specified property.
+ * @method getProperty
+ * @param {String} key The name of the property
+ * @return {Object} The value of the specified property
+ */
+ this.getProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.value;
+ } else {
+ return undefined;
+ }
+ };
+
+ /**
+ * Resets the specified property's value to its initial value.
+ * @method resetProperty
+ * @param {String} key The name of the property
+ * @return {Boolean} True is the property was reset, false if not
+ */
+ this.resetProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (initialConfig[key] && initialConfig[key] != 'undefined') {
+ this.setProperty(key, initialConfig[key]);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
+ * @method setProperty
+ * @param {String} key The name of the property
+ * @param {String} value The value to set the property to
+ * @param {Boolean} silent Whether the value should be set silently, without firing the property event.
+ * @return {Boolean} True, if the set was successful, false if it failed.
+ */
+ this.setProperty = function(key, value, silent) {
+ key = key.toLowerCase();
+
+ if (this.queueInProgress && ! silent) {
+ this.queueProperty(key,value); // Currently running through a queue...
+ return true;
+ } else {
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+ property.value = value;
+ if (! silent) {
+ fireEvent(key, value);
+ this.configChangedEvent.fire([key, value]);
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+ };
+
+ /**
+ * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
+ * moved from its current position to the end of the queue.
+ * @method queueProperty
+ * @param {String} key The name of the property
+ * @param {String} value The value to set the property to
+ * @return {Boolean} true, if the set was successful, false if it failed.
+ */
+ this.queueProperty = function(key, value) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+
+ if (typeof value != 'undefined') {
+ property.value = value;
+ } else {
+ value = property.value;
+ }
+
+ var foundDuplicate = false;
+
+ for (var i=0;iOR
+* @param {HTMLElement} el The element representing the Module
+* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+*/
+YAHOO.widget.Module = function(el, userConfig) {
+ if (el) {
+ this.init(el, userConfig);
+ }
+};
+
+/**
+* Constant representing the prefix path to use for non-secure images
+* @property YAHOO.widget.Module.IMG_ROOT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
+
+/**
+* Constant representing the prefix path to use for securely served images
+* @property YAHOO.widget.Module.IMG_ROOT_SSL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
+
+/**
+* Constant for the default CSS class name that represents a Module
+* @property YAHOO.widget.Module.CSS_MODULE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_MODULE = "module";
+
+/**
+* Constant representing the module header
+* @property YAHOO.widget.Module.CSS_HEADER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_HEADER = "hd";
+
+/**
+* Constant representing the module body
+* @property YAHOO.widget.Module.CSS_BODY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_BODY = "bd";
+
+/**
+* Constant representing the module footer
+* @property YAHOO.widget.Module.CSS_FOOTER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_FOOTER = "ft";
+
+/**
+* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
+* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";
+
+/**
+* Singleton CustomEvent fired when the font size is changed in the browser.
+* Opera's "zoom" functionality currently does not support text size detection.
+* @event YAHOO.widget.Module.textResizeEvent
+*/
+YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");
+
+YAHOO.widget.Module.prototype = {
+ /**
+ * The class's constructor function
+ * @property contructor
+ * @type Function
+ */
+ constructor : YAHOO.widget.Module,
+
+ /**
+ * The main module element that contains the header, body, and footer
+ * @property element
+ * @type HTMLElement
+ */
+ element : null,
+
+ /**
+ * The header element, denoted with CSS class "hd"
+ * @property header
+ * @type HTMLElement
+ */
+ header : null,
+
+ /**
+ * The body element, denoted with CSS class "bd"
+ * @property body
+ * @type HTMLElement
+ */
+ body : null,
+
+ /**
+ * The footer element, denoted with CSS class "ft"
+ * @property footer
+ * @type HTMLElement
+ */
+ footer : null,
+
+ /**
+ * The id of the element
+ * @property id
+ * @type String
+ */
+ id : null,
+
+ /**
+ * The String representing the image root
+ * @property imageRoot
+ * @type String
+ */
+ imageRoot : YAHOO.widget.Module.IMG_ROOT,
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ * @method initEvents
+ */
+ initEvents : function() {
+
+ /**
+ * CustomEvent fired prior to class initalization.
+ * @event beforeInitEvent
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ */
+ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
+
+ /**
+ * CustomEvent fired after class initalization.
+ * @event initEvent
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ */
+ this.initEvent = new YAHOO.util.CustomEvent("init");
+
+ /**
+ * CustomEvent fired when the Module is appended to the DOM
+ * @event appendEvent
+ */
+ this.appendEvent = new YAHOO.util.CustomEvent("append");
+
+ /**
+ * CustomEvent fired before the Module is rendered
+ * @event beforeRenderEvent
+ */
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+
+ /**
+ * CustomEvent fired after the Module is rendered
+ * @event renderEvent
+ */
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ /**
+ * CustomEvent fired when the header content of the Module is modified
+ * @event changeHeaderEvent
+ * @param {String/HTMLElement} content String/element representing the new header content
+ */
+ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
+
+ /**
+ * CustomEvent fired when the body content of the Module is modified
+ * @event changeBodyEvent
+ * @param {String/HTMLElement} content String/element representing the new body content
+ */
+ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
+
+ /**
+ * CustomEvent fired when the footer content of the Module is modified
+ * @event changeFooterEvent
+ * @param {String/HTMLElement} content String/element representing the new footer content
+ */
+ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
+
+ /**
+ * CustomEvent fired when the content of the Module is modified
+ * @event changeContentEvent
+ */
+ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
+
+ /**
+ * CustomEvent fired when the Module is destroyed
+ * @event destroyEvent
+ */
+ this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
+
+ /**
+ * CustomEvent fired before the Module is shown
+ * @event beforeShowEvent
+ */
+ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
+
+ /**
+ * CustomEvent fired after the Module is shown
+ * @event showEvent
+ */
+ this.showEvent = new YAHOO.util.CustomEvent("show");
+
+ /**
+ * CustomEvent fired before the Module is hidden
+ * @event beforeHideEvent
+ */
+ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
+
+ /**
+ * CustomEvent fired after the Module is hidden
+ * @event hideEvent
+ */
+ this.hideEvent = new YAHOO.util.CustomEvent("hide");
+ },
+
+ /**
+ * String representing the current user-agent platform
+ * @property platform
+ * @type String
+ */
+ platform : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
+ return "windows";
+ } else if (ua.indexOf("macintosh") != -1) {
+ return "mac";
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * String representing the current user-agent browser
+ * @property browser
+ * @type String
+ */
+ browser : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
+ return 'opera';
+ } else if (ua.indexOf('msie 7')!=-1) { // IE7
+ return 'ie7';
+ } else if (ua.indexOf('msie') !=-1) { // IE
+ return 'ie';
+ } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ } else if (ua.indexOf('gecko') != -1) { // Gecko
+ return 'gecko';
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Boolean representing whether or not the current browsing context is secure (https)
+ * @property isSecure
+ * @type Boolean
+ */
+ isSecure : function() {
+ if (window.location.href.toLowerCase().indexOf("https") === 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initDefaultConfig : function() {
+ // Add properties //
+
+ /**
+ * Specifies whether the Module is visible on the page.
+ * @config visible
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
+
+ /**
+ * Object or array of objects representing the ContainerEffect classes that are active for animating the container.
+ * @config effect
+ * @type Object
+ * @default null
+ */
+ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
+
+ /**
+ * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document
+ * @config monitorresize
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
+ },
+
+ /**
+ * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+ * @method init
+ * @param {String} el The element ID representing the Module OR
+ * @param {HTMLElement} el The element representing the Module
+ * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+ */
+ init : function(el, userConfig) {
+
+ this.initEvents();
+
+ this.beforeInitEvent.fire(YAHOO.widget.Module);
+
+ /**
+ * The Module's Config object used for monitoring configuration properties.
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ if (this.isSecure) {
+ this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
+ }
+
+ if (typeof el == "string") {
+ var elId = el;
+
+ el = document.getElementById(el);
+ if (! el) {
+ el = document.createElement("DIV");
+ el.id = elId;
+ }
+ }
+
+ this.element = el;
+
+ if (el.id) {
+ this.id = el.id;
+ }
+
+ var childNodes = this.element.childNodes;
+
+ if (childNodes) {
+ for (var i=0;iOR
+ * @param {HTMLElement} headerContent The HTMLElement to append to the header
+ */
+ setHeader : function(headerContent) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ if (typeof headerContent == "string") {
+ this.header.innerHTML = headerContent;
+ } else {
+ this.header.innerHTML = "";
+ this.header.appendChild(headerContent);
+ }
+
+ this.changeHeaderEvent.fire(headerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the header. If no header is present, one will be automatically created.
+ * @method appendToHeader
+ * @param {HTMLElement} element The element to append to the header
+ */
+ appendToHeader : function(element) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ this.header.appendChild(element);
+ this.changeHeaderEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
+ * @method setBody
+ * @param {String} bodyContent The HTML used to set the body OR
+ * @param {HTMLElement} bodyContent The HTMLElement to append to the body
+ */
+ setBody : function(bodyContent) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ if (typeof bodyContent == "string")
+ {
+ this.body.innerHTML = bodyContent;
+ } else {
+ this.body.innerHTML = "";
+ this.body.appendChild(bodyContent);
+ }
+
+ this.changeBodyEvent.fire(bodyContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the body. If no body is present, one will be automatically created.
+ * @method appendToBody
+ * @param {HTMLElement} element The element to append to the body
+ */
+ appendToBody : function(element) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ this.body.appendChild(element);
+ this.changeBodyEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @method setFooter
+ * @param {String} footerContent The HTML used to set the footer OR
+ * @param {HTMLElement} footerContent The HTMLElement to append to the footer
+ */
+ setFooter : function(footerContent) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ if (typeof footerContent == "string") {
+ this.footer.innerHTML = footerContent;
+ } else {
+ this.footer.innerHTML = "";
+ this.footer.appendChild(footerContent);
+ }
+
+ this.changeFooterEvent.fire(footerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @method appendToFooter
+ * @param {HTMLElement} element The element to append to the footer
+ */
+ appendToFooter : function(element) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ this.footer.appendChild(element);
+ this.changeFooterEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+ * @method render
+ * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering OR
+ * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
+ * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
+ * @return {Boolean} Success or failure of the render
+ */
+ render : function(appendToNode, moduleElement) {
+ this.beforeRenderEvent.fire();
+
+ if (! moduleElement) {
+ moduleElement = this.element;
+ }
+
+ var me = this;
+ var appendTo = function(element) {
+ if (typeof element == "string") {
+ element = document.getElementById(element);
+ }
+
+ if (element) {
+ element.appendChild(me.element);
+ me.appendEvent.fire();
+ }
+ };
+
+ if (appendToNode) {
+ appendTo(appendToNode);
+ } else { // No node was passed in. If the element is not pre-marked up, this fails
+ if (! YAHOO.util.Dom.inDocument(this.element)) {
+ return false;
+ }
+ }
+
+ // Need to get everything into the DOM if it isn't already
+
+ if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
+ // There is a header, but it's not in the DOM yet... need to add it
+ var firstChild = moduleElement.firstChild;
+ if (firstChild) { // Insert before first child if exists
+ moduleElement.insertBefore(this.header, firstChild);
+ } else { // Append to empty body because there are no children
+ moduleElement.appendChild(this.header);
+ }
+ }
+
+ if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
+ // There is a body, but it's not in the DOM yet... need to add it
+ if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
+ moduleElement.insertBefore(this.body, this.footer);
+ } else { // Append to element because there is no footer
+ moduleElement.appendChild(this.body);
+ }
+ }
+
+ if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
+ // There is a footer, but it's not in the DOM yet... need to add it
+ moduleElement.appendChild(this.footer);
+ }
+
+ this.renderEvent.fire();
+ return true;
+ },
+
+ /**
+ * Removes the Module element from the DOM and sets all child elements to null.
+ * @method destroy
+ */
+ destroy : function() {
+ var parent;
+
+ if (this.element) {
+ YAHOO.util.Event.purgeElement(this.element, true);
+ parent = this.element.parentNode;
+ }
+ if (parent) {
+ parent.removeChild(this.element);
+ }
+
+ this.element = null;
+ this.header = null;
+ this.body = null;
+ this.footer = null;
+
+ for (var e in this) {
+ if (e instanceof YAHOO.util.CustomEvent) {
+ e.unsubscribeAll();
+ }
+ }
+
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this);
+
+ this.destroyEvent.fire();
+ },
+
+ /**
+ * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
+ * @method show
+ */
+ show : function() {
+ this.cfg.setProperty("visible", true);
+ },
+
+ /**
+ * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
+ * @method hide
+ */
+ hide : function() {
+ this.cfg.setProperty("visible", false);
+ },
+
+ // BUILT-IN EVENT HANDLERS FOR MODULE //
+
+ /**
+ * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
+ * This method is responsible for firing showEvent and hideEvent.
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ * @method configVisible
+ */
+ configVisible : function(type, args, obj) {
+ var visible = args[0];
+ if (visible) {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "block");
+ this.showEvent.fire();
+ } else {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "none");
+ this.hideEvent.fire();
+ }
+ },
+
+ /**
+ * Default event handler for the "monitorresize" configuration property
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ * @method configMonitorResize
+ */
+ configMonitorResize : function(type, args, obj) {
+ var monitor = args[0];
+ if (monitor) {
+ this.initResizeMonitor();
+ } else {
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this, true);
+ this.resizeMonitor = null;
+ }
+ }
+};
+
+/**
+* Returns a String representation of the Object.
+* @method toString
+* @return {String} The string representation of the Module
+*/
+YAHOO.widget.Module.prototype.toString = function() {
+ return "Module " + this.id;
+};
+
+/**
+* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
+* @namespace YAHOO.widget
+* @class Overlay
+* @extends YAHOO.widget.Module
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Overlay = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
+
+/**
+* The URL that will be placed in the iframe
+* @property YAHOO.widget.Overlay.IFRAME_SRC
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;";
+
+/**
+* Constant representing the top left corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.TOP_LEFT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.TOP_LEFT = "tl";
+
+/**
+* Constant representing the top right corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.TOP_RIGHT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.TOP_RIGHT = "tr";
+
+/**
+* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.BOTTOM_LEFT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
+
+/**
+* Constant representing the bottom right corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.BOTTOM_RIGHT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
+
+/**
+* Constant representing the default CSS class used for an Overlay
+* @property YAHOO.widget.Overlay.CSS_OVERLAY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Overlay);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ if (this.platform == "mac" && this.browser == "gecko") {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
+ this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
+ this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
+ }
+ }
+
+ this.initEvent.fire(YAHOO.widget.Overlay);
+};
+
+/**
+* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
+* @method initEvents
+*/
+YAHOO.widget.Overlay.prototype.initEvents = function() {
+ YAHOO.widget.Overlay.superclass.initEvents.call(this);
+
+ /**
+ * CustomEvent fired before the Overlay is moved.
+ * @event beforeMoveEvent
+ * @param {Number} x x coordinate
+ * @param {Number} y y coordinate
+ */
+ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
+
+ /**
+ * CustomEvent fired after the Overlay is moved.
+ * @event moveEvent
+ * @param {Number} x x coordinate
+ * @param {Number} y y coordinate
+ */
+ this.moveEvent = new YAHOO.util.CustomEvent("move", this);
+};
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
+
+ // Add overlay config properties //
+
+ /**
+ * The absolute x-coordinate position of the Overlay
+ * @config x
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * The absolute y-coordinate position of the Overlay
+ * @config y
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * An array with the absolute x and y positions of the Overlay
+ * @config xy
+ * @type Number[]
+ * @default null
+ */
+ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner.
+ * @config context
+ * @type Array
+ * @default null
+ */
+ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * True if the Overlay should be anchored to the center of the viewport.
+ * @config fixedcenter
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
+
+ /**
+ * CSS width of the Overlay.
+ * @config width
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * CSS height of the Overlay.
+ * @config height
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * CSS z-index of the Overlay.
+ * @config zIndex
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
+
+ /**
+ * True if the Overlay should be prevented from being positioned out of the viewport.
+ * @config constraintoviewport
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
+
+ /**
+ * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below).
+ * @config iframe
+ * @type Boolean
+ * @default true for IE6 and below, false for all others
+ */
+ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
+};
+
+/**
+* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
+* @method moveTo
+* @param {Number} x The Overlay's new x position
+* @param {Number} y The Overlay's new y position
+*/
+YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
+ this.cfg.setProperty("xy",[x,y]);
+};
+
+/**
+* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+* @method hideMacGeckoScrollbars
+*/
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
+};
+
+/**
+* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+* @method showMacGeckoScrollbars
+*/
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
+* @method configVisible
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
+ var visible = args[0];
+
+ var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
+
+ if (currentVis == "inherit") {
+ var e = this.element.parentNode;
+ while (e.nodeType != 9 && e.nodeType != 11) {
+ currentVis = YAHOO.util.Dom.getStyle(e, "visibility");
+ if (currentVis != "inherit") { break; }
+ e = e.parentNode;
+ }
+ if (currentVis == "inherit") {
+ currentVis = "visible";
+ }
+ }
+
+ var effect = this.cfg.getProperty("effect");
+
+ var effectInstances = [];
+ if (effect) {
+ if (effect instanceof Array) {
+ for (var i=0;i rightConstraint) {
+ x = rightConstraint;
+ }
+
+ if (y < topConstraint) {
+ y = topConstraint;
+ } else if (y > bottomConstraint) {
+ y = bottomConstraint;
+ }
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+ this.cfg.setProperty("xy", [x,y], true);
+};
+
+/**
+* Centers the container in the viewport.
+* @method center
+*/
+YAHOO.widget.Overlay.prototype.center = function() {
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+
+ var viewPortWidth = YAHOO.util.Dom.getClientWidth();
+ var viewPortHeight = YAHOO.util.Dom.getClientHeight();
+
+ var elementWidth = this.element.offsetWidth;
+ var elementHeight = this.element.offsetHeight;
+
+ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
+ var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
+
+ this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
+
+ this.cfg.refireEvent("iframe");
+};
+
+/**
+* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
+* @method syncPosition
+*/
+YAHOO.widget.Overlay.prototype.syncPosition = function() {
+ var pos = YAHOO.util.Dom.getXY(this.element);
+ this.cfg.setProperty("x", pos[0], true);
+ this.cfg.setProperty("y", pos[1], true);
+ this.cfg.setProperty("xy", pos, true);
+};
+
+/**
+* Event handler fired when the resize monitor element is resized.
+* @method onDomResize
+* @param {DOMEvent} e The resize DOM event
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
+ var me = this;
+ setTimeout(function() {
+ me.syncPosition();
+ me.cfg.refireEvent("iframe");
+ me.cfg.refireEvent("context");
+ }, 0);
+};
+
+/**
+* Removes the Overlay element from the DOM and sets all child elements to null.
+* @method destroy
+*/
+YAHOO.widget.Overlay.prototype.destroy = function() {
+ if (this.iframe) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+
+ this.iframe = null;
+
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+
+ YAHOO.widget.Overlay.superclass.destroy.call(this);
+};
+
+/**
+* Returns a String representation of the object.
+* @method toString
+* @return {String} The string representation of the Overlay.
+*/
+YAHOO.widget.Overlay.prototype.toString = function() {
+ return "Overlay " + this.id;
+};
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window scroll
+* @event YAHOO.widget.Overlay.windowScrollEvent
+*/
+YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window resize
+* @event YAHOO.widget.Overlay.windowResizeEvent
+*/
+YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
+
+/**
+* The DOM event handler used to fire the CustomEvent for window scroll
+* @method YAHOO.widget.Overlay.windowScrollHandler
+* @static
+* @param {DOMEvent} e The DOM scroll event
+*/
+YAHOO.widget.Overlay.windowScrollHandler = function(e) {
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
+ if (! window.scrollEnd) {
+ window.scrollEnd = -1;
+ }
+ clearTimeout(window.scrollEnd);
+ window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1);
+ } else {
+ YAHOO.widget.Overlay.windowScrollEvent.fire();
+ }
+};
+
+/**
+* The DOM event handler used to fire the CustomEvent for window resize
+* @method YAHOO.widget.Overlay.windowResizeHandler
+* @static
+* @param {DOMEvent} e The DOM resize event
+*/
+YAHOO.widget.Overlay.windowResizeHandler = function(e) {
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
+ if (! window.resizeEnd) {
+ window.resizeEnd = -1;
+ }
+ clearTimeout(window.resizeEnd);
+ window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100);
+ } else {
+ YAHOO.widget.Overlay.windowResizeEvent.fire();
+ }
+};
+
+/**
+* A boolean that indicated whether the window resize and scroll events have already been subscribed to.
+* @property YAHOO.widget.Overlay._initialized
+* @private
+* @type Boolean
+*/
+YAHOO.widget.Overlay._initialized = null;
+
+if (YAHOO.widget.Overlay._initialized === null) {
+ YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
+ YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
+
+ YAHOO.widget.Overlay._initialized = true;
+}
+
+/**
+* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget
+* @namespace YAHOO.widget
+* @class OverlayManager
+* @constructor
+* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
+*/
+YAHOO.widget.OverlayManager = function(userConfig) {
+ this.init(userConfig);
+};
+
+/**
+* The CSS class representing a focused Overlay
+* @property YAHOO.widget.OverlayManager.CSS_FOCUSED
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
+
+YAHOO.widget.OverlayManager.prototype = {
+ /**
+ * The class's constructor function
+ * @property contructor
+ * @type Function
+ */
+ constructor : YAHOO.widget.OverlayManager,
+
+ /**
+ * The array of Overlays that are currently registered
+ * @property overlays
+ * @type YAHOO.widget.Overlay[]
+ */
+ overlays : null,
+
+ /**
+ * Initializes the default configuration of the OverlayManager
+ * @method initDefaultConfig
+ */
+ initDefaultConfig : function() {
+ /**
+ * The collection of registered Overlays in use by the OverlayManager
+ * @config overlays
+ * @type YAHOO.widget.Overlay[]
+ * @default null
+ */
+ this.cfg.addProperty("overlays", { suppressEvent:true } );
+
+ /**
+ * The default DOM event that should be used to focus an Overlay
+ * @config focusevent
+ * @type String
+ * @default "mousedown"
+ */
+ this.cfg.addProperty("focusevent", { value:"mousedown" } );
+ },
+
+ /**
+ * Initializes the OverlayManager
+ * @method init
+ * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager.
+ * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
+ */
+ init : function(userConfig) {
+ /**
+ * The OverlayManager's Config object used for monitoring configuration properties.
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+ this.cfg.fireQueue();
+
+ /**
+ * The currently activated Overlay
+ * @property activeOverlay
+ * @private
+ * @type YAHOO.widget.Overlay
+ */
+ var activeOverlay = null;
+
+ /**
+ * Returns the currently focused Overlay
+ * @method getActive
+ * @return {YAHOO.widget.Overlay} The currently focused Overlay
+ */
+ this.getActive = function() {
+ return activeOverlay;
+ };
+
+ /**
+ * Focuses the specified Overlay
+ * @method focus
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to focus
+ * @param {String} overlay The id of the Overlay to focus
+ */
+ this.focus = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ this.blurAll();
+ activeOverlay = o;
+ YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ this.overlays.sort(this.compareZIndexDesc);
+ var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
+ if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
+ activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2));
+ }
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ };
+
+ /**
+ * Removes the specified Overlay from the manager
+ * @method remove
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to remove
+ * @param {String} overlay The id of the Overlay to remove
+ */
+ this.remove = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
+ o.cfg.setProperty("zIndex", -1000, true);
+ this.overlays.sort(this.compareZIndexDesc);
+ this.overlays = this.overlays.slice(0, this.overlays.length-1);
+ o.cfg.setProperty("zIndex", originalZ, true);
+
+ o.cfg.setProperty("manager", null);
+ o.focusEvent = null;
+ o.blurEvent = null;
+ o.focus = null;
+ o.blur = null;
+ }
+ };
+
+ /**
+ * Removes focus from all registered Overlays in the manager
+ * @method blurAll
+ */
+ this.blurAll = function() {
+ activeOverlay = null;
+ for (var o=0;o 0) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Attempts to locate an Overlay by instance or ID.
+ * @method find
+ * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager
+ * @param {String} overlay An Overlay id to locate within the manager
+ * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located.
+ */
+ find : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ for (var o=0;o zIndex2) {
+ return -1;
+ } else if (zIndex1 < zIndex2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ },
+
+ /**
+ * Shows all Overlays in the manager.
+ * @method showAll
+ */
+ showAll : function() {
+ for (var o=0;oOR
+* @param {HTMLElement} el The element representing the Tooltip
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Tooltip = function(el, userConfig) {
+ YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay);
+
+/**
+* Constant representing the Tooltip CSS class
+* @property YAHOO.widget.Tooltip.CSS_TOOLTIP
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Tooltip.CSS_TOOLTIP = "tt";
+
+/**
+* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well.
+* @method init
+* @param {String} el The element ID representing the Tooltip OR
+* @param {HTMLElement} el The element representing the Tooltip
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details.
+*/
+YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) {
+ if (document.readyState && document.readyState != "complete") {
+ var deferredInit = function() {
+ this.init(el, userConfig);
+ };
+ YAHOO.util.Event.addListener(window, "load", deferredInit, this, true);
+ } else {
+ YAHOO.widget.Tooltip.superclass.init.call(this, el);
+
+ this.beforeInitEvent.fire(YAHOO.widget.Tooltip);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.cfg.queueProperty("visible",false);
+ this.cfg.queueProperty("constraintoviewport",true);
+
+ this.setBody("");
+ this.render(this.cfg.getProperty("container"));
+
+ this.initEvent.fire(YAHOO.widget.Tooltip);
+ }
+};
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);
+
+ /**
+ * Specifies whether the Tooltip should be kept from overlapping its context element.
+ * @config preventoverlap
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } );
+
+ /**
+ * The number of milliseconds to wait before showing a Tooltip on mouseover.
+ * @config showdelay
+ * @type Number
+ * @default 200
+ */
+ this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } );
+
+ /**
+ * The number of milliseconds to wait before automatically dismissing a Tooltip after the mouse has been resting on the context element.
+ * @config autodismissdelay
+ * @type Number
+ * @default 5000
+ */
+ this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } );
+
+ /**
+ * The number of milliseconds to wait before hiding a Tooltip on mouseover.
+ * @config hidedelay
+ * @type Number
+ * @default 250
+ */
+ this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } );
+
+ /**
+ * Specifies the Tooltip's text.
+ * @config text
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } );
+
+ /**
+ * Specifies the container element that the Tooltip's markup should be rendered into.
+ * @config container
+ * @type HTMLElement/String
+ * @default document.body
+ */
+ this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } );
+
+ /**
+ * Specifies the element or elements that the Tooltip should be anchored to on mouseover.
+ * @config context
+ * @type HTMLElement[]/String[]
+ * @default null
+ */
+
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "text" property is changed.
+* @method configText
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) {
+ var text = args[0];
+ if (text) {
+ this.setBody(text);
+ }
+};
+
+/**
+* The default event handler fired when the "container" property is changed.
+* @method configContainer
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) {
+ var container = args[0];
+ if (typeof container == 'string') {
+ this.cfg.setProperty("container", document.getElementById(container), true);
+ }
+};
+
+/**
+* The default event handler fired when the "context" property is changed.
+* @method configContext
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) {
+ var context = args[0];
+ if (context) {
+
+ // Normalize parameter into an array
+ if (! (context instanceof Array)) {
+ if (typeof context == "string") {
+ this.cfg.setProperty("context", [document.getElementById(context)], true);
+ } else { // Assuming this is an element
+ this.cfg.setProperty("context", [context], true);
+ }
+ context = this.cfg.getProperty("context");
+ }
+
+
+ // Remove any existing mouseover/mouseout listeners
+ if (this._context) {
+ for (var c=0;cOR
+* @param {HTMLElement} el The element representing the Panel
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details.
+*/
+YAHOO.widget.Panel = function(el, userConfig) {
+ YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay);
+
+/**
+* Constant representing the default CSS class used for a Panel
+* @property YAHOO.widget.Panel.CSS_PANEL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Panel.CSS_PANEL = "panel";
+
+/**
+* Constant representing the default CSS class used for a Panel's wrapping container
+* @property YAHOO.widget.Panel.CSS_PANEL_CONTAINER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "panel-container";
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Panel.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Panel);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL);
+
+ this.buildWrapper();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.beforeRenderEvent.subscribe(function() {
+ var draggable = this.cfg.getProperty("draggable");
+ if (draggable) {
+ if (! this.header) {
+ this.setHeader(" ");
+ }
+ }
+ }, this, true);
+
+ var me = this;
+
+ var doBlur = function() {
+ this.blur();
+ };
+
+ this.showMaskEvent.subscribe(function() {
+ var checkFocusable = function(el) {
+ if ((el.tagName == "A" || el.tagName == "BUTTON" || el.tagName == "SELECT" || el.tagName == "INPUT" || el.tagName == "TEXTAREA") && el.type != "hidden") {
+ if (! YAHOO.util.Dom.isAncestor(me.element, el)) {
+ YAHOO.util.Event.addListener(el, "focus", doBlur, el, true);
+ return true;
+ }
+ } else {
+ return false;
+ }
+ };
+
+ this.focusableElements = YAHOO.util.Dom.getElementsBy(checkFocusable);
+ }, this, true);
+
+ this.hideMaskEvent.subscribe(function() {
+ for (var i=0;iOR
+* @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
+* @return {boolean} Success or failure of the render
+*/
+YAHOO.widget.Panel.prototype.render = function(appendToNode) {
+ return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement);
+};
+
+/**
+* Returns a String representation of the object.
+* @method toString
+* @return {String} The string representation of the Panel.
+*/
+YAHOO.widget.Panel.prototype.toString = function() {
+ return "Panel " + this.id;
+};
+
+/**
+* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
+* @namespace YAHOO.widget
+* @class Dialog
+* @extends YAHOO.widget.Panel
+* @constructor
+* @param {String} el The element ID representing the Dialog OR
+* @param {HTMLElement} el The element representing the Dialog
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
+*/
+YAHOO.widget.Dialog = function(el, userConfig) {
+ YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel);
+
+/**
+* Constant representing the default CSS class used for a Dialog
+* @property YAHOO.widget.Dialog.CSS_DIALOG
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Dialog.CSS_DIALOG = "dialog";
+
+/**
+* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.Dialog.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this);
+
+ /**
+ * The internally maintained callback object for use with the Connection utility
+ * @property callback
+ * @type Object
+ */
+ this.callback = {
+ /**
+ * The function to execute upon success of the Connection submission
+ * @property callback.success
+ * @type Function
+ */
+ success : null,
+ /**
+ * The function to execute upon failure of the Connection submission
+ * @property callback.failure
+ * @type Function
+ */
+ failure : null,
+ /**
+ * The arbitraty argument or arguments to pass to the Connection callback functions
+ * @property callback.argument
+ * @type Object
+ */
+ argument: null
+ };
+
+ // Add form dialog config properties //
+
+ /**
+ * The method to use for posting the Dialog's form. Possible values are "async", "form", and "manual".
+ * @config postmethod
+ * @type String
+ * @default async
+ */
+ this.cfg.addProperty("postmethod", { value:"async", handler:this.configPostMethod, validator:function(val) {
+ if (val != "form" && val != "async" && val != "none" && val != "manual") {
+ return false;
+ } else {
+ return true;
+ }
+ } });
+
+ /**
+ * Object literal(s) defining the buttons for the Dialog's footer.
+ * @config buttons
+ * @type Object[]
+ * @default "none"
+ */
+ this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } );
+};
+
+/**
+* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class.
+* @method initEvents
+*/
+YAHOO.widget.Dialog.prototype.initEvents = function() {
+ YAHOO.widget.Dialog.superclass.initEvents.call(this);
+
+ /**
+ * CustomEvent fired prior to submission
+ * @event beforeSumitEvent
+ */
+ this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit");
+
+ /**
+ * CustomEvent fired after submission
+ * @event submitEvent
+ */
+ this.submitEvent = new YAHOO.util.CustomEvent("submit");
+
+ /**
+ * CustomEvent fired prior to manual submission
+ * @event manualSubmitEvent
+ */
+ this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit");
+
+ /**
+ * CustomEvent fired prior to asynchronous submission
+ * @event asyncSubmitEvent
+ */
+ this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit");
+
+ /**
+ * CustomEvent fired prior to form-based submission
+ * @event formSubmitEvent
+ */
+ this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit");
+
+ /**
+ * CustomEvent fired after cancel
+ * @event cancelEvent
+ */
+ this.cancelEvent = new YAHOO.util.CustomEvent("cancel");
+};
+
+/**
+* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the Dialog OR
+* @param {HTMLElement} el The element representing the Dialog
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
+*/
+YAHOO.widget.Dialog.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Dialog);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG);
+
+ this.cfg.setProperty("visible", false);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.showEvent.subscribe(this.focusFirst, this, true);
+ this.beforeHideEvent.subscribe(this.blurButtons, this, true);
+
+ this.beforeRenderEvent.subscribe(function() {
+ var buttonCfg = this.cfg.getProperty("buttons");
+ if (buttonCfg && buttonCfg != "none") {
+ if (! this.footer) {
+ this.setFooter("");
+ }
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.Dialog);
+};
+
+/**
+* Performs the submission of the Dialog form depending on the value of "postmethod" property.
+* @method doSubmit
+*/
+YAHOO.widget.Dialog.prototype.doSubmit = function() {
+ var pm = this.cfg.getProperty("postmethod");
+ switch (pm) {
+ case "async":
+ var method = this.form.getAttribute("method") || 'POST';
+ method = method.toUpperCase();
+ YAHOO.util.Connect.setForm(this.form);
+ var cObj = YAHOO.util.Connect.asyncRequest(method, this.form.getAttribute("action"), this.callback);
+ this.asyncSubmitEvent.fire();
+ break;
+ case "form":
+ this.form.submit();
+ this.formSubmitEvent.fire();
+ break;
+ case "none":
+ case "manual":
+ this.manualSubmitEvent.fire();
+ break;
+ }
+};
+
+/**
+* Prepares the Dialog's internal FORM object, creating one if one is not currently present.
+* @method registerForm
+*/
+YAHOO.widget.Dialog.prototype.registerForm = function() {
+ var form = this.element.getElementsByTagName("FORM")[0];
+
+ if (! form) {
+ var formHTML = "";
+ this.body.innerHTML += formHTML;
+ form = this.element.getElementsByTagName("FORM")[0];
+ }
+
+ this.firstFormElement = function() {
+ for (var f=0;f=0;f-- ) {
+ var el = form.elements[f];
+ if (el.focus && ! el.disabled) {
+ if (el.type && el.type != "hidden") {
+ return el;
+ }
+ }
+ }
+ return null;
+ }();
+
+ this.form = form;
+
+ if (this.cfg.getProperty("modal") && this.form) {
+
+ var me = this;
+
+ var firstElement = this.firstFormElement || this.firstButton;
+ if (firstElement) {
+ this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} );
+ this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true);
+ this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true);
+ }
+
+ var lastElement = this.lastButton || this.lastFormElement;
+ if (lastElement) {
+ this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} );
+ this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true);
+ this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true);
+ }
+ }
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Dialog.
+* @method configClose
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Dialog.prototype.configClose = function(type, args, obj) {
+ var val = args[0];
+
+ var doCancel = function(e, obj) {
+ obj.cancel();
+ };
+
+ if (val) {
+ if (! this.close) {
+ this.close = document.createElement("DIV");
+ YAHOO.util.Dom.addClass(this.close, "close");
+
+ if (this.isSecure) {
+ YAHOO.util.Dom.addClass(this.close, "secure");
+ } else {
+ YAHOO.util.Dom.addClass(this.close, "nonsecure");
+ }
+
+ this.close.innerHTML = " ";
+ this.innerElement.appendChild(this.close);
+ YAHOO.util.Event.addListener(this.close, "click", doCancel, this);
+ } else {
+ this.close.style.display = "block";
+ }
+ } else {
+ if (this.close) {
+ this.close.style.display = "none";
+ }
+ }
+};
+
+/**
+* The default event handler for the "buttons" configuration property
+* @method configButtons
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) {
+ var buttons = args[0];
+ if (buttons != "none") {
+ this.buttonSpan = null;
+ this.buttonSpan = document.createElement("SPAN");
+ this.buttonSpan.className = "button-group";
+
+ for (var b=0;bOR
+* @param {HTMLElement} el The element representing the SimpleDialog
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
+*/
+YAHOO.widget.SimpleDialog = function(el, userConfig) {
+ YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog);
+
+/**
+* Constant for the standard network icon for a blocking action
+* @property YAHOO.widget.SimpleDialog.ICON_BLOCK
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_BLOCK = "nt/ic/ut/bsc/blck16_1.gif";
+
+/**
+* Constant for the standard network icon for alarm
+* @property YAHOO.widget.SimpleDialog.ICON_ALARM
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_ALARM = "nt/ic/ut/bsc/alrt16_1.gif";
+
+/**
+* Constant for the standard network icon for help
+* @property YAHOO.widget.SimpleDialog.ICON_HELP
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_HELP = "nt/ic/ut/bsc/hlp16_1.gif";
+
+/**
+* Constant for the standard network icon for info
+* @property YAHOO.widget.SimpleDialog.ICON_INFO
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_INFO = "nt/ic/ut/bsc/info16_1.gif";
+
+/**
+* Constant for the standard network icon for warn
+* @property YAHOO.widget.SimpleDialog.ICON_WARN
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_WARN = "nt/ic/ut/bsc/warn16_1.gif";
+
+/**
+* Constant for the standard network icon for a tip
+* @property YAHOO.widget.SimpleDialog.ICON_TIP
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.ICON_TIP = "nt/ic/ut/bsc/tip16_1.gif";
+
+/**
+* Constant representing the default CSS class used for a SimpleDialog
+* @property YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "simple-dialog";
+
+/**
+* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() {
+ YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this);
+
+ // Add dialog config properties //
+
+ /**
+ * Sets the informational icon for the SimpleDialog
+ * @config icon
+ * @type String
+ * @default "none"
+ */
+ this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } );
+
+ /**
+ * Sets the text for the SimpleDialog
+ * @config text
+ * @type String
+ * @default ""
+ */
+ this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } );
+};
+
+
+/**
+* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the SimpleDialog OR
+* @param {HTMLElement} el The element representing the SimpleDialog
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
+*/
+YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) {
+ YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG);
+
+ this.cfg.queueProperty("postmethod", "manual");
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.beforeRenderEvent.subscribe(function() {
+ if (! this.body) {
+ this.setBody("");
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.SimpleDialog);
+
+};
+/**
+* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field.
+* @method registerForm
+*/
+YAHOO.widget.SimpleDialog.prototype.registerForm = function() {
+ YAHOO.widget.SimpleDialog.superclass.registerForm.call(this);
+ this.form.innerHTML += " ";
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Fired when the "icon" property is set.
+* @method configIcon
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) {
+ var icon = args[0];
+ if (icon && icon != "none") {
+ var iconHTML = " ";
+ this.body.innerHTML = iconHTML + this.body.innerHTML;
+ }
+};
+
+/**
+* Fired when the "text" property is set.
+* @method configText
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) {
+ var text = args[0];
+ if (text) {
+ this.setBody(text);
+ this.cfg.refireEvent("icon");
+ }
+};
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Returns a string representation of the object.
+* @method toString
+* @return {String} The string representation of the SimpleDialog
+*/
+YAHOO.widget.SimpleDialog.prototype.toString = function() {
+ return "SimpleDialog " + this.id;
+};
+
+/**
+* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden.
+* @namespace YAHOO.widget
+* @class ContainerEffect
+* @constructor
+* @param {YAHOO.widget.Overlay} overlay The Overlay that the animation should be associated with
+* @param {Object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
+* @param {Object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
+* @param {HTMLElement} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element.
+* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion.
+*/
+YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) {
+ if (! animClass) {
+ animClass = YAHOO.util.Anim;
+ }
+
+ /**
+ * The overlay to animate
+ * @property overlay
+ * @type YAHOO.widget.Overlay
+ */
+ this.overlay = overlay;
+ /**
+ * The animation attributes to use when transitioning into view
+ * @property attrIn
+ * @type Object
+ */
+ this.attrIn = attrIn;
+ /**
+ * The animation attributes to use when transitioning out of view
+ * @property attrOut
+ * @type Object
+ */
+ this.attrOut = attrOut;
+ /**
+ * The target element to be animated
+ * @property targetElement
+ * @type HTMLElement
+ */
+ this.targetElement = targetElement || overlay.element;
+ /**
+ * The animation class to use for animating the overlay
+ * @property animClass
+ * @type class
+ */
+ this.animClass = animClass;
+};
+
+/**
+* Initializes the animation classes and events.
+* @method init
+*/
+YAHOO.widget.ContainerEffect.prototype.init = function() {
+ this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn");
+ this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut");
+
+ this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete");
+ this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete");
+
+ this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method);
+ this.animIn.onStart.subscribe(this.handleStartAnimateIn, this);
+ this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this);
+ this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this);
+
+ this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method);
+ this.animOut.onStart.subscribe(this.handleStartAnimateOut, this);
+ this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this);
+ this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this);
+};
+
+/**
+* Triggers the in-animation.
+* @method animateIn
+*/
+YAHOO.widget.ContainerEffect.prototype.animateIn = function() {
+ this.beforeAnimateInEvent.fire();
+ this.animIn.animate();
+};
+
+/**
+* Triggers the out-animation.
+* @method animateOut
+*/
+YAHOO.widget.ContainerEffect.prototype.animateOut = function() {
+ this.beforeAnimateOutEvent.fire();
+ this.animOut.animate();
+};
+
+/**
+* The default onStart handler for the in-animation.
+* @method handleStartAnimateIn
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { };
+/**
+* The default onTween handler for the in-animation.
+* @method handleTweenAnimateIn
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { };
+/**
+* The default onComplete handler for the in-animation.
+* @method handleCompleteAnimateIn
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { };
+
+/**
+* The default onStart handler for the out-animation.
+* @method handleStartAnimateOut
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { };
+/**
+* The default onTween handler for the out-animation.
+* @method handleTweenAnimateOut
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { };
+/**
+* The default onComplete handler for the out-animation.
+* @method handleCompleteAnimateOut
+* @param {String} type The CustomEvent type
+* @param {Object[]} args The CustomEvent arguments
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { };
+
+/**
+* Returns a string representation of the object.
+* @method toString
+* @return {String} The string representation of the ContainerEffect
+*/
+YAHOO.widget.ContainerEffect.prototype.toString = function() {
+ var output = "ContainerEffect";
+ if (this.overlay) {
+ output += " [" + this.overlay.toString() + "]";
+ }
+ return output;
+};
+
+/**
+* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out.
+* @method FADE
+* @static
+* @param {Overlay} overlay The Overlay object to animate
+* @param {Number} dur The duration of the animation
+* @return {ContainerEffect} The configured ContainerEffect object
+*/
+YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) {
+ var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element );
+
+ fade.handleStartAnimateIn = function(type,args,obj) {
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
+
+ if (! obj.overlay.underlay) {
+ obj.overlay.cfg.refireEvent("underlay");
+ }
+
+ if (obj.overlay.underlay) {
+ obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity");
+ obj.overlay.underlay.style.filter = null;
+ }
+
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0);
+ };
+
+ fade.handleCompleteAnimateIn = function(type,args,obj) {
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
+
+ if (obj.overlay.element.style.filter) {
+ obj.overlay.element.style.filter = null;
+ }
+
+ if (obj.overlay.underlay) {
+ YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity);
+ }
+
+ obj.overlay.cfg.refireEvent("iframe");
+ obj.animateInCompleteEvent.fire();
+ };
+
+ fade.handleStartAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
+
+ if (obj.overlay.underlay) {
+ obj.overlay.underlay.style.filter = null;
+ }
+ };
+
+ fade.handleCompleteAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
+ if (obj.overlay.element.style.filter) {
+ obj.overlay.element.style.filter = null;
+ }
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1);
+
+ obj.overlay.cfg.refireEvent("iframe");
+
+ obj.animateOutCompleteEvent.fire();
+ };
+
+ fade.init();
+ return fade;
+};
+
+
+/**
+* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out.
+* @method SLIDE
+* @static
+* @param {Overlay} overlay The Overlay object to animate
+* @param {Number} dur The duration of the animation
+* @return {ContainerEffect} The configured ContainerEffect object
+*/
+YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) {
+ var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element);
+ var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element);
+
+ var clientWidth = YAHOO.util.Dom.getClientWidth();
+ var offsetWidth = overlay.element.offsetWidth;
+
+ var slide = new YAHOO.widget.ContainerEffect(overlay, {
+ attributes:{ points: { to:[x, y] } },
+ duration:dur,
+ method:YAHOO.util.Easing.easeIn
+ },
+ {
+ attributes:{ points: { to:[(clientWidth+25), y] } },
+ duration:dur,
+ method:YAHOO.util.Easing.easeOut
+ },
+ overlay.element,
+ YAHOO.util.Motion);
+
+
+ slide.handleStartAnimateIn = function(type,args,obj) {
+ obj.overlay.element.style.left = (-25-offsetWidth) + "px";
+ obj.overlay.element.style.top = y + "px";
+ };
+
+ slide.handleTweenAnimateIn = function(type, args, obj) {
+
+
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var currentX = pos[0];
+ var currentY = pos[1];
+
+ if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) {
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
+ }
+
+ obj.overlay.cfg.setProperty("xy", [currentX,currentY], true);
+ obj.overlay.cfg.refireEvent("iframe");
+ };
+
+ slide.handleCompleteAnimateIn = function(type, args, obj) {
+ obj.overlay.cfg.setProperty("xy", [x,y], true);
+ obj.startX = x;
+ obj.startY = y;
+ obj.overlay.cfg.refireEvent("iframe");
+ obj.animateInCompleteEvent.fire();
+ };
+
+ slide.handleStartAnimateOut = function(type, args, obj) {
+ var vw = YAHOO.util.Dom.getViewportWidth();
+
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var yso = pos[1];
+
+ var currentTo = obj.animOut.attributes.points.to;
+ obj.animOut.attributes.points.to = [(vw+25), yso];
+ };
+
+ slide.handleTweenAnimateOut = function(type, args, obj) {
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var xto = pos[0];
+ var yto = pos[1];
+
+ obj.overlay.cfg.setProperty("xy", [xto,yto], true);
+ obj.overlay.cfg.refireEvent("iframe");
+ };
+
+ slide.handleCompleteAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
+
+ obj.overlay.cfg.setProperty("xy", [x,y]);
+ obj.animateOutCompleteEvent.fire();
+ };
+
+ slide.init();
+ return slide;
};
\ No newline at end of file
diff --git a/lib/yui/container/container_core-debug.js b/lib/yui/container/container_core-debug.js
index 2b256079cc..d0c8a5b459 100755
--- a/lib/yui/container/container_core-debug.js
+++ b/lib/yui/container/container_core-debug.js
@@ -1,2943 +1,2942 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version 0.12.1
-*/
-
-/**
-* Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
-* @namespace YAHOO.util
-* @class Config
-* @constructor
-* @param {Object} owner The owner Object to which this Config Object belongs
-*/
-YAHOO.util.Config = function(owner) {
- if (owner) {
- this.init(owner);
- } else {
- YAHOO.log("No owner specified for Config object", "error");
- }
-};
-
-YAHOO.util.Config.prototype = {
-
- /**
- * Object reference to the owner of this Config Object
- * @property owner
- * @type Object
- */
- owner : null,
-
- /**
- * Boolean flag that specifies whether a queue is currently being executed
- * @property queueInProgress
- * @type Boolean
- */
- queueInProgress : false,
-
-
- /**
- * Validates that the value passed in is a Boolean.
- * @method checkBoolean
- * @param {Object} val The value to validate
- * @return {Boolean} true, if the value is valid
- */
- checkBoolean: function(val) {
- if (typeof val == 'boolean') {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * Validates that the value passed in is a number.
- * @method checkNumber
- * @param {Object} val The value to validate
- * @return {Boolean} true, if the value is valid
- */
- checkNumber: function(val) {
- if (isNaN(val)) {
- return false;
- } else {
- return true;
- }
- }
-};
-
-
-/**
-* Initializes the configuration Object and all of its local members.
-* @method init
-* @param {Object} owner The owner Object to which this Config Object belongs
-*/
-YAHOO.util.Config.prototype.init = function(owner) {
-
- this.owner = owner;
-
- /**
- * Object reference to the owner of this Config Object
- * @event configChangedEvent
- */
- this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
- this.queueInProgress = false;
-
- /* Private Members */
-
- /**
- * Maintains the local collection of configuration property objects and their specified values
- * @property config
- * @private
- * @type Object
- */
- var config = {};
-
- /**
- * Maintains the local collection of configuration property objects as they were initially applied.
- * This object is used when resetting a property.
- * @property initialConfig
- * @private
- * @type Object
- */
- var initialConfig = {};
-
- /**
- * Maintains the local, normalized CustomEvent queue
- * @property eventQueue
- * @private
- * @type Object
- */
- var eventQueue = [];
-
- /**
- * Fires a configuration property event using the specified value.
- * @method fireEvent
- * @private
- * @param {String} key The configuration property's name
- * @param {value} Object The value of the correct type for the property
- */
- var fireEvent = function( key, value ) {
- YAHOO.log("Firing Config event: " + key + "=" + value, "info");
-
- key = key.toLowerCase();
-
- var property = config[key];
-
- if (typeof property != 'undefined' && property.event) {
- property.event.fire(value);
- }
- };
- /* End Private Members */
-
- /**
- * Adds a property to the Config Object's private config hash.
- * @method addProperty
- * @param {String} key The configuration property's name
- * @param {Object} propertyObject The Object containing all of this property's arguments
- */
- this.addProperty = function( key, propertyObject ) {
- key = key.toLowerCase();
-
- YAHOO.log("Added property: " + key, "info");
-
- config[key] = propertyObject;
-
- propertyObject.event = new YAHOO.util.CustomEvent(key);
- propertyObject.key = key;
-
- if (propertyObject.handler) {
- propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
- }
-
- this.setProperty(key, propertyObject.value, true);
-
- if (! propertyObject.suppressEvent) {
- this.queueProperty(key, propertyObject.value);
- }
- };
-
- /**
- * Returns a key-value configuration map of the values currently set in the Config Object.
- * @method getConfig
- * @return {Object} The current config, represented in a key-value map
- */
- this.getConfig = function() {
- var cfg = {};
-
- for (var prop in config) {
- var property = config[prop];
- if (typeof property != 'undefined' && property.event) {
- cfg[prop] = property.value;
- }
- }
-
- return cfg;
- };
-
- /**
- * Returns the value of specified property.
- * @method getProperty
- * @param {String} key The name of the property
- * @return {Object} The value of the specified property
- */
- this.getProperty = function(key) {
- key = key.toLowerCase();
-
- var property = config[key];
- if (typeof property != 'undefined' && property.event) {
- return property.value;
- } else {
- return undefined;
- }
- };
-
- /**
- * Resets the specified property's value to its initial value.
- * @method resetProperty
- * @param {String} key The name of the property
- * @return {Boolean} True is the property was reset, false if not
- */
- this.resetProperty = function(key) {
- key = key.toLowerCase();
-
- var property = config[key];
- if (typeof property != 'undefined' && property.event) {
- if (initialConfig[key] && initialConfig[key] != 'undefined') {
- this.setProperty(key, initialConfig[key]);
- }
- return true;
- } else {
- return false;
- }
- };
-
- /**
- * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
- * @method setProperty
- * @param {String} key The name of the property
- * @param {String} value The value to set the property to
- * @param {Boolean} silent Whether the value should be set silently, without firing the property event.
- * @return {Boolean} True, if the set was successful, false if it failed.
- */
- this.setProperty = function(key, value, silent) {
- key = key.toLowerCase();
-
- YAHOO.log("setProperty: " + key + "=" + value, "info");
-
- if (this.queueInProgress && ! silent) {
- this.queueProperty(key,value); // Currently running through a queue...
- return true;
- } else {
- var property = config[key];
- if (typeof property != 'undefined' && property.event) {
- if (property.validator && ! property.validator(value)) { // validator
- return false;
- } else {
- property.value = value;
- if (! silent) {
- fireEvent(key, value);
- this.configChangedEvent.fire([key, value]);
- }
- return true;
- }
- } else {
- return false;
- }
- }
- };
-
- /**
- * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
- * moved from its current position to the end of the queue.
- * @method queueProperty
- * @param {String} key The name of the property
- * @param {String} value The value to set the property to
- * @return {Boolean} true, if the set was successful, false if it failed.
- */
- this.queueProperty = function(key, value) {
- key = key.toLowerCase();
-
- YAHOO.log("queueProperty: " + key + "=" + value, "info");
-
- var property = config[key];
-
- if (typeof property != 'undefined' && property.event) {
- if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
- return false;
- } else {
-
- if (typeof value != 'undefined') {
- property.value = value;
- } else {
- value = property.value;
- }
-
- var foundDuplicate = false;
-
- for (var i=0;iOR
-* @param {HTMLElement} el The element representing the Module
-* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
-*/
-YAHOO.widget.Module = function(el, userConfig) {
- if (el) {
- this.init(el, userConfig);
- } else {
- YAHOO.log("No element or element ID specified for Module instantiation", "error");
- }
-};
-
-/**
-* Constant representing the prefix path to use for non-secure images
-* @property YAHOO.widget.Module.IMG_ROOT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
-
-/**
-* Constant representing the prefix path to use for securely served images
-* @property YAHOO.widget.Module.IMG_ROOT_SSL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
-
-/**
-* Constant for the default CSS class name that represents a Module
-* @property YAHOO.widget.Module.CSS_MODULE
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_MODULE = "module";
-
-/**
-* Constant representing the module header
-* @property YAHOO.widget.Module.CSS_HEADER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_HEADER = "hd";
-
-/**
-* Constant representing the module body
-* @property YAHOO.widget.Module.CSS_BODY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_BODY = "bd";
-
-/**
-* Constant representing the module footer
-* @property YAHOO.widget.Module.CSS_FOOTER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_FOOTER = "ft";
-
-/**
-* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
-* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";
-
-/**
-* Singleton CustomEvent fired when the font size is changed in the browser.
-* Opera's "zoom" functionality currently does not support text size detection.
-* @event YAHOO.widget.Module.textResizeEvent
-*/
-YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");
-
-YAHOO.widget.Module.prototype = {
- /**
- * The class's constructor function
- * @property contructor
- * @type Function
- */
- constructor : YAHOO.widget.Module,
-
- /**
- * The main module element that contains the header, body, and footer
- * @property element
- * @type HTMLElement
- */
- element : null,
-
- /**
- * The header element, denoted with CSS class "hd"
- * @property header
- * @type HTMLElement
- */
- header : null,
-
- /**
- * The body element, denoted with CSS class "bd"
- * @property body
- * @type HTMLElement
- */
- body : null,
-
- /**
- * The footer element, denoted with CSS class "ft"
- * @property footer
- * @type HTMLElement
- */
- footer : null,
-
- /**
- * The id of the element
- * @property id
- * @type String
- */
- id : null,
-
- /**
- * The String representing the image root
- * @property imageRoot
- * @type String
- */
- imageRoot : YAHOO.widget.Module.IMG_ROOT,
-
- /**
- * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
- * @method initEvents
- */
- initEvents : function() {
-
- /**
- * CustomEvent fired prior to class initalization.
- * @event beforeInitEvent
- * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
- */
- this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
-
- /**
- * CustomEvent fired after class initalization.
- * @event initEvent
- * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
- */
- this.initEvent = new YAHOO.util.CustomEvent("init");
-
- /**
- * CustomEvent fired when the Module is appended to the DOM
- * @event appendEvent
- */
- this.appendEvent = new YAHOO.util.CustomEvent("append");
-
- /**
- * CustomEvent fired before the Module is rendered
- * @event beforeRenderEvent
- */
- this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
-
- /**
- * CustomEvent fired after the Module is rendered
- * @event renderEvent
- */
- this.renderEvent = new YAHOO.util.CustomEvent("render");
-
- /**
- * CustomEvent fired when the header content of the Module is modified
- * @event changeHeaderEvent
- * @param {String/HTMLElement} content String/element representing the new header content
- */
- this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
-
- /**
- * CustomEvent fired when the body content of the Module is modified
- * @event changeBodyEvent
- * @param {String/HTMLElement} content String/element representing the new body content
- */
- this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
-
- /**
- * CustomEvent fired when the footer content of the Module is modified
- * @event changeFooterEvent
- * @param {String/HTMLElement} content String/element representing the new footer content
- */
- this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
-
- /**
- * CustomEvent fired when the content of the Module is modified
- * @event changeContentEvent
- */
- this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
-
- /**
- * CustomEvent fired when the Module is destroyed
- * @event destroyEvent
- */
- this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
-
- /**
- * CustomEvent fired before the Module is shown
- * @event beforeShowEvent
- */
- this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
-
- /**
- * CustomEvent fired after the Module is shown
- * @event showEvent
- */
- this.showEvent = new YAHOO.util.CustomEvent("show");
-
- /**
- * CustomEvent fired before the Module is hidden
- * @event beforeHideEvent
- */
- this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
-
- /**
- * CustomEvent fired after the Module is hidden
- * @event hideEvent
- */
- this.hideEvent = new YAHOO.util.CustomEvent("hide");
- },
-
- /**
- * String representing the current user-agent platform
- * @property platform
- * @type String
- */
- platform : function() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
- return "windows";
- } else if (ua.indexOf("macintosh") != -1) {
- return "mac";
- } else {
- return false;
- }
- }(),
-
- /**
- * String representing the current user-agent browser
- * @property browser
- * @type String
- */
- browser : function() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
- return 'opera';
- } else if (ua.indexOf('msie 7')!=-1) { // IE7
- return 'ie7';
- } else if (ua.indexOf('msie') !=-1) { // IE
- return 'ie';
- } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
- return 'safari';
- } else if (ua.indexOf('gecko') != -1) { // Gecko
- return 'gecko';
- } else {
- return false;
- }
- }(),
-
- /**
- * Boolean representing whether or not the current browsing context is secure (https)
- * @property isSecure
- * @type Boolean
- */
- isSecure : function() {
- if (window.location.href.toLowerCase().indexOf("https") === 0) {
- return true;
- } else {
- return false;
- }
- }(),
-
- /**
- * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
- */
- initDefaultConfig : function() {
- // Add properties //
-
- /**
- * Specifies whether the Module is visible on the page.
- * @config visible
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
-
- /**
- * Object or array of objects representing the ContainerEffect classes that are active for animating the container.
- * @config effect
- * @type Object
- * @default null
- */
- this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
-
- /**
- * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document
- * @config monitorresize
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
- },
-
- /**
- * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
- * @method init
- * @param {String} el The element ID representing the Module OR
- * @param {HTMLElement} el The element representing the Module
- * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
- */
- init : function(el, userConfig) {
-
- this.initEvents();
-
- this.beforeInitEvent.fire(YAHOO.widget.Module);
-
- /**
- * The Module's Config object used for monitoring configuration properties.
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- if (this.isSecure) {
- this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
- }
-
- if (typeof el == "string") {
- var elId = el;
-
- el = document.getElementById(el);
- if (! el) {
- el = document.createElement("DIV");
- el.id = elId;
- }
- }
-
- this.element = el;
-
- if (el.id) {
- this.id = el.id;
- }
-
- var childNodes = this.element.childNodes;
-
- if (childNodes) {
- for (var i=0;iOR
- * @param {HTMLElement} headerContent The HTMLElement to append to the header
- */
- setHeader : function(headerContent) {
- if (! this.header) {
- this.header = document.createElement("DIV");
- this.header.className = YAHOO.widget.Module.CSS_HEADER;
- }
-
- if (typeof headerContent == "string") {
- this.header.innerHTML = headerContent;
- } else {
- this.header.innerHTML = "";
- this.header.appendChild(headerContent);
- }
-
- this.changeHeaderEvent.fire(headerContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the header. If no header is present, one will be automatically created.
- * @method appendToHeader
- * @param {HTMLElement} element The element to append to the header
- */
- appendToHeader : function(element) {
- if (! this.header) {
- this.header = document.createElement("DIV");
- this.header.className = YAHOO.widget.Module.CSS_HEADER;
- }
-
- this.header.appendChild(element);
- this.changeHeaderEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
- * @method setBody
- * @param {String} bodyContent The HTML used to set the body OR
- * @param {HTMLElement} bodyContent The HTMLElement to append to the body
- */
- setBody : function(bodyContent) {
- if (! this.body) {
- this.body = document.createElement("DIV");
- this.body.className = YAHOO.widget.Module.CSS_BODY;
- }
-
- if (typeof bodyContent == "string")
- {
- this.body.innerHTML = bodyContent;
- } else {
- this.body.innerHTML = "";
- this.body.appendChild(bodyContent);
- }
-
- this.changeBodyEvent.fire(bodyContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the body. If no body is present, one will be automatically created.
- * @method appendToBody
- * @param {HTMLElement} element The element to append to the body
- */
- appendToBody : function(element) {
- if (! this.body) {
- this.body = document.createElement("DIV");
- this.body.className = YAHOO.widget.Module.CSS_BODY;
- }
-
- this.body.appendChild(element);
- this.changeBodyEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
- * @method setFooter
- * @param {String} footerContent The HTML used to set the footer OR
- * @param {HTMLElement} footerContent The HTMLElement to append to the footer
- */
- setFooter : function(footerContent) {
- if (! this.footer) {
- this.footer = document.createElement("DIV");
- this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
- }
-
- if (typeof footerContent == "string") {
- this.footer.innerHTML = footerContent;
- } else {
- this.footer.innerHTML = "";
- this.footer.appendChild(footerContent);
- }
-
- this.changeFooterEvent.fire(footerContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the footer. If no footer is present, one will be automatically created.
- * @method appendToFooter
- * @param {HTMLElement} element The element to append to the footer
- */
- appendToFooter : function(element) {
- if (! this.footer) {
- this.footer = document.createElement("DIV");
- this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
- }
-
- this.footer.appendChild(element);
- this.changeFooterEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
- * @method render
- * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering OR
- * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
- * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
- * @return {Boolean} Success or failure of the render
- */
- render : function(appendToNode, moduleElement) {
- this.beforeRenderEvent.fire();
-
- if (! moduleElement) {
- moduleElement = this.element;
- }
-
- var me = this;
- var appendTo = function(element) {
- if (typeof element == "string") {
- element = document.getElementById(element);
- }
-
- if (element) {
- element.appendChild(me.element);
- me.appendEvent.fire();
- }
- };
-
- if (appendToNode) {
- appendTo(appendToNode);
- } else { // No node was passed in. If the element is not pre-marked up, this fails
- if (! YAHOO.util.Dom.inDocument(this.element)) {
- YAHOO.log("Render failed. Must specify appendTo node if Module isn't already in the DOM.", "error");
- return false;
- }
- }
-
- // Need to get everything into the DOM if it isn't already
-
- if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
- // There is a header, but it's not in the DOM yet... need to add it
- var firstChild = moduleElement.firstChild;
- if (firstChild) { // Insert before first child if exists
- moduleElement.insertBefore(this.header, firstChild);
- } else { // Append to empty body because there are no children
- moduleElement.appendChild(this.header);
- }
- }
-
- if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
- // There is a body, but it's not in the DOM yet... need to add it
- if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
- moduleElement.insertBefore(this.body, this.footer);
- } else { // Append to element because there is no footer
- moduleElement.appendChild(this.body);
- }
- }
-
- if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
- // There is a footer, but it's not in the DOM yet... need to add it
- moduleElement.appendChild(this.footer);
- }
-
- this.renderEvent.fire();
- return true;
- },
-
- /**
- * Removes the Module element from the DOM and sets all child elements to null.
- * @method destroy
- */
- destroy : function() {
- var parent;
-
- if (this.element) {
- YAHOO.util.Event.purgeElement(this.element, true);
- parent = this.element.parentNode;
- }
- if (parent) {
- parent.removeChild(this.element);
- }
-
- this.element = null;
- this.header = null;
- this.body = null;
- this.footer = null;
-
- for (var e in this) {
- if (e instanceof YAHOO.util.CustomEvent) {
- e.unsubscribeAll();
- }
- }
-
- YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this);
-
- this.destroyEvent.fire();
- },
-
- /**
- * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
- * @method show
- */
- show : function() {
- this.cfg.setProperty("visible", true);
- },
-
- /**
- * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
- * @method hide
- */
- hide : function() {
- this.cfg.setProperty("visible", false);
- },
-
- // BUILT-IN EVENT HANDLERS FOR MODULE //
-
- /**
- * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
- * This method is responsible for firing showEvent and hideEvent.
- * @param {String} type The CustomEvent type (usually the property name)
- * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
- * @method configVisible
- */
- configVisible : function(type, args, obj) {
- var visible = args[0];
- if (visible) {
- this.beforeShowEvent.fire();
- YAHOO.util.Dom.setStyle(this.element, "display", "block");
- this.showEvent.fire();
- } else {
- this.beforeHideEvent.fire();
- YAHOO.util.Dom.setStyle(this.element, "display", "none");
- this.hideEvent.fire();
- }
- },
-
- /**
- * Default event handler for the "monitorresize" configuration property
- * @param {String} type The CustomEvent type (usually the property name)
- * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
- * @method configMonitorResize
- */
- configMonitorResize : function(type, args, obj) {
- var monitor = args[0];
- if (monitor) {
- this.initResizeMonitor();
- } else {
- YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize);
- this.resizeMonitor = null;
- }
- }
-};
-
-/**
-* Returns a String representation of the Object.
-* @method toString
-* @return {String} The string representation of the Module
-*/
-YAHOO.widget.Module.prototype.toString = function() {
- return "Module " + this.id;
-};
-
-/**
-* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
-* @namespace YAHOO.widget
-* @class Overlay
-* @extends YAHOO.widget.Module
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details.
-* @constructor
-*/
-YAHOO.widget.Overlay = function(el, userConfig) {
- YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
-
-/**
-* The URL that will be placed in the iframe
-* @property YAHOO.widget.Overlay.IFRAME_SRC
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;";
-
-/**
-* Constant representing the top left corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.TOP_LEFT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.TOP_LEFT = "tl";
-
-/**
-* Constant representing the top right corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.TOP_RIGHT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.TOP_RIGHT = "tr";
-
-/**
-* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.BOTTOM_LEFT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
-
-/**
-* Constant representing the bottom right corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.BOTTOM_RIGHT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
-
-/**
-* Constant representing the default CSS class used for an Overlay
-* @property YAHOO.widget.Overlay.CSS_OVERLAY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
-
-/**
-* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
-*/
-YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
- YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.Overlay);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- if (this.platform == "mac" && this.browser == "gecko") {
- if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
- this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
- }
- if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
- this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
- }
- }
-
- this.initEvent.fire(YAHOO.widget.Overlay);
-
-};
-
-/**
-* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
-* @method initEvents
-*/
-YAHOO.widget.Overlay.prototype.initEvents = function() {
- YAHOO.widget.Overlay.superclass.initEvents.call(this);
-
- /**
- * CustomEvent fired before the Overlay is moved.
- * @event beforeMoveEvent
- * @param {Number} x x coordinate
- * @param {Number} y y coordinate
- */
- this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
-
- /**
- * CustomEvent fired after the Overlay is moved.
- * @event moveEvent
- * @param {Number} x x coordinate
- * @param {Number} y y coordinate
- */
- this.moveEvent = new YAHOO.util.CustomEvent("move", this);
-};
-
-/**
-* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
- YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
-
- // Add overlay config properties //
-
- /**
- * The absolute x-coordinate position of the Overlay
- * @config x
- * @type Number
- * @default null
- */
- this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * The absolute y-coordinate position of the Overlay
- * @config y
- * @type Number
- * @default null
- */
- this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * An array with the absolute x and y positions of the Overlay
- * @config xy
- * @type Number[]
- * @default null
- */
- this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner.
- * @config context
- * @type Array
- * @default null
- */
- this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * True if the Overlay should be anchored to the center of the viewport.
- * @config fixedcenter
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
-
- /**
- * CSS width of the Overlay.
- * @config width
- * @type String
- * @default null
- */
- this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * CSS height of the Overlay.
- * @config height
- * @type String
- * @default null
- */
- this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * CSS z-index of the Overlay.
- * @config zIndex
- * @type Number
- * @default null
- */
- this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
-
- /**
- * True if the Overlay should be prevented from being positioned out of the viewport.
- * @config constraintoviewport
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
-
- /**
- * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below).
- * @config iframe
- * @type Boolean
- * @default true for IE6 and below, false for all others
- */
- this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
-};
-
-/**
-* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
-* @method moveTo
-* @param {Number} x The Overlay's new x position
-* @param {Number} y The Overlay's new y position
-*/
-YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
- this.cfg.setProperty("xy",[x,y]);
-};
-
-/**
-* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
-* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
-* @method hideMacGeckoScrollbars
-*/
-YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
- YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
- YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
-};
-
-/**
-* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
-* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
-* @method showMacGeckoScrollbars
-*/
-YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
- YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
- YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
-* @method configVisible
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
- var visible = args[0];
- var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
-
- if (currentVis == "inherit") {
- var e = this.element.parentNode;
- while (e.nodeType != 9 && e.nodeType != 11) {
- currentVis = YAHOO.util.Dom.getStyle(e, "visibility");
- if (currentVis != "inherit") { break; }
- e = e.parentNode;
- }
- if (currentVis == "inherit") {
- currentVis = "visible";
- }
- }
-
- var effect = this.cfg.getProperty("effect");
-
- var effectInstances = [];
- if (effect) {
- if (effect instanceof Array) {
- for (var i=0;i rightConstraint) {
- x = rightConstraint;
- }
-
- if (y < topConstraint) {
- y = topConstraint;
- } else if (y > bottomConstraint) {
- y = bottomConstraint;
- }
-
- this.cfg.setProperty("x", x, true);
- this.cfg.setProperty("y", y, true);
- this.cfg.setProperty("xy", [x,y], true);
-};
-
-/**
-* Centers the container in the viewport.
-* @method center
-*/
-YAHOO.widget.Overlay.prototype.center = function() {
- var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
- var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
-
- var viewPortWidth = YAHOO.util.Dom.getClientWidth();
- var viewPortHeight = YAHOO.util.Dom.getClientHeight();
-
- var elementWidth = this.element.offsetWidth;
- var elementHeight = this.element.offsetHeight;
-
- var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
- var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
-
- this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
-
- this.cfg.refireEvent("iframe");
-};
-
-/**
-* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
-* @method syncPosition
-*/
-YAHOO.widget.Overlay.prototype.syncPosition = function() {
- var pos = YAHOO.util.Dom.getXY(this.element);
- this.cfg.setProperty("x", pos[0], true);
- this.cfg.setProperty("y", pos[1], true);
- this.cfg.setProperty("xy", pos, true);
-};
-
-/**
-* Event handler fired when the resize monitor element is resized.
-* @method onDomResize
-* @param {DOMEvent} e The resize DOM event
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
- YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
- var me = this;
- setTimeout(function() {
- me.syncPosition();
- me.cfg.refireEvent("iframe");
- me.cfg.refireEvent("context");
- }, 0);
-};
-
-/**
-* Removes the Overlay element from the DOM and sets all child elements to null.
-* @method destroy
-*/
-YAHOO.widget.Overlay.prototype.destroy = function() {
- if (this.iframe) {
- this.iframe.parentNode.removeChild(this.iframe);
- }
-
- this.iframe = null;
-
- YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
- YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
-
- YAHOO.widget.Overlay.superclass.destroy.call(this);
-};
-
-/**
-* Returns a String representation of the object.
-* @method toString
-* @return {String} The string representation of the Overlay.
-*/
-YAHOO.widget.Overlay.prototype.toString = function() {
- return "Overlay " + this.id;
-};
-
-/**
-* A singleton CustomEvent used for reacting to the DOM event for window scroll
-* @event YAHOO.widget.Overlay.windowScrollEvent
-*/
-YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
-
-/**
-* A singleton CustomEvent used for reacting to the DOM event for window resize
-* @event YAHOO.widget.Overlay.windowResizeEvent
-*/
-YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
-
-/**
-* The DOM event handler used to fire the CustomEvent for window scroll
-* @method YAHOO.widget.Overlay.windowScrollHandler
-* @static
-* @param {DOMEvent} e The DOM scroll event
-*/
-YAHOO.widget.Overlay.windowScrollHandler = function(e) {
- if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
- if (! window.scrollEnd) {
- window.scrollEnd = -1;
- }
- clearTimeout(window.scrollEnd);
- window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1);
- } else {
- YAHOO.widget.Overlay.windowScrollEvent.fire();
- }
-};
-
-/**
-* The DOM event handler used to fire the CustomEvent for window resize
-* @method YAHOO.widget.Overlay.windowResizeHandler
-* @static
-* @param {DOMEvent} e The DOM resize event
-*/
-YAHOO.widget.Overlay.windowResizeHandler = function(e) {
- if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
- if (! window.resizeEnd) {
- window.resizeEnd = -1;
- }
- clearTimeout(window.resizeEnd);
- window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100);
- } else {
- YAHOO.widget.Overlay.windowResizeEvent.fire();
- }
-};
-
-/**
-* A boolean that indicated whether the window resize and scroll events have already been subscribed to.
-* @property YAHOO.widget.Overlay._initialized
-* @private
-* @type Boolean
-*/
-YAHOO.widget.Overlay._initialized = null;
-
-if (YAHOO.widget.Overlay._initialized === null) {
- YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
- YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
-
- YAHOO.widget.Overlay._initialized = true;
-}
-
-/**
-* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget
-* @namespace YAHOO.widget
-* @class OverlayManager
-* @constructor
-* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
-* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
-*/
-YAHOO.widget.OverlayManager = function(userConfig) {
- this.init(userConfig);
-};
-
-/**
-* The CSS class representing a focused Overlay
-* @property YAHOO.widget.OverlayManager.CSS_FOCUSED
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
-
-YAHOO.widget.OverlayManager.prototype = {
- /**
- * The class's constructor function
- * @property contructor
- * @type Function
- */
- constructor : YAHOO.widget.OverlayManager,
-
- /**
- * The array of Overlays that are currently registered
- * @property overlays
- * @type YAHOO.widget.Overlay[]
- */
- overlays : null,
-
- /**
- * Initializes the default configuration of the OverlayManager
- * @method initDefaultConfig
- */
- initDefaultConfig : function() {
- /**
- * The collection of registered Overlays in use by the OverlayManager
- * @config overlays
- * @type YAHOO.widget.Overlay[]
- * @default null
- */
- this.cfg.addProperty("overlays", { suppressEvent:true } );
-
- /**
- * The default DOM event that should be used to focus an Overlay
- * @config focusevent
- * @type String
- * @default "mousedown"
- */
- this.cfg.addProperty("focusevent", { value:"mousedown" } );
- },
-
- /**
- * Initializes the OverlayManager
- * @method init
- * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager.
- * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
- */
- init : function(userConfig) {
- /**
- * The OverlayManager's Config object used for monitoring configuration properties.
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- this.initDefaultConfig();
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
- this.cfg.fireQueue();
-
- /**
- * The currently activated Overlay
- * @property activeOverlay
- * @private
- * @type YAHOO.widget.Overlay
- */
- var activeOverlay = null;
-
- /**
- * Returns the currently focused Overlay
- * @method getActive
- * @return {YAHOO.widget.Overlay} The currently focused Overlay
- */
- this.getActive = function() {
- return activeOverlay;
- };
-
- /**
- * Focuses the specified Overlay
- * @method focus
- * @param {YAHOO.widget.Overlay} overlay The Overlay to focus
- * @param {String} overlay The id of the Overlay to focus
- */
- this.focus = function(overlay) {
- var o = this.find(overlay);
- if (o) {
- this.blurAll();
- activeOverlay = o;
- YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
- this.overlays.sort(this.compareZIndexDesc);
- var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
- if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
- activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2));
- }
- this.overlays.sort(this.compareZIndexDesc);
- }
- };
-
- /**
- * Removes the specified Overlay from the manager
- * @method remove
- * @param {YAHOO.widget.Overlay} overlay The Overlay to remove
- * @param {String} overlay The id of the Overlay to remove
- */
- this.remove = function(overlay) {
- var o = this.find(overlay);
- if (o) {
- var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
- o.cfg.setProperty("zIndex", -1000, true);
- this.overlays.sort(this.compareZIndexDesc);
- this.overlays = this.overlays.slice(0, this.overlays.length-1);
- o.cfg.setProperty("zIndex", originalZ, true);
-
- o.cfg.setProperty("manager", null);
- o.focusEvent = null;
- o.blurEvent = null;
- o.focus = null;
- o.blur = null;
- }
- };
-
- /**
- * Removes focus from all registered Overlays in the manager
- * @method blurAll
- */
- this.blurAll = function() {
- activeOverlay = null;
- for (var o=0;o 0) {
- return true;
- }
- } else {
- return false;
- }
- },
-
- /**
- * Attempts to locate an Overlay by instance or ID.
- * @method find
- * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager
- * @param {String} overlay An Overlay id to locate within the manager
- * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located.
- */
- find : function(overlay) {
- if (overlay instanceof YAHOO.widget.Overlay) {
- for (var o=0;o zIndex2) {
- return -1;
- } else if (zIndex1 < zIndex2) {
- return 1;
- } else {
- return 0;
- }
- },
-
- /**
- * Shows all Overlays in the manager.
- * @method showAll
- */
- showAll : function() {
- for (var o=0;oOR
+* @param {HTMLElement} el The element representing the Module
+* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+*/
+YAHOO.widget.Module = function(el, userConfig) {
+ if (el) {
+ this.init(el, userConfig);
+ } else {
+ YAHOO.log("No element or element ID specified for Module instantiation", "error");
+ }
+};
+
+/**
+* Constant representing the prefix path to use for non-secure images
+* @property YAHOO.widget.Module.IMG_ROOT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
+
+/**
+* Constant representing the prefix path to use for securely served images
+* @property YAHOO.widget.Module.IMG_ROOT_SSL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
+
+/**
+* Constant for the default CSS class name that represents a Module
+* @property YAHOO.widget.Module.CSS_MODULE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_MODULE = "module";
+
+/**
+* Constant representing the module header
+* @property YAHOO.widget.Module.CSS_HEADER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_HEADER = "hd";
+
+/**
+* Constant representing the module body
+* @property YAHOO.widget.Module.CSS_BODY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_BODY = "bd";
+
+/**
+* Constant representing the module footer
+* @property YAHOO.widget.Module.CSS_FOOTER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_FOOTER = "ft";
+
+/**
+* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
+* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";
+
+/**
+* Singleton CustomEvent fired when the font size is changed in the browser.
+* Opera's "zoom" functionality currently does not support text size detection.
+* @event YAHOO.widget.Module.textResizeEvent
+*/
+YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");
+
+YAHOO.widget.Module.prototype = {
+ /**
+ * The class's constructor function
+ * @property contructor
+ * @type Function
+ */
+ constructor : YAHOO.widget.Module,
+
+ /**
+ * The main module element that contains the header, body, and footer
+ * @property element
+ * @type HTMLElement
+ */
+ element : null,
+
+ /**
+ * The header element, denoted with CSS class "hd"
+ * @property header
+ * @type HTMLElement
+ */
+ header : null,
+
+ /**
+ * The body element, denoted with CSS class "bd"
+ * @property body
+ * @type HTMLElement
+ */
+ body : null,
+
+ /**
+ * The footer element, denoted with CSS class "ft"
+ * @property footer
+ * @type HTMLElement
+ */
+ footer : null,
+
+ /**
+ * The id of the element
+ * @property id
+ * @type String
+ */
+ id : null,
+
+ /**
+ * The String representing the image root
+ * @property imageRoot
+ * @type String
+ */
+ imageRoot : YAHOO.widget.Module.IMG_ROOT,
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ * @method initEvents
+ */
+ initEvents : function() {
+
+ /**
+ * CustomEvent fired prior to class initalization.
+ * @event beforeInitEvent
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ */
+ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
+
+ /**
+ * CustomEvent fired after class initalization.
+ * @event initEvent
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ */
+ this.initEvent = new YAHOO.util.CustomEvent("init");
+
+ /**
+ * CustomEvent fired when the Module is appended to the DOM
+ * @event appendEvent
+ */
+ this.appendEvent = new YAHOO.util.CustomEvent("append");
+
+ /**
+ * CustomEvent fired before the Module is rendered
+ * @event beforeRenderEvent
+ */
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+
+ /**
+ * CustomEvent fired after the Module is rendered
+ * @event renderEvent
+ */
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ /**
+ * CustomEvent fired when the header content of the Module is modified
+ * @event changeHeaderEvent
+ * @param {String/HTMLElement} content String/element representing the new header content
+ */
+ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
+
+ /**
+ * CustomEvent fired when the body content of the Module is modified
+ * @event changeBodyEvent
+ * @param {String/HTMLElement} content String/element representing the new body content
+ */
+ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
+
+ /**
+ * CustomEvent fired when the footer content of the Module is modified
+ * @event changeFooterEvent
+ * @param {String/HTMLElement} content String/element representing the new footer content
+ */
+ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
+
+ /**
+ * CustomEvent fired when the content of the Module is modified
+ * @event changeContentEvent
+ */
+ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
+
+ /**
+ * CustomEvent fired when the Module is destroyed
+ * @event destroyEvent
+ */
+ this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
+
+ /**
+ * CustomEvent fired before the Module is shown
+ * @event beforeShowEvent
+ */
+ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
+
+ /**
+ * CustomEvent fired after the Module is shown
+ * @event showEvent
+ */
+ this.showEvent = new YAHOO.util.CustomEvent("show");
+
+ /**
+ * CustomEvent fired before the Module is hidden
+ * @event beforeHideEvent
+ */
+ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
+
+ /**
+ * CustomEvent fired after the Module is hidden
+ * @event hideEvent
+ */
+ this.hideEvent = new YAHOO.util.CustomEvent("hide");
+ },
+
+ /**
+ * String representing the current user-agent platform
+ * @property platform
+ * @type String
+ */
+ platform : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
+ return "windows";
+ } else if (ua.indexOf("macintosh") != -1) {
+ return "mac";
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * String representing the current user-agent browser
+ * @property browser
+ * @type String
+ */
+ browser : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
+ return 'opera';
+ } else if (ua.indexOf('msie 7')!=-1) { // IE7
+ return 'ie7';
+ } else if (ua.indexOf('msie') !=-1) { // IE
+ return 'ie';
+ } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ } else if (ua.indexOf('gecko') != -1) { // Gecko
+ return 'gecko';
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Boolean representing whether or not the current browsing context is secure (https)
+ * @property isSecure
+ * @type Boolean
+ */
+ isSecure : function() {
+ if (window.location.href.toLowerCase().indexOf("https") === 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initDefaultConfig : function() {
+ // Add properties //
+
+ /**
+ * Specifies whether the Module is visible on the page.
+ * @config visible
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
+
+ /**
+ * Object or array of objects representing the ContainerEffect classes that are active for animating the container.
+ * @config effect
+ * @type Object
+ * @default null
+ */
+ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
+
+ /**
+ * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document
+ * @config monitorresize
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
+ },
+
+ /**
+ * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+ * @method init
+ * @param {String} el The element ID representing the Module OR
+ * @param {HTMLElement} el The element representing the Module
+ * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+ */
+ init : function(el, userConfig) {
+
+ this.initEvents();
+
+ this.beforeInitEvent.fire(YAHOO.widget.Module);
+
+ /**
+ * The Module's Config object used for monitoring configuration properties.
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ if (this.isSecure) {
+ this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
+ }
+
+ if (typeof el == "string") {
+ var elId = el;
+
+ el = document.getElementById(el);
+ if (! el) {
+ el = document.createElement("DIV");
+ el.id = elId;
+ }
+ }
+
+ this.element = el;
+
+ if (el.id) {
+ this.id = el.id;
+ }
+
+ var childNodes = this.element.childNodes;
+
+ if (childNodes) {
+ for (var i=0;iOR
+ * @param {HTMLElement} headerContent The HTMLElement to append to the header
+ */
+ setHeader : function(headerContent) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ if (typeof headerContent == "string") {
+ this.header.innerHTML = headerContent;
+ } else {
+ this.header.innerHTML = "";
+ this.header.appendChild(headerContent);
+ }
+
+ this.changeHeaderEvent.fire(headerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the header. If no header is present, one will be automatically created.
+ * @method appendToHeader
+ * @param {HTMLElement} element The element to append to the header
+ */
+ appendToHeader : function(element) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ this.header.appendChild(element);
+ this.changeHeaderEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
+ * @method setBody
+ * @param {String} bodyContent The HTML used to set the body OR
+ * @param {HTMLElement} bodyContent The HTMLElement to append to the body
+ */
+ setBody : function(bodyContent) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ if (typeof bodyContent == "string")
+ {
+ this.body.innerHTML = bodyContent;
+ } else {
+ this.body.innerHTML = "";
+ this.body.appendChild(bodyContent);
+ }
+
+ this.changeBodyEvent.fire(bodyContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the body. If no body is present, one will be automatically created.
+ * @method appendToBody
+ * @param {HTMLElement} element The element to append to the body
+ */
+ appendToBody : function(element) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ this.body.appendChild(element);
+ this.changeBodyEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @method setFooter
+ * @param {String} footerContent The HTML used to set the footer OR
+ * @param {HTMLElement} footerContent The HTMLElement to append to the footer
+ */
+ setFooter : function(footerContent) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ if (typeof footerContent == "string") {
+ this.footer.innerHTML = footerContent;
+ } else {
+ this.footer.innerHTML = "";
+ this.footer.appendChild(footerContent);
+ }
+
+ this.changeFooterEvent.fire(footerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @method appendToFooter
+ * @param {HTMLElement} element The element to append to the footer
+ */
+ appendToFooter : function(element) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ this.footer.appendChild(element);
+ this.changeFooterEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+ * @method render
+ * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering OR
+ * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
+ * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
+ * @return {Boolean} Success or failure of the render
+ */
+ render : function(appendToNode, moduleElement) {
+ this.beforeRenderEvent.fire();
+
+ if (! moduleElement) {
+ moduleElement = this.element;
+ }
+
+ var me = this;
+ var appendTo = function(element) {
+ if (typeof element == "string") {
+ element = document.getElementById(element);
+ }
+
+ if (element) {
+ element.appendChild(me.element);
+ me.appendEvent.fire();
+ }
+ };
+
+ if (appendToNode) {
+ appendTo(appendToNode);
+ } else { // No node was passed in. If the element is not pre-marked up, this fails
+ if (! YAHOO.util.Dom.inDocument(this.element)) {
+ YAHOO.log("Render failed. Must specify appendTo node if Module isn't already in the DOM.", "error");
+ return false;
+ }
+ }
+
+ // Need to get everything into the DOM if it isn't already
+
+ if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
+ // There is a header, but it's not in the DOM yet... need to add it
+ var firstChild = moduleElement.firstChild;
+ if (firstChild) { // Insert before first child if exists
+ moduleElement.insertBefore(this.header, firstChild);
+ } else { // Append to empty body because there are no children
+ moduleElement.appendChild(this.header);
+ }
+ }
+
+ if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
+ // There is a body, but it's not in the DOM yet... need to add it
+ if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
+ moduleElement.insertBefore(this.body, this.footer);
+ } else { // Append to element because there is no footer
+ moduleElement.appendChild(this.body);
+ }
+ }
+
+ if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
+ // There is a footer, but it's not in the DOM yet... need to add it
+ moduleElement.appendChild(this.footer);
+ }
+
+ this.renderEvent.fire();
+ return true;
+ },
+
+ /**
+ * Removes the Module element from the DOM and sets all child elements to null.
+ * @method destroy
+ */
+ destroy : function() {
+ var parent;
+
+ if (this.element) {
+ YAHOO.util.Event.purgeElement(this.element, true);
+ parent = this.element.parentNode;
+ }
+ if (parent) {
+ parent.removeChild(this.element);
+ }
+
+ this.element = null;
+ this.header = null;
+ this.body = null;
+ this.footer = null;
+
+ for (var e in this) {
+ if (e instanceof YAHOO.util.CustomEvent) {
+ e.unsubscribeAll();
+ }
+ }
+
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this);
+
+ this.destroyEvent.fire();
+ },
+
+ /**
+ * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
+ * @method show
+ */
+ show : function() {
+ this.cfg.setProperty("visible", true);
+ },
+
+ /**
+ * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
+ * @method hide
+ */
+ hide : function() {
+ this.cfg.setProperty("visible", false);
+ },
+
+ // BUILT-IN EVENT HANDLERS FOR MODULE //
+
+ /**
+ * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
+ * This method is responsible for firing showEvent and hideEvent.
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ * @method configVisible
+ */
+ configVisible : function(type, args, obj) {
+ var visible = args[0];
+ if (visible) {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "block");
+ this.showEvent.fire();
+ } else {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "none");
+ this.hideEvent.fire();
+ }
+ },
+
+ /**
+ * Default event handler for the "monitorresize" configuration property
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ * @method configMonitorResize
+ */
+ configMonitorResize : function(type, args, obj) {
+ var monitor = args[0];
+ if (monitor) {
+ this.initResizeMonitor();
+ } else {
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this, true);
+ this.resizeMonitor = null;
+ }
+ }
+};
+
+/**
+* Returns a String representation of the Object.
+* @method toString
+* @return {String} The string representation of the Module
+*/
+YAHOO.widget.Module.prototype.toString = function() {
+ return "Module " + this.id;
+};
+
+/**
+* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
+* @namespace YAHOO.widget
+* @class Overlay
+* @extends YAHOO.widget.Module
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Overlay = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
+
+/**
+* The URL that will be placed in the iframe
+* @property YAHOO.widget.Overlay.IFRAME_SRC
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;";
+
+/**
+* Constant representing the top left corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.TOP_LEFT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.TOP_LEFT = "tl";
+
+/**
+* Constant representing the top right corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.TOP_RIGHT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.TOP_RIGHT = "tr";
+
+/**
+* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.BOTTOM_LEFT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
+
+/**
+* Constant representing the bottom right corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.BOTTOM_RIGHT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
+
+/**
+* Constant representing the default CSS class used for an Overlay
+* @property YAHOO.widget.Overlay.CSS_OVERLAY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Overlay);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ if (this.platform == "mac" && this.browser == "gecko") {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
+ this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
+ this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
+ }
+ }
+
+ this.initEvent.fire(YAHOO.widget.Overlay);
+
+};
+
+/**
+* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
+* @method initEvents
+*/
+YAHOO.widget.Overlay.prototype.initEvents = function() {
+ YAHOO.widget.Overlay.superclass.initEvents.call(this);
+
+ /**
+ * CustomEvent fired before the Overlay is moved.
+ * @event beforeMoveEvent
+ * @param {Number} x x coordinate
+ * @param {Number} y y coordinate
+ */
+ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
+
+ /**
+ * CustomEvent fired after the Overlay is moved.
+ * @event moveEvent
+ * @param {Number} x x coordinate
+ * @param {Number} y y coordinate
+ */
+ this.moveEvent = new YAHOO.util.CustomEvent("move", this);
+};
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
+
+ // Add overlay config properties //
+
+ /**
+ * The absolute x-coordinate position of the Overlay
+ * @config x
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * The absolute y-coordinate position of the Overlay
+ * @config y
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * An array with the absolute x and y positions of the Overlay
+ * @config xy
+ * @type Number[]
+ * @default null
+ */
+ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner.
+ * @config context
+ * @type Array
+ * @default null
+ */
+ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * True if the Overlay should be anchored to the center of the viewport.
+ * @config fixedcenter
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
+
+ /**
+ * CSS width of the Overlay.
+ * @config width
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * CSS height of the Overlay.
+ * @config height
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * CSS z-index of the Overlay.
+ * @config zIndex
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
+
+ /**
+ * True if the Overlay should be prevented from being positioned out of the viewport.
+ * @config constraintoviewport
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
+
+ /**
+ * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below).
+ * @config iframe
+ * @type Boolean
+ * @default true for IE6 and below, false for all others
+ */
+ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
+};
+
+/**
+* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
+* @method moveTo
+* @param {Number} x The Overlay's new x position
+* @param {Number} y The Overlay's new y position
+*/
+YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
+ this.cfg.setProperty("xy",[x,y]);
+};
+
+/**
+* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+* @method hideMacGeckoScrollbars
+*/
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
+};
+
+/**
+* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+* @method showMacGeckoScrollbars
+*/
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
+* @method configVisible
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
+ var visible = args[0];
+ var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
+
+ if (currentVis == "inherit") {
+ var e = this.element.parentNode;
+ while (e.nodeType != 9 && e.nodeType != 11) {
+ currentVis = YAHOO.util.Dom.getStyle(e, "visibility");
+ if (currentVis != "inherit") { break; }
+ e = e.parentNode;
+ }
+ if (currentVis == "inherit") {
+ currentVis = "visible";
+ }
+ }
+
+ var effect = this.cfg.getProperty("effect");
+
+ var effectInstances = [];
+ if (effect) {
+ if (effect instanceof Array) {
+ for (var i=0;i rightConstraint) {
+ x = rightConstraint;
+ }
+
+ if (y < topConstraint) {
+ y = topConstraint;
+ } else if (y > bottomConstraint) {
+ y = bottomConstraint;
+ }
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+ this.cfg.setProperty("xy", [x,y], true);
+};
+
+/**
+* Centers the container in the viewport.
+* @method center
+*/
+YAHOO.widget.Overlay.prototype.center = function() {
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+
+ var viewPortWidth = YAHOO.util.Dom.getClientWidth();
+ var viewPortHeight = YAHOO.util.Dom.getClientHeight();
+
+ var elementWidth = this.element.offsetWidth;
+ var elementHeight = this.element.offsetHeight;
+
+ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
+ var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
+
+ this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
+
+ this.cfg.refireEvent("iframe");
+};
+
+/**
+* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
+* @method syncPosition
+*/
+YAHOO.widget.Overlay.prototype.syncPosition = function() {
+ var pos = YAHOO.util.Dom.getXY(this.element);
+ this.cfg.setProperty("x", pos[0], true);
+ this.cfg.setProperty("y", pos[1], true);
+ this.cfg.setProperty("xy", pos, true);
+};
+
+/**
+* Event handler fired when the resize monitor element is resized.
+* @method onDomResize
+* @param {DOMEvent} e The resize DOM event
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
+ var me = this;
+ setTimeout(function() {
+ me.syncPosition();
+ me.cfg.refireEvent("iframe");
+ me.cfg.refireEvent("context");
+ }, 0);
+};
+
+/**
+* Removes the Overlay element from the DOM and sets all child elements to null.
+* @method destroy
+*/
+YAHOO.widget.Overlay.prototype.destroy = function() {
+ if (this.iframe) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+
+ this.iframe = null;
+
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+
+ YAHOO.widget.Overlay.superclass.destroy.call(this);
+};
+
+/**
+* Returns a String representation of the object.
+* @method toString
+* @return {String} The string representation of the Overlay.
+*/
+YAHOO.widget.Overlay.prototype.toString = function() {
+ return "Overlay " + this.id;
+};
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window scroll
+* @event YAHOO.widget.Overlay.windowScrollEvent
+*/
+YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window resize
+* @event YAHOO.widget.Overlay.windowResizeEvent
+*/
+YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
+
+/**
+* The DOM event handler used to fire the CustomEvent for window scroll
+* @method YAHOO.widget.Overlay.windowScrollHandler
+* @static
+* @param {DOMEvent} e The DOM scroll event
+*/
+YAHOO.widget.Overlay.windowScrollHandler = function(e) {
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
+ if (! window.scrollEnd) {
+ window.scrollEnd = -1;
+ }
+ clearTimeout(window.scrollEnd);
+ window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1);
+ } else {
+ YAHOO.widget.Overlay.windowScrollEvent.fire();
+ }
+};
+
+/**
+* The DOM event handler used to fire the CustomEvent for window resize
+* @method YAHOO.widget.Overlay.windowResizeHandler
+* @static
+* @param {DOMEvent} e The DOM resize event
+*/
+YAHOO.widget.Overlay.windowResizeHandler = function(e) {
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
+ if (! window.resizeEnd) {
+ window.resizeEnd = -1;
+ }
+ clearTimeout(window.resizeEnd);
+ window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100);
+ } else {
+ YAHOO.widget.Overlay.windowResizeEvent.fire();
+ }
+};
+
+/**
+* A boolean that indicated whether the window resize and scroll events have already been subscribed to.
+* @property YAHOO.widget.Overlay._initialized
+* @private
+* @type Boolean
+*/
+YAHOO.widget.Overlay._initialized = null;
+
+if (YAHOO.widget.Overlay._initialized === null) {
+ YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
+ YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
+
+ YAHOO.widget.Overlay._initialized = true;
+}
+
+/**
+* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget
+* @namespace YAHOO.widget
+* @class OverlayManager
+* @constructor
+* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
+*/
+YAHOO.widget.OverlayManager = function(userConfig) {
+ this.init(userConfig);
+};
+
+/**
+* The CSS class representing a focused Overlay
+* @property YAHOO.widget.OverlayManager.CSS_FOCUSED
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
+
+YAHOO.widget.OverlayManager.prototype = {
+ /**
+ * The class's constructor function
+ * @property contructor
+ * @type Function
+ */
+ constructor : YAHOO.widget.OverlayManager,
+
+ /**
+ * The array of Overlays that are currently registered
+ * @property overlays
+ * @type YAHOO.widget.Overlay[]
+ */
+ overlays : null,
+
+ /**
+ * Initializes the default configuration of the OverlayManager
+ * @method initDefaultConfig
+ */
+ initDefaultConfig : function() {
+ /**
+ * The collection of registered Overlays in use by the OverlayManager
+ * @config overlays
+ * @type YAHOO.widget.Overlay[]
+ * @default null
+ */
+ this.cfg.addProperty("overlays", { suppressEvent:true } );
+
+ /**
+ * The default DOM event that should be used to focus an Overlay
+ * @config focusevent
+ * @type String
+ * @default "mousedown"
+ */
+ this.cfg.addProperty("focusevent", { value:"mousedown" } );
+ },
+
+ /**
+ * Initializes the OverlayManager
+ * @method init
+ * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager.
+ * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
+ */
+ init : function(userConfig) {
+ /**
+ * The OverlayManager's Config object used for monitoring configuration properties.
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+ this.cfg.fireQueue();
+
+ /**
+ * The currently activated Overlay
+ * @property activeOverlay
+ * @private
+ * @type YAHOO.widget.Overlay
+ */
+ var activeOverlay = null;
+
+ /**
+ * Returns the currently focused Overlay
+ * @method getActive
+ * @return {YAHOO.widget.Overlay} The currently focused Overlay
+ */
+ this.getActive = function() {
+ return activeOverlay;
+ };
+
+ /**
+ * Focuses the specified Overlay
+ * @method focus
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to focus
+ * @param {String} overlay The id of the Overlay to focus
+ */
+ this.focus = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ this.blurAll();
+ activeOverlay = o;
+ YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ this.overlays.sort(this.compareZIndexDesc);
+ var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
+ if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
+ activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2));
+ }
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ };
+
+ /**
+ * Removes the specified Overlay from the manager
+ * @method remove
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to remove
+ * @param {String} overlay The id of the Overlay to remove
+ */
+ this.remove = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
+ o.cfg.setProperty("zIndex", -1000, true);
+ this.overlays.sort(this.compareZIndexDesc);
+ this.overlays = this.overlays.slice(0, this.overlays.length-1);
+ o.cfg.setProperty("zIndex", originalZ, true);
+
+ o.cfg.setProperty("manager", null);
+ o.focusEvent = null;
+ o.blurEvent = null;
+ o.focus = null;
+ o.blur = null;
+ }
+ };
+
+ /**
+ * Removes focus from all registered Overlays in the manager
+ * @method blurAll
+ */
+ this.blurAll = function() {
+ activeOverlay = null;
+ for (var o=0;o 0) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Attempts to locate an Overlay by instance or ID.
+ * @method find
+ * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager
+ * @param {String} overlay An Overlay id to locate within the manager
+ * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located.
+ */
+ find : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ for (var o=0;o zIndex2) {
+ return -1;
+ } else if (zIndex1 < zIndex2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ },
+
+ /**
+ * Shows all Overlays in the manager.
+ * @method showAll
+ */
+ showAll : function() {
+ for (var o=0;orightConstraint){x=rightConstraint;}
-if(ybottomConstraint){y=bottomConstraint;}
-this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.cfg.setProperty("xy",[x,y],true);};YAHOO.widget.Overlay.prototype.center=function(){var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var viewPortWidth=YAHOO.util.Dom.getClientWidth();var viewPortHeight=YAHOO.util.Dom.getClientHeight();var elementWidth=this.element.offsetWidth;var elementHeight=this.element.offsetHeight;var x=(viewPortWidth/2)-(elementWidth/2)+scrollX;var y=(viewPortHeight/2)-(elementHeight/2)+scrollY;this.cfg.setProperty("xy",[parseInt(x,10),parseInt(y,10)]);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.syncPosition=function(){var pos=YAHOO.util.Dom.getXY(this.element);this.cfg.setProperty("x",pos[0],true);this.cfg.setProperty("y",pos[1],true);this.cfg.setProperty("xy",pos,true);};YAHOO.widget.Overlay.prototype.onDomResize=function(e,obj){YAHOO.widget.Overlay.superclass.onDomResize.call(this,e,obj);var me=this;setTimeout(function(){me.syncPosition();me.cfg.refireEvent("iframe");me.cfg.refireEvent("context");},0);};YAHOO.widget.Overlay.prototype.destroy=function(){if(this.iframe){this.iframe.parentNode.removeChild(this.iframe);}
-this.iframe=null;YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.superclass.destroy.call(this);};YAHOO.widget.Overlay.prototype.toString=function(){return"Overlay "+this.id;};YAHOO.widget.Overlay.windowScrollEvent=new YAHOO.util.CustomEvent("windowScroll");YAHOO.widget.Overlay.windowResizeEvent=new YAHOO.util.CustomEvent("windowResize");YAHOO.widget.Overlay.windowScrollHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.scrollEnd){window.scrollEnd=-1;}
-clearTimeout(window.scrollEnd);window.scrollEnd=setTimeout(function(){YAHOO.widget.Overlay.windowScrollEvent.fire();},1);}else{YAHOO.widget.Overlay.windowScrollEvent.fire();}};YAHOO.widget.Overlay.windowResizeHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.resizeEnd){window.resizeEnd=-1;}
-clearTimeout(window.resizeEnd);window.resizeEnd=setTimeout(function(){YAHOO.widget.Overlay.windowResizeEvent.fire();},100);}else{YAHOO.widget.Overlay.windowResizeEvent.fire();}};YAHOO.widget.Overlay._initialized=null;if(YAHOO.widget.Overlay._initialized===null){YAHOO.util.Event.addListener(window,"scroll",YAHOO.widget.Overlay.windowScrollHandler);YAHOO.util.Event.addListener(window,"resize",YAHOO.widget.Overlay.windowResizeHandler);YAHOO.widget.Overlay._initialized=true;}
-YAHOO.widget.OverlayManager=function(userConfig){this.init(userConfig);};YAHOO.widget.OverlayManager.CSS_FOCUSED="focused";YAHOO.widget.OverlayManager.prototype={constructor:YAHOO.widget.OverlayManager,overlays:null,initDefaultConfig:function(){this.cfg.addProperty("overlays",{suppressEvent:true});this.cfg.addProperty("focusevent",{value:"mousedown"});},init:function(userConfig){this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();if(userConfig){this.cfg.applyConfig(userConfig,true);}
-this.cfg.fireQueue();var activeOverlay=null;this.getActive=function(){return activeOverlay;};this.focus=function(overlay){var o=this.find(overlay);if(o){this.blurAll();activeOverlay=o;YAHOO.util.Dom.addClass(activeOverlay.element,YAHOO.widget.OverlayManager.CSS_FOCUSED);this.overlays.sort(this.compareZIndexDesc);var topZIndex=YAHOO.util.Dom.getStyle(this.overlays[0].element,"zIndex");if(!isNaN(topZIndex)&&this.overlays[0]!=overlay){activeOverlay.cfg.setProperty("zIndex",(parseInt(topZIndex,10)+2));}
-this.overlays.sort(this.compareZIndexDesc);}};this.remove=function(overlay){var o=this.find(overlay);if(o){var originalZ=YAHOO.util.Dom.getStyle(o.element,"zIndex");o.cfg.setProperty("zIndex",-1000,true);this.overlays.sort(this.compareZIndexDesc);this.overlays=this.overlays.slice(0,this.overlays.length-1);o.cfg.setProperty("zIndex",originalZ,true);o.cfg.setProperty("manager",null);o.focusEvent=null;o.blurEvent=null;o.focus=null;o.blur=null;}};this.blurAll=function(){activeOverlay=null;for(var o=0;o0){return true;}}else{return false;}},find:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){for(var o=0;ozIndex2){return-1;}else if(zIndex1rightConstraint){x=rightConstraint;}
+if(ybottomConstraint){y=bottomConstraint;}
+this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.cfg.setProperty("xy",[x,y],true);};YAHOO.widget.Overlay.prototype.center=function(){var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var viewPortWidth=YAHOO.util.Dom.getClientWidth();var viewPortHeight=YAHOO.util.Dom.getClientHeight();var elementWidth=this.element.offsetWidth;var elementHeight=this.element.offsetHeight;var x=(viewPortWidth/2)-(elementWidth/2)+scrollX;var y=(viewPortHeight/2)-(elementHeight/2)+scrollY;this.cfg.setProperty("xy",[parseInt(x,10),parseInt(y,10)]);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.syncPosition=function(){var pos=YAHOO.util.Dom.getXY(this.element);this.cfg.setProperty("x",pos[0],true);this.cfg.setProperty("y",pos[1],true);this.cfg.setProperty("xy",pos,true);};YAHOO.widget.Overlay.prototype.onDomResize=function(e,obj){YAHOO.widget.Overlay.superclass.onDomResize.call(this,e,obj);var me=this;setTimeout(function(){me.syncPosition();me.cfg.refireEvent("iframe");me.cfg.refireEvent("context");},0);};YAHOO.widget.Overlay.prototype.destroy=function(){if(this.iframe){this.iframe.parentNode.removeChild(this.iframe);}
+this.iframe=null;YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.superclass.destroy.call(this);};YAHOO.widget.Overlay.prototype.toString=function(){return"Overlay "+this.id;};YAHOO.widget.Overlay.windowScrollEvent=new YAHOO.util.CustomEvent("windowScroll");YAHOO.widget.Overlay.windowResizeEvent=new YAHOO.util.CustomEvent("windowResize");YAHOO.widget.Overlay.windowScrollHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.scrollEnd){window.scrollEnd=-1;}
+clearTimeout(window.scrollEnd);window.scrollEnd=setTimeout(function(){YAHOO.widget.Overlay.windowScrollEvent.fire();},1);}else{YAHOO.widget.Overlay.windowScrollEvent.fire();}};YAHOO.widget.Overlay.windowResizeHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.resizeEnd){window.resizeEnd=-1;}
+clearTimeout(window.resizeEnd);window.resizeEnd=setTimeout(function(){YAHOO.widget.Overlay.windowResizeEvent.fire();},100);}else{YAHOO.widget.Overlay.windowResizeEvent.fire();}};YAHOO.widget.Overlay._initialized=null;if(YAHOO.widget.Overlay._initialized===null){YAHOO.util.Event.addListener(window,"scroll",YAHOO.widget.Overlay.windowScrollHandler);YAHOO.util.Event.addListener(window,"resize",YAHOO.widget.Overlay.windowResizeHandler);YAHOO.widget.Overlay._initialized=true;}
+YAHOO.widget.OverlayManager=function(userConfig){this.init(userConfig);};YAHOO.widget.OverlayManager.CSS_FOCUSED="focused";YAHOO.widget.OverlayManager.prototype={constructor:YAHOO.widget.OverlayManager,overlays:null,initDefaultConfig:function(){this.cfg.addProperty("overlays",{suppressEvent:true});this.cfg.addProperty("focusevent",{value:"mousedown"});},init:function(userConfig){this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();if(userConfig){this.cfg.applyConfig(userConfig,true);}
+this.cfg.fireQueue();var activeOverlay=null;this.getActive=function(){return activeOverlay;};this.focus=function(overlay){var o=this.find(overlay);if(o){this.blurAll();activeOverlay=o;YAHOO.util.Dom.addClass(activeOverlay.element,YAHOO.widget.OverlayManager.CSS_FOCUSED);this.overlays.sort(this.compareZIndexDesc);var topZIndex=YAHOO.util.Dom.getStyle(this.overlays[0].element,"zIndex");if(!isNaN(topZIndex)&&this.overlays[0]!=overlay){activeOverlay.cfg.setProperty("zIndex",(parseInt(topZIndex,10)+2));}
+this.overlays.sort(this.compareZIndexDesc);}};this.remove=function(overlay){var o=this.find(overlay);if(o){var originalZ=YAHOO.util.Dom.getStyle(o.element,"zIndex");o.cfg.setProperty("zIndex",-1000,true);this.overlays.sort(this.compareZIndexDesc);this.overlays=this.overlays.slice(0,this.overlays.length-1);o.cfg.setProperty("zIndex",originalZ,true);o.cfg.setProperty("manager",null);o.focusEvent=null;o.blurEvent=null;o.focus=null;o.blur=null;}};this.blurAll=function(){activeOverlay=null;for(var o=0;o0){return true;}}else{return false;}},find:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){for(var o=0;ozIndex2){return-1;}else if(zIndex1OR
-* @param {HTMLElement} el The element representing the Module
-* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
-*/
-YAHOO.widget.Module = function(el, userConfig) {
- if (el) {
- this.init(el, userConfig);
- }
-};
-
-/**
-* Constant representing the prefix path to use for non-secure images
-* @property YAHOO.widget.Module.IMG_ROOT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
-
-/**
-* Constant representing the prefix path to use for securely served images
-* @property YAHOO.widget.Module.IMG_ROOT_SSL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
-
-/**
-* Constant for the default CSS class name that represents a Module
-* @property YAHOO.widget.Module.CSS_MODULE
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_MODULE = "module";
-
-/**
-* Constant representing the module header
-* @property YAHOO.widget.Module.CSS_HEADER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_HEADER = "hd";
-
-/**
-* Constant representing the module body
-* @property YAHOO.widget.Module.CSS_BODY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_BODY = "bd";
-
-/**
-* Constant representing the module footer
-* @property YAHOO.widget.Module.CSS_FOOTER
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.CSS_FOOTER = "ft";
-
-/**
-* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
-* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";
-
-/**
-* Singleton CustomEvent fired when the font size is changed in the browser.
-* Opera's "zoom" functionality currently does not support text size detection.
-* @event YAHOO.widget.Module.textResizeEvent
-*/
-YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");
-
-YAHOO.widget.Module.prototype = {
- /**
- * The class's constructor function
- * @property contructor
- * @type Function
- */
- constructor : YAHOO.widget.Module,
-
- /**
- * The main module element that contains the header, body, and footer
- * @property element
- * @type HTMLElement
- */
- element : null,
-
- /**
- * The header element, denoted with CSS class "hd"
- * @property header
- * @type HTMLElement
- */
- header : null,
-
- /**
- * The body element, denoted with CSS class "bd"
- * @property body
- * @type HTMLElement
- */
- body : null,
-
- /**
- * The footer element, denoted with CSS class "ft"
- * @property footer
- * @type HTMLElement
- */
- footer : null,
-
- /**
- * The id of the element
- * @property id
- * @type String
- */
- id : null,
-
- /**
- * The String representing the image root
- * @property imageRoot
- * @type String
- */
- imageRoot : YAHOO.widget.Module.IMG_ROOT,
-
- /**
- * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
- * @method initEvents
- */
- initEvents : function() {
-
- /**
- * CustomEvent fired prior to class initalization.
- * @event beforeInitEvent
- * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
- */
- this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
-
- /**
- * CustomEvent fired after class initalization.
- * @event initEvent
- * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
- */
- this.initEvent = new YAHOO.util.CustomEvent("init");
-
- /**
- * CustomEvent fired when the Module is appended to the DOM
- * @event appendEvent
- */
- this.appendEvent = new YAHOO.util.CustomEvent("append");
-
- /**
- * CustomEvent fired before the Module is rendered
- * @event beforeRenderEvent
- */
- this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
-
- /**
- * CustomEvent fired after the Module is rendered
- * @event renderEvent
- */
- this.renderEvent = new YAHOO.util.CustomEvent("render");
-
- /**
- * CustomEvent fired when the header content of the Module is modified
- * @event changeHeaderEvent
- * @param {String/HTMLElement} content String/element representing the new header content
- */
- this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
-
- /**
- * CustomEvent fired when the body content of the Module is modified
- * @event changeBodyEvent
- * @param {String/HTMLElement} content String/element representing the new body content
- */
- this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
-
- /**
- * CustomEvent fired when the footer content of the Module is modified
- * @event changeFooterEvent
- * @param {String/HTMLElement} content String/element representing the new footer content
- */
- this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
-
- /**
- * CustomEvent fired when the content of the Module is modified
- * @event changeContentEvent
- */
- this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
-
- /**
- * CustomEvent fired when the Module is destroyed
- * @event destroyEvent
- */
- this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
-
- /**
- * CustomEvent fired before the Module is shown
- * @event beforeShowEvent
- */
- this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
-
- /**
- * CustomEvent fired after the Module is shown
- * @event showEvent
- */
- this.showEvent = new YAHOO.util.CustomEvent("show");
-
- /**
- * CustomEvent fired before the Module is hidden
- * @event beforeHideEvent
- */
- this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
-
- /**
- * CustomEvent fired after the Module is hidden
- * @event hideEvent
- */
- this.hideEvent = new YAHOO.util.CustomEvent("hide");
- },
-
- /**
- * String representing the current user-agent platform
- * @property platform
- * @type String
- */
- platform : function() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
- return "windows";
- } else if (ua.indexOf("macintosh") != -1) {
- return "mac";
- } else {
- return false;
- }
- }(),
-
- /**
- * String representing the current user-agent browser
- * @property browser
- * @type String
- */
- browser : function() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
- return 'opera';
- } else if (ua.indexOf('msie 7')!=-1) { // IE7
- return 'ie7';
- } else if (ua.indexOf('msie') !=-1) { // IE
- return 'ie';
- } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
- return 'safari';
- } else if (ua.indexOf('gecko') != -1) { // Gecko
- return 'gecko';
- } else {
- return false;
- }
- }(),
-
- /**
- * Boolean representing whether or not the current browsing context is secure (https)
- * @property isSecure
- * @type Boolean
- */
- isSecure : function() {
- if (window.location.href.toLowerCase().indexOf("https") === 0) {
- return true;
- } else {
- return false;
- }
- }(),
-
- /**
- * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
- */
- initDefaultConfig : function() {
- // Add properties //
-
- /**
- * Specifies whether the Module is visible on the page.
- * @config visible
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
-
- /**
- * Object or array of objects representing the ContainerEffect classes that are active for animating the container.
- * @config effect
- * @type Object
- * @default null
- */
- this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
-
- /**
- * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document
- * @config monitorresize
- * @type Boolean
- * @default true
- */
- this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
- },
-
- /**
- * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
- * @method init
- * @param {String} el The element ID representing the Module OR
- * @param {HTMLElement} el The element representing the Module
- * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
- */
- init : function(el, userConfig) {
-
- this.initEvents();
-
- this.beforeInitEvent.fire(YAHOO.widget.Module);
-
- /**
- * The Module's Config object used for monitoring configuration properties.
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- if (this.isSecure) {
- this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
- }
-
- if (typeof el == "string") {
- var elId = el;
-
- el = document.getElementById(el);
- if (! el) {
- el = document.createElement("DIV");
- el.id = elId;
- }
- }
-
- this.element = el;
-
- if (el.id) {
- this.id = el.id;
- }
-
- var childNodes = this.element.childNodes;
-
- if (childNodes) {
- for (var i=0;iOR
- * @param {HTMLElement} headerContent The HTMLElement to append to the header
- */
- setHeader : function(headerContent) {
- if (! this.header) {
- this.header = document.createElement("DIV");
- this.header.className = YAHOO.widget.Module.CSS_HEADER;
- }
-
- if (typeof headerContent == "string") {
- this.header.innerHTML = headerContent;
- } else {
- this.header.innerHTML = "";
- this.header.appendChild(headerContent);
- }
-
- this.changeHeaderEvent.fire(headerContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the header. If no header is present, one will be automatically created.
- * @method appendToHeader
- * @param {HTMLElement} element The element to append to the header
- */
- appendToHeader : function(element) {
- if (! this.header) {
- this.header = document.createElement("DIV");
- this.header.className = YAHOO.widget.Module.CSS_HEADER;
- }
-
- this.header.appendChild(element);
- this.changeHeaderEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
- * @method setBody
- * @param {String} bodyContent The HTML used to set the body OR
- * @param {HTMLElement} bodyContent The HTMLElement to append to the body
- */
- setBody : function(bodyContent) {
- if (! this.body) {
- this.body = document.createElement("DIV");
- this.body.className = YAHOO.widget.Module.CSS_BODY;
- }
-
- if (typeof bodyContent == "string")
- {
- this.body.innerHTML = bodyContent;
- } else {
- this.body.innerHTML = "";
- this.body.appendChild(bodyContent);
- }
-
- this.changeBodyEvent.fire(bodyContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the body. If no body is present, one will be automatically created.
- * @method appendToBody
- * @param {HTMLElement} element The element to append to the body
- */
- appendToBody : function(element) {
- if (! this.body) {
- this.body = document.createElement("DIV");
- this.body.className = YAHOO.widget.Module.CSS_BODY;
- }
-
- this.body.appendChild(element);
- this.changeBodyEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
- * @method setFooter
- * @param {String} footerContent The HTML used to set the footer OR
- * @param {HTMLElement} footerContent The HTMLElement to append to the footer
- */
- setFooter : function(footerContent) {
- if (! this.footer) {
- this.footer = document.createElement("DIV");
- this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
- }
-
- if (typeof footerContent == "string") {
- this.footer.innerHTML = footerContent;
- } else {
- this.footer.innerHTML = "";
- this.footer.appendChild(footerContent);
- }
-
- this.changeFooterEvent.fire(footerContent);
- this.changeContentEvent.fire();
- },
-
- /**
- * Appends the passed element to the footer. If no footer is present, one will be automatically created.
- * @method appendToFooter
- * @param {HTMLElement} element The element to append to the footer
- */
- appendToFooter : function(element) {
- if (! this.footer) {
- this.footer = document.createElement("DIV");
- this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
- }
-
- this.footer.appendChild(element);
- this.changeFooterEvent.fire(element);
- this.changeContentEvent.fire();
- },
-
- /**
- * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
- * @method render
- * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering OR
- * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
- * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
- * @return {Boolean} Success or failure of the render
- */
- render : function(appendToNode, moduleElement) {
- this.beforeRenderEvent.fire();
-
- if (! moduleElement) {
- moduleElement = this.element;
- }
-
- var me = this;
- var appendTo = function(element) {
- if (typeof element == "string") {
- element = document.getElementById(element);
- }
-
- if (element) {
- element.appendChild(me.element);
- me.appendEvent.fire();
- }
- };
-
- if (appendToNode) {
- appendTo(appendToNode);
- } else { // No node was passed in. If the element is not pre-marked up, this fails
- if (! YAHOO.util.Dom.inDocument(this.element)) {
- return false;
- }
- }
-
- // Need to get everything into the DOM if it isn't already
-
- if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
- // There is a header, but it's not in the DOM yet... need to add it
- var firstChild = moduleElement.firstChild;
- if (firstChild) { // Insert before first child if exists
- moduleElement.insertBefore(this.header, firstChild);
- } else { // Append to empty body because there are no children
- moduleElement.appendChild(this.header);
- }
- }
-
- if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
- // There is a body, but it's not in the DOM yet... need to add it
- if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
- moduleElement.insertBefore(this.body, this.footer);
- } else { // Append to element because there is no footer
- moduleElement.appendChild(this.body);
- }
- }
-
- if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
- // There is a footer, but it's not in the DOM yet... need to add it
- moduleElement.appendChild(this.footer);
- }
-
- this.renderEvent.fire();
- return true;
- },
-
- /**
- * Removes the Module element from the DOM and sets all child elements to null.
- * @method destroy
- */
- destroy : function() {
- var parent;
-
- if (this.element) {
- YAHOO.util.Event.purgeElement(this.element, true);
- parent = this.element.parentNode;
- }
- if (parent) {
- parent.removeChild(this.element);
- }
-
- this.element = null;
- this.header = null;
- this.body = null;
- this.footer = null;
-
- for (var e in this) {
- if (e instanceof YAHOO.util.CustomEvent) {
- e.unsubscribeAll();
- }
- }
-
- YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this);
-
- this.destroyEvent.fire();
- },
-
- /**
- * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
- * @method show
- */
- show : function() {
- this.cfg.setProperty("visible", true);
- },
-
- /**
- * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
- * @method hide
- */
- hide : function() {
- this.cfg.setProperty("visible", false);
- },
-
- // BUILT-IN EVENT HANDLERS FOR MODULE //
-
- /**
- * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
- * This method is responsible for firing showEvent and hideEvent.
- * @param {String} type The CustomEvent type (usually the property name)
- * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
- * @method configVisible
- */
- configVisible : function(type, args, obj) {
- var visible = args[0];
- if (visible) {
- this.beforeShowEvent.fire();
- YAHOO.util.Dom.setStyle(this.element, "display", "block");
- this.showEvent.fire();
- } else {
- this.beforeHideEvent.fire();
- YAHOO.util.Dom.setStyle(this.element, "display", "none");
- this.hideEvent.fire();
- }
- },
-
- /**
- * Default event handler for the "monitorresize" configuration property
- * @param {String} type The CustomEvent type (usually the property name)
- * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
- * @method configMonitorResize
- */
- configMonitorResize : function(type, args, obj) {
- var monitor = args[0];
- if (monitor) {
- this.initResizeMonitor();
- } else {
- YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize);
- this.resizeMonitor = null;
- }
- }
-};
-
-/**
-* Returns a String representation of the Object.
-* @method toString
-* @return {String} The string representation of the Module
-*/
-YAHOO.widget.Module.prototype.toString = function() {
- return "Module " + this.id;
-};
-
-/**
-* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
-* @namespace YAHOO.widget
-* @class Overlay
-* @extends YAHOO.widget.Module
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details.
-* @constructor
-*/
-YAHOO.widget.Overlay = function(el, userConfig) {
- YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
-};
-
-YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
-
-/**
-* The URL that will be placed in the iframe
-* @property YAHOO.widget.Overlay.IFRAME_SRC
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;";
-
-/**
-* Constant representing the top left corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.TOP_LEFT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.TOP_LEFT = "tl";
-
-/**
-* Constant representing the top right corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.TOP_RIGHT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.TOP_RIGHT = "tr";
-
-/**
-* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.BOTTOM_LEFT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
-
-/**
-* Constant representing the bottom right corner of an element, used for configuring the context element alignment
-* @property YAHOO.widget.Overlay.BOTTOM_RIGHT
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
-
-/**
-* Constant representing the default CSS class used for an Overlay
-* @property YAHOO.widget.Overlay.CSS_OVERLAY
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
-
-/**
-* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
-* @method init
-* @param {String} el The element ID representing the Overlay OR
-* @param {HTMLElement} el The element representing the Overlay
-* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
-*/
-YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
- YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
-
- this.beforeInitEvent.fire(YAHOO.widget.Overlay);
-
- YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
-
- if (this.platform == "mac" && this.browser == "gecko") {
- if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
- this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
- }
- if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
- this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
- }
- }
-
- this.initEvent.fire(YAHOO.widget.Overlay);
-};
-
-/**
-* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
-* @method initEvents
-*/
-YAHOO.widget.Overlay.prototype.initEvents = function() {
- YAHOO.widget.Overlay.superclass.initEvents.call(this);
-
- /**
- * CustomEvent fired before the Overlay is moved.
- * @event beforeMoveEvent
- * @param {Number} x x coordinate
- * @param {Number} y y coordinate
- */
- this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
-
- /**
- * CustomEvent fired after the Overlay is moved.
- * @event moveEvent
- * @param {Number} x x coordinate
- * @param {Number} y y coordinate
- */
- this.moveEvent = new YAHOO.util.CustomEvent("move", this);
-};
-
-/**
-* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
-* @method initDefaultConfig
-*/
-YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
- YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
-
- // Add overlay config properties //
-
- /**
- * The absolute x-coordinate position of the Overlay
- * @config x
- * @type Number
- * @default null
- */
- this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * The absolute y-coordinate position of the Overlay
- * @config y
- * @type Number
- * @default null
- */
- this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * An array with the absolute x and y positions of the Overlay
- * @config xy
- * @type Number[]
- * @default null
- */
- this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner.
- * @config context
- * @type Array
- * @default null
- */
- this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * True if the Overlay should be anchored to the center of the viewport.
- * @config fixedcenter
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
-
- /**
- * CSS width of the Overlay.
- * @config width
- * @type String
- * @default null
- */
- this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * CSS height of the Overlay.
- * @config height
- * @type String
- * @default null
- */
- this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
-
- /**
- * CSS z-index of the Overlay.
- * @config zIndex
- * @type Number
- * @default null
- */
- this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
-
- /**
- * True if the Overlay should be prevented from being positioned out of the viewport.
- * @config constraintoviewport
- * @type Boolean
- * @default false
- */
- this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
-
- /**
- * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below).
- * @config iframe
- * @type Boolean
- * @default true for IE6 and below, false for all others
- */
- this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
-};
-
-/**
-* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
-* @method moveTo
-* @param {Number} x The Overlay's new x position
-* @param {Number} y The Overlay's new y position
-*/
-YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
- this.cfg.setProperty("xy",[x,y]);
-};
-
-/**
-* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
-* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
-* @method hideMacGeckoScrollbars
-*/
-YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
- YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
- YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
-};
-
-/**
-* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
-* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
-* @method showMacGeckoScrollbars
-*/
-YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
- YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
- YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
-};
-
-// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
-
-/**
-* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
-* @method configVisible
-* @param {String} type The CustomEvent type (usually the property name)
-* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
-* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
-*/
-YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
- var visible = args[0];
-
- var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
-
- if (currentVis == "inherit") {
- var e = this.element.parentNode;
- while (e.nodeType != 9 && e.nodeType != 11) {
- currentVis = YAHOO.util.Dom.getStyle(e, "visibility");
- if (currentVis != "inherit") { break; }
- e = e.parentNode;
- }
- if (currentVis == "inherit") {
- currentVis = "visible";
- }
- }
-
- var effect = this.cfg.getProperty("effect");
-
- var effectInstances = [];
- if (effect) {
- if (effect instanceof Array) {
- for (var i=0;i rightConstraint) {
- x = rightConstraint;
- }
-
- if (y < topConstraint) {
- y = topConstraint;
- } else if (y > bottomConstraint) {
- y = bottomConstraint;
- }
-
- this.cfg.setProperty("x", x, true);
- this.cfg.setProperty("y", y, true);
- this.cfg.setProperty("xy", [x,y], true);
-};
-
-/**
-* Centers the container in the viewport.
-* @method center
-*/
-YAHOO.widget.Overlay.prototype.center = function() {
- var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
- var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
-
- var viewPortWidth = YAHOO.util.Dom.getClientWidth();
- var viewPortHeight = YAHOO.util.Dom.getClientHeight();
-
- var elementWidth = this.element.offsetWidth;
- var elementHeight = this.element.offsetHeight;
-
- var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
- var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
-
- this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
-
- this.cfg.refireEvent("iframe");
-};
-
-/**
-* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
-* @method syncPosition
-*/
-YAHOO.widget.Overlay.prototype.syncPosition = function() {
- var pos = YAHOO.util.Dom.getXY(this.element);
- this.cfg.setProperty("x", pos[0], true);
- this.cfg.setProperty("y", pos[1], true);
- this.cfg.setProperty("xy", pos, true);
-};
-
-/**
-* Event handler fired when the resize monitor element is resized.
-* @method onDomResize
-* @param {DOMEvent} e The resize DOM event
-* @param {Object} obj The scope object
-*/
-YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
- YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
- var me = this;
- setTimeout(function() {
- me.syncPosition();
- me.cfg.refireEvent("iframe");
- me.cfg.refireEvent("context");
- }, 0);
-};
-
-/**
-* Removes the Overlay element from the DOM and sets all child elements to null.
-* @method destroy
-*/
-YAHOO.widget.Overlay.prototype.destroy = function() {
- if (this.iframe) {
- this.iframe.parentNode.removeChild(this.iframe);
- }
-
- this.iframe = null;
-
- YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
- YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
-
- YAHOO.widget.Overlay.superclass.destroy.call(this);
-};
-
-/**
-* Returns a String representation of the object.
-* @method toString
-* @return {String} The string representation of the Overlay.
-*/
-YAHOO.widget.Overlay.prototype.toString = function() {
- return "Overlay " + this.id;
-};
-
-/**
-* A singleton CustomEvent used for reacting to the DOM event for window scroll
-* @event YAHOO.widget.Overlay.windowScrollEvent
-*/
-YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
-
-/**
-* A singleton CustomEvent used for reacting to the DOM event for window resize
-* @event YAHOO.widget.Overlay.windowResizeEvent
-*/
-YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
-
-/**
-* The DOM event handler used to fire the CustomEvent for window scroll
-* @method YAHOO.widget.Overlay.windowScrollHandler
-* @static
-* @param {DOMEvent} e The DOM scroll event
-*/
-YAHOO.widget.Overlay.windowScrollHandler = function(e) {
- if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
- if (! window.scrollEnd) {
- window.scrollEnd = -1;
- }
- clearTimeout(window.scrollEnd);
- window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1);
- } else {
- YAHOO.widget.Overlay.windowScrollEvent.fire();
- }
-};
-
-/**
-* The DOM event handler used to fire the CustomEvent for window resize
-* @method YAHOO.widget.Overlay.windowResizeHandler
-* @static
-* @param {DOMEvent} e The DOM resize event
-*/
-YAHOO.widget.Overlay.windowResizeHandler = function(e) {
- if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
- if (! window.resizeEnd) {
- window.resizeEnd = -1;
- }
- clearTimeout(window.resizeEnd);
- window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100);
- } else {
- YAHOO.widget.Overlay.windowResizeEvent.fire();
- }
-};
-
-/**
-* A boolean that indicated whether the window resize and scroll events have already been subscribed to.
-* @property YAHOO.widget.Overlay._initialized
-* @private
-* @type Boolean
-*/
-YAHOO.widget.Overlay._initialized = null;
-
-if (YAHOO.widget.Overlay._initialized === null) {
- YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
- YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
-
- YAHOO.widget.Overlay._initialized = true;
-}
-
-/**
-* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget
-* @namespace YAHOO.widget
-* @class OverlayManager
-* @constructor
-* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
-* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
-*/
-YAHOO.widget.OverlayManager = function(userConfig) {
- this.init(userConfig);
-};
-
-/**
-* The CSS class representing a focused Overlay
-* @property YAHOO.widget.OverlayManager.CSS_FOCUSED
-* @static
-* @final
-* @type String
-*/
-YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
-
-YAHOO.widget.OverlayManager.prototype = {
- /**
- * The class's constructor function
- * @property contructor
- * @type Function
- */
- constructor : YAHOO.widget.OverlayManager,
-
- /**
- * The array of Overlays that are currently registered
- * @property overlays
- * @type YAHOO.widget.Overlay[]
- */
- overlays : null,
-
- /**
- * Initializes the default configuration of the OverlayManager
- * @method initDefaultConfig
- */
- initDefaultConfig : function() {
- /**
- * The collection of registered Overlays in use by the OverlayManager
- * @config overlays
- * @type YAHOO.widget.Overlay[]
- * @default null
- */
- this.cfg.addProperty("overlays", { suppressEvent:true } );
-
- /**
- * The default DOM event that should be used to focus an Overlay
- * @config focusevent
- * @type String
- * @default "mousedown"
- */
- this.cfg.addProperty("focusevent", { value:"mousedown" } );
- },
-
- /**
- * Initializes the OverlayManager
- * @method init
- * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager.
- * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
- */
- init : function(userConfig) {
- /**
- * The OverlayManager's Config object used for monitoring configuration properties.
- * @property cfg
- * @type YAHOO.util.Config
- */
- this.cfg = new YAHOO.util.Config(this);
-
- this.initDefaultConfig();
-
- if (userConfig) {
- this.cfg.applyConfig(userConfig, true);
- }
- this.cfg.fireQueue();
-
- /**
- * The currently activated Overlay
- * @property activeOverlay
- * @private
- * @type YAHOO.widget.Overlay
- */
- var activeOverlay = null;
-
- /**
- * Returns the currently focused Overlay
- * @method getActive
- * @return {YAHOO.widget.Overlay} The currently focused Overlay
- */
- this.getActive = function() {
- return activeOverlay;
- };
-
- /**
- * Focuses the specified Overlay
- * @method focus
- * @param {YAHOO.widget.Overlay} overlay The Overlay to focus
- * @param {String} overlay The id of the Overlay to focus
- */
- this.focus = function(overlay) {
- var o = this.find(overlay);
- if (o) {
- this.blurAll();
- activeOverlay = o;
- YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
- this.overlays.sort(this.compareZIndexDesc);
- var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
- if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
- activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2));
- }
- this.overlays.sort(this.compareZIndexDesc);
- }
- };
-
- /**
- * Removes the specified Overlay from the manager
- * @method remove
- * @param {YAHOO.widget.Overlay} overlay The Overlay to remove
- * @param {String} overlay The id of the Overlay to remove
- */
- this.remove = function(overlay) {
- var o = this.find(overlay);
- if (o) {
- var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
- o.cfg.setProperty("zIndex", -1000, true);
- this.overlays.sort(this.compareZIndexDesc);
- this.overlays = this.overlays.slice(0, this.overlays.length-1);
- o.cfg.setProperty("zIndex", originalZ, true);
-
- o.cfg.setProperty("manager", null);
- o.focusEvent = null;
- o.blurEvent = null;
- o.focus = null;
- o.blur = null;
- }
- };
-
- /**
- * Removes focus from all registered Overlays in the manager
- * @method blurAll
- */
- this.blurAll = function() {
- activeOverlay = null;
- for (var o=0;o 0) {
- return true;
- }
- } else {
- return false;
- }
- },
-
- /**
- * Attempts to locate an Overlay by instance or ID.
- * @method find
- * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager
- * @param {String} overlay An Overlay id to locate within the manager
- * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located.
- */
- find : function(overlay) {
- if (overlay instanceof YAHOO.widget.Overlay) {
- for (var o=0;o zIndex2) {
- return -1;
- } else if (zIndex1 < zIndex2) {
- return 1;
- } else {
- return 0;
- }
- },
-
- /**
- * Shows all Overlays in the manager.
- * @method showAll
- */
- showAll : function() {
- for (var o=0;oOR
+* @param {HTMLElement} el The element representing the Module
+* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+*/
+YAHOO.widget.Module = function(el, userConfig) {
+ if (el) {
+ this.init(el, userConfig);
+ }
+};
+
+/**
+* Constant representing the prefix path to use for non-secure images
+* @property YAHOO.widget.Module.IMG_ROOT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
+
+/**
+* Constant representing the prefix path to use for securely served images
+* @property YAHOO.widget.Module.IMG_ROOT_SSL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
+
+/**
+* Constant for the default CSS class name that represents a Module
+* @property YAHOO.widget.Module.CSS_MODULE
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_MODULE = "module";
+
+/**
+* Constant representing the module header
+* @property YAHOO.widget.Module.CSS_HEADER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_HEADER = "hd";
+
+/**
+* Constant representing the module body
+* @property YAHOO.widget.Module.CSS_BODY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_BODY = "bd";
+
+/**
+* Constant representing the module footer
+* @property YAHOO.widget.Module.CSS_FOOTER
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.CSS_FOOTER = "ft";
+
+/**
+* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
+* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";
+
+/**
+* Singleton CustomEvent fired when the font size is changed in the browser.
+* Opera's "zoom" functionality currently does not support text size detection.
+* @event YAHOO.widget.Module.textResizeEvent
+*/
+YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");
+
+YAHOO.widget.Module.prototype = {
+ /**
+ * The class's constructor function
+ * @property contructor
+ * @type Function
+ */
+ constructor : YAHOO.widget.Module,
+
+ /**
+ * The main module element that contains the header, body, and footer
+ * @property element
+ * @type HTMLElement
+ */
+ element : null,
+
+ /**
+ * The header element, denoted with CSS class "hd"
+ * @property header
+ * @type HTMLElement
+ */
+ header : null,
+
+ /**
+ * The body element, denoted with CSS class "bd"
+ * @property body
+ * @type HTMLElement
+ */
+ body : null,
+
+ /**
+ * The footer element, denoted with CSS class "ft"
+ * @property footer
+ * @type HTMLElement
+ */
+ footer : null,
+
+ /**
+ * The id of the element
+ * @property id
+ * @type String
+ */
+ id : null,
+
+ /**
+ * The String representing the image root
+ * @property imageRoot
+ * @type String
+ */
+ imageRoot : YAHOO.widget.Module.IMG_ROOT,
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ * @method initEvents
+ */
+ initEvents : function() {
+
+ /**
+ * CustomEvent fired prior to class initalization.
+ * @event beforeInitEvent
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ */
+ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
+
+ /**
+ * CustomEvent fired after class initalization.
+ * @event initEvent
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ */
+ this.initEvent = new YAHOO.util.CustomEvent("init");
+
+ /**
+ * CustomEvent fired when the Module is appended to the DOM
+ * @event appendEvent
+ */
+ this.appendEvent = new YAHOO.util.CustomEvent("append");
+
+ /**
+ * CustomEvent fired before the Module is rendered
+ * @event beforeRenderEvent
+ */
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+
+ /**
+ * CustomEvent fired after the Module is rendered
+ * @event renderEvent
+ */
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ /**
+ * CustomEvent fired when the header content of the Module is modified
+ * @event changeHeaderEvent
+ * @param {String/HTMLElement} content String/element representing the new header content
+ */
+ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
+
+ /**
+ * CustomEvent fired when the body content of the Module is modified
+ * @event changeBodyEvent
+ * @param {String/HTMLElement} content String/element representing the new body content
+ */
+ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
+
+ /**
+ * CustomEvent fired when the footer content of the Module is modified
+ * @event changeFooterEvent
+ * @param {String/HTMLElement} content String/element representing the new footer content
+ */
+ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
+
+ /**
+ * CustomEvent fired when the content of the Module is modified
+ * @event changeContentEvent
+ */
+ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
+
+ /**
+ * CustomEvent fired when the Module is destroyed
+ * @event destroyEvent
+ */
+ this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
+
+ /**
+ * CustomEvent fired before the Module is shown
+ * @event beforeShowEvent
+ */
+ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
+
+ /**
+ * CustomEvent fired after the Module is shown
+ * @event showEvent
+ */
+ this.showEvent = new YAHOO.util.CustomEvent("show");
+
+ /**
+ * CustomEvent fired before the Module is hidden
+ * @event beforeHideEvent
+ */
+ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
+
+ /**
+ * CustomEvent fired after the Module is hidden
+ * @event hideEvent
+ */
+ this.hideEvent = new YAHOO.util.CustomEvent("hide");
+ },
+
+ /**
+ * String representing the current user-agent platform
+ * @property platform
+ * @type String
+ */
+ platform : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
+ return "windows";
+ } else if (ua.indexOf("macintosh") != -1) {
+ return "mac";
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * String representing the current user-agent browser
+ * @property browser
+ * @type String
+ */
+ browser : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
+ return 'opera';
+ } else if (ua.indexOf('msie 7')!=-1) { // IE7
+ return 'ie7';
+ } else if (ua.indexOf('msie') !=-1) { // IE
+ return 'ie';
+ } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ } else if (ua.indexOf('gecko') != -1) { // Gecko
+ return 'gecko';
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Boolean representing whether or not the current browsing context is secure (https)
+ * @property isSecure
+ * @type Boolean
+ */
+ isSecure : function() {
+ if (window.location.href.toLowerCase().indexOf("https") === 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initDefaultConfig : function() {
+ // Add properties //
+
+ /**
+ * Specifies whether the Module is visible on the page.
+ * @config visible
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
+
+ /**
+ * Object or array of objects representing the ContainerEffect classes that are active for animating the container.
+ * @config effect
+ * @type Object
+ * @default null
+ */
+ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
+
+ /**
+ * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document
+ * @config monitorresize
+ * @type Boolean
+ * @default true
+ */
+ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
+ },
+
+ /**
+ * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+ * @method init
+ * @param {String} el The element ID representing the Module OR
+ * @param {HTMLElement} el The element representing the Module
+ * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+ */
+ init : function(el, userConfig) {
+
+ this.initEvents();
+
+ this.beforeInitEvent.fire(YAHOO.widget.Module);
+
+ /**
+ * The Module's Config object used for monitoring configuration properties.
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ if (this.isSecure) {
+ this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
+ }
+
+ if (typeof el == "string") {
+ var elId = el;
+
+ el = document.getElementById(el);
+ if (! el) {
+ el = document.createElement("DIV");
+ el.id = elId;
+ }
+ }
+
+ this.element = el;
+
+ if (el.id) {
+ this.id = el.id;
+ }
+
+ var childNodes = this.element.childNodes;
+
+ if (childNodes) {
+ for (var i=0;iOR
+ * @param {HTMLElement} headerContent The HTMLElement to append to the header
+ */
+ setHeader : function(headerContent) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ if (typeof headerContent == "string") {
+ this.header.innerHTML = headerContent;
+ } else {
+ this.header.innerHTML = "";
+ this.header.appendChild(headerContent);
+ }
+
+ this.changeHeaderEvent.fire(headerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the header. If no header is present, one will be automatically created.
+ * @method appendToHeader
+ * @param {HTMLElement} element The element to append to the header
+ */
+ appendToHeader : function(element) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ this.header.appendChild(element);
+ this.changeHeaderEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
+ * @method setBody
+ * @param {String} bodyContent The HTML used to set the body OR
+ * @param {HTMLElement} bodyContent The HTMLElement to append to the body
+ */
+ setBody : function(bodyContent) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ if (typeof bodyContent == "string")
+ {
+ this.body.innerHTML = bodyContent;
+ } else {
+ this.body.innerHTML = "";
+ this.body.appendChild(bodyContent);
+ }
+
+ this.changeBodyEvent.fire(bodyContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the body. If no body is present, one will be automatically created.
+ * @method appendToBody
+ * @param {HTMLElement} element The element to append to the body
+ */
+ appendToBody : function(element) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ this.body.appendChild(element);
+ this.changeBodyEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @method setFooter
+ * @param {String} footerContent The HTML used to set the footer OR
+ * @param {HTMLElement} footerContent The HTMLElement to append to the footer
+ */
+ setFooter : function(footerContent) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ if (typeof footerContent == "string") {
+ this.footer.innerHTML = footerContent;
+ } else {
+ this.footer.innerHTML = "";
+ this.footer.appendChild(footerContent);
+ }
+
+ this.changeFooterEvent.fire(footerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @method appendToFooter
+ * @param {HTMLElement} element The element to append to the footer
+ */
+ appendToFooter : function(element) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ this.footer.appendChild(element);
+ this.changeFooterEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+ * @method render
+ * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering OR
+ * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
+ * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
+ * @return {Boolean} Success or failure of the render
+ */
+ render : function(appendToNode, moduleElement) {
+ this.beforeRenderEvent.fire();
+
+ if (! moduleElement) {
+ moduleElement = this.element;
+ }
+
+ var me = this;
+ var appendTo = function(element) {
+ if (typeof element == "string") {
+ element = document.getElementById(element);
+ }
+
+ if (element) {
+ element.appendChild(me.element);
+ me.appendEvent.fire();
+ }
+ };
+
+ if (appendToNode) {
+ appendTo(appendToNode);
+ } else { // No node was passed in. If the element is not pre-marked up, this fails
+ if (! YAHOO.util.Dom.inDocument(this.element)) {
+ return false;
+ }
+ }
+
+ // Need to get everything into the DOM if it isn't already
+
+ if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
+ // There is a header, but it's not in the DOM yet... need to add it
+ var firstChild = moduleElement.firstChild;
+ if (firstChild) { // Insert before first child if exists
+ moduleElement.insertBefore(this.header, firstChild);
+ } else { // Append to empty body because there are no children
+ moduleElement.appendChild(this.header);
+ }
+ }
+
+ if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
+ // There is a body, but it's not in the DOM yet... need to add it
+ if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
+ moduleElement.insertBefore(this.body, this.footer);
+ } else { // Append to element because there is no footer
+ moduleElement.appendChild(this.body);
+ }
+ }
+
+ if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
+ // There is a footer, but it's not in the DOM yet... need to add it
+ moduleElement.appendChild(this.footer);
+ }
+
+ this.renderEvent.fire();
+ return true;
+ },
+
+ /**
+ * Removes the Module element from the DOM and sets all child elements to null.
+ * @method destroy
+ */
+ destroy : function() {
+ var parent;
+
+ if (this.element) {
+ YAHOO.util.Event.purgeElement(this.element, true);
+ parent = this.element.parentNode;
+ }
+ if (parent) {
+ parent.removeChild(this.element);
+ }
+
+ this.element = null;
+ this.header = null;
+ this.body = null;
+ this.footer = null;
+
+ for (var e in this) {
+ if (e instanceof YAHOO.util.CustomEvent) {
+ e.unsubscribeAll();
+ }
+ }
+
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this);
+
+ this.destroyEvent.fire();
+ },
+
+ /**
+ * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
+ * @method show
+ */
+ show : function() {
+ this.cfg.setProperty("visible", true);
+ },
+
+ /**
+ * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
+ * @method hide
+ */
+ hide : function() {
+ this.cfg.setProperty("visible", false);
+ },
+
+ // BUILT-IN EVENT HANDLERS FOR MODULE //
+
+ /**
+ * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
+ * This method is responsible for firing showEvent and hideEvent.
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ * @method configVisible
+ */
+ configVisible : function(type, args, obj) {
+ var visible = args[0];
+ if (visible) {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "block");
+ this.showEvent.fire();
+ } else {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "none");
+ this.hideEvent.fire();
+ }
+ },
+
+ /**
+ * Default event handler for the "monitorresize" configuration property
+ * @param {String} type The CustomEvent type (usually the property name)
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+ * @method configMonitorResize
+ */
+ configMonitorResize : function(type, args, obj) {
+ var monitor = args[0];
+ if (monitor) {
+ this.initResizeMonitor();
+ } else {
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this, true);
+ this.resizeMonitor = null;
+ }
+ }
+};
+
+/**
+* Returns a String representation of the Object.
+* @method toString
+* @return {String} The string representation of the Module
+*/
+YAHOO.widget.Module.prototype.toString = function() {
+ return "Module " + this.id;
+};
+
+/**
+* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
+* @namespace YAHOO.widget
+* @class Overlay
+* @extends YAHOO.widget.Module
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Overlay = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
+};
+
+YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
+
+/**
+* The URL that will be placed in the iframe
+* @property YAHOO.widget.Overlay.IFRAME_SRC
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;";
+
+/**
+* Constant representing the top left corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.TOP_LEFT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.TOP_LEFT = "tl";
+
+/**
+* Constant representing the top right corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.TOP_RIGHT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.TOP_RIGHT = "tr";
+
+/**
+* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.BOTTOM_LEFT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
+
+/**
+* Constant representing the bottom right corner of an element, used for configuring the context element alignment
+* @property YAHOO.widget.Overlay.BOTTOM_RIGHT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
+
+/**
+* Constant representing the default CSS class used for an Overlay
+* @property YAHOO.widget.Overlay.CSS_OVERLAY
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @method init
+* @param {String} el The element ID representing the Overlay OR
+* @param {HTMLElement} el The element representing the Overlay
+* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Overlay);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ if (this.platform == "mac" && this.browser == "gecko") {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
+ this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
+ this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
+ }
+ }
+
+ this.initEvent.fire(YAHOO.widget.Overlay);
+};
+
+/**
+* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
+* @method initEvents
+*/
+YAHOO.widget.Overlay.prototype.initEvents = function() {
+ YAHOO.widget.Overlay.superclass.initEvents.call(this);
+
+ /**
+ * CustomEvent fired before the Overlay is moved.
+ * @event beforeMoveEvent
+ * @param {Number} x x coordinate
+ * @param {Number} y y coordinate
+ */
+ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
+
+ /**
+ * CustomEvent fired after the Overlay is moved.
+ * @event moveEvent
+ * @param {Number} x x coordinate
+ * @param {Number} y y coordinate
+ */
+ this.moveEvent = new YAHOO.util.CustomEvent("move", this);
+};
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+* @method initDefaultConfig
+*/
+YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
+
+ // Add overlay config properties //
+
+ /**
+ * The absolute x-coordinate position of the Overlay
+ * @config x
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * The absolute y-coordinate position of the Overlay
+ * @config y
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * An array with the absolute x and y positions of the Overlay
+ * @config xy
+ * @type Number[]
+ * @default null
+ */
+ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner.
+ * @config context
+ * @type Array
+ * @default null
+ */
+ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * True if the Overlay should be anchored to the center of the viewport.
+ * @config fixedcenter
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
+
+ /**
+ * CSS width of the Overlay.
+ * @config width
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * CSS height of the Overlay.
+ * @config height
+ * @type String
+ * @default null
+ */
+ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
+
+ /**
+ * CSS z-index of the Overlay.
+ * @config zIndex
+ * @type Number
+ * @default null
+ */
+ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
+
+ /**
+ * True if the Overlay should be prevented from being positioned out of the viewport.
+ * @config constraintoviewport
+ * @type Boolean
+ * @default false
+ */
+ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
+
+ /**
+ * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below).
+ * @config iframe
+ * @type Boolean
+ * @default true for IE6 and below, false for all others
+ */
+ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
+};
+
+/**
+* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
+* @method moveTo
+* @param {Number} x The Overlay's new x position
+* @param {Number} y The Overlay's new y position
+*/
+YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
+ this.cfg.setProperty("xy",[x,y]);
+};
+
+/**
+* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+* @method hideMacGeckoScrollbars
+*/
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
+};
+
+/**
+* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+* @method showMacGeckoScrollbars
+*/
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
+};
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
+* @method configVisible
+* @param {String} type The CustomEvent type (usually the property name)
+* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
+* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
+*/
+YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
+ var visible = args[0];
+
+ var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
+
+ if (currentVis == "inherit") {
+ var e = this.element.parentNode;
+ while (e.nodeType != 9 && e.nodeType != 11) {
+ currentVis = YAHOO.util.Dom.getStyle(e, "visibility");
+ if (currentVis != "inherit") { break; }
+ e = e.parentNode;
+ }
+ if (currentVis == "inherit") {
+ currentVis = "visible";
+ }
+ }
+
+ var effect = this.cfg.getProperty("effect");
+
+ var effectInstances = [];
+ if (effect) {
+ if (effect instanceof Array) {
+ for (var i=0;i rightConstraint) {
+ x = rightConstraint;
+ }
+
+ if (y < topConstraint) {
+ y = topConstraint;
+ } else if (y > bottomConstraint) {
+ y = bottomConstraint;
+ }
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+ this.cfg.setProperty("xy", [x,y], true);
+};
+
+/**
+* Centers the container in the viewport.
+* @method center
+*/
+YAHOO.widget.Overlay.prototype.center = function() {
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+
+ var viewPortWidth = YAHOO.util.Dom.getClientWidth();
+ var viewPortHeight = YAHOO.util.Dom.getClientHeight();
+
+ var elementWidth = this.element.offsetWidth;
+ var elementHeight = this.element.offsetHeight;
+
+ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
+ var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
+
+ this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
+
+ this.cfg.refireEvent("iframe");
+};
+
+/**
+* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
+* @method syncPosition
+*/
+YAHOO.widget.Overlay.prototype.syncPosition = function() {
+ var pos = YAHOO.util.Dom.getXY(this.element);
+ this.cfg.setProperty("x", pos[0], true);
+ this.cfg.setProperty("y", pos[1], true);
+ this.cfg.setProperty("xy", pos, true);
+};
+
+/**
+* Event handler fired when the resize monitor element is resized.
+* @method onDomResize
+* @param {DOMEvent} e The resize DOM event
+* @param {Object} obj The scope object
+*/
+YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
+ var me = this;
+ setTimeout(function() {
+ me.syncPosition();
+ me.cfg.refireEvent("iframe");
+ me.cfg.refireEvent("context");
+ }, 0);
+};
+
+/**
+* Removes the Overlay element from the DOM and sets all child elements to null.
+* @method destroy
+*/
+YAHOO.widget.Overlay.prototype.destroy = function() {
+ if (this.iframe) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+
+ this.iframe = null;
+
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+
+ YAHOO.widget.Overlay.superclass.destroy.call(this);
+};
+
+/**
+* Returns a String representation of the object.
+* @method toString
+* @return {String} The string representation of the Overlay.
+*/
+YAHOO.widget.Overlay.prototype.toString = function() {
+ return "Overlay " + this.id;
+};
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window scroll
+* @event YAHOO.widget.Overlay.windowScrollEvent
+*/
+YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window resize
+* @event YAHOO.widget.Overlay.windowResizeEvent
+*/
+YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
+
+/**
+* The DOM event handler used to fire the CustomEvent for window scroll
+* @method YAHOO.widget.Overlay.windowScrollHandler
+* @static
+* @param {DOMEvent} e The DOM scroll event
+*/
+YAHOO.widget.Overlay.windowScrollHandler = function(e) {
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
+ if (! window.scrollEnd) {
+ window.scrollEnd = -1;
+ }
+ clearTimeout(window.scrollEnd);
+ window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1);
+ } else {
+ YAHOO.widget.Overlay.windowScrollEvent.fire();
+ }
+};
+
+/**
+* The DOM event handler used to fire the CustomEvent for window resize
+* @method YAHOO.widget.Overlay.windowResizeHandler
+* @static
+* @param {DOMEvent} e The DOM resize event
+*/
+YAHOO.widget.Overlay.windowResizeHandler = function(e) {
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
+ if (! window.resizeEnd) {
+ window.resizeEnd = -1;
+ }
+ clearTimeout(window.resizeEnd);
+ window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100);
+ } else {
+ YAHOO.widget.Overlay.windowResizeEvent.fire();
+ }
+};
+
+/**
+* A boolean that indicated whether the window resize and scroll events have already been subscribed to.
+* @property YAHOO.widget.Overlay._initialized
+* @private
+* @type Boolean
+*/
+YAHOO.widget.Overlay._initialized = null;
+
+if (YAHOO.widget.Overlay._initialized === null) {
+ YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
+ YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
+
+ YAHOO.widget.Overlay._initialized = true;
+}
+
+/**
+* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget
+* @namespace YAHOO.widget
+* @class OverlayManager
+* @constructor
+* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
+*/
+YAHOO.widget.OverlayManager = function(userConfig) {
+ this.init(userConfig);
+};
+
+/**
+* The CSS class representing a focused Overlay
+* @property YAHOO.widget.OverlayManager.CSS_FOCUSED
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
+
+YAHOO.widget.OverlayManager.prototype = {
+ /**
+ * The class's constructor function
+ * @property contructor
+ * @type Function
+ */
+ constructor : YAHOO.widget.OverlayManager,
+
+ /**
+ * The array of Overlays that are currently registered
+ * @property overlays
+ * @type YAHOO.widget.Overlay[]
+ */
+ overlays : null,
+
+ /**
+ * Initializes the default configuration of the OverlayManager
+ * @method initDefaultConfig
+ */
+ initDefaultConfig : function() {
+ /**
+ * The collection of registered Overlays in use by the OverlayManager
+ * @config overlays
+ * @type YAHOO.widget.Overlay[]
+ * @default null
+ */
+ this.cfg.addProperty("overlays", { suppressEvent:true } );
+
+ /**
+ * The default DOM event that should be used to focus an Overlay
+ * @config focusevent
+ * @type String
+ * @default "mousedown"
+ */
+ this.cfg.addProperty("focusevent", { value:"mousedown" } );
+ },
+
+ /**
+ * Initializes the OverlayManager
+ * @method init
+ * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager.
+ * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
+ */
+ init : function(userConfig) {
+ /**
+ * The OverlayManager's Config object used for monitoring configuration properties.
+ * @property cfg
+ * @type YAHOO.util.Config
+ */
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+ this.cfg.fireQueue();
+
+ /**
+ * The currently activated Overlay
+ * @property activeOverlay
+ * @private
+ * @type YAHOO.widget.Overlay
+ */
+ var activeOverlay = null;
+
+ /**
+ * Returns the currently focused Overlay
+ * @method getActive
+ * @return {YAHOO.widget.Overlay} The currently focused Overlay
+ */
+ this.getActive = function() {
+ return activeOverlay;
+ };
+
+ /**
+ * Focuses the specified Overlay
+ * @method focus
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to focus
+ * @param {String} overlay The id of the Overlay to focus
+ */
+ this.focus = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ this.blurAll();
+ activeOverlay = o;
+ YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ this.overlays.sort(this.compareZIndexDesc);
+ var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
+ if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
+ activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2));
+ }
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ };
+
+ /**
+ * Removes the specified Overlay from the manager
+ * @method remove
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to remove
+ * @param {String} overlay The id of the Overlay to remove
+ */
+ this.remove = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
+ o.cfg.setProperty("zIndex", -1000, true);
+ this.overlays.sort(this.compareZIndexDesc);
+ this.overlays = this.overlays.slice(0, this.overlays.length-1);
+ o.cfg.setProperty("zIndex", originalZ, true);
+
+ o.cfg.setProperty("manager", null);
+ o.focusEvent = null;
+ o.blurEvent = null;
+ o.focus = null;
+ o.blur = null;
+ }
+ };
+
+ /**
+ * Removes focus from all registered Overlays in the manager
+ * @method blurAll
+ */
+ this.blurAll = function() {
+ activeOverlay = null;
+ for (var o=0;o 0) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Attempts to locate an Overlay by instance or ID.
+ * @method find
+ * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager
+ * @param {String} overlay An Overlay id to locate within the manager
+ * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located.
+ */
+ find : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ for (var o=0;o zIndex2) {
+ return -1;
+ } else if (zIndex1 < zIndex2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ },
+
+ /**
+ * Shows all Overlays in the manager.
+ * @method showAll
+ */
+ showAll : function() {
+ for (var o=0;o -1),
- isSafari = (ua.indexOf('safari') > -1),
- isGecko = (!isOpera && !isSafari && ua.indexOf('gecko') > -1),
- isIE = (!isOpera && ua.indexOf('msie') > -1);
-
- // regex cache
- var patterns = {
- HYPHEN: /(-[a-z])/i
- };
-
- var logger = {};
- logger.log = function() { YAHOO.log.apply(window, arguments); };
-
- var toCamel = function(property) {
- if ( !patterns.HYPHEN.test(property) ) {
- return property; // no hyphens
- }
-
- if (propertyCache[property]) { // already converted
- return propertyCache[property];
- }
-
- while( patterns.HYPHEN.exec(property) ) {
- property = property.replace(RegExp.$1,
- RegExp.$1.substr(1).toUpperCase());
- }
-
- propertyCache[property] = property;
- return property;
- //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
- };
-
- // branching at load instead of runtime
- if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method
- getStyle = function(el, property) {
- var value = null;
-
- var computed = document.defaultView.getComputedStyle(el, '');
- if (computed) { // test computed before touching for safari
- value = computed[toCamel(property)];
- }
-
- return el.style[property] || value;
- };
- } else if (document.documentElement.currentStyle && isIE) { // IE method
- getStyle = function(el, property) {
- switch( toCamel(property) ) {
- case 'opacity' :// IE opacity uses filter
- var val = 100;
- try { // will error if no DXImageTransform
- val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
-
- } catch(e) {
- try { // make sure its in the document
- val = el.filters('alpha').opacity;
- } catch(e) {
- logger.log('getStyle: IE filter failed',
- 'error', 'Dom');
- }
- }
- return val / 100;
- break;
- default:
- // test currentStyle before touching
- var value = el.currentStyle ? el.currentStyle[property] : null;
- return ( el.style[property] || value );
- }
- };
- } else { // default to inline only
- getStyle = function(el, property) { return el.style[property]; };
- }
-
- if (isIE) {
- setStyle = function(el, property, val) {
- switch (property) {
- case 'opacity':
- if ( typeof el.style.filter == 'string' ) { // in case not appended
- el.style.filter = 'alpha(opacity=' + val * 100 + ')';
-
- if (!el.currentStyle || !el.currentStyle.hasLayout) {
- el.style.zoom = 1; // when no layout or cant tell
- }
- }
- break;
- default:
- el.style[property] = val;
- }
- };
- } else {
- setStyle = function(el, property, val) {
- el.style[property] = val;
- };
- }
-
- /**
- * Provides helper methods for DOM elements.
- * @namespace YAHOO.util
- * @class Dom
- */
- YAHOO.util.Dom = {
- /**
- * Returns an HTMLElement reference.
- * @method get
- * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements.
- */
- get: function(el) {
- if (!el) { return null; } // nothing to work with
-
- if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is
- logger.log('get(' + el + ') returning ' + el, 'info', 'Dom');
- return el;
- }
-
- if (typeof el == 'string') { // ID
- logger.log('get("' + el + '") returning ' + document.getElementById(el), 'info', 'Dom');
- return document.getElementById(el);
- }
- else { // array of ID's and/or elements
- var collection = [];
- for (var i = 0, len = el.length; i < len; ++i) {
- collection[collection.length] = Y.Dom.get(el[i]);
- }
-
- logger.log('get("' + el + '") returning ' + collection, 'info', 'Dom');
- return collection;
- }
-
- logger.log('element ' + el + ' not found', 'error', 'Dom');
- return null; // safety, should never happen
- },
-
- /**
- * Normalizes currentStyle and ComputedStyle.
- * @method getStyle
- * @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @param {String} property The style property whose value is returned.
- * @return {String | Array} The current value of the style property for the element(s).
- */
- getStyle: function(el, property) {
- property = toCamel(property);
-
- var f = function(element) {
- return getStyle(element, property);
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers.
- * @method setStyle
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @param {String} property The style property to be set.
- * @param {String} val The value to apply to the given property.
- */
- setStyle: function(el, property, val) {
- property = toCamel(property);
-
- var f = function(element) {
- setStyle(element, property, val);
- logger.log('setStyle setting ' + property + ' to ' + val, 'info', 'Dom');
-
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method getXY
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
- * @return {Array} The XY position of the element(s)
- */
- getXY: function(el) {
- var f = function(el) {
-
- // has to be part of document to have pageXY
- if (el.parentNode === null || el.offsetParent === null ||
- this.getStyle(el, 'display') == 'none') {
- logger.log('getXY failed: element not available', 'error', 'Dom');
- return false;
- }
-
- var parentNode = null;
- var pos = [];
- var box;
-
- if (el.getBoundingClientRect) { // IE
- box = el.getBoundingClientRect();
- var doc = document;
- if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll
- doc = parent.document;
-
- if ( !this.isAncestor(doc.documentElement, el) ) {
- logger.log('getXY failed: element not available', 'error', 'Dom');
- return false;
- }
-
- }
-
- var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
- var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
-
- return [box.left + scrollLeft, box.top + scrollTop];
- }
- else { // safari, opera, & gecko
- pos = [el.offsetLeft, el.offsetTop];
- parentNode = el.offsetParent;
- if (parentNode != el) {
- while (parentNode) {
- pos[0] += parentNode.offsetLeft;
- pos[1] += parentNode.offsetTop;
- parentNode = parentNode.offsetParent;
- }
- }
- if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases
- pos[0] -= document.body.offsetLeft;
- pos[1] -= document.body.offsetTop;
- }
- }
-
- if (el.parentNode) { parentNode = el.parentNode; }
- else { parentNode = null; }
-
- while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
- { // account for any scrolled ancestors
- if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { // work around opera inline scrollLeft/Top bug
- pos[0] -= parentNode.scrollLeft;
- pos[1] -= parentNode.scrollTop;
- }
-
- if (parentNode.parentNode) {
- parentNode = parentNode.parentNode;
- } else { parentNode = null; }
- }
-
- logger.log('getXY returning ' + pos, 'info', 'Dom');
-
- return pos;
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method getX
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
- * @return {String | Array} The X position of the element(s)
- */
- getX: function(el) {
- var f = function(el) {
- return Y.Dom.getXY(el)[0];
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method getY
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
- * @return {String | Array} The Y position of the element(s)
- */
- getY: function(el) {
- var f = function(el) {
- return Y.Dom.getXY(el)[1];
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Set the position of an html element in page coordinates, regardless of how the element is positioned.
- * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method setXY
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
- * @param {Array} pos Contains X & Y values for new position (coordinates are page-based)
- * @param {Boolean} noRetry By default we try and set the position a second time if the first fails
- */
- setXY: function(el, pos, noRetry) {
- var f = function(el) {
- var style_pos = this.getStyle(el, 'position');
- if (style_pos == 'static') { // default to relative
- this.setStyle(el, 'position', 'relative');
- style_pos = 'relative';
- }
-
- var pageXY = this.getXY(el);
- if (pageXY === false) { // has to be part of doc to have pageXY
- logger.log('setXY failed: element not available', 'error', 'Dom');
- return false;
- }
-
- var delta = [ // assuming pixels; if not we will have to retry
- parseInt( this.getStyle(el, 'left'), 10 ),
- parseInt( this.getStyle(el, 'top'), 10 )
- ];
-
- if ( isNaN(delta[0]) ) {// in case of 'auto'
- delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
- }
- if ( isNaN(delta[1]) ) { // in case of 'auto'
- delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
- }
-
- if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
- if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }
-
- if (!noRetry) {
- var newXY = this.getXY(el);
-
- // if retry is true, try one more time if we miss
- if ( (pos[0] !== null && newXY[0] != pos[0]) ||
- (pos[1] !== null && newXY[1] != pos[1]) ) {
- this.setXY(el, pos, true);
- }
- }
-
- logger.log('setXY setting position to ' + pos, 'info', 'Dom');
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Set the X position of an html element in page coordinates, regardless of how the element is positioned.
- * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method setX
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @param {Int} x The value to use as the X coordinate for the element(s).
- */
- setX: function(el, x) {
- Y.Dom.setXY(el, [x, null]);
- },
-
- /**
- * Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
- * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method setY
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @param {Int} x To use as the Y coordinate for the element(s).
- */
- setY: function(el, y) {
- Y.Dom.setXY(el, [null, y]);
- },
-
- /**
- * Returns the region position of the given element.
- * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
- * @method getRegion
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @return {Region | Array} A Region or array of Region instances containing "top, left, bottom, right" member data.
- */
- getRegion: function(el) {
- var f = function(el) {
- var region = new Y.Region.getRegion(el);
- logger.log('getRegion returning ' + region, 'info', 'Dom');
- return region;
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Returns the width of the client (viewport).
- * @method getClientWidth
- * @deprecated Now using getViewportWidth. This interface left intact for back compat.
- * @return {Int} The width of the viewable area of the page.
- */
- getClientWidth: function() {
- return Y.Dom.getViewportWidth();
- },
-
- /**
- * Returns the height of the client (viewport).
- * @method getClientHeight
- * @deprecated Now using getViewportHeight. This interface left intact for back compat.
- * @return {Int} The height of the viewable area of the page.
- */
- getClientHeight: function() {
- return Y.Dom.getViewportHeight();
- },
-
- /**
- * Returns a array of HTMLElements with the given class.
- * For optimized performance, include a tag and/or root node when possible.
- * @method getElementsByClassName
- * @param {String} className The class name to match against
- * @param {String} tag (optional) The tag name of the elements being collected
- * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
- * @return {Array} An array of elements that have the given class name
- */
- getElementsByClassName: function(className, tag, root) {
- var method = function(el) { return Y.Dom.hasClass(el, className); };
- return Y.Dom.getElementsBy(method, tag, root);
- },
-
- /**
- * Determines whether an HTMLElement has the given className.
- * @method hasClass
- * @param {String | HTMLElement | Array} el The element or collection to test
- * @param {String} className the class name to search for
- * @return {Boolean | Array} A boolean value or array of boolean values
- */
- hasClass: function(el, className) {
- var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
-
- var f = function(el) {
- logger.log('hasClass returning ' + re.test(el['className']), 'info', 'Dom');
- return re.test(el['className']);
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Adds a class name to a given element or collection of elements.
- * @method addClass
- * @param {String | HTMLElement | Array} el The element or collection to add the class to
- * @param {String} className the class name to add to the class attribute
- */
- addClass: function(el, className) {
- var f = function(el) {
- if (this.hasClass(el, className)) { return; } // already present
-
- logger.log('addClass adding ' + className, 'info', 'Dom');
-
- el['className'] = [el['className'], className].join(' ');
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Removes a class name from a given element or collection of elements.
- * @method removeClass
- * @param {String | HTMLElement | Array} el The element or collection to remove the class from
- * @param {String} className the class name to remove from the class attribute
- */
- removeClass: function(el, className) {
- var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
-
- var f = function(el) {
- if (!this.hasClass(el, className)) { return; } // not present
-
- logger.log('removeClass removing ' + className, 'info', 'Dom');
-
- var c = el['className'];
- el['className'] = c.replace(re, ' ');
- if ( this.hasClass(el, className) ) { // in case of multiple adjacent
- this.removeClass(el, className);
- }
-
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Replace a class with another class for a given element or collection of elements.
- * If no oldClassName is present, the newClassName is simply added.
- * @method replaceClass
- * @param {String | HTMLElement | Array} el The element or collection to remove the class from
- * @param {String} oldClassName the class name to be replaced
- * @param {String} newClassName the class name that will be replacing the old class name
- */
- replaceClass: function(el, oldClassName, newClassName) {
- if (oldClassName === newClassName) { // avoid infinite loop
- return false;
- }
-
- var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');
-
- var f = function(el) {
- logger.log('replaceClass replacing ' + oldClassName + ' with ' + newClassName, 'info', 'Dom');
-
- if ( !this.hasClass(el, oldClassName) ) {
- this.addClass(el, newClassName); // just add it if nothing to replace
- return; // note return
- }
-
- el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
-
- if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
- this.replaceClass(el, oldClassName, newClassName);
- }
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Generates a unique ID
- * @method generateId
- * @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present).
- * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen").
- * @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
- */
- generateId: function(el, prefix) {
- prefix = prefix || 'yui-gen';
- el = el || {};
-
- var f = function(el) {
- if (el) {
- el = Y.Dom.get(el);
- } else {
- el = {}; // just generating ID in this case
- }
-
- if (!el.id) {
- el.id = prefix + id_counter++;
- logger.log('generateId generating ' + el.id, 'info', 'Dom');
- } // dont override existing
-
- logger.log('generateId returning ' + el.id, 'info', 'Dom');
-
- return el.id;
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy.
- * @method isAncestor
- * @param {String | HTMLElement} haystack The possible ancestor
- * @param {String | HTMLElement} needle The possible descendent
- * @return {Boolean} Whether or not the haystack is an ancestor of needle
- */
- isAncestor: function(haystack, needle) {
- haystack = Y.Dom.get(haystack);
- if (!haystack || !needle) { return false; }
-
- var f = function(needle) {
- if (haystack.contains && !isSafari) { // safari "contains" is broken
- logger.log('isAncestor returning ' + haystack.contains(needle), 'info', 'Dom');
- return haystack.contains(needle);
- }
- else if ( haystack.compareDocumentPosition ) {
- logger.log('isAncestor returning ' + !!(haystack.compareDocumentPosition(needle) & 16), 'info', 'Dom');
- return !!(haystack.compareDocumentPosition(needle) & 16);
- }
- else { // loop up and test each parent
- var parent = needle.parentNode;
-
- while (parent) {
- if (parent == haystack) {
- logger.log('isAncestor returning true', 'info', 'Dom');
- return true;
- }
- else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') {
- logger.log('isAncestor returning false', 'info', 'Dom');
- return false;
- }
-
- parent = parent.parentNode;
- }
- logger.log('isAncestor returning false', 'info', 'Dom');
- return false;
- }
- };
-
- return Y.Dom.batch(needle, f, Y.Dom, true);
- },
-
- /**
- * Determines whether an HTMLElement is present in the current document.
- * @method inDocument
- * @param {String | HTMLElement} el The element to search for
- * @return {Boolean} Whether or not the element is present in the current document
- */
- inDocument: function(el) {
- var f = function(el) {
- return this.isAncestor(document.documentElement, el);
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Returns a array of HTMLElements that pass the test applied by supplied boolean method.
- * For optimized performance, include a tag and/or root node when possible.
- * @method getElementsBy
- * @param {Function} method - A boolean method for testing elements which receives the element as its only argument.
-
- * @param {String} tag (optional) The tag name of the elements being collected
- * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
- */
- getElementsBy: function(method, tag, root) {
- tag = tag || '*';
-
- var nodes = [];
-
- if (root) {
- root = Y.Dom.get(root);
- if (!root) { // if no root node, then no children
- return nodes;
- }
- } else {
- root = document;
- }
-
- var elements = root.getElementsByTagName(tag);
-
- if ( !elements.length && (tag == '*' && root.all) ) {
- elements = root.all; // IE < 6
- }
-
- for (var i = 0, len = elements.length; i < len; ++i) {
- if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; }
- }
-
- logger.log('getElementsBy returning ' + nodes, 'info', 'Dom');
-
- return nodes;
- },
-
- /**
- * Returns an array of elements that have had the supplied method applied.
- * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ).
- * @method batch
- * @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to
- * @param {Function} method The method to apply to the element(s)
- * @param {Any} o (optional) An optional arg that is passed to the supplied method
- * @param {Boolean} override (optional) Whether or not to override the scope of "method" with "o"
- * @return {HTMLElement | Array} The element(s) with the method applied
- */
- batch: function(el, method, o, override) {
- var id = el;
- el = Y.Dom.get(el);
-
- var scope = (override) ? o : window;
-
- if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection)
- if (!el) {
- logger.log(id + ' not available', 'error', 'Dom');
- return false;
- }
- return method.call(scope, el, o);
- }
-
- var collection = [];
-
- for (var i = 0, len = el.length; i < len; ++i) {
- if (!el[i]) {
- id = el[i];
- logger.log(id + ' not available', 'error', 'Dom');
- }
- collection[collection.length] = method.call(scope, el[i], o);
- }
-
- return collection;
- },
-
- /**
- * Returns the height of the document.
- * @method getDocumentHeight
- * @return {Int} The height of the actual document (which includes the body and its margin).
- */
- getDocumentHeight: function() {
- var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;
-
- var h = Math.max(scrollHeight, Y.Dom.getViewportHeight());
- logger.log('getDocumentHeight returning ' + h, 'info', 'Dom');
- return h;
- },
-
- /**
- * Returns the width of the document.
- * @method getDocumentWidth
- * @return {Int} The width of the actual document (which includes the body and its margin).
- */
- getDocumentWidth: function() {
- var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth;
- var w = Math.max(scrollWidth, Y.Dom.getViewportWidth());
- logger.log('getDocumentWidth returning ' + w, 'info', 'Dom');
- return w;
- },
-
- /**
- * Returns the current height of the viewport.
- * @method getViewportHeight
- * @return {Int} The height of the viewable area of the page (excludes scrollbars).
- */
- getViewportHeight: function() {
- var height = self.innerHeight; // Safari, Opera
- var mode = document.compatMode;
-
- if ( (mode || isIE) && !isOpera ) { // IE, Gecko
- height = (mode == 'CSS1Compat') ?
- document.documentElement.clientHeight : // Standards
- document.body.clientHeight; // Quirks
- }
-
- logger.log('getViewportHeight returning ' + height, 'info', 'Dom');
- return height;
- },
-
- /**
- * Returns the current width of the viewport.
- * @method getViewportWidth
- * @return {Int} The width of the viewable area of the page (excludes scrollbars).
- */
-
- getViewportWidth: function() {
- var width = self.innerWidth; // Safari
- var mode = document.compatMode;
-
- if (mode || isIE) { // IE, Gecko, Opera
- width = (mode == 'CSS1Compat') ?
- document.documentElement.clientWidth : // Standards
- document.body.clientWidth; // Quirks
- }
- logger.log('getViewportWidth returning ' + width, 'info', 'Dom');
- return width;
- }
- };
-})();
-/**
- * A region is a representation of an object on a grid. It is defined
- * by the top, right, bottom, left extents, so is rectangular by default. If
- * other shapes are required, this class could be extended to support it.
- * @namespace YAHOO.util
- * @class Region
- * @param {Int} t the top extent
- * @param {Int} r the right extent
- * @param {Int} b the bottom extent
- * @param {Int} l the left extent
- * @constructor
- */
-YAHOO.util.Region = function(t, r, b, l) {
-
- /**
- * The region's top extent
- * @property top
- * @type Int
- */
- this.top = t;
-
- /**
- * The region's top extent as index, for symmetry with set/getXY
- * @property 1
- * @type Int
- */
- this[1] = t;
-
- /**
- * The region's right extent
- * @property right
- * @type int
- */
- this.right = r;
-
- /**
- * The region's bottom extent
- * @property bottom
- * @type Int
- */
- this.bottom = b;
-
- /**
- * The region's left extent
- * @property left
- * @type Int
- */
- this.left = l;
-
- /**
- * The region's left extent as index, for symmetry with set/getXY
- * @property 0
- * @type Int
- */
- this[0] = l;
-};
-
-/**
- * Returns true if this region contains the region passed in
- * @method contains
- * @param {Region} region The region to evaluate
- * @return {Boolean} True if the region is contained with this region,
- * else false
- */
-YAHOO.util.Region.prototype.contains = function(region) {
- return ( region.left >= this.left &&
- region.right <= this.right &&
- region.top >= this.top &&
- region.bottom <= this.bottom );
-
- // this.logger.debug("does " + this + " contain " + region + " ... " + ret);
-};
-
-/**
- * Returns the area of the region
- * @method getArea
- * @return {Int} the region's area
- */
-YAHOO.util.Region.prototype.getArea = function() {
- return ( (this.bottom - this.top) * (this.right - this.left) );
-};
-
-/**
- * Returns the region where the passed in region overlaps with this one
- * @method intersect
- * @param {Region} region The region that intersects
- * @return {Region} The overlap region, or null if there is no overlap
- */
-YAHOO.util.Region.prototype.intersect = function(region) {
- var t = Math.max( this.top, region.top );
- var r = Math.min( this.right, region.right );
- var b = Math.min( this.bottom, region.bottom );
- var l = Math.max( this.left, region.left );
-
- if (b >= t && r >= l) {
- return new YAHOO.util.Region(t, r, b, l);
- } else {
- return null;
- }
-};
-
-/**
- * Returns the region representing the smallest region that can contain both
- * the passed in region and this region.
- * @method union
- * @param {Region} region The region that to create the union with
- * @return {Region} The union region
- */
-YAHOO.util.Region.prototype.union = function(region) {
- var t = Math.min( this.top, region.top );
- var r = Math.max( this.right, region.right );
- var b = Math.max( this.bottom, region.bottom );
- var l = Math.min( this.left, region.left );
-
- return new YAHOO.util.Region(t, r, b, l);
-};
-
-/**
- * toString
- * @method toString
- * @return string the region properties
- */
-YAHOO.util.Region.prototype.toString = function() {
- return ( "Region {" +
- "top: " + this.top +
- ", right: " + this.right +
- ", bottom: " + this.bottom +
- ", left: " + this.left +
- "}" );
-};
-
-/**
- * Returns a region that is occupied by the DOM element
- * @method getRegion
- * @param {HTMLElement} el The element
- * @return {Region} The region that the element occupies
- * @static
- */
-YAHOO.util.Region.getRegion = function(el) {
- var p = YAHOO.util.Dom.getXY(el);
-
- var t = p[1];
- var r = p[0] + el.offsetWidth;
- var b = p[1] + el.offsetHeight;
- var l = p[0];
-
- return new YAHOO.util.Region(t, r, b, l);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-
-/**
- * A point is a region that is special in that it represents a single point on
- * the grid.
- * @namespace YAHOO.util
- * @class Point
- * @param {Int} x The X position of the point
- * @param {Int} y The Y position of the point
- * @constructor
- * @extends YAHOO.util.Region
- */
-YAHOO.util.Point = function(x, y) {
- if (x instanceof Array) { // accept output from Dom.getXY
- y = x[1];
- x = x[0];
- }
-
- /**
- * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry)
- * @property x
- * @type Int
- */
-
- this.x = this.right = this.left = this[0] = x;
-
- /**
- * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry)
- * @property y
- * @type Int
- */
- this.y = this.top = this.bottom = this[1] = y;
-};
-
-YAHOO.util.Point.prototype = new YAHOO.util.Region();
-
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/**
+ * The dom module provides helper methods for manipulating Dom elements.
+ * @module dom
+ *
+ */
+
+(function() {
+ var Y = YAHOO.util, // internal shorthand
+ getStyle, // for load time browser branching
+ setStyle, // ditto
+ id_counter = 0, // for use with generateId
+ propertyCache = {}; // for faster hyphen converts
+
+ // brower detection
+ var ua = navigator.userAgent.toLowerCase(),
+ isOpera = (ua.indexOf('opera') > -1),
+ isSafari = (ua.indexOf('safari') > -1),
+ isGecko = (!isOpera && !isSafari && ua.indexOf('gecko') > -1),
+ isIE = (!isOpera && ua.indexOf('msie') > -1);
+
+ // regex cache
+ var patterns = {
+ HYPHEN: /(-[a-z])/i
+ };
+
+ var logger = {};
+ logger.log = function() { YAHOO.log.apply(window, arguments); };
+
+ var toCamel = function(property) {
+ if ( !patterns.HYPHEN.test(property) ) {
+ return property; // no hyphens
+ }
+
+ if (propertyCache[property]) { // already converted
+ return propertyCache[property];
+ }
+
+ while( patterns.HYPHEN.exec(property) ) {
+ property = property.replace(RegExp.$1,
+ RegExp.$1.substr(1).toUpperCase());
+ }
+
+ propertyCache[property] = property;
+ return property;
+ //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
+ };
+
+ // branching at load instead of runtime
+ if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method
+ getStyle = function(el, property) {
+ var value = null;
+
+ var computed = document.defaultView.getComputedStyle(el, '');
+ if (computed) { // test computed before touching for safari
+ value = computed[toCamel(property)];
+ }
+
+ return el.style[property] || value;
+ };
+ } else if (document.documentElement.currentStyle && isIE) { // IE method
+ getStyle = function(el, property) {
+ switch( toCamel(property) ) {
+ case 'opacity' :// IE opacity uses filter
+ var val = 100;
+ try { // will error if no DXImageTransform
+ val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
+
+ } catch(e) {
+ try { // make sure its in the document
+ val = el.filters('alpha').opacity;
+ } catch(e) {
+ logger.log('getStyle: IE filter failed',
+ 'error', 'Dom');
+ }
+ }
+ return val / 100;
+ break;
+ default:
+ // test currentStyle before touching
+ var value = el.currentStyle ? el.currentStyle[property] : null;
+ return ( el.style[property] || value );
+ }
+ };
+ } else { // default to inline only
+ getStyle = function(el, property) { return el.style[property]; };
+ }
+
+ if (isIE) {
+ setStyle = function(el, property, val) {
+ switch (property) {
+ case 'opacity':
+ if ( typeof el.style.filter == 'string' ) { // in case not appended
+ el.style.filter = 'alpha(opacity=' + val * 100 + ')';
+
+ if (!el.currentStyle || !el.currentStyle.hasLayout) {
+ el.style.zoom = 1; // when no layout or cant tell
+ }
+ }
+ break;
+ default:
+ el.style[property] = val;
+ }
+ };
+ } else {
+ setStyle = function(el, property, val) {
+ el.style[property] = val;
+ };
+ }
+
+ /**
+ * Provides helper methods for DOM elements.
+ * @namespace YAHOO.util
+ * @class Dom
+ */
+ YAHOO.util.Dom = {
+ /**
+ * Returns an HTMLElement reference.
+ * @method get
+ * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements.
+ */
+ get: function(el) {
+ if (!el) { return null; } // nothing to work with
+
+ if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is
+ logger.log('get(' + el + ') returning ' + el, 'info', 'Dom');
+ return el;
+ }
+
+ if (typeof el == 'string') { // ID
+ logger.log('get("' + el + '") returning ' + document.getElementById(el), 'info', 'Dom');
+ return document.getElementById(el);
+ }
+ else { // array of ID's and/or elements
+ var collection = [];
+ for (var i = 0, len = el.length; i < len; ++i) {
+ collection[collection.length] = Y.Dom.get(el[i]);
+ }
+
+ logger.log('get("' + el + '") returning ' + collection, 'info', 'Dom');
+ return collection;
+ }
+
+ logger.log('element ' + el + ' not found', 'error', 'Dom');
+ return null; // safety, should never happen
+ },
+
+ /**
+ * Normalizes currentStyle and ComputedStyle.
+ * @method getStyle
+ * @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {String} property The style property whose value is returned.
+ * @return {String | Array} The current value of the style property for the element(s).
+ */
+ getStyle: function(el, property) {
+ property = toCamel(property);
+
+ var f = function(element) {
+ return getStyle(element, property);
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers.
+ * @method setStyle
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {String} property The style property to be set.
+ * @param {String} val The value to apply to the given property.
+ */
+ setStyle: function(el, property, val) {
+ property = toCamel(property);
+
+ var f = function(element) {
+ setStyle(element, property, val);
+ logger.log('setStyle setting ' + property + ' to ' + val, 'info', 'Dom');
+
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method getXY
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {Array} The XY position of the element(s)
+ */
+ getXY: function(el) {
+ var f = function(el) {
+
+ // has to be part of document to have pageXY
+ if (el.parentNode === null || el.offsetParent === null ||
+ this.getStyle(el, 'display') == 'none') {
+ logger.log('getXY failed: element not available', 'error', 'Dom');
+ return false;
+ }
+
+ var parentNode = null;
+ var pos = [];
+ var box;
+
+ if (el.getBoundingClientRect) { // IE
+ box = el.getBoundingClientRect();
+ var doc = document;
+ if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll
+ doc = parent.document;
+
+ if ( !this.isAncestor(doc.documentElement, el) ) {
+ logger.log('getXY failed: element not available', 'error', 'Dom');
+ return false;
+ }
+
+ }
+
+ var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
+ var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
+
+ return [box.left + scrollLeft, box.top + scrollTop];
+ }
+ else { // safari, opera, & gecko
+ pos = [el.offsetLeft, el.offsetTop];
+ parentNode = el.offsetParent;
+ if (parentNode != el) {
+ while (parentNode) {
+ pos[0] += parentNode.offsetLeft;
+ pos[1] += parentNode.offsetTop;
+ parentNode = parentNode.offsetParent;
+ }
+ }
+ if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases
+ pos[0] -= document.body.offsetLeft;
+ pos[1] -= document.body.offsetTop;
+ }
+ }
+
+ if (el.parentNode) { parentNode = el.parentNode; }
+ else { parentNode = null; }
+
+ while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
+ { // account for any scrolled ancestors
+ if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { // work around opera inline scrollLeft/Top bug
+ pos[0] -= parentNode.scrollLeft;
+ pos[1] -= parentNode.scrollTop;
+ }
+
+ if (parentNode.parentNode) {
+ parentNode = parentNode.parentNode;
+ } else { parentNode = null; }
+ }
+
+ logger.log('getXY returning ' + pos, 'info', 'Dom');
+
+ return pos;
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method getX
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {String | Array} The X position of the element(s)
+ */
+ getX: function(el) {
+ var f = function(el) {
+ return Y.Dom.getXY(el)[0];
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method getY
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {String | Array} The Y position of the element(s)
+ */
+ getY: function(el) {
+ var f = function(el) {
+ return Y.Dom.getXY(el)[1];
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Set the position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method setXY
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @param {Array} pos Contains X & Y values for new position (coordinates are page-based)
+ * @param {Boolean} noRetry By default we try and set the position a second time if the first fails
+ */
+ setXY: function(el, pos, noRetry) {
+ var f = function(el) {
+ var style_pos = this.getStyle(el, 'position');
+ if (style_pos == 'static') { // default to relative
+ this.setStyle(el, 'position', 'relative');
+ style_pos = 'relative';
+ }
+
+ var pageXY = this.getXY(el);
+ if (pageXY === false) { // has to be part of doc to have pageXY
+ logger.log('setXY failed: element not available', 'error', 'Dom');
+ return false;
+ }
+
+ var delta = [ // assuming pixels; if not we will have to retry
+ parseInt( this.getStyle(el, 'left'), 10 ),
+ parseInt( this.getStyle(el, 'top'), 10 )
+ ];
+
+ if ( isNaN(delta[0]) ) {// in case of 'auto'
+ delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
+ }
+ if ( isNaN(delta[1]) ) { // in case of 'auto'
+ delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
+ }
+
+ if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
+ if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }
+
+ if (!noRetry) {
+ var newXY = this.getXY(el);
+
+ // if retry is true, try one more time if we miss
+ if ( (pos[0] !== null && newXY[0] != pos[0]) ||
+ (pos[1] !== null && newXY[1] != pos[1]) ) {
+ this.setXY(el, pos, true);
+ }
+ }
+
+ logger.log('setXY setting position to ' + pos, 'info', 'Dom');
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Set the X position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method setX
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {Int} x The value to use as the X coordinate for the element(s).
+ */
+ setX: function(el, x) {
+ Y.Dom.setXY(el, [x, null]);
+ },
+
+ /**
+ * Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method setY
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {Int} x To use as the Y coordinate for the element(s).
+ */
+ setY: function(el, y) {
+ Y.Dom.setXY(el, [null, y]);
+ },
+
+ /**
+ * Returns the region position of the given element.
+ * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
+ * @method getRegion
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @return {Region | Array} A Region or array of Region instances containing "top, left, bottom, right" member data.
+ */
+ getRegion: function(el) {
+ var f = function(el) {
+ var region = new Y.Region.getRegion(el);
+ logger.log('getRegion returning ' + region, 'info', 'Dom');
+ return region;
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Returns the width of the client (viewport).
+ * @method getClientWidth
+ * @deprecated Now using getViewportWidth. This interface left intact for back compat.
+ * @return {Int} The width of the viewable area of the page.
+ */
+ getClientWidth: function() {
+ return Y.Dom.getViewportWidth();
+ },
+
+ /**
+ * Returns the height of the client (viewport).
+ * @method getClientHeight
+ * @deprecated Now using getViewportHeight. This interface left intact for back compat.
+ * @return {Int} The height of the viewable area of the page.
+ */
+ getClientHeight: function() {
+ return Y.Dom.getViewportHeight();
+ },
+
+ /**
+ * Returns a array of HTMLElements with the given class.
+ * For optimized performance, include a tag and/or root node when possible.
+ * @method getElementsByClassName
+ * @param {String} className The class name to match against
+ * @param {String} tag (optional) The tag name of the elements being collected
+ * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+ * @return {Array} An array of elements that have the given class name
+ */
+ getElementsByClassName: function(className, tag, root) {
+ var method = function(el) { return Y.Dom.hasClass(el, className); };
+ return Y.Dom.getElementsBy(method, tag, root);
+ },
+
+ /**
+ * Determines whether an HTMLElement has the given className.
+ * @method hasClass
+ * @param {String | HTMLElement | Array} el The element or collection to test
+ * @param {String} className the class name to search for
+ * @return {Boolean | Array} A boolean value or array of boolean values
+ */
+ hasClass: function(el, className) {
+ var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
+
+ var f = function(el) {
+ logger.log('hasClass returning ' + re.test(el['className']), 'info', 'Dom');
+ return re.test(el['className']);
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Adds a class name to a given element or collection of elements.
+ * @method addClass
+ * @param {String | HTMLElement | Array} el The element or collection to add the class to
+ * @param {String} className the class name to add to the class attribute
+ */
+ addClass: function(el, className) {
+ var f = function(el) {
+ if (this.hasClass(el, className)) { return; } // already present
+
+ logger.log('addClass adding ' + className, 'info', 'Dom');
+
+ el['className'] = [el['className'], className].join(' ');
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Removes a class name from a given element or collection of elements.
+ * @method removeClass
+ * @param {String | HTMLElement | Array} el The element or collection to remove the class from
+ * @param {String} className the class name to remove from the class attribute
+ */
+ removeClass: function(el, className) {
+ var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
+
+ var f = function(el) {
+ if (!this.hasClass(el, className)) { return; } // not present
+
+ logger.log('removeClass removing ' + className, 'info', 'Dom');
+
+ var c = el['className'];
+ el['className'] = c.replace(re, ' ');
+ if ( this.hasClass(el, className) ) { // in case of multiple adjacent
+ this.removeClass(el, className);
+ }
+
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Replace a class with another class for a given element or collection of elements.
+ * If no oldClassName is present, the newClassName is simply added.
+ * @method replaceClass
+ * @param {String | HTMLElement | Array} el The element or collection to remove the class from
+ * @param {String} oldClassName the class name to be replaced
+ * @param {String} newClassName the class name that will be replacing the old class name
+ */
+ replaceClass: function(el, oldClassName, newClassName) {
+ if (oldClassName === newClassName) { // avoid infinite loop
+ return false;
+ }
+
+ var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');
+
+ var f = function(el) {
+ logger.log('replaceClass replacing ' + oldClassName + ' with ' + newClassName, 'info', 'Dom');
+
+ if ( !this.hasClass(el, oldClassName) ) {
+ this.addClass(el, newClassName); // just add it if nothing to replace
+ return; // note return
+ }
+
+ el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
+
+ if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
+ this.replaceClass(el, oldClassName, newClassName);
+ }
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Generates a unique ID
+ * @method generateId
+ * @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present).
+ * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen").
+ * @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
+ */
+ generateId: function(el, prefix) {
+ prefix = prefix || 'yui-gen';
+ el = el || {};
+
+ var f = function(el) {
+ if (el) {
+ el = Y.Dom.get(el);
+ } else {
+ el = {}; // just generating ID in this case
+ }
+
+ if (!el.id) {
+ el.id = prefix + id_counter++;
+ logger.log('generateId generating ' + el.id, 'info', 'Dom');
+ } // dont override existing
+
+ logger.log('generateId returning ' + el.id, 'info', 'Dom');
+
+ return el.id;
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy.
+ * @method isAncestor
+ * @param {String | HTMLElement} haystack The possible ancestor
+ * @param {String | HTMLElement} needle The possible descendent
+ * @return {Boolean} Whether or not the haystack is an ancestor of needle
+ */
+ isAncestor: function(haystack, needle) {
+ haystack = Y.Dom.get(haystack);
+ if (!haystack || !needle) { return false; }
+
+ var f = function(needle) {
+ if (haystack.contains && !isSafari) { // safari "contains" is broken
+ logger.log('isAncestor returning ' + haystack.contains(needle), 'info', 'Dom');
+ return haystack.contains(needle);
+ }
+ else if ( haystack.compareDocumentPosition ) {
+ logger.log('isAncestor returning ' + !!(haystack.compareDocumentPosition(needle) & 16), 'info', 'Dom');
+ return !!(haystack.compareDocumentPosition(needle) & 16);
+ }
+ else { // loop up and test each parent
+ var parent = needle.parentNode;
+
+ while (parent) {
+ if (parent == haystack) {
+ logger.log('isAncestor returning true', 'info', 'Dom');
+ return true;
+ }
+ else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') {
+ logger.log('isAncestor returning false', 'info', 'Dom');
+ return false;
+ }
+
+ parent = parent.parentNode;
+ }
+ logger.log('isAncestor returning false', 'info', 'Dom');
+ return false;
+ }
+ };
+
+ return Y.Dom.batch(needle, f, Y.Dom, true);
+ },
+
+ /**
+ * Determines whether an HTMLElement is present in the current document.
+ * @method inDocument
+ * @param {String | HTMLElement} el The element to search for
+ * @return {Boolean} Whether or not the element is present in the current document
+ */
+ inDocument: function(el) {
+ var f = function(el) {
+ return this.isAncestor(document.documentElement, el);
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Returns a array of HTMLElements that pass the test applied by supplied boolean method.
+ * For optimized performance, include a tag and/or root node when possible.
+ * @method getElementsBy
+ * @param {Function} method - A boolean method for testing elements which receives the element as its only argument.
+
+ * @param {String} tag (optional) The tag name of the elements being collected
+ * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+ */
+ getElementsBy: function(method, tag, root) {
+ tag = tag || '*';
+
+ var nodes = [];
+
+ if (root) {
+ root = Y.Dom.get(root);
+ if (!root) { // if no root node, then no children
+ return nodes;
+ }
+ } else {
+ root = document;
+ }
+
+ var elements = root.getElementsByTagName(tag);
+
+ if ( !elements.length && (tag == '*' && root.all) ) {
+ elements = root.all; // IE < 6
+ }
+
+ for (var i = 0, len = elements.length; i < len; ++i) {
+ if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; }
+ }
+
+ logger.log('getElementsBy returning ' + nodes, 'info', 'Dom');
+
+ return nodes;
+ },
+
+ /**
+ * Returns an array of elements that have had the supplied method applied.
+ * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ).
+ * @method batch
+ * @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to
+ * @param {Function} method The method to apply to the element(s)
+ * @param {Any} o (optional) An optional arg that is passed to the supplied method
+ * @param {Boolean} override (optional) Whether or not to override the scope of "method" with "o"
+ * @return {HTMLElement | Array} The element(s) with the method applied
+ */
+ batch: function(el, method, o, override) {
+ var id = el;
+ el = Y.Dom.get(el);
+
+ var scope = (override) ? o : window;
+
+ if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection)
+ if (!el) {
+ logger.log(id + ' not available', 'error', 'Dom');
+ return false;
+ }
+ return method.call(scope, el, o);
+ }
+
+ var collection = [];
+
+ for (var i = 0, len = el.length; i < len; ++i) {
+ if (!el[i]) {
+ id = el[i];
+ logger.log(id + ' not available', 'error', 'Dom');
+ }
+ collection[collection.length] = method.call(scope, el[i], o);
+ }
+
+ return collection;
+ },
+
+ /**
+ * Returns the height of the document.
+ * @method getDocumentHeight
+ * @return {Int} The height of the actual document (which includes the body and its margin).
+ */
+ getDocumentHeight: function() {
+ var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;
+
+ var h = Math.max(scrollHeight, Y.Dom.getViewportHeight());
+ logger.log('getDocumentHeight returning ' + h, 'info', 'Dom');
+ return h;
+ },
+
+ /**
+ * Returns the width of the document.
+ * @method getDocumentWidth
+ * @return {Int} The width of the actual document (which includes the body and its margin).
+ */
+ getDocumentWidth: function() {
+ var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth;
+ var w = Math.max(scrollWidth, Y.Dom.getViewportWidth());
+ logger.log('getDocumentWidth returning ' + w, 'info', 'Dom');
+ return w;
+ },
+
+ /**
+ * Returns the current height of the viewport.
+ * @method getViewportHeight
+ * @return {Int} The height of the viewable area of the page (excludes scrollbars).
+ */
+ getViewportHeight: function() {
+ var height = self.innerHeight; // Safari, Opera
+ var mode = document.compatMode;
+
+ if ( (mode || isIE) && !isOpera ) { // IE, Gecko
+ height = (mode == 'CSS1Compat') ?
+ document.documentElement.clientHeight : // Standards
+ document.body.clientHeight; // Quirks
+ }
+
+ logger.log('getViewportHeight returning ' + height, 'info', 'Dom');
+ return height;
+ },
+
+ /**
+ * Returns the current width of the viewport.
+ * @method getViewportWidth
+ * @return {Int} The width of the viewable area of the page (excludes scrollbars).
+ */
+
+ getViewportWidth: function() {
+ var width = self.innerWidth; // Safari
+ var mode = document.compatMode;
+
+ if (mode || isIE) { // IE, Gecko, Opera
+ width = (mode == 'CSS1Compat') ?
+ document.documentElement.clientWidth : // Standards
+ document.body.clientWidth; // Quirks
+ }
+ logger.log('getViewportWidth returning ' + width, 'info', 'Dom');
+ return width;
+ }
+ };
+})();
+/**
+ * A region is a representation of an object on a grid. It is defined
+ * by the top, right, bottom, left extents, so is rectangular by default. If
+ * other shapes are required, this class could be extended to support it.
+ * @namespace YAHOO.util
+ * @class Region
+ * @param {Int} t the top extent
+ * @param {Int} r the right extent
+ * @param {Int} b the bottom extent
+ * @param {Int} l the left extent
+ * @constructor
+ */
+YAHOO.util.Region = function(t, r, b, l) {
+
+ /**
+ * The region's top extent
+ * @property top
+ * @type Int
+ */
+ this.top = t;
+
+ /**
+ * The region's top extent as index, for symmetry with set/getXY
+ * @property 1
+ * @type Int
+ */
+ this[1] = t;
+
+ /**
+ * The region's right extent
+ * @property right
+ * @type int
+ */
+ this.right = r;
+
+ /**
+ * The region's bottom extent
+ * @property bottom
+ * @type Int
+ */
+ this.bottom = b;
+
+ /**
+ * The region's left extent
+ * @property left
+ * @type Int
+ */
+ this.left = l;
+
+ /**
+ * The region's left extent as index, for symmetry with set/getXY
+ * @property 0
+ * @type Int
+ */
+ this[0] = l;
+};
+
+/**
+ * Returns true if this region contains the region passed in
+ * @method contains
+ * @param {Region} region The region to evaluate
+ * @return {Boolean} True if the region is contained with this region,
+ * else false
+ */
+YAHOO.util.Region.prototype.contains = function(region) {
+ return ( region.left >= this.left &&
+ region.right <= this.right &&
+ region.top >= this.top &&
+ region.bottom <= this.bottom );
+
+ // this.logger.debug("does " + this + " contain " + region + " ... " + ret);
+};
+
+/**
+ * Returns the area of the region
+ * @method getArea
+ * @return {Int} the region's area
+ */
+YAHOO.util.Region.prototype.getArea = function() {
+ return ( (this.bottom - this.top) * (this.right - this.left) );
+};
+
+/**
+ * Returns the region where the passed in region overlaps with this one
+ * @method intersect
+ * @param {Region} region The region that intersects
+ * @return {Region} The overlap region, or null if there is no overlap
+ */
+YAHOO.util.Region.prototype.intersect = function(region) {
+ var t = Math.max( this.top, region.top );
+ var r = Math.min( this.right, region.right );
+ var b = Math.min( this.bottom, region.bottom );
+ var l = Math.max( this.left, region.left );
+
+ if (b >= t && r >= l) {
+ return new YAHOO.util.Region(t, r, b, l);
+ } else {
+ return null;
+ }
+};
+
+/**
+ * Returns the region representing the smallest region that can contain both
+ * the passed in region and this region.
+ * @method union
+ * @param {Region} region The region that to create the union with
+ * @return {Region} The union region
+ */
+YAHOO.util.Region.prototype.union = function(region) {
+ var t = Math.min( this.top, region.top );
+ var r = Math.max( this.right, region.right );
+ var b = Math.max( this.bottom, region.bottom );
+ var l = Math.min( this.left, region.left );
+
+ return new YAHOO.util.Region(t, r, b, l);
+};
+
+/**
+ * toString
+ * @method toString
+ * @return string the region properties
+ */
+YAHOO.util.Region.prototype.toString = function() {
+ return ( "Region {" +
+ "top: " + this.top +
+ ", right: " + this.right +
+ ", bottom: " + this.bottom +
+ ", left: " + this.left +
+ "}" );
+};
+
+/**
+ * Returns a region that is occupied by the DOM element
+ * @method getRegion
+ * @param {HTMLElement} el The element
+ * @return {Region} The region that the element occupies
+ * @static
+ */
+YAHOO.util.Region.getRegion = function(el) {
+ var p = YAHOO.util.Dom.getXY(el);
+
+ var t = p[1];
+ var r = p[0] + el.offsetWidth;
+ var b = p[1] + el.offsetHeight;
+ var l = p[0];
+
+ return new YAHOO.util.Region(t, r, b, l);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * A point is a region that is special in that it represents a single point on
+ * the grid.
+ * @namespace YAHOO.util
+ * @class Point
+ * @param {Int} x The X position of the point
+ * @param {Int} y The Y position of the point
+ * @constructor
+ * @extends YAHOO.util.Region
+ */
+YAHOO.util.Point = function(x, y) {
+ if (x instanceof Array) { // accept output from Dom.getXY
+ y = x[1];
+ x = x[0];
+ }
+
+ /**
+ * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry)
+ * @property x
+ * @type Int
+ */
+
+ this.x = this.right = this.left = this[0] = x;
+
+ /**
+ * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry)
+ * @property y
+ * @type Int
+ */
+ this.y = this.top = this.bottom = this[1] = y;
+};
+
+YAHOO.util.Point.prototype = new YAHOO.util.Region();
+
diff --git a/lib/yui/dom/dom-min.js b/lib/yui/dom/dom-min.js
index 1cbbc7aba5..36e62f93a3 100755
--- a/lib/yui/dom/dom-min.js
+++ b/lib/yui/dom/dom-min.js
@@ -1,53 +1,59 @@
-/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.12.1 */
-(function(){var Y=YAHOO.util,getStyle,setStyle,id_counter=0,propertyCache={};var ua=navigator.userAgent.toLowerCase(),isOpera=(ua.indexOf('opera')>-1),isSafari=(ua.indexOf('safari')>-1),isGecko=(!isOpera&&!isSafari&&ua.indexOf('gecko')>-1),isIE=(!isOpera&&ua.indexOf('msie')>-1);var patterns={HYPHEN:/(-[a-z])/i};var toCamel=function(property){if(!patterns.HYPHEN.test(property)){return property;}
-if(propertyCache[property]){return propertyCache[property];}
-while(patterns.HYPHEN.exec(property)){property=property.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());}
-propertyCache[property]=property;return property;};if(document.defaultView&&document.defaultView.getComputedStyle){getStyle=function(el,property){var value=null;var computed=document.defaultView.getComputedStyle(el,'');if(computed){value=computed[toCamel(property)];}
-return el.style[property]||value;};}else if(document.documentElement.currentStyle&&isIE){getStyle=function(el,property){switch(toCamel(property)){case'opacity':var val=100;try{val=el.filters['DXImageTransform.Microsoft.Alpha'].opacity;}catch(e){try{val=el.filters('alpha').opacity;}catch(e){}}
-return val/100;break;default:var value=el.currentStyle?el.currentStyle[property]:null;return(el.style[property]||value);}};}else{getStyle=function(el,property){return el.style[property];};}
-if(isIE){setStyle=function(el,property,val){switch(property){case'opacity':if(typeof el.style.filter=='string'){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1;}}
-break;default:el.style[property]=val;}};}else{setStyle=function(el,property,val){el.style[property]=val;};}
-YAHOO.util.Dom={get:function(el){if(!el){return null;}
-if(typeof el!='string'&&!(el instanceof Array)){return el;}
-if(typeof el=='string'){return document.getElementById(el);}
-else{var collection=[];for(var i=0,len=el.length;i=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];}
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+
+(function(){var Y=YAHOO.util,getStyle,setStyle,id_counter=0,propertyCache={};var ua=navigator.userAgent.toLowerCase(),isOpera=(ua.indexOf('opera')>-1),isSafari=(ua.indexOf('safari')>-1),isGecko=(!isOpera&&!isSafari&&ua.indexOf('gecko')>-1),isIE=(!isOpera&&ua.indexOf('msie')>-1);var patterns={HYPHEN:/(-[a-z])/i};var toCamel=function(property){if(!patterns.HYPHEN.test(property)){return property;}
+if(propertyCache[property]){return propertyCache[property];}
+while(patterns.HYPHEN.exec(property)){property=property.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());}
+propertyCache[property]=property;return property;};if(document.defaultView&&document.defaultView.getComputedStyle){getStyle=function(el,property){var value=null;var computed=document.defaultView.getComputedStyle(el,'');if(computed){value=computed[toCamel(property)];}
+return el.style[property]||value;};}else if(document.documentElement.currentStyle&&isIE){getStyle=function(el,property){switch(toCamel(property)){case'opacity':var val=100;try{val=el.filters['DXImageTransform.Microsoft.Alpha'].opacity;}catch(e){try{val=el.filters('alpha').opacity;}catch(e){}}
+return val/100;break;default:var value=el.currentStyle?el.currentStyle[property]:null;return(el.style[property]||value);}};}else{getStyle=function(el,property){return el.style[property];};}
+if(isIE){setStyle=function(el,property,val){switch(property){case'opacity':if(typeof el.style.filter=='string'){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1;}}
+break;default:el.style[property]=val;}};}else{setStyle=function(el,property,val){el.style[property]=val;};}
+YAHOO.util.Dom={get:function(el){if(!el){return null;}
+if(typeof el!='string'&&!(el instanceof Array)){return el;}
+if(typeof el=='string'){return document.getElementById(el);}
+else{var collection=[];for(var i=0,len=el.length;i=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];}
this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};YAHOO.util.Point.prototype=new YAHOO.util.Region();
\ No newline at end of file
diff --git a/lib/yui/dom/dom.js b/lib/yui/dom/dom.js
index a823018347..c37bd1b04e 100755
--- a/lib/yui/dom/dom.js
+++ b/lib/yui/dom/dom.js
@@ -1,893 +1,892 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 0.12.1
-*/
-
-/**
- * The dom module provides helper methods for manipulating Dom elements.
- * @module dom
- *
- */
-
-(function() {
- var Y = YAHOO.util, // internal shorthand
- getStyle, // for load time browser branching
- setStyle, // ditto
- id_counter = 0, // for use with generateId
- propertyCache = {}; // for faster hyphen converts
-
- // brower detection
- var ua = navigator.userAgent.toLowerCase(),
- isOpera = (ua.indexOf('opera') > -1),
- isSafari = (ua.indexOf('safari') > -1),
- isGecko = (!isOpera && !isSafari && ua.indexOf('gecko') > -1),
- isIE = (!isOpera && ua.indexOf('msie') > -1);
-
- // regex cache
- var patterns = {
- HYPHEN: /(-[a-z])/i
- };
-
-
- var toCamel = function(property) {
- if ( !patterns.HYPHEN.test(property) ) {
- return property; // no hyphens
- }
-
- if (propertyCache[property]) { // already converted
- return propertyCache[property];
- }
-
- while( patterns.HYPHEN.exec(property) ) {
- property = property.replace(RegExp.$1,
- RegExp.$1.substr(1).toUpperCase());
- }
-
- propertyCache[property] = property;
- return property;
- //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
- };
-
- // branching at load instead of runtime
- if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method
- getStyle = function(el, property) {
- var value = null;
-
- var computed = document.defaultView.getComputedStyle(el, '');
- if (computed) { // test computed before touching for safari
- value = computed[toCamel(property)];
- }
-
- return el.style[property] || value;
- };
- } else if (document.documentElement.currentStyle && isIE) { // IE method
- getStyle = function(el, property) {
- switch( toCamel(property) ) {
- case 'opacity' :// IE opacity uses filter
- var val = 100;
- try { // will error if no DXImageTransform
- val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
-
- } catch(e) {
- try { // make sure its in the document
- val = el.filters('alpha').opacity;
- } catch(e) {
- }
- }
- return val / 100;
- break;
- default:
- // test currentStyle before touching
- var value = el.currentStyle ? el.currentStyle[property] : null;
- return ( el.style[property] || value );
- }
- };
- } else { // default to inline only
- getStyle = function(el, property) { return el.style[property]; };
- }
-
- if (isIE) {
- setStyle = function(el, property, val) {
- switch (property) {
- case 'opacity':
- if ( typeof el.style.filter == 'string' ) { // in case not appended
- el.style.filter = 'alpha(opacity=' + val * 100 + ')';
-
- if (!el.currentStyle || !el.currentStyle.hasLayout) {
- el.style.zoom = 1; // when no layout or cant tell
- }
- }
- break;
- default:
- el.style[property] = val;
- }
- };
- } else {
- setStyle = function(el, property, val) {
- el.style[property] = val;
- };
- }
-
- /**
- * Provides helper methods for DOM elements.
- * @namespace YAHOO.util
- * @class Dom
- */
- YAHOO.util.Dom = {
- /**
- * Returns an HTMLElement reference.
- * @method get
- * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements.
- */
- get: function(el) {
- if (!el) { return null; } // nothing to work with
-
- if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is
- return el;
- }
-
- if (typeof el == 'string') { // ID
- return document.getElementById(el);
- }
- else { // array of ID's and/or elements
- var collection = [];
- for (var i = 0, len = el.length; i < len; ++i) {
- collection[collection.length] = Y.Dom.get(el[i]);
- }
-
- return collection;
- }
-
- return null; // safety, should never happen
- },
-
- /**
- * Normalizes currentStyle and ComputedStyle.
- * @method getStyle
- * @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @param {String} property The style property whose value is returned.
- * @return {String | Array} The current value of the style property for the element(s).
- */
- getStyle: function(el, property) {
- property = toCamel(property);
-
- var f = function(element) {
- return getStyle(element, property);
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers.
- * @method setStyle
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @param {String} property The style property to be set.
- * @param {String} val The value to apply to the given property.
- */
- setStyle: function(el, property, val) {
- property = toCamel(property);
-
- var f = function(element) {
- setStyle(element, property, val);
-
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method getXY
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
- * @return {Array} The XY position of the element(s)
- */
- getXY: function(el) {
- var f = function(el) {
-
- // has to be part of document to have pageXY
- if (el.parentNode === null || el.offsetParent === null ||
- this.getStyle(el, 'display') == 'none') {
- return false;
- }
-
- var parentNode = null;
- var pos = [];
- var box;
-
- if (el.getBoundingClientRect) { // IE
- box = el.getBoundingClientRect();
- var doc = document;
- if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll
- doc = parent.document;
-
- if ( !this.isAncestor(doc.documentElement, el) ) {
- return false;
- }
-
- }
-
- var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
- var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
-
- return [box.left + scrollLeft, box.top + scrollTop];
- }
- else { // safari, opera, & gecko
- pos = [el.offsetLeft, el.offsetTop];
- parentNode = el.offsetParent;
- if (parentNode != el) {
- while (parentNode) {
- pos[0] += parentNode.offsetLeft;
- pos[1] += parentNode.offsetTop;
- parentNode = parentNode.offsetParent;
- }
- }
- if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases
- pos[0] -= document.body.offsetLeft;
- pos[1] -= document.body.offsetTop;
- }
- }
-
- if (el.parentNode) { parentNode = el.parentNode; }
- else { parentNode = null; }
-
- while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
- { // account for any scrolled ancestors
- if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { // work around opera inline scrollLeft/Top bug
- pos[0] -= parentNode.scrollLeft;
- pos[1] -= parentNode.scrollTop;
- }
-
- if (parentNode.parentNode) {
- parentNode = parentNode.parentNode;
- } else { parentNode = null; }
- }
-
-
- return pos;
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method getX
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
- * @return {String | Array} The X position of the element(s)
- */
- getX: function(el) {
- var f = function(el) {
- return Y.Dom.getXY(el)[0];
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method getY
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
- * @return {String | Array} The Y position of the element(s)
- */
- getY: function(el) {
- var f = function(el) {
- return Y.Dom.getXY(el)[1];
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Set the position of an html element in page coordinates, regardless of how the element is positioned.
- * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method setXY
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
- * @param {Array} pos Contains X & Y values for new position (coordinates are page-based)
- * @param {Boolean} noRetry By default we try and set the position a second time if the first fails
- */
- setXY: function(el, pos, noRetry) {
- var f = function(el) {
- var style_pos = this.getStyle(el, 'position');
- if (style_pos == 'static') { // default to relative
- this.setStyle(el, 'position', 'relative');
- style_pos = 'relative';
- }
-
- var pageXY = this.getXY(el);
- if (pageXY === false) { // has to be part of doc to have pageXY
- return false;
- }
-
- var delta = [ // assuming pixels; if not we will have to retry
- parseInt( this.getStyle(el, 'left'), 10 ),
- parseInt( this.getStyle(el, 'top'), 10 )
- ];
-
- if ( isNaN(delta[0]) ) {// in case of 'auto'
- delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
- }
- if ( isNaN(delta[1]) ) { // in case of 'auto'
- delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
- }
-
- if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
- if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }
-
- if (!noRetry) {
- var newXY = this.getXY(el);
-
- // if retry is true, try one more time if we miss
- if ( (pos[0] !== null && newXY[0] != pos[0]) ||
- (pos[1] !== null && newXY[1] != pos[1]) ) {
- this.setXY(el, pos, true);
- }
- }
-
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Set the X position of an html element in page coordinates, regardless of how the element is positioned.
- * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method setX
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @param {Int} x The value to use as the X coordinate for the element(s).
- */
- setX: function(el, x) {
- Y.Dom.setXY(el, [x, null]);
- },
-
- /**
- * Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
- * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
- * @method setY
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @param {Int} x To use as the Y coordinate for the element(s).
- */
- setY: function(el, y) {
- Y.Dom.setXY(el, [null, y]);
- },
-
- /**
- * Returns the region position of the given element.
- * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
- * @method getRegion
- * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
- * @return {Region | Array} A Region or array of Region instances containing "top, left, bottom, right" member data.
- */
- getRegion: function(el) {
- var f = function(el) {
- var region = new Y.Region.getRegion(el);
- return region;
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Returns the width of the client (viewport).
- * @method getClientWidth
- * @deprecated Now using getViewportWidth. This interface left intact for back compat.
- * @return {Int} The width of the viewable area of the page.
- */
- getClientWidth: function() {
- return Y.Dom.getViewportWidth();
- },
-
- /**
- * Returns the height of the client (viewport).
- * @method getClientHeight
- * @deprecated Now using getViewportHeight. This interface left intact for back compat.
- * @return {Int} The height of the viewable area of the page.
- */
- getClientHeight: function() {
- return Y.Dom.getViewportHeight();
- },
-
- /**
- * Returns a array of HTMLElements with the given class.
- * For optimized performance, include a tag and/or root node when possible.
- * @method getElementsByClassName
- * @param {String} className The class name to match against
- * @param {String} tag (optional) The tag name of the elements being collected
- * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
- * @return {Array} An array of elements that have the given class name
- */
- getElementsByClassName: function(className, tag, root) {
- var method = function(el) { return Y.Dom.hasClass(el, className); };
- return Y.Dom.getElementsBy(method, tag, root);
- },
-
- /**
- * Determines whether an HTMLElement has the given className.
- * @method hasClass
- * @param {String | HTMLElement | Array} el The element or collection to test
- * @param {String} className the class name to search for
- * @return {Boolean | Array} A boolean value or array of boolean values
- */
- hasClass: function(el, className) {
- var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
-
- var f = function(el) {
- return re.test(el['className']);
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Adds a class name to a given element or collection of elements.
- * @method addClass
- * @param {String | HTMLElement | Array} el The element or collection to add the class to
- * @param {String} className the class name to add to the class attribute
- */
- addClass: function(el, className) {
- var f = function(el) {
- if (this.hasClass(el, className)) { return; } // already present
-
-
- el['className'] = [el['className'], className].join(' ');
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Removes a class name from a given element or collection of elements.
- * @method removeClass
- * @param {String | HTMLElement | Array} el The element or collection to remove the class from
- * @param {String} className the class name to remove from the class attribute
- */
- removeClass: function(el, className) {
- var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
-
- var f = function(el) {
- if (!this.hasClass(el, className)) { return; } // not present
-
-
- var c = el['className'];
- el['className'] = c.replace(re, ' ');
- if ( this.hasClass(el, className) ) { // in case of multiple adjacent
- this.removeClass(el, className);
- }
-
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Replace a class with another class for a given element or collection of elements.
- * If no oldClassName is present, the newClassName is simply added.
- * @method replaceClass
- * @param {String | HTMLElement | Array} el The element or collection to remove the class from
- * @param {String} oldClassName the class name to be replaced
- * @param {String} newClassName the class name that will be replacing the old class name
- */
- replaceClass: function(el, oldClassName, newClassName) {
- if (oldClassName === newClassName) { // avoid infinite loop
- return false;
- }
-
- var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');
-
- var f = function(el) {
-
- if ( !this.hasClass(el, oldClassName) ) {
- this.addClass(el, newClassName); // just add it if nothing to replace
- return; // note return
- }
-
- el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
-
- if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
- this.replaceClass(el, oldClassName, newClassName);
- }
- };
-
- Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Generates a unique ID
- * @method generateId
- * @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present).
- * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen").
- * @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
- */
- generateId: function(el, prefix) {
- prefix = prefix || 'yui-gen';
- el = el || {};
-
- var f = function(el) {
- if (el) {
- el = Y.Dom.get(el);
- } else {
- el = {}; // just generating ID in this case
- }
-
- if (!el.id) {
- el.id = prefix + id_counter++;
- } // dont override existing
-
-
- return el.id;
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy.
- * @method isAncestor
- * @param {String | HTMLElement} haystack The possible ancestor
- * @param {String | HTMLElement} needle The possible descendent
- * @return {Boolean} Whether or not the haystack is an ancestor of needle
- */
- isAncestor: function(haystack, needle) {
- haystack = Y.Dom.get(haystack);
- if (!haystack || !needle) { return false; }
-
- var f = function(needle) {
- if (haystack.contains && !isSafari) { // safari "contains" is broken
- return haystack.contains(needle);
- }
- else if ( haystack.compareDocumentPosition ) {
- return !!(haystack.compareDocumentPosition(needle) & 16);
- }
- else { // loop up and test each parent
- var parent = needle.parentNode;
-
- while (parent) {
- if (parent == haystack) {
- return true;
- }
- else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') {
- return false;
- }
-
- parent = parent.parentNode;
- }
- return false;
- }
- };
-
- return Y.Dom.batch(needle, f, Y.Dom, true);
- },
-
- /**
- * Determines whether an HTMLElement is present in the current document.
- * @method inDocument
- * @param {String | HTMLElement} el The element to search for
- * @return {Boolean} Whether or not the element is present in the current document
- */
- inDocument: function(el) {
- var f = function(el) {
- return this.isAncestor(document.documentElement, el);
- };
-
- return Y.Dom.batch(el, f, Y.Dom, true);
- },
-
- /**
- * Returns a array of HTMLElements that pass the test applied by supplied boolean method.
- * For optimized performance, include a tag and/or root node when possible.
- * @method getElementsBy
- * @param {Function} method - A boolean method for testing elements which receives the element as its only argument.
-
- * @param {String} tag (optional) The tag name of the elements being collected
- * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
- */
- getElementsBy: function(method, tag, root) {
- tag = tag || '*';
-
- var nodes = [];
-
- if (root) {
- root = Y.Dom.get(root);
- if (!root) { // if no root node, then no children
- return nodes;
- }
- } else {
- root = document;
- }
-
- var elements = root.getElementsByTagName(tag);
-
- if ( !elements.length && (tag == '*' && root.all) ) {
- elements = root.all; // IE < 6
- }
-
- for (var i = 0, len = elements.length; i < len; ++i) {
- if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; }
- }
-
-
- return nodes;
- },
-
- /**
- * Returns an array of elements that have had the supplied method applied.
- * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ).
- * @method batch
- * @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to
- * @param {Function} method The method to apply to the element(s)
- * @param {Any} o (optional) An optional arg that is passed to the supplied method
- * @param {Boolean} override (optional) Whether or not to override the scope of "method" with "o"
- * @return {HTMLElement | Array} The element(s) with the method applied
- */
- batch: function(el, method, o, override) {
- var id = el;
- el = Y.Dom.get(el);
-
- var scope = (override) ? o : window;
-
- if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection)
- if (!el) {
- return false;
- }
- return method.call(scope, el, o);
- }
-
- var collection = [];
-
- for (var i = 0, len = el.length; i < len; ++i) {
- if (!el[i]) {
- id = el[i];
- }
- collection[collection.length] = method.call(scope, el[i], o);
- }
-
- return collection;
- },
-
- /**
- * Returns the height of the document.
- * @method getDocumentHeight
- * @return {Int} The height of the actual document (which includes the body and its margin).
- */
- getDocumentHeight: function() {
- var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;
-
- var h = Math.max(scrollHeight, Y.Dom.getViewportHeight());
- return h;
- },
-
- /**
- * Returns the width of the document.
- * @method getDocumentWidth
- * @return {Int} The width of the actual document (which includes the body and its margin).
- */
- getDocumentWidth: function() {
- var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth;
- var w = Math.max(scrollWidth, Y.Dom.getViewportWidth());
- return w;
- },
-
- /**
- * Returns the current height of the viewport.
- * @method getViewportHeight
- * @return {Int} The height of the viewable area of the page (excludes scrollbars).
- */
- getViewportHeight: function() {
- var height = self.innerHeight; // Safari, Opera
- var mode = document.compatMode;
-
- if ( (mode || isIE) && !isOpera ) { // IE, Gecko
- height = (mode == 'CSS1Compat') ?
- document.documentElement.clientHeight : // Standards
- document.body.clientHeight; // Quirks
- }
-
- return height;
- },
-
- /**
- * Returns the current width of the viewport.
- * @method getViewportWidth
- * @return {Int} The width of the viewable area of the page (excludes scrollbars).
- */
-
- getViewportWidth: function() {
- var width = self.innerWidth; // Safari
- var mode = document.compatMode;
-
- if (mode || isIE) { // IE, Gecko, Opera
- width = (mode == 'CSS1Compat') ?
- document.documentElement.clientWidth : // Standards
- document.body.clientWidth; // Quirks
- }
- return width;
- }
- };
-})();
-/**
- * A region is a representation of an object on a grid. It is defined
- * by the top, right, bottom, left extents, so is rectangular by default. If
- * other shapes are required, this class could be extended to support it.
- * @namespace YAHOO.util
- * @class Region
- * @param {Int} t the top extent
- * @param {Int} r the right extent
- * @param {Int} b the bottom extent
- * @param {Int} l the left extent
- * @constructor
- */
-YAHOO.util.Region = function(t, r, b, l) {
-
- /**
- * The region's top extent
- * @property top
- * @type Int
- */
- this.top = t;
-
- /**
- * The region's top extent as index, for symmetry with set/getXY
- * @property 1
- * @type Int
- */
- this[1] = t;
-
- /**
- * The region's right extent
- * @property right
- * @type int
- */
- this.right = r;
-
- /**
- * The region's bottom extent
- * @property bottom
- * @type Int
- */
- this.bottom = b;
-
- /**
- * The region's left extent
- * @property left
- * @type Int
- */
- this.left = l;
-
- /**
- * The region's left extent as index, for symmetry with set/getXY
- * @property 0
- * @type Int
- */
- this[0] = l;
-};
-
-/**
- * Returns true if this region contains the region passed in
- * @method contains
- * @param {Region} region The region to evaluate
- * @return {Boolean} True if the region is contained with this region,
- * else false
- */
-YAHOO.util.Region.prototype.contains = function(region) {
- return ( region.left >= this.left &&
- region.right <= this.right &&
- region.top >= this.top &&
- region.bottom <= this.bottom );
-
-};
-
-/**
- * Returns the area of the region
- * @method getArea
- * @return {Int} the region's area
- */
-YAHOO.util.Region.prototype.getArea = function() {
- return ( (this.bottom - this.top) * (this.right - this.left) );
-};
-
-/**
- * Returns the region where the passed in region overlaps with this one
- * @method intersect
- * @param {Region} region The region that intersects
- * @return {Region} The overlap region, or null if there is no overlap
- */
-YAHOO.util.Region.prototype.intersect = function(region) {
- var t = Math.max( this.top, region.top );
- var r = Math.min( this.right, region.right );
- var b = Math.min( this.bottom, region.bottom );
- var l = Math.max( this.left, region.left );
-
- if (b >= t && r >= l) {
- return new YAHOO.util.Region(t, r, b, l);
- } else {
- return null;
- }
-};
-
-/**
- * Returns the region representing the smallest region that can contain both
- * the passed in region and this region.
- * @method union
- * @param {Region} region The region that to create the union with
- * @return {Region} The union region
- */
-YAHOO.util.Region.prototype.union = function(region) {
- var t = Math.min( this.top, region.top );
- var r = Math.max( this.right, region.right );
- var b = Math.max( this.bottom, region.bottom );
- var l = Math.min( this.left, region.left );
-
- return new YAHOO.util.Region(t, r, b, l);
-};
-
-/**
- * toString
- * @method toString
- * @return string the region properties
- */
-YAHOO.util.Region.prototype.toString = function() {
- return ( "Region {" +
- "top: " + this.top +
- ", right: " + this.right +
- ", bottom: " + this.bottom +
- ", left: " + this.left +
- "}" );
-};
-
-/**
- * Returns a region that is occupied by the DOM element
- * @method getRegion
- * @param {HTMLElement} el The element
- * @return {Region} The region that the element occupies
- * @static
- */
-YAHOO.util.Region.getRegion = function(el) {
- var p = YAHOO.util.Dom.getXY(el);
-
- var t = p[1];
- var r = p[0] + el.offsetWidth;
- var b = p[1] + el.offsetHeight;
- var l = p[0];
-
- return new YAHOO.util.Region(t, r, b, l);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * A point is a region that is special in that it represents a single point on
- * the grid.
- * @namespace YAHOO.util
- * @class Point
- * @param {Int} x The X position of the point
- * @param {Int} y The Y position of the point
- * @constructor
- * @extends YAHOO.util.Region
- */
-YAHOO.util.Point = function(x, y) {
- if (x instanceof Array) { // accept output from Dom.getXY
- y = x[1];
- x = x[0];
- }
-
- /**
- * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry)
- * @property x
- * @type Int
- */
-
- this.x = this.right = this.left = this[0] = x;
-
- /**
- * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry)
- * @property y
- * @type Int
- */
- this.y = this.top = this.bottom = this[1] = y;
-};
-
-YAHOO.util.Point.prototype = new YAHOO.util.Region();
-
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/**
+ * The dom module provides helper methods for manipulating Dom elements.
+ * @module dom
+ *
+ */
+
+(function() {
+ var Y = YAHOO.util, // internal shorthand
+ getStyle, // for load time browser branching
+ setStyle, // ditto
+ id_counter = 0, // for use with generateId
+ propertyCache = {}; // for faster hyphen converts
+
+ // brower detection
+ var ua = navigator.userAgent.toLowerCase(),
+ isOpera = (ua.indexOf('opera') > -1),
+ isSafari = (ua.indexOf('safari') > -1),
+ isGecko = (!isOpera && !isSafari && ua.indexOf('gecko') > -1),
+ isIE = (!isOpera && ua.indexOf('msie') > -1);
+
+ // regex cache
+ var patterns = {
+ HYPHEN: /(-[a-z])/i
+ };
+
+
+ var toCamel = function(property) {
+ if ( !patterns.HYPHEN.test(property) ) {
+ return property; // no hyphens
+ }
+
+ if (propertyCache[property]) { // already converted
+ return propertyCache[property];
+ }
+
+ while( patterns.HYPHEN.exec(property) ) {
+ property = property.replace(RegExp.$1,
+ RegExp.$1.substr(1).toUpperCase());
+ }
+
+ propertyCache[property] = property;
+ return property;
+ //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
+ };
+
+ // branching at load instead of runtime
+ if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method
+ getStyle = function(el, property) {
+ var value = null;
+
+ var computed = document.defaultView.getComputedStyle(el, '');
+ if (computed) { // test computed before touching for safari
+ value = computed[toCamel(property)];
+ }
+
+ return el.style[property] || value;
+ };
+ } else if (document.documentElement.currentStyle && isIE) { // IE method
+ getStyle = function(el, property) {
+ switch( toCamel(property) ) {
+ case 'opacity' :// IE opacity uses filter
+ var val = 100;
+ try { // will error if no DXImageTransform
+ val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
+
+ } catch(e) {
+ try { // make sure its in the document
+ val = el.filters('alpha').opacity;
+ } catch(e) {
+ }
+ }
+ return val / 100;
+ break;
+ default:
+ // test currentStyle before touching
+ var value = el.currentStyle ? el.currentStyle[property] : null;
+ return ( el.style[property] || value );
+ }
+ };
+ } else { // default to inline only
+ getStyle = function(el, property) { return el.style[property]; };
+ }
+
+ if (isIE) {
+ setStyle = function(el, property, val) {
+ switch (property) {
+ case 'opacity':
+ if ( typeof el.style.filter == 'string' ) { // in case not appended
+ el.style.filter = 'alpha(opacity=' + val * 100 + ')';
+
+ if (!el.currentStyle || !el.currentStyle.hasLayout) {
+ el.style.zoom = 1; // when no layout or cant tell
+ }
+ }
+ break;
+ default:
+ el.style[property] = val;
+ }
+ };
+ } else {
+ setStyle = function(el, property, val) {
+ el.style[property] = val;
+ };
+ }
+
+ /**
+ * Provides helper methods for DOM elements.
+ * @namespace YAHOO.util
+ * @class Dom
+ */
+ YAHOO.util.Dom = {
+ /**
+ * Returns an HTMLElement reference.
+ * @method get
+ * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements.
+ */
+ get: function(el) {
+ if (!el) { return null; } // nothing to work with
+
+ if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is
+ return el;
+ }
+
+ if (typeof el == 'string') { // ID
+ return document.getElementById(el);
+ }
+ else { // array of ID's and/or elements
+ var collection = [];
+ for (var i = 0, len = el.length; i < len; ++i) {
+ collection[collection.length] = Y.Dom.get(el[i]);
+ }
+
+ return collection;
+ }
+
+ return null; // safety, should never happen
+ },
+
+ /**
+ * Normalizes currentStyle and ComputedStyle.
+ * @method getStyle
+ * @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {String} property The style property whose value is returned.
+ * @return {String | Array} The current value of the style property for the element(s).
+ */
+ getStyle: function(el, property) {
+ property = toCamel(property);
+
+ var f = function(element) {
+ return getStyle(element, property);
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers.
+ * @method setStyle
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {String} property The style property to be set.
+ * @param {String} val The value to apply to the given property.
+ */
+ setStyle: function(el, property, val) {
+ property = toCamel(property);
+
+ var f = function(element) {
+ setStyle(element, property, val);
+
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method getXY
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {Array} The XY position of the element(s)
+ */
+ getXY: function(el) {
+ var f = function(el) {
+
+ // has to be part of document to have pageXY
+ if (el.parentNode === null || el.offsetParent === null ||
+ this.getStyle(el, 'display') == 'none') {
+ return false;
+ }
+
+ var parentNode = null;
+ var pos = [];
+ var box;
+
+ if (el.getBoundingClientRect) { // IE
+ box = el.getBoundingClientRect();
+ var doc = document;
+ if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll
+ doc = parent.document;
+
+ if ( !this.isAncestor(doc.documentElement, el) ) {
+ return false;
+ }
+
+ }
+
+ var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
+ var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
+
+ return [box.left + scrollLeft, box.top + scrollTop];
+ }
+ else { // safari, opera, & gecko
+ pos = [el.offsetLeft, el.offsetTop];
+ parentNode = el.offsetParent;
+ if (parentNode != el) {
+ while (parentNode) {
+ pos[0] += parentNode.offsetLeft;
+ pos[1] += parentNode.offsetTop;
+ parentNode = parentNode.offsetParent;
+ }
+ }
+ if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases
+ pos[0] -= document.body.offsetLeft;
+ pos[1] -= document.body.offsetTop;
+ }
+ }
+
+ if (el.parentNode) { parentNode = el.parentNode; }
+ else { parentNode = null; }
+
+ while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
+ { // account for any scrolled ancestors
+ if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { // work around opera inline scrollLeft/Top bug
+ pos[0] -= parentNode.scrollLeft;
+ pos[1] -= parentNode.scrollTop;
+ }
+
+ if (parentNode.parentNode) {
+ parentNode = parentNode.parentNode;
+ } else { parentNode = null; }
+ }
+
+
+ return pos;
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method getX
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {String | Array} The X position of the element(s)
+ */
+ getX: function(el) {
+ var f = function(el) {
+ return Y.Dom.getXY(el)[0];
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method getY
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {String | Array} The Y position of the element(s)
+ */
+ getY: function(el) {
+ var f = function(el) {
+ return Y.Dom.getXY(el)[1];
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Set the position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method setXY
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @param {Array} pos Contains X & Y values for new position (coordinates are page-based)
+ * @param {Boolean} noRetry By default we try and set the position a second time if the first fails
+ */
+ setXY: function(el, pos, noRetry) {
+ var f = function(el) {
+ var style_pos = this.getStyle(el, 'position');
+ if (style_pos == 'static') { // default to relative
+ this.setStyle(el, 'position', 'relative');
+ style_pos = 'relative';
+ }
+
+ var pageXY = this.getXY(el);
+ if (pageXY === false) { // has to be part of doc to have pageXY
+ return false;
+ }
+
+ var delta = [ // assuming pixels; if not we will have to retry
+ parseInt( this.getStyle(el, 'left'), 10 ),
+ parseInt( this.getStyle(el, 'top'), 10 )
+ ];
+
+ if ( isNaN(delta[0]) ) {// in case of 'auto'
+ delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
+ }
+ if ( isNaN(delta[1]) ) { // in case of 'auto'
+ delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
+ }
+
+ if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
+ if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }
+
+ if (!noRetry) {
+ var newXY = this.getXY(el);
+
+ // if retry is true, try one more time if we miss
+ if ( (pos[0] !== null && newXY[0] != pos[0]) ||
+ (pos[1] !== null && newXY[1] != pos[1]) ) {
+ this.setXY(el, pos, true);
+ }
+ }
+
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Set the X position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method setX
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {Int} x The value to use as the X coordinate for the element(s).
+ */
+ setX: function(el, x) {
+ Y.Dom.setXY(el, [x, null]);
+ },
+
+ /**
+ * Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @method setY
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {Int} x To use as the Y coordinate for the element(s).
+ */
+ setY: function(el, y) {
+ Y.Dom.setXY(el, [null, y]);
+ },
+
+ /**
+ * Returns the region position of the given element.
+ * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
+ * @method getRegion
+ * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @return {Region | Array} A Region or array of Region instances containing "top, left, bottom, right" member data.
+ */
+ getRegion: function(el) {
+ var f = function(el) {
+ var region = new Y.Region.getRegion(el);
+ return region;
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Returns the width of the client (viewport).
+ * @method getClientWidth
+ * @deprecated Now using getViewportWidth. This interface left intact for back compat.
+ * @return {Int} The width of the viewable area of the page.
+ */
+ getClientWidth: function() {
+ return Y.Dom.getViewportWidth();
+ },
+
+ /**
+ * Returns the height of the client (viewport).
+ * @method getClientHeight
+ * @deprecated Now using getViewportHeight. This interface left intact for back compat.
+ * @return {Int} The height of the viewable area of the page.
+ */
+ getClientHeight: function() {
+ return Y.Dom.getViewportHeight();
+ },
+
+ /**
+ * Returns a array of HTMLElements with the given class.
+ * For optimized performance, include a tag and/or root node when possible.
+ * @method getElementsByClassName
+ * @param {String} className The class name to match against
+ * @param {String} tag (optional) The tag name of the elements being collected
+ * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+ * @return {Array} An array of elements that have the given class name
+ */
+ getElementsByClassName: function(className, tag, root) {
+ var method = function(el) { return Y.Dom.hasClass(el, className); };
+ return Y.Dom.getElementsBy(method, tag, root);
+ },
+
+ /**
+ * Determines whether an HTMLElement has the given className.
+ * @method hasClass
+ * @param {String | HTMLElement | Array} el The element or collection to test
+ * @param {String} className the class name to search for
+ * @return {Boolean | Array} A boolean value or array of boolean values
+ */
+ hasClass: function(el, className) {
+ var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
+
+ var f = function(el) {
+ return re.test(el['className']);
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Adds a class name to a given element or collection of elements.
+ * @method addClass
+ * @param {String | HTMLElement | Array} el The element or collection to add the class to
+ * @param {String} className the class name to add to the class attribute
+ */
+ addClass: function(el, className) {
+ var f = function(el) {
+ if (this.hasClass(el, className)) { return; } // already present
+
+
+ el['className'] = [el['className'], className].join(' ');
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Removes a class name from a given element or collection of elements.
+ * @method removeClass
+ * @param {String | HTMLElement | Array} el The element or collection to remove the class from
+ * @param {String} className the class name to remove from the class attribute
+ */
+ removeClass: function(el, className) {
+ var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
+
+ var f = function(el) {
+ if (!this.hasClass(el, className)) { return; } // not present
+
+
+ var c = el['className'];
+ el['className'] = c.replace(re, ' ');
+ if ( this.hasClass(el, className) ) { // in case of multiple adjacent
+ this.removeClass(el, className);
+ }
+
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Replace a class with another class for a given element or collection of elements.
+ * If no oldClassName is present, the newClassName is simply added.
+ * @method replaceClass
+ * @param {String | HTMLElement | Array} el The element or collection to remove the class from
+ * @param {String} oldClassName the class name to be replaced
+ * @param {String} newClassName the class name that will be replacing the old class name
+ */
+ replaceClass: function(el, oldClassName, newClassName) {
+ if (oldClassName === newClassName) { // avoid infinite loop
+ return false;
+ }
+
+ var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');
+
+ var f = function(el) {
+
+ if ( !this.hasClass(el, oldClassName) ) {
+ this.addClass(el, newClassName); // just add it if nothing to replace
+ return; // note return
+ }
+
+ el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
+
+ if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
+ this.replaceClass(el, oldClassName, newClassName);
+ }
+ };
+
+ Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Generates a unique ID
+ * @method generateId
+ * @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present).
+ * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen").
+ * @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
+ */
+ generateId: function(el, prefix) {
+ prefix = prefix || 'yui-gen';
+ el = el || {};
+
+ var f = function(el) {
+ if (el) {
+ el = Y.Dom.get(el);
+ } else {
+ el = {}; // just generating ID in this case
+ }
+
+ if (!el.id) {
+ el.id = prefix + id_counter++;
+ } // dont override existing
+
+
+ return el.id;
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy.
+ * @method isAncestor
+ * @param {String | HTMLElement} haystack The possible ancestor
+ * @param {String | HTMLElement} needle The possible descendent
+ * @return {Boolean} Whether or not the haystack is an ancestor of needle
+ */
+ isAncestor: function(haystack, needle) {
+ haystack = Y.Dom.get(haystack);
+ if (!haystack || !needle) { return false; }
+
+ var f = function(needle) {
+ if (haystack.contains && !isSafari) { // safari "contains" is broken
+ return haystack.contains(needle);
+ }
+ else if ( haystack.compareDocumentPosition ) {
+ return !!(haystack.compareDocumentPosition(needle) & 16);
+ }
+ else { // loop up and test each parent
+ var parent = needle.parentNode;
+
+ while (parent) {
+ if (parent == haystack) {
+ return true;
+ }
+ else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') {
+ return false;
+ }
+
+ parent = parent.parentNode;
+ }
+ return false;
+ }
+ };
+
+ return Y.Dom.batch(needle, f, Y.Dom, true);
+ },
+
+ /**
+ * Determines whether an HTMLElement is present in the current document.
+ * @method inDocument
+ * @param {String | HTMLElement} el The element to search for
+ * @return {Boolean} Whether or not the element is present in the current document
+ */
+ inDocument: function(el) {
+ var f = function(el) {
+ return this.isAncestor(document.documentElement, el);
+ };
+
+ return Y.Dom.batch(el, f, Y.Dom, true);
+ },
+
+ /**
+ * Returns a array of HTMLElements that pass the test applied by supplied boolean method.
+ * For optimized performance, include a tag and/or root node when possible.
+ * @method getElementsBy
+ * @param {Function} method - A boolean method for testing elements which receives the element as its only argument.
+
+ * @param {String} tag (optional) The tag name of the elements being collected
+ * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+ */
+ getElementsBy: function(method, tag, root) {
+ tag = tag || '*';
+
+ var nodes = [];
+
+ if (root) {
+ root = Y.Dom.get(root);
+ if (!root) { // if no root node, then no children
+ return nodes;
+ }
+ } else {
+ root = document;
+ }
+
+ var elements = root.getElementsByTagName(tag);
+
+ if ( !elements.length && (tag == '*' && root.all) ) {
+ elements = root.all; // IE < 6
+ }
+
+ for (var i = 0, len = elements.length; i < len; ++i) {
+ if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; }
+ }
+
+
+ return nodes;
+ },
+
+ /**
+ * Returns an array of elements that have had the supplied method applied.
+ * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ).
+ * @method batch
+ * @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to
+ * @param {Function} method The method to apply to the element(s)
+ * @param {Any} o (optional) An optional arg that is passed to the supplied method
+ * @param {Boolean} override (optional) Whether or not to override the scope of "method" with "o"
+ * @return {HTMLElement | Array} The element(s) with the method applied
+ */
+ batch: function(el, method, o, override) {
+ var id = el;
+ el = Y.Dom.get(el);
+
+ var scope = (override) ? o : window;
+
+ if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection)
+ if (!el) {
+ return false;
+ }
+ return method.call(scope, el, o);
+ }
+
+ var collection = [];
+
+ for (var i = 0, len = el.length; i < len; ++i) {
+ if (!el[i]) {
+ id = el[i];
+ }
+ collection[collection.length] = method.call(scope, el[i], o);
+ }
+
+ return collection;
+ },
+
+ /**
+ * Returns the height of the document.
+ * @method getDocumentHeight
+ * @return {Int} The height of the actual document (which includes the body and its margin).
+ */
+ getDocumentHeight: function() {
+ var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;
+
+ var h = Math.max(scrollHeight, Y.Dom.getViewportHeight());
+ return h;
+ },
+
+ /**
+ * Returns the width of the document.
+ * @method getDocumentWidth
+ * @return {Int} The width of the actual document (which includes the body and its margin).
+ */
+ getDocumentWidth: function() {
+ var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth;
+ var w = Math.max(scrollWidth, Y.Dom.getViewportWidth());
+ return w;
+ },
+
+ /**
+ * Returns the current height of the viewport.
+ * @method getViewportHeight
+ * @return {Int} The height of the viewable area of the page (excludes scrollbars).
+ */
+ getViewportHeight: function() {
+ var height = self.innerHeight; // Safari, Opera
+ var mode = document.compatMode;
+
+ if ( (mode || isIE) && !isOpera ) { // IE, Gecko
+ height = (mode == 'CSS1Compat') ?
+ document.documentElement.clientHeight : // Standards
+ document.body.clientHeight; // Quirks
+ }
+
+ return height;
+ },
+
+ /**
+ * Returns the current width of the viewport.
+ * @method getViewportWidth
+ * @return {Int} The width of the viewable area of the page (excludes scrollbars).
+ */
+
+ getViewportWidth: function() {
+ var width = self.innerWidth; // Safari
+ var mode = document.compatMode;
+
+ if (mode || isIE) { // IE, Gecko, Opera
+ width = (mode == 'CSS1Compat') ?
+ document.documentElement.clientWidth : // Standards
+ document.body.clientWidth; // Quirks
+ }
+ return width;
+ }
+ };
+})();
+/**
+ * A region is a representation of an object on a grid. It is defined
+ * by the top, right, bottom, left extents, so is rectangular by default. If
+ * other shapes are required, this class could be extended to support it.
+ * @namespace YAHOO.util
+ * @class Region
+ * @param {Int} t the top extent
+ * @param {Int} r the right extent
+ * @param {Int} b the bottom extent
+ * @param {Int} l the left extent
+ * @constructor
+ */
+YAHOO.util.Region = function(t, r, b, l) {
+
+ /**
+ * The region's top extent
+ * @property top
+ * @type Int
+ */
+ this.top = t;
+
+ /**
+ * The region's top extent as index, for symmetry with set/getXY
+ * @property 1
+ * @type Int
+ */
+ this[1] = t;
+
+ /**
+ * The region's right extent
+ * @property right
+ * @type int
+ */
+ this.right = r;
+
+ /**
+ * The region's bottom extent
+ * @property bottom
+ * @type Int
+ */
+ this.bottom = b;
+
+ /**
+ * The region's left extent
+ * @property left
+ * @type Int
+ */
+ this.left = l;
+
+ /**
+ * The region's left extent as index, for symmetry with set/getXY
+ * @property 0
+ * @type Int
+ */
+ this[0] = l;
+};
+
+/**
+ * Returns true if this region contains the region passed in
+ * @method contains
+ * @param {Region} region The region to evaluate
+ * @return {Boolean} True if the region is contained with this region,
+ * else false
+ */
+YAHOO.util.Region.prototype.contains = function(region) {
+ return ( region.left >= this.left &&
+ region.right <= this.right &&
+ region.top >= this.top &&
+ region.bottom <= this.bottom );
+
+};
+
+/**
+ * Returns the area of the region
+ * @method getArea
+ * @return {Int} the region's area
+ */
+YAHOO.util.Region.prototype.getArea = function() {
+ return ( (this.bottom - this.top) * (this.right - this.left) );
+};
+
+/**
+ * Returns the region where the passed in region overlaps with this one
+ * @method intersect
+ * @param {Region} region The region that intersects
+ * @return {Region} The overlap region, or null if there is no overlap
+ */
+YAHOO.util.Region.prototype.intersect = function(region) {
+ var t = Math.max( this.top, region.top );
+ var r = Math.min( this.right, region.right );
+ var b = Math.min( this.bottom, region.bottom );
+ var l = Math.max( this.left, region.left );
+
+ if (b >= t && r >= l) {
+ return new YAHOO.util.Region(t, r, b, l);
+ } else {
+ return null;
+ }
+};
+
+/**
+ * Returns the region representing the smallest region that can contain both
+ * the passed in region and this region.
+ * @method union
+ * @param {Region} region The region that to create the union with
+ * @return {Region} The union region
+ */
+YAHOO.util.Region.prototype.union = function(region) {
+ var t = Math.min( this.top, region.top );
+ var r = Math.max( this.right, region.right );
+ var b = Math.max( this.bottom, region.bottom );
+ var l = Math.min( this.left, region.left );
+
+ return new YAHOO.util.Region(t, r, b, l);
+};
+
+/**
+ * toString
+ * @method toString
+ * @return string the region properties
+ */
+YAHOO.util.Region.prototype.toString = function() {
+ return ( "Region {" +
+ "top: " + this.top +
+ ", right: " + this.right +
+ ", bottom: " + this.bottom +
+ ", left: " + this.left +
+ "}" );
+};
+
+/**
+ * Returns a region that is occupied by the DOM element
+ * @method getRegion
+ * @param {HTMLElement} el The element
+ * @return {Region} The region that the element occupies
+ * @static
+ */
+YAHOO.util.Region.getRegion = function(el) {
+ var p = YAHOO.util.Dom.getXY(el);
+
+ var t = p[1];
+ var r = p[0] + el.offsetWidth;
+ var b = p[1] + el.offsetHeight;
+ var l = p[0];
+
+ return new YAHOO.util.Region(t, r, b, l);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * A point is a region that is special in that it represents a single point on
+ * the grid.
+ * @namespace YAHOO.util
+ * @class Point
+ * @param {Int} x The X position of the point
+ * @param {Int} y The Y position of the point
+ * @constructor
+ * @extends YAHOO.util.Region
+ */
+YAHOO.util.Point = function(x, y) {
+ if (x instanceof Array) { // accept output from Dom.getXY
+ y = x[1];
+ x = x[0];
+ }
+
+ /**
+ * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry)
+ * @property x
+ * @type Int
+ */
+
+ this.x = this.right = this.left = this[0] = x;
+
+ /**
+ * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry)
+ * @property y
+ * @type Int
+ */
+ this.y = this.top = this.bottom = this[1] = y;
+};
+
+YAHOO.util.Point.prototype = new YAHOO.util.Region();
+
diff --git a/lib/yui/dragdrop/README b/lib/yui/dragdrop/README
index 763731b7fd..255ead5513 100755
--- a/lib/yui/dragdrop/README
+++ b/lib/yui/dragdrop/README
@@ -1,106 +1,110 @@
-Drag and Drop Release Notes
-
-0.12.1
-
- * Added a STRICT_INTERSECT drag and drop interaction mode. This alters the
- behavior of DDM::getBestMatch. INTERSECT mode first tests the cursor
- location, and if it is over the target that target wins, otherwise it
- tests the overlap of the elements. STRICT_INTERSECT mode tests only
- the overlap, the largest overlap wins.
-
- * getBestMatch will work for targeted elements that have no overlap.
-
-0.12.0
-
- * The logic to determine if a drag should be initiated has been isolated
- to the clickValidator method. This method can be overridden to provide
- custom valdiation logic. For example, it is possible to specify hotspots
- of any dimension or shape. The provided example shows how to make only
- a circular region in the middle of the element initiate a drag.
-
- * Added a new drag and drop event: onInvalidDrop. This is executed when
- the dragged element in dropped in a location without a target. Previously
- this condition could only detected by implementing handlers for three
- other events.
-
- * Now accepts an element reference in lieu of an id. Ids will
- be generated if the element does not have one.
-
- * Fixed horizontal autoscroll when scrollTop is zero.
-
- * Added hasOuterHandles property to bypass the isOverTarget check in the
- mousedown validation routine. Fixes setOuterHandleElId.
-
-0.11.4
-
- * YAHOO.util.DragDropMgr.swapNode now handles adjacent nodes properly
-
- * Fixed missing variable declarations
-
-0.11.3
-
- * Fixed a JavaScript error that would be generated when trying to implement
- DDProxy using the default settings and a tiny element.
-
- * Fixed an error that resulted when constraints were applied to DragDrop
- instances.
-
-0.11.2
-
- * Drag and drop will no longer interfere with selecting text on elements
- that are not involved in drag and drop.
-
- * The shared drag and drop proxy element now resizes correctly when autoResize
- is enabled.
-
-0.11.1
-
- * Fixes an issue where the setXY cache could get out of sync if the element's
- offsetParent is changed during onDragDrop.
-
-0.11.0
-
- * The Dom.util.setXY calculation for the initial placement of the dragged
- element is cached during the drag, enhancing the drag performance.
-
- * DDProxy no longer enforces having a single proxy element for all instances.
- dragElId can be set in the config object in the constructor. If the
- element already exists it will use that element, otherwise a new one will
- be created with that id.
-
- * DDProxy->borderWidth has been removed. The value is calculated on the fly
- instead.
-
- * Added DragDrop->clearTicks and DragDrop->clearConstraints
-
- * All drag and drop constructors now have an additional, optional parameter
- call "config". It is an object that can contain properties for a
- number of configuration settings.
-
- * Drag and drop will not be disabled for elements that cannot have their
- location determined.
-
- * isLegalTarget won't return dd objects that are not targetable.
-
- * Added DragDrop->removeFromGroup.
-
- * Constraints are now applied properly when determining which drag and drop
- events should fire.
-
-
-0.10.0
-
- * Improved the performance when in intersect mode
-
- * It was possible for the drag and drop initialization to be skipped
- for very slow loading pages. This was fixed.
-
- * New methods to exclude regions within your drag and drop element:
- addInvalidHandleId(), addInvalidHandleClass()
-
- * Added an onAvailable handler that is executed after the initial state is set.
-
- * Drag and drop is more forgiving when the implementer attempts to create the
- instance prior to the element being in the document, but after the window
- load event has fired.
-
+Drag and Drop Release Notes
+
+0.12.2
+
+ * No change
+
+0.12.1
+
+ * Added a STRICT_INTERSECT drag and drop interaction mode. This alters the
+ behavior of DDM::getBestMatch. INTERSECT mode first tests the cursor
+ location, and if it is over the target that target wins, otherwise it
+ tests the overlap of the elements. STRICT_INTERSECT mode tests only
+ the overlap, the largest overlap wins.
+
+ * getBestMatch will work for targeted elements that have no overlap.
+
+0.12.0
+
+ * The logic to determine if a drag should be initiated has been isolated
+ to the clickValidator method. This method can be overridden to provide
+ custom valdiation logic. For example, it is possible to specify hotspots
+ of any dimension or shape. The provided example shows how to make only
+ a circular region in the middle of the element initiate a drag.
+
+ * Added a new drag and drop event: onInvalidDrop. This is executed when
+ the dragged element in dropped in a location without a target. Previously
+ this condition could only detected by implementing handlers for three
+ other events.
+
+ * Now accepts an element reference in lieu of an id. Ids will
+ be generated if the element does not have one.
+
+ * Fixed horizontal autoscroll when scrollTop is zero.
+
+ * Added hasOuterHandles property to bypass the isOverTarget check in the
+ mousedown validation routine. Fixes setOuterHandleElId.
+
+0.11.4
+
+ * YAHOO.util.DragDropMgr.swapNode now handles adjacent nodes properly
+
+ * Fixed missing variable declarations
+
+0.11.3
+
+ * Fixed a JavaScript error that would be generated when trying to implement
+ DDProxy using the default settings and a tiny element.
+
+ * Fixed an error that resulted when constraints were applied to DragDrop
+ instances.
+
+0.11.2
+
+ * Drag and drop will no longer interfere with selecting text on elements
+ that are not involved in drag and drop.
+
+ * The shared drag and drop proxy element now resizes correctly when autoResize
+ is enabled.
+
+0.11.1
+
+ * Fixes an issue where the setXY cache could get out of sync if the element's
+ offsetParent is changed during onDragDrop.
+
+0.11.0
+
+ * The Dom.util.setXY calculation for the initial placement of the dragged
+ element is cached during the drag, enhancing the drag performance.
+
+ * DDProxy no longer enforces having a single proxy element for all instances.
+ dragElId can be set in the config object in the constructor. If the
+ element already exists it will use that element, otherwise a new one will
+ be created with that id.
+
+ * DDProxy->borderWidth has been removed. The value is calculated on the fly
+ instead.
+
+ * Added DragDrop->clearTicks and DragDrop->clearConstraints
+
+ * All drag and drop constructors now have an additional, optional parameter
+ call "config". It is an object that can contain properties for a
+ number of configuration settings.
+
+ * Drag and drop will not be disabled for elements that cannot have their
+ location determined.
+
+ * isLegalTarget won't return dd objects that are not targetable.
+
+ * Added DragDrop->removeFromGroup.
+
+ * Constraints are now applied properly when determining which drag and drop
+ events should fire.
+
+
+0.10.0
+
+ * Improved the performance when in intersect mode
+
+ * It was possible for the drag and drop initialization to be skipped
+ for very slow loading pages. This was fixed.
+
+ * New methods to exclude regions within your drag and drop element:
+ addInvalidHandleId(), addInvalidHandleClass()
+
+ * Added an onAvailable handler that is executed after the initial state is set.
+
+ * Drag and drop is more forgiving when the implementer attempts to create the
+ instance prior to the element being in the document, but after the window
+ load event has fired.
+
diff --git a/lib/yui/dragdrop/dragdrop-debug.js b/lib/yui/dragdrop/dragdrop-debug.js
index 4ff7d68a4e..4254049ef9 100755
--- a/lib/yui/dragdrop/dragdrop-debug.js
+++ b/lib/yui/dragdrop/dragdrop-debug.js
@@ -1,3055 +1,3056 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 0.12.1
-*/
-(function() {
-
-var Event=YAHOO.util.Event;
-var Dom=YAHOO.util.Dom;
-
-/**
- * Defines the interface and base operation of items that that can be
- * dragged or can be drop targets. It was designed to be extended, overriding
- * the event handlers for startDrag, onDrag, onDragOver, onDragOut.
- * Up to three html elements can be associated with a DragDrop instance:
- *
- * linked element: the element that is passed into the constructor.
- * This is the element which defines the boundaries for interaction with
- * other DragDrop objects.
- * handle element(s): The drag operation only occurs if the element that
- * was clicked matches a handle element. By default this is the linked
- * element, but there are times that you will want only a portion of the
- * linked element to initiate the drag operation, and the setHandleElId()
- * method provides a way to define this.
- * drag element: this represents an the element that would be moved along
- * with the cursor during a drag operation. By default, this is the linked
- * element itself as in {@link YAHOO.util.DD}. setDragElId() lets you define
- * a separate element that would be moved, as in {@link YAHOO.util.DDProxy}
- *
- *
- * This class should not be instantiated until the onload event to ensure that
- * the associated elements are available.
- * The following would define a DragDrop obj that would interact with any
- * other DragDrop obj in the "group1" group:
- *
- * dd = new YAHOO.util.DragDrop("div1", "group1");
- *
- * Since none of the event handlers have been implemented, nothing would
- * actually happen if you were to run the code above. Normally you would
- * override this class or one of the default implementations, but you can
- * also override the methods you want on an instance of the class...
- *
- * dd.onDragDrop = function(e, id) {
- * alert("dd was dropped on " + id);
- * }
- *
- * @namespace YAHOO.util
- * @class DragDrop
- * @constructor
- * @param {String} id of the element that is linked to this instance
- * @param {String} sGroup the group of related DragDrop objects
- * @param {object} config an object containing configurable attributes
- * Valid properties for DragDrop:
- * padding, isTarget, maintainOffset, primaryButtonOnly,
- */
-YAHOO.util.DragDrop = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- }
-};
-
-YAHOO.util.DragDrop.prototype = {
-
- /**
- * The id of the element associated with this object. This is what we
- * refer to as the "linked element" because the size and position of
- * this element is used to determine when the drag and drop objects have
- * interacted.
- * @property id
- * @type String
- */
- id: null,
-
- /**
- * Configuration attributes passed into the constructor
- * @property config
- * @type object
- */
- config: null,
-
- /**
- * The id of the element that will be dragged. By default this is same
- * as the linked element , but could be changed to another element. Ex:
- * YAHOO.util.DDProxy
- * @property dragElId
- * @type String
- * @private
- */
- dragElId: null,
-
- /**
- * the id of the element that initiates the drag operation. By default
- * this is the linked element, but could be changed to be a child of this
- * element. This lets us do things like only starting the drag when the
- * header element within the linked html element is clicked.
- * @property handleElId
- * @type String
- * @private
- */
- handleElId: null,
-
- /**
- * An associative array of HTML tags that will be ignored if clicked.
- * @property invalidHandleTypes
- * @type {string: string}
- */
- invalidHandleTypes: null,
-
- /**
- * An associative array of ids for elements that will be ignored if clicked
- * @property invalidHandleIds
- * @type {string: string}
- */
- invalidHandleIds: null,
-
- /**
- * An indexted array of css class names for elements that will be ignored
- * if clicked.
- * @property invalidHandleClasses
- * @type string[]
- */
- invalidHandleClasses: null,
-
- /**
- * The linked element's absolute X position at the time the drag was
- * started
- * @property startPageX
- * @type int
- * @private
- */
- startPageX: 0,
-
- /**
- * The linked element's absolute X position at the time the drag was
- * started
- * @property startPageY
- * @type int
- * @private
- */
- startPageY: 0,
-
- /**
- * The group defines a logical collection of DragDrop objects that are
- * related. Instances only get events when interacting with other
- * DragDrop object in the same group. This lets us define multiple
- * groups using a single DragDrop subclass if we want.
- * @property groups
- * @type {string: string}
- */
- groups: null,
-
- /**
- * Individual drag/drop instances can be locked. This will prevent
- * onmousedown start drag.
- * @property locked
- * @type boolean
- * @private
- */
- locked: false,
-
- /**
- * Lock this instance
- * @method lock
- */
- lock: function() { this.locked = true; },
-
- /**
- * Unlock this instace
- * @method unlock
- */
- unlock: function() { this.locked = false; },
-
- /**
- * By default, all insances can be a drop target. This can be disabled by
- * setting isTarget to false.
- * @method isTarget
- * @type boolean
- */
- isTarget: true,
-
- /**
- * The padding configured for this drag and drop object for calculating
- * the drop zone intersection with this object.
- * @method padding
- * @type int[]
- */
- padding: null,
-
- /**
- * Cached reference to the linked element
- * @property _domRef
- * @private
- */
- _domRef: null,
-
- /**
- * Internal typeof flag
- * @property __ygDragDrop
- * @private
- */
- __ygDragDrop: true,
-
- /**
- * Set to true when horizontal contraints are applied
- * @property constrainX
- * @type boolean
- * @private
- */
- constrainX: false,
-
- /**
- * Set to true when vertical contraints are applied
- * @property constrainY
- * @type boolean
- * @private
- */
- constrainY: false,
-
- /**
- * The left constraint
- * @property minX
- * @type int
- * @private
- */
- minX: 0,
-
- /**
- * The right constraint
- * @property maxX
- * @type int
- * @private
- */
- maxX: 0,
-
- /**
- * The up constraint
- * @property minY
- * @type int
- * @type int
- * @private
- */
- minY: 0,
-
- /**
- * The down constraint
- * @property maxY
- * @type int
- * @private
- */
- maxY: 0,
-
- /**
- * Maintain offsets when we resetconstraints. Set to true when you want
- * the position of the element relative to its parent to stay the same
- * when the page changes
- *
- * @property maintainOffset
- * @type boolean
- */
- maintainOffset: false,
-
- /**
- * Array of pixel locations the element will snap to if we specified a
- * horizontal graduation/interval. This array is generated automatically
- * when you define a tick interval.
- * @property xTicks
- * @type int[]
- */
- xTicks: null,
-
- /**
- * Array of pixel locations the element will snap to if we specified a
- * vertical graduation/interval. This array is generated automatically
- * when you define a tick interval.
- * @property yTicks
- * @type int[]
- */
- yTicks: null,
-
- /**
- * By default the drag and drop instance will only respond to the primary
- * button click (left button for a right-handed mouse). Set to true to
- * allow drag and drop to start with any mouse click that is propogated
- * by the browser
- * @property primaryButtonOnly
- * @type boolean
- */
- primaryButtonOnly: true,
-
- /**
- * The availabe property is false until the linked dom element is accessible.
- * @property available
- * @type boolean
- */
- available: false,
-
- /**
- * By default, drags can only be initiated if the mousedown occurs in the
- * region the linked element is. This is done in part to work around a
- * bug in some browsers that mis-report the mousedown if the previous
- * mouseup happened outside of the window. This property is set to true
- * if outer handles are defined.
- *
- * @property hasOuterHandles
- * @type boolean
- * @default false
- */
- hasOuterHandles: false,
-
- /**
- * Code that executes immediately before the startDrag event
- * @method b4StartDrag
- * @private
- */
- b4StartDrag: function(x, y) { },
-
- /**
- * Abstract method called after a drag/drop object is clicked
- * and the drag or mousedown time thresholds have beeen met.
- * @method startDrag
- * @param {int} X click location
- * @param {int} Y click location
- */
- startDrag: function(x, y) { /* override this */ },
-
- /**
- * Code that executes immediately before the onDrag event
- * @method b4Drag
- * @private
- */
- b4Drag: function(e) { },
-
- /**
- * Abstract method called during the onMouseMove event while dragging an
- * object.
- * @method onDrag
- * @param {Event} e the mousemove event
- */
- onDrag: function(e) { /* override this */ },
-
- /**
- * Abstract method called when this element fist begins hovering over
- * another DragDrop obj
- * @method onDragEnter
- * @param {Event} e the mousemove event
- * @param {String|DragDrop[]} id In POINT mode, the element
- * id this is hovering over. In INTERSECT mode, an array of one or more
- * dragdrop items being hovered over.
- */
- onDragEnter: function(e, id) { /* override this */ },
-
- /**
- * Code that executes immediately before the onDragOver event
- * @method b4DragOver
- * @private
- */
- b4DragOver: function(e) { },
-
- /**
- * Abstract method called when this element is hovering over another
- * DragDrop obj
- * @method onDragOver
- * @param {Event} e the mousemove event
- * @param {String|DragDrop[]} id In POINT mode, the element
- * id this is hovering over. In INTERSECT mode, an array of dd items
- * being hovered over.
- */
- onDragOver: function(e, id) { /* override this */ },
-
- /**
- * Code that executes immediately before the onDragOut event
- * @method b4DragOut
- * @private
- */
- b4DragOut: function(e) { },
-
- /**
- * Abstract method called when we are no longer hovering over an element
- * @method onDragOut
- * @param {Event} e the mousemove event
- * @param {String|DragDrop[]} id In POINT mode, the element
- * id this was hovering over. In INTERSECT mode, an array of dd items
- * that the mouse is no longer over.
- */
- onDragOut: function(e, id) { /* override this */ },
-
- /**
- * Code that executes immediately before the onDragDrop event
- * @method b4DragDrop
- * @private
- */
- b4DragDrop: function(e) { },
-
- /**
- * Abstract method called when this item is dropped on another DragDrop
- * obj
- * @method onDragDrop
- * @param {Event} e the mouseup event
- * @param {String|DragDrop[]} id In POINT mode, the element
- * id this was dropped on. In INTERSECT mode, an array of dd items this
- * was dropped on.
- */
- onDragDrop: function(e, id) { /* override this */ },
-
- /**
- * Abstract method called when this item is dropped on an area with no
- * drop target
- * @method onInvalidDrop
- * @param {Event} e the mouseup event
- */
- onInvalidDrop: function(e) { /* override this */ },
-
- /**
- * Code that executes immediately before the endDrag event
- * @method b4EndDrag
- * @private
- */
- b4EndDrag: function(e) { },
-
- /**
- * Fired when we are done dragging the object
- * @method endDrag
- * @param {Event} e the mouseup event
- */
- endDrag: function(e) { /* override this */ },
-
- /**
- * Code executed immediately before the onMouseDown event
- * @method b4MouseDown
- * @param {Event} e the mousedown event
- * @private
- */
- b4MouseDown: function(e) { },
-
- /**
- * Event handler that fires when a drag/drop obj gets a mousedown
- * @method onMouseDown
- * @param {Event} e the mousedown event
- */
- onMouseDown: function(e) { /* override this */ },
-
- /**
- * Event handler that fires when a drag/drop obj gets a mouseup
- * @method onMouseUp
- * @param {Event} e the mouseup event
- */
- onMouseUp: function(e) { /* override this */ },
-
- /**
- * Override the onAvailable method to do what is needed after the initial
- * position was determined.
- * @method onAvailable
- */
- onAvailable: function () {
- this.logger.log("onAvailable (base)");
- },
-
- /**
- * Returns a reference to the linked element
- * @method getEl
- * @return {HTMLElement} the html element
- */
- getEl: function() {
- if (!this._domRef) {
- this._domRef = Dom.get(this.id);
- }
-
- return this._domRef;
- },
-
- /**
- * Returns a reference to the actual element to drag. By default this is
- * the same as the html element, but it can be assigned to another
- * element. An example of this can be found in YAHOO.util.DDProxy
- * @method getDragEl
- * @return {HTMLElement} the html element
- */
- getDragEl: function() {
- return Dom.get(this.dragElId);
- },
-
- /**
- * Sets up the DragDrop object. Must be called in the constructor of any
- * YAHOO.util.DragDrop subclass
- * @method init
- * @param id the id of the linked element
- * @param {String} sGroup the group of related items
- * @param {object} config configuration attributes
- */
- init: function(id, sGroup, config) {
- this.initTarget(id, sGroup, config);
- Event.on(this.id, "mousedown", this.handleMouseDown, this, true);
- // Event.on(this.id, "selectstart", Event.preventDefault);
- },
-
- /**
- * Initializes Targeting functionality only... the object does not
- * get a mousedown handler.
- * @method initTarget
- * @param id the id of the linked element
- * @param {String} sGroup the group of related items
- * @param {object} config configuration attributes
- */
- initTarget: function(id, sGroup, config) {
-
- // configuration attributes
- this.config = config || {};
-
- // create a local reference to the drag and drop manager
- this.DDM = YAHOO.util.DDM;
- // initialize the groups array
- this.groups = {};
-
- // assume that we have an element reference instead of an id if the
- // parameter is not a string
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
-
- // set the id
- this.id = id;
-
- // add to an interaction group
- this.addToGroup((sGroup) ? sGroup : "default");
-
- // We don't want to register this as the handle with the manager
- // so we just set the id rather than calling the setter.
- this.handleElId = id;
-
- Event.onAvailable(id, this.handleOnAvailable, this, true);
-
- // create a logger instance
- this.logger = (YAHOO.widget.LogWriter) ?
- new YAHOO.widget.LogWriter(this.toString()) : YAHOO;
-
- // the linked element is the element that gets dragged by default
- this.setDragElId(id);
-
- // by default, clicked anchors will not start drag operations.
- // @TODO what else should be here? Probably form fields.
- this.invalidHandleTypes = { A: "A" };
- this.invalidHandleIds = {};
- this.invalidHandleClasses = [];
-
- this.applyConfig();
- },
-
- /**
- * Applies the configuration parameters that were passed into the constructor.
- * This is supposed to happen at each level through the inheritance chain. So
- * a DDProxy implentation will execute apply config on DDProxy, DD, and
- * DragDrop in order to get all of the parameters that are available in
- * each object.
- * @method applyConfig
- */
- applyConfig: function() {
-
- // configurable properties:
- // padding, isTarget, maintainOffset, primaryButtonOnly
- this.padding = this.config.padding || [0, 0, 0, 0];
- this.isTarget = (this.config.isTarget !== false);
- this.maintainOffset = (this.config.maintainOffset);
- this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
-
- },
-
- /**
- * Executed when the linked element is available
- * @method handleOnAvailable
- * @private
- */
- handleOnAvailable: function() {
- this.logger.log("handleOnAvailable");
- this.available = true;
- this.resetConstraints();
- this.onAvailable();
- },
-
- /**
- * Configures the padding for the target zone in px. Effectively expands
- * (or reduces) the virtual object size for targeting calculations.
- * Supports css-style shorthand; if only one parameter is passed, all sides
- * will have that padding, and if only two are passed, the top and bottom
- * will have the first param, the left and right the second.
- * @method setPadding
- * @param {int} iTop Top pad
- * @param {int} iRight Right pad
- * @param {int} iBot Bot pad
- * @param {int} iLeft Left pad
- */
- setPadding: function(iTop, iRight, iBot, iLeft) {
- // this.padding = [iLeft, iRight, iTop, iBot];
- if (!iRight && 0 !== iRight) {
- this.padding = [iTop, iTop, iTop, iTop];
- } else if (!iBot && 0 !== iBot) {
- this.padding = [iTop, iRight, iTop, iRight];
- } else {
- this.padding = [iTop, iRight, iBot, iLeft];
- }
- },
-
- /**
- * Stores the initial placement of the linked element.
- * @method setInitialPosition
- * @param {int} diffX the X offset, default 0
- * @param {int} diffY the Y offset, default 0
- */
- setInitPosition: function(diffX, diffY) {
- var el = this.getEl();
-
- if (!this.DDM.verifyEl(el)) {
- this.logger.log(this.id + " element is broken");
- return;
- }
-
- var dx = diffX || 0;
- var dy = diffY || 0;
-
- var p = Dom.getXY( el );
-
- this.initPageX = p[0] - dx;
- this.initPageY = p[1] - dy;
-
- this.lastPageX = p[0];
- this.lastPageY = p[1];
-
- this.logger.log(this.id + " inital position: " + this.initPageX +
- ", " + this.initPageY);
-
-
- this.setStartPosition(p);
- },
-
- /**
- * Sets the start position of the element. This is set when the obj
- * is initialized, the reset when a drag is started.
- * @method setStartPosition
- * @param pos current position (from previous lookup)
- * @private
- */
- setStartPosition: function(pos) {
- var p = pos || Dom.getXY( this.getEl() );
-
- this.deltaSetXY = null;
-
- this.startPageX = p[0];
- this.startPageY = p[1];
- },
-
- /**
- * Add this instance to a group of related drag/drop objects. All
- * instances belong to at least one group, and can belong to as many
- * groups as needed.
- * @method addToGroup
- * @param sGroup {string} the name of the group
- */
- addToGroup: function(sGroup) {
- this.groups[sGroup] = true;
- this.DDM.regDragDrop(this, sGroup);
- },
-
- /**
- * Remove's this instance from the supplied interaction group
- * @method removeFromGroup
- * @param {string} sGroup The group to drop
- */
- removeFromGroup: function(sGroup) {
- this.logger.log("Removing from group: " + sGroup);
- if (this.groups[sGroup]) {
- delete this.groups[sGroup];
- }
-
- this.DDM.removeDDFromGroup(this, sGroup);
- },
-
- /**
- * Allows you to specify that an element other than the linked element
- * will be moved with the cursor during a drag
- * @method setDragElId
- * @param id {string} the id of the element that will be used to initiate the drag
- */
- setDragElId: function(id) {
- this.dragElId = id;
- },
-
- /**
- * Allows you to specify a child of the linked element that should be
- * used to initiate the drag operation. An example of this would be if
- * you have a content div with text and links. Clicking anywhere in the
- * content area would normally start the drag operation. Use this method
- * to specify that an element inside of the content div is the element
- * that starts the drag operation.
- * @method setHandleElId
- * @param id {string} the id of the element that will be used to
- * initiate the drag.
- */
- setHandleElId: function(id) {
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
- this.handleElId = id;
- this.DDM.regHandle(this.id, id);
- },
-
- /**
- * Allows you to set an element outside of the linked element as a drag
- * handle
- * @method setOuterHandleElId
- * @param id the id of the element that will be used to initiate the drag
- */
- setOuterHandleElId: function(id) {
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
- this.logger.log("Adding outer handle event: " + id);
- Event.on(id, "mousedown",
- this.handleMouseDown, this, true);
- this.setHandleElId(id);
-
- this.hasOuterHandles = true;
- },
-
- /**
- * Remove all drag and drop hooks for this element
- * @method unreg
- */
- unreg: function() {
- this.logger.log("DragDrop obj cleanup " + this.id);
- Event.removeListener(this.id, "mousedown",
- this.handleMouseDown);
- this._domRef = null;
- this.DDM._remove(this);
- },
-
- /**
- * Returns true if this instance is locked, or the drag drop mgr is locked
- * (meaning that all drag/drop is disabled on the page.)
- * @method isLocked
- * @return {boolean} true if this obj or all drag/drop is locked, else
- * false
- */
- isLocked: function() {
- return (this.DDM.isLocked() || this.locked);
- },
-
- /**
- * Fired when this object is clicked
- * @method handleMouseDown
- * @param {Event} e
- * @param {YAHOO.util.DragDrop} oDD the clicked dd object (this dd obj)
- * @private
- */
- handleMouseDown: function(e, oDD) {
-
- var button = e.which || e.button;
- this.logger.log("button: " + button);
-
- if (this.primaryButtonOnly && button > 1) {
- this.logger.log("Mousedown was not produced by the primary button");
- return;
- }
-
- if (this.isLocked()) {
- this.logger.log("Drag and drop is disabled, aborting");
- return;
- }
-
- this.logger.log("mousedown " + this.id);
- this.DDM.refreshCache(this.groups);
- // var self = this;
- // setTimeout( function() { self.DDM.refreshCache(self.groups); }, 0);
-
- // Only process the event if we really clicked within the linked
- // element. The reason we make this check is that in the case that
- // another element was moved between the clicked element and the
- // cursor in the time between the mousedown and mouseup events. When
- // this happens, the element gets the next mousedown event
- // regardless of where on the screen it happened.
- var pt = new YAHOO.util.Point(Event.getPageX(e), Event.getPageY(e));
- if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
- this.logger.log("Click was not over the element: " + this.id);
- } else {
- if (this.clickValidator(e)) {
-
- this.logger.log("click was a valid handle");
-
- // set the initial element position
- this.setStartPosition();
-
- this.logger.log("firing onMouseDown events");
-
- this.b4MouseDown(e);
- this.onMouseDown(e);
- this.DDM.handleMouseDown(e, this);
-
- this.DDM.stopEvent(e);
- } else {
-
-this.logger.log("clickValidator returned false, drag not initiated");
-
- }
- }
- },
-
- clickValidator: function(e) {
- var target = Event.getTarget(e);
- return ( this.isValidHandleChild(target) &&
- (this.id == this.handleElId ||
- this.DDM.handleWasClicked(target, this.id)) );
- },
-
- /**
- * Allows you to specify a tag name that should not start a drag operation
- * when clicked. This is designed to facilitate embedding links within a
- * drag handle that do something other than start the drag.
- * @method addInvalidHandleType
- * @param {string} tagName the type of element to exclude
- */
- addInvalidHandleType: function(tagName) {
- var type = tagName.toUpperCase();
- this.invalidHandleTypes[type] = type;
- },
-
- /**
- * Lets you to specify an element id for a child of a drag handle
- * that should not initiate a drag
- * @method addInvalidHandleId
- * @param {string} id the element id of the element you wish to ignore
- */
- addInvalidHandleId: function(id) {
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
- this.invalidHandleIds[id] = id;
- },
-
-
- /**
- * Lets you specify a css class of elements that will not initiate a drag
- * @method addInvalidHandleClass
- * @param {string} cssClass the class of the elements you wish to ignore
- */
- addInvalidHandleClass: function(cssClass) {
- this.invalidHandleClasses.push(cssClass);
- },
-
- /**
- * Unsets an excluded tag name set by addInvalidHandleType
- * @method removeInvalidHandleType
- * @param {string} tagName the type of element to unexclude
- */
- removeInvalidHandleType: function(tagName) {
- var type = tagName.toUpperCase();
- // this.invalidHandleTypes[type] = null;
- delete this.invalidHandleTypes[type];
- },
-
- /**
- * Unsets an invalid handle id
- * @method removeInvalidHandleId
- * @param {string} id the id of the element to re-enable
- */
- removeInvalidHandleId: function(id) {
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
- delete this.invalidHandleIds[id];
- },
-
- /**
- * Unsets an invalid css class
- * @method removeInvalidHandleClass
- * @param {string} cssClass the class of the element(s) you wish to
- * re-enable
- */
- removeInvalidHandleClass: function(cssClass) {
- for (var i=0, len=this.invalidHandleClasses.length; i= this.minX; i = i - iTickSize) {
- if (!tickMap[i]) {
- this.xTicks[this.xTicks.length] = i;
- tickMap[i] = true;
- }
- }
-
- for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
- if (!tickMap[i]) {
- this.xTicks[this.xTicks.length] = i;
- tickMap[i] = true;
- }
- }
-
- this.xTicks.sort(this.DDM.numericSort) ;
- this.logger.log("xTicks: " + this.xTicks.join());
- },
-
- /**
- * Create the array of vertical tick marks if an interval was specified in
- * setYConstraint().
- * @method setYTicks
- * @private
- */
- setYTicks: function(iStartY, iTickSize) {
- // this.logger.log("setYTicks: " + iStartY + ", " + iTickSize
- // + ", " + this.initPageY + ", " + this.minY + ", " + this.maxY );
- this.yTicks = [];
- this.yTickSize = iTickSize;
-
- var tickMap = {};
-
- for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
- if (!tickMap[i]) {
- this.yTicks[this.yTicks.length] = i;
- tickMap[i] = true;
- }
- }
-
- for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
- if (!tickMap[i]) {
- this.yTicks[this.yTicks.length] = i;
- tickMap[i] = true;
- }
- }
-
- this.yTicks.sort(this.DDM.numericSort) ;
- this.logger.log("yTicks: " + this.yTicks.join());
- },
-
- /**
- * By default, the element can be dragged any place on the screen. Use
- * this method to limit the horizontal travel of the element. Pass in
- * 0,0 for the parameters if you want to lock the drag to the y axis.
- * @method setXConstraint
- * @param {int} iLeft the number of pixels the element can move to the left
- * @param {int} iRight the number of pixels the element can move to the
- * right
- * @param {int} iTickSize optional parameter for specifying that the
- * element
- * should move iTickSize pixels at a time.
- */
- setXConstraint: function(iLeft, iRight, iTickSize) {
- this.leftConstraint = iLeft;
- this.rightConstraint = iRight;
-
- this.minX = this.initPageX - iLeft;
- this.maxX = this.initPageX + iRight;
- if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
-
- this.constrainX = true;
- this.logger.log("initPageX:" + this.initPageX + " minX:" + this.minX +
- " maxX:" + this.maxX);
- },
-
- /**
- * Clears any constraints applied to this instance. Also clears ticks
- * since they can't exist independent of a constraint at this time.
- * @method clearConstraints
- */
- clearConstraints: function() {
- this.logger.log("Clearing constraints");
- this.constrainX = false;
- this.constrainY = false;
- this.clearTicks();
- },
-
- /**
- * Clears any tick interval defined for this instance
- * @method clearTicks
- */
- clearTicks: function() {
- this.logger.log("Clearing ticks");
- this.xTicks = null;
- this.yTicks = null;
- this.xTickSize = 0;
- this.yTickSize = 0;
- },
-
- /**
- * By default, the element can be dragged any place on the screen. Set
- * this to limit the vertical travel of the element. Pass in 0,0 for the
- * parameters if you want to lock the drag to the x axis.
- * @method setYConstraint
- * @param {int} iUp the number of pixels the element can move up
- * @param {int} iDown the number of pixels the element can move down
- * @param {int} iTickSize optional parameter for specifying that the
- * element should move iTickSize pixels at a time.
- */
- setYConstraint: function(iUp, iDown, iTickSize) {
- this.logger.log("setYConstraint: " + iUp + "," + iDown + "," + iTickSize);
- this.topConstraint = iUp;
- this.bottomConstraint = iDown;
-
- this.minY = this.initPageY - iUp;
- this.maxY = this.initPageY + iDown;
- if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
-
- this.constrainY = true;
-
- this.logger.log("initPageY:" + this.initPageY + " minY:" + this.minY +
- " maxY:" + this.maxY);
- },
-
- /**
- * resetConstraints must be called if you manually reposition a dd element.
- * @method resetConstraints
- * @param {boolean} maintainOffset
- */
- resetConstraints: function() {
-
- this.logger.log("resetConstraints");
-
- // Maintain offsets if necessary
- if (this.initPageX || this.initPageX === 0) {
- this.logger.log("init pagexy: " + this.initPageX + ", " +
- this.initPageY);
- this.logger.log("last pagexy: " + this.lastPageX + ", " +
- this.lastPageY);
- // figure out how much this thing has moved
- var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
- var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
-
- this.setInitPosition(dx, dy);
-
- // This is the first time we have detected the element's position
- } else {
- this.setInitPosition();
- }
-
- if (this.constrainX) {
- this.setXConstraint( this.leftConstraint,
- this.rightConstraint,
- this.xTickSize );
- }
-
- if (this.constrainY) {
- this.setYConstraint( this.topConstraint,
- this.bottomConstraint,
- this.yTickSize );
- }
- },
-
- /**
- * Normally the drag element is moved pixel by pixel, but we can specify
- * that it move a number of pixels at a time. This method resolves the
- * location when we have it set up like this.
- * @method getTick
- * @param {int} val where we want to place the object
- * @param {int[]} tickArray sorted array of valid points
- * @return {int} the closest tick
- * @private
- */
- getTick: function(val, tickArray) {
-
- if (!tickArray) {
- // If tick interval is not defined, it is effectively 1 pixel,
- // so we return the value passed to us.
- return val;
- } else if (tickArray[0] >= val) {
- // The value is lower than the first tick, so we return the first
- // tick.
- return tickArray[0];
- } else {
- for (var i=0, len=tickArray.length; i= val) {
- var diff1 = val - tickArray[i];
- var diff2 = tickArray[next] - val;
- return (diff2 > diff1) ? tickArray[i] : tickArray[next];
- }
- }
-
- // The value is larger than the last tick, so we return the last
- // tick.
- return tickArray[tickArray.length - 1];
- }
- },
-
- /**
- * toString method
- * @method toString
- * @return {string} string representation of the dd obj
- */
- toString: function() {
- return ("DragDrop " + this.id);
- }
-
-};
-
-})();
-/**
- * The drag and drop utility provides a framework for building drag and drop
- * applications. In addition to enabling drag and drop for specific elements,
- * the drag and drop elements are tracked by the manager class, and the
- * interactions between the various elements are tracked during the drag and
- * the implementing code is notified about these important moments.
- * @module dragdrop
- * @title Drag and Drop
- * @requires yahoo,dom,event
- * @namespace YAHOO.util
- */
-
-// Only load the library once. Rewriting the manager class would orphan
-// existing drag and drop instances.
-if (!YAHOO.util.DragDropMgr) {
-
-/**
- * DragDropMgr is a singleton that tracks the element interaction for
- * all DragDrop items in the window. Generally, you will not call
- * this class directly, but it does have helper methods that could
- * be useful in your DragDrop implementations.
- * @class DragDropMgr
- * @static
- */
-YAHOO.util.DragDropMgr = function() {
-
- var Event = YAHOO.util.Event;
-
- return {
-
- /**
- * Two dimensional Array of registered DragDrop objects. The first
- * dimension is the DragDrop item group, the second the DragDrop
- * object.
- * @property ids
- * @type {string: string}
- * @private
- * @static
- */
- ids: {},
-
- /**
- * Array of element ids defined as drag handles. Used to determine
- * if the element that generated the mousedown event is actually the
- * handle and not the html element itself.
- * @property handleIds
- * @type {string: string}
- * @private
- * @static
- */
- handleIds: {},
-
- /**
- * the DragDrop object that is currently being dragged
- * @property dragCurrent
- * @type DragDrop
- * @private
- * @static
- **/
- dragCurrent: null,
-
- /**
- * the DragDrop object(s) that are being hovered over
- * @property dragOvers
- * @type Array
- * @private
- * @static
- */
- dragOvers: {},
-
- /**
- * the X distance between the cursor and the object being dragged
- * @property deltaX
- * @type int
- * @private
- * @static
- */
- deltaX: 0,
-
- /**
- * the Y distance between the cursor and the object being dragged
- * @property deltaY
- * @type int
- * @private
- * @static
- */
- deltaY: 0,
-
- /**
- * Flag to determine if we should prevent the default behavior of the
- * events we define. By default this is true, but this can be set to
- * false if you need the default behavior (not recommended)
- * @property preventDefault
- * @type boolean
- * @static
- */
- preventDefault: true,
-
- /**
- * Flag to determine if we should stop the propagation of the events
- * we generate. This is true by default but you may want to set it to
- * false if the html element contains other features that require the
- * mouse click.
- * @property stopPropagation
- * @type boolean
- * @static
- */
- stopPropagation: true,
-
- /**
- * Internal flag that is set to true when drag and drop has been
- * intialized
- * @property initialized
- * @private
- * @static
- */
- initalized: false,
-
- /**
- * All drag and drop can be disabled.
- * @property locked
- * @private
- * @static
- */
- locked: false,
-
- /**
- * Called the first time an element is registered.
- * @method init
- * @private
- * @static
- */
- init: function() {
- this.logger = new YAHOO.widget.LogWriter("DragDropMgr");
- this.initialized = true;
- },
-
- /**
- * In point mode, drag and drop interaction is defined by the
- * location of the cursor during the drag/drop
- * @property POINT
- * @type int
- * @static
- * @final
- */
- POINT: 0,
-
- /**
- * In intersect mode, drag and drop interaction is defined by the
- * cursor position or the amount of overlap of two or more drag and
- * drop objects.
- * @property INTERSECT
- * @type int
- * @static
- * @final
- */
- INTERSECT: 1,
-
- /**
- * In intersect mode, drag and drop interaction is defined only by the
- * overlap of two or more drag and drop objects.
- * @property STRICT_INTERSECT
- * @type int
- * @static
- * @final
- */
- STRICT_INTERSECT: 2,
-
- /**
- * The current drag and drop mode. Default: POINT
- * @property mode
- * @type int
- * @static
- */
- mode: 0,
-
- /**
- * Runs method on all drag and drop objects
- * @method _execOnAll
- * @private
- * @static
- */
- _execOnAll: function(sMethod, args) {
- for (var i in this.ids) {
- for (var j in this.ids[i]) {
- var oDD = this.ids[i][j];
- if (! this.isTypeOfDD(oDD)) {
- continue;
- }
- oDD[sMethod].apply(oDD, args);
- }
- }
- },
-
- /**
- * Drag and drop initialization. Sets up the global event handlers
- * @method _onLoad
- * @private
- * @static
- */
- _onLoad: function() {
-
- this.init();
-
- this.logger.log("DDM onload");
-
- Event.on(document, "mouseup", this.handleMouseUp, this, true);
- Event.on(document, "mousemove", this.handleMouseMove, this, true);
- Event.on(window, "unload", this._onUnload, this, true);
- Event.on(window, "resize", this._onResize, this, true);
- // Event.on(window, "mouseout", this._test);
-
- },
-
- /**
- * Reset constraints on all drag and drop objs
- * @method _onResize
- * @private
- * @static
- */
- _onResize: function(e) {
- this.logger.log("window resize");
- this._execOnAll("resetConstraints", []);
- },
-
- /**
- * Lock all drag and drop functionality
- * @method lock
- * @static
- */
- lock: function() { this.locked = true; },
-
- /**
- * Unlock all drag and drop functionality
- * @method unlock
- * @static
- */
- unlock: function() { this.locked = false; },
-
- /**
- * Is drag and drop locked?
- * @method isLocked
- * @return {boolean} True if drag and drop is locked, false otherwise.
- * @static
- */
- isLocked: function() { return this.locked; },
-
- /**
- * Location cache that is set for all drag drop objects when a drag is
- * initiated, cleared when the drag is finished.
- * @property locationCache
- * @private
- * @static
- */
- locationCache: {},
-
- /**
- * Set useCache to false if you want to force object the lookup of each
- * drag and drop linked element constantly during a drag.
- * @property useCache
- * @type boolean
- * @static
- */
- useCache: true,
-
- /**
- * The number of pixels that the mouse needs to move after the
- * mousedown before the drag is initiated. Default=3;
- * @property clickPixelThresh
- * @type int
- * @static
- */
- clickPixelThresh: 3,
-
- /**
- * The number of milliseconds after the mousedown event to initiate the
- * drag if we don't get a mouseup event. Default=1000
- * @property clickTimeThresh
- * @type int
- * @static
- */
- clickTimeThresh: 1000,
-
- /**
- * Flag that indicates that either the drag pixel threshold or the
- * mousdown time threshold has been met
- * @property dragThreshMet
- * @type boolean
- * @private
- * @static
- */
- dragThreshMet: false,
-
- /**
- * Timeout used for the click time threshold
- * @property clickTimeout
- * @type Object
- * @private
- * @static
- */
- clickTimeout: null,
-
- /**
- * The X position of the mousedown event stored for later use when a
- * drag threshold is met.
- * @property startX
- * @type int
- * @private
- * @static
- */
- startX: 0,
-
- /**
- * The Y position of the mousedown event stored for later use when a
- * drag threshold is met.
- * @property startY
- * @type int
- * @private
- * @static
- */
- startY: 0,
-
- /**
- * Each DragDrop instance must be registered with the DragDropMgr.
- * This is executed in DragDrop.init()
- * @method regDragDrop
- * @param {DragDrop} oDD the DragDrop object to register
- * @param {String} sGroup the name of the group this element belongs to
- * @static
- */
- regDragDrop: function(oDD, sGroup) {
- if (!this.initialized) { this.init(); }
-
- if (!this.ids[sGroup]) {
- this.ids[sGroup] = {};
- }
- this.ids[sGroup][oDD.id] = oDD;
- },
-
- /**
- * Removes the supplied dd instance from the supplied group. Executed
- * by DragDrop.removeFromGroup, so don't call this function directly.
- * @method removeDDFromGroup
- * @private
- * @static
- */
- removeDDFromGroup: function(oDD, sGroup) {
- if (!this.ids[sGroup]) {
- this.ids[sGroup] = {};
- }
-
- var obj = this.ids[sGroup];
- if (obj && obj[oDD.id]) {
- delete obj[oDD.id];
- }
- },
-
- /**
- * Unregisters a drag and drop item. This is executed in
- * DragDrop.unreg, use that method instead of calling this directly.
- * @method _remove
- * @private
- * @static
- */
- _remove: function(oDD) {
- for (var g in oDD.groups) {
- if (g && this.ids[g][oDD.id]) {
- delete this.ids[g][oDD.id];
- //this.logger.log("NEW LEN " + this.ids.length, "warn");
- }
- }
- delete this.handleIds[oDD.id];
- },
-
- /**
- * Each DragDrop handle element must be registered. This is done
- * automatically when executing DragDrop.setHandleElId()
- * @method regHandle
- * @param {String} sDDId the DragDrop id this element is a handle for
- * @param {String} sHandleId the id of the element that is the drag
- * handle
- * @static
- */
- regHandle: function(sDDId, sHandleId) {
- if (!this.handleIds[sDDId]) {
- this.handleIds[sDDId] = {};
- }
- this.handleIds[sDDId][sHandleId] = sHandleId;
- },
-
- /**
- * Utility function to determine if a given element has been
- * registered as a drag drop item.
- * @method isDragDrop
- * @param {String} id the element id to check
- * @return {boolean} true if this element is a DragDrop item,
- * false otherwise
- * @static
- */
- isDragDrop: function(id) {
- return ( this.getDDById(id) ) ? true : false;
- },
-
- /**
- * Returns the drag and drop instances that are in all groups the
- * passed in instance belongs to.
- * @method getRelated
- * @param {DragDrop} p_oDD the obj to get related data for
- * @param {boolean} bTargetsOnly if true, only return targetable objs
- * @return {DragDrop[]} the related instances
- * @static
- */
- getRelated: function(p_oDD, bTargetsOnly) {
- var oDDs = [];
- for (var i in p_oDD.groups) {
- for (j in this.ids[i]) {
- var dd = this.ids[i][j];
- if (! this.isTypeOfDD(dd)) {
- continue;
- }
- if (!bTargetsOnly || dd.isTarget) {
- oDDs[oDDs.length] = dd;
- }
- }
- }
-
- return oDDs;
- },
-
- /**
- * Returns true if the specified dd target is a legal target for
- * the specifice drag obj
- * @method isLegalTarget
- * @param {DragDrop} the drag obj
- * @param {DragDrop} the target
- * @return {boolean} true if the target is a legal target for the
- * dd obj
- * @static
- */
- isLegalTarget: function (oDD, oTargetDD) {
- var targets = this.getRelated(oDD, true);
- for (var i=0, len=targets.length;i this.clickPixelThresh ||
- diffY > this.clickPixelThresh) {
- this.logger.log("pixel threshold met");
- this.startDrag(this.startX, this.startY);
- }
- }
-
- if (this.dragThreshMet) {
- this.dragCurrent.b4Drag(e);
- this.dragCurrent.onDrag(e);
- this.fireEvents(e, false);
- }
-
- this.stopEvent(e);
-
- return true;
- },
-
- /**
- * Iterates over all of the DragDrop elements to find ones we are
- * hovering over or dropping on
- * @method fireEvents
- * @param {Event} e the event
- * @param {boolean} isDrop is this a drop op or a mouseover op?
- * @private
- * @static
- */
- fireEvents: function(e, isDrop) {
- var dc = this.dragCurrent;
-
- // If the user did the mouse up outside of the window, we could
- // get here even though we have ended the drag.
- if (!dc || dc.isLocked()) {
- return;
- }
-
- var x = YAHOO.util.Event.getPageX(e);
- var y = YAHOO.util.Event.getPageY(e);
- var pt = new YAHOO.util.Point(x,y);
-
- // cache the previous dragOver array
- var oldOvers = [];
-
- var outEvts = [];
- var overEvts = [];
- var dropEvts = [];
- var enterEvts = [];
-
- // Check to see if the object(s) we were hovering over is no longer
- // being hovered over so we can fire the onDragOut event
- for (var i in this.dragOvers) {
-
- var ddo = this.dragOvers[i];
-
- if (! this.isTypeOfDD(ddo)) {
- continue;
- }
-
- if (! this.isOverTarget(pt, ddo, this.mode)) {
- outEvts.push( ddo );
- }
-
- oldOvers[i] = true;
- delete this.dragOvers[i];
- }
-
- for (var sGroup in dc.groups) {
- // this.logger.log("Processing group " + sGroup);
-
- if ("string" != typeof sGroup) {
- continue;
- }
-
- for (i in this.ids[sGroup]) {
- var oDD = this.ids[sGroup][i];
- if (! this.isTypeOfDD(oDD)) {
- continue;
- }
-
- if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
- if (this.isOverTarget(pt, oDD, this.mode)) {
- // look for drop interactions
- if (isDrop) {
- dropEvts.push( oDD );
- // look for drag enter and drag over interactions
- } else {
-
- // initial drag over: dragEnter fires
- if (!oldOvers[oDD.id]) {
- enterEvts.push( oDD );
- // subsequent drag overs: dragOver fires
- } else {
- overEvts.push( oDD );
- }
-
- this.dragOvers[oDD.id] = oDD;
- }
- }
- }
- }
- }
-
- if (this.mode) {
- if (outEvts.length) {
- this.logger.log(dc.id+" onDragOut: " + outEvts);
- dc.b4DragOut(e, outEvts);
- dc.onDragOut(e, outEvts);
- }
-
- if (enterEvts.length) {
- this.logger.log(dc.id+" onDragEnter: " + enterEvts);
- dc.onDragEnter(e, enterEvts);
- }
-
- if (overEvts.length) {
- this.logger.log(dc.id+" onDragOver: " + overEvts);
- dc.b4DragOver(e, overEvts);
- dc.onDragOver(e, overEvts);
- }
-
- if (dropEvts.length) {
- this.logger.log(dc.id+" onDragDrop: " + dropEvts);
- dc.b4DragDrop(e, dropEvts);
- dc.onDragDrop(e, dropEvts);
- }
-
- } else {
- // fire dragout events
- var len = 0;
- for (i=0, len=outEvts.length; i
- * YAHOO.util.DragDropMgr.refreshCache(ddinstance.groups);
- *
- * Alternatively:
- *
- * YAHOO.util.DragDropMgr.refreshCache({group1:true, group2:true});
- *
- * @TODO this really should be an indexed array. Alternatively this
- * method could accept both.
- * @method refreshCache
- * @param {Object} groups an associative array of groups to refresh
- * @static
- */
- refreshCache: function(groups) {
- this.logger.log("refreshing element location cache");
- for (var sGroup in groups) {
- if ("string" != typeof sGroup) {
- continue;
- }
- for (var i in this.ids[sGroup]) {
- var oDD = this.ids[sGroup][i];
-
- if (this.isTypeOfDD(oDD)) {
- // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
- var loc = this.getLocation(oDD);
- if (loc) {
- this.locationCache[oDD.id] = loc;
- } else {
- delete this.locationCache[oDD.id];
- this.logger.log("Could not get the loc for " + oDD.id,
- "warn");
- // this will unregister the drag and drop object if
- // the element is not in a usable state
- // oDD.unreg();
- }
- }
- }
- }
- },
-
- /**
- * This checks to make sure an element exists and is in the DOM. The
- * main purpose is to handle cases where innerHTML is used to remove
- * drag and drop objects from the DOM. IE provides an 'unspecified
- * error' when trying to access the offsetParent of such an element
- * @method verifyEl
- * @param {HTMLElement} el the element to check
- * @return {boolean} true if the element looks usable
- * @static
- */
- verifyEl: function(el) {
- try {
- if (el) {
- var parent = el.offsetParent;
- if (parent) {
- return true;
- }
- }
- } catch(e) {
- this.logger.log("detected problem with an element");
- }
-
- return false;
- },
-
- /**
- * Returns a Region object containing the drag and drop element's position
- * and size, including the padding configured for it
- * @method getLocation
- * @param {DragDrop} oDD the drag and drop object to get the
- * location for
- * @return {YAHOO.util.Region} a Region object representing the total area
- * the element occupies, including any padding
- * the instance is configured for.
- * @static
- */
- getLocation: function(oDD) {
- if (! this.isTypeOfDD(oDD)) {
- this.logger.log(oDD + " is not a DD obj");
- return null;
- }
-
- var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
-
- try {
- pos= YAHOO.util.Dom.getXY(el);
- } catch (e) { }
-
- if (!pos) {
- this.logger.log("getXY failed");
- return null;
- }
-
- x1 = pos[0];
- x2 = x1 + el.offsetWidth;
- y1 = pos[1];
- y2 = y1 + el.offsetHeight;
-
- t = y1 - oDD.padding[0];
- r = x2 + oDD.padding[1];
- b = y2 + oDD.padding[2];
- l = x1 - oDD.padding[3];
-
- return new YAHOO.util.Region( t, r, b, l );
- },
-
- /**
- * Checks the cursor location to see if it over the target
- * @method isOverTarget
- * @param {YAHOO.util.Point} pt The point to evaluate
- * @param {DragDrop} oTarget the DragDrop object we are inspecting
- * @return {boolean} true if the mouse is over the target
- * @private
- * @static
- */
- isOverTarget: function(pt, oTarget, intersect) {
- // use cache if available
- var loc = this.locationCache[oTarget.id];
- if (!loc || !this.useCache) {
- this.logger.log("cache not populated");
- loc = this.getLocation(oTarget);
- this.locationCache[oTarget.id] = loc;
-
- this.logger.log("cache: " + loc);
- }
-
- if (!loc) {
- this.logger.log("could not get the location of the element");
- return false;
- }
-
- //this.logger.log("loc: " + loc + ", pt: " + pt);
- oTarget.cursorIsOver = loc.contains( pt );
-
- // DragDrop is using this as a sanity check for the initial mousedown
- // in this case we are done. In POINT mode, if the drag obj has no
- // contraints, we are also done. Otherwise we need to evaluate the
- // location of the target as related to the actual location of the
- // dragged element.
- var dc = this.dragCurrent;
- if (!dc || !dc.getTargetCoord ||
- (!intersect && !dc.constrainX && !dc.constrainY)) {
- return oTarget.cursorIsOver;
- }
-
- oTarget.overlap = null;
-
- // Get the current location of the drag element, this is the
- // location of the mouse event less the delta that represents
- // where the original mousedown happened on the element. We
- // need to consider constraints and ticks as well.
- var pos = dc.getTargetCoord(pt.x, pt.y);
-
- var el = dc.getDragEl();
- var curRegion = new YAHOO.util.Region( pos.y,
- pos.x + el.offsetWidth,
- pos.y + el.offsetHeight,
- pos.x );
-
- var overlap = curRegion.intersect(loc);
-
- if (overlap) {
- oTarget.overlap = overlap;
- return (intersect) ? true : oTarget.cursorIsOver;
- } else {
- return false;
- }
- },
-
- /**
- * unload event handler
- * @method _onUnload
- * @private
- * @static
- */
- _onUnload: function(e, me) {
- this.unregAll();
- },
-
- /**
- * Cleans up the drag and drop events and objects.
- * @method unregAll
- * @private
- * @static
- */
- unregAll: function() {
- this.logger.log("unregister all");
-
- if (this.dragCurrent) {
- this.stopDrag();
- this.dragCurrent = null;
- }
-
- this._execOnAll("unreg", []);
-
- for (i in this.elementCache) {
- delete this.elementCache[i];
- }
-
- this.elementCache = {};
- this.ids = {};
- },
-
- /**
- * A cache of DOM elements
- * @property elementCache
- * @private
- * @static
- */
- elementCache: {},
-
- /**
- * Get the wrapper for the DOM element specified
- * @method getElWrapper
- * @param {String} id the id of the element to get
- * @return {YAHOO.util.DDM.ElementWrapper} the wrapped element
- * @private
- * @deprecated This wrapper isn't that useful
- * @static
- */
- getElWrapper: function(id) {
- var oWrapper = this.elementCache[id];
- if (!oWrapper || !oWrapper.el) {
- oWrapper = this.elementCache[id] =
- new this.ElementWrapper(YAHOO.util.Dom.get(id));
- }
- return oWrapper;
- },
-
- /**
- * Returns the actual DOM element
- * @method getElement
- * @param {String} id the id of the elment to get
- * @return {Object} The element
- * @deprecated use YAHOO.util.Dom.get instead
- * @static
- */
- getElement: function(id) {
- return YAHOO.util.Dom.get(id);
- },
-
- /**
- * Returns the style property for the DOM element (i.e.,
- * document.getElById(id).style)
- * @method getCss
- * @param {String} id the id of the elment to get
- * @return {Object} The style property of the element
- * @deprecated use YAHOO.util.Dom instead
- * @static
- */
- getCss: function(id) {
- var el = YAHOO.util.Dom.get(id);
- return (el) ? el.style : null;
- },
-
- /**
- * Inner class for cached elements
- * @class DragDropMgr.ElementWrapper
- * @for DragDropMgr
- * @private
- * @deprecated
- */
- ElementWrapper: function(el) {
- /**
- * The element
- * @property el
- */
- this.el = el || null;
- /**
- * The element id
- * @property id
- */
- this.id = this.el && el.id;
- /**
- * A reference to the style property
- * @property css
- */
- this.css = this.el && el.style;
- },
-
- /**
- * Returns the X position of an html element
- * @method getPosX
- * @param el the element for which to get the position
- * @return {int} the X coordinate
- * @for DragDropMgr
- * @deprecated use YAHOO.util.Dom.getX instead
- * @static
- */
- getPosX: function(el) {
- return YAHOO.util.Dom.getX(el);
- },
-
- /**
- * Returns the Y position of an html element
- * @method getPosY
- * @param el the element for which to get the position
- * @return {int} the Y coordinate
- * @deprecated use YAHOO.util.Dom.getY instead
- * @static
- */
- getPosY: function(el) {
- return YAHOO.util.Dom.getY(el);
- },
-
- /**
- * Swap two nodes. In IE, we use the native method, for others we
- * emulate the IE behavior
- * @method swapNode
- * @param n1 the first node to swap
- * @param n2 the other node to swap
- * @static
- */
- swapNode: function(n1, n2) {
- if (n1.swapNode) {
- n1.swapNode(n2);
- } else {
- var p = n2.parentNode;
- var s = n2.nextSibling;
-
- if (s == n1) {
- p.insertBefore(n1, n2);
- } else if (n2 == n1.nextSibling) {
- p.insertBefore(n2, n1);
- } else {
- n1.parentNode.replaceChild(n2, n1);
- p.insertBefore(n1, s);
- }
- }
- },
-
- /**
- * Returns the current scroll position
- * @method getScroll
- * @private
- * @static
- */
- getScroll: function () {
- var t, l, dde=document.documentElement, db=document.body;
- if (dde && (dde.scrollTop || dde.scrollLeft)) {
- t = dde.scrollTop;
- l = dde.scrollLeft;
- } else if (db) {
- t = db.scrollTop;
- l = db.scrollLeft;
- } else {
- YAHOO.log("could not get scroll property");
- }
- return { top: t, left: l };
- },
-
- /**
- * Returns the specified element style property
- * @method getStyle
- * @param {HTMLElement} el the element
- * @param {string} styleProp the style property
- * @return {string} The value of the style property
- * @deprecated use YAHOO.util.Dom.getStyle
- * @static
- */
- getStyle: function(el, styleProp) {
- return YAHOO.util.Dom.getStyle(el, styleProp);
- },
-
- /**
- * Gets the scrollTop
- * @method getScrollTop
- * @return {int} the document's scrollTop
- * @static
- */
- getScrollTop: function () { return this.getScroll().top; },
-
- /**
- * Gets the scrollLeft
- * @method getScrollLeft
- * @return {int} the document's scrollTop
- * @static
- */
- getScrollLeft: function () { return this.getScroll().left; },
-
- /**
- * Sets the x/y position of an element to the location of the
- * target element.
- * @method moveToEl
- * @param {HTMLElement} moveEl The element to move
- * @param {HTMLElement} targetEl The position reference element
- * @static
- */
- moveToEl: function (moveEl, targetEl) {
- var aCoord = YAHOO.util.Dom.getXY(targetEl);
- this.logger.log("moveToEl: " + aCoord);
- YAHOO.util.Dom.setXY(moveEl, aCoord);
- },
-
- /**
- * Gets the client height
- * @method getClientHeight
- * @return {int} client height in px
- * @deprecated use YAHOO.util.Dom.getViewportHeight instead
- * @static
- */
- getClientHeight: function() {
- return YAHOO.util.Dom.getViewportHeight();
- },
-
- /**
- * Gets the client width
- * @method getClientWidth
- * @return {int} client width in px
- * @deprecated use YAHOO.util.Dom.getViewportWidth instead
- * @static
- */
- getClientWidth: function() {
- return YAHOO.util.Dom.getViewportWidth();
- },
-
- /**
- * Numeric array sort function
- * @method numericSort
- * @static
- */
- numericSort: function(a, b) { return (a - b); },
-
- /**
- * Internal counter
- * @property _timeoutCount
- * @private
- * @static
- */
- _timeoutCount: 0,
-
- /**
- * Trying to make the load order less important. Without this we get
- * an error if this file is loaded before the Event Utility.
- * @method _addListeners
- * @private
- * @static
- */
- _addListeners: function() {
- var DDM = YAHOO.util.DDM;
- if ( YAHOO.util.Event && document ) {
- DDM._onLoad();
- } else {
- if (DDM._timeoutCount > 2000) {
- DDM.logger.log("DragDrop requires the Event Utility");
- } else {
- setTimeout(DDM._addListeners, 10);
- if (document && document.body) {
- DDM._timeoutCount += 1;
- }
- }
- }
- },
-
- /**
- * Recursively searches the immediate parent and all child nodes for
- * the handle element in order to determine wheter or not it was
- * clicked.
- * @method handleWasClicked
- * @param node the html element to inspect
- * @static
- */
- handleWasClicked: function(node, id) {
- if (this.isHandle(id, node.id)) {
- this.logger.log("clicked node is a handle");
- return true;
- } else {
- // check to see if this is a text node child of the one we want
- var p = node.parentNode;
- // this.logger.log("p: " + p);
-
- while (p) {
- if (this.isHandle(id, p.id)) {
- return true;
- } else {
- this.logger.log(p.id + " is not a handle");
- p = p.parentNode;
- }
- }
- }
-
- return false;
- }
-
- };
-
-}();
-
-// shorter alias, save a few bytes
-YAHOO.util.DDM = YAHOO.util.DragDropMgr;
-YAHOO.util.DDM._addListeners();
-
-}
-
-/**
- * A DragDrop implementation where the linked element follows the
- * mouse cursor during a drag.
- * @class DD
- * @extends YAHOO.util.DragDrop
- * @constructor
- * @param {String} id the id of the linked element
- * @param {String} sGroup the group of related DragDrop items
- * @param {object} config an object containing configurable attributes
- * Valid properties for DD:
- * scroll
- */
-YAHOO.util.DD = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- }
-};
-
-YAHOO.extend(YAHOO.util.DD, YAHOO.util.DragDrop, {
-
- /**
- * When set to true, the utility automatically tries to scroll the browser
- * window wehn a drag and drop element is dragged near the viewport boundary.
- * Defaults to true.
- * @property scroll
- * @type boolean
- */
- scroll: true,
-
- /**
- * Sets the pointer offset to the distance between the linked element's top
- * left corner and the location the element was clicked
- * @method autoOffset
- * @param {int} iPageX the X coordinate of the click
- * @param {int} iPageY the Y coordinate of the click
- */
- autoOffset: function(iPageX, iPageY) {
- var x = iPageX - this.startPageX;
- var y = iPageY - this.startPageY;
- this.setDelta(x, y);
- // this.logger.log("autoOffset el pos: " + aCoord + ", delta: " + x + "," + y);
- },
-
- /**
- * Sets the pointer offset. You can call this directly to force the
- * offset to be in a particular location (e.g., pass in 0,0 to set it
- * to the center of the object, as done in YAHOO.widget.Slider)
- * @method setDelta
- * @param {int} iDeltaX the distance from the left
- * @param {int} iDeltaY the distance from the top
- */
- setDelta: function(iDeltaX, iDeltaY) {
- this.deltaX = iDeltaX;
- this.deltaY = iDeltaY;
- this.logger.log("deltaX:" + this.deltaX + ", deltaY:" + this.deltaY);
- },
-
- /**
- * Sets the drag element to the location of the mousedown or click event,
- * maintaining the cursor location relative to the location on the element
- * that was clicked. Override this if you want to place the element in a
- * location other than where the cursor is.
- * @method setDragElPos
- * @param {int} iPageX the X coordinate of the mousedown or drag event
- * @param {int} iPageY the Y coordinate of the mousedown or drag event
- */
- setDragElPos: function(iPageX, iPageY) {
- // the first time we do this, we are going to check to make sure
- // the element has css positioning
-
- var el = this.getDragEl();
- this.alignElWithMouse(el, iPageX, iPageY);
- },
-
- /**
- * Sets the element to the location of the mousedown or click event,
- * maintaining the cursor location relative to the location on the element
- * that was clicked. Override this if you want to place the element in a
- * location other than where the cursor is.
- * @method alignElWithMouse
- * @param {HTMLElement} el the element to move
- * @param {int} iPageX the X coordinate of the mousedown or drag event
- * @param {int} iPageY the Y coordinate of the mousedown or drag event
- */
- alignElWithMouse: function(el, iPageX, iPageY) {
- var oCoord = this.getTargetCoord(iPageX, iPageY);
- // this.logger.log("****alignElWithMouse : " + el.id + ", " + aCoord + ", " + el.style.display);
-
- if (!this.deltaSetXY) {
- var aCoord = [oCoord.x, oCoord.y];
- YAHOO.util.Dom.setXY(el, aCoord);
- var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
- var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
-
- this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
- } else {
- YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px");
- YAHOO.util.Dom.setStyle(el, "top", (oCoord.y + this.deltaSetXY[1]) + "px");
- }
-
- this.cachePosition(oCoord.x, oCoord.y);
- this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
- },
-
- /**
- * Saves the most recent position so that we can reset the constraints and
- * tick marks on-demand. We need to know this so that we can calculate the
- * number of pixels the element is offset from its original position.
- * @method cachePosition
- * @param iPageX the current x position (optional, this just makes it so we
- * don't have to look it up again)
- * @param iPageY the current y position (optional, this just makes it so we
- * don't have to look it up again)
- */
- cachePosition: function(iPageX, iPageY) {
- if (iPageX) {
- this.lastPageX = iPageX;
- this.lastPageY = iPageY;
- } else {
- var aCoord = YAHOO.util.Dom.getXY(this.getEl());
- this.lastPageX = aCoord[0];
- this.lastPageY = aCoord[1];
- }
- },
-
- /**
- * Auto-scroll the window if the dragged object has been moved beyond the
- * visible window boundary.
- * @method autoScroll
- * @param {int} x the drag element's x position
- * @param {int} y the drag element's y position
- * @param {int} h the height of the drag element
- * @param {int} w the width of the drag element
- * @private
- */
- autoScroll: function(x, y, h, w) {
-
- if (this.scroll) {
- // The client height
- var clientH = this.DDM.getClientHeight();
-
- // The client width
- var clientW = this.DDM.getClientWidth();
-
- // The amt scrolled down
- var st = this.DDM.getScrollTop();
-
- // The amt scrolled right
- var sl = this.DDM.getScrollLeft();
-
- // Location of the bottom of the element
- var bot = h + y;
-
- // Location of the right of the element
- var right = w + x;
-
- // The distance from the cursor to the bottom of the visible area,
- // adjusted so that we don't scroll if the cursor is beyond the
- // element drag constraints
- var toBot = (clientH + st - y - this.deltaY);
-
- // The distance from the cursor to the right of the visible area
- var toRight = (clientW + sl - x - this.deltaX);
-
- // this.logger.log( " x: " + x + " y: " + y + " h: " + h +
- // " clientH: " + clientH + " clientW: " + clientW +
- // " st: " + st + " sl: " + sl + " bot: " + bot +
- // " right: " + right + " toBot: " + toBot + " toRight: " + toRight);
-
- // How close to the edge the cursor must be before we scroll
- // var thresh = (document.all) ? 100 : 40;
- var thresh = 40;
-
- // How many pixels to scroll per autoscroll op. This helps to reduce
- // clunky scrolling. IE is more sensitive about this ... it needs this
- // value to be higher.
- var scrAmt = (document.all) ? 80 : 30;
-
- // Scroll down if we are near the bottom of the visible page and the
- // obj extends below the crease
- if ( bot > clientH && toBot < thresh ) {
- window.scrollTo(sl, st + scrAmt);
- }
-
- // Scroll up if the window is scrolled down and the top of the object
- // goes above the top border
- if ( y < st && st > 0 && y - st < thresh ) {
- window.scrollTo(sl, st - scrAmt);
- }
-
- // Scroll right if the obj is beyond the right border and the cursor is
- // near the border.
- if ( right > clientW && toRight < thresh ) {
- window.scrollTo(sl + scrAmt, st);
- }
-
- // Scroll left if the window has been scrolled to the right and the obj
- // extends past the left border
- if ( x < sl && sl > 0 && x - sl < thresh ) {
- window.scrollTo(sl - scrAmt, st);
- }
- }
- },
-
- /**
- * Finds the location the element should be placed if we want to move
- * it to where the mouse location less the click offset would place us.
- * @method getTargetCoord
- * @param {int} iPageX the X coordinate of the click
- * @param {int} iPageY the Y coordinate of the click
- * @return an object that contains the coordinates (Object.x and Object.y)
- * @private
- */
- getTargetCoord: function(iPageX, iPageY) {
-
- // this.logger.log("getTargetCoord: " + iPageX + ", " + iPageY);
-
- var x = iPageX - this.deltaX;
- var y = iPageY - this.deltaY;
-
- if (this.constrainX) {
- if (x < this.minX) { x = this.minX; }
- if (x > this.maxX) { x = this.maxX; }
- }
-
- if (this.constrainY) {
- if (y < this.minY) { y = this.minY; }
- if (y > this.maxY) { y = this.maxY; }
- }
-
- x = this.getTick(x, this.xTicks);
- y = this.getTick(y, this.yTicks);
-
- // this.logger.log("getTargetCoord " +
- // " iPageX: " + iPageX +
- // " iPageY: " + iPageY +
- // " x: " + x + ", y: " + y);
-
- return {x:x, y:y};
- },
-
- /*
- * Sets up config options specific to this class. Overrides
- * YAHOO.util.DragDrop, but all versions of this method through the
- * inheritance chain are called
- */
- applyConfig: function() {
- YAHOO.util.DD.superclass.applyConfig.call(this);
- this.scroll = (this.config.scroll !== false);
- },
-
- /*
- * Event that fires prior to the onMouseDown event. Overrides
- * YAHOO.util.DragDrop.
- */
- b4MouseDown: function(e) {
- // this.resetConstraints();
- this.autoOffset(YAHOO.util.Event.getPageX(e),
- YAHOO.util.Event.getPageY(e));
- },
-
- /*
- * Event that fires prior to the onDrag event. Overrides
- * YAHOO.util.DragDrop.
- */
- b4Drag: function(e) {
- this.setDragElPos(YAHOO.util.Event.getPageX(e),
- YAHOO.util.Event.getPageY(e));
- },
-
- toString: function() {
- return ("DD " + this.id);
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Debugging ygDragDrop events that can be overridden
- //////////////////////////////////////////////////////////////////////////
- /*
- startDrag: function(x, y) {
- this.logger.log(this.id.toString() + " startDrag");
- },
-
- onDrag: function(e) {
- this.logger.log(this.id.toString() + " onDrag");
- },
-
- onDragEnter: function(e, id) {
- this.logger.log(this.id.toString() + " onDragEnter: " + id);
- },
-
- onDragOver: function(e, id) {
- this.logger.log(this.id.toString() + " onDragOver: " + id);
- },
-
- onDragOut: function(e, id) {
- this.logger.log(this.id.toString() + " onDragOut: " + id);
- },
-
- onDragDrop: function(e, id) {
- this.logger.log(this.id.toString() + " onDragDrop: " + id);
- },
-
- endDrag: function(e) {
- this.logger.log(this.id.toString() + " endDrag");
- }
-
- */
-
-});
-/**
- * A DragDrop implementation that inserts an empty, bordered div into
- * the document that follows the cursor during drag operations. At the time of
- * the click, the frame div is resized to the dimensions of the linked html
- * element, and moved to the exact location of the linked element.
- *
- * References to the "frame" element refer to the single proxy element that
- * was created to be dragged in place of all DDProxy elements on the
- * page.
- *
- * @class DDProxy
- * @extends YAHOO.util.DD
- * @constructor
- * @param {String} id the id of the linked html element
- * @param {String} sGroup the group of related DragDrop objects
- * @param {object} config an object containing configurable attributes
- * Valid properties for DDProxy in addition to those in DragDrop:
- * resizeFrame, centerFrame, dragElId
- */
-YAHOO.util.DDProxy = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- this.initFrame();
- }
-};
-
-/**
- * The default drag frame div id
- * @property YAHOO.util.DDProxy.dragElId
- * @type String
- * @static
- */
-YAHOO.util.DDProxy.dragElId = "ygddfdiv";
-
-YAHOO.extend(YAHOO.util.DDProxy, YAHOO.util.DD, {
-
- /**
- * By default we resize the drag frame to be the same size as the element
- * we want to drag (this is to get the frame effect). We can turn it off
- * if we want a different behavior.
- * @property resizeFrame
- * @type boolean
- */
- resizeFrame: true,
-
- /**
- * By default the frame is positioned exactly where the drag element is, so
- * we use the cursor offset provided by YAHOO.util.DD. Another option that works only if
- * you do not have constraints on the obj is to have the drag frame centered
- * around the cursor. Set centerFrame to true for this effect.
- * @property centerFrame
- * @type boolean
- */
- centerFrame: false,
-
- /**
- * Creates the proxy element if it does not yet exist
- * @method createFrame
- */
- createFrame: function() {
- var self = this;
- var body = document.body;
-
- if (!body || !body.firstChild) {
- setTimeout( function() { self.createFrame(); }, 50 );
- return;
- }
-
- var div = this.getDragEl();
-
- if (!div) {
- div = document.createElement("div");
- div.id = this.dragElId;
- var s = div.style;
-
- s.position = "absolute";
- s.visibility = "hidden";
- s.cursor = "move";
- s.border = "2px solid #aaa";
- s.zIndex = 999;
-
- // appendChild can blow up IE if invoked prior to the window load event
- // while rendering a table. It is possible there are other scenarios
- // that would cause this to happen as well.
- body.insertBefore(div, body.firstChild);
- }
- },
-
- /**
- * Initialization for the drag frame element. Must be called in the
- * constructor of all subclasses
- * @method initFrame
- */
- initFrame: function() {
- this.createFrame();
- },
-
- applyConfig: function() {
- this.logger.log("DDProxy applyConfig");
- YAHOO.util.DDProxy.superclass.applyConfig.call(this);
-
- this.resizeFrame = (this.config.resizeFrame !== false);
- this.centerFrame = (this.config.centerFrame);
- this.setDragElId(this.config.dragElId || YAHOO.util.DDProxy.dragElId);
- },
-
- /**
- * Resizes the drag frame to the dimensions of the clicked object, positions
- * it over the object, and finally displays it
- * @method showFrame
- * @param {int} iPageX X click position
- * @param {int} iPageY Y click position
- * @private
- */
- showFrame: function(iPageX, iPageY) {
- var el = this.getEl();
- var dragEl = this.getDragEl();
- var s = dragEl.style;
-
- this._resizeProxy();
-
- if (this.centerFrame) {
- this.setDelta( Math.round(parseInt(s.width, 10)/2),
- Math.round(parseInt(s.height, 10)/2) );
- }
-
- this.setDragElPos(iPageX, iPageY);
-
- YAHOO.util.Dom.setStyle(dragEl, "visibility", "visible");
- },
-
- /**
- * The proxy is automatically resized to the dimensions of the linked
- * element when a drag is initiated, unless resizeFrame is set to false
- * @method _resizeProxy
- * @private
- */
- _resizeProxy: function() {
- if (this.resizeFrame) {
- var DOM = YAHOO.util.Dom;
- var el = this.getEl();
- var dragEl = this.getDragEl();
-
- var bt = parseInt( DOM.getStyle(dragEl, "borderTopWidth" ), 10);
- var br = parseInt( DOM.getStyle(dragEl, "borderRightWidth" ), 10);
- var bb = parseInt( DOM.getStyle(dragEl, "borderBottomWidth" ), 10);
- var bl = parseInt( DOM.getStyle(dragEl, "borderLeftWidth" ), 10);
-
- if (isNaN(bt)) { bt = 0; }
- if (isNaN(br)) { br = 0; }
- if (isNaN(bb)) { bb = 0; }
- if (isNaN(bl)) { bl = 0; }
-
- this.logger.log("proxy size: " + bt + " " + br + " " + bb + " " + bl);
-
- var newWidth = Math.max(0, el.offsetWidth - br - bl);
- var newHeight = Math.max(0, el.offsetHeight - bt - bb);
-
- this.logger.log("Resizing proxy element");
-
- DOM.setStyle( dragEl, "width", newWidth + "px" );
- DOM.setStyle( dragEl, "height", newHeight + "px" );
- }
- },
-
- // overrides YAHOO.util.DragDrop
- b4MouseDown: function(e) {
- var x = YAHOO.util.Event.getPageX(e);
- var y = YAHOO.util.Event.getPageY(e);
- this.autoOffset(x, y);
- this.setDragElPos(x, y);
- },
-
- // overrides YAHOO.util.DragDrop
- b4StartDrag: function(x, y) {
- // show the drag frame
- this.logger.log("start drag show frame, x: " + x + ", y: " + y);
- this.showFrame(x, y);
- },
-
- // overrides YAHOO.util.DragDrop
- b4EndDrag: function(e) {
- this.logger.log(this.id + " b4EndDrag");
- YAHOO.util.Dom.setStyle(this.getDragEl(), "visibility", "hidden");
- },
-
- // overrides YAHOO.util.DragDrop
- // By default we try to move the element to the last location of the frame.
- // This is so that the default behavior mirrors that of YAHOO.util.DD.
- endDrag: function(e) {
- var DOM = YAHOO.util.Dom;
- this.logger.log(this.id + " endDrag");
- var lel = this.getEl();
- var del = this.getDragEl();
-
- // Show the drag frame briefly so we can get its position
- // del.style.visibility = "";
- DOM.setStyle(del, "visibility", "");
-
- // Hide the linked element before the move to get around a Safari
- // rendering bug.
- //lel.style.visibility = "hidden";
- DOM.setStyle(lel, "visibility", "hidden");
- YAHOO.util.DDM.moveToEl(lel, del);
- //del.style.visibility = "hidden";
- DOM.setStyle(del, "visibility", "hidden");
- //lel.style.visibility = "";
- DOM.setStyle(lel, "visibility", "");
- },
-
- toString: function() {
- return ("DDProxy " + this.id);
- }
-
-});
-/**
- * A DragDrop implementation that does not move, but can be a drop
- * target. You would get the same result by simply omitting implementation
- * for the event callbacks, but this way we reduce the processing cost of the
- * event listener and the callbacks.
- * @class DDTarget
- * @extends YAHOO.util.DragDrop
- * @constructor
- * @param {String} id the id of the element that is a drop target
- * @param {String} sGroup the group of related DragDrop objects
- * @param {object} config an object containing configurable attributes
- * Valid properties for DDTarget in addition to those in
- * DragDrop:
- * none
- */
-YAHOO.util.DDTarget = function(id, sGroup, config) {
- if (id) {
- this.initTarget(id, sGroup, config);
- }
-};
-
-// YAHOO.util.DDTarget.prototype = new YAHOO.util.DragDrop();
-YAHOO.extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop, {
- toString: function() {
- return ("DDTarget " + this.id);
- }
-});
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+
+(function() {
+
+var Event=YAHOO.util.Event;
+var Dom=YAHOO.util.Dom;
+
+/**
+ * Defines the interface and base operation of items that that can be
+ * dragged or can be drop targets. It was designed to be extended, overriding
+ * the event handlers for startDrag, onDrag, onDragOver, onDragOut.
+ * Up to three html elements can be associated with a DragDrop instance:
+ *
+ * linked element: the element that is passed into the constructor.
+ * This is the element which defines the boundaries for interaction with
+ * other DragDrop objects.
+ * handle element(s): The drag operation only occurs if the element that
+ * was clicked matches a handle element. By default this is the linked
+ * element, but there are times that you will want only a portion of the
+ * linked element to initiate the drag operation, and the setHandleElId()
+ * method provides a way to define this.
+ * drag element: this represents an the element that would be moved along
+ * with the cursor during a drag operation. By default, this is the linked
+ * element itself as in {@link YAHOO.util.DD}. setDragElId() lets you define
+ * a separate element that would be moved, as in {@link YAHOO.util.DDProxy}
+ *
+ *
+ * This class should not be instantiated until the onload event to ensure that
+ * the associated elements are available.
+ * The following would define a DragDrop obj that would interact with any
+ * other DragDrop obj in the "group1" group:
+ *
+ * dd = new YAHOO.util.DragDrop("div1", "group1");
+ *
+ * Since none of the event handlers have been implemented, nothing would
+ * actually happen if you were to run the code above. Normally you would
+ * override this class or one of the default implementations, but you can
+ * also override the methods you want on an instance of the class...
+ *
+ * dd.onDragDrop = function(e, id) {
+ * alert("dd was dropped on " + id);
+ * }
+ *
+ * @namespace YAHOO.util
+ * @class DragDrop
+ * @constructor
+ * @param {String} id of the element that is linked to this instance
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DragDrop:
+ * padding, isTarget, maintainOffset, primaryButtonOnly,
+ */
+YAHOO.util.DragDrop = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+YAHOO.util.DragDrop.prototype = {
+
+ /**
+ * The id of the element associated with this object. This is what we
+ * refer to as the "linked element" because the size and position of
+ * this element is used to determine when the drag and drop objects have
+ * interacted.
+ * @property id
+ * @type String
+ */
+ id: null,
+
+ /**
+ * Configuration attributes passed into the constructor
+ * @property config
+ * @type object
+ */
+ config: null,
+
+ /**
+ * The id of the element that will be dragged. By default this is same
+ * as the linked element , but could be changed to another element. Ex:
+ * YAHOO.util.DDProxy
+ * @property dragElId
+ * @type String
+ * @private
+ */
+ dragElId: null,
+
+ /**
+ * the id of the element that initiates the drag operation. By default
+ * this is the linked element, but could be changed to be a child of this
+ * element. This lets us do things like only starting the drag when the
+ * header element within the linked html element is clicked.
+ * @property handleElId
+ * @type String
+ * @private
+ */
+ handleElId: null,
+
+ /**
+ * An associative array of HTML tags that will be ignored if clicked.
+ * @property invalidHandleTypes
+ * @type {string: string}
+ */
+ invalidHandleTypes: null,
+
+ /**
+ * An associative array of ids for elements that will be ignored if clicked
+ * @property invalidHandleIds
+ * @type {string: string}
+ */
+ invalidHandleIds: null,
+
+ /**
+ * An indexted array of css class names for elements that will be ignored
+ * if clicked.
+ * @property invalidHandleClasses
+ * @type string[]
+ */
+ invalidHandleClasses: null,
+
+ /**
+ * The linked element's absolute X position at the time the drag was
+ * started
+ * @property startPageX
+ * @type int
+ * @private
+ */
+ startPageX: 0,
+
+ /**
+ * The linked element's absolute X position at the time the drag was
+ * started
+ * @property startPageY
+ * @type int
+ * @private
+ */
+ startPageY: 0,
+
+ /**
+ * The group defines a logical collection of DragDrop objects that are
+ * related. Instances only get events when interacting with other
+ * DragDrop object in the same group. This lets us define multiple
+ * groups using a single DragDrop subclass if we want.
+ * @property groups
+ * @type {string: string}
+ */
+ groups: null,
+
+ /**
+ * Individual drag/drop instances can be locked. This will prevent
+ * onmousedown start drag.
+ * @property locked
+ * @type boolean
+ * @private
+ */
+ locked: false,
+
+ /**
+ * Lock this instance
+ * @method lock
+ */
+ lock: function() { this.locked = true; },
+
+ /**
+ * Unlock this instace
+ * @method unlock
+ */
+ unlock: function() { this.locked = false; },
+
+ /**
+ * By default, all insances can be a drop target. This can be disabled by
+ * setting isTarget to false.
+ * @method isTarget
+ * @type boolean
+ */
+ isTarget: true,
+
+ /**
+ * The padding configured for this drag and drop object for calculating
+ * the drop zone intersection with this object.
+ * @method padding
+ * @type int[]
+ */
+ padding: null,
+
+ /**
+ * Cached reference to the linked element
+ * @property _domRef
+ * @private
+ */
+ _domRef: null,
+
+ /**
+ * Internal typeof flag
+ * @property __ygDragDrop
+ * @private
+ */
+ __ygDragDrop: true,
+
+ /**
+ * Set to true when horizontal contraints are applied
+ * @property constrainX
+ * @type boolean
+ * @private
+ */
+ constrainX: false,
+
+ /**
+ * Set to true when vertical contraints are applied
+ * @property constrainY
+ * @type boolean
+ * @private
+ */
+ constrainY: false,
+
+ /**
+ * The left constraint
+ * @property minX
+ * @type int
+ * @private
+ */
+ minX: 0,
+
+ /**
+ * The right constraint
+ * @property maxX
+ * @type int
+ * @private
+ */
+ maxX: 0,
+
+ /**
+ * The up constraint
+ * @property minY
+ * @type int
+ * @type int
+ * @private
+ */
+ minY: 0,
+
+ /**
+ * The down constraint
+ * @property maxY
+ * @type int
+ * @private
+ */
+ maxY: 0,
+
+ /**
+ * Maintain offsets when we resetconstraints. Set to true when you want
+ * the position of the element relative to its parent to stay the same
+ * when the page changes
+ *
+ * @property maintainOffset
+ * @type boolean
+ */
+ maintainOffset: false,
+
+ /**
+ * Array of pixel locations the element will snap to if we specified a
+ * horizontal graduation/interval. This array is generated automatically
+ * when you define a tick interval.
+ * @property xTicks
+ * @type int[]
+ */
+ xTicks: null,
+
+ /**
+ * Array of pixel locations the element will snap to if we specified a
+ * vertical graduation/interval. This array is generated automatically
+ * when you define a tick interval.
+ * @property yTicks
+ * @type int[]
+ */
+ yTicks: null,
+
+ /**
+ * By default the drag and drop instance will only respond to the primary
+ * button click (left button for a right-handed mouse). Set to true to
+ * allow drag and drop to start with any mouse click that is propogated
+ * by the browser
+ * @property primaryButtonOnly
+ * @type boolean
+ */
+ primaryButtonOnly: true,
+
+ /**
+ * The availabe property is false until the linked dom element is accessible.
+ * @property available
+ * @type boolean
+ */
+ available: false,
+
+ /**
+ * By default, drags can only be initiated if the mousedown occurs in the
+ * region the linked element is. This is done in part to work around a
+ * bug in some browsers that mis-report the mousedown if the previous
+ * mouseup happened outside of the window. This property is set to true
+ * if outer handles are defined.
+ *
+ * @property hasOuterHandles
+ * @type boolean
+ * @default false
+ */
+ hasOuterHandles: false,
+
+ /**
+ * Code that executes immediately before the startDrag event
+ * @method b4StartDrag
+ * @private
+ */
+ b4StartDrag: function(x, y) { },
+
+ /**
+ * Abstract method called after a drag/drop object is clicked
+ * and the drag or mousedown time thresholds have beeen met.
+ * @method startDrag
+ * @param {int} X click location
+ * @param {int} Y click location
+ */
+ startDrag: function(x, y) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDrag event
+ * @method b4Drag
+ * @private
+ */
+ b4Drag: function(e) { },
+
+ /**
+ * Abstract method called during the onMouseMove event while dragging an
+ * object.
+ * @method onDrag
+ * @param {Event} e the mousemove event
+ */
+ onDrag: function(e) { /* override this */ },
+
+ /**
+ * Abstract method called when this element fist begins hovering over
+ * another DragDrop obj
+ * @method onDragEnter
+ * @param {Event} e the mousemove event
+ * @param {String|DragDrop[]} id In POINT mode, the element
+ * id this is hovering over. In INTERSECT mode, an array of one or more
+ * dragdrop items being hovered over.
+ */
+ onDragEnter: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragOver event
+ * @method b4DragOver
+ * @private
+ */
+ b4DragOver: function(e) { },
+
+ /**
+ * Abstract method called when this element is hovering over another
+ * DragDrop obj
+ * @method onDragOver
+ * @param {Event} e the mousemove event
+ * @param {String|DragDrop[]} id In POINT mode, the element
+ * id this is hovering over. In INTERSECT mode, an array of dd items
+ * being hovered over.
+ */
+ onDragOver: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragOut event
+ * @method b4DragOut
+ * @private
+ */
+ b4DragOut: function(e) { },
+
+ /**
+ * Abstract method called when we are no longer hovering over an element
+ * @method onDragOut
+ * @param {Event} e the mousemove event
+ * @param {String|DragDrop[]} id In POINT mode, the element
+ * id this was hovering over. In INTERSECT mode, an array of dd items
+ * that the mouse is no longer over.
+ */
+ onDragOut: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragDrop event
+ * @method b4DragDrop
+ * @private
+ */
+ b4DragDrop: function(e) { },
+
+ /**
+ * Abstract method called when this item is dropped on another DragDrop
+ * obj
+ * @method onDragDrop
+ * @param {Event} e the mouseup event
+ * @param {String|DragDrop[]} id In POINT mode, the element
+ * id this was dropped on. In INTERSECT mode, an array of dd items this
+ * was dropped on.
+ */
+ onDragDrop: function(e, id) { /* override this */ },
+
+ /**
+ * Abstract method called when this item is dropped on an area with no
+ * drop target
+ * @method onInvalidDrop
+ * @param {Event} e the mouseup event
+ */
+ onInvalidDrop: function(e) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the endDrag event
+ * @method b4EndDrag
+ * @private
+ */
+ b4EndDrag: function(e) { },
+
+ /**
+ * Fired when we are done dragging the object
+ * @method endDrag
+ * @param {Event} e the mouseup event
+ */
+ endDrag: function(e) { /* override this */ },
+
+ /**
+ * Code executed immediately before the onMouseDown event
+ * @method b4MouseDown
+ * @param {Event} e the mousedown event
+ * @private
+ */
+ b4MouseDown: function(e) { },
+
+ /**
+ * Event handler that fires when a drag/drop obj gets a mousedown
+ * @method onMouseDown
+ * @param {Event} e the mousedown event
+ */
+ onMouseDown: function(e) { /* override this */ },
+
+ /**
+ * Event handler that fires when a drag/drop obj gets a mouseup
+ * @method onMouseUp
+ * @param {Event} e the mouseup event
+ */
+ onMouseUp: function(e) { /* override this */ },
+
+ /**
+ * Override the onAvailable method to do what is needed after the initial
+ * position was determined.
+ * @method onAvailable
+ */
+ onAvailable: function () {
+ this.logger.log("onAvailable (base)");
+ },
+
+ /**
+ * Returns a reference to the linked element
+ * @method getEl
+ * @return {HTMLElement} the html element
+ */
+ getEl: function() {
+ if (!this._domRef) {
+ this._domRef = Dom.get(this.id);
+ }
+
+ return this._domRef;
+ },
+
+ /**
+ * Returns a reference to the actual element to drag. By default this is
+ * the same as the html element, but it can be assigned to another
+ * element. An example of this can be found in YAHOO.util.DDProxy
+ * @method getDragEl
+ * @return {HTMLElement} the html element
+ */
+ getDragEl: function() {
+ return Dom.get(this.dragElId);
+ },
+
+ /**
+ * Sets up the DragDrop object. Must be called in the constructor of any
+ * YAHOO.util.DragDrop subclass
+ * @method init
+ * @param id the id of the linked element
+ * @param {String} sGroup the group of related items
+ * @param {object} config configuration attributes
+ */
+ init: function(id, sGroup, config) {
+ this.initTarget(id, sGroup, config);
+ Event.on(this.id, "mousedown", this.handleMouseDown, this, true);
+ // Event.on(this.id, "selectstart", Event.preventDefault);
+ },
+
+ /**
+ * Initializes Targeting functionality only... the object does not
+ * get a mousedown handler.
+ * @method initTarget
+ * @param id the id of the linked element
+ * @param {String} sGroup the group of related items
+ * @param {object} config configuration attributes
+ */
+ initTarget: function(id, sGroup, config) {
+
+ // configuration attributes
+ this.config = config || {};
+
+ // create a local reference to the drag and drop manager
+ this.DDM = YAHOO.util.DDM;
+ // initialize the groups array
+ this.groups = {};
+
+ // assume that we have an element reference instead of an id if the
+ // parameter is not a string
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+
+ // set the id
+ this.id = id;
+
+ // add to an interaction group
+ this.addToGroup((sGroup) ? sGroup : "default");
+
+ // We don't want to register this as the handle with the manager
+ // so we just set the id rather than calling the setter.
+ this.handleElId = id;
+
+ Event.onAvailable(id, this.handleOnAvailable, this, true);
+
+ // create a logger instance
+ this.logger = (YAHOO.widget.LogWriter) ?
+ new YAHOO.widget.LogWriter(this.toString()) : YAHOO;
+
+ // the linked element is the element that gets dragged by default
+ this.setDragElId(id);
+
+ // by default, clicked anchors will not start drag operations.
+ // @TODO what else should be here? Probably form fields.
+ this.invalidHandleTypes = { A: "A" };
+ this.invalidHandleIds = {};
+ this.invalidHandleClasses = [];
+
+ this.applyConfig();
+ },
+
+ /**
+ * Applies the configuration parameters that were passed into the constructor.
+ * This is supposed to happen at each level through the inheritance chain. So
+ * a DDProxy implentation will execute apply config on DDProxy, DD, and
+ * DragDrop in order to get all of the parameters that are available in
+ * each object.
+ * @method applyConfig
+ */
+ applyConfig: function() {
+
+ // configurable properties:
+ // padding, isTarget, maintainOffset, primaryButtonOnly
+ this.padding = this.config.padding || [0, 0, 0, 0];
+ this.isTarget = (this.config.isTarget !== false);
+ this.maintainOffset = (this.config.maintainOffset);
+ this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
+
+ },
+
+ /**
+ * Executed when the linked element is available
+ * @method handleOnAvailable
+ * @private
+ */
+ handleOnAvailable: function() {
+ this.logger.log("handleOnAvailable");
+ this.available = true;
+ this.resetConstraints();
+ this.onAvailable();
+ },
+
+ /**
+ * Configures the padding for the target zone in px. Effectively expands
+ * (or reduces) the virtual object size for targeting calculations.
+ * Supports css-style shorthand; if only one parameter is passed, all sides
+ * will have that padding, and if only two are passed, the top and bottom
+ * will have the first param, the left and right the second.
+ * @method setPadding
+ * @param {int} iTop Top pad
+ * @param {int} iRight Right pad
+ * @param {int} iBot Bot pad
+ * @param {int} iLeft Left pad
+ */
+ setPadding: function(iTop, iRight, iBot, iLeft) {
+ // this.padding = [iLeft, iRight, iTop, iBot];
+ if (!iRight && 0 !== iRight) {
+ this.padding = [iTop, iTop, iTop, iTop];
+ } else if (!iBot && 0 !== iBot) {
+ this.padding = [iTop, iRight, iTop, iRight];
+ } else {
+ this.padding = [iTop, iRight, iBot, iLeft];
+ }
+ },
+
+ /**
+ * Stores the initial placement of the linked element.
+ * @method setInitialPosition
+ * @param {int} diffX the X offset, default 0
+ * @param {int} diffY the Y offset, default 0
+ */
+ setInitPosition: function(diffX, diffY) {
+ var el = this.getEl();
+
+ if (!this.DDM.verifyEl(el)) {
+ this.logger.log(this.id + " element is broken");
+ return;
+ }
+
+ var dx = diffX || 0;
+ var dy = diffY || 0;
+
+ var p = Dom.getXY( el );
+
+ this.initPageX = p[0] - dx;
+ this.initPageY = p[1] - dy;
+
+ this.lastPageX = p[0];
+ this.lastPageY = p[1];
+
+ this.logger.log(this.id + " inital position: " + this.initPageX +
+ ", " + this.initPageY);
+
+
+ this.setStartPosition(p);
+ },
+
+ /**
+ * Sets the start position of the element. This is set when the obj
+ * is initialized, the reset when a drag is started.
+ * @method setStartPosition
+ * @param pos current position (from previous lookup)
+ * @private
+ */
+ setStartPosition: function(pos) {
+ var p = pos || Dom.getXY( this.getEl() );
+
+ this.deltaSetXY = null;
+
+ this.startPageX = p[0];
+ this.startPageY = p[1];
+ },
+
+ /**
+ * Add this instance to a group of related drag/drop objects. All
+ * instances belong to at least one group, and can belong to as many
+ * groups as needed.
+ * @method addToGroup
+ * @param sGroup {string} the name of the group
+ */
+ addToGroup: function(sGroup) {
+ this.groups[sGroup] = true;
+ this.DDM.regDragDrop(this, sGroup);
+ },
+
+ /**
+ * Remove's this instance from the supplied interaction group
+ * @method removeFromGroup
+ * @param {string} sGroup The group to drop
+ */
+ removeFromGroup: function(sGroup) {
+ this.logger.log("Removing from group: " + sGroup);
+ if (this.groups[sGroup]) {
+ delete this.groups[sGroup];
+ }
+
+ this.DDM.removeDDFromGroup(this, sGroup);
+ },
+
+ /**
+ * Allows you to specify that an element other than the linked element
+ * will be moved with the cursor during a drag
+ * @method setDragElId
+ * @param id {string} the id of the element that will be used to initiate the drag
+ */
+ setDragElId: function(id) {
+ this.dragElId = id;
+ },
+
+ /**
+ * Allows you to specify a child of the linked element that should be
+ * used to initiate the drag operation. An example of this would be if
+ * you have a content div with text and links. Clicking anywhere in the
+ * content area would normally start the drag operation. Use this method
+ * to specify that an element inside of the content div is the element
+ * that starts the drag operation.
+ * @method setHandleElId
+ * @param id {string} the id of the element that will be used to
+ * initiate the drag.
+ */
+ setHandleElId: function(id) {
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+ this.handleElId = id;
+ this.DDM.regHandle(this.id, id);
+ },
+
+ /**
+ * Allows you to set an element outside of the linked element as a drag
+ * handle
+ * @method setOuterHandleElId
+ * @param id the id of the element that will be used to initiate the drag
+ */
+ setOuterHandleElId: function(id) {
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+ this.logger.log("Adding outer handle event: " + id);
+ Event.on(id, "mousedown",
+ this.handleMouseDown, this, true);
+ this.setHandleElId(id);
+
+ this.hasOuterHandles = true;
+ },
+
+ /**
+ * Remove all drag and drop hooks for this element
+ * @method unreg
+ */
+ unreg: function() {
+ this.logger.log("DragDrop obj cleanup " + this.id);
+ Event.removeListener(this.id, "mousedown",
+ this.handleMouseDown);
+ this._domRef = null;
+ this.DDM._remove(this);
+ },
+
+ /**
+ * Returns true if this instance is locked, or the drag drop mgr is locked
+ * (meaning that all drag/drop is disabled on the page.)
+ * @method isLocked
+ * @return {boolean} true if this obj or all drag/drop is locked, else
+ * false
+ */
+ isLocked: function() {
+ return (this.DDM.isLocked() || this.locked);
+ },
+
+ /**
+ * Fired when this object is clicked
+ * @method handleMouseDown
+ * @param {Event} e
+ * @param {YAHOO.util.DragDrop} oDD the clicked dd object (this dd obj)
+ * @private
+ */
+ handleMouseDown: function(e, oDD) {
+
+ var button = e.which || e.button;
+ this.logger.log("button: " + button);
+
+ if (this.primaryButtonOnly && button > 1) {
+ this.logger.log("Mousedown was not produced by the primary button");
+ return;
+ }
+
+ if (this.isLocked()) {
+ this.logger.log("Drag and drop is disabled, aborting");
+ return;
+ }
+
+ this.logger.log("mousedown " + this.id);
+ this.DDM.refreshCache(this.groups);
+ // var self = this;
+ // setTimeout( function() { self.DDM.refreshCache(self.groups); }, 0);
+
+ // Only process the event if we really clicked within the linked
+ // element. The reason we make this check is that in the case that
+ // another element was moved between the clicked element and the
+ // cursor in the time between the mousedown and mouseup events. When
+ // this happens, the element gets the next mousedown event
+ // regardless of where on the screen it happened.
+ var pt = new YAHOO.util.Point(Event.getPageX(e), Event.getPageY(e));
+ if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
+ this.logger.log("Click was not over the element: " + this.id);
+ } else {
+ if (this.clickValidator(e)) {
+
+ this.logger.log("click was a valid handle");
+
+ // set the initial element position
+ this.setStartPosition();
+
+ this.logger.log("firing onMouseDown events");
+
+ this.b4MouseDown(e);
+ this.onMouseDown(e);
+ this.DDM.handleMouseDown(e, this);
+
+ this.DDM.stopEvent(e);
+ } else {
+
+this.logger.log("clickValidator returned false, drag not initiated");
+
+ }
+ }
+ },
+
+ clickValidator: function(e) {
+ var target = Event.getTarget(e);
+ return ( this.isValidHandleChild(target) &&
+ (this.id == this.handleElId ||
+ this.DDM.handleWasClicked(target, this.id)) );
+ },
+
+ /**
+ * Allows you to specify a tag name that should not start a drag operation
+ * when clicked. This is designed to facilitate embedding links within a
+ * drag handle that do something other than start the drag.
+ * @method addInvalidHandleType
+ * @param {string} tagName the type of element to exclude
+ */
+ addInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+ this.invalidHandleTypes[type] = type;
+ },
+
+ /**
+ * Lets you to specify an element id for a child of a drag handle
+ * that should not initiate a drag
+ * @method addInvalidHandleId
+ * @param {string} id the element id of the element you wish to ignore
+ */
+ addInvalidHandleId: function(id) {
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+ this.invalidHandleIds[id] = id;
+ },
+
+
+ /**
+ * Lets you specify a css class of elements that will not initiate a drag
+ * @method addInvalidHandleClass
+ * @param {string} cssClass the class of the elements you wish to ignore
+ */
+ addInvalidHandleClass: function(cssClass) {
+ this.invalidHandleClasses.push(cssClass);
+ },
+
+ /**
+ * Unsets an excluded tag name set by addInvalidHandleType
+ * @method removeInvalidHandleType
+ * @param {string} tagName the type of element to unexclude
+ */
+ removeInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+ // this.invalidHandleTypes[type] = null;
+ delete this.invalidHandleTypes[type];
+ },
+
+ /**
+ * Unsets an invalid handle id
+ * @method removeInvalidHandleId
+ * @param {string} id the id of the element to re-enable
+ */
+ removeInvalidHandleId: function(id) {
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+ delete this.invalidHandleIds[id];
+ },
+
+ /**
+ * Unsets an invalid css class
+ * @method removeInvalidHandleClass
+ * @param {string} cssClass the class of the element(s) you wish to
+ * re-enable
+ */
+ removeInvalidHandleClass: function(cssClass) {
+ for (var i=0, len=this.invalidHandleClasses.length; i= this.minX; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.xTicks.sort(this.DDM.numericSort) ;
+ this.logger.log("xTicks: " + this.xTicks.join());
+ },
+
+ /**
+ * Create the array of vertical tick marks if an interval was specified in
+ * setYConstraint().
+ * @method setYTicks
+ * @private
+ */
+ setYTicks: function(iStartY, iTickSize) {
+ // this.logger.log("setYTicks: " + iStartY + ", " + iTickSize
+ // + ", " + this.initPageY + ", " + this.minY + ", " + this.maxY );
+ this.yTicks = [];
+ this.yTickSize = iTickSize;
+
+ var tickMap = {};
+
+ for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.yTicks.sort(this.DDM.numericSort) ;
+ this.logger.log("yTicks: " + this.yTicks.join());
+ },
+
+ /**
+ * By default, the element can be dragged any place on the screen. Use
+ * this method to limit the horizontal travel of the element. Pass in
+ * 0,0 for the parameters if you want to lock the drag to the y axis.
+ * @method setXConstraint
+ * @param {int} iLeft the number of pixels the element can move to the left
+ * @param {int} iRight the number of pixels the element can move to the
+ * right
+ * @param {int} iTickSize optional parameter for specifying that the
+ * element
+ * should move iTickSize pixels at a time.
+ */
+ setXConstraint: function(iLeft, iRight, iTickSize) {
+ this.leftConstraint = iLeft;
+ this.rightConstraint = iRight;
+
+ this.minX = this.initPageX - iLeft;
+ this.maxX = this.initPageX + iRight;
+ if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
+
+ this.constrainX = true;
+ this.logger.log("initPageX:" + this.initPageX + " minX:" + this.minX +
+ " maxX:" + this.maxX);
+ },
+
+ /**
+ * Clears any constraints applied to this instance. Also clears ticks
+ * since they can't exist independent of a constraint at this time.
+ * @method clearConstraints
+ */
+ clearConstraints: function() {
+ this.logger.log("Clearing constraints");
+ this.constrainX = false;
+ this.constrainY = false;
+ this.clearTicks();
+ },
+
+ /**
+ * Clears any tick interval defined for this instance
+ * @method clearTicks
+ */
+ clearTicks: function() {
+ this.logger.log("Clearing ticks");
+ this.xTicks = null;
+ this.yTicks = null;
+ this.xTickSize = 0;
+ this.yTickSize = 0;
+ },
+
+ /**
+ * By default, the element can be dragged any place on the screen. Set
+ * this to limit the vertical travel of the element. Pass in 0,0 for the
+ * parameters if you want to lock the drag to the x axis.
+ * @method setYConstraint
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the
+ * element should move iTickSize pixels at a time.
+ */
+ setYConstraint: function(iUp, iDown, iTickSize) {
+ this.logger.log("setYConstraint: " + iUp + "," + iDown + "," + iTickSize);
+ this.topConstraint = iUp;
+ this.bottomConstraint = iDown;
+
+ this.minY = this.initPageY - iUp;
+ this.maxY = this.initPageY + iDown;
+ if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
+
+ this.constrainY = true;
+
+ this.logger.log("initPageY:" + this.initPageY + " minY:" + this.minY +
+ " maxY:" + this.maxY);
+ },
+
+ /**
+ * resetConstraints must be called if you manually reposition a dd element.
+ * @method resetConstraints
+ * @param {boolean} maintainOffset
+ */
+ resetConstraints: function() {
+
+ this.logger.log("resetConstraints");
+
+ // Maintain offsets if necessary
+ if (this.initPageX || this.initPageX === 0) {
+ this.logger.log("init pagexy: " + this.initPageX + ", " +
+ this.initPageY);
+ this.logger.log("last pagexy: " + this.lastPageX + ", " +
+ this.lastPageY);
+ // figure out how much this thing has moved
+ var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
+ var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
+
+ this.setInitPosition(dx, dy);
+
+ // This is the first time we have detected the element's position
+ } else {
+ this.setInitPosition();
+ }
+
+ if (this.constrainX) {
+ this.setXConstraint( this.leftConstraint,
+ this.rightConstraint,
+ this.xTickSize );
+ }
+
+ if (this.constrainY) {
+ this.setYConstraint( this.topConstraint,
+ this.bottomConstraint,
+ this.yTickSize );
+ }
+ },
+
+ /**
+ * Normally the drag element is moved pixel by pixel, but we can specify
+ * that it move a number of pixels at a time. This method resolves the
+ * location when we have it set up like this.
+ * @method getTick
+ * @param {int} val where we want to place the object
+ * @param {int[]} tickArray sorted array of valid points
+ * @return {int} the closest tick
+ * @private
+ */
+ getTick: function(val, tickArray) {
+
+ if (!tickArray) {
+ // If tick interval is not defined, it is effectively 1 pixel,
+ // so we return the value passed to us.
+ return val;
+ } else if (tickArray[0] >= val) {
+ // The value is lower than the first tick, so we return the first
+ // tick.
+ return tickArray[0];
+ } else {
+ for (var i=0, len=tickArray.length; i= val) {
+ var diff1 = val - tickArray[i];
+ var diff2 = tickArray[next] - val;
+ return (diff2 > diff1) ? tickArray[i] : tickArray[next];
+ }
+ }
+
+ // The value is larger than the last tick, so we return the last
+ // tick.
+ return tickArray[tickArray.length - 1];
+ }
+ },
+
+ /**
+ * toString method
+ * @method toString
+ * @return {string} string representation of the dd obj
+ */
+ toString: function() {
+ return ("DragDrop " + this.id);
+ }
+
+};
+
+})();
+/**
+ * The drag and drop utility provides a framework for building drag and drop
+ * applications. In addition to enabling drag and drop for specific elements,
+ * the drag and drop elements are tracked by the manager class, and the
+ * interactions between the various elements are tracked during the drag and
+ * the implementing code is notified about these important moments.
+ * @module dragdrop
+ * @title Drag and Drop
+ * @requires yahoo,dom,event
+ * @namespace YAHOO.util
+ */
+
+// Only load the library once. Rewriting the manager class would orphan
+// existing drag and drop instances.
+if (!YAHOO.util.DragDropMgr) {
+
+/**
+ * DragDropMgr is a singleton that tracks the element interaction for
+ * all DragDrop items in the window. Generally, you will not call
+ * this class directly, but it does have helper methods that could
+ * be useful in your DragDrop implementations.
+ * @class DragDropMgr
+ * @static
+ */
+YAHOO.util.DragDropMgr = function() {
+
+ var Event = YAHOO.util.Event;
+
+ return {
+
+ /**
+ * Two dimensional Array of registered DragDrop objects. The first
+ * dimension is the DragDrop item group, the second the DragDrop
+ * object.
+ * @property ids
+ * @type {string: string}
+ * @private
+ * @static
+ */
+ ids: {},
+
+ /**
+ * Array of element ids defined as drag handles. Used to determine
+ * if the element that generated the mousedown event is actually the
+ * handle and not the html element itself.
+ * @property handleIds
+ * @type {string: string}
+ * @private
+ * @static
+ */
+ handleIds: {},
+
+ /**
+ * the DragDrop object that is currently being dragged
+ * @property dragCurrent
+ * @type DragDrop
+ * @private
+ * @static
+ **/
+ dragCurrent: null,
+
+ /**
+ * the DragDrop object(s) that are being hovered over
+ * @property dragOvers
+ * @type Array
+ * @private
+ * @static
+ */
+ dragOvers: {},
+
+ /**
+ * the X distance between the cursor and the object being dragged
+ * @property deltaX
+ * @type int
+ * @private
+ * @static
+ */
+ deltaX: 0,
+
+ /**
+ * the Y distance between the cursor and the object being dragged
+ * @property deltaY
+ * @type int
+ * @private
+ * @static
+ */
+ deltaY: 0,
+
+ /**
+ * Flag to determine if we should prevent the default behavior of the
+ * events we define. By default this is true, but this can be set to
+ * false if you need the default behavior (not recommended)
+ * @property preventDefault
+ * @type boolean
+ * @static
+ */
+ preventDefault: true,
+
+ /**
+ * Flag to determine if we should stop the propagation of the events
+ * we generate. This is true by default but you may want to set it to
+ * false if the html element contains other features that require the
+ * mouse click.
+ * @property stopPropagation
+ * @type boolean
+ * @static
+ */
+ stopPropagation: true,
+
+ /**
+ * Internal flag that is set to true when drag and drop has been
+ * intialized
+ * @property initialized
+ * @private
+ * @static
+ */
+ initalized: false,
+
+ /**
+ * All drag and drop can be disabled.
+ * @property locked
+ * @private
+ * @static
+ */
+ locked: false,
+
+ /**
+ * Called the first time an element is registered.
+ * @method init
+ * @private
+ * @static
+ */
+ init: function() {
+ this.logger = new YAHOO.widget.LogWriter("DragDropMgr");
+ this.initialized = true;
+ },
+
+ /**
+ * In point mode, drag and drop interaction is defined by the
+ * location of the cursor during the drag/drop
+ * @property POINT
+ * @type int
+ * @static
+ * @final
+ */
+ POINT: 0,
+
+ /**
+ * In intersect mode, drag and drop interaction is defined by the
+ * cursor position or the amount of overlap of two or more drag and
+ * drop objects.
+ * @property INTERSECT
+ * @type int
+ * @static
+ * @final
+ */
+ INTERSECT: 1,
+
+ /**
+ * In intersect mode, drag and drop interaction is defined only by the
+ * overlap of two or more drag and drop objects.
+ * @property STRICT_INTERSECT
+ * @type int
+ * @static
+ * @final
+ */
+ STRICT_INTERSECT: 2,
+
+ /**
+ * The current drag and drop mode. Default: POINT
+ * @property mode
+ * @type int
+ * @static
+ */
+ mode: 0,
+
+ /**
+ * Runs method on all drag and drop objects
+ * @method _execOnAll
+ * @private
+ * @static
+ */
+ _execOnAll: function(sMethod, args) {
+ for (var i in this.ids) {
+ for (var j in this.ids[i]) {
+ var oDD = this.ids[i][j];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+ oDD[sMethod].apply(oDD, args);
+ }
+ }
+ },
+
+ /**
+ * Drag and drop initialization. Sets up the global event handlers
+ * @method _onLoad
+ * @private
+ * @static
+ */
+ _onLoad: function() {
+
+ this.init();
+
+ this.logger.log("DDM onload");
+
+ Event.on(document, "mouseup", this.handleMouseUp, this, true);
+ Event.on(document, "mousemove", this.handleMouseMove, this, true);
+ Event.on(window, "unload", this._onUnload, this, true);
+ Event.on(window, "resize", this._onResize, this, true);
+ // Event.on(window, "mouseout", this._test);
+
+ },
+
+ /**
+ * Reset constraints on all drag and drop objs
+ * @method _onResize
+ * @private
+ * @static
+ */
+ _onResize: function(e) {
+ this.logger.log("window resize");
+ this._execOnAll("resetConstraints", []);
+ },
+
+ /**
+ * Lock all drag and drop functionality
+ * @method lock
+ * @static
+ */
+ lock: function() { this.locked = true; },
+
+ /**
+ * Unlock all drag and drop functionality
+ * @method unlock
+ * @static
+ */
+ unlock: function() { this.locked = false; },
+
+ /**
+ * Is drag and drop locked?
+ * @method isLocked
+ * @return {boolean} True if drag and drop is locked, false otherwise.
+ * @static
+ */
+ isLocked: function() { return this.locked; },
+
+ /**
+ * Location cache that is set for all drag drop objects when a drag is
+ * initiated, cleared when the drag is finished.
+ * @property locationCache
+ * @private
+ * @static
+ */
+ locationCache: {},
+
+ /**
+ * Set useCache to false if you want to force object the lookup of each
+ * drag and drop linked element constantly during a drag.
+ * @property useCache
+ * @type boolean
+ * @static
+ */
+ useCache: true,
+
+ /**
+ * The number of pixels that the mouse needs to move after the
+ * mousedown before the drag is initiated. Default=3;
+ * @property clickPixelThresh
+ * @type int
+ * @static
+ */
+ clickPixelThresh: 3,
+
+ /**
+ * The number of milliseconds after the mousedown event to initiate the
+ * drag if we don't get a mouseup event. Default=1000
+ * @property clickTimeThresh
+ * @type int
+ * @static
+ */
+ clickTimeThresh: 1000,
+
+ /**
+ * Flag that indicates that either the drag pixel threshold or the
+ * mousdown time threshold has been met
+ * @property dragThreshMet
+ * @type boolean
+ * @private
+ * @static
+ */
+ dragThreshMet: false,
+
+ /**
+ * Timeout used for the click time threshold
+ * @property clickTimeout
+ * @type Object
+ * @private
+ * @static
+ */
+ clickTimeout: null,
+
+ /**
+ * The X position of the mousedown event stored for later use when a
+ * drag threshold is met.
+ * @property startX
+ * @type int
+ * @private
+ * @static
+ */
+ startX: 0,
+
+ /**
+ * The Y position of the mousedown event stored for later use when a
+ * drag threshold is met.
+ * @property startY
+ * @type int
+ * @private
+ * @static
+ */
+ startY: 0,
+
+ /**
+ * Each DragDrop instance must be registered with the DragDropMgr.
+ * This is executed in DragDrop.init()
+ * @method regDragDrop
+ * @param {DragDrop} oDD the DragDrop object to register
+ * @param {String} sGroup the name of the group this element belongs to
+ * @static
+ */
+ regDragDrop: function(oDD, sGroup) {
+ if (!this.initialized) { this.init(); }
+
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+ this.ids[sGroup][oDD.id] = oDD;
+ },
+
+ /**
+ * Removes the supplied dd instance from the supplied group. Executed
+ * by DragDrop.removeFromGroup, so don't call this function directly.
+ * @method removeDDFromGroup
+ * @private
+ * @static
+ */
+ removeDDFromGroup: function(oDD, sGroup) {
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+
+ var obj = this.ids[sGroup];
+ if (obj && obj[oDD.id]) {
+ delete obj[oDD.id];
+ }
+ },
+
+ /**
+ * Unregisters a drag and drop item. This is executed in
+ * DragDrop.unreg, use that method instead of calling this directly.
+ * @method _remove
+ * @private
+ * @static
+ */
+ _remove: function(oDD) {
+ for (var g in oDD.groups) {
+ if (g && this.ids[g][oDD.id]) {
+ delete this.ids[g][oDD.id];
+ //this.logger.log("NEW LEN " + this.ids.length, "warn");
+ }
+ }
+ delete this.handleIds[oDD.id];
+ },
+
+ /**
+ * Each DragDrop handle element must be registered. This is done
+ * automatically when executing DragDrop.setHandleElId()
+ * @method regHandle
+ * @param {String} sDDId the DragDrop id this element is a handle for
+ * @param {String} sHandleId the id of the element that is the drag
+ * handle
+ * @static
+ */
+ regHandle: function(sDDId, sHandleId) {
+ if (!this.handleIds[sDDId]) {
+ this.handleIds[sDDId] = {};
+ }
+ this.handleIds[sDDId][sHandleId] = sHandleId;
+ },
+
+ /**
+ * Utility function to determine if a given element has been
+ * registered as a drag drop item.
+ * @method isDragDrop
+ * @param {String} id the element id to check
+ * @return {boolean} true if this element is a DragDrop item,
+ * false otherwise
+ * @static
+ */
+ isDragDrop: function(id) {
+ return ( this.getDDById(id) ) ? true : false;
+ },
+
+ /**
+ * Returns the drag and drop instances that are in all groups the
+ * passed in instance belongs to.
+ * @method getRelated
+ * @param {DragDrop} p_oDD the obj to get related data for
+ * @param {boolean} bTargetsOnly if true, only return targetable objs
+ * @return {DragDrop[]} the related instances
+ * @static
+ */
+ getRelated: function(p_oDD, bTargetsOnly) {
+ var oDDs = [];
+ for (var i in p_oDD.groups) {
+ for (j in this.ids[i]) {
+ var dd = this.ids[i][j];
+ if (! this.isTypeOfDD(dd)) {
+ continue;
+ }
+ if (!bTargetsOnly || dd.isTarget) {
+ oDDs[oDDs.length] = dd;
+ }
+ }
+ }
+
+ return oDDs;
+ },
+
+ /**
+ * Returns true if the specified dd target is a legal target for
+ * the specifice drag obj
+ * @method isLegalTarget
+ * @param {DragDrop} the drag obj
+ * @param {DragDrop} the target
+ * @return {boolean} true if the target is a legal target for the
+ * dd obj
+ * @static
+ */
+ isLegalTarget: function (oDD, oTargetDD) {
+ var targets = this.getRelated(oDD, true);
+ for (var i=0, len=targets.length;i this.clickPixelThresh ||
+ diffY > this.clickPixelThresh) {
+ this.logger.log("pixel threshold met");
+ this.startDrag(this.startX, this.startY);
+ }
+ }
+
+ if (this.dragThreshMet) {
+ this.dragCurrent.b4Drag(e);
+ this.dragCurrent.onDrag(e);
+ this.fireEvents(e, false);
+ }
+
+ this.stopEvent(e);
+
+ return true;
+ },
+
+ /**
+ * Iterates over all of the DragDrop elements to find ones we are
+ * hovering over or dropping on
+ * @method fireEvents
+ * @param {Event} e the event
+ * @param {boolean} isDrop is this a drop op or a mouseover op?
+ * @private
+ * @static
+ */
+ fireEvents: function(e, isDrop) {
+ var dc = this.dragCurrent;
+
+ // If the user did the mouse up outside of the window, we could
+ // get here even though we have ended the drag.
+ if (!dc || dc.isLocked()) {
+ return;
+ }
+
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ var pt = new YAHOO.util.Point(x,y);
+
+ // cache the previous dragOver array
+ var oldOvers = [];
+
+ var outEvts = [];
+ var overEvts = [];
+ var dropEvts = [];
+ var enterEvts = [];
+
+ // Check to see if the object(s) we were hovering over is no longer
+ // being hovered over so we can fire the onDragOut event
+ for (var i in this.dragOvers) {
+
+ var ddo = this.dragOvers[i];
+
+ if (! this.isTypeOfDD(ddo)) {
+ continue;
+ }
+
+ if (! this.isOverTarget(pt, ddo, this.mode)) {
+ outEvts.push( ddo );
+ }
+
+ oldOvers[i] = true;
+ delete this.dragOvers[i];
+ }
+
+ for (var sGroup in dc.groups) {
+ // this.logger.log("Processing group " + sGroup);
+
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+
+ for (i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+
+ if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
+ if (this.isOverTarget(pt, oDD, this.mode)) {
+ // look for drop interactions
+ if (isDrop) {
+ dropEvts.push( oDD );
+ // look for drag enter and drag over interactions
+ } else {
+
+ // initial drag over: dragEnter fires
+ if (!oldOvers[oDD.id]) {
+ enterEvts.push( oDD );
+ // subsequent drag overs: dragOver fires
+ } else {
+ overEvts.push( oDD );
+ }
+
+ this.dragOvers[oDD.id] = oDD;
+ }
+ }
+ }
+ }
+ }
+
+ if (this.mode) {
+ if (outEvts.length) {
+ this.logger.log(dc.id+" onDragOut: " + outEvts);
+ dc.b4DragOut(e, outEvts);
+ dc.onDragOut(e, outEvts);
+ }
+
+ if (enterEvts.length) {
+ this.logger.log(dc.id+" onDragEnter: " + enterEvts);
+ dc.onDragEnter(e, enterEvts);
+ }
+
+ if (overEvts.length) {
+ this.logger.log(dc.id+" onDragOver: " + overEvts);
+ dc.b4DragOver(e, overEvts);
+ dc.onDragOver(e, overEvts);
+ }
+
+ if (dropEvts.length) {
+ this.logger.log(dc.id+" onDragDrop: " + dropEvts);
+ dc.b4DragDrop(e, dropEvts);
+ dc.onDragDrop(e, dropEvts);
+ }
+
+ } else {
+ // fire dragout events
+ var len = 0;
+ for (i=0, len=outEvts.length; i
+ * YAHOO.util.DragDropMgr.refreshCache(ddinstance.groups);
+ *
+ * Alternatively:
+ *
+ * YAHOO.util.DragDropMgr.refreshCache({group1:true, group2:true});
+ *
+ * @TODO this really should be an indexed array. Alternatively this
+ * method could accept both.
+ * @method refreshCache
+ * @param {Object} groups an associative array of groups to refresh
+ * @static
+ */
+ refreshCache: function(groups) {
+ this.logger.log("refreshing element location cache");
+ for (var sGroup in groups) {
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+ for (var i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+
+ if (this.isTypeOfDD(oDD)) {
+ // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
+ var loc = this.getLocation(oDD);
+ if (loc) {
+ this.locationCache[oDD.id] = loc;
+ } else {
+ delete this.locationCache[oDD.id];
+ this.logger.log("Could not get the loc for " + oDD.id,
+ "warn");
+ // this will unregister the drag and drop object if
+ // the element is not in a usable state
+ // oDD.unreg();
+ }
+ }
+ }
+ }
+ },
+
+ /**
+ * This checks to make sure an element exists and is in the DOM. The
+ * main purpose is to handle cases where innerHTML is used to remove
+ * drag and drop objects from the DOM. IE provides an 'unspecified
+ * error' when trying to access the offsetParent of such an element
+ * @method verifyEl
+ * @param {HTMLElement} el the element to check
+ * @return {boolean} true if the element looks usable
+ * @static
+ */
+ verifyEl: function(el) {
+ try {
+ if (el) {
+ var parent = el.offsetParent;
+ if (parent) {
+ return true;
+ }
+ }
+ } catch(e) {
+ this.logger.log("detected problem with an element");
+ }
+
+ return false;
+ },
+
+ /**
+ * Returns a Region object containing the drag and drop element's position
+ * and size, including the padding configured for it
+ * @method getLocation
+ * @param {DragDrop} oDD the drag and drop object to get the
+ * location for
+ * @return {YAHOO.util.Region} a Region object representing the total area
+ * the element occupies, including any padding
+ * the instance is configured for.
+ * @static
+ */
+ getLocation: function(oDD) {
+ if (! this.isTypeOfDD(oDD)) {
+ this.logger.log(oDD + " is not a DD obj");
+ return null;
+ }
+
+ var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
+
+ try {
+ pos= YAHOO.util.Dom.getXY(el);
+ } catch (e) { }
+
+ if (!pos) {
+ this.logger.log("getXY failed");
+ return null;
+ }
+
+ x1 = pos[0];
+ x2 = x1 + el.offsetWidth;
+ y1 = pos[1];
+ y2 = y1 + el.offsetHeight;
+
+ t = y1 - oDD.padding[0];
+ r = x2 + oDD.padding[1];
+ b = y2 + oDD.padding[2];
+ l = x1 - oDD.padding[3];
+
+ return new YAHOO.util.Region( t, r, b, l );
+ },
+
+ /**
+ * Checks the cursor location to see if it over the target
+ * @method isOverTarget
+ * @param {YAHOO.util.Point} pt The point to evaluate
+ * @param {DragDrop} oTarget the DragDrop object we are inspecting
+ * @return {boolean} true if the mouse is over the target
+ * @private
+ * @static
+ */
+ isOverTarget: function(pt, oTarget, intersect) {
+ // use cache if available
+ var loc = this.locationCache[oTarget.id];
+ if (!loc || !this.useCache) {
+ this.logger.log("cache not populated");
+ loc = this.getLocation(oTarget);
+ this.locationCache[oTarget.id] = loc;
+
+ this.logger.log("cache: " + loc);
+ }
+
+ if (!loc) {
+ this.logger.log("could not get the location of the element");
+ return false;
+ }
+
+ //this.logger.log("loc: " + loc + ", pt: " + pt);
+ oTarget.cursorIsOver = loc.contains( pt );
+
+ // DragDrop is using this as a sanity check for the initial mousedown
+ // in this case we are done. In POINT mode, if the drag obj has no
+ // contraints, we are also done. Otherwise we need to evaluate the
+ // location of the target as related to the actual location of the
+ // dragged element.
+ var dc = this.dragCurrent;
+ if (!dc || !dc.getTargetCoord ||
+ (!intersect && !dc.constrainX && !dc.constrainY)) {
+ return oTarget.cursorIsOver;
+ }
+
+ oTarget.overlap = null;
+
+ // Get the current location of the drag element, this is the
+ // location of the mouse event less the delta that represents
+ // where the original mousedown happened on the element. We
+ // need to consider constraints and ticks as well.
+ var pos = dc.getTargetCoord(pt.x, pt.y);
+
+ var el = dc.getDragEl();
+ var curRegion = new YAHOO.util.Region( pos.y,
+ pos.x + el.offsetWidth,
+ pos.y + el.offsetHeight,
+ pos.x );
+
+ var overlap = curRegion.intersect(loc);
+
+ if (overlap) {
+ oTarget.overlap = overlap;
+ return (intersect) ? true : oTarget.cursorIsOver;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * unload event handler
+ * @method _onUnload
+ * @private
+ * @static
+ */
+ _onUnload: function(e, me) {
+ this.unregAll();
+ },
+
+ /**
+ * Cleans up the drag and drop events and objects.
+ * @method unregAll
+ * @private
+ * @static
+ */
+ unregAll: function() {
+ this.logger.log("unregister all");
+
+ if (this.dragCurrent) {
+ this.stopDrag();
+ this.dragCurrent = null;
+ }
+
+ this._execOnAll("unreg", []);
+
+ for (i in this.elementCache) {
+ delete this.elementCache[i];
+ }
+
+ this.elementCache = {};
+ this.ids = {};
+ },
+
+ /**
+ * A cache of DOM elements
+ * @property elementCache
+ * @private
+ * @static
+ */
+ elementCache: {},
+
+ /**
+ * Get the wrapper for the DOM element specified
+ * @method getElWrapper
+ * @param {String} id the id of the element to get
+ * @return {YAHOO.util.DDM.ElementWrapper} the wrapped element
+ * @private
+ * @deprecated This wrapper isn't that useful
+ * @static
+ */
+ getElWrapper: function(id) {
+ var oWrapper = this.elementCache[id];
+ if (!oWrapper || !oWrapper.el) {
+ oWrapper = this.elementCache[id] =
+ new this.ElementWrapper(YAHOO.util.Dom.get(id));
+ }
+ return oWrapper;
+ },
+
+ /**
+ * Returns the actual DOM element
+ * @method getElement
+ * @param {String} id the id of the elment to get
+ * @return {Object} The element
+ * @deprecated use YAHOO.util.Dom.get instead
+ * @static
+ */
+ getElement: function(id) {
+ return YAHOO.util.Dom.get(id);
+ },
+
+ /**
+ * Returns the style property for the DOM element (i.e.,
+ * document.getElById(id).style)
+ * @method getCss
+ * @param {String} id the id of the elment to get
+ * @return {Object} The style property of the element
+ * @deprecated use YAHOO.util.Dom instead
+ * @static
+ */
+ getCss: function(id) {
+ var el = YAHOO.util.Dom.get(id);
+ return (el) ? el.style : null;
+ },
+
+ /**
+ * Inner class for cached elements
+ * @class DragDropMgr.ElementWrapper
+ * @for DragDropMgr
+ * @private
+ * @deprecated
+ */
+ ElementWrapper: function(el) {
+ /**
+ * The element
+ * @property el
+ */
+ this.el = el || null;
+ /**
+ * The element id
+ * @property id
+ */
+ this.id = this.el && el.id;
+ /**
+ * A reference to the style property
+ * @property css
+ */
+ this.css = this.el && el.style;
+ },
+
+ /**
+ * Returns the X position of an html element
+ * @method getPosX
+ * @param el the element for which to get the position
+ * @return {int} the X coordinate
+ * @for DragDropMgr
+ * @deprecated use YAHOO.util.Dom.getX instead
+ * @static
+ */
+ getPosX: function(el) {
+ return YAHOO.util.Dom.getX(el);
+ },
+
+ /**
+ * Returns the Y position of an html element
+ * @method getPosY
+ * @param el the element for which to get the position
+ * @return {int} the Y coordinate
+ * @deprecated use YAHOO.util.Dom.getY instead
+ * @static
+ */
+ getPosY: function(el) {
+ return YAHOO.util.Dom.getY(el);
+ },
+
+ /**
+ * Swap two nodes. In IE, we use the native method, for others we
+ * emulate the IE behavior
+ * @method swapNode
+ * @param n1 the first node to swap
+ * @param n2 the other node to swap
+ * @static
+ */
+ swapNode: function(n1, n2) {
+ if (n1.swapNode) {
+ n1.swapNode(n2);
+ } else {
+ var p = n2.parentNode;
+ var s = n2.nextSibling;
+
+ if (s == n1) {
+ p.insertBefore(n1, n2);
+ } else if (n2 == n1.nextSibling) {
+ p.insertBefore(n2, n1);
+ } else {
+ n1.parentNode.replaceChild(n2, n1);
+ p.insertBefore(n1, s);
+ }
+ }
+ },
+
+ /**
+ * Returns the current scroll position
+ * @method getScroll
+ * @private
+ * @static
+ */
+ getScroll: function () {
+ var t, l, dde=document.documentElement, db=document.body;
+ if (dde && (dde.scrollTop || dde.scrollLeft)) {
+ t = dde.scrollTop;
+ l = dde.scrollLeft;
+ } else if (db) {
+ t = db.scrollTop;
+ l = db.scrollLeft;
+ } else {
+ YAHOO.log("could not get scroll property");
+ }
+ return { top: t, left: l };
+ },
+
+ /**
+ * Returns the specified element style property
+ * @method getStyle
+ * @param {HTMLElement} el the element
+ * @param {string} styleProp the style property
+ * @return {string} The value of the style property
+ * @deprecated use YAHOO.util.Dom.getStyle
+ * @static
+ */
+ getStyle: function(el, styleProp) {
+ return YAHOO.util.Dom.getStyle(el, styleProp);
+ },
+
+ /**
+ * Gets the scrollTop
+ * @method getScrollTop
+ * @return {int} the document's scrollTop
+ * @static
+ */
+ getScrollTop: function () { return this.getScroll().top; },
+
+ /**
+ * Gets the scrollLeft
+ * @method getScrollLeft
+ * @return {int} the document's scrollTop
+ * @static
+ */
+ getScrollLeft: function () { return this.getScroll().left; },
+
+ /**
+ * Sets the x/y position of an element to the location of the
+ * target element.
+ * @method moveToEl
+ * @param {HTMLElement} moveEl The element to move
+ * @param {HTMLElement} targetEl The position reference element
+ * @static
+ */
+ moveToEl: function (moveEl, targetEl) {
+ var aCoord = YAHOO.util.Dom.getXY(targetEl);
+ this.logger.log("moveToEl: " + aCoord);
+ YAHOO.util.Dom.setXY(moveEl, aCoord);
+ },
+
+ /**
+ * Gets the client height
+ * @method getClientHeight
+ * @return {int} client height in px
+ * @deprecated use YAHOO.util.Dom.getViewportHeight instead
+ * @static
+ */
+ getClientHeight: function() {
+ return YAHOO.util.Dom.getViewportHeight();
+ },
+
+ /**
+ * Gets the client width
+ * @method getClientWidth
+ * @return {int} client width in px
+ * @deprecated use YAHOO.util.Dom.getViewportWidth instead
+ * @static
+ */
+ getClientWidth: function() {
+ return YAHOO.util.Dom.getViewportWidth();
+ },
+
+ /**
+ * Numeric array sort function
+ * @method numericSort
+ * @static
+ */
+ numericSort: function(a, b) { return (a - b); },
+
+ /**
+ * Internal counter
+ * @property _timeoutCount
+ * @private
+ * @static
+ */
+ _timeoutCount: 0,
+
+ /**
+ * Trying to make the load order less important. Without this we get
+ * an error if this file is loaded before the Event Utility.
+ * @method _addListeners
+ * @private
+ * @static
+ */
+ _addListeners: function() {
+ var DDM = YAHOO.util.DDM;
+ if ( YAHOO.util.Event && document ) {
+ DDM._onLoad();
+ } else {
+ if (DDM._timeoutCount > 2000) {
+ DDM.logger.log("DragDrop requires the Event Utility");
+ } else {
+ setTimeout(DDM._addListeners, 10);
+ if (document && document.body) {
+ DDM._timeoutCount += 1;
+ }
+ }
+ }
+ },
+
+ /**
+ * Recursively searches the immediate parent and all child nodes for
+ * the handle element in order to determine wheter or not it was
+ * clicked.
+ * @method handleWasClicked
+ * @param node the html element to inspect
+ * @static
+ */
+ handleWasClicked: function(node, id) {
+ if (this.isHandle(id, node.id)) {
+ this.logger.log("clicked node is a handle");
+ return true;
+ } else {
+ // check to see if this is a text node child of the one we want
+ var p = node.parentNode;
+ // this.logger.log("p: " + p);
+
+ while (p) {
+ if (this.isHandle(id, p.id)) {
+ return true;
+ } else {
+ this.logger.log(p.id + " is not a handle");
+ p = p.parentNode;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ };
+
+}();
+
+// shorter alias, save a few bytes
+YAHOO.util.DDM = YAHOO.util.DragDropMgr;
+YAHOO.util.DDM._addListeners();
+
+}
+
+/**
+ * A DragDrop implementation where the linked element follows the
+ * mouse cursor during a drag.
+ * @class DD
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id the id of the linked element
+ * @param {String} sGroup the group of related DragDrop items
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DD:
+ * scroll
+ */
+YAHOO.util.DD = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+YAHOO.extend(YAHOO.util.DD, YAHOO.util.DragDrop, {
+
+ /**
+ * When set to true, the utility automatically tries to scroll the browser
+ * window wehn a drag and drop element is dragged near the viewport boundary.
+ * Defaults to true.
+ * @property scroll
+ * @type boolean
+ */
+ scroll: true,
+
+ /**
+ * Sets the pointer offset to the distance between the linked element's top
+ * left corner and the location the element was clicked
+ * @method autoOffset
+ * @param {int} iPageX the X coordinate of the click
+ * @param {int} iPageY the Y coordinate of the click
+ */
+ autoOffset: function(iPageX, iPageY) {
+ var x = iPageX - this.startPageX;
+ var y = iPageY - this.startPageY;
+ this.setDelta(x, y);
+ // this.logger.log("autoOffset el pos: " + aCoord + ", delta: " + x + "," + y);
+ },
+
+ /**
+ * Sets the pointer offset. You can call this directly to force the
+ * offset to be in a particular location (e.g., pass in 0,0 to set it
+ * to the center of the object, as done in YAHOO.widget.Slider)
+ * @method setDelta
+ * @param {int} iDeltaX the distance from the left
+ * @param {int} iDeltaY the distance from the top
+ */
+ setDelta: function(iDeltaX, iDeltaY) {
+ this.deltaX = iDeltaX;
+ this.deltaY = iDeltaY;
+ this.logger.log("deltaX:" + this.deltaX + ", deltaY:" + this.deltaY);
+ },
+
+ /**
+ * Sets the drag element to the location of the mousedown or click event,
+ * maintaining the cursor location relative to the location on the element
+ * that was clicked. Override this if you want to place the element in a
+ * location other than where the cursor is.
+ * @method setDragElPos
+ * @param {int} iPageX the X coordinate of the mousedown or drag event
+ * @param {int} iPageY the Y coordinate of the mousedown or drag event
+ */
+ setDragElPos: function(iPageX, iPageY) {
+ // the first time we do this, we are going to check to make sure
+ // the element has css positioning
+
+ var el = this.getDragEl();
+ this.alignElWithMouse(el, iPageX, iPageY);
+ },
+
+ /**
+ * Sets the element to the location of the mousedown or click event,
+ * maintaining the cursor location relative to the location on the element
+ * that was clicked. Override this if you want to place the element in a
+ * location other than where the cursor is.
+ * @method alignElWithMouse
+ * @param {HTMLElement} el the element to move
+ * @param {int} iPageX the X coordinate of the mousedown or drag event
+ * @param {int} iPageY the Y coordinate of the mousedown or drag event
+ */
+ alignElWithMouse: function(el, iPageX, iPageY) {
+ var oCoord = this.getTargetCoord(iPageX, iPageY);
+ // this.logger.log("****alignElWithMouse : " + el.id + ", " + aCoord + ", " + el.style.display);
+
+ if (!this.deltaSetXY) {
+ var aCoord = [oCoord.x, oCoord.y];
+ YAHOO.util.Dom.setXY(el, aCoord);
+ var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
+ var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
+
+ this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
+ } else {
+ YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px");
+ YAHOO.util.Dom.setStyle(el, "top", (oCoord.y + this.deltaSetXY[1]) + "px");
+ }
+
+ this.cachePosition(oCoord.x, oCoord.y);
+ this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
+ },
+
+ /**
+ * Saves the most recent position so that we can reset the constraints and
+ * tick marks on-demand. We need to know this so that we can calculate the
+ * number of pixels the element is offset from its original position.
+ * @method cachePosition
+ * @param iPageX the current x position (optional, this just makes it so we
+ * don't have to look it up again)
+ * @param iPageY the current y position (optional, this just makes it so we
+ * don't have to look it up again)
+ */
+ cachePosition: function(iPageX, iPageY) {
+ if (iPageX) {
+ this.lastPageX = iPageX;
+ this.lastPageY = iPageY;
+ } else {
+ var aCoord = YAHOO.util.Dom.getXY(this.getEl());
+ this.lastPageX = aCoord[0];
+ this.lastPageY = aCoord[1];
+ }
+ },
+
+ /**
+ * Auto-scroll the window if the dragged object has been moved beyond the
+ * visible window boundary.
+ * @method autoScroll
+ * @param {int} x the drag element's x position
+ * @param {int} y the drag element's y position
+ * @param {int} h the height of the drag element
+ * @param {int} w the width of the drag element
+ * @private
+ */
+ autoScroll: function(x, y, h, w) {
+
+ if (this.scroll) {
+ // The client height
+ var clientH = this.DDM.getClientHeight();
+
+ // The client width
+ var clientW = this.DDM.getClientWidth();
+
+ // The amt scrolled down
+ var st = this.DDM.getScrollTop();
+
+ // The amt scrolled right
+ var sl = this.DDM.getScrollLeft();
+
+ // Location of the bottom of the element
+ var bot = h + y;
+
+ // Location of the right of the element
+ var right = w + x;
+
+ // The distance from the cursor to the bottom of the visible area,
+ // adjusted so that we don't scroll if the cursor is beyond the
+ // element drag constraints
+ var toBot = (clientH + st - y - this.deltaY);
+
+ // The distance from the cursor to the right of the visible area
+ var toRight = (clientW + sl - x - this.deltaX);
+
+ // this.logger.log( " x: " + x + " y: " + y + " h: " + h +
+ // " clientH: " + clientH + " clientW: " + clientW +
+ // " st: " + st + " sl: " + sl + " bot: " + bot +
+ // " right: " + right + " toBot: " + toBot + " toRight: " + toRight);
+
+ // How close to the edge the cursor must be before we scroll
+ // var thresh = (document.all) ? 100 : 40;
+ var thresh = 40;
+
+ // How many pixels to scroll per autoscroll op. This helps to reduce
+ // clunky scrolling. IE is more sensitive about this ... it needs this
+ // value to be higher.
+ var scrAmt = (document.all) ? 80 : 30;
+
+ // Scroll down if we are near the bottom of the visible page and the
+ // obj extends below the crease
+ if ( bot > clientH && toBot < thresh ) {
+ window.scrollTo(sl, st + scrAmt);
+ }
+
+ // Scroll up if the window is scrolled down and the top of the object
+ // goes above the top border
+ if ( y < st && st > 0 && y - st < thresh ) {
+ window.scrollTo(sl, st - scrAmt);
+ }
+
+ // Scroll right if the obj is beyond the right border and the cursor is
+ // near the border.
+ if ( right > clientW && toRight < thresh ) {
+ window.scrollTo(sl + scrAmt, st);
+ }
+
+ // Scroll left if the window has been scrolled to the right and the obj
+ // extends past the left border
+ if ( x < sl && sl > 0 && x - sl < thresh ) {
+ window.scrollTo(sl - scrAmt, st);
+ }
+ }
+ },
+
+ /**
+ * Finds the location the element should be placed if we want to move
+ * it to where the mouse location less the click offset would place us.
+ * @method getTargetCoord
+ * @param {int} iPageX the X coordinate of the click
+ * @param {int} iPageY the Y coordinate of the click
+ * @return an object that contains the coordinates (Object.x and Object.y)
+ * @private
+ */
+ getTargetCoord: function(iPageX, iPageY) {
+
+ // this.logger.log("getTargetCoord: " + iPageX + ", " + iPageY);
+
+ var x = iPageX - this.deltaX;
+ var y = iPageY - this.deltaY;
+
+ if (this.constrainX) {
+ if (x < this.minX) { x = this.minX; }
+ if (x > this.maxX) { x = this.maxX; }
+ }
+
+ if (this.constrainY) {
+ if (y < this.minY) { y = this.minY; }
+ if (y > this.maxY) { y = this.maxY; }
+ }
+
+ x = this.getTick(x, this.xTicks);
+ y = this.getTick(y, this.yTicks);
+
+ // this.logger.log("getTargetCoord " +
+ // " iPageX: " + iPageX +
+ // " iPageY: " + iPageY +
+ // " x: " + x + ", y: " + y);
+
+ return {x:x, y:y};
+ },
+
+ /*
+ * Sets up config options specific to this class. Overrides
+ * YAHOO.util.DragDrop, but all versions of this method through the
+ * inheritance chain are called
+ */
+ applyConfig: function() {
+ YAHOO.util.DD.superclass.applyConfig.call(this);
+ this.scroll = (this.config.scroll !== false);
+ },
+
+ /*
+ * Event that fires prior to the onMouseDown event. Overrides
+ * YAHOO.util.DragDrop.
+ */
+ b4MouseDown: function(e) {
+ // this.resetConstraints();
+ this.autoOffset(YAHOO.util.Event.getPageX(e),
+ YAHOO.util.Event.getPageY(e));
+ },
+
+ /*
+ * Event that fires prior to the onDrag event. Overrides
+ * YAHOO.util.DragDrop.
+ */
+ b4Drag: function(e) {
+ this.setDragElPos(YAHOO.util.Event.getPageX(e),
+ YAHOO.util.Event.getPageY(e));
+ },
+
+ toString: function() {
+ return ("DD " + this.id);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Debugging ygDragDrop events that can be overridden
+ //////////////////////////////////////////////////////////////////////////
+ /*
+ startDrag: function(x, y) {
+ this.logger.log(this.id.toString() + " startDrag");
+ },
+
+ onDrag: function(e) {
+ this.logger.log(this.id.toString() + " onDrag");
+ },
+
+ onDragEnter: function(e, id) {
+ this.logger.log(this.id.toString() + " onDragEnter: " + id);
+ },
+
+ onDragOver: function(e, id) {
+ this.logger.log(this.id.toString() + " onDragOver: " + id);
+ },
+
+ onDragOut: function(e, id) {
+ this.logger.log(this.id.toString() + " onDragOut: " + id);
+ },
+
+ onDragDrop: function(e, id) {
+ this.logger.log(this.id.toString() + " onDragDrop: " + id);
+ },
+
+ endDrag: function(e) {
+ this.logger.log(this.id.toString() + " endDrag");
+ }
+
+ */
+
+});
+/**
+ * A DragDrop implementation that inserts an empty, bordered div into
+ * the document that follows the cursor during drag operations. At the time of
+ * the click, the frame div is resized to the dimensions of the linked html
+ * element, and moved to the exact location of the linked element.
+ *
+ * References to the "frame" element refer to the single proxy element that
+ * was created to be dragged in place of all DDProxy elements on the
+ * page.
+ *
+ * @class DDProxy
+ * @extends YAHOO.util.DD
+ * @constructor
+ * @param {String} id the id of the linked html element
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DDProxy in addition to those in DragDrop:
+ * resizeFrame, centerFrame, dragElId
+ */
+YAHOO.util.DDProxy = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ this.initFrame();
+ }
+};
+
+/**
+ * The default drag frame div id
+ * @property YAHOO.util.DDProxy.dragElId
+ * @type String
+ * @static
+ */
+YAHOO.util.DDProxy.dragElId = "ygddfdiv";
+
+YAHOO.extend(YAHOO.util.DDProxy, YAHOO.util.DD, {
+
+ /**
+ * By default we resize the drag frame to be the same size as the element
+ * we want to drag (this is to get the frame effect). We can turn it off
+ * if we want a different behavior.
+ * @property resizeFrame
+ * @type boolean
+ */
+ resizeFrame: true,
+
+ /**
+ * By default the frame is positioned exactly where the drag element is, so
+ * we use the cursor offset provided by YAHOO.util.DD. Another option that works only if
+ * you do not have constraints on the obj is to have the drag frame centered
+ * around the cursor. Set centerFrame to true for this effect.
+ * @property centerFrame
+ * @type boolean
+ */
+ centerFrame: false,
+
+ /**
+ * Creates the proxy element if it does not yet exist
+ * @method createFrame
+ */
+ createFrame: function() {
+ var self = this;
+ var body = document.body;
+
+ if (!body || !body.firstChild) {
+ setTimeout( function() { self.createFrame(); }, 50 );
+ return;
+ }
+
+ var div = this.getDragEl();
+
+ if (!div) {
+ div = document.createElement("div");
+ div.id = this.dragElId;
+ var s = div.style;
+
+ s.position = "absolute";
+ s.visibility = "hidden";
+ s.cursor = "move";
+ s.border = "2px solid #aaa";
+ s.zIndex = 999;
+
+ // appendChild can blow up IE if invoked prior to the window load event
+ // while rendering a table. It is possible there are other scenarios
+ // that would cause this to happen as well.
+ body.insertBefore(div, body.firstChild);
+ }
+ },
+
+ /**
+ * Initialization for the drag frame element. Must be called in the
+ * constructor of all subclasses
+ * @method initFrame
+ */
+ initFrame: function() {
+ this.createFrame();
+ },
+
+ applyConfig: function() {
+ this.logger.log("DDProxy applyConfig");
+ YAHOO.util.DDProxy.superclass.applyConfig.call(this);
+
+ this.resizeFrame = (this.config.resizeFrame !== false);
+ this.centerFrame = (this.config.centerFrame);
+ this.setDragElId(this.config.dragElId || YAHOO.util.DDProxy.dragElId);
+ },
+
+ /**
+ * Resizes the drag frame to the dimensions of the clicked object, positions
+ * it over the object, and finally displays it
+ * @method showFrame
+ * @param {int} iPageX X click position
+ * @param {int} iPageY Y click position
+ * @private
+ */
+ showFrame: function(iPageX, iPageY) {
+ var el = this.getEl();
+ var dragEl = this.getDragEl();
+ var s = dragEl.style;
+
+ this._resizeProxy();
+
+ if (this.centerFrame) {
+ this.setDelta( Math.round(parseInt(s.width, 10)/2),
+ Math.round(parseInt(s.height, 10)/2) );
+ }
+
+ this.setDragElPos(iPageX, iPageY);
+
+ YAHOO.util.Dom.setStyle(dragEl, "visibility", "visible");
+ },
+
+ /**
+ * The proxy is automatically resized to the dimensions of the linked
+ * element when a drag is initiated, unless resizeFrame is set to false
+ * @method _resizeProxy
+ * @private
+ */
+ _resizeProxy: function() {
+ if (this.resizeFrame) {
+ var DOM = YAHOO.util.Dom;
+ var el = this.getEl();
+ var dragEl = this.getDragEl();
+
+ var bt = parseInt( DOM.getStyle(dragEl, "borderTopWidth" ), 10);
+ var br = parseInt( DOM.getStyle(dragEl, "borderRightWidth" ), 10);
+ var bb = parseInt( DOM.getStyle(dragEl, "borderBottomWidth" ), 10);
+ var bl = parseInt( DOM.getStyle(dragEl, "borderLeftWidth" ), 10);
+
+ if (isNaN(bt)) { bt = 0; }
+ if (isNaN(br)) { br = 0; }
+ if (isNaN(bb)) { bb = 0; }
+ if (isNaN(bl)) { bl = 0; }
+
+ this.logger.log("proxy size: " + bt + " " + br + " " + bb + " " + bl);
+
+ var newWidth = Math.max(0, el.offsetWidth - br - bl);
+ var newHeight = Math.max(0, el.offsetHeight - bt - bb);
+
+ this.logger.log("Resizing proxy element");
+
+ DOM.setStyle( dragEl, "width", newWidth + "px" );
+ DOM.setStyle( dragEl, "height", newHeight + "px" );
+ }
+ },
+
+ // overrides YAHOO.util.DragDrop
+ b4MouseDown: function(e) {
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ this.autoOffset(x, y);
+ this.setDragElPos(x, y);
+ },
+
+ // overrides YAHOO.util.DragDrop
+ b4StartDrag: function(x, y) {
+ // show the drag frame
+ this.logger.log("start drag show frame, x: " + x + ", y: " + y);
+ this.showFrame(x, y);
+ },
+
+ // overrides YAHOO.util.DragDrop
+ b4EndDrag: function(e) {
+ this.logger.log(this.id + " b4EndDrag");
+ YAHOO.util.Dom.setStyle(this.getDragEl(), "visibility", "hidden");
+ },
+
+ // overrides YAHOO.util.DragDrop
+ // By default we try to move the element to the last location of the frame.
+ // This is so that the default behavior mirrors that of YAHOO.util.DD.
+ endDrag: function(e) {
+ var DOM = YAHOO.util.Dom;
+ this.logger.log(this.id + " endDrag");
+ var lel = this.getEl();
+ var del = this.getDragEl();
+
+ // Show the drag frame briefly so we can get its position
+ // del.style.visibility = "";
+ DOM.setStyle(del, "visibility", "");
+
+ // Hide the linked element before the move to get around a Safari
+ // rendering bug.
+ //lel.style.visibility = "hidden";
+ DOM.setStyle(lel, "visibility", "hidden");
+ YAHOO.util.DDM.moveToEl(lel, del);
+ //del.style.visibility = "hidden";
+ DOM.setStyle(del, "visibility", "hidden");
+ //lel.style.visibility = "";
+ DOM.setStyle(lel, "visibility", "");
+ },
+
+ toString: function() {
+ return ("DDProxy " + this.id);
+ }
+
+});
+/**
+ * A DragDrop implementation that does not move, but can be a drop
+ * target. You would get the same result by simply omitting implementation
+ * for the event callbacks, but this way we reduce the processing cost of the
+ * event listener and the callbacks.
+ * @class DDTarget
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id the id of the element that is a drop target
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DDTarget in addition to those in
+ * DragDrop:
+ * none
+ */
+YAHOO.util.DDTarget = function(id, sGroup, config) {
+ if (id) {
+ this.initTarget(id, sGroup, config);
+ }
+};
+
+// YAHOO.util.DDTarget.prototype = new YAHOO.util.DragDrop();
+YAHOO.extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop, {
+ toString: function() {
+ return ("DDTarget " + this.id);
+ }
+});
diff --git a/lib/yui/dragdrop/dragdrop-min.js b/lib/yui/dragdrop/dragdrop-min.js
index 2ee619ff6c..26e0ba284b 100755
--- a/lib/yui/dragdrop/dragdrop-min.js
+++ b/lib/yui/dragdrop/dragdrop-min.js
@@ -1,87 +1,94 @@
-/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.12.1 */
-(function(){var Event=YAHOO.util.Event;var Dom=YAHOO.util.Dom;YAHOO.util.DragDrop=function(id,sGroup,config){if(id){this.init(id,sGroup,config);}};YAHOO.util.DragDrop.prototype={id:null,config:null,dragElId:null,handleElId:null,invalidHandleTypes:null,invalidHandleIds:null,invalidHandleClasses:null,startPageX:0,startPageY:0,groups:null,locked:false,lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isTarget:true,padding:null,_domRef:null,__ygDragDrop:true,constrainX:false,constrainY:false,minX:0,maxX:0,minY:0,maxY:0,maintainOffset:false,xTicks:null,yTicks:null,primaryButtonOnly:true,available:false,hasOuterHandles:false,b4StartDrag:function(x,y){},startDrag:function(x,y){},b4Drag:function(e){},onDrag:function(e){},onDragEnter:function(e,id){},b4DragOver:function(e){},onDragOver:function(e,id){},b4DragOut:function(e){},onDragOut:function(e,id){},b4DragDrop:function(e){},onDragDrop:function(e,id){},onInvalidDrop:function(e){},b4EndDrag:function(e){},endDrag:function(e){},b4MouseDown:function(e){},onMouseDown:function(e){},onMouseUp:function(e){},onAvailable:function(){},getEl:function(){if(!this._domRef){this._domRef=Dom.get(this.id);}
-return this._domRef;},getDragEl:function(){return Dom.get(this.dragElId);},init:function(id,sGroup,config){this.initTarget(id,sGroup,config);Event.on(this.id,"mousedown",this.handleMouseDown,this,true);},initTarget:function(id,sGroup,config){this.config=config||{};this.DDM=YAHOO.util.DDM;this.groups={};if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
-this.id=id;this.addToGroup((sGroup)?sGroup:"default");this.handleElId=id;Event.onAvailable(id,this.handleOnAvailable,this,true);this.setDragElId(id);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();},applyConfig:function(){this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);},handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(iTop,iRight,iBot,iLeft){if(!iRight&&0!==iRight){this.padding=[iTop,iTop,iTop,iTop];}else if(!iBot&&0!==iBot){this.padding=[iTop,iRight,iTop,iRight];}else{this.padding=[iTop,iRight,iBot,iLeft];}},setInitPosition:function(diffX,diffY){var el=this.getEl();if(!this.DDM.verifyEl(el)){return;}
-var dx=diffX||0;var dy=diffY||0;var p=Dom.getXY(el);this.initPageX=p[0]-dx;this.initPageY=p[1]-dy;this.lastPageX=p[0];this.lastPageY=p[1];this.setStartPosition(p);},setStartPosition:function(pos){var p=pos||Dom.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=p[0];this.startPageY=p[1];},addToGroup:function(sGroup){this.groups[sGroup]=true;this.DDM.regDragDrop(this,sGroup);},removeFromGroup:function(sGroup){if(this.groups[sGroup]){delete this.groups[sGroup];}
-this.DDM.removeDDFromGroup(this,sGroup);},setDragElId:function(id){this.dragElId=id;},setHandleElId:function(id){if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
-this.handleElId=id;this.DDM.regHandle(this.id,id);},setOuterHandleElId:function(id){if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
-Event.on(id,"mousedown",this.handleMouseDown,this,true);this.setHandleElId(id);this.hasOuterHandles=true;},unreg:function(){Event.removeListener(this.id,"mousedown",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},isLocked:function(){return(this.DDM.isLocked()||this.locked);},handleMouseDown:function(e,oDD){var button=e.which||e.button;if(this.primaryButtonOnly&&button>1){return;}
-if(this.isLocked()){return;}
-this.DDM.refreshCache(this.groups);var pt=new YAHOO.util.Point(Event.getPageX(e),Event.getPageY(e));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(pt,this)){}else{if(this.clickValidator(e)){this.setStartPosition();this.b4MouseDown(e);this.onMouseDown(e);this.DDM.handleMouseDown(e,this);this.DDM.stopEvent(e);}else{}}},clickValidator:function(e){var target=Event.getTarget(e);return(this.isValidHandleChild(target)&&(this.id==this.handleElId||this.DDM.handleWasClicked(target,this.id)));},addInvalidHandleType:function(tagName){var type=tagName.toUpperCase();this.invalidHandleTypes[type]=type;},addInvalidHandleId:function(id){if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
-this.invalidHandleIds[id]=id;},addInvalidHandleClass:function(cssClass){this.invalidHandleClasses.push(cssClass);},removeInvalidHandleType:function(tagName){var type=tagName.toUpperCase();delete this.invalidHandleTypes[type];},removeInvalidHandleId:function(id){if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
-delete this.invalidHandleIds[id];},removeInvalidHandleClass:function(cssClass){for(var i=0,len=this.invalidHandleClasses.length;i=this.minX;i=i-iTickSize){if(!tickMap[i]){this.xTicks[this.xTicks.length]=i;tickMap[i]=true;}}
-for(i=this.initPageX;i<=this.maxX;i=i+iTickSize){if(!tickMap[i]){this.xTicks[this.xTicks.length]=i;tickMap[i]=true;}}
-this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(iStartY,iTickSize){this.yTicks=[];this.yTickSize=iTickSize;var tickMap={};for(var i=this.initPageY;i>=this.minY;i=i-iTickSize){if(!tickMap[i]){this.yTicks[this.yTicks.length]=i;tickMap[i]=true;}}
-for(i=this.initPageY;i<=this.maxY;i=i+iTickSize){if(!tickMap[i]){this.yTicks[this.yTicks.length]=i;tickMap[i]=true;}}
-this.yTicks.sort(this.DDM.numericSort);},setXConstraint:function(iLeft,iRight,iTickSize){this.leftConstraint=iLeft;this.rightConstraint=iRight;this.minX=this.initPageX-iLeft;this.maxX=this.initPageX+iRight;if(iTickSize){this.setXTicks(this.initPageX,iTickSize);}
-this.constrainX=true;},clearConstraints:function(){this.constrainX=false;this.constrainY=false;this.clearTicks();},clearTicks:function(){this.xTicks=null;this.yTicks=null;this.xTickSize=0;this.yTickSize=0;},setYConstraint:function(iUp,iDown,iTickSize){this.topConstraint=iUp;this.bottomConstraint=iDown;this.minY=this.initPageY-iUp;this.maxY=this.initPageY+iDown;if(iTickSize){this.setYTicks(this.initPageY,iTickSize);}
-this.constrainY=true;},resetConstraints:function(){if(this.initPageX||this.initPageX===0){var dx=(this.maintainOffset)?this.lastPageX-this.initPageX:0;var dy=(this.maintainOffset)?this.lastPageY-this.initPageY:0;this.setInitPosition(dx,dy);}else{this.setInitPosition();}
-if(this.constrainX){this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);}
-if(this.constrainY){this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize);}},getTick:function(val,tickArray){if(!tickArray){return val;}else if(tickArray[0]>=val){return tickArray[0];}else{for(var i=0,len=tickArray.length;i=val){var diff1=val-tickArray[i];var diff2=tickArray[next]-val;return(diff2>diff1)?tickArray[i]:tickArray[next];}}
-return tickArray[tickArray.length-1];}},toString:function(){return("DragDrop "+this.id);}};})();if(!YAHOO.util.DragDropMgr){YAHOO.util.DragDropMgr=function(){var Event=YAHOO.util.Event;return{ids:{},handleIds:{},dragCurrent:null,dragOvers:{},deltaX:0,deltaY:0,preventDefault:true,stopPropagation:true,initalized:false,locked:false,init:function(){this.initialized=true;},POINT:0,INTERSECT:1,STRICT_INTERSECT:2,mode:0,_execOnAll:function(sMethod,args){for(var i in this.ids){for(var j in this.ids[i]){var oDD=this.ids[i][j];if(!this.isTypeOfDD(oDD)){continue;}
-oDD[sMethod].apply(oDD,args);}}},_onLoad:function(){this.init();Event.on(document,"mouseup",this.handleMouseUp,this,true);Event.on(document,"mousemove",this.handleMouseMove,this,true);Event.on(window,"unload",this._onUnload,this,true);Event.on(window,"resize",this._onResize,this,true);},_onResize:function(e){this._execOnAll("resetConstraints",[]);},lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isLocked:function(){return this.locked;},locationCache:{},useCache:true,clickPixelThresh:3,clickTimeThresh:1000,dragThreshMet:false,clickTimeout:null,startX:0,startY:0,regDragDrop:function(oDD,sGroup){if(!this.initialized){this.init();}
-if(!this.ids[sGroup]){this.ids[sGroup]={};}
-this.ids[sGroup][oDD.id]=oDD;},removeDDFromGroup:function(oDD,sGroup){if(!this.ids[sGroup]){this.ids[sGroup]={};}
-var obj=this.ids[sGroup];if(obj&&obj[oDD.id]){delete obj[oDD.id];}},_remove:function(oDD){for(var g in oDD.groups){if(g&&this.ids[g][oDD.id]){delete this.ids[g][oDD.id];}}
-delete this.handleIds[oDD.id];},regHandle:function(sDDId,sHandleId){if(!this.handleIds[sDDId]){this.handleIds[sDDId]={};}
-this.handleIds[sDDId][sHandleId]=sHandleId;},isDragDrop:function(id){return(this.getDDById(id))?true:false;},getRelated:function(p_oDD,bTargetsOnly){var oDDs=[];for(var i in p_oDD.groups){for(j in this.ids[i]){var dd=this.ids[i][j];if(!this.isTypeOfDD(dd)){continue;}
-if(!bTargetsOnly||dd.isTarget){oDDs[oDDs.length]=dd;}}}
-return oDDs;},isLegalTarget:function(oDD,oTargetDD){var targets=this.getRelated(oDD,true);for(var i=0,len=targets.length;ithis.clickPixelThresh||diffY>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}}
-if(this.dragThreshMet){this.dragCurrent.b4Drag(e);this.dragCurrent.onDrag(e);this.fireEvents(e,false);}
-this.stopEvent(e);return true;},fireEvents:function(e,isDrop){var dc=this.dragCurrent;if(!dc||dc.isLocked()){return;}
-var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);var pt=new YAHOO.util.Point(x,y);var oldOvers=[];var outEvts=[];var overEvts=[];var dropEvts=[];var enterEvts=[];for(var i in this.dragOvers){var ddo=this.dragOvers[i];if(!this.isTypeOfDD(ddo)){continue;}
-if(!this.isOverTarget(pt,ddo,this.mode)){outEvts.push(ddo);}
-oldOvers[i]=true;delete this.dragOvers[i];}
-for(var sGroup in dc.groups){if("string"!=typeof sGroup){continue;}
-for(i in this.ids[sGroup]){var oDD=this.ids[sGroup][i];if(!this.isTypeOfDD(oDD)){continue;}
-if(oDD.isTarget&&!oDD.isLocked()&&oDD!=dc){if(this.isOverTarget(pt,oDD,this.mode)){if(isDrop){dropEvts.push(oDD);}else{if(!oldOvers[oDD.id]){enterEvts.push(oDD);}else{overEvts.push(oDD);}
-this.dragOvers[oDD.id]=oDD;}}}}}
-if(this.mode){if(outEvts.length){dc.b4DragOut(e,outEvts);dc.onDragOut(e,outEvts);}
-if(enterEvts.length){dc.onDragEnter(e,enterEvts);}
-if(overEvts.length){dc.b4DragOver(e,overEvts);dc.onDragOver(e,overEvts);}
-if(dropEvts.length){dc.b4DragDrop(e,dropEvts);dc.onDragDrop(e,dropEvts);}}else{var len=0;for(i=0,len=outEvts.length;i2000){}else{setTimeout(DDM._addListeners,10);if(document&&document.body){DDM._timeoutCount+=1;}}}},handleWasClicked:function(node,id){if(this.isHandle(id,node.id)){return true;}else{var p=node.parentNode;while(p){if(this.isHandle(id,p.id)){return true;}else{p=p.parentNode;}}}
-return false;}};}();YAHOO.util.DDM=YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();}
-YAHOO.util.DD=function(id,sGroup,config){if(id){this.init(id,sGroup,config);}};YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop,{scroll:true,autoOffset:function(iPageX,iPageY){var x=iPageX-this.startPageX;var y=iPageY-this.startPageY;this.setDelta(x,y);},setDelta:function(iDeltaX,iDeltaY){this.deltaX=iDeltaX;this.deltaY=iDeltaY;},setDragElPos:function(iPageX,iPageY){var el=this.getDragEl();this.alignElWithMouse(el,iPageX,iPageY);},alignElWithMouse:function(el,iPageX,iPageY){var oCoord=this.getTargetCoord(iPageX,iPageY);if(!this.deltaSetXY){var aCoord=[oCoord.x,oCoord.y];YAHOO.util.Dom.setXY(el,aCoord);var newLeft=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var newTop=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);this.deltaSetXY=[newLeft-oCoord.x,newTop-oCoord.y];}else{YAHOO.util.Dom.setStyle(el,"left",(oCoord.x+this.deltaSetXY[0])+"px");YAHOO.util.Dom.setStyle(el,"top",(oCoord.y+this.deltaSetXY[1])+"px");}
-this.cachePosition(oCoord.x,oCoord.y);this.autoScroll(oCoord.x,oCoord.y,el.offsetHeight,el.offsetWidth);},cachePosition:function(iPageX,iPageY){if(iPageX){this.lastPageX=iPageX;this.lastPageY=iPageY;}else{var aCoord=YAHOO.util.Dom.getXY(this.getEl());this.lastPageX=aCoord[0];this.lastPageY=aCoord[1];}},autoScroll:function(x,y,h,w){if(this.scroll){var clientH=this.DDM.getClientHeight();var clientW=this.DDM.getClientWidth();var st=this.DDM.getScrollTop();var sl=this.DDM.getScrollLeft();var bot=h+y;var right=w+x;var toBot=(clientH+st-y-this.deltaY);var toRight=(clientW+sl-x-this.deltaX);var thresh=40;var scrAmt=(document.all)?80:30;if(bot>clientH&&toBot0&&y-stclientW&&toRight0&&x-slthis.maxX){x=this.maxX;}}
-if(this.constrainY){if(ythis.maxY){y=this.maxY;}}
-x=this.getTick(x,this.xTicks);y=this.getTick(y,this.yTicks);return{x:x,y:y};},applyConfig:function(){YAHOO.util.DD.superclass.applyConfig.call(this);this.scroll=(this.config.scroll!==false);},b4MouseDown:function(e){this.autoOffset(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));},b4Drag:function(e){this.setDragElPos(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));},toString:function(){return("DD "+this.id);}});YAHOO.util.DDProxy=function(id,sGroup,config){if(id){this.init(id,sGroup,config);this.initFrame();}};YAHOO.util.DDProxy.dragElId="ygddfdiv";YAHOO.extend(YAHOO.util.DDProxy,YAHOO.util.DD,{resizeFrame:true,centerFrame:false,createFrame:function(){var self=this;var body=document.body;if(!body||!body.firstChild){setTimeout(function(){self.createFrame();},50);return;}
-var div=this.getDragEl();if(!div){div=document.createElement("div");div.id=this.dragElId;var s=div.style;s.position="absolute";s.visibility="hidden";s.cursor="move";s.border="2px solid #aaa";s.zIndex=999;body.insertBefore(div,body.firstChild);}},initFrame:function(){this.createFrame();},applyConfig:function(){YAHOO.util.DDProxy.superclass.applyConfig.call(this);this.resizeFrame=(this.config.resizeFrame!==false);this.centerFrame=(this.config.centerFrame);this.setDragElId(this.config.dragElId||YAHOO.util.DDProxy.dragElId);},showFrame:function(iPageX,iPageY){var el=this.getEl();var dragEl=this.getDragEl();var s=dragEl.style;this._resizeProxy();if(this.centerFrame){this.setDelta(Math.round(parseInt(s.width,10)/2),Math.round(parseInt(s.height,10)/2));}
-this.setDragElPos(iPageX,iPageY);YAHOO.util.Dom.setStyle(dragEl,"visibility","visible");},_resizeProxy:function(){if(this.resizeFrame){var DOM=YAHOO.util.Dom;var el=this.getEl();var dragEl=this.getDragEl();var bt=parseInt(DOM.getStyle(dragEl,"borderTopWidth"),10);var br=parseInt(DOM.getStyle(dragEl,"borderRightWidth"),10);var bb=parseInt(DOM.getStyle(dragEl,"borderBottomWidth"),10);var bl=parseInt(DOM.getStyle(dragEl,"borderLeftWidth"),10);if(isNaN(bt)){bt=0;}
-if(isNaN(br)){br=0;}
-if(isNaN(bb)){bb=0;}
-if(isNaN(bl)){bl=0;}
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+
+
+(function(){var Event=YAHOO.util.Event;var Dom=YAHOO.util.Dom;YAHOO.util.DragDrop=function(id,sGroup,config){if(id){this.init(id,sGroup,config);}};YAHOO.util.DragDrop.prototype={id:null,config:null,dragElId:null,handleElId:null,invalidHandleTypes:null,invalidHandleIds:null,invalidHandleClasses:null,startPageX:0,startPageY:0,groups:null,locked:false,lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isTarget:true,padding:null,_domRef:null,__ygDragDrop:true,constrainX:false,constrainY:false,minX:0,maxX:0,minY:0,maxY:0,maintainOffset:false,xTicks:null,yTicks:null,primaryButtonOnly:true,available:false,hasOuterHandles:false,b4StartDrag:function(x,y){},startDrag:function(x,y){},b4Drag:function(e){},onDrag:function(e){},onDragEnter:function(e,id){},b4DragOver:function(e){},onDragOver:function(e,id){},b4DragOut:function(e){},onDragOut:function(e,id){},b4DragDrop:function(e){},onDragDrop:function(e,id){},onInvalidDrop:function(e){},b4EndDrag:function(e){},endDrag:function(e){},b4MouseDown:function(e){},onMouseDown:function(e){},onMouseUp:function(e){},onAvailable:function(){},getEl:function(){if(!this._domRef){this._domRef=Dom.get(this.id);}
+return this._domRef;},getDragEl:function(){return Dom.get(this.dragElId);},init:function(id,sGroup,config){this.initTarget(id,sGroup,config);Event.on(this.id,"mousedown",this.handleMouseDown,this,true);},initTarget:function(id,sGroup,config){this.config=config||{};this.DDM=YAHOO.util.DDM;this.groups={};if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
+this.id=id;this.addToGroup((sGroup)?sGroup:"default");this.handleElId=id;Event.onAvailable(id,this.handleOnAvailable,this,true);this.setDragElId(id);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();},applyConfig:function(){this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);},handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(iTop,iRight,iBot,iLeft){if(!iRight&&0!==iRight){this.padding=[iTop,iTop,iTop,iTop];}else if(!iBot&&0!==iBot){this.padding=[iTop,iRight,iTop,iRight];}else{this.padding=[iTop,iRight,iBot,iLeft];}},setInitPosition:function(diffX,diffY){var el=this.getEl();if(!this.DDM.verifyEl(el)){return;}
+var dx=diffX||0;var dy=diffY||0;var p=Dom.getXY(el);this.initPageX=p[0]-dx;this.initPageY=p[1]-dy;this.lastPageX=p[0];this.lastPageY=p[1];this.setStartPosition(p);},setStartPosition:function(pos){var p=pos||Dom.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=p[0];this.startPageY=p[1];},addToGroup:function(sGroup){this.groups[sGroup]=true;this.DDM.regDragDrop(this,sGroup);},removeFromGroup:function(sGroup){if(this.groups[sGroup]){delete this.groups[sGroup];}
+this.DDM.removeDDFromGroup(this,sGroup);},setDragElId:function(id){this.dragElId=id;},setHandleElId:function(id){if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
+this.handleElId=id;this.DDM.regHandle(this.id,id);},setOuterHandleElId:function(id){if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
+Event.on(id,"mousedown",this.handleMouseDown,this,true);this.setHandleElId(id);this.hasOuterHandles=true;},unreg:function(){Event.removeListener(this.id,"mousedown",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},isLocked:function(){return(this.DDM.isLocked()||this.locked);},handleMouseDown:function(e,oDD){var button=e.which||e.button;if(this.primaryButtonOnly&&button>1){return;}
+if(this.isLocked()){return;}
+this.DDM.refreshCache(this.groups);var pt=new YAHOO.util.Point(Event.getPageX(e),Event.getPageY(e));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(pt,this)){}else{if(this.clickValidator(e)){this.setStartPosition();this.b4MouseDown(e);this.onMouseDown(e);this.DDM.handleMouseDown(e,this);this.DDM.stopEvent(e);}else{}}},clickValidator:function(e){var target=Event.getTarget(e);return(this.isValidHandleChild(target)&&(this.id==this.handleElId||this.DDM.handleWasClicked(target,this.id)));},addInvalidHandleType:function(tagName){var type=tagName.toUpperCase();this.invalidHandleTypes[type]=type;},addInvalidHandleId:function(id){if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
+this.invalidHandleIds[id]=id;},addInvalidHandleClass:function(cssClass){this.invalidHandleClasses.push(cssClass);},removeInvalidHandleType:function(tagName){var type=tagName.toUpperCase();delete this.invalidHandleTypes[type];},removeInvalidHandleId:function(id){if(typeof id!=="string"){YAHOO.log("id is not a string, assuming it is an HTMLElement");id=Dom.generateId(id);}
+delete this.invalidHandleIds[id];},removeInvalidHandleClass:function(cssClass){for(var i=0,len=this.invalidHandleClasses.length;i=this.minX;i=i-iTickSize){if(!tickMap[i]){this.xTicks[this.xTicks.length]=i;tickMap[i]=true;}}
+for(i=this.initPageX;i<=this.maxX;i=i+iTickSize){if(!tickMap[i]){this.xTicks[this.xTicks.length]=i;tickMap[i]=true;}}
+this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(iStartY,iTickSize){this.yTicks=[];this.yTickSize=iTickSize;var tickMap={};for(var i=this.initPageY;i>=this.minY;i=i-iTickSize){if(!tickMap[i]){this.yTicks[this.yTicks.length]=i;tickMap[i]=true;}}
+for(i=this.initPageY;i<=this.maxY;i=i+iTickSize){if(!tickMap[i]){this.yTicks[this.yTicks.length]=i;tickMap[i]=true;}}
+this.yTicks.sort(this.DDM.numericSort);},setXConstraint:function(iLeft,iRight,iTickSize){this.leftConstraint=iLeft;this.rightConstraint=iRight;this.minX=this.initPageX-iLeft;this.maxX=this.initPageX+iRight;if(iTickSize){this.setXTicks(this.initPageX,iTickSize);}
+this.constrainX=true;},clearConstraints:function(){this.constrainX=false;this.constrainY=false;this.clearTicks();},clearTicks:function(){this.xTicks=null;this.yTicks=null;this.xTickSize=0;this.yTickSize=0;},setYConstraint:function(iUp,iDown,iTickSize){this.topConstraint=iUp;this.bottomConstraint=iDown;this.minY=this.initPageY-iUp;this.maxY=this.initPageY+iDown;if(iTickSize){this.setYTicks(this.initPageY,iTickSize);}
+this.constrainY=true;},resetConstraints:function(){if(this.initPageX||this.initPageX===0){var dx=(this.maintainOffset)?this.lastPageX-this.initPageX:0;var dy=(this.maintainOffset)?this.lastPageY-this.initPageY:0;this.setInitPosition(dx,dy);}else{this.setInitPosition();}
+if(this.constrainX){this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);}
+if(this.constrainY){this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize);}},getTick:function(val,tickArray){if(!tickArray){return val;}else if(tickArray[0]>=val){return tickArray[0];}else{for(var i=0,len=tickArray.length;i=val){var diff1=val-tickArray[i];var diff2=tickArray[next]-val;return(diff2>diff1)?tickArray[i]:tickArray[next];}}
+return tickArray[tickArray.length-1];}},toString:function(){return("DragDrop "+this.id);}};})();if(!YAHOO.util.DragDropMgr){YAHOO.util.DragDropMgr=function(){var Event=YAHOO.util.Event;return{ids:{},handleIds:{},dragCurrent:null,dragOvers:{},deltaX:0,deltaY:0,preventDefault:true,stopPropagation:true,initalized:false,locked:false,init:function(){this.initialized=true;},POINT:0,INTERSECT:1,STRICT_INTERSECT:2,mode:0,_execOnAll:function(sMethod,args){for(var i in this.ids){for(var j in this.ids[i]){var oDD=this.ids[i][j];if(!this.isTypeOfDD(oDD)){continue;}
+oDD[sMethod].apply(oDD,args);}}},_onLoad:function(){this.init();Event.on(document,"mouseup",this.handleMouseUp,this,true);Event.on(document,"mousemove",this.handleMouseMove,this,true);Event.on(window,"unload",this._onUnload,this,true);Event.on(window,"resize",this._onResize,this,true);},_onResize:function(e){this._execOnAll("resetConstraints",[]);},lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isLocked:function(){return this.locked;},locationCache:{},useCache:true,clickPixelThresh:3,clickTimeThresh:1000,dragThreshMet:false,clickTimeout:null,startX:0,startY:0,regDragDrop:function(oDD,sGroup){if(!this.initialized){this.init();}
+if(!this.ids[sGroup]){this.ids[sGroup]={};}
+this.ids[sGroup][oDD.id]=oDD;},removeDDFromGroup:function(oDD,sGroup){if(!this.ids[sGroup]){this.ids[sGroup]={};}
+var obj=this.ids[sGroup];if(obj&&obj[oDD.id]){delete obj[oDD.id];}},_remove:function(oDD){for(var g in oDD.groups){if(g&&this.ids[g][oDD.id]){delete this.ids[g][oDD.id];}}
+delete this.handleIds[oDD.id];},regHandle:function(sDDId,sHandleId){if(!this.handleIds[sDDId]){this.handleIds[sDDId]={};}
+this.handleIds[sDDId][sHandleId]=sHandleId;},isDragDrop:function(id){return(this.getDDById(id))?true:false;},getRelated:function(p_oDD,bTargetsOnly){var oDDs=[];for(var i in p_oDD.groups){for(j in this.ids[i]){var dd=this.ids[i][j];if(!this.isTypeOfDD(dd)){continue;}
+if(!bTargetsOnly||dd.isTarget){oDDs[oDDs.length]=dd;}}}
+return oDDs;},isLegalTarget:function(oDD,oTargetDD){var targets=this.getRelated(oDD,true);for(var i=0,len=targets.length;ithis.clickPixelThresh||diffY>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}}
+if(this.dragThreshMet){this.dragCurrent.b4Drag(e);this.dragCurrent.onDrag(e);this.fireEvents(e,false);}
+this.stopEvent(e);return true;},fireEvents:function(e,isDrop){var dc=this.dragCurrent;if(!dc||dc.isLocked()){return;}
+var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);var pt=new YAHOO.util.Point(x,y);var oldOvers=[];var outEvts=[];var overEvts=[];var dropEvts=[];var enterEvts=[];for(var i in this.dragOvers){var ddo=this.dragOvers[i];if(!this.isTypeOfDD(ddo)){continue;}
+if(!this.isOverTarget(pt,ddo,this.mode)){outEvts.push(ddo);}
+oldOvers[i]=true;delete this.dragOvers[i];}
+for(var sGroup in dc.groups){if("string"!=typeof sGroup){continue;}
+for(i in this.ids[sGroup]){var oDD=this.ids[sGroup][i];if(!this.isTypeOfDD(oDD)){continue;}
+if(oDD.isTarget&&!oDD.isLocked()&&oDD!=dc){if(this.isOverTarget(pt,oDD,this.mode)){if(isDrop){dropEvts.push(oDD);}else{if(!oldOvers[oDD.id]){enterEvts.push(oDD);}else{overEvts.push(oDD);}
+this.dragOvers[oDD.id]=oDD;}}}}}
+if(this.mode){if(outEvts.length){dc.b4DragOut(e,outEvts);dc.onDragOut(e,outEvts);}
+if(enterEvts.length){dc.onDragEnter(e,enterEvts);}
+if(overEvts.length){dc.b4DragOver(e,overEvts);dc.onDragOver(e,overEvts);}
+if(dropEvts.length){dc.b4DragDrop(e,dropEvts);dc.onDragDrop(e,dropEvts);}}else{var len=0;for(i=0,len=outEvts.length;i2000){}else{setTimeout(DDM._addListeners,10);if(document&&document.body){DDM._timeoutCount+=1;}}}},handleWasClicked:function(node,id){if(this.isHandle(id,node.id)){return true;}else{var p=node.parentNode;while(p){if(this.isHandle(id,p.id)){return true;}else{p=p.parentNode;}}}
+return false;}};}();YAHOO.util.DDM=YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();}
+YAHOO.util.DD=function(id,sGroup,config){if(id){this.init(id,sGroup,config);}};YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop,{scroll:true,autoOffset:function(iPageX,iPageY){var x=iPageX-this.startPageX;var y=iPageY-this.startPageY;this.setDelta(x,y);},setDelta:function(iDeltaX,iDeltaY){this.deltaX=iDeltaX;this.deltaY=iDeltaY;},setDragElPos:function(iPageX,iPageY){var el=this.getDragEl();this.alignElWithMouse(el,iPageX,iPageY);},alignElWithMouse:function(el,iPageX,iPageY){var oCoord=this.getTargetCoord(iPageX,iPageY);if(!this.deltaSetXY){var aCoord=[oCoord.x,oCoord.y];YAHOO.util.Dom.setXY(el,aCoord);var newLeft=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var newTop=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);this.deltaSetXY=[newLeft-oCoord.x,newTop-oCoord.y];}else{YAHOO.util.Dom.setStyle(el,"left",(oCoord.x+this.deltaSetXY[0])+"px");YAHOO.util.Dom.setStyle(el,"top",(oCoord.y+this.deltaSetXY[1])+"px");}
+this.cachePosition(oCoord.x,oCoord.y);this.autoScroll(oCoord.x,oCoord.y,el.offsetHeight,el.offsetWidth);},cachePosition:function(iPageX,iPageY){if(iPageX){this.lastPageX=iPageX;this.lastPageY=iPageY;}else{var aCoord=YAHOO.util.Dom.getXY(this.getEl());this.lastPageX=aCoord[0];this.lastPageY=aCoord[1];}},autoScroll:function(x,y,h,w){if(this.scroll){var clientH=this.DDM.getClientHeight();var clientW=this.DDM.getClientWidth();var st=this.DDM.getScrollTop();var sl=this.DDM.getScrollLeft();var bot=h+y;var right=w+x;var toBot=(clientH+st-y-this.deltaY);var toRight=(clientW+sl-x-this.deltaX);var thresh=40;var scrAmt=(document.all)?80:30;if(bot>clientH&&toBot0&&y-stclientW&&toRight0&&x-slthis.maxX){x=this.maxX;}}
+if(this.constrainY){if(ythis.maxY){y=this.maxY;}}
+x=this.getTick(x,this.xTicks);y=this.getTick(y,this.yTicks);return{x:x,y:y};},applyConfig:function(){YAHOO.util.DD.superclass.applyConfig.call(this);this.scroll=(this.config.scroll!==false);},b4MouseDown:function(e){this.autoOffset(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));},b4Drag:function(e){this.setDragElPos(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));},toString:function(){return("DD "+this.id);}});YAHOO.util.DDProxy=function(id,sGroup,config){if(id){this.init(id,sGroup,config);this.initFrame();}};YAHOO.util.DDProxy.dragElId="ygddfdiv";YAHOO.extend(YAHOO.util.DDProxy,YAHOO.util.DD,{resizeFrame:true,centerFrame:false,createFrame:function(){var self=this;var body=document.body;if(!body||!body.firstChild){setTimeout(function(){self.createFrame();},50);return;}
+var div=this.getDragEl();if(!div){div=document.createElement("div");div.id=this.dragElId;var s=div.style;s.position="absolute";s.visibility="hidden";s.cursor="move";s.border="2px solid #aaa";s.zIndex=999;body.insertBefore(div,body.firstChild);}},initFrame:function(){this.createFrame();},applyConfig:function(){YAHOO.util.DDProxy.superclass.applyConfig.call(this);this.resizeFrame=(this.config.resizeFrame!==false);this.centerFrame=(this.config.centerFrame);this.setDragElId(this.config.dragElId||YAHOO.util.DDProxy.dragElId);},showFrame:function(iPageX,iPageY){var el=this.getEl();var dragEl=this.getDragEl();var s=dragEl.style;this._resizeProxy();if(this.centerFrame){this.setDelta(Math.round(parseInt(s.width,10)/2),Math.round(parseInt(s.height,10)/2));}
+this.setDragElPos(iPageX,iPageY);YAHOO.util.Dom.setStyle(dragEl,"visibility","visible");},_resizeProxy:function(){if(this.resizeFrame){var DOM=YAHOO.util.Dom;var el=this.getEl();var dragEl=this.getDragEl();var bt=parseInt(DOM.getStyle(dragEl,"borderTopWidth"),10);var br=parseInt(DOM.getStyle(dragEl,"borderRightWidth"),10);var bb=parseInt(DOM.getStyle(dragEl,"borderBottomWidth"),10);var bl=parseInt(DOM.getStyle(dragEl,"borderLeftWidth"),10);if(isNaN(bt)){bt=0;}
+if(isNaN(br)){br=0;}
+if(isNaN(bb)){bb=0;}
+if(isNaN(bl)){bl=0;}
var newWidth=Math.max(0,el.offsetWidth-br-bl);var newHeight=Math.max(0,el.offsetHeight-bt-bb);DOM.setStyle(dragEl,"width",newWidth+"px");DOM.setStyle(dragEl,"height",newHeight+"px");}},b4MouseDown:function(e){var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.autoOffset(x,y);this.setDragElPos(x,y);},b4StartDrag:function(x,y){this.showFrame(x,y);},b4EndDrag:function(e){YAHOO.util.Dom.setStyle(this.getDragEl(),"visibility","hidden");},endDrag:function(e){var DOM=YAHOO.util.Dom;var lel=this.getEl();var del=this.getDragEl();DOM.setStyle(del,"visibility","");DOM.setStyle(lel,"visibility","hidden");YAHOO.util.DDM.moveToEl(lel,del);DOM.setStyle(del,"visibility","hidden");DOM.setStyle(lel,"visibility","");},toString:function(){return("DDProxy "+this.id);}});YAHOO.util.DDTarget=function(id,sGroup,config){if(id){this.initTarget(id,sGroup,config);}};YAHOO.extend(YAHOO.util.DDTarget,YAHOO.util.DragDrop,{toString:function(){return("DDTarget "+this.id);}});
\ No newline at end of file
diff --git a/lib/yui/dragdrop/dragdrop.js b/lib/yui/dragdrop/dragdrop.js
index f571e2448a..88ad3b7c95 100755
--- a/lib/yui/dragdrop/dragdrop.js
+++ b/lib/yui/dragdrop/dragdrop.js
@@ -1,2948 +1,2948 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 0.12.1
-*/
-(function() {
-
-var Event=YAHOO.util.Event;
-var Dom=YAHOO.util.Dom;
-
-/**
- * Defines the interface and base operation of items that that can be
- * dragged or can be drop targets. It was designed to be extended, overriding
- * the event handlers for startDrag, onDrag, onDragOver, onDragOut.
- * Up to three html elements can be associated with a DragDrop instance:
- *
- * linked element: the element that is passed into the constructor.
- * This is the element which defines the boundaries for interaction with
- * other DragDrop objects.
- * handle element(s): The drag operation only occurs if the element that
- * was clicked matches a handle element. By default this is the linked
- * element, but there are times that you will want only a portion of the
- * linked element to initiate the drag operation, and the setHandleElId()
- * method provides a way to define this.
- * drag element: this represents an the element that would be moved along
- * with the cursor during a drag operation. By default, this is the linked
- * element itself as in {@link YAHOO.util.DD}. setDragElId() lets you define
- * a separate element that would be moved, as in {@link YAHOO.util.DDProxy}
- *
- *
- * This class should not be instantiated until the onload event to ensure that
- * the associated elements are available.
- * The following would define a DragDrop obj that would interact with any
- * other DragDrop obj in the "group1" group:
- *
- * dd = new YAHOO.util.DragDrop("div1", "group1");
- *
- * Since none of the event handlers have been implemented, nothing would
- * actually happen if you were to run the code above. Normally you would
- * override this class or one of the default implementations, but you can
- * also override the methods you want on an instance of the class...
- *
- * dd.onDragDrop = function(e, id) {
- * alert("dd was dropped on " + id);
- * }
- *
- * @namespace YAHOO.util
- * @class DragDrop
- * @constructor
- * @param {String} id of the element that is linked to this instance
- * @param {String} sGroup the group of related DragDrop objects
- * @param {object} config an object containing configurable attributes
- * Valid properties for DragDrop:
- * padding, isTarget, maintainOffset, primaryButtonOnly,
- */
-YAHOO.util.DragDrop = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- }
-};
-
-YAHOO.util.DragDrop.prototype = {
-
- /**
- * The id of the element associated with this object. This is what we
- * refer to as the "linked element" because the size and position of
- * this element is used to determine when the drag and drop objects have
- * interacted.
- * @property id
- * @type String
- */
- id: null,
-
- /**
- * Configuration attributes passed into the constructor
- * @property config
- * @type object
- */
- config: null,
-
- /**
- * The id of the element that will be dragged. By default this is same
- * as the linked element , but could be changed to another element. Ex:
- * YAHOO.util.DDProxy
- * @property dragElId
- * @type String
- * @private
- */
- dragElId: null,
-
- /**
- * the id of the element that initiates the drag operation. By default
- * this is the linked element, but could be changed to be a child of this
- * element. This lets us do things like only starting the drag when the
- * header element within the linked html element is clicked.
- * @property handleElId
- * @type String
- * @private
- */
- handleElId: null,
-
- /**
- * An associative array of HTML tags that will be ignored if clicked.
- * @property invalidHandleTypes
- * @type {string: string}
- */
- invalidHandleTypes: null,
-
- /**
- * An associative array of ids for elements that will be ignored if clicked
- * @property invalidHandleIds
- * @type {string: string}
- */
- invalidHandleIds: null,
-
- /**
- * An indexted array of css class names for elements that will be ignored
- * if clicked.
- * @property invalidHandleClasses
- * @type string[]
- */
- invalidHandleClasses: null,
-
- /**
- * The linked element's absolute X position at the time the drag was
- * started
- * @property startPageX
- * @type int
- * @private
- */
- startPageX: 0,
-
- /**
- * The linked element's absolute X position at the time the drag was
- * started
- * @property startPageY
- * @type int
- * @private
- */
- startPageY: 0,
-
- /**
- * The group defines a logical collection of DragDrop objects that are
- * related. Instances only get events when interacting with other
- * DragDrop object in the same group. This lets us define multiple
- * groups using a single DragDrop subclass if we want.
- * @property groups
- * @type {string: string}
- */
- groups: null,
-
- /**
- * Individual drag/drop instances can be locked. This will prevent
- * onmousedown start drag.
- * @property locked
- * @type boolean
- * @private
- */
- locked: false,
-
- /**
- * Lock this instance
- * @method lock
- */
- lock: function() { this.locked = true; },
-
- /**
- * Unlock this instace
- * @method unlock
- */
- unlock: function() { this.locked = false; },
-
- /**
- * By default, all insances can be a drop target. This can be disabled by
- * setting isTarget to false.
- * @method isTarget
- * @type boolean
- */
- isTarget: true,
-
- /**
- * The padding configured for this drag and drop object for calculating
- * the drop zone intersection with this object.
- * @method padding
- * @type int[]
- */
- padding: null,
-
- /**
- * Cached reference to the linked element
- * @property _domRef
- * @private
- */
- _domRef: null,
-
- /**
- * Internal typeof flag
- * @property __ygDragDrop
- * @private
- */
- __ygDragDrop: true,
-
- /**
- * Set to true when horizontal contraints are applied
- * @property constrainX
- * @type boolean
- * @private
- */
- constrainX: false,
-
- /**
- * Set to true when vertical contraints are applied
- * @property constrainY
- * @type boolean
- * @private
- */
- constrainY: false,
-
- /**
- * The left constraint
- * @property minX
- * @type int
- * @private
- */
- minX: 0,
-
- /**
- * The right constraint
- * @property maxX
- * @type int
- * @private
- */
- maxX: 0,
-
- /**
- * The up constraint
- * @property minY
- * @type int
- * @type int
- * @private
- */
- minY: 0,
-
- /**
- * The down constraint
- * @property maxY
- * @type int
- * @private
- */
- maxY: 0,
-
- /**
- * Maintain offsets when we resetconstraints. Set to true when you want
- * the position of the element relative to its parent to stay the same
- * when the page changes
- *
- * @property maintainOffset
- * @type boolean
- */
- maintainOffset: false,
-
- /**
- * Array of pixel locations the element will snap to if we specified a
- * horizontal graduation/interval. This array is generated automatically
- * when you define a tick interval.
- * @property xTicks
- * @type int[]
- */
- xTicks: null,
-
- /**
- * Array of pixel locations the element will snap to if we specified a
- * vertical graduation/interval. This array is generated automatically
- * when you define a tick interval.
- * @property yTicks
- * @type int[]
- */
- yTicks: null,
-
- /**
- * By default the drag and drop instance will only respond to the primary
- * button click (left button for a right-handed mouse). Set to true to
- * allow drag and drop to start with any mouse click that is propogated
- * by the browser
- * @property primaryButtonOnly
- * @type boolean
- */
- primaryButtonOnly: true,
-
- /**
- * The availabe property is false until the linked dom element is accessible.
- * @property available
- * @type boolean
- */
- available: false,
-
- /**
- * By default, drags can only be initiated if the mousedown occurs in the
- * region the linked element is. This is done in part to work around a
- * bug in some browsers that mis-report the mousedown if the previous
- * mouseup happened outside of the window. This property is set to true
- * if outer handles are defined.
- *
- * @property hasOuterHandles
- * @type boolean
- * @default false
- */
- hasOuterHandles: false,
-
- /**
- * Code that executes immediately before the startDrag event
- * @method b4StartDrag
- * @private
- */
- b4StartDrag: function(x, y) { },
-
- /**
- * Abstract method called after a drag/drop object is clicked
- * and the drag or mousedown time thresholds have beeen met.
- * @method startDrag
- * @param {int} X click location
- * @param {int} Y click location
- */
- startDrag: function(x, y) { /* override this */ },
-
- /**
- * Code that executes immediately before the onDrag event
- * @method b4Drag
- * @private
- */
- b4Drag: function(e) { },
-
- /**
- * Abstract method called during the onMouseMove event while dragging an
- * object.
- * @method onDrag
- * @param {Event} e the mousemove event
- */
- onDrag: function(e) { /* override this */ },
-
- /**
- * Abstract method called when this element fist begins hovering over
- * another DragDrop obj
- * @method onDragEnter
- * @param {Event} e the mousemove event
- * @param {String|DragDrop[]} id In POINT mode, the element
- * id this is hovering over. In INTERSECT mode, an array of one or more
- * dragdrop items being hovered over.
- */
- onDragEnter: function(e, id) { /* override this */ },
-
- /**
- * Code that executes immediately before the onDragOver event
- * @method b4DragOver
- * @private
- */
- b4DragOver: function(e) { },
-
- /**
- * Abstract method called when this element is hovering over another
- * DragDrop obj
- * @method onDragOver
- * @param {Event} e the mousemove event
- * @param {String|DragDrop[]} id In POINT mode, the element
- * id this is hovering over. In INTERSECT mode, an array of dd items
- * being hovered over.
- */
- onDragOver: function(e, id) { /* override this */ },
-
- /**
- * Code that executes immediately before the onDragOut event
- * @method b4DragOut
- * @private
- */
- b4DragOut: function(e) { },
-
- /**
- * Abstract method called when we are no longer hovering over an element
- * @method onDragOut
- * @param {Event} e the mousemove event
- * @param {String|DragDrop[]} id In POINT mode, the element
- * id this was hovering over. In INTERSECT mode, an array of dd items
- * that the mouse is no longer over.
- */
- onDragOut: function(e, id) { /* override this */ },
-
- /**
- * Code that executes immediately before the onDragDrop event
- * @method b4DragDrop
- * @private
- */
- b4DragDrop: function(e) { },
-
- /**
- * Abstract method called when this item is dropped on another DragDrop
- * obj
- * @method onDragDrop
- * @param {Event} e the mouseup event
- * @param {String|DragDrop[]} id In POINT mode, the element
- * id this was dropped on. In INTERSECT mode, an array of dd items this
- * was dropped on.
- */
- onDragDrop: function(e, id) { /* override this */ },
-
- /**
- * Abstract method called when this item is dropped on an area with no
- * drop target
- * @method onInvalidDrop
- * @param {Event} e the mouseup event
- */
- onInvalidDrop: function(e) { /* override this */ },
-
- /**
- * Code that executes immediately before the endDrag event
- * @method b4EndDrag
- * @private
- */
- b4EndDrag: function(e) { },
-
- /**
- * Fired when we are done dragging the object
- * @method endDrag
- * @param {Event} e the mouseup event
- */
- endDrag: function(e) { /* override this */ },
-
- /**
- * Code executed immediately before the onMouseDown event
- * @method b4MouseDown
- * @param {Event} e the mousedown event
- * @private
- */
- b4MouseDown: function(e) { },
-
- /**
- * Event handler that fires when a drag/drop obj gets a mousedown
- * @method onMouseDown
- * @param {Event} e the mousedown event
- */
- onMouseDown: function(e) { /* override this */ },
-
- /**
- * Event handler that fires when a drag/drop obj gets a mouseup
- * @method onMouseUp
- * @param {Event} e the mouseup event
- */
- onMouseUp: function(e) { /* override this */ },
-
- /**
- * Override the onAvailable method to do what is needed after the initial
- * position was determined.
- * @method onAvailable
- */
- onAvailable: function () {
- },
-
- /**
- * Returns a reference to the linked element
- * @method getEl
- * @return {HTMLElement} the html element
- */
- getEl: function() {
- if (!this._domRef) {
- this._domRef = Dom.get(this.id);
- }
-
- return this._domRef;
- },
-
- /**
- * Returns a reference to the actual element to drag. By default this is
- * the same as the html element, but it can be assigned to another
- * element. An example of this can be found in YAHOO.util.DDProxy
- * @method getDragEl
- * @return {HTMLElement} the html element
- */
- getDragEl: function() {
- return Dom.get(this.dragElId);
- },
-
- /**
- * Sets up the DragDrop object. Must be called in the constructor of any
- * YAHOO.util.DragDrop subclass
- * @method init
- * @param id the id of the linked element
- * @param {String} sGroup the group of related items
- * @param {object} config configuration attributes
- */
- init: function(id, sGroup, config) {
- this.initTarget(id, sGroup, config);
- Event.on(this.id, "mousedown", this.handleMouseDown, this, true);
- // Event.on(this.id, "selectstart", Event.preventDefault);
- },
-
- /**
- * Initializes Targeting functionality only... the object does not
- * get a mousedown handler.
- * @method initTarget
- * @param id the id of the linked element
- * @param {String} sGroup the group of related items
- * @param {object} config configuration attributes
- */
- initTarget: function(id, sGroup, config) {
-
- // configuration attributes
- this.config = config || {};
-
- // create a local reference to the drag and drop manager
- this.DDM = YAHOO.util.DDM;
- // initialize the groups array
- this.groups = {};
-
- // assume that we have an element reference instead of an id if the
- // parameter is not a string
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
-
- // set the id
- this.id = id;
-
- // add to an interaction group
- this.addToGroup((sGroup) ? sGroup : "default");
-
- // We don't want to register this as the handle with the manager
- // so we just set the id rather than calling the setter.
- this.handleElId = id;
-
- Event.onAvailable(id, this.handleOnAvailable, this, true);
-
-
- // the linked element is the element that gets dragged by default
- this.setDragElId(id);
-
- // by default, clicked anchors will not start drag operations.
- // @TODO what else should be here? Probably form fields.
- this.invalidHandleTypes = { A: "A" };
- this.invalidHandleIds = {};
- this.invalidHandleClasses = [];
-
- this.applyConfig();
- },
-
- /**
- * Applies the configuration parameters that were passed into the constructor.
- * This is supposed to happen at each level through the inheritance chain. So
- * a DDProxy implentation will execute apply config on DDProxy, DD, and
- * DragDrop in order to get all of the parameters that are available in
- * each object.
- * @method applyConfig
- */
- applyConfig: function() {
-
- // configurable properties:
- // padding, isTarget, maintainOffset, primaryButtonOnly
- this.padding = this.config.padding || [0, 0, 0, 0];
- this.isTarget = (this.config.isTarget !== false);
- this.maintainOffset = (this.config.maintainOffset);
- this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
-
- },
-
- /**
- * Executed when the linked element is available
- * @method handleOnAvailable
- * @private
- */
- handleOnAvailable: function() {
- this.available = true;
- this.resetConstraints();
- this.onAvailable();
- },
-
- /**
- * Configures the padding for the target zone in px. Effectively expands
- * (or reduces) the virtual object size for targeting calculations.
- * Supports css-style shorthand; if only one parameter is passed, all sides
- * will have that padding, and if only two are passed, the top and bottom
- * will have the first param, the left and right the second.
- * @method setPadding
- * @param {int} iTop Top pad
- * @param {int} iRight Right pad
- * @param {int} iBot Bot pad
- * @param {int} iLeft Left pad
- */
- setPadding: function(iTop, iRight, iBot, iLeft) {
- // this.padding = [iLeft, iRight, iTop, iBot];
- if (!iRight && 0 !== iRight) {
- this.padding = [iTop, iTop, iTop, iTop];
- } else if (!iBot && 0 !== iBot) {
- this.padding = [iTop, iRight, iTop, iRight];
- } else {
- this.padding = [iTop, iRight, iBot, iLeft];
- }
- },
-
- /**
- * Stores the initial placement of the linked element.
- * @method setInitialPosition
- * @param {int} diffX the X offset, default 0
- * @param {int} diffY the Y offset, default 0
- */
- setInitPosition: function(diffX, diffY) {
- var el = this.getEl();
-
- if (!this.DDM.verifyEl(el)) {
- return;
- }
-
- var dx = diffX || 0;
- var dy = diffY || 0;
-
- var p = Dom.getXY( el );
-
- this.initPageX = p[0] - dx;
- this.initPageY = p[1] - dy;
-
- this.lastPageX = p[0];
- this.lastPageY = p[1];
-
-
- this.setStartPosition(p);
- },
-
- /**
- * Sets the start position of the element. This is set when the obj
- * is initialized, the reset when a drag is started.
- * @method setStartPosition
- * @param pos current position (from previous lookup)
- * @private
- */
- setStartPosition: function(pos) {
- var p = pos || Dom.getXY( this.getEl() );
-
- this.deltaSetXY = null;
-
- this.startPageX = p[0];
- this.startPageY = p[1];
- },
-
- /**
- * Add this instance to a group of related drag/drop objects. All
- * instances belong to at least one group, and can belong to as many
- * groups as needed.
- * @method addToGroup
- * @param sGroup {string} the name of the group
- */
- addToGroup: function(sGroup) {
- this.groups[sGroup] = true;
- this.DDM.regDragDrop(this, sGroup);
- },
-
- /**
- * Remove's this instance from the supplied interaction group
- * @method removeFromGroup
- * @param {string} sGroup The group to drop
- */
- removeFromGroup: function(sGroup) {
- if (this.groups[sGroup]) {
- delete this.groups[sGroup];
- }
-
- this.DDM.removeDDFromGroup(this, sGroup);
- },
-
- /**
- * Allows you to specify that an element other than the linked element
- * will be moved with the cursor during a drag
- * @method setDragElId
- * @param id {string} the id of the element that will be used to initiate the drag
- */
- setDragElId: function(id) {
- this.dragElId = id;
- },
-
- /**
- * Allows you to specify a child of the linked element that should be
- * used to initiate the drag operation. An example of this would be if
- * you have a content div with text and links. Clicking anywhere in the
- * content area would normally start the drag operation. Use this method
- * to specify that an element inside of the content div is the element
- * that starts the drag operation.
- * @method setHandleElId
- * @param id {string} the id of the element that will be used to
- * initiate the drag.
- */
- setHandleElId: function(id) {
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
- this.handleElId = id;
- this.DDM.regHandle(this.id, id);
- },
-
- /**
- * Allows you to set an element outside of the linked element as a drag
- * handle
- * @method setOuterHandleElId
- * @param id the id of the element that will be used to initiate the drag
- */
- setOuterHandleElId: function(id) {
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
- Event.on(id, "mousedown",
- this.handleMouseDown, this, true);
- this.setHandleElId(id);
-
- this.hasOuterHandles = true;
- },
-
- /**
- * Remove all drag and drop hooks for this element
- * @method unreg
- */
- unreg: function() {
- Event.removeListener(this.id, "mousedown",
- this.handleMouseDown);
- this._domRef = null;
- this.DDM._remove(this);
- },
-
- /**
- * Returns true if this instance is locked, or the drag drop mgr is locked
- * (meaning that all drag/drop is disabled on the page.)
- * @method isLocked
- * @return {boolean} true if this obj or all drag/drop is locked, else
- * false
- */
- isLocked: function() {
- return (this.DDM.isLocked() || this.locked);
- },
-
- /**
- * Fired when this object is clicked
- * @method handleMouseDown
- * @param {Event} e
- * @param {YAHOO.util.DragDrop} oDD the clicked dd object (this dd obj)
- * @private
- */
- handleMouseDown: function(e, oDD) {
-
- var button = e.which || e.button;
-
- if (this.primaryButtonOnly && button > 1) {
- return;
- }
-
- if (this.isLocked()) {
- return;
- }
-
- this.DDM.refreshCache(this.groups);
- // var self = this;
- // setTimeout( function() { self.DDM.refreshCache(self.groups); }, 0);
-
- // Only process the event if we really clicked within the linked
- // element. The reason we make this check is that in the case that
- // another element was moved between the clicked element and the
- // cursor in the time between the mousedown and mouseup events. When
- // this happens, the element gets the next mousedown event
- // regardless of where on the screen it happened.
- var pt = new YAHOO.util.Point(Event.getPageX(e), Event.getPageY(e));
- if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
- } else {
- if (this.clickValidator(e)) {
-
-
- // set the initial element position
- this.setStartPosition();
-
-
- this.b4MouseDown(e);
- this.onMouseDown(e);
- this.DDM.handleMouseDown(e, this);
-
- this.DDM.stopEvent(e);
- } else {
-
-
- }
- }
- },
-
- clickValidator: function(e) {
- var target = Event.getTarget(e);
- return ( this.isValidHandleChild(target) &&
- (this.id == this.handleElId ||
- this.DDM.handleWasClicked(target, this.id)) );
- },
-
- /**
- * Allows you to specify a tag name that should not start a drag operation
- * when clicked. This is designed to facilitate embedding links within a
- * drag handle that do something other than start the drag.
- * @method addInvalidHandleType
- * @param {string} tagName the type of element to exclude
- */
- addInvalidHandleType: function(tagName) {
- var type = tagName.toUpperCase();
- this.invalidHandleTypes[type] = type;
- },
-
- /**
- * Lets you to specify an element id for a child of a drag handle
- * that should not initiate a drag
- * @method addInvalidHandleId
- * @param {string} id the element id of the element you wish to ignore
- */
- addInvalidHandleId: function(id) {
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
- this.invalidHandleIds[id] = id;
- },
-
- /**
- * Lets you specify a css class of elements that will not initiate a drag
- * @method addInvalidHandleClass
- * @param {string} cssClass the class of the elements you wish to ignore
- */
- addInvalidHandleClass: function(cssClass) {
- this.invalidHandleClasses.push(cssClass);
- },
-
- /**
- * Unsets an excluded tag name set by addInvalidHandleType
- * @method removeInvalidHandleType
- * @param {string} tagName the type of element to unexclude
- */
- removeInvalidHandleType: function(tagName) {
- var type = tagName.toUpperCase();
- // this.invalidHandleTypes[type] = null;
- delete this.invalidHandleTypes[type];
- },
-
- /**
- * Unsets an invalid handle id
- * @method removeInvalidHandleId
- * @param {string} id the id of the element to re-enable
- */
- removeInvalidHandleId: function(id) {
- if (typeof id !== "string") {
- YAHOO.log("id is not a string, assuming it is an HTMLElement");
- id = Dom.generateId(id);
- }
- delete this.invalidHandleIds[id];
- },
-
- /**
- * Unsets an invalid css class
- * @method removeInvalidHandleClass
- * @param {string} cssClass the class of the element(s) you wish to
- * re-enable
- */
- removeInvalidHandleClass: function(cssClass) {
- for (var i=0, len=this.invalidHandleClasses.length; i= this.minX; i = i - iTickSize) {
- if (!tickMap[i]) {
- this.xTicks[this.xTicks.length] = i;
- tickMap[i] = true;
- }
- }
-
- for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
- if (!tickMap[i]) {
- this.xTicks[this.xTicks.length] = i;
- tickMap[i] = true;
- }
- }
-
- this.xTicks.sort(this.DDM.numericSort) ;
- },
-
- /**
- * Create the array of vertical tick marks if an interval was specified in
- * setYConstraint().
- * @method setYTicks
- * @private
- */
- setYTicks: function(iStartY, iTickSize) {
- this.yTicks = [];
- this.yTickSize = iTickSize;
-
- var tickMap = {};
-
- for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
- if (!tickMap[i]) {
- this.yTicks[this.yTicks.length] = i;
- tickMap[i] = true;
- }
- }
-
- for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
- if (!tickMap[i]) {
- this.yTicks[this.yTicks.length] = i;
- tickMap[i] = true;
- }
- }
-
- this.yTicks.sort(this.DDM.numericSort) ;
- },
-
- /**
- * By default, the element can be dragged any place on the screen. Use
- * this method to limit the horizontal travel of the element. Pass in
- * 0,0 for the parameters if you want to lock the drag to the y axis.
- * @method setXConstraint
- * @param {int} iLeft the number of pixels the element can move to the left
- * @param {int} iRight the number of pixels the element can move to the
- * right
- * @param {int} iTickSize optional parameter for specifying that the
- * element
- * should move iTickSize pixels at a time.
- */
- setXConstraint: function(iLeft, iRight, iTickSize) {
- this.leftConstraint = iLeft;
- this.rightConstraint = iRight;
-
- this.minX = this.initPageX - iLeft;
- this.maxX = this.initPageX + iRight;
- if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
-
- this.constrainX = true;
- },
-
- /**
- * Clears any constraints applied to this instance. Also clears ticks
- * since they can't exist independent of a constraint at this time.
- * @method clearConstraints
- */
- clearConstraints: function() {
- this.constrainX = false;
- this.constrainY = false;
- this.clearTicks();
- },
-
- /**
- * Clears any tick interval defined for this instance
- * @method clearTicks
- */
- clearTicks: function() {
- this.xTicks = null;
- this.yTicks = null;
- this.xTickSize = 0;
- this.yTickSize = 0;
- },
-
- /**
- * By default, the element can be dragged any place on the screen. Set
- * this to limit the vertical travel of the element. Pass in 0,0 for the
- * parameters if you want to lock the drag to the x axis.
- * @method setYConstraint
- * @param {int} iUp the number of pixels the element can move up
- * @param {int} iDown the number of pixels the element can move down
- * @param {int} iTickSize optional parameter for specifying that the
- * element should move iTickSize pixels at a time.
- */
- setYConstraint: function(iUp, iDown, iTickSize) {
- this.topConstraint = iUp;
- this.bottomConstraint = iDown;
-
- this.minY = this.initPageY - iUp;
- this.maxY = this.initPageY + iDown;
- if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
-
- this.constrainY = true;
-
- },
-
- /**
- * resetConstraints must be called if you manually reposition a dd element.
- * @method resetConstraints
- * @param {boolean} maintainOffset
- */
- resetConstraints: function() {
-
-
- // Maintain offsets if necessary
- if (this.initPageX || this.initPageX === 0) {
- // figure out how much this thing has moved
- var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
- var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
-
- this.setInitPosition(dx, dy);
-
- // This is the first time we have detected the element's position
- } else {
- this.setInitPosition();
- }
-
- if (this.constrainX) {
- this.setXConstraint( this.leftConstraint,
- this.rightConstraint,
- this.xTickSize );
- }
-
- if (this.constrainY) {
- this.setYConstraint( this.topConstraint,
- this.bottomConstraint,
- this.yTickSize );
- }
- },
-
- /**
- * Normally the drag element is moved pixel by pixel, but we can specify
- * that it move a number of pixels at a time. This method resolves the
- * location when we have it set up like this.
- * @method getTick
- * @param {int} val where we want to place the object
- * @param {int[]} tickArray sorted array of valid points
- * @return {int} the closest tick
- * @private
- */
- getTick: function(val, tickArray) {
-
- if (!tickArray) {
- // If tick interval is not defined, it is effectively 1 pixel,
- // so we return the value passed to us.
- return val;
- } else if (tickArray[0] >= val) {
- // The value is lower than the first tick, so we return the first
- // tick.
- return tickArray[0];
- } else {
- for (var i=0, len=tickArray.length; i= val) {
- var diff1 = val - tickArray[i];
- var diff2 = tickArray[next] - val;
- return (diff2 > diff1) ? tickArray[i] : tickArray[next];
- }
- }
-
- // The value is larger than the last tick, so we return the last
- // tick.
- return tickArray[tickArray.length - 1];
- }
- },
-
- /**
- * toString method
- * @method toString
- * @return {string} string representation of the dd obj
- */
- toString: function() {
- return ("DragDrop " + this.id);
- }
-
-};
-
-})();
-/**
- * The drag and drop utility provides a framework for building drag and drop
- * applications. In addition to enabling drag and drop for specific elements,
- * the drag and drop elements are tracked by the manager class, and the
- * interactions between the various elements are tracked during the drag and
- * the implementing code is notified about these important moments.
- * @module dragdrop
- * @title Drag and Drop
- * @requires yahoo,dom,event
- * @namespace YAHOO.util
- */
-
-// Only load the library once. Rewriting the manager class would orphan
-// existing drag and drop instances.
-if (!YAHOO.util.DragDropMgr) {
-
-/**
- * DragDropMgr is a singleton that tracks the element interaction for
- * all DragDrop items in the window. Generally, you will not call
- * this class directly, but it does have helper methods that could
- * be useful in your DragDrop implementations.
- * @class DragDropMgr
- * @static
- */
-YAHOO.util.DragDropMgr = function() {
-
- var Event = YAHOO.util.Event;
-
- return {
-
- /**
- * Two dimensional Array of registered DragDrop objects. The first
- * dimension is the DragDrop item group, the second the DragDrop
- * object.
- * @property ids
- * @type {string: string}
- * @private
- * @static
- */
- ids: {},
-
- /**
- * Array of element ids defined as drag handles. Used to determine
- * if the element that generated the mousedown event is actually the
- * handle and not the html element itself.
- * @property handleIds
- * @type {string: string}
- * @private
- * @static
- */
- handleIds: {},
-
- /**
- * the DragDrop object that is currently being dragged
- * @property dragCurrent
- * @type DragDrop
- * @private
- * @static
- **/
- dragCurrent: null,
-
- /**
- * the DragDrop object(s) that are being hovered over
- * @property dragOvers
- * @type Array
- * @private
- * @static
- */
- dragOvers: {},
-
- /**
- * the X distance between the cursor and the object being dragged
- * @property deltaX
- * @type int
- * @private
- * @static
- */
- deltaX: 0,
-
- /**
- * the Y distance between the cursor and the object being dragged
- * @property deltaY
- * @type int
- * @private
- * @static
- */
- deltaY: 0,
-
- /**
- * Flag to determine if we should prevent the default behavior of the
- * events we define. By default this is true, but this can be set to
- * false if you need the default behavior (not recommended)
- * @property preventDefault
- * @type boolean
- * @static
- */
- preventDefault: true,
-
- /**
- * Flag to determine if we should stop the propagation of the events
- * we generate. This is true by default but you may want to set it to
- * false if the html element contains other features that require the
- * mouse click.
- * @property stopPropagation
- * @type boolean
- * @static
- */
- stopPropagation: true,
-
- /**
- * Internal flag that is set to true when drag and drop has been
- * intialized
- * @property initialized
- * @private
- * @static
- */
- initalized: false,
-
- /**
- * All drag and drop can be disabled.
- * @property locked
- * @private
- * @static
- */
- locked: false,
-
- /**
- * Called the first time an element is registered.
- * @method init
- * @private
- * @static
- */
- init: function() {
- this.initialized = true;
- },
-
- /**
- * In point mode, drag and drop interaction is defined by the
- * location of the cursor during the drag/drop
- * @property POINT
- * @type int
- * @static
- * @final
- */
- POINT: 0,
-
- /**
- * In intersect mode, drag and drop interaction is defined by the
- * cursor position or the amount of overlap of two or more drag and
- * drop objects.
- * @property INTERSECT
- * @type int
- * @static
- * @final
- */
- INTERSECT: 1,
-
- /**
- * In intersect mode, drag and drop interaction is defined only by the
- * overlap of two or more drag and drop objects.
- * @property STRICT_INTERSECT
- * @type int
- * @static
- * @final
- */
- STRICT_INTERSECT: 2,
-
- /**
- * The current drag and drop mode. Default: POINT
- * @property mode
- * @type int
- * @static
- */
- mode: 0,
-
- /**
- * Runs method on all drag and drop objects
- * @method _execOnAll
- * @private
- * @static
- */
- _execOnAll: function(sMethod, args) {
- for (var i in this.ids) {
- for (var j in this.ids[i]) {
- var oDD = this.ids[i][j];
- if (! this.isTypeOfDD(oDD)) {
- continue;
- }
- oDD[sMethod].apply(oDD, args);
- }
- }
- },
-
- /**
- * Drag and drop initialization. Sets up the global event handlers
- * @method _onLoad
- * @private
- * @static
- */
- _onLoad: function() {
-
- this.init();
-
-
- Event.on(document, "mouseup", this.handleMouseUp, this, true);
- Event.on(document, "mousemove", this.handleMouseMove, this, true);
- Event.on(window, "unload", this._onUnload, this, true);
- Event.on(window, "resize", this._onResize, this, true);
- // Event.on(window, "mouseout", this._test);
-
- },
-
- /**
- * Reset constraints on all drag and drop objs
- * @method _onResize
- * @private
- * @static
- */
- _onResize: function(e) {
- this._execOnAll("resetConstraints", []);
- },
-
- /**
- * Lock all drag and drop functionality
- * @method lock
- * @static
- */
- lock: function() { this.locked = true; },
-
- /**
- * Unlock all drag and drop functionality
- * @method unlock
- * @static
- */
- unlock: function() { this.locked = false; },
-
- /**
- * Is drag and drop locked?
- * @method isLocked
- * @return {boolean} True if drag and drop is locked, false otherwise.
- * @static
- */
- isLocked: function() { return this.locked; },
-
- /**
- * Location cache that is set for all drag drop objects when a drag is
- * initiated, cleared when the drag is finished.
- * @property locationCache
- * @private
- * @static
- */
- locationCache: {},
-
- /**
- * Set useCache to false if you want to force object the lookup of each
- * drag and drop linked element constantly during a drag.
- * @property useCache
- * @type boolean
- * @static
- */
- useCache: true,
-
- /**
- * The number of pixels that the mouse needs to move after the
- * mousedown before the drag is initiated. Default=3;
- * @property clickPixelThresh
- * @type int
- * @static
- */
- clickPixelThresh: 3,
-
- /**
- * The number of milliseconds after the mousedown event to initiate the
- * drag if we don't get a mouseup event. Default=1000
- * @property clickTimeThresh
- * @type int
- * @static
- */
- clickTimeThresh: 1000,
-
- /**
- * Flag that indicates that either the drag pixel threshold or the
- * mousdown time threshold has been met
- * @property dragThreshMet
- * @type boolean
- * @private
- * @static
- */
- dragThreshMet: false,
-
- /**
- * Timeout used for the click time threshold
- * @property clickTimeout
- * @type Object
- * @private
- * @static
- */
- clickTimeout: null,
-
- /**
- * The X position of the mousedown event stored for later use when a
- * drag threshold is met.
- * @property startX
- * @type int
- * @private
- * @static
- */
- startX: 0,
-
- /**
- * The Y position of the mousedown event stored for later use when a
- * drag threshold is met.
- * @property startY
- * @type int
- * @private
- * @static
- */
- startY: 0,
-
- /**
- * Each DragDrop instance must be registered with the DragDropMgr.
- * This is executed in DragDrop.init()
- * @method regDragDrop
- * @param {DragDrop} oDD the DragDrop object to register
- * @param {String} sGroup the name of the group this element belongs to
- * @static
- */
- regDragDrop: function(oDD, sGroup) {
- if (!this.initialized) { this.init(); }
-
- if (!this.ids[sGroup]) {
- this.ids[sGroup] = {};
- }
- this.ids[sGroup][oDD.id] = oDD;
- },
-
- /**
- * Removes the supplied dd instance from the supplied group. Executed
- * by DragDrop.removeFromGroup, so don't call this function directly.
- * @method removeDDFromGroup
- * @private
- * @static
- */
- removeDDFromGroup: function(oDD, sGroup) {
- if (!this.ids[sGroup]) {
- this.ids[sGroup] = {};
- }
-
- var obj = this.ids[sGroup];
- if (obj && obj[oDD.id]) {
- delete obj[oDD.id];
- }
- },
-
- /**
- * Unregisters a drag and drop item. This is executed in
- * DragDrop.unreg, use that method instead of calling this directly.
- * @method _remove
- * @private
- * @static
- */
- _remove: function(oDD) {
- for (var g in oDD.groups) {
- if (g && this.ids[g][oDD.id]) {
- delete this.ids[g][oDD.id];
- }
- }
- delete this.handleIds[oDD.id];
- },
-
- /**
- * Each DragDrop handle element must be registered. This is done
- * automatically when executing DragDrop.setHandleElId()
- * @method regHandle
- * @param {String} sDDId the DragDrop id this element is a handle for
- * @param {String} sHandleId the id of the element that is the drag
- * handle
- * @static
- */
- regHandle: function(sDDId, sHandleId) {
- if (!this.handleIds[sDDId]) {
- this.handleIds[sDDId] = {};
- }
- this.handleIds[sDDId][sHandleId] = sHandleId;
- },
-
- /**
- * Utility function to determine if a given element has been
- * registered as a drag drop item.
- * @method isDragDrop
- * @param {String} id the element id to check
- * @return {boolean} true if this element is a DragDrop item,
- * false otherwise
- * @static
- */
- isDragDrop: function(id) {
- return ( this.getDDById(id) ) ? true : false;
- },
-
- /**
- * Returns the drag and drop instances that are in all groups the
- * passed in instance belongs to.
- * @method getRelated
- * @param {DragDrop} p_oDD the obj to get related data for
- * @param {boolean} bTargetsOnly if true, only return targetable objs
- * @return {DragDrop[]} the related instances
- * @static
- */
- getRelated: function(p_oDD, bTargetsOnly) {
- var oDDs = [];
- for (var i in p_oDD.groups) {
- for (j in this.ids[i]) {
- var dd = this.ids[i][j];
- if (! this.isTypeOfDD(dd)) {
- continue;
- }
- if (!bTargetsOnly || dd.isTarget) {
- oDDs[oDDs.length] = dd;
- }
- }
- }
-
- return oDDs;
- },
-
- /**
- * Returns true if the specified dd target is a legal target for
- * the specifice drag obj
- * @method isLegalTarget
- * @param {DragDrop} the drag obj
- * @param {DragDrop} the target
- * @return {boolean} true if the target is a legal target for the
- * dd obj
- * @static
- */
- isLegalTarget: function (oDD, oTargetDD) {
- var targets = this.getRelated(oDD, true);
- for (var i=0, len=targets.length;i this.clickPixelThresh ||
- diffY > this.clickPixelThresh) {
- this.startDrag(this.startX, this.startY);
- }
- }
-
- if (this.dragThreshMet) {
- this.dragCurrent.b4Drag(e);
- this.dragCurrent.onDrag(e);
- this.fireEvents(e, false);
- }
-
- this.stopEvent(e);
-
- return true;
- },
-
- /**
- * Iterates over all of the DragDrop elements to find ones we are
- * hovering over or dropping on
- * @method fireEvents
- * @param {Event} e the event
- * @param {boolean} isDrop is this a drop op or a mouseover op?
- * @private
- * @static
- */
- fireEvents: function(e, isDrop) {
- var dc = this.dragCurrent;
-
- // If the user did the mouse up outside of the window, we could
- // get here even though we have ended the drag.
- if (!dc || dc.isLocked()) {
- return;
- }
-
- var x = YAHOO.util.Event.getPageX(e);
- var y = YAHOO.util.Event.getPageY(e);
- var pt = new YAHOO.util.Point(x,y);
-
- // cache the previous dragOver array
- var oldOvers = [];
-
- var outEvts = [];
- var overEvts = [];
- var dropEvts = [];
- var enterEvts = [];
-
- // Check to see if the object(s) we were hovering over is no longer
- // being hovered over so we can fire the onDragOut event
- for (var i in this.dragOvers) {
-
- var ddo = this.dragOvers[i];
-
- if (! this.isTypeOfDD(ddo)) {
- continue;
- }
-
- if (! this.isOverTarget(pt, ddo, this.mode)) {
- outEvts.push( ddo );
- }
-
- oldOvers[i] = true;
- delete this.dragOvers[i];
- }
-
- for (var sGroup in dc.groups) {
-
- if ("string" != typeof sGroup) {
- continue;
- }
-
- for (i in this.ids[sGroup]) {
- var oDD = this.ids[sGroup][i];
- if (! this.isTypeOfDD(oDD)) {
- continue;
- }
-
- if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
- if (this.isOverTarget(pt, oDD, this.mode)) {
- // look for drop interactions
- if (isDrop) {
- dropEvts.push( oDD );
- // look for drag enter and drag over interactions
- } else {
-
- // initial drag over: dragEnter fires
- if (!oldOvers[oDD.id]) {
- enterEvts.push( oDD );
- // subsequent drag overs: dragOver fires
- } else {
- overEvts.push( oDD );
- }
-
- this.dragOvers[oDD.id] = oDD;
- }
- }
- }
- }
- }
-
- if (this.mode) {
- if (outEvts.length) {
- dc.b4DragOut(e, outEvts);
- dc.onDragOut(e, outEvts);
- }
-
- if (enterEvts.length) {
- dc.onDragEnter(e, enterEvts);
- }
-
- if (overEvts.length) {
- dc.b4DragOver(e, overEvts);
- dc.onDragOver(e, overEvts);
- }
-
- if (dropEvts.length) {
- dc.b4DragDrop(e, dropEvts);
- dc.onDragDrop(e, dropEvts);
- }
-
- } else {
- // fire dragout events
- var len = 0;
- for (i=0, len=outEvts.length; i
- * YAHOO.util.DragDropMgr.refreshCache(ddinstance.groups);
- *
- * Alternatively:
- *
- * YAHOO.util.DragDropMgr.refreshCache({group1:true, group2:true});
- *
- * @TODO this really should be an indexed array. Alternatively this
- * method could accept both.
- * @method refreshCache
- * @param {Object} groups an associative array of groups to refresh
- * @static
- */
- refreshCache: function(groups) {
- for (var sGroup in groups) {
- if ("string" != typeof sGroup) {
- continue;
- }
- for (var i in this.ids[sGroup]) {
- var oDD = this.ids[sGroup][i];
-
- if (this.isTypeOfDD(oDD)) {
- // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
- var loc = this.getLocation(oDD);
- if (loc) {
- this.locationCache[oDD.id] = loc;
- } else {
- delete this.locationCache[oDD.id];
- // this will unregister the drag and drop object if
- // the element is not in a usable state
- // oDD.unreg();
- }
- }
- }
- }
- },
-
- /**
- * This checks to make sure an element exists and is in the DOM. The
- * main purpose is to handle cases where innerHTML is used to remove
- * drag and drop objects from the DOM. IE provides an 'unspecified
- * error' when trying to access the offsetParent of such an element
- * @method verifyEl
- * @param {HTMLElement} el the element to check
- * @return {boolean} true if the element looks usable
- * @static
- */
- verifyEl: function(el) {
- try {
- if (el) {
- var parent = el.offsetParent;
- if (parent) {
- return true;
- }
- }
- } catch(e) {
- }
-
- return false;
- },
-
- /**
- * Returns a Region object containing the drag and drop element's position
- * and size, including the padding configured for it
- * @method getLocation
- * @param {DragDrop} oDD the drag and drop object to get the
- * location for
- * @return {YAHOO.util.Region} a Region object representing the total area
- * the element occupies, including any padding
- * the instance is configured for.
- * @static
- */
- getLocation: function(oDD) {
- if (! this.isTypeOfDD(oDD)) {
- return null;
- }
-
- var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
-
- try {
- pos= YAHOO.util.Dom.getXY(el);
- } catch (e) { }
-
- if (!pos) {
- return null;
- }
-
- x1 = pos[0];
- x2 = x1 + el.offsetWidth;
- y1 = pos[1];
- y2 = y1 + el.offsetHeight;
-
- t = y1 - oDD.padding[0];
- r = x2 + oDD.padding[1];
- b = y2 + oDD.padding[2];
- l = x1 - oDD.padding[3];
-
- return new YAHOO.util.Region( t, r, b, l );
- },
-
- /**
- * Checks the cursor location to see if it over the target
- * @method isOverTarget
- * @param {YAHOO.util.Point} pt The point to evaluate
- * @param {DragDrop} oTarget the DragDrop object we are inspecting
- * @return {boolean} true if the mouse is over the target
- * @private
- * @static
- */
- isOverTarget: function(pt, oTarget, intersect) {
- // use cache if available
- var loc = this.locationCache[oTarget.id];
- if (!loc || !this.useCache) {
- loc = this.getLocation(oTarget);
- this.locationCache[oTarget.id] = loc;
-
- }
-
- if (!loc) {
- return false;
- }
-
- oTarget.cursorIsOver = loc.contains( pt );
-
- // DragDrop is using this as a sanity check for the initial mousedown
- // in this case we are done. In POINT mode, if the drag obj has no
- // contraints, we are also done. Otherwise we need to evaluate the
- // location of the target as related to the actual location of the
- // dragged element.
- var dc = this.dragCurrent;
- if (!dc || !dc.getTargetCoord ||
- (!intersect && !dc.constrainX && !dc.constrainY)) {
- return oTarget.cursorIsOver;
- }
-
- oTarget.overlap = null;
-
- // Get the current location of the drag element, this is the
- // location of the mouse event less the delta that represents
- // where the original mousedown happened on the element. We
- // need to consider constraints and ticks as well.
- var pos = dc.getTargetCoord(pt.x, pt.y);
-
- var el = dc.getDragEl();
- var curRegion = new YAHOO.util.Region( pos.y,
- pos.x + el.offsetWidth,
- pos.y + el.offsetHeight,
- pos.x );
-
- var overlap = curRegion.intersect(loc);
-
- if (overlap) {
- oTarget.overlap = overlap;
- return (intersect) ? true : oTarget.cursorIsOver;
- } else {
- return false;
- }
- },
-
- /**
- * unload event handler
- * @method _onUnload
- * @private
- * @static
- */
- _onUnload: function(e, me) {
- this.unregAll();
- },
-
- /**
- * Cleans up the drag and drop events and objects.
- * @method unregAll
- * @private
- * @static
- */
- unregAll: function() {
-
- if (this.dragCurrent) {
- this.stopDrag();
- this.dragCurrent = null;
- }
-
- this._execOnAll("unreg", []);
-
- for (i in this.elementCache) {
- delete this.elementCache[i];
- }
-
- this.elementCache = {};
- this.ids = {};
- },
-
- /**
- * A cache of DOM elements
- * @property elementCache
- * @private
- * @static
- */
- elementCache: {},
-
- /**
- * Get the wrapper for the DOM element specified
- * @method getElWrapper
- * @param {String} id the id of the element to get
- * @return {YAHOO.util.DDM.ElementWrapper} the wrapped element
- * @private
- * @deprecated This wrapper isn't that useful
- * @static
- */
- getElWrapper: function(id) {
- var oWrapper = this.elementCache[id];
- if (!oWrapper || !oWrapper.el) {
- oWrapper = this.elementCache[id] =
- new this.ElementWrapper(YAHOO.util.Dom.get(id));
- }
- return oWrapper;
- },
-
- /**
- * Returns the actual DOM element
- * @method getElement
- * @param {String} id the id of the elment to get
- * @return {Object} The element
- * @deprecated use YAHOO.util.Dom.get instead
- * @static
- */
- getElement: function(id) {
- return YAHOO.util.Dom.get(id);
- },
-
- /**
- * Returns the style property for the DOM element (i.e.,
- * document.getElById(id).style)
- * @method getCss
- * @param {String} id the id of the elment to get
- * @return {Object} The style property of the element
- * @deprecated use YAHOO.util.Dom instead
- * @static
- */
- getCss: function(id) {
- var el = YAHOO.util.Dom.get(id);
- return (el) ? el.style : null;
- },
-
- /**
- * Inner class for cached elements
- * @class DragDropMgr.ElementWrapper
- * @for DragDropMgr
- * @private
- * @deprecated
- */
- ElementWrapper: function(el) {
- /**
- * The element
- * @property el
- */
- this.el = el || null;
- /**
- * The element id
- * @property id
- */
- this.id = this.el && el.id;
- /**
- * A reference to the style property
- * @property css
- */
- this.css = this.el && el.style;
- },
-
- /**
- * Returns the X position of an html element
- * @method getPosX
- * @param el the element for which to get the position
- * @return {int} the X coordinate
- * @for DragDropMgr
- * @deprecated use YAHOO.util.Dom.getX instead
- * @static
- */
- getPosX: function(el) {
- return YAHOO.util.Dom.getX(el);
- },
-
- /**
- * Returns the Y position of an html element
- * @method getPosY
- * @param el the element for which to get the position
- * @return {int} the Y coordinate
- * @deprecated use YAHOO.util.Dom.getY instead
- * @static
- */
- getPosY: function(el) {
- return YAHOO.util.Dom.getY(el);
- },
-
- /**
- * Swap two nodes. In IE, we use the native method, for others we
- * emulate the IE behavior
- * @method swapNode
- * @param n1 the first node to swap
- * @param n2 the other node to swap
- * @static
- */
- swapNode: function(n1, n2) {
- if (n1.swapNode) {
- n1.swapNode(n2);
- } else {
- var p = n2.parentNode;
- var s = n2.nextSibling;
-
- if (s == n1) {
- p.insertBefore(n1, n2);
- } else if (n2 == n1.nextSibling) {
- p.insertBefore(n2, n1);
- } else {
- n1.parentNode.replaceChild(n2, n1);
- p.insertBefore(n1, s);
- }
- }
- },
-
- /**
- * Returns the current scroll position
- * @method getScroll
- * @private
- * @static
- */
- getScroll: function () {
- var t, l, dde=document.documentElement, db=document.body;
- if (dde && (dde.scrollTop || dde.scrollLeft)) {
- t = dde.scrollTop;
- l = dde.scrollLeft;
- } else if (db) {
- t = db.scrollTop;
- l = db.scrollLeft;
- } else {
- YAHOO.log("could not get scroll property");
- }
- return { top: t, left: l };
- },
-
- /**
- * Returns the specified element style property
- * @method getStyle
- * @param {HTMLElement} el the element
- * @param {string} styleProp the style property
- * @return {string} The value of the style property
- * @deprecated use YAHOO.util.Dom.getStyle
- * @static
- */
- getStyle: function(el, styleProp) {
- return YAHOO.util.Dom.getStyle(el, styleProp);
- },
-
- /**
- * Gets the scrollTop
- * @method getScrollTop
- * @return {int} the document's scrollTop
- * @static
- */
- getScrollTop: function () { return this.getScroll().top; },
-
- /**
- * Gets the scrollLeft
- * @method getScrollLeft
- * @return {int} the document's scrollTop
- * @static
- */
- getScrollLeft: function () { return this.getScroll().left; },
-
- /**
- * Sets the x/y position of an element to the location of the
- * target element.
- * @method moveToEl
- * @param {HTMLElement} moveEl The element to move
- * @param {HTMLElement} targetEl The position reference element
- * @static
- */
- moveToEl: function (moveEl, targetEl) {
- var aCoord = YAHOO.util.Dom.getXY(targetEl);
- YAHOO.util.Dom.setXY(moveEl, aCoord);
- },
-
- /**
- * Gets the client height
- * @method getClientHeight
- * @return {int} client height in px
- * @deprecated use YAHOO.util.Dom.getViewportHeight instead
- * @static
- */
- getClientHeight: function() {
- return YAHOO.util.Dom.getViewportHeight();
- },
-
- /**
- * Gets the client width
- * @method getClientWidth
- * @return {int} client width in px
- * @deprecated use YAHOO.util.Dom.getViewportWidth instead
- * @static
- */
- getClientWidth: function() {
- return YAHOO.util.Dom.getViewportWidth();
- },
-
- /**
- * Numeric array sort function
- * @method numericSort
- * @static
- */
- numericSort: function(a, b) { return (a - b); },
-
- /**
- * Internal counter
- * @property _timeoutCount
- * @private
- * @static
- */
- _timeoutCount: 0,
-
- /**
- * Trying to make the load order less important. Without this we get
- * an error if this file is loaded before the Event Utility.
- * @method _addListeners
- * @private
- * @static
- */
- _addListeners: function() {
- var DDM = YAHOO.util.DDM;
- if ( YAHOO.util.Event && document ) {
- DDM._onLoad();
- } else {
- if (DDM._timeoutCount > 2000) {
- } else {
- setTimeout(DDM._addListeners, 10);
- if (document && document.body) {
- DDM._timeoutCount += 1;
- }
- }
- }
- },
-
- /**
- * Recursively searches the immediate parent and all child nodes for
- * the handle element in order to determine wheter or not it was
- * clicked.
- * @method handleWasClicked
- * @param node the html element to inspect
- * @static
- */
- handleWasClicked: function(node, id) {
- if (this.isHandle(id, node.id)) {
- return true;
- } else {
- // check to see if this is a text node child of the one we want
- var p = node.parentNode;
-
- while (p) {
- if (this.isHandle(id, p.id)) {
- return true;
- } else {
- p = p.parentNode;
- }
- }
- }
-
- return false;
- }
-
- };
-
-}();
-
-// shorter alias, save a few bytes
-YAHOO.util.DDM = YAHOO.util.DragDropMgr;
-YAHOO.util.DDM._addListeners();
-
-}
-
-/**
- * A DragDrop implementation where the linked element follows the
- * mouse cursor during a drag.
- * @class DD
- * @extends YAHOO.util.DragDrop
- * @constructor
- * @param {String} id the id of the linked element
- * @param {String} sGroup the group of related DragDrop items
- * @param {object} config an object containing configurable attributes
- * Valid properties for DD:
- * scroll
- */
-YAHOO.util.DD = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- }
-};
-
-YAHOO.extend(YAHOO.util.DD, YAHOO.util.DragDrop, {
-
- /**
- * When set to true, the utility automatically tries to scroll the browser
- * window wehn a drag and drop element is dragged near the viewport boundary.
- * Defaults to true.
- * @property scroll
- * @type boolean
- */
- scroll: true,
-
- /**
- * Sets the pointer offset to the distance between the linked element's top
- * left corner and the location the element was clicked
- * @method autoOffset
- * @param {int} iPageX the X coordinate of the click
- * @param {int} iPageY the Y coordinate of the click
- */
- autoOffset: function(iPageX, iPageY) {
- var x = iPageX - this.startPageX;
- var y = iPageY - this.startPageY;
- this.setDelta(x, y);
- },
-
- /**
- * Sets the pointer offset. You can call this directly to force the
- * offset to be in a particular location (e.g., pass in 0,0 to set it
- * to the center of the object, as done in YAHOO.widget.Slider)
- * @method setDelta
- * @param {int} iDeltaX the distance from the left
- * @param {int} iDeltaY the distance from the top
- */
- setDelta: function(iDeltaX, iDeltaY) {
- this.deltaX = iDeltaX;
- this.deltaY = iDeltaY;
- },
-
- /**
- * Sets the drag element to the location of the mousedown or click event,
- * maintaining the cursor location relative to the location on the element
- * that was clicked. Override this if you want to place the element in a
- * location other than where the cursor is.
- * @method setDragElPos
- * @param {int} iPageX the X coordinate of the mousedown or drag event
- * @param {int} iPageY the Y coordinate of the mousedown or drag event
- */
- setDragElPos: function(iPageX, iPageY) {
- // the first time we do this, we are going to check to make sure
- // the element has css positioning
-
- var el = this.getDragEl();
- this.alignElWithMouse(el, iPageX, iPageY);
- },
-
- /**
- * Sets the element to the location of the mousedown or click event,
- * maintaining the cursor location relative to the location on the element
- * that was clicked. Override this if you want to place the element in a
- * location other than where the cursor is.
- * @method alignElWithMouse
- * @param {HTMLElement} el the element to move
- * @param {int} iPageX the X coordinate of the mousedown or drag event
- * @param {int} iPageY the Y coordinate of the mousedown or drag event
- */
- alignElWithMouse: function(el, iPageX, iPageY) {
- var oCoord = this.getTargetCoord(iPageX, iPageY);
-
- if (!this.deltaSetXY) {
- var aCoord = [oCoord.x, oCoord.y];
- YAHOO.util.Dom.setXY(el, aCoord);
- var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
- var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
-
- this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
- } else {
- YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px");
- YAHOO.util.Dom.setStyle(el, "top", (oCoord.y + this.deltaSetXY[1]) + "px");
- }
-
- this.cachePosition(oCoord.x, oCoord.y);
- this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
- },
-
- /**
- * Saves the most recent position so that we can reset the constraints and
- * tick marks on-demand. We need to know this so that we can calculate the
- * number of pixels the element is offset from its original position.
- * @method cachePosition
- * @param iPageX the current x position (optional, this just makes it so we
- * don't have to look it up again)
- * @param iPageY the current y position (optional, this just makes it so we
- * don't have to look it up again)
- */
- cachePosition: function(iPageX, iPageY) {
- if (iPageX) {
- this.lastPageX = iPageX;
- this.lastPageY = iPageY;
- } else {
- var aCoord = YAHOO.util.Dom.getXY(this.getEl());
- this.lastPageX = aCoord[0];
- this.lastPageY = aCoord[1];
- }
- },
-
- /**
- * Auto-scroll the window if the dragged object has been moved beyond the
- * visible window boundary.
- * @method autoScroll
- * @param {int} x the drag element's x position
- * @param {int} y the drag element's y position
- * @param {int} h the height of the drag element
- * @param {int} w the width of the drag element
- * @private
- */
- autoScroll: function(x, y, h, w) {
-
- if (this.scroll) {
- // The client height
- var clientH = this.DDM.getClientHeight();
-
- // The client width
- var clientW = this.DDM.getClientWidth();
-
- // The amt scrolled down
- var st = this.DDM.getScrollTop();
-
- // The amt scrolled right
- var sl = this.DDM.getScrollLeft();
-
- // Location of the bottom of the element
- var bot = h + y;
-
- // Location of the right of the element
- var right = w + x;
-
- // The distance from the cursor to the bottom of the visible area,
- // adjusted so that we don't scroll if the cursor is beyond the
- // element drag constraints
- var toBot = (clientH + st - y - this.deltaY);
-
- // The distance from the cursor to the right of the visible area
- var toRight = (clientW + sl - x - this.deltaX);
-
-
- // How close to the edge the cursor must be before we scroll
- // var thresh = (document.all) ? 100 : 40;
- var thresh = 40;
-
- // How many pixels to scroll per autoscroll op. This helps to reduce
- // clunky scrolling. IE is more sensitive about this ... it needs this
- // value to be higher.
- var scrAmt = (document.all) ? 80 : 30;
-
- // Scroll down if we are near the bottom of the visible page and the
- // obj extends below the crease
- if ( bot > clientH && toBot < thresh ) {
- window.scrollTo(sl, st + scrAmt);
- }
-
- // Scroll up if the window is scrolled down and the top of the object
- // goes above the top border
- if ( y < st && st > 0 && y - st < thresh ) {
- window.scrollTo(sl, st - scrAmt);
- }
-
- // Scroll right if the obj is beyond the right border and the cursor is
- // near the border.
- if ( right > clientW && toRight < thresh ) {
- window.scrollTo(sl + scrAmt, st);
- }
-
- // Scroll left if the window has been scrolled to the right and the obj
- // extends past the left border
- if ( x < sl && sl > 0 && x - sl < thresh ) {
- window.scrollTo(sl - scrAmt, st);
- }
- }
- },
-
- /**
- * Finds the location the element should be placed if we want to move
- * it to where the mouse location less the click offset would place us.
- * @method getTargetCoord
- * @param {int} iPageX the X coordinate of the click
- * @param {int} iPageY the Y coordinate of the click
- * @return an object that contains the coordinates (Object.x and Object.y)
- * @private
- */
- getTargetCoord: function(iPageX, iPageY) {
-
-
- var x = iPageX - this.deltaX;
- var y = iPageY - this.deltaY;
-
- if (this.constrainX) {
- if (x < this.minX) { x = this.minX; }
- if (x > this.maxX) { x = this.maxX; }
- }
-
- if (this.constrainY) {
- if (y < this.minY) { y = this.minY; }
- if (y > this.maxY) { y = this.maxY; }
- }
-
- x = this.getTick(x, this.xTicks);
- y = this.getTick(y, this.yTicks);
-
-
- return {x:x, y:y};
- },
-
- /*
- * Sets up config options specific to this class. Overrides
- * YAHOO.util.DragDrop, but all versions of this method through the
- * inheritance chain are called
- */
- applyConfig: function() {
- YAHOO.util.DD.superclass.applyConfig.call(this);
- this.scroll = (this.config.scroll !== false);
- },
-
- /*
- * Event that fires prior to the onMouseDown event. Overrides
- * YAHOO.util.DragDrop.
- */
- b4MouseDown: function(e) {
- // this.resetConstraints();
- this.autoOffset(YAHOO.util.Event.getPageX(e),
- YAHOO.util.Event.getPageY(e));
- },
-
- /*
- * Event that fires prior to the onDrag event. Overrides
- * YAHOO.util.DragDrop.
- */
- b4Drag: function(e) {
- this.setDragElPos(YAHOO.util.Event.getPageX(e),
- YAHOO.util.Event.getPageY(e));
- },
-
- toString: function() {
- return ("DD " + this.id);
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Debugging ygDragDrop events that can be overridden
- //////////////////////////////////////////////////////////////////////////
- /*
- startDrag: function(x, y) {
- },
-
- onDrag: function(e) {
- },
-
- onDragEnter: function(e, id) {
- },
-
- onDragOver: function(e, id) {
- },
-
- onDragOut: function(e, id) {
- },
-
- onDragDrop: function(e, id) {
- },
-
- endDrag: function(e) {
- }
-
- */
-
-});
-/**
- * A DragDrop implementation that inserts an empty, bordered div into
- * the document that follows the cursor during drag operations. At the time of
- * the click, the frame div is resized to the dimensions of the linked html
- * element, and moved to the exact location of the linked element.
- *
- * References to the "frame" element refer to the single proxy element that
- * was created to be dragged in place of all DDProxy elements on the
- * page.
- *
- * @class DDProxy
- * @extends YAHOO.util.DD
- * @constructor
- * @param {String} id the id of the linked html element
- * @param {String} sGroup the group of related DragDrop objects
- * @param {object} config an object containing configurable attributes
- * Valid properties for DDProxy in addition to those in DragDrop:
- * resizeFrame, centerFrame, dragElId
- */
-YAHOO.util.DDProxy = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- this.initFrame();
- }
-};
-
-/**
- * The default drag frame div id
- * @property YAHOO.util.DDProxy.dragElId
- * @type String
- * @static
- */
-YAHOO.util.DDProxy.dragElId = "ygddfdiv";
-
-YAHOO.extend(YAHOO.util.DDProxy, YAHOO.util.DD, {
-
- /**
- * By default we resize the drag frame to be the same size as the element
- * we want to drag (this is to get the frame effect). We can turn it off
- * if we want a different behavior.
- * @property resizeFrame
- * @type boolean
- */
- resizeFrame: true,
-
- /**
- * By default the frame is positioned exactly where the drag element is, so
- * we use the cursor offset provided by YAHOO.util.DD. Another option that works only if
- * you do not have constraints on the obj is to have the drag frame centered
- * around the cursor. Set centerFrame to true for this effect.
- * @property centerFrame
- * @type boolean
- */
- centerFrame: false,
-
- /**
- * Creates the proxy element if it does not yet exist
- * @method createFrame
- */
- createFrame: function() {
- var self = this;
- var body = document.body;
-
- if (!body || !body.firstChild) {
- setTimeout( function() { self.createFrame(); }, 50 );
- return;
- }
-
- var div = this.getDragEl();
-
- if (!div) {
- div = document.createElement("div");
- div.id = this.dragElId;
- var s = div.style;
-
- s.position = "absolute";
- s.visibility = "hidden";
- s.cursor = "move";
- s.border = "2px solid #aaa";
- s.zIndex = 999;
-
- // appendChild can blow up IE if invoked prior to the window load event
- // while rendering a table. It is possible there are other scenarios
- // that would cause this to happen as well.
- body.insertBefore(div, body.firstChild);
- }
- },
-
- /**
- * Initialization for the drag frame element. Must be called in the
- * constructor of all subclasses
- * @method initFrame
- */
- initFrame: function() {
- this.createFrame();
- },
-
- applyConfig: function() {
- YAHOO.util.DDProxy.superclass.applyConfig.call(this);
-
- this.resizeFrame = (this.config.resizeFrame !== false);
- this.centerFrame = (this.config.centerFrame);
- this.setDragElId(this.config.dragElId || YAHOO.util.DDProxy.dragElId);
- },
-
- /**
- * Resizes the drag frame to the dimensions of the clicked object, positions
- * it over the object, and finally displays it
- * @method showFrame
- * @param {int} iPageX X click position
- * @param {int} iPageY Y click position
- * @private
- */
- showFrame: function(iPageX, iPageY) {
- var el = this.getEl();
- var dragEl = this.getDragEl();
- var s = dragEl.style;
-
- this._resizeProxy();
-
- if (this.centerFrame) {
- this.setDelta( Math.round(parseInt(s.width, 10)/2),
- Math.round(parseInt(s.height, 10)/2) );
- }
-
- this.setDragElPos(iPageX, iPageY);
-
- YAHOO.util.Dom.setStyle(dragEl, "visibility", "visible");
- },
-
- /**
- * The proxy is automatically resized to the dimensions of the linked
- * element when a drag is initiated, unless resizeFrame is set to false
- * @method _resizeProxy
- * @private
- */
- _resizeProxy: function() {
- if (this.resizeFrame) {
- var DOM = YAHOO.util.Dom;
- var el = this.getEl();
- var dragEl = this.getDragEl();
-
- var bt = parseInt( DOM.getStyle(dragEl, "borderTopWidth" ), 10);
- var br = parseInt( DOM.getStyle(dragEl, "borderRightWidth" ), 10);
- var bb = parseInt( DOM.getStyle(dragEl, "borderBottomWidth" ), 10);
- var bl = parseInt( DOM.getStyle(dragEl, "borderLeftWidth" ), 10);
-
- if (isNaN(bt)) { bt = 0; }
- if (isNaN(br)) { br = 0; }
- if (isNaN(bb)) { bb = 0; }
- if (isNaN(bl)) { bl = 0; }
-
-
- var newWidth = Math.max(0, el.offsetWidth - br - bl);
- var newHeight = Math.max(0, el.offsetHeight - bt - bb);
-
-
- DOM.setStyle( dragEl, "width", newWidth + "px" );
- DOM.setStyle( dragEl, "height", newHeight + "px" );
- }
- },
-
- // overrides YAHOO.util.DragDrop
- b4MouseDown: function(e) {
- var x = YAHOO.util.Event.getPageX(e);
- var y = YAHOO.util.Event.getPageY(e);
- this.autoOffset(x, y);
- this.setDragElPos(x, y);
- },
-
- // overrides YAHOO.util.DragDrop
- b4StartDrag: function(x, y) {
- // show the drag frame
- this.showFrame(x, y);
- },
-
- // overrides YAHOO.util.DragDrop
- b4EndDrag: function(e) {
- YAHOO.util.Dom.setStyle(this.getDragEl(), "visibility", "hidden");
- },
-
- // overrides YAHOO.util.DragDrop
- // By default we try to move the element to the last location of the frame.
- // This is so that the default behavior mirrors that of YAHOO.util.DD.
- endDrag: function(e) {
- var DOM = YAHOO.util.Dom;
- var lel = this.getEl();
- var del = this.getDragEl();
-
- // Show the drag frame briefly so we can get its position
- // del.style.visibility = "";
- DOM.setStyle(del, "visibility", "");
-
- // Hide the linked element before the move to get around a Safari
- // rendering bug.
- //lel.style.visibility = "hidden";
- DOM.setStyle(lel, "visibility", "hidden");
- YAHOO.util.DDM.moveToEl(lel, del);
- //del.style.visibility = "hidden";
- DOM.setStyle(del, "visibility", "hidden");
- //lel.style.visibility = "";
- DOM.setStyle(lel, "visibility", "");
- },
-
- toString: function() {
- return ("DDProxy " + this.id);
- }
-
-});
-/**
- * A DragDrop implementation that does not move, but can be a drop
- * target. You would get the same result by simply omitting implementation
- * for the event callbacks, but this way we reduce the processing cost of the
- * event listener and the callbacks.
- * @class DDTarget
- * @extends YAHOO.util.DragDrop
- * @constructor
- * @param {String} id the id of the element that is a drop target
- * @param {String} sGroup the group of related DragDrop objects
- * @param {object} config an object containing configurable attributes
- * Valid properties for DDTarget in addition to those in
- * DragDrop:
- * none
- */
-YAHOO.util.DDTarget = function(id, sGroup, config) {
- if (id) {
- this.initTarget(id, sGroup, config);
- }
-};
-
-// YAHOO.util.DDTarget.prototype = new YAHOO.util.DragDrop();
-YAHOO.extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop, {
- toString: function() {
- return ("DDTarget " + this.id);
- }
-});
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+(function() {
+
+var Event=YAHOO.util.Event;
+var Dom=YAHOO.util.Dom;
+
+/**
+ * Defines the interface and base operation of items that that can be
+ * dragged or can be drop targets. It was designed to be extended, overriding
+ * the event handlers for startDrag, onDrag, onDragOver, onDragOut.
+ * Up to three html elements can be associated with a DragDrop instance:
+ *
+ * linked element: the element that is passed into the constructor.
+ * This is the element which defines the boundaries for interaction with
+ * other DragDrop objects.
+ * handle element(s): The drag operation only occurs if the element that
+ * was clicked matches a handle element. By default this is the linked
+ * element, but there are times that you will want only a portion of the
+ * linked element to initiate the drag operation, and the setHandleElId()
+ * method provides a way to define this.
+ * drag element: this represents an the element that would be moved along
+ * with the cursor during a drag operation. By default, this is the linked
+ * element itself as in {@link YAHOO.util.DD}. setDragElId() lets you define
+ * a separate element that would be moved, as in {@link YAHOO.util.DDProxy}
+ *
+ *
+ * This class should not be instantiated until the onload event to ensure that
+ * the associated elements are available.
+ * The following would define a DragDrop obj that would interact with any
+ * other DragDrop obj in the "group1" group:
+ *
+ * dd = new YAHOO.util.DragDrop("div1", "group1");
+ *
+ * Since none of the event handlers have been implemented, nothing would
+ * actually happen if you were to run the code above. Normally you would
+ * override this class or one of the default implementations, but you can
+ * also override the methods you want on an instance of the class...
+ *
+ * dd.onDragDrop = function(e, id) {
+ * alert("dd was dropped on " + id);
+ * }
+ *
+ * @namespace YAHOO.util
+ * @class DragDrop
+ * @constructor
+ * @param {String} id of the element that is linked to this instance
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DragDrop:
+ * padding, isTarget, maintainOffset, primaryButtonOnly,
+ */
+YAHOO.util.DragDrop = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+YAHOO.util.DragDrop.prototype = {
+
+ /**
+ * The id of the element associated with this object. This is what we
+ * refer to as the "linked element" because the size and position of
+ * this element is used to determine when the drag and drop objects have
+ * interacted.
+ * @property id
+ * @type String
+ */
+ id: null,
+
+ /**
+ * Configuration attributes passed into the constructor
+ * @property config
+ * @type object
+ */
+ config: null,
+
+ /**
+ * The id of the element that will be dragged. By default this is same
+ * as the linked element , but could be changed to another element. Ex:
+ * YAHOO.util.DDProxy
+ * @property dragElId
+ * @type String
+ * @private
+ */
+ dragElId: null,
+
+ /**
+ * the id of the element that initiates the drag operation. By default
+ * this is the linked element, but could be changed to be a child of this
+ * element. This lets us do things like only starting the drag when the
+ * header element within the linked html element is clicked.
+ * @property handleElId
+ * @type String
+ * @private
+ */
+ handleElId: null,
+
+ /**
+ * An associative array of HTML tags that will be ignored if clicked.
+ * @property invalidHandleTypes
+ * @type {string: string}
+ */
+ invalidHandleTypes: null,
+
+ /**
+ * An associative array of ids for elements that will be ignored if clicked
+ * @property invalidHandleIds
+ * @type {string: string}
+ */
+ invalidHandleIds: null,
+
+ /**
+ * An indexted array of css class names for elements that will be ignored
+ * if clicked.
+ * @property invalidHandleClasses
+ * @type string[]
+ */
+ invalidHandleClasses: null,
+
+ /**
+ * The linked element's absolute X position at the time the drag was
+ * started
+ * @property startPageX
+ * @type int
+ * @private
+ */
+ startPageX: 0,
+
+ /**
+ * The linked element's absolute X position at the time the drag was
+ * started
+ * @property startPageY
+ * @type int
+ * @private
+ */
+ startPageY: 0,
+
+ /**
+ * The group defines a logical collection of DragDrop objects that are
+ * related. Instances only get events when interacting with other
+ * DragDrop object in the same group. This lets us define multiple
+ * groups using a single DragDrop subclass if we want.
+ * @property groups
+ * @type {string: string}
+ */
+ groups: null,
+
+ /**
+ * Individual drag/drop instances can be locked. This will prevent
+ * onmousedown start drag.
+ * @property locked
+ * @type boolean
+ * @private
+ */
+ locked: false,
+
+ /**
+ * Lock this instance
+ * @method lock
+ */
+ lock: function() { this.locked = true; },
+
+ /**
+ * Unlock this instace
+ * @method unlock
+ */
+ unlock: function() { this.locked = false; },
+
+ /**
+ * By default, all insances can be a drop target. This can be disabled by
+ * setting isTarget to false.
+ * @method isTarget
+ * @type boolean
+ */
+ isTarget: true,
+
+ /**
+ * The padding configured for this drag and drop object for calculating
+ * the drop zone intersection with this object.
+ * @method padding
+ * @type int[]
+ */
+ padding: null,
+
+ /**
+ * Cached reference to the linked element
+ * @property _domRef
+ * @private
+ */
+ _domRef: null,
+
+ /**
+ * Internal typeof flag
+ * @property __ygDragDrop
+ * @private
+ */
+ __ygDragDrop: true,
+
+ /**
+ * Set to true when horizontal contraints are applied
+ * @property constrainX
+ * @type boolean
+ * @private
+ */
+ constrainX: false,
+
+ /**
+ * Set to true when vertical contraints are applied
+ * @property constrainY
+ * @type boolean
+ * @private
+ */
+ constrainY: false,
+
+ /**
+ * The left constraint
+ * @property minX
+ * @type int
+ * @private
+ */
+ minX: 0,
+
+ /**
+ * The right constraint
+ * @property maxX
+ * @type int
+ * @private
+ */
+ maxX: 0,
+
+ /**
+ * The up constraint
+ * @property minY
+ * @type int
+ * @type int
+ * @private
+ */
+ minY: 0,
+
+ /**
+ * The down constraint
+ * @property maxY
+ * @type int
+ * @private
+ */
+ maxY: 0,
+
+ /**
+ * Maintain offsets when we resetconstraints. Set to true when you want
+ * the position of the element relative to its parent to stay the same
+ * when the page changes
+ *
+ * @property maintainOffset
+ * @type boolean
+ */
+ maintainOffset: false,
+
+ /**
+ * Array of pixel locations the element will snap to if we specified a
+ * horizontal graduation/interval. This array is generated automatically
+ * when you define a tick interval.
+ * @property xTicks
+ * @type int[]
+ */
+ xTicks: null,
+
+ /**
+ * Array of pixel locations the element will snap to if we specified a
+ * vertical graduation/interval. This array is generated automatically
+ * when you define a tick interval.
+ * @property yTicks
+ * @type int[]
+ */
+ yTicks: null,
+
+ /**
+ * By default the drag and drop instance will only respond to the primary
+ * button click (left button for a right-handed mouse). Set to true to
+ * allow drag and drop to start with any mouse click that is propogated
+ * by the browser
+ * @property primaryButtonOnly
+ * @type boolean
+ */
+ primaryButtonOnly: true,
+
+ /**
+ * The availabe property is false until the linked dom element is accessible.
+ * @property available
+ * @type boolean
+ */
+ available: false,
+
+ /**
+ * By default, drags can only be initiated if the mousedown occurs in the
+ * region the linked element is. This is done in part to work around a
+ * bug in some browsers that mis-report the mousedown if the previous
+ * mouseup happened outside of the window. This property is set to true
+ * if outer handles are defined.
+ *
+ * @property hasOuterHandles
+ * @type boolean
+ * @default false
+ */
+ hasOuterHandles: false,
+
+ /**
+ * Code that executes immediately before the startDrag event
+ * @method b4StartDrag
+ * @private
+ */
+ b4StartDrag: function(x, y) { },
+
+ /**
+ * Abstract method called after a drag/drop object is clicked
+ * and the drag or mousedown time thresholds have beeen met.
+ * @method startDrag
+ * @param {int} X click location
+ * @param {int} Y click location
+ */
+ startDrag: function(x, y) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDrag event
+ * @method b4Drag
+ * @private
+ */
+ b4Drag: function(e) { },
+
+ /**
+ * Abstract method called during the onMouseMove event while dragging an
+ * object.
+ * @method onDrag
+ * @param {Event} e the mousemove event
+ */
+ onDrag: function(e) { /* override this */ },
+
+ /**
+ * Abstract method called when this element fist begins hovering over
+ * another DragDrop obj
+ * @method onDragEnter
+ * @param {Event} e the mousemove event
+ * @param {String|DragDrop[]} id In POINT mode, the element
+ * id this is hovering over. In INTERSECT mode, an array of one or more
+ * dragdrop items being hovered over.
+ */
+ onDragEnter: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragOver event
+ * @method b4DragOver
+ * @private
+ */
+ b4DragOver: function(e) { },
+
+ /**
+ * Abstract method called when this element is hovering over another
+ * DragDrop obj
+ * @method onDragOver
+ * @param {Event} e the mousemove event
+ * @param {String|DragDrop[]} id In POINT mode, the element
+ * id this is hovering over. In INTERSECT mode, an array of dd items
+ * being hovered over.
+ */
+ onDragOver: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragOut event
+ * @method b4DragOut
+ * @private
+ */
+ b4DragOut: function(e) { },
+
+ /**
+ * Abstract method called when we are no longer hovering over an element
+ * @method onDragOut
+ * @param {Event} e the mousemove event
+ * @param {String|DragDrop[]} id In POINT mode, the element
+ * id this was hovering over. In INTERSECT mode, an array of dd items
+ * that the mouse is no longer over.
+ */
+ onDragOut: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragDrop event
+ * @method b4DragDrop
+ * @private
+ */
+ b4DragDrop: function(e) { },
+
+ /**
+ * Abstract method called when this item is dropped on another DragDrop
+ * obj
+ * @method onDragDrop
+ * @param {Event} e the mouseup event
+ * @param {String|DragDrop[]} id In POINT mode, the element
+ * id this was dropped on. In INTERSECT mode, an array of dd items this
+ * was dropped on.
+ */
+ onDragDrop: function(e, id) { /* override this */ },
+
+ /**
+ * Abstract method called when this item is dropped on an area with no
+ * drop target
+ * @method onInvalidDrop
+ * @param {Event} e the mouseup event
+ */
+ onInvalidDrop: function(e) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the endDrag event
+ * @method b4EndDrag
+ * @private
+ */
+ b4EndDrag: function(e) { },
+
+ /**
+ * Fired when we are done dragging the object
+ * @method endDrag
+ * @param {Event} e the mouseup event
+ */
+ endDrag: function(e) { /* override this */ },
+
+ /**
+ * Code executed immediately before the onMouseDown event
+ * @method b4MouseDown
+ * @param {Event} e the mousedown event
+ * @private
+ */
+ b4MouseDown: function(e) { },
+
+ /**
+ * Event handler that fires when a drag/drop obj gets a mousedown
+ * @method onMouseDown
+ * @param {Event} e the mousedown event
+ */
+ onMouseDown: function(e) { /* override this */ },
+
+ /**
+ * Event handler that fires when a drag/drop obj gets a mouseup
+ * @method onMouseUp
+ * @param {Event} e the mouseup event
+ */
+ onMouseUp: function(e) { /* override this */ },
+
+ /**
+ * Override the onAvailable method to do what is needed after the initial
+ * position was determined.
+ * @method onAvailable
+ */
+ onAvailable: function () {
+ },
+
+ /**
+ * Returns a reference to the linked element
+ * @method getEl
+ * @return {HTMLElement} the html element
+ */
+ getEl: function() {
+ if (!this._domRef) {
+ this._domRef = Dom.get(this.id);
+ }
+
+ return this._domRef;
+ },
+
+ /**
+ * Returns a reference to the actual element to drag. By default this is
+ * the same as the html element, but it can be assigned to another
+ * element. An example of this can be found in YAHOO.util.DDProxy
+ * @method getDragEl
+ * @return {HTMLElement} the html element
+ */
+ getDragEl: function() {
+ return Dom.get(this.dragElId);
+ },
+
+ /**
+ * Sets up the DragDrop object. Must be called in the constructor of any
+ * YAHOO.util.DragDrop subclass
+ * @method init
+ * @param id the id of the linked element
+ * @param {String} sGroup the group of related items
+ * @param {object} config configuration attributes
+ */
+ init: function(id, sGroup, config) {
+ this.initTarget(id, sGroup, config);
+ Event.on(this.id, "mousedown", this.handleMouseDown, this, true);
+ // Event.on(this.id, "selectstart", Event.preventDefault);
+ },
+
+ /**
+ * Initializes Targeting functionality only... the object does not
+ * get a mousedown handler.
+ * @method initTarget
+ * @param id the id of the linked element
+ * @param {String} sGroup the group of related items
+ * @param {object} config configuration attributes
+ */
+ initTarget: function(id, sGroup, config) {
+
+ // configuration attributes
+ this.config = config || {};
+
+ // create a local reference to the drag and drop manager
+ this.DDM = YAHOO.util.DDM;
+ // initialize the groups array
+ this.groups = {};
+
+ // assume that we have an element reference instead of an id if the
+ // parameter is not a string
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+
+ // set the id
+ this.id = id;
+
+ // add to an interaction group
+ this.addToGroup((sGroup) ? sGroup : "default");
+
+ // We don't want to register this as the handle with the manager
+ // so we just set the id rather than calling the setter.
+ this.handleElId = id;
+
+ Event.onAvailable(id, this.handleOnAvailable, this, true);
+
+
+ // the linked element is the element that gets dragged by default
+ this.setDragElId(id);
+
+ // by default, clicked anchors will not start drag operations.
+ // @TODO what else should be here? Probably form fields.
+ this.invalidHandleTypes = { A: "A" };
+ this.invalidHandleIds = {};
+ this.invalidHandleClasses = [];
+
+ this.applyConfig();
+ },
+
+ /**
+ * Applies the configuration parameters that were passed into the constructor.
+ * This is supposed to happen at each level through the inheritance chain. So
+ * a DDProxy implentation will execute apply config on DDProxy, DD, and
+ * DragDrop in order to get all of the parameters that are available in
+ * each object.
+ * @method applyConfig
+ */
+ applyConfig: function() {
+
+ // configurable properties:
+ // padding, isTarget, maintainOffset, primaryButtonOnly
+ this.padding = this.config.padding || [0, 0, 0, 0];
+ this.isTarget = (this.config.isTarget !== false);
+ this.maintainOffset = (this.config.maintainOffset);
+ this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
+
+ },
+
+ /**
+ * Executed when the linked element is available
+ * @method handleOnAvailable
+ * @private
+ */
+ handleOnAvailable: function() {
+ this.available = true;
+ this.resetConstraints();
+ this.onAvailable();
+ },
+
+ /**
+ * Configures the padding for the target zone in px. Effectively expands
+ * (or reduces) the virtual object size for targeting calculations.
+ * Supports css-style shorthand; if only one parameter is passed, all sides
+ * will have that padding, and if only two are passed, the top and bottom
+ * will have the first param, the left and right the second.
+ * @method setPadding
+ * @param {int} iTop Top pad
+ * @param {int} iRight Right pad
+ * @param {int} iBot Bot pad
+ * @param {int} iLeft Left pad
+ */
+ setPadding: function(iTop, iRight, iBot, iLeft) {
+ // this.padding = [iLeft, iRight, iTop, iBot];
+ if (!iRight && 0 !== iRight) {
+ this.padding = [iTop, iTop, iTop, iTop];
+ } else if (!iBot && 0 !== iBot) {
+ this.padding = [iTop, iRight, iTop, iRight];
+ } else {
+ this.padding = [iTop, iRight, iBot, iLeft];
+ }
+ },
+
+ /**
+ * Stores the initial placement of the linked element.
+ * @method setInitialPosition
+ * @param {int} diffX the X offset, default 0
+ * @param {int} diffY the Y offset, default 0
+ */
+ setInitPosition: function(diffX, diffY) {
+ var el = this.getEl();
+
+ if (!this.DDM.verifyEl(el)) {
+ return;
+ }
+
+ var dx = diffX || 0;
+ var dy = diffY || 0;
+
+ var p = Dom.getXY( el );
+
+ this.initPageX = p[0] - dx;
+ this.initPageY = p[1] - dy;
+
+ this.lastPageX = p[0];
+ this.lastPageY = p[1];
+
+
+ this.setStartPosition(p);
+ },
+
+ /**
+ * Sets the start position of the element. This is set when the obj
+ * is initialized, the reset when a drag is started.
+ * @method setStartPosition
+ * @param pos current position (from previous lookup)
+ * @private
+ */
+ setStartPosition: function(pos) {
+ var p = pos || Dom.getXY( this.getEl() );
+
+ this.deltaSetXY = null;
+
+ this.startPageX = p[0];
+ this.startPageY = p[1];
+ },
+
+ /**
+ * Add this instance to a group of related drag/drop objects. All
+ * instances belong to at least one group, and can belong to as many
+ * groups as needed.
+ * @method addToGroup
+ * @param sGroup {string} the name of the group
+ */
+ addToGroup: function(sGroup) {
+ this.groups[sGroup] = true;
+ this.DDM.regDragDrop(this, sGroup);
+ },
+
+ /**
+ * Remove's this instance from the supplied interaction group
+ * @method removeFromGroup
+ * @param {string} sGroup The group to drop
+ */
+ removeFromGroup: function(sGroup) {
+ if (this.groups[sGroup]) {
+ delete this.groups[sGroup];
+ }
+
+ this.DDM.removeDDFromGroup(this, sGroup);
+ },
+
+ /**
+ * Allows you to specify that an element other than the linked element
+ * will be moved with the cursor during a drag
+ * @method setDragElId
+ * @param id {string} the id of the element that will be used to initiate the drag
+ */
+ setDragElId: function(id) {
+ this.dragElId = id;
+ },
+
+ /**
+ * Allows you to specify a child of the linked element that should be
+ * used to initiate the drag operation. An example of this would be if
+ * you have a content div with text and links. Clicking anywhere in the
+ * content area would normally start the drag operation. Use this method
+ * to specify that an element inside of the content div is the element
+ * that starts the drag operation.
+ * @method setHandleElId
+ * @param id {string} the id of the element that will be used to
+ * initiate the drag.
+ */
+ setHandleElId: function(id) {
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+ this.handleElId = id;
+ this.DDM.regHandle(this.id, id);
+ },
+
+ /**
+ * Allows you to set an element outside of the linked element as a drag
+ * handle
+ * @method setOuterHandleElId
+ * @param id the id of the element that will be used to initiate the drag
+ */
+ setOuterHandleElId: function(id) {
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+ Event.on(id, "mousedown",
+ this.handleMouseDown, this, true);
+ this.setHandleElId(id);
+
+ this.hasOuterHandles = true;
+ },
+
+ /**
+ * Remove all drag and drop hooks for this element
+ * @method unreg
+ */
+ unreg: function() {
+ Event.removeListener(this.id, "mousedown",
+ this.handleMouseDown);
+ this._domRef = null;
+ this.DDM._remove(this);
+ },
+
+ /**
+ * Returns true if this instance is locked, or the drag drop mgr is locked
+ * (meaning that all drag/drop is disabled on the page.)
+ * @method isLocked
+ * @return {boolean} true if this obj or all drag/drop is locked, else
+ * false
+ */
+ isLocked: function() {
+ return (this.DDM.isLocked() || this.locked);
+ },
+
+ /**
+ * Fired when this object is clicked
+ * @method handleMouseDown
+ * @param {Event} e
+ * @param {YAHOO.util.DragDrop} oDD the clicked dd object (this dd obj)
+ * @private
+ */
+ handleMouseDown: function(e, oDD) {
+
+ var button = e.which || e.button;
+
+ if (this.primaryButtonOnly && button > 1) {
+ return;
+ }
+
+ if (this.isLocked()) {
+ return;
+ }
+
+ this.DDM.refreshCache(this.groups);
+ // var self = this;
+ // setTimeout( function() { self.DDM.refreshCache(self.groups); }, 0);
+
+ // Only process the event if we really clicked within the linked
+ // element. The reason we make this check is that in the case that
+ // another element was moved between the clicked element and the
+ // cursor in the time between the mousedown and mouseup events. When
+ // this happens, the element gets the next mousedown event
+ // regardless of where on the screen it happened.
+ var pt = new YAHOO.util.Point(Event.getPageX(e), Event.getPageY(e));
+ if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
+ } else {
+ if (this.clickValidator(e)) {
+
+
+ // set the initial element position
+ this.setStartPosition();
+
+
+ this.b4MouseDown(e);
+ this.onMouseDown(e);
+ this.DDM.handleMouseDown(e, this);
+
+ this.DDM.stopEvent(e);
+ } else {
+
+
+ }
+ }
+ },
+
+ clickValidator: function(e) {
+ var target = Event.getTarget(e);
+ return ( this.isValidHandleChild(target) &&
+ (this.id == this.handleElId ||
+ this.DDM.handleWasClicked(target, this.id)) );
+ },
+
+ /**
+ * Allows you to specify a tag name that should not start a drag operation
+ * when clicked. This is designed to facilitate embedding links within a
+ * drag handle that do something other than start the drag.
+ * @method addInvalidHandleType
+ * @param {string} tagName the type of element to exclude
+ */
+ addInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+ this.invalidHandleTypes[type] = type;
+ },
+
+ /**
+ * Lets you to specify an element id for a child of a drag handle
+ * that should not initiate a drag
+ * @method addInvalidHandleId
+ * @param {string} id the element id of the element you wish to ignore
+ */
+ addInvalidHandleId: function(id) {
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+ this.invalidHandleIds[id] = id;
+ },
+
+ /**
+ * Lets you specify a css class of elements that will not initiate a drag
+ * @method addInvalidHandleClass
+ * @param {string} cssClass the class of the elements you wish to ignore
+ */
+ addInvalidHandleClass: function(cssClass) {
+ this.invalidHandleClasses.push(cssClass);
+ },
+
+ /**
+ * Unsets an excluded tag name set by addInvalidHandleType
+ * @method removeInvalidHandleType
+ * @param {string} tagName the type of element to unexclude
+ */
+ removeInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+ // this.invalidHandleTypes[type] = null;
+ delete this.invalidHandleTypes[type];
+ },
+
+ /**
+ * Unsets an invalid handle id
+ * @method removeInvalidHandleId
+ * @param {string} id the id of the element to re-enable
+ */
+ removeInvalidHandleId: function(id) {
+ if (typeof id !== "string") {
+ YAHOO.log("id is not a string, assuming it is an HTMLElement");
+ id = Dom.generateId(id);
+ }
+ delete this.invalidHandleIds[id];
+ },
+
+ /**
+ * Unsets an invalid css class
+ * @method removeInvalidHandleClass
+ * @param {string} cssClass the class of the element(s) you wish to
+ * re-enable
+ */
+ removeInvalidHandleClass: function(cssClass) {
+ for (var i=0, len=this.invalidHandleClasses.length; i= this.minX; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.xTicks.sort(this.DDM.numericSort) ;
+ },
+
+ /**
+ * Create the array of vertical tick marks if an interval was specified in
+ * setYConstraint().
+ * @method setYTicks
+ * @private
+ */
+ setYTicks: function(iStartY, iTickSize) {
+ this.yTicks = [];
+ this.yTickSize = iTickSize;
+
+ var tickMap = {};
+
+ for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.yTicks.sort(this.DDM.numericSort) ;
+ },
+
+ /**
+ * By default, the element can be dragged any place on the screen. Use
+ * this method to limit the horizontal travel of the element. Pass in
+ * 0,0 for the parameters if you want to lock the drag to the y axis.
+ * @method setXConstraint
+ * @param {int} iLeft the number of pixels the element can move to the left
+ * @param {int} iRight the number of pixels the element can move to the
+ * right
+ * @param {int} iTickSize optional parameter for specifying that the
+ * element
+ * should move iTickSize pixels at a time.
+ */
+ setXConstraint: function(iLeft, iRight, iTickSize) {
+ this.leftConstraint = iLeft;
+ this.rightConstraint = iRight;
+
+ this.minX = this.initPageX - iLeft;
+ this.maxX = this.initPageX + iRight;
+ if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
+
+ this.constrainX = true;
+ },
+
+ /**
+ * Clears any constraints applied to this instance. Also clears ticks
+ * since they can't exist independent of a constraint at this time.
+ * @method clearConstraints
+ */
+ clearConstraints: function() {
+ this.constrainX = false;
+ this.constrainY = false;
+ this.clearTicks();
+ },
+
+ /**
+ * Clears any tick interval defined for this instance
+ * @method clearTicks
+ */
+ clearTicks: function() {
+ this.xTicks = null;
+ this.yTicks = null;
+ this.xTickSize = 0;
+ this.yTickSize = 0;
+ },
+
+ /**
+ * By default, the element can be dragged any place on the screen. Set
+ * this to limit the vertical travel of the element. Pass in 0,0 for the
+ * parameters if you want to lock the drag to the x axis.
+ * @method setYConstraint
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the
+ * element should move iTickSize pixels at a time.
+ */
+ setYConstraint: function(iUp, iDown, iTickSize) {
+ this.topConstraint = iUp;
+ this.bottomConstraint = iDown;
+
+ this.minY = this.initPageY - iUp;
+ this.maxY = this.initPageY + iDown;
+ if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
+
+ this.constrainY = true;
+
+ },
+
+ /**
+ * resetConstraints must be called if you manually reposition a dd element.
+ * @method resetConstraints
+ * @param {boolean} maintainOffset
+ */
+ resetConstraints: function() {
+
+
+ // Maintain offsets if necessary
+ if (this.initPageX || this.initPageX === 0) {
+ // figure out how much this thing has moved
+ var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
+ var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
+
+ this.setInitPosition(dx, dy);
+
+ // This is the first time we have detected the element's position
+ } else {
+ this.setInitPosition();
+ }
+
+ if (this.constrainX) {
+ this.setXConstraint( this.leftConstraint,
+ this.rightConstraint,
+ this.xTickSize );
+ }
+
+ if (this.constrainY) {
+ this.setYConstraint( this.topConstraint,
+ this.bottomConstraint,
+ this.yTickSize );
+ }
+ },
+
+ /**
+ * Normally the drag element is moved pixel by pixel, but we can specify
+ * that it move a number of pixels at a time. This method resolves the
+ * location when we have it set up like this.
+ * @method getTick
+ * @param {int} val where we want to place the object
+ * @param {int[]} tickArray sorted array of valid points
+ * @return {int} the closest tick
+ * @private
+ */
+ getTick: function(val, tickArray) {
+
+ if (!tickArray) {
+ // If tick interval is not defined, it is effectively 1 pixel,
+ // so we return the value passed to us.
+ return val;
+ } else if (tickArray[0] >= val) {
+ // The value is lower than the first tick, so we return the first
+ // tick.
+ return tickArray[0];
+ } else {
+ for (var i=0, len=tickArray.length; i= val) {
+ var diff1 = val - tickArray[i];
+ var diff2 = tickArray[next] - val;
+ return (diff2 > diff1) ? tickArray[i] : tickArray[next];
+ }
+ }
+
+ // The value is larger than the last tick, so we return the last
+ // tick.
+ return tickArray[tickArray.length - 1];
+ }
+ },
+
+ /**
+ * toString method
+ * @method toString
+ * @return {string} string representation of the dd obj
+ */
+ toString: function() {
+ return ("DragDrop " + this.id);
+ }
+
+};
+
+})();
+/**
+ * The drag and drop utility provides a framework for building drag and drop
+ * applications. In addition to enabling drag and drop for specific elements,
+ * the drag and drop elements are tracked by the manager class, and the
+ * interactions between the various elements are tracked during the drag and
+ * the implementing code is notified about these important moments.
+ * @module dragdrop
+ * @title Drag and Drop
+ * @requires yahoo,dom,event
+ * @namespace YAHOO.util
+ */
+
+// Only load the library once. Rewriting the manager class would orphan
+// existing drag and drop instances.
+if (!YAHOO.util.DragDropMgr) {
+
+/**
+ * DragDropMgr is a singleton that tracks the element interaction for
+ * all DragDrop items in the window. Generally, you will not call
+ * this class directly, but it does have helper methods that could
+ * be useful in your DragDrop implementations.
+ * @class DragDropMgr
+ * @static
+ */
+YAHOO.util.DragDropMgr = function() {
+
+ var Event = YAHOO.util.Event;
+
+ return {
+
+ /**
+ * Two dimensional Array of registered DragDrop objects. The first
+ * dimension is the DragDrop item group, the second the DragDrop
+ * object.
+ * @property ids
+ * @type {string: string}
+ * @private
+ * @static
+ */
+ ids: {},
+
+ /**
+ * Array of element ids defined as drag handles. Used to determine
+ * if the element that generated the mousedown event is actually the
+ * handle and not the html element itself.
+ * @property handleIds
+ * @type {string: string}
+ * @private
+ * @static
+ */
+ handleIds: {},
+
+ /**
+ * the DragDrop object that is currently being dragged
+ * @property dragCurrent
+ * @type DragDrop
+ * @private
+ * @static
+ **/
+ dragCurrent: null,
+
+ /**
+ * the DragDrop object(s) that are being hovered over
+ * @property dragOvers
+ * @type Array
+ * @private
+ * @static
+ */
+ dragOvers: {},
+
+ /**
+ * the X distance between the cursor and the object being dragged
+ * @property deltaX
+ * @type int
+ * @private
+ * @static
+ */
+ deltaX: 0,
+
+ /**
+ * the Y distance between the cursor and the object being dragged
+ * @property deltaY
+ * @type int
+ * @private
+ * @static
+ */
+ deltaY: 0,
+
+ /**
+ * Flag to determine if we should prevent the default behavior of the
+ * events we define. By default this is true, but this can be set to
+ * false if you need the default behavior (not recommended)
+ * @property preventDefault
+ * @type boolean
+ * @static
+ */
+ preventDefault: true,
+
+ /**
+ * Flag to determine if we should stop the propagation of the events
+ * we generate. This is true by default but you may want to set it to
+ * false if the html element contains other features that require the
+ * mouse click.
+ * @property stopPropagation
+ * @type boolean
+ * @static
+ */
+ stopPropagation: true,
+
+ /**
+ * Internal flag that is set to true when drag and drop has been
+ * intialized
+ * @property initialized
+ * @private
+ * @static
+ */
+ initalized: false,
+
+ /**
+ * All drag and drop can be disabled.
+ * @property locked
+ * @private
+ * @static
+ */
+ locked: false,
+
+ /**
+ * Called the first time an element is registered.
+ * @method init
+ * @private
+ * @static
+ */
+ init: function() {
+ this.initialized = true;
+ },
+
+ /**
+ * In point mode, drag and drop interaction is defined by the
+ * location of the cursor during the drag/drop
+ * @property POINT
+ * @type int
+ * @static
+ * @final
+ */
+ POINT: 0,
+
+ /**
+ * In intersect mode, drag and drop interaction is defined by the
+ * cursor position or the amount of overlap of two or more drag and
+ * drop objects.
+ * @property INTERSECT
+ * @type int
+ * @static
+ * @final
+ */
+ INTERSECT: 1,
+
+ /**
+ * In intersect mode, drag and drop interaction is defined only by the
+ * overlap of two or more drag and drop objects.
+ * @property STRICT_INTERSECT
+ * @type int
+ * @static
+ * @final
+ */
+ STRICT_INTERSECT: 2,
+
+ /**
+ * The current drag and drop mode. Default: POINT
+ * @property mode
+ * @type int
+ * @static
+ */
+ mode: 0,
+
+ /**
+ * Runs method on all drag and drop objects
+ * @method _execOnAll
+ * @private
+ * @static
+ */
+ _execOnAll: function(sMethod, args) {
+ for (var i in this.ids) {
+ for (var j in this.ids[i]) {
+ var oDD = this.ids[i][j];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+ oDD[sMethod].apply(oDD, args);
+ }
+ }
+ },
+
+ /**
+ * Drag and drop initialization. Sets up the global event handlers
+ * @method _onLoad
+ * @private
+ * @static
+ */
+ _onLoad: function() {
+
+ this.init();
+
+
+ Event.on(document, "mouseup", this.handleMouseUp, this, true);
+ Event.on(document, "mousemove", this.handleMouseMove, this, true);
+ Event.on(window, "unload", this._onUnload, this, true);
+ Event.on(window, "resize", this._onResize, this, true);
+ // Event.on(window, "mouseout", this._test);
+
+ },
+
+ /**
+ * Reset constraints on all drag and drop objs
+ * @method _onResize
+ * @private
+ * @static
+ */
+ _onResize: function(e) {
+ this._execOnAll("resetConstraints", []);
+ },
+
+ /**
+ * Lock all drag and drop functionality
+ * @method lock
+ * @static
+ */
+ lock: function() { this.locked = true; },
+
+ /**
+ * Unlock all drag and drop functionality
+ * @method unlock
+ * @static
+ */
+ unlock: function() { this.locked = false; },
+
+ /**
+ * Is drag and drop locked?
+ * @method isLocked
+ * @return {boolean} True if drag and drop is locked, false otherwise.
+ * @static
+ */
+ isLocked: function() { return this.locked; },
+
+ /**
+ * Location cache that is set for all drag drop objects when a drag is
+ * initiated, cleared when the drag is finished.
+ * @property locationCache
+ * @private
+ * @static
+ */
+ locationCache: {},
+
+ /**
+ * Set useCache to false if you want to force object the lookup of each
+ * drag and drop linked element constantly during a drag.
+ * @property useCache
+ * @type boolean
+ * @static
+ */
+ useCache: true,
+
+ /**
+ * The number of pixels that the mouse needs to move after the
+ * mousedown before the drag is initiated. Default=3;
+ * @property clickPixelThresh
+ * @type int
+ * @static
+ */
+ clickPixelThresh: 3,
+
+ /**
+ * The number of milliseconds after the mousedown event to initiate the
+ * drag if we don't get a mouseup event. Default=1000
+ * @property clickTimeThresh
+ * @type int
+ * @static
+ */
+ clickTimeThresh: 1000,
+
+ /**
+ * Flag that indicates that either the drag pixel threshold or the
+ * mousdown time threshold has been met
+ * @property dragThreshMet
+ * @type boolean
+ * @private
+ * @static
+ */
+ dragThreshMet: false,
+
+ /**
+ * Timeout used for the click time threshold
+ * @property clickTimeout
+ * @type Object
+ * @private
+ * @static
+ */
+ clickTimeout: null,
+
+ /**
+ * The X position of the mousedown event stored for later use when a
+ * drag threshold is met.
+ * @property startX
+ * @type int
+ * @private
+ * @static
+ */
+ startX: 0,
+
+ /**
+ * The Y position of the mousedown event stored for later use when a
+ * drag threshold is met.
+ * @property startY
+ * @type int
+ * @private
+ * @static
+ */
+ startY: 0,
+
+ /**
+ * Each DragDrop instance must be registered with the DragDropMgr.
+ * This is executed in DragDrop.init()
+ * @method regDragDrop
+ * @param {DragDrop} oDD the DragDrop object to register
+ * @param {String} sGroup the name of the group this element belongs to
+ * @static
+ */
+ regDragDrop: function(oDD, sGroup) {
+ if (!this.initialized) { this.init(); }
+
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+ this.ids[sGroup][oDD.id] = oDD;
+ },
+
+ /**
+ * Removes the supplied dd instance from the supplied group. Executed
+ * by DragDrop.removeFromGroup, so don't call this function directly.
+ * @method removeDDFromGroup
+ * @private
+ * @static
+ */
+ removeDDFromGroup: function(oDD, sGroup) {
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+
+ var obj = this.ids[sGroup];
+ if (obj && obj[oDD.id]) {
+ delete obj[oDD.id];
+ }
+ },
+
+ /**
+ * Unregisters a drag and drop item. This is executed in
+ * DragDrop.unreg, use that method instead of calling this directly.
+ * @method _remove
+ * @private
+ * @static
+ */
+ _remove: function(oDD) {
+ for (var g in oDD.groups) {
+ if (g && this.ids[g][oDD.id]) {
+ delete this.ids[g][oDD.id];
+ }
+ }
+ delete this.handleIds[oDD.id];
+ },
+
+ /**
+ * Each DragDrop handle element must be registered. This is done
+ * automatically when executing DragDrop.setHandleElId()
+ * @method regHandle
+ * @param {String} sDDId the DragDrop id this element is a handle for
+ * @param {String} sHandleId the id of the element that is the drag
+ * handle
+ * @static
+ */
+ regHandle: function(sDDId, sHandleId) {
+ if (!this.handleIds[sDDId]) {
+ this.handleIds[sDDId] = {};
+ }
+ this.handleIds[sDDId][sHandleId] = sHandleId;
+ },
+
+ /**
+ * Utility function to determine if a given element has been
+ * registered as a drag drop item.
+ * @method isDragDrop
+ * @param {String} id the element id to check
+ * @return {boolean} true if this element is a DragDrop item,
+ * false otherwise
+ * @static
+ */
+ isDragDrop: function(id) {
+ return ( this.getDDById(id) ) ? true : false;
+ },
+
+ /**
+ * Returns the drag and drop instances that are in all groups the
+ * passed in instance belongs to.
+ * @method getRelated
+ * @param {DragDrop} p_oDD the obj to get related data for
+ * @param {boolean} bTargetsOnly if true, only return targetable objs
+ * @return {DragDrop[]} the related instances
+ * @static
+ */
+ getRelated: function(p_oDD, bTargetsOnly) {
+ var oDDs = [];
+ for (var i in p_oDD.groups) {
+ for (j in this.ids[i]) {
+ var dd = this.ids[i][j];
+ if (! this.isTypeOfDD(dd)) {
+ continue;
+ }
+ if (!bTargetsOnly || dd.isTarget) {
+ oDDs[oDDs.length] = dd;
+ }
+ }
+ }
+
+ return oDDs;
+ },
+
+ /**
+ * Returns true if the specified dd target is a legal target for
+ * the specifice drag obj
+ * @method isLegalTarget
+ * @param {DragDrop} the drag obj
+ * @param {DragDrop} the target
+ * @return {boolean} true if the target is a legal target for the
+ * dd obj
+ * @static
+ */
+ isLegalTarget: function (oDD, oTargetDD) {
+ var targets = this.getRelated(oDD, true);
+ for (var i=0, len=targets.length;i this.clickPixelThresh ||
+ diffY > this.clickPixelThresh) {
+ this.startDrag(this.startX, this.startY);
+ }
+ }
+
+ if (this.dragThreshMet) {
+ this.dragCurrent.b4Drag(e);
+ this.dragCurrent.onDrag(e);
+ this.fireEvents(e, false);
+ }
+
+ this.stopEvent(e);
+
+ return true;
+ },
+
+ /**
+ * Iterates over all of the DragDrop elements to find ones we are
+ * hovering over or dropping on
+ * @method fireEvents
+ * @param {Event} e the event
+ * @param {boolean} isDrop is this a drop op or a mouseover op?
+ * @private
+ * @static
+ */
+ fireEvents: function(e, isDrop) {
+ var dc = this.dragCurrent;
+
+ // If the user did the mouse up outside of the window, we could
+ // get here even though we have ended the drag.
+ if (!dc || dc.isLocked()) {
+ return;
+ }
+
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ var pt = new YAHOO.util.Point(x,y);
+
+ // cache the previous dragOver array
+ var oldOvers = [];
+
+ var outEvts = [];
+ var overEvts = [];
+ var dropEvts = [];
+ var enterEvts = [];
+
+ // Check to see if the object(s) we were hovering over is no longer
+ // being hovered over so we can fire the onDragOut event
+ for (var i in this.dragOvers) {
+
+ var ddo = this.dragOvers[i];
+
+ if (! this.isTypeOfDD(ddo)) {
+ continue;
+ }
+
+ if (! this.isOverTarget(pt, ddo, this.mode)) {
+ outEvts.push( ddo );
+ }
+
+ oldOvers[i] = true;
+ delete this.dragOvers[i];
+ }
+
+ for (var sGroup in dc.groups) {
+
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+
+ for (i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+
+ if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
+ if (this.isOverTarget(pt, oDD, this.mode)) {
+ // look for drop interactions
+ if (isDrop) {
+ dropEvts.push( oDD );
+ // look for drag enter and drag over interactions
+ } else {
+
+ // initial drag over: dragEnter fires
+ if (!oldOvers[oDD.id]) {
+ enterEvts.push( oDD );
+ // subsequent drag overs: dragOver fires
+ } else {
+ overEvts.push( oDD );
+ }
+
+ this.dragOvers[oDD.id] = oDD;
+ }
+ }
+ }
+ }
+ }
+
+ if (this.mode) {
+ if (outEvts.length) {
+ dc.b4DragOut(e, outEvts);
+ dc.onDragOut(e, outEvts);
+ }
+
+ if (enterEvts.length) {
+ dc.onDragEnter(e, enterEvts);
+ }
+
+ if (overEvts.length) {
+ dc.b4DragOver(e, overEvts);
+ dc.onDragOver(e, overEvts);
+ }
+
+ if (dropEvts.length) {
+ dc.b4DragDrop(e, dropEvts);
+ dc.onDragDrop(e, dropEvts);
+ }
+
+ } else {
+ // fire dragout events
+ var len = 0;
+ for (i=0, len=outEvts.length; i
+ * YAHOO.util.DragDropMgr.refreshCache(ddinstance.groups);
+ *
+ * Alternatively:
+ *
+ * YAHOO.util.DragDropMgr.refreshCache({group1:true, group2:true});
+ *
+ * @TODO this really should be an indexed array. Alternatively this
+ * method could accept both.
+ * @method refreshCache
+ * @param {Object} groups an associative array of groups to refresh
+ * @static
+ */
+ refreshCache: function(groups) {
+ for (var sGroup in groups) {
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+ for (var i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+
+ if (this.isTypeOfDD(oDD)) {
+ // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
+ var loc = this.getLocation(oDD);
+ if (loc) {
+ this.locationCache[oDD.id] = loc;
+ } else {
+ delete this.locationCache[oDD.id];
+ // this will unregister the drag and drop object if
+ // the element is not in a usable state
+ // oDD.unreg();
+ }
+ }
+ }
+ }
+ },
+
+ /**
+ * This checks to make sure an element exists and is in the DOM. The
+ * main purpose is to handle cases where innerHTML is used to remove
+ * drag and drop objects from the DOM. IE provides an 'unspecified
+ * error' when trying to access the offsetParent of such an element
+ * @method verifyEl
+ * @param {HTMLElement} el the element to check
+ * @return {boolean} true if the element looks usable
+ * @static
+ */
+ verifyEl: function(el) {
+ try {
+ if (el) {
+ var parent = el.offsetParent;
+ if (parent) {
+ return true;
+ }
+ }
+ } catch(e) {
+ }
+
+ return false;
+ },
+
+ /**
+ * Returns a Region object containing the drag and drop element's position
+ * and size, including the padding configured for it
+ * @method getLocation
+ * @param {DragDrop} oDD the drag and drop object to get the
+ * location for
+ * @return {YAHOO.util.Region} a Region object representing the total area
+ * the element occupies, including any padding
+ * the instance is configured for.
+ * @static
+ */
+ getLocation: function(oDD) {
+ if (! this.isTypeOfDD(oDD)) {
+ return null;
+ }
+
+ var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
+
+ try {
+ pos= YAHOO.util.Dom.getXY(el);
+ } catch (e) { }
+
+ if (!pos) {
+ return null;
+ }
+
+ x1 = pos[0];
+ x2 = x1 + el.offsetWidth;
+ y1 = pos[1];
+ y2 = y1 + el.offsetHeight;
+
+ t = y1 - oDD.padding[0];
+ r = x2 + oDD.padding[1];
+ b = y2 + oDD.padding[2];
+ l = x1 - oDD.padding[3];
+
+ return new YAHOO.util.Region( t, r, b, l );
+ },
+
+ /**
+ * Checks the cursor location to see if it over the target
+ * @method isOverTarget
+ * @param {YAHOO.util.Point} pt The point to evaluate
+ * @param {DragDrop} oTarget the DragDrop object we are inspecting
+ * @return {boolean} true if the mouse is over the target
+ * @private
+ * @static
+ */
+ isOverTarget: function(pt, oTarget, intersect) {
+ // use cache if available
+ var loc = this.locationCache[oTarget.id];
+ if (!loc || !this.useCache) {
+ loc = this.getLocation(oTarget);
+ this.locationCache[oTarget.id] = loc;
+
+ }
+
+ if (!loc) {
+ return false;
+ }
+
+ oTarget.cursorIsOver = loc.contains( pt );
+
+ // DragDrop is using this as a sanity check for the initial mousedown
+ // in this case we are done. In POINT mode, if the drag obj has no
+ // contraints, we are also done. Otherwise we need to evaluate the
+ // location of the target as related to the actual location of the
+ // dragged element.
+ var dc = this.dragCurrent;
+ if (!dc || !dc.getTargetCoord ||
+ (!intersect && !dc.constrainX && !dc.constrainY)) {
+ return oTarget.cursorIsOver;
+ }
+
+ oTarget.overlap = null;
+
+ // Get the current location of the drag element, this is the
+ // location of the mouse event less the delta that represents
+ // where the original mousedown happened on the element. We
+ // need to consider constraints and ticks as well.
+ var pos = dc.getTargetCoord(pt.x, pt.y);
+
+ var el = dc.getDragEl();
+ var curRegion = new YAHOO.util.Region( pos.y,
+ pos.x + el.offsetWidth,
+ pos.y + el.offsetHeight,
+ pos.x );
+
+ var overlap = curRegion.intersect(loc);
+
+ if (overlap) {
+ oTarget.overlap = overlap;
+ return (intersect) ? true : oTarget.cursorIsOver;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * unload event handler
+ * @method _onUnload
+ * @private
+ * @static
+ */
+ _onUnload: function(e, me) {
+ this.unregAll();
+ },
+
+ /**
+ * Cleans up the drag and drop events and objects.
+ * @method unregAll
+ * @private
+ * @static
+ */
+ unregAll: function() {
+
+ if (this.dragCurrent) {
+ this.stopDrag();
+ this.dragCurrent = null;
+ }
+
+ this._execOnAll("unreg", []);
+
+ for (i in this.elementCache) {
+ delete this.elementCache[i];
+ }
+
+ this.elementCache = {};
+ this.ids = {};
+ },
+
+ /**
+ * A cache of DOM elements
+ * @property elementCache
+ * @private
+ * @static
+ */
+ elementCache: {},
+
+ /**
+ * Get the wrapper for the DOM element specified
+ * @method getElWrapper
+ * @param {String} id the id of the element to get
+ * @return {YAHOO.util.DDM.ElementWrapper} the wrapped element
+ * @private
+ * @deprecated This wrapper isn't that useful
+ * @static
+ */
+ getElWrapper: function(id) {
+ var oWrapper = this.elementCache[id];
+ if (!oWrapper || !oWrapper.el) {
+ oWrapper = this.elementCache[id] =
+ new this.ElementWrapper(YAHOO.util.Dom.get(id));
+ }
+ return oWrapper;
+ },
+
+ /**
+ * Returns the actual DOM element
+ * @method getElement
+ * @param {String} id the id of the elment to get
+ * @return {Object} The element
+ * @deprecated use YAHOO.util.Dom.get instead
+ * @static
+ */
+ getElement: function(id) {
+ return YAHOO.util.Dom.get(id);
+ },
+
+ /**
+ * Returns the style property for the DOM element (i.e.,
+ * document.getElById(id).style)
+ * @method getCss
+ * @param {String} id the id of the elment to get
+ * @return {Object} The style property of the element
+ * @deprecated use YAHOO.util.Dom instead
+ * @static
+ */
+ getCss: function(id) {
+ var el = YAHOO.util.Dom.get(id);
+ return (el) ? el.style : null;
+ },
+
+ /**
+ * Inner class for cached elements
+ * @class DragDropMgr.ElementWrapper
+ * @for DragDropMgr
+ * @private
+ * @deprecated
+ */
+ ElementWrapper: function(el) {
+ /**
+ * The element
+ * @property el
+ */
+ this.el = el || null;
+ /**
+ * The element id
+ * @property id
+ */
+ this.id = this.el && el.id;
+ /**
+ * A reference to the style property
+ * @property css
+ */
+ this.css = this.el && el.style;
+ },
+
+ /**
+ * Returns the X position of an html element
+ * @method getPosX
+ * @param el the element for which to get the position
+ * @return {int} the X coordinate
+ * @for DragDropMgr
+ * @deprecated use YAHOO.util.Dom.getX instead
+ * @static
+ */
+ getPosX: function(el) {
+ return YAHOO.util.Dom.getX(el);
+ },
+
+ /**
+ * Returns the Y position of an html element
+ * @method getPosY
+ * @param el the element for which to get the position
+ * @return {int} the Y coordinate
+ * @deprecated use YAHOO.util.Dom.getY instead
+ * @static
+ */
+ getPosY: function(el) {
+ return YAHOO.util.Dom.getY(el);
+ },
+
+ /**
+ * Swap two nodes. In IE, we use the native method, for others we
+ * emulate the IE behavior
+ * @method swapNode
+ * @param n1 the first node to swap
+ * @param n2 the other node to swap
+ * @static
+ */
+ swapNode: function(n1, n2) {
+ if (n1.swapNode) {
+ n1.swapNode(n2);
+ } else {
+ var p = n2.parentNode;
+ var s = n2.nextSibling;
+
+ if (s == n1) {
+ p.insertBefore(n1, n2);
+ } else if (n2 == n1.nextSibling) {
+ p.insertBefore(n2, n1);
+ } else {
+ n1.parentNode.replaceChild(n2, n1);
+ p.insertBefore(n1, s);
+ }
+ }
+ },
+
+ /**
+ * Returns the current scroll position
+ * @method getScroll
+ * @private
+ * @static
+ */
+ getScroll: function () {
+ var t, l, dde=document.documentElement, db=document.body;
+ if (dde && (dde.scrollTop || dde.scrollLeft)) {
+ t = dde.scrollTop;
+ l = dde.scrollLeft;
+ } else if (db) {
+ t = db.scrollTop;
+ l = db.scrollLeft;
+ } else {
+ YAHOO.log("could not get scroll property");
+ }
+ return { top: t, left: l };
+ },
+
+ /**
+ * Returns the specified element style property
+ * @method getStyle
+ * @param {HTMLElement} el the element
+ * @param {string} styleProp the style property
+ * @return {string} The value of the style property
+ * @deprecated use YAHOO.util.Dom.getStyle
+ * @static
+ */
+ getStyle: function(el, styleProp) {
+ return YAHOO.util.Dom.getStyle(el, styleProp);
+ },
+
+ /**
+ * Gets the scrollTop
+ * @method getScrollTop
+ * @return {int} the document's scrollTop
+ * @static
+ */
+ getScrollTop: function () { return this.getScroll().top; },
+
+ /**
+ * Gets the scrollLeft
+ * @method getScrollLeft
+ * @return {int} the document's scrollTop
+ * @static
+ */
+ getScrollLeft: function () { return this.getScroll().left; },
+
+ /**
+ * Sets the x/y position of an element to the location of the
+ * target element.
+ * @method moveToEl
+ * @param {HTMLElement} moveEl The element to move
+ * @param {HTMLElement} targetEl The position reference element
+ * @static
+ */
+ moveToEl: function (moveEl, targetEl) {
+ var aCoord = YAHOO.util.Dom.getXY(targetEl);
+ YAHOO.util.Dom.setXY(moveEl, aCoord);
+ },
+
+ /**
+ * Gets the client height
+ * @method getClientHeight
+ * @return {int} client height in px
+ * @deprecated use YAHOO.util.Dom.getViewportHeight instead
+ * @static
+ */
+ getClientHeight: function() {
+ return YAHOO.util.Dom.getViewportHeight();
+ },
+
+ /**
+ * Gets the client width
+ * @method getClientWidth
+ * @return {int} client width in px
+ * @deprecated use YAHOO.util.Dom.getViewportWidth instead
+ * @static
+ */
+ getClientWidth: function() {
+ return YAHOO.util.Dom.getViewportWidth();
+ },
+
+ /**
+ * Numeric array sort function
+ * @method numericSort
+ * @static
+ */
+ numericSort: function(a, b) { return (a - b); },
+
+ /**
+ * Internal counter
+ * @property _timeoutCount
+ * @private
+ * @static
+ */
+ _timeoutCount: 0,
+
+ /**
+ * Trying to make the load order less important. Without this we get
+ * an error if this file is loaded before the Event Utility.
+ * @method _addListeners
+ * @private
+ * @static
+ */
+ _addListeners: function() {
+ var DDM = YAHOO.util.DDM;
+ if ( YAHOO.util.Event && document ) {
+ DDM._onLoad();
+ } else {
+ if (DDM._timeoutCount > 2000) {
+ } else {
+ setTimeout(DDM._addListeners, 10);
+ if (document && document.body) {
+ DDM._timeoutCount += 1;
+ }
+ }
+ }
+ },
+
+ /**
+ * Recursively searches the immediate parent and all child nodes for
+ * the handle element in order to determine wheter or not it was
+ * clicked.
+ * @method handleWasClicked
+ * @param node the html element to inspect
+ * @static
+ */
+ handleWasClicked: function(node, id) {
+ if (this.isHandle(id, node.id)) {
+ return true;
+ } else {
+ // check to see if this is a text node child of the one we want
+ var p = node.parentNode;
+
+ while (p) {
+ if (this.isHandle(id, p.id)) {
+ return true;
+ } else {
+ p = p.parentNode;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ };
+
+}();
+
+// shorter alias, save a few bytes
+YAHOO.util.DDM = YAHOO.util.DragDropMgr;
+YAHOO.util.DDM._addListeners();
+
+}
+
+/**
+ * A DragDrop implementation where the linked element follows the
+ * mouse cursor during a drag.
+ * @class DD
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id the id of the linked element
+ * @param {String} sGroup the group of related DragDrop items
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DD:
+ * scroll
+ */
+YAHOO.util.DD = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+YAHOO.extend(YAHOO.util.DD, YAHOO.util.DragDrop, {
+
+ /**
+ * When set to true, the utility automatically tries to scroll the browser
+ * window wehn a drag and drop element is dragged near the viewport boundary.
+ * Defaults to true.
+ * @property scroll
+ * @type boolean
+ */
+ scroll: true,
+
+ /**
+ * Sets the pointer offset to the distance between the linked element's top
+ * left corner and the location the element was clicked
+ * @method autoOffset
+ * @param {int} iPageX the X coordinate of the click
+ * @param {int} iPageY the Y coordinate of the click
+ */
+ autoOffset: function(iPageX, iPageY) {
+ var x = iPageX - this.startPageX;
+ var y = iPageY - this.startPageY;
+ this.setDelta(x, y);
+ },
+
+ /**
+ * Sets the pointer offset. You can call this directly to force the
+ * offset to be in a particular location (e.g., pass in 0,0 to set it
+ * to the center of the object, as done in YAHOO.widget.Slider)
+ * @method setDelta
+ * @param {int} iDeltaX the distance from the left
+ * @param {int} iDeltaY the distance from the top
+ */
+ setDelta: function(iDeltaX, iDeltaY) {
+ this.deltaX = iDeltaX;
+ this.deltaY = iDeltaY;
+ },
+
+ /**
+ * Sets the drag element to the location of the mousedown or click event,
+ * maintaining the cursor location relative to the location on the element
+ * that was clicked. Override this if you want to place the element in a
+ * location other than where the cursor is.
+ * @method setDragElPos
+ * @param {int} iPageX the X coordinate of the mousedown or drag event
+ * @param {int} iPageY the Y coordinate of the mousedown or drag event
+ */
+ setDragElPos: function(iPageX, iPageY) {
+ // the first time we do this, we are going to check to make sure
+ // the element has css positioning
+
+ var el = this.getDragEl();
+ this.alignElWithMouse(el, iPageX, iPageY);
+ },
+
+ /**
+ * Sets the element to the location of the mousedown or click event,
+ * maintaining the cursor location relative to the location on the element
+ * that was clicked. Override this if you want to place the element in a
+ * location other than where the cursor is.
+ * @method alignElWithMouse
+ * @param {HTMLElement} el the element to move
+ * @param {int} iPageX the X coordinate of the mousedown or drag event
+ * @param {int} iPageY the Y coordinate of the mousedown or drag event
+ */
+ alignElWithMouse: function(el, iPageX, iPageY) {
+ var oCoord = this.getTargetCoord(iPageX, iPageY);
+
+ if (!this.deltaSetXY) {
+ var aCoord = [oCoord.x, oCoord.y];
+ YAHOO.util.Dom.setXY(el, aCoord);
+ var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
+ var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
+
+ this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
+ } else {
+ YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px");
+ YAHOO.util.Dom.setStyle(el, "top", (oCoord.y + this.deltaSetXY[1]) + "px");
+ }
+
+ this.cachePosition(oCoord.x, oCoord.y);
+ this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
+ },
+
+ /**
+ * Saves the most recent position so that we can reset the constraints and
+ * tick marks on-demand. We need to know this so that we can calculate the
+ * number of pixels the element is offset from its original position.
+ * @method cachePosition
+ * @param iPageX the current x position (optional, this just makes it so we
+ * don't have to look it up again)
+ * @param iPageY the current y position (optional, this just makes it so we
+ * don't have to look it up again)
+ */
+ cachePosition: function(iPageX, iPageY) {
+ if (iPageX) {
+ this.lastPageX = iPageX;
+ this.lastPageY = iPageY;
+ } else {
+ var aCoord = YAHOO.util.Dom.getXY(this.getEl());
+ this.lastPageX = aCoord[0];
+ this.lastPageY = aCoord[1];
+ }
+ },
+
+ /**
+ * Auto-scroll the window if the dragged object has been moved beyond the
+ * visible window boundary.
+ * @method autoScroll
+ * @param {int} x the drag element's x position
+ * @param {int} y the drag element's y position
+ * @param {int} h the height of the drag element
+ * @param {int} w the width of the drag element
+ * @private
+ */
+ autoScroll: function(x, y, h, w) {
+
+ if (this.scroll) {
+ // The client height
+ var clientH = this.DDM.getClientHeight();
+
+ // The client width
+ var clientW = this.DDM.getClientWidth();
+
+ // The amt scrolled down
+ var st = this.DDM.getScrollTop();
+
+ // The amt scrolled right
+ var sl = this.DDM.getScrollLeft();
+
+ // Location of the bottom of the element
+ var bot = h + y;
+
+ // Location of the right of the element
+ var right = w + x;
+
+ // The distance from the cursor to the bottom of the visible area,
+ // adjusted so that we don't scroll if the cursor is beyond the
+ // element drag constraints
+ var toBot = (clientH + st - y - this.deltaY);
+
+ // The distance from the cursor to the right of the visible area
+ var toRight = (clientW + sl - x - this.deltaX);
+
+
+ // How close to the edge the cursor must be before we scroll
+ // var thresh = (document.all) ? 100 : 40;
+ var thresh = 40;
+
+ // How many pixels to scroll per autoscroll op. This helps to reduce
+ // clunky scrolling. IE is more sensitive about this ... it needs this
+ // value to be higher.
+ var scrAmt = (document.all) ? 80 : 30;
+
+ // Scroll down if we are near the bottom of the visible page and the
+ // obj extends below the crease
+ if ( bot > clientH && toBot < thresh ) {
+ window.scrollTo(sl, st + scrAmt);
+ }
+
+ // Scroll up if the window is scrolled down and the top of the object
+ // goes above the top border
+ if ( y < st && st > 0 && y - st < thresh ) {
+ window.scrollTo(sl, st - scrAmt);
+ }
+
+ // Scroll right if the obj is beyond the right border and the cursor is
+ // near the border.
+ if ( right > clientW && toRight < thresh ) {
+ window.scrollTo(sl + scrAmt, st);
+ }
+
+ // Scroll left if the window has been scrolled to the right and the obj
+ // extends past the left border
+ if ( x < sl && sl > 0 && x - sl < thresh ) {
+ window.scrollTo(sl - scrAmt, st);
+ }
+ }
+ },
+
+ /**
+ * Finds the location the element should be placed if we want to move
+ * it to where the mouse location less the click offset would place us.
+ * @method getTargetCoord
+ * @param {int} iPageX the X coordinate of the click
+ * @param {int} iPageY the Y coordinate of the click
+ * @return an object that contains the coordinates (Object.x and Object.y)
+ * @private
+ */
+ getTargetCoord: function(iPageX, iPageY) {
+
+
+ var x = iPageX - this.deltaX;
+ var y = iPageY - this.deltaY;
+
+ if (this.constrainX) {
+ if (x < this.minX) { x = this.minX; }
+ if (x > this.maxX) { x = this.maxX; }
+ }
+
+ if (this.constrainY) {
+ if (y < this.minY) { y = this.minY; }
+ if (y > this.maxY) { y = this.maxY; }
+ }
+
+ x = this.getTick(x, this.xTicks);
+ y = this.getTick(y, this.yTicks);
+
+
+ return {x:x, y:y};
+ },
+
+ /*
+ * Sets up config options specific to this class. Overrides
+ * YAHOO.util.DragDrop, but all versions of this method through the
+ * inheritance chain are called
+ */
+ applyConfig: function() {
+ YAHOO.util.DD.superclass.applyConfig.call(this);
+ this.scroll = (this.config.scroll !== false);
+ },
+
+ /*
+ * Event that fires prior to the onMouseDown event. Overrides
+ * YAHOO.util.DragDrop.
+ */
+ b4MouseDown: function(e) {
+ // this.resetConstraints();
+ this.autoOffset(YAHOO.util.Event.getPageX(e),
+ YAHOO.util.Event.getPageY(e));
+ },
+
+ /*
+ * Event that fires prior to the onDrag event. Overrides
+ * YAHOO.util.DragDrop.
+ */
+ b4Drag: function(e) {
+ this.setDragElPos(YAHOO.util.Event.getPageX(e),
+ YAHOO.util.Event.getPageY(e));
+ },
+
+ toString: function() {
+ return ("DD " + this.id);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Debugging ygDragDrop events that can be overridden
+ //////////////////////////////////////////////////////////////////////////
+ /*
+ startDrag: function(x, y) {
+ },
+
+ onDrag: function(e) {
+ },
+
+ onDragEnter: function(e, id) {
+ },
+
+ onDragOver: function(e, id) {
+ },
+
+ onDragOut: function(e, id) {
+ },
+
+ onDragDrop: function(e, id) {
+ },
+
+ endDrag: function(e) {
+ }
+
+ */
+
+});
+/**
+ * A DragDrop implementation that inserts an empty, bordered div into
+ * the document that follows the cursor during drag operations. At the time of
+ * the click, the frame div is resized to the dimensions of the linked html
+ * element, and moved to the exact location of the linked element.
+ *
+ * References to the "frame" element refer to the single proxy element that
+ * was created to be dragged in place of all DDProxy elements on the
+ * page.
+ *
+ * @class DDProxy
+ * @extends YAHOO.util.DD
+ * @constructor
+ * @param {String} id the id of the linked html element
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DDProxy in addition to those in DragDrop:
+ * resizeFrame, centerFrame, dragElId
+ */
+YAHOO.util.DDProxy = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ this.initFrame();
+ }
+};
+
+/**
+ * The default drag frame div id
+ * @property YAHOO.util.DDProxy.dragElId
+ * @type String
+ * @static
+ */
+YAHOO.util.DDProxy.dragElId = "ygddfdiv";
+
+YAHOO.extend(YAHOO.util.DDProxy, YAHOO.util.DD, {
+
+ /**
+ * By default we resize the drag frame to be the same size as the element
+ * we want to drag (this is to get the frame effect). We can turn it off
+ * if we want a different behavior.
+ * @property resizeFrame
+ * @type boolean
+ */
+ resizeFrame: true,
+
+ /**
+ * By default the frame is positioned exactly where the drag element is, so
+ * we use the cursor offset provided by YAHOO.util.DD. Another option that works only if
+ * you do not have constraints on the obj is to have the drag frame centered
+ * around the cursor. Set centerFrame to true for this effect.
+ * @property centerFrame
+ * @type boolean
+ */
+ centerFrame: false,
+
+ /**
+ * Creates the proxy element if it does not yet exist
+ * @method createFrame
+ */
+ createFrame: function() {
+ var self = this;
+ var body = document.body;
+
+ if (!body || !body.firstChild) {
+ setTimeout( function() { self.createFrame(); }, 50 );
+ return;
+ }
+
+ var div = this.getDragEl();
+
+ if (!div) {
+ div = document.createElement("div");
+ div.id = this.dragElId;
+ var s = div.style;
+
+ s.position = "absolute";
+ s.visibility = "hidden";
+ s.cursor = "move";
+ s.border = "2px solid #aaa";
+ s.zIndex = 999;
+
+ // appendChild can blow up IE if invoked prior to the window load event
+ // while rendering a table. It is possible there are other scenarios
+ // that would cause this to happen as well.
+ body.insertBefore(div, body.firstChild);
+ }
+ },
+
+ /**
+ * Initialization for the drag frame element. Must be called in the
+ * constructor of all subclasses
+ * @method initFrame
+ */
+ initFrame: function() {
+ this.createFrame();
+ },
+
+ applyConfig: function() {
+ YAHOO.util.DDProxy.superclass.applyConfig.call(this);
+
+ this.resizeFrame = (this.config.resizeFrame !== false);
+ this.centerFrame = (this.config.centerFrame);
+ this.setDragElId(this.config.dragElId || YAHOO.util.DDProxy.dragElId);
+ },
+
+ /**
+ * Resizes the drag frame to the dimensions of the clicked object, positions
+ * it over the object, and finally displays it
+ * @method showFrame
+ * @param {int} iPageX X click position
+ * @param {int} iPageY Y click position
+ * @private
+ */
+ showFrame: function(iPageX, iPageY) {
+ var el = this.getEl();
+ var dragEl = this.getDragEl();
+ var s = dragEl.style;
+
+ this._resizeProxy();
+
+ if (this.centerFrame) {
+ this.setDelta( Math.round(parseInt(s.width, 10)/2),
+ Math.round(parseInt(s.height, 10)/2) );
+ }
+
+ this.setDragElPos(iPageX, iPageY);
+
+ YAHOO.util.Dom.setStyle(dragEl, "visibility", "visible");
+ },
+
+ /**
+ * The proxy is automatically resized to the dimensions of the linked
+ * element when a drag is initiated, unless resizeFrame is set to false
+ * @method _resizeProxy
+ * @private
+ */
+ _resizeProxy: function() {
+ if (this.resizeFrame) {
+ var DOM = YAHOO.util.Dom;
+ var el = this.getEl();
+ var dragEl = this.getDragEl();
+
+ var bt = parseInt( DOM.getStyle(dragEl, "borderTopWidth" ), 10);
+ var br = parseInt( DOM.getStyle(dragEl, "borderRightWidth" ), 10);
+ var bb = parseInt( DOM.getStyle(dragEl, "borderBottomWidth" ), 10);
+ var bl = parseInt( DOM.getStyle(dragEl, "borderLeftWidth" ), 10);
+
+ if (isNaN(bt)) { bt = 0; }
+ if (isNaN(br)) { br = 0; }
+ if (isNaN(bb)) { bb = 0; }
+ if (isNaN(bl)) { bl = 0; }
+
+
+ var newWidth = Math.max(0, el.offsetWidth - br - bl);
+ var newHeight = Math.max(0, el.offsetHeight - bt - bb);
+
+
+ DOM.setStyle( dragEl, "width", newWidth + "px" );
+ DOM.setStyle( dragEl, "height", newHeight + "px" );
+ }
+ },
+
+ // overrides YAHOO.util.DragDrop
+ b4MouseDown: function(e) {
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ this.autoOffset(x, y);
+ this.setDragElPos(x, y);
+ },
+
+ // overrides YAHOO.util.DragDrop
+ b4StartDrag: function(x, y) {
+ // show the drag frame
+ this.showFrame(x, y);
+ },
+
+ // overrides YAHOO.util.DragDrop
+ b4EndDrag: function(e) {
+ YAHOO.util.Dom.setStyle(this.getDragEl(), "visibility", "hidden");
+ },
+
+ // overrides YAHOO.util.DragDrop
+ // By default we try to move the element to the last location of the frame.
+ // This is so that the default behavior mirrors that of YAHOO.util.DD.
+ endDrag: function(e) {
+ var DOM = YAHOO.util.Dom;
+ var lel = this.getEl();
+ var del = this.getDragEl();
+
+ // Show the drag frame briefly so we can get its position
+ // del.style.visibility = "";
+ DOM.setStyle(del, "visibility", "");
+
+ // Hide the linked element before the move to get around a Safari
+ // rendering bug.
+ //lel.style.visibility = "hidden";
+ DOM.setStyle(lel, "visibility", "hidden");
+ YAHOO.util.DDM.moveToEl(lel, del);
+ //del.style.visibility = "hidden";
+ DOM.setStyle(del, "visibility", "hidden");
+ //lel.style.visibility = "";
+ DOM.setStyle(lel, "visibility", "");
+ },
+
+ toString: function() {
+ return ("DDProxy " + this.id);
+ }
+
+});
+/**
+ * A DragDrop implementation that does not move, but can be a drop
+ * target. You would get the same result by simply omitting implementation
+ * for the event callbacks, but this way we reduce the processing cost of the
+ * event listener and the callbacks.
+ * @class DDTarget
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id the id of the element that is a drop target
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DDTarget in addition to those in
+ * DragDrop:
+ * none
+ */
+YAHOO.util.DDTarget = function(id, sGroup, config) {
+ if (id) {
+ this.initTarget(id, sGroup, config);
+ }
+};
+
+// YAHOO.util.DDTarget.prototype = new YAHOO.util.DragDrop();
+YAHOO.extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop, {
+ toString: function() {
+ return ("DDTarget " + this.id);
+ }
+});
diff --git a/lib/yui/event/README b/lib/yui/event/README
index c63ba0a889..18defb61c7 100755
--- a/lib/yui/event/README
+++ b/lib/yui/event/README
@@ -1,130 +1,135 @@
-
-YUI Library - Event - Release Notes
-
-0.12.1
-
- * If an error is thrown during the browser-specific add/remove lister call,
- addListener/removeListener will catch the error and return false.
-
- * onAvailable array items are nulled out instead of deleted when completed to
- get around an Opera issue introduced in a recent version of the browser.
-
-0.12.0
-
- * If the function argument is not provided to Event.removeListener, all
- all listeners for the specified event type on the element will be removed.
-
- * CustomEvent now has an optional parameter that defines the signature of
- the listeners for this event. Two signatures are supported:
-
- YAHOO.util.CustomEvent.LIST:
- param1: event name
- param2: array of arguments provided to fire()
- param3: the custom object supplied to subscribe()
-
- YAHOO.util.CustomEvent.FLAT:
- param1: the first argument provided to fire()
- param2: the custom object supplied to subscribe()
-
- The new flat signature makes it possible to provide a better API
- when using custom events, and it makes it possible to transparently
- wrap DOM events.
-
- * The parameters for overriding scope in both Event.addListener, and
- CustomEvent.subscribe have been augmented. In addition to the
- previous behavior where a true value would make the previous parameter
- the execution scope, an object can be supplied instead. If an object
- is provided, that object becomes the scope obj. This makes it possible
- to pass a both a custom object and adjust the scope to a different object.
-
- * Added EventProvider, which is a wrapper for CustomEvent that makes it
- possible to subscribe to events by name, whether or not the event has
- been created. This class was designed to be used with YAHOO.augment.
- EventProvider custom events are created with the new FLAT listener
- signature.
-
- * CustomEvent subscribers can return false to stop the propagation of
- the event.
-
- * CustomEvents now have an onSubscribe custom event that can used to the
- case where a subscriber subscribes to an one-time event that has already
- happened. Also provides a way for the implementer to defer initialization
- logic until after the first subscription.
-
- * Event.getCharCode now always returns keyCode if charCode is not available.
-
- * Added Event.onContentReady, which is similar to onAvailable, but it also
- checks simblings to try to determine when the element's children are
- available.
-
-0.11.4
-
- * Fixed a memory leak in IE6 that occurred when the utility was hosted in
- an iframe.
-
- * Fixed an issue with Safari click listeners when listeners were removed.
-
-0.11.3
-
- * The listener cache is now pruned when events are removed. This fixes
- a performance issue when adding many listeners, removing them, and
- adding them again repeatedly.
-
- * Safari click listeners will work correctly if a bound element is removed
- from the DOM and a new element with the same ID is added.
-
- * Removed the code that automatically unsubscribed custom event listeners.
-
-0.11.0
-
- * Added Event.purgeElement which will remove all listeners added via
- addListener from the supplied element. If an optional "type" parameter
- is supplied, only events of that type will be removed. Optionally, the
- purge can be performed recursively on the element's children as well.
-
- * Added Event.getListeners which will return all listeners attached to
- a given element.. either all listeners or listeners of a specific type.
-
- * getTarget now automatically resolves text nodes. The optional parameter
- for this feature is now deprecated.
-
- * getRelatedTarget now resolves text nodes for the browsers that return the
- text node rather than its host HTML element.
-
- * CustomEvent now logs the custom event activity if the logger widget is available
-
-0.10.0
-
- * Added Safari dblclick to the list of legacy events.
-
- * When multiple identical event handlers are defined, multiple calls
- to removeListener can now remove all of them.
-
- * removeListener works properly for unload events
-
- * Legacy event bookkeeping is more efficient, improving the performance for
- adding Safari click events.
-
- * _unload() is more efficient, improving the page transition experience in
- Safari in particular.
-
- * addListener, removeListener now return false if the function argument is
- not valid.
-
- * Fixed an operator precedence issue in getCharCode.
-
- * Added Event.getXY, which returns [Event.getPageX(e), Event.getPageY(e)]
-
- * Added Event.onAvailable, which will execute the callback when the element
- with the supplied id is found. Currently searches periodically until the
- window load event or for up to 10 seconds after the onAvailable method
- was executed.
-
- * The lazy listener attachment process now will poll beyond the window load
- event in order to better handle the case when a listener is defined
- late in the page but before the element is in the dom.
-
- * Fixed browser detection for Opera installations reporting as IE.
-
- * It is now possible to remove and re-add legacy events (Safari click event).
-
+
+YUI Library - Event - Release Notes
+
+0.12.2
+
+ * Fixed a bug introduced in 0.12.1 release caused nested onAvailable
+ calls to fail.
+
+0.12.1
+
+ * If an error is thrown during the browser-specific add/remove lister call,
+ addListener/removeListener will catch the error and return false.
+
+ * onAvailable array items are nulled out instead of deleted when completed to
+ get around an Opera issue introduced in a recent version of the browser.
+
+0.12.0
+
+ * If the function argument is not provided to Event.removeListener, all
+ all listeners for the specified event type on the element will be removed.
+
+ * CustomEvent now has an optional parameter that defines the signature of
+ the listeners for this event. Two signatures are supported:
+
+ YAHOO.util.CustomEvent.LIST:
+ param1: event name
+ param2: array of arguments provided to fire()
+ param3: the custom object supplied to subscribe()
+
+ YAHOO.util.CustomEvent.FLAT:
+ param1: the first argument provided to fire()
+ param2: the custom object supplied to subscribe()
+
+ The new flat signature makes it possible to provide a better API
+ when using custom events, and it makes it possible to transparently
+ wrap DOM events.
+
+ * The parameters for overriding scope in both Event.addListener, and
+ CustomEvent.subscribe have been augmented. In addition to the
+ previous behavior where a true value would make the previous parameter
+ the execution scope, an object can be supplied instead. If an object
+ is provided, that object becomes the scope obj. This makes it possible
+ to pass a both a custom object and adjust the scope to a different object.
+
+ * Added EventProvider, which is a wrapper for CustomEvent that makes it
+ possible to subscribe to events by name, whether or not the event has
+ been created. This class was designed to be used with YAHOO.augment.
+ EventProvider custom events are created with the new FLAT listener
+ signature.
+
+ * CustomEvent subscribers can return false to stop the propagation of
+ the event.
+
+ * CustomEvents now have an onSubscribe custom event that can used to the
+ case where a subscriber subscribes to an one-time event that has already
+ happened. Also provides a way for the implementer to defer initialization
+ logic until after the first subscription.
+
+ * Event.getCharCode now always returns keyCode if charCode is not available.
+
+ * Added Event.onContentReady, which is similar to onAvailable, but it also
+ checks simblings to try to determine when the element's children are
+ available.
+
+0.11.4
+
+ * Fixed a memory leak in IE6 that occurred when the utility was hosted in
+ an iframe.
+
+ * Fixed an issue with Safari click listeners when listeners were removed.
+
+0.11.3
+
+ * The listener cache is now pruned when events are removed. This fixes
+ a performance issue when adding many listeners, removing them, and
+ adding them again repeatedly.
+
+ * Safari click listeners will work correctly if a bound element is removed
+ from the DOM and a new element with the same ID is added.
+
+ * Removed the code that automatically unsubscribed custom event listeners.
+
+0.11.0
+
+ * Added Event.purgeElement which will remove all listeners added via
+ addListener from the supplied element. If an optional "type" parameter
+ is supplied, only events of that type will be removed. Optionally, the
+ purge can be performed recursively on the element's children as well.
+
+ * Added Event.getListeners which will return all listeners attached to
+ a given element.. either all listeners or listeners of a specific type.
+
+ * getTarget now automatically resolves text nodes. The optional parameter
+ for this feature is now deprecated.
+
+ * getRelatedTarget now resolves text nodes for the browsers that return the
+ text node rather than its host HTML element.
+
+ * CustomEvent now logs the custom event activity if the logger widget is available
+
+0.10.0
+
+ * Added Safari dblclick to the list of legacy events.
+
+ * When multiple identical event handlers are defined, multiple calls
+ to removeListener can now remove all of them.
+
+ * removeListener works properly for unload events
+
+ * Legacy event bookkeeping is more efficient, improving the performance for
+ adding Safari click events.
+
+ * _unload() is more efficient, improving the page transition experience in
+ Safari in particular.
+
+ * addListener, removeListener now return false if the function argument is
+ not valid.
+
+ * Fixed an operator precedence issue in getCharCode.
+
+ * Added Event.getXY, which returns [Event.getPageX(e), Event.getPageY(e)]
+
+ * Added Event.onAvailable, which will execute the callback when the element
+ with the supplied id is found. Currently searches periodically until the
+ window load event or for up to 10 seconds after the onAvailable method
+ was executed.
+
+ * The lazy listener attachment process now will poll beyond the window load
+ event in order to better handle the case when a listener is defined
+ late in the page but before the element is in the dom.
+
+ * Fixed browser detection for Opera installations reporting as IE.
+
+ * It is now possible to remove and re-add legacy events (Safari click event).
+
diff --git a/lib/yui/event/event-debug.js b/lib/yui/event/event-debug.js
index c80fa735a7..468e592e71 100755
--- a/lib/yui/event/event-debug.js
+++ b/lib/yui/event/event-debug.js
@@ -1,1795 +1,1797 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 0.12.1
-*/
-
-/**
- * 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.
- * @param {boolean} silent pass true to prevent the event from writing to
- * the debugsystem
- * @param {int} signature the signature that the custom event subscriber
- * will receive. YAHOO.util.CustomEvent.LIST or
- * YAHOO.util.CustomEvent.FLAT. The default is
- * YAHOO.util.CustomEvent.LIST.
- * @namespace YAHOO.util
- * @class CustomEvent
- * @constructor
- */
-YAHOO.util.CustomEvent = function(type, oScope, silent, signature) {
-
- /**
- * The type of event, returned to subscribers when the event fires
- * @property type
- * @type string
- */
- this.type = type;
-
- /**
- * The scope the the event will fire from by default. Defaults to the window
- * obj
- * @property scope
- * @type object
- */
- this.scope = oScope || window;
-
- /**
- * By default all custom events are logged in the debug build, set silent
- * to true to disable debug outpu for this event.
- * @property silent
- * @type boolean
- */
- this.silent = silent;
-
- /**
- * Custom events support two styles of arguments provided to the event
- * subscribers.
- *
- * YAHOO.util.CustomEvent.LIST:
- *
- * param1: event name
- * param2: array of arguments sent to fire
- * param3: a custom object supplied by the subscriber
- *
- *
- * YAHOO.util.CustomEvent.FLAT
- *
- * param1: the first argument passed to fire. If you need to
- * pass multiple parameters, use and array or object literal
- * param2: a custom object supplied by the subscriber
- *
- *
- *
- * @property signature
- * @type int
- */
- this.signature = signature || YAHOO.util.CustomEvent.LIST;
-
- /**
- * The subscribers to this event
- * @property subscribers
- * @type Subscriber[]
- */
- this.subscribers = [];
-
- if (!this.silent) {
- YAHOO.log( "Creating " + this, "info", "Event" );
- }
-
- var onsubscribeType = "_YUICEOnSubscribe";
-
- // Only add subscribe events for events that are not generated by
- // CustomEvent
- if (type !== onsubscribeType) {
-
- /**
- * Custom events provide a custom event that fires whenever there is
- * a new subscriber to the event. This provides an opportunity to
- * handle the case where there is a non-repeating event that has
- * already fired has a new subscriber.
- *
- * @event subscribeEvent
- * @type YAHOO.util.CustomEvent
- * @param {Function} fn The function to execute
- * @param {Object} obj An object to be passed along when the event
- * fires
- * @param {boolean|Object} override If true, the obj passed in becomes
- * the execution scope of the listener.
- * if an object, that object becomes the
- * the execution scope.
- */
- this.subscribeEvent =
- new YAHOO.util.CustomEvent(onsubscribeType, this, true);
-
- }
-};
-
-/**
- * Subscriber listener sigature constant. The LIST type returns three
- * parameters: the event type, the array of args passed to fire, and
- * the optional custom object
- * @property YAHOO.util.CustomEvent.LIST
- * @static
- * @type int
- */
-YAHOO.util.CustomEvent.LIST = 0;
-
-/**
- * Subscriber listener sigature constant. The FLAT type returns two
- * parameters: the first argument passed to fire and the optional
- * custom object
- * @property YAHOO.util.CustomEvent.FLAT
- * @static
- * @type int
- */
-YAHOO.util.CustomEvent.FLAT = 1;
-
-YAHOO.util.CustomEvent.prototype = {
-
- /**
- * Subscribes the caller to this event
- * @method subscribe
- * @param {Function} fn The function to execute
- * @param {Object} obj An object to be passed along when the event
- * fires
- * @param {boolean|Object} override If true, the obj passed in becomes
- * the execution scope of the listener.
- * if an object, that object becomes the
- * the execution scope.
- */
- subscribe: function(fn, obj, override) {
- if (this.subscribeEvent) {
- this.subscribeEvent.fire(fn, obj, override);
- }
-
- this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, override) );
- },
-
- /**
- * Unsubscribes the caller from this event
- * @method unsubscribe
- * @param {Function} fn The function to execute
- * @param {Object} obj The custom object passed to subscribe (optional)
- * @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
- * 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
- *
- * @method fire
- * @param {Object*} arguments an arbitrary set of parameters to pass to
- * the handler.
- * @return {boolean} false if one of the subscribers returned false,
- * true otherwise
- */
- fire: function() {
- var len=this.subscribers.length;
- if (!len && this.silent) {
- return true;
- }
-
- var args=[], ret=true, i;
-
- for (i=0; i" + (i+1) + ": " + s,
- "info", "Event" );
- }
-
- var scope = s.getScope(this.scope);
-
- if (this.signature == YAHOO.util.CustomEvent.FLAT) {
- var param = null;
- if (args.length > 0) {
- param = args[0];
- }
- ret = s.fn.call(scope, param, s.obj);
- } else {
- ret = s.fn.call(scope, this.type, args, s.obj);
- }
- if (false === ret) {
- if (!this.silent) {
- YAHOO.log("Event cancelled, subscriber " + i +
- " of " + len);
- }
-
- //break;
- return false;
- }
- }
- }
-
- return true;
- },
-
- /**
- * Removes all listeners
- * @method unsubscribeAll
- */
- unsubscribeAll: function() {
- for (var i=0, len=this.subscribers.length; i= 0) {
- cacheItem = listeners[index];
- }
-
- if (!el || !cacheItem) {
- // this.logger.debug("cached listener not found");
- return false;
- }
-
- // this.logger.debug("Removing handler: " + el + ", " + sType);
-
- if (this.useLegacyEvent(el, sType)) {
- var legacyIndex = this.getLegacyIndex(el, sType);
- var llist = legacyHandlers[legacyIndex];
- if (llist) {
- for (i=0, len=llist.length; i 0);
- }
-
- // onAvailable
- var notAvail = [];
- for (var i=0,len=onAvailStack.length; i 0) {
- for (var i=0,len=listeners.length; i 0) {
- j = listeners.length;
- while (j) {
- index = j-1;
- l = listeners[index];
- if (l) {
- EU.removeListener(l[EU.EL], l[EU.TYPE],
- l[EU.FN], index);
- }
- j = j - 1;
- }
- l=null;
-
- EU.clearCache();
- }
-
- for (i=0,len=legacyEvents.length; i
- *
- * scope: defines the default execution scope. If not defined
- * the default scope will be this instance.
- *
- *
- * silent: if true, the custom event will not generate log messages.
- * This is false by default.
- *
- *
- * onSubscribeCallback: specifies a callback to execute when the
- * event has a new subscriber. This will fire immediately for
- * each queued subscriber if any exist prior to the creation of
- * the event.
- *
- *
- *
- * @return {CustomEvent} the custom event
- *
- */
- createEvent: function(p_type, p_config) {
-
- this.__yui_events = this.__yui_events || {};
- var opts = p_config || {};
- var events = this.__yui_events;
-
- if (events[p_type]) {
- YAHOO.log("EventProvider: error, event already exists");
- } else {
-
- var scope = opts.scope || this;
- var silent = opts.silent || null;
-
- var ce = new YAHOO.util.CustomEvent(p_type, scope, silent,
- YAHOO.util.CustomEvent.FLAT);
- events[p_type] = ce;
-
- if (opts.onSubscribeCallback) {
- ce.subscribeEvent.subscribe(opts.onSubscribeCallback);
- }
-
- this.__yui_subscribers = this.__yui_subscribers || {};
- var qs = this.__yui_subscribers[p_type];
-
- if (qs) {
- for (var i=0; i
- * The first argument fire() was executed with
- * The custom object (if any) that was passed into the subscribe()
- * method
- *
- * @method fireEvent
- * @param p_type {string} the type, or name of the event
- * @param arguments {Object*} an arbitrary set of parameters to pass to
- * the handler.
- * @return {boolean} the return value from CustomEvent.fire, or null if
- * the custom event does not exist.
- */
- fireEvent: function(p_type, arg1, arg2, etc) {
-
- this.__yui_events = this.__yui_events || {};
- var ce = this.__yui_events[p_type];
-
- if (ce) {
- var args = [];
- for (var i=1; i
+ * YAHOO.util.CustomEvent.LIST:
+ *
+ * param1: event name
+ * param2: array of arguments sent to fire
+ * param3: a custom object supplied by the subscriber
+ *
+ *
+ * YAHOO.util.CustomEvent.FLAT
+ *
+ * param1: the first argument passed to fire. If you need to
+ * pass multiple parameters, use and array or object literal
+ * param2: a custom object supplied by the subscriber
+ *
+ *
+ *
+ * @property signature
+ * @type int
+ */
+ this.signature = signature || YAHOO.util.CustomEvent.LIST;
+
+ /**
+ * The subscribers to this event
+ * @property subscribers
+ * @type Subscriber[]
+ */
+ this.subscribers = [];
+
+ if (!this.silent) {
+ YAHOO.log( "Creating " + this, "info", "Event" );
+ }
+
+ var onsubscribeType = "_YUICEOnSubscribe";
+
+ // Only add subscribe events for events that are not generated by
+ // CustomEvent
+ if (type !== onsubscribeType) {
+
+ /**
+ * Custom events provide a custom event that fires whenever there is
+ * a new subscriber to the event. This provides an opportunity to
+ * handle the case where there is a non-repeating event that has
+ * already fired has a new subscriber.
+ *
+ * @event subscribeEvent
+ * @type YAHOO.util.CustomEvent
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event
+ * fires
+ * @param {boolean|Object} override If true, the obj passed in becomes
+ * the execution scope of the listener.
+ * if an object, that object becomes the
+ * the execution scope.
+ */
+ this.subscribeEvent =
+ new YAHOO.util.CustomEvent(onsubscribeType, this, true);
+
+ }
+};
+
+/**
+ * Subscriber listener sigature constant. The LIST type returns three
+ * parameters: the event type, the array of args passed to fire, and
+ * the optional custom object
+ * @property YAHOO.util.CustomEvent.LIST
+ * @static
+ * @type int
+ */
+YAHOO.util.CustomEvent.LIST = 0;
+
+/**
+ * Subscriber listener sigature constant. The FLAT type returns two
+ * parameters: the first argument passed to fire and the optional
+ * custom object
+ * @property YAHOO.util.CustomEvent.FLAT
+ * @static
+ * @type int
+ */
+YAHOO.util.CustomEvent.FLAT = 1;
+
+YAHOO.util.CustomEvent.prototype = {
+
+ /**
+ * Subscribes the caller to this event
+ * @method subscribe
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event
+ * fires
+ * @param {boolean|Object} override If true, the obj passed in becomes
+ * the execution scope of the listener.
+ * if an object, that object becomes the
+ * the execution scope.
+ */
+ subscribe: function(fn, obj, override) {
+ if (this.subscribeEvent) {
+ this.subscribeEvent.fire(fn, obj, override);
+ }
+
+ this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, override) );
+ },
+
+ /**
+ * Unsubscribes the caller from this event
+ * @method unsubscribe
+ * @param {Function} fn The function to execute
+ * @param {Object} obj The custom object passed to subscribe (optional)
+ * @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
+ * 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
+ *
+ * @method fire
+ * @param {Object*} arguments an arbitrary set of parameters to pass to
+ * the handler.
+ * @return {boolean} false if one of the subscribers returned false,
+ * true otherwise
+ */
+ fire: function() {
+ var len=this.subscribers.length;
+ if (!len && this.silent) {
+ return true;
+ }
+
+ var args=[], ret=true, i;
+
+ for (i=0; i" + (i+1) + ": " + s,
+ "info", "Event" );
+ }
+
+ var scope = s.getScope(this.scope);
+
+ if (this.signature == YAHOO.util.CustomEvent.FLAT) {
+ var param = null;
+ if (args.length > 0) {
+ param = args[0];
+ }
+ ret = s.fn.call(scope, param, s.obj);
+ } else {
+ ret = s.fn.call(scope, this.type, args, s.obj);
+ }
+ if (false === ret) {
+ if (!this.silent) {
+ YAHOO.log("Event cancelled, subscriber " + i +
+ " of " + len);
+ }
+
+ //break;
+ return false;
+ }
+ }
+ }
+
+ return true;
+ },
+
+ /**
+ * Removes all listeners
+ * @method unsubscribeAll
+ */
+ unsubscribeAll: function() {
+ for (var i=0, len=this.subscribers.length; i= 0) {
+ cacheItem = listeners[index];
+ }
+
+ if (!el || !cacheItem) {
+ // this.logger.debug("cached listener not found");
+ return false;
+ }
+
+ // this.logger.debug("Removing handler: " + el + ", " + sType);
+
+ if (this.useLegacyEvent(el, sType)) {
+ var legacyIndex = this.getLegacyIndex(el, sType);
+ var llist = legacyHandlers[legacyIndex];
+ if (llist) {
+ for (i=0, len=llist.length; i 0);
+ }
+
+ // onAvailable
+ var notAvail = [];
+ for (var i=0,len=onAvailStack.length; i 0) {
+ for (var i=0,len=listeners.length; i 0) {
+ j = listeners.length;
+ while (j) {
+ index = j-1;
+ l = listeners[index];
+ if (l) {
+ EU.removeListener(l[EU.EL], l[EU.TYPE],
+ l[EU.FN], index);
+ }
+ j = j - 1;
+ }
+ l=null;
+
+ EU.clearCache();
+ }
+
+ for (i=0,len=legacyEvents.length; i
+ *
+ * scope: defines the default execution scope. If not defined
+ * the default scope will be this instance.
+ *
+ *
+ * silent: if true, the custom event will not generate log messages.
+ * This is false by default.
+ *
+ *
+ * onSubscribeCallback: specifies a callback to execute when the
+ * event has a new subscriber. This will fire immediately for
+ * each queued subscriber if any exist prior to the creation of
+ * the event.
+ *
+ *
+ *
+ * @return {CustomEvent} the custom event
+ *
+ */
+ createEvent: function(p_type, p_config) {
+
+ this.__yui_events = this.__yui_events || {};
+ var opts = p_config || {};
+ var events = this.__yui_events;
+
+ if (events[p_type]) {
+ YAHOO.log("EventProvider: error, event already exists");
+ } else {
+
+ var scope = opts.scope || this;
+ var silent = opts.silent || null;
+
+ var ce = new YAHOO.util.CustomEvent(p_type, scope, silent,
+ YAHOO.util.CustomEvent.FLAT);
+ events[p_type] = ce;
+
+ if (opts.onSubscribeCallback) {
+ ce.subscribeEvent.subscribe(opts.onSubscribeCallback);
+ }
+
+ this.__yui_subscribers = this.__yui_subscribers || {};
+ var qs = this.__yui_subscribers[p_type];
+
+ if (qs) {
+ for (var i=0; i
+ * The first argument fire() was executed with
+ * The custom object (if any) that was passed into the subscribe()
+ * method
+ *
+ * @method fireEvent
+ * @param p_type {string} the type, or name of the event
+ * @param arguments {Object*} an arbitrary set of parameters to pass to
+ * the handler.
+ * @return {boolean} the return value from CustomEvent.fire, or null if
+ * the custom event does not exist.
+ */
+ fireEvent: function(p_type, arg1, arg2, etc) {
+
+ this.__yui_events = this.__yui_events || {};
+ var ce = this.__yui_events[p_type];
+
+ if (ce) {
+ var args = [];
+ for (var i=1; i0){param=args[0];}
-ret=s.fn.call(scope,param,s.obj);}else{ret=s.fn.call(scope,this.type,args,s.obj);}
-if(false===ret){if(!this.silent){}
-return false;}}}
-return true;},unsubscribeAll:function(){for(var i=0,len=this.subscribers.length;i=0){cacheItem=listeners[index];}
-if(!el||!cacheItem){return false;}
-if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);var llist=legacyHandlers[legacyIndex];if(llist){for(i=0,len=llist.length;i0);}
-var notAvail=[];for(var i=0,len=onAvailStack.length;i0){for(var i=0,len=listeners.length;i0){j=listeners.length;while(j){index=j-1;l=listeners[index];if(l){EU.removeListener(l[EU.EL],l[EU.TYPE],l[EU.FN],index);}
-j=j-1;}
-l=null;EU.clearCache();}
-for(i=0,len=legacyEvents.length;i0){param=args[0];}
+ret=s.fn.call(scope,param,s.obj);}else{ret=s.fn.call(scope,this.type,args,s.obj);}
+if(false===ret){if(!this.silent){}
+return false;}}}
+return true;},unsubscribeAll:function(){for(var i=0,len=this.subscribers.length;i=0){cacheItem=listeners[index];}
+if(!el||!cacheItem){return false;}
+if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);var llist=legacyHandlers[legacyIndex];if(llist){for(i=0,len=llist.length;i0);}
+var notAvail=[];for(var i=0,len=onAvailStack.length;i0){for(var i=0,len=listeners.length;i0){j=listeners.length;while(j){index=j-1;l=listeners[index];if(l){EU.removeListener(l[EU.EL],l[EU.TYPE],l[EU.FN],index);}
+j=j-1;}
+l=null;EU.clearCache();}
+for(i=0,len=legacyEvents.length;i
- * YAHOO.util.CustomEvent.LIST:
- *
- * param1: event name
- * param2: array of arguments sent to fire
- * param3: a custom object supplied by the subscriber
- *
- *
- * YAHOO.util.CustomEvent.FLAT
- *
- * param1: the first argument passed to fire. If you need to
- * pass multiple parameters, use and array or object literal
- * param2: a custom object supplied by the subscriber
- *
- *
- *
- * @property signature
- * @type int
- */
- this.signature = signature || YAHOO.util.CustomEvent.LIST;
-
- /**
- * The subscribers to this event
- * @property subscribers
- * @type Subscriber[]
- */
- this.subscribers = [];
-
- if (!this.silent) {
- }
-
- var onsubscribeType = "_YUICEOnSubscribe";
-
- // Only add subscribe events for events that are not generated by
- // CustomEvent
- if (type !== onsubscribeType) {
-
- /**
- * Custom events provide a custom event that fires whenever there is
- * a new subscriber to the event. This provides an opportunity to
- * handle the case where there is a non-repeating event that has
- * already fired has a new subscriber.
- *
- * @event subscribeEvent
- * @type YAHOO.util.CustomEvent
- * @param {Function} fn The function to execute
- * @param {Object} obj An object to be passed along when the event
- * fires
- * @param {boolean|Object} override If true, the obj passed in becomes
- * the execution scope of the listener.
- * if an object, that object becomes the
- * the execution scope.
- */
- this.subscribeEvent =
- new YAHOO.util.CustomEvent(onsubscribeType, this, true);
-
- }
-};
-
-/**
- * Subscriber listener sigature constant. The LIST type returns three
- * parameters: the event type, the array of args passed to fire, and
- * the optional custom object
- * @property YAHOO.util.CustomEvent.LIST
- * @static
- * @type int
- */
-YAHOO.util.CustomEvent.LIST = 0;
-
-/**
- * Subscriber listener sigature constant. The FLAT type returns two
- * parameters: the first argument passed to fire and the optional
- * custom object
- * @property YAHOO.util.CustomEvent.FLAT
- * @static
- * @type int
- */
-YAHOO.util.CustomEvent.FLAT = 1;
-
-YAHOO.util.CustomEvent.prototype = {
-
- /**
- * Subscribes the caller to this event
- * @method subscribe
- * @param {Function} fn The function to execute
- * @param {Object} obj An object to be passed along when the event
- * fires
- * @param {boolean|Object} override If true, the obj passed in becomes
- * the execution scope of the listener.
- * if an object, that object becomes the
- * the execution scope.
- */
- subscribe: function(fn, obj, override) {
- if (this.subscribeEvent) {
- this.subscribeEvent.fire(fn, obj, override);
- }
-
- this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, override) );
- },
-
- /**
- * Unsubscribes the caller from this event
- * @method unsubscribe
- * @param {Function} fn The function to execute
- * @param {Object} obj The custom object passed to subscribe (optional)
- * @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
- * 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
- *
- * @method fire
- * @param {Object*} arguments an arbitrary set of parameters to pass to
- * the handler.
- * @return {boolean} false if one of the subscribers returned false,
- * true otherwise
- */
- fire: function() {
- var len=this.subscribers.length;
- if (!len && this.silent) {
- return true;
- }
-
- var args=[], ret=true, i;
-
- for (i=0; i 0) {
- param = args[0];
- }
- ret = s.fn.call(scope, param, s.obj);
- } else {
- ret = s.fn.call(scope, this.type, args, s.obj);
- }
- if (false === ret) {
- if (!this.silent) {
- }
-
- //break;
- return false;
- }
- }
- }
-
- return true;
- },
-
- /**
- * Removes all listeners
- * @method unsubscribeAll
- */
- unsubscribeAll: function() {
- for (var i=0, len=this.subscribers.length; i= 0) {
- cacheItem = listeners[index];
- }
-
- if (!el || !cacheItem) {
- return false;
- }
-
-
- if (this.useLegacyEvent(el, sType)) {
- var legacyIndex = this.getLegacyIndex(el, sType);
- var llist = legacyHandlers[legacyIndex];
- if (llist) {
- for (i=0, len=llist.length; i 0);
- }
-
- // onAvailable
- var notAvail = [];
- for (var i=0,len=onAvailStack.length; i 0) {
- for (var i=0,len=listeners.length; i 0) {
- j = listeners.length;
- while (j) {
- index = j-1;
- l = listeners[index];
- if (l) {
- EU.removeListener(l[EU.EL], l[EU.TYPE],
- l[EU.FN], index);
- }
- j = j - 1;
- }
- l=null;
-
- EU.clearCache();
- }
-
- for (i=0,len=legacyEvents.length; i
- *
- * scope: defines the default execution scope. If not defined
- * the default scope will be this instance.
- *
- *
- * silent: if true, the custom event will not generate log messages.
- * This is false by default.
- *
- *
- * onSubscribeCallback: specifies a callback to execute when the
- * event has a new subscriber. This will fire immediately for
- * each queued subscriber if any exist prior to the creation of
- * the event.
- *
- *
- *
- * @return {CustomEvent} the custom event
- *
- */
- createEvent: function(p_type, p_config) {
-
- this.__yui_events = this.__yui_events || {};
- var opts = p_config || {};
- var events = this.__yui_events;
-
- if (events[p_type]) {
- } else {
-
- var scope = opts.scope || this;
- var silent = opts.silent || null;
-
- var ce = new YAHOO.util.CustomEvent(p_type, scope, silent,
- YAHOO.util.CustomEvent.FLAT);
- events[p_type] = ce;
-
- if (opts.onSubscribeCallback) {
- ce.subscribeEvent.subscribe(opts.onSubscribeCallback);
- }
-
- this.__yui_subscribers = this.__yui_subscribers || {};
- var qs = this.__yui_subscribers[p_type];
-
- if (qs) {
- for (var i=0; i
- * The first argument fire() was executed with
- * The custom object (if any) that was passed into the subscribe()
- * method
- *
- * @method fireEvent
- * @param p_type {string} the type, or name of the event
- * @param arguments {Object*} an arbitrary set of parameters to pass to
- * the handler.
- * @return {boolean} the return value from CustomEvent.fire, or null if
- * the custom event does not exist.
- */
- fireEvent: function(p_type, arg1, arg2, etc) {
-
- this.__yui_events = this.__yui_events || {};
- var ce = this.__yui_events[p_type];
-
- if (ce) {
- var args = [];
- for (var i=1; i
+ * YAHOO.util.CustomEvent.LIST:
+ *
+ * param1: event name
+ * param2: array of arguments sent to fire
+ * param3: a custom object supplied by the subscriber
+ *
+ *
+ * YAHOO.util.CustomEvent.FLAT
+ *
+ * param1: the first argument passed to fire. If you need to
+ * pass multiple parameters, use and array or object literal
+ * param2: a custom object supplied by the subscriber
+ *
+ *
+ *
+ * @property signature
+ * @type int
+ */
+ this.signature = signature || YAHOO.util.CustomEvent.LIST;
+
+ /**
+ * The subscribers to this event
+ * @property subscribers
+ * @type Subscriber[]
+ */
+ this.subscribers = [];
+
+ if (!this.silent) {
+ }
+
+ var onsubscribeType = "_YUICEOnSubscribe";
+
+ // Only add subscribe events for events that are not generated by
+ // CustomEvent
+ if (type !== onsubscribeType) {
+
+ /**
+ * Custom events provide a custom event that fires whenever there is
+ * a new subscriber to the event. This provides an opportunity to
+ * handle the case where there is a non-repeating event that has
+ * already fired has a new subscriber.
+ *
+ * @event subscribeEvent
+ * @type YAHOO.util.CustomEvent
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event
+ * fires
+ * @param {boolean|Object} override If true, the obj passed in becomes
+ * the execution scope of the listener.
+ * if an object, that object becomes the
+ * the execution scope.
+ */
+ this.subscribeEvent =
+ new YAHOO.util.CustomEvent(onsubscribeType, this, true);
+
+ }
+};
+
+/**
+ * Subscriber listener sigature constant. The LIST type returns three
+ * parameters: the event type, the array of args passed to fire, and
+ * the optional custom object
+ * @property YAHOO.util.CustomEvent.LIST
+ * @static
+ * @type int
+ */
+YAHOO.util.CustomEvent.LIST = 0;
+
+/**
+ * Subscriber listener sigature constant. The FLAT type returns two
+ * parameters: the first argument passed to fire and the optional
+ * custom object
+ * @property YAHOO.util.CustomEvent.FLAT
+ * @static
+ * @type int
+ */
+YAHOO.util.CustomEvent.FLAT = 1;
+
+YAHOO.util.CustomEvent.prototype = {
+
+ /**
+ * Subscribes the caller to this event
+ * @method subscribe
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event
+ * fires
+ * @param {boolean|Object} override If true, the obj passed in becomes
+ * the execution scope of the listener.
+ * if an object, that object becomes the
+ * the execution scope.
+ */
+ subscribe: function(fn, obj, override) {
+ if (this.subscribeEvent) {
+ this.subscribeEvent.fire(fn, obj, override);
+ }
+
+ this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, override) );
+ },
+
+ /**
+ * Unsubscribes the caller from this event
+ * @method unsubscribe
+ * @param {Function} fn The function to execute
+ * @param {Object} obj The custom object passed to subscribe (optional)
+ * @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
+ * 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
+ *
+ * @method fire
+ * @param {Object*} arguments an arbitrary set of parameters to pass to
+ * the handler.
+ * @return {boolean} false if one of the subscribers returned false,
+ * true otherwise
+ */
+ fire: function() {
+ var len=this.subscribers.length;
+ if (!len && this.silent) {
+ return true;
+ }
+
+ var args=[], ret=true, i;
+
+ for (i=0; i 0) {
+ param = args[0];
+ }
+ ret = s.fn.call(scope, param, s.obj);
+ } else {
+ ret = s.fn.call(scope, this.type, args, s.obj);
+ }
+ if (false === ret) {
+ if (!this.silent) {
+ }
+
+ //break;
+ return false;
+ }
+ }
+ }
+
+ return true;
+ },
+
+ /**
+ * Removes all listeners
+ * @method unsubscribeAll
+ */
+ unsubscribeAll: function() {
+ for (var i=0, len=this.subscribers.length; i= 0) {
+ cacheItem = listeners[index];
+ }
+
+ if (!el || !cacheItem) {
+ return false;
+ }
+
+
+ if (this.useLegacyEvent(el, sType)) {
+ var legacyIndex = this.getLegacyIndex(el, sType);
+ var llist = legacyHandlers[legacyIndex];
+ if (llist) {
+ for (i=0, len=llist.length; i 0);
+ }
+
+ // onAvailable
+ var notAvail = [];
+ for (var i=0,len=onAvailStack.length; i 0) {
+ for (var i=0,len=listeners.length; i 0) {
+ j = listeners.length;
+ while (j) {
+ index = j-1;
+ l = listeners[index];
+ if (l) {
+ EU.removeListener(l[EU.EL], l[EU.TYPE],
+ l[EU.FN], index);
+ }
+ j = j - 1;
+ }
+ l=null;
+
+ EU.clearCache();
+ }
+
+ for (i=0,len=legacyEvents.length; i
+ *
+ * scope: defines the default execution scope. If not defined
+ * the default scope will be this instance.
+ *
+ *
+ * silent: if true, the custom event will not generate log messages.
+ * This is false by default.
+ *
+ *
+ * onSubscribeCallback: specifies a callback to execute when the
+ * event has a new subscriber. This will fire immediately for
+ * each queued subscriber if any exist prior to the creation of
+ * the event.
+ *
+ *
+ *
+ * @return {CustomEvent} the custom event
+ *
+ */
+ createEvent: function(p_type, p_config) {
+
+ this.__yui_events = this.__yui_events || {};
+ var opts = p_config || {};
+ var events = this.__yui_events;
+
+ if (events[p_type]) {
+ } else {
+
+ var scope = opts.scope || this;
+ var silent = opts.silent || null;
+
+ var ce = new YAHOO.util.CustomEvent(p_type, scope, silent,
+ YAHOO.util.CustomEvent.FLAT);
+ events[p_type] = ce;
+
+ if (opts.onSubscribeCallback) {
+ ce.subscribeEvent.subscribe(opts.onSubscribeCallback);
+ }
+
+ this.__yui_subscribers = this.__yui_subscribers || {};
+ var qs = this.__yui_subscribers[p_type];
+
+ if (qs) {
+ for (var i=0; i
+ * The first argument fire() was executed with
+ * The custom object (if any) that was passed into the subscribe()
+ * method
+ *
+ * @method fireEvent
+ * @param p_type {string} the type, or name of the event
+ * @param arguments {Object*} an arbitrary set of parameters to pass to
+ * the handler.
+ * @return {boolean} the return value from CustomEvent.fire, or null if
+ * the custom event does not exist.
+ */
+ fireEvent: function(p_type, arg1, arg2, etc) {
+
+ this.__yui_events = this.__yui_events || {};
+ var ce = this.__yui_events[p_type];
+
+ if (ce) {
+ var args = [];
+ for (var i=1; i", label, " ",
- totalTime, "ms (+", elapsedTime, ") ",
- localTime, ": ",
- "",
- sourceAndDetail,
- ":
",
- msg,
- "
"] :
-
- ["", label, " ",
- totalTime, "ms (+", elapsedTime, ") ",
- localTime, ": ",
- sourceAndDetail, ": ",
- msg,"
"];
-
- return output.join("");
-};
-
-/**
- * Converts input chars "<", ">", and "&" to HTML entities.
- *
- * @method html2Text
- * @param sHtml {String} String to convert.
- * @private
- */
-YAHOO.widget.LogReader.prototype.html2Text = function(sHtml) {
- if(sHtml) {
- sHtml += "";
- return sHtml.replace(/&/g, "&").replace(//g, ">");
- }
- return "";
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Internal class member to index multiple log reader instances.
- *
- * @property _memberName
- * @static
- * @type Number
- * @default 0
- * @private
- */
-YAHOO.widget.LogReader._index = 0;
-
-/**
- * Name of LogReader instance.
- *
- * @property _sName
- * @type String
- * @private
- */
-YAHOO.widget.LogReader.prototype._sName = null;
-
-/**
- * A class member shared by all log readers if a container needs to be
- * created during instantiation. Will be null if a container element never needs to
- * be created on the fly, such as when the implementer passes in their own element.
- *
- * @property _elDefaultContainer
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader._elDefaultContainer = null;
-
-/**
- * Buffer of log message objects for batch output.
- *
- * @property _buffer
- * @type Object[]
- * @private
- */
-YAHOO.widget.LogReader.prototype._buffer = null;
-
-/**
- * Number of log messages output to console.
- *
- * @property _consoleMsgCount
- * @type Number
- * @default 0
- * @private
- */
-YAHOO.widget.LogReader.prototype._consoleMsgCount = 0;
-
-/**
- * Date of last output log message.
- *
- * @property _lastTime
- * @type Date
- * @private
- */
-YAHOO.widget.LogReader.prototype._lastTime = null;
-
-/**
- * Batched output timeout ID.
- *
- * @property _timeout
- * @type Number
- * @private
- */
-YAHOO.widget.LogReader.prototype._timeout = null;
-
-/**
- * Array of filters for log message categories.
- *
- * @property _categoryFilters
- * @type String[]
- * @private
- */
-YAHOO.widget.LogReader.prototype._categoryFilters = null;
-
-/**
- * Array of filters for log message sources.
- *
- * @property _sourceFilters
- * @type String[]
- * @private
- */
-YAHOO.widget.LogReader.prototype._sourceFilters = null;
-
-/**
- * Log reader container element.
- *
- * @property _elContainer
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elContainer = null;
-
-/**
- * Log reader header element.
- *
- * @property _elHd
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elHd = null;
-
-/**
- * Log reader collapse element.
- *
- * @property _elCollapse
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elCollapse = null;
-
-/**
- * Log reader collapse button element.
- *
- * @property _btnCollapse
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._btnCollapse = null;
-
-/**
- * Log reader title header element.
- *
- * @property _title
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._title = null;
-
-/**
- * Log reader console element.
- *
- * @property _elConsole
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elConsole = null;
-
-/**
- * Log reader footer element.
- *
- * @property _elFt
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elFt = null;
-
-/**
- * Log reader buttons container element.
- *
- * @property _elBtns
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elBtns = null;
-
-/**
- * Container element for log reader category filter checkboxes.
- *
- * @property _elCategoryFilters
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elCategoryFilters = null;
-
-/**
- * Container element for log reader source filter checkboxes.
- *
- * @property _elSourceFilters
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elSourceFilters = null;
-
-/**
- * Log reader pause button element.
- *
- * @property _btnPause
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._btnPause = null;
-
-/**
- * Clear button element.
- *
- * @property _btnClear
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._btnClear = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Creates the UI for a category filter in the log reader footer element.
- *
- * @method _createCategoryCheckbox
- * @param sCategory {String} Category name.
- * @private
- */
-YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(sCategory) {
- var oSelf = this;
-
- if(this._elFt) {
- var elParent = this._elCategoryFilters;
- var filters = this._categoryFilters;
-
- var elFilter = elParent.appendChild(document.createElement("span"));
- elFilter.className = "yui-log-filtergrp";
- // Append el at the end so IE 5.5 can set "type" attribute
- // and THEN set checked property
- var chkCategory = document.createElement("input");
- chkCategory.id = "yui-log-filter-" + sCategory + this._sName;
- chkCategory.className = "yui-log-filter-" + sCategory;
- chkCategory.type = "checkbox";
- chkCategory.category = sCategory;
- chkCategory = elFilter.appendChild(chkCategory);
- chkCategory.checked = true;
-
- // Add this checked filter to the internal array of filters
- filters.push(sCategory);
- // Subscribe to the click event
- YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf);
-
- // Create and class the text label
- var lblCategory = elFilter.appendChild(document.createElement("label"));
- lblCategory.htmlFor = chkCategory.id;
- lblCategory.className = sCategory;
- lblCategory.innerHTML = sCategory;
- }
-};
-
-/**
- * Creates a checkbox in the log reader footer element to filter by source.
- *
- * @method _createSourceCheckbox
- * @param sSource {String} Source name.
- * @private
- */
-YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(sSource) {
- var oSelf = this;
-
- if(this._elFt) {
- var elParent = this._elSourceFilters;
- var filters = this._sourceFilters;
-
- var elFilter = elParent.appendChild(document.createElement("span"));
- elFilter.className = "yui-log-filtergrp";
-
- // Append el at the end so IE 5.5 can set "type" attribute
- // and THEN set checked property
- var chkSource = document.createElement("input");
- chkSource.id = "yui-log-filter" + sSource + this._sName;
- chkSource.className = "yui-log-filter" + sSource;
- chkSource.type = "checkbox";
- chkSource.source = sSource;
- chkSource = elFilter.appendChild(chkSource);
- chkSource.checked = true;
-
- // Add this checked filter to the internal array of filters
- filters.push(sSource);
- // Subscribe to the click event
- YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf);
-
- // Create and class the text label
- var lblSource = elFilter.appendChild(document.createElement("label"));
- lblSource.htmlFor = chkSource.id;
- lblSource.className = sSource;
- lblSource.innerHTML = sSource;
- }
-};
-
-/**
- * Reprints all log messages in the stack through filters.
- *
- * @method _filterLogs
- * @private
- */
-YAHOO.widget.LogReader.prototype._filterLogs = function() {
- // Reprint stack with new filters
- if (this._elConsole !== null) {
- this._clearConsole();
- this._printToConsole(YAHOO.widget.Logger.getStack());
- }
-};
-
-/**
- * Clears all outputted log messages from the console and resets the time of the
- * last output log message.
- *
- * @method _clearConsole
- * @private
- */
-YAHOO.widget.LogReader.prototype._clearConsole = function() {
- // Clear the buffer of any pending messages
- this._timeout = null;
- this._buffer = [];
- this._consoleMsgCount = 0;
-
- // Reset the rolling timer
- this._lastTime = YAHOO.widget.Logger.getStartTime();
-
- var elConsole = this._elConsole;
- while(elConsole.hasChildNodes()) {
- elConsole.removeChild(elConsole.firstChild);
- }
-};
-
-/**
- * Sends buffer of log messages to output and clears buffer.
- *
- * @method _printBuffer
- * @private
- */
-YAHOO.widget.LogReader.prototype._printBuffer = function() {
- this._timeout = null;
-
- if(this._elConsole !== null) {
- var thresholdMax = this.thresholdMax;
- thresholdMax = (thresholdMax && !isNaN(thresholdMax)) ? thresholdMax : 500;
- if(this._consoleMsgCount < thresholdMax) {
- var entries = [];
- for (var i=0; i this.thresholdMax)) {
- thresholdMin = 0;
- }
- var entriesStartIndex = (entriesLen > thresholdMin) ? (entriesLen - thresholdMin) : 0;
-
- // Iterate through all log entries
- var sourceFiltersLen = this._sourceFilters.length;
- var categoryFiltersLen = this._categoryFilters.length;
- for(var i=entriesStartIndex; i tag instead of tag (for wrapping)
- var container = (this.verboseOutput) ? "CODE" : "PRE";
- var oNewElement = (this.newestOnTop) ?
- this._elConsole.insertBefore(
- document.createElement(container),this._elConsole.firstChild):
- this._elConsole.appendChild(document.createElement(container));
-
- oNewElement.innerHTML = output;
- this._consoleMsgCount++;
- this._lastTime = entry.time.getTime();
- }
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles Logger's categoryCreateEvent.
- *
- * @method _onCategoryCreate
- * @param sType {String} The event.
- * @param aArgs {Object[]} Data passed from event firer.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onCategoryCreate = function(sType, aArgs, oSelf) {
- var category = aArgs[0];
- if(oSelf._elFt) {
- oSelf._createCategoryCheckbox(category);
- }
-};
-
-/**
- * Handles Logger's sourceCreateEvent.
- *
- * @method _onSourceCreate
- * @param sType {String} The event.
- * @param aArgs {Object[]} Data passed from event firer.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onSourceCreate = function(sType, aArgs, oSelf) {
- var source = aArgs[0];
- if(oSelf._elFt) {
- oSelf._createSourceCheckbox(source);
- }
-};
-
-/**
- * Handles check events on the category filter checkboxes.
- *
- * @method _onCheckCategory
- * @param v {HTMLEvent} The click event.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onCheckCategory = function(v, oSelf) {
- var newFilter = this.category;
- var filtersArray = oSelf._categoryFilters;
-
- if(!this.checked) { // Remove category from filters
- for(var i=0; i 0) {
- // Substring until first space
- sClass = sSource.substring(0,spaceIndex);
- // The rest of the source
- sDetail = sSource.substring(spaceIndex,sSource.length);
- }
- else {
- sClass = sSource;
- }
- if(this._isNewSource(sClass)) {
- this._createNewSource(sClass);
- }
- }
-
- var timestamp = new Date();
- var logEntry = new YAHOO.widget.LogMsg({
- msg: sMsg,
- time: timestamp,
- category: sCategory,
- source: sClass,
- sourceDetail: sDetail
- });
-
- var stack = this._stack;
- var maxStackEntries = this.maxStackEntries;
- if(maxStackEntries && !isNaN(maxStackEntries) &&
- (stack.length >= maxStackEntries)) {
- stack.shift();
- }
- stack.push(logEntry);
- this.newLogEvent.fire(logEntry);
-
- if(this._browserConsoleEnabled) {
- this._printToBrowserConsole(logEntry);
- }
- return true;
- }
- else {
- return false;
- }
-};
-
-/**
- * Resets internal stack and startTime, enables Logger, and fires logResetEvent.
- *
- * @method reset
- */
-YAHOO.widget.Logger.reset = function() {
- this._stack = [];
- this._startTime = new Date().getTime();
- this.loggerEnabled = true;
- this.log("Logger reset");
- this.logResetEvent.fire();
-};
-
-/**
- * Public accessor to internal stack of log message objects.
- *
- * @method getStack
- * @return {Object[]} Array of log message objects.
- */
-YAHOO.widget.Logger.getStack = function() {
- return this._stack;
-};
-
-/**
- * Public accessor to internal start time.
- *
- * @method getStartTime
- * @return {Date} Internal date of when Logger singleton was initialized.
- */
-YAHOO.widget.Logger.getStartTime = function() {
- return this._startTime;
-};
-
-/**
- * Disables output to the browser's global console.log() function, which is used
- * by the Firebug extension to Firefox as well as Safari.
- *
- * @method disableBrowserConsole
- */
-YAHOO.widget.Logger.disableBrowserConsole = function() {
- YAHOO.log("Logger output to the function console.log() has been disabled.");
- this._browserConsoleEnabled = false;
-};
-
-/**
- * Enables output to the browser's global console.log() function, which is used
- * by the Firebug extension to Firefox as well as Safari.
- *
- * @method enableBrowserConsole
- */
-YAHOO.widget.Logger.enableBrowserConsole = function() {
- this._browserConsoleEnabled = true;
- YAHOO.log("Logger output to the function console.log() has been enabled.");
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Fired when a new category has been created.
- *
- * @event categoryCreateEvent
- * @param sCategory {String} Category name.
- */
-YAHOO.widget.Logger.categoryCreateEvent =
- new YAHOO.util.CustomEvent("categoryCreate", this, true);
-
- /**
- * Fired when a new source has been named.
- *
- * @event sourceCreateEvent
- * @param sSource {String} Source name.
- */
-YAHOO.widget.Logger.sourceCreateEvent =
- new YAHOO.util.CustomEvent("sourceCreate", this, true);
-
- /**
- * Fired when a new log message has been created.
- *
- * @event newLogEvent
- * @param sMsg {String} Log message.
- */
-YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true);
-
-/**
- * Fired when the Logger has been reset has been created.
- *
- * @event logResetEvent
- */
-YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true);
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Creates a new category of log messages and fires categoryCreateEvent.
- *
- * @method _createNewCategory
- * @param sCategory {String} Category name.
- * @private
- */
-YAHOO.widget.Logger._createNewCategory = function(sCategory) {
- this.categories.push(sCategory);
- this.categoryCreateEvent.fire(sCategory);
-};
-
-/**
- * Checks to see if a category has already been created.
- *
- * @method _isNewCategory
- * @param sCategory {String} Category name.
- * @return {Boolean} Returns true if category is unknown, else returns false.
- * @private
- */
-YAHOO.widget.Logger._isNewCategory = function(sCategory) {
- for(var i=0; i < this.categories.length; i++) {
- if(sCategory == this.categories[i]) {
- return false;
- }
- }
- return true;
-};
-
-/**
- * Creates a new source of log messages and fires sourceCreateEvent.
- *
- * @method _createNewSource
- * @param sSource {String} Source name.
- * @private
- */
-YAHOO.widget.Logger._createNewSource = function(sSource) {
- this.sources.push(sSource);
- this.sourceCreateEvent.fire(sSource);
-};
-
-/**
- * Checks to see if a source already exists.
- *
- * @method _isNewSource
- * @param sSource {String} Source name.
- * @return {Boolean} Returns true if source is unknown, else returns false.
- * @private
- */
-YAHOO.widget.Logger._isNewSource = function(sSource) {
- if(sSource) {
- for(var i=0; i < this.sources.length; i++) {
- if(sSource == this.sources[i]) {
- return false;
- }
- }
- return true;
- }
-};
-
-/**
- * Outputs a log message to global console.log() function.
- *
- * @method _printToBrowserConsole
- * @param oEntry {Object} Log entry object.
- * @private
- */
-YAHOO.widget.Logger._printToBrowserConsole = function(oEntry) {
- if(window.console && console.log) {
- var category = oEntry.category;
- var label = oEntry.category.substring(0,4).toUpperCase();
-
- var time = oEntry.time;
- if (time.toLocaleTimeString) {
- var localTime = time.toLocaleTimeString();
- }
- else {
- localTime = time.toString();
- }
-
- var msecs = time.getTime();
- var elapsedTime = (YAHOO.widget.Logger._lastTime) ?
- (msecs - YAHOO.widget.Logger._lastTime) : 0;
- YAHOO.widget.Logger._lastTime = msecs;
-
- var output =
- localTime + " (" +
- elapsedTime + "ms): " +
- oEntry.source + ": " +
- oEntry.msg;
-
- console.log(output);
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles logging of messages due to window error events.
- *
- * @method _onWindowError
- * @param sMsg {String} The error message.
- * @param sUrl {String} URL of the error.
- * @param sLine {String} Line number of the error.
- * @private
- */
-YAHOO.widget.Logger._onWindowError = function(sMsg,sUrl,sLine) {
- // Logger is not in scope of this event handler
- try {
- YAHOO.widget.Logger.log(sMsg+' ('+sUrl+', line '+sLine+')', "window");
- if(YAHOO.widget.Logger._origOnWindowError) {
- YAHOO.widget.Logger._origOnWindowError();
- }
- }
- catch(e) {
- return false;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Enable handling of native JavaScript errors
-// NB: Not all browsers support the window.onerror event
-//
-/////////////////////////////////////////////////////////////////////////////
-
-if(window.onerror) {
- // Save any previously defined handler to call
- YAHOO.widget.Logger._origOnWindowError = window.onerror;
-}
-window.onerror = YAHOO.widget.Logger._onWindowError;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// First log
-//
-/////////////////////////////////////////////////////////////////////////////
-
-YAHOO.widget.Logger.log("Logger initialized");
-
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogMsg class defines a single log message.
+ *
+ * @class LogMsg
+ * @constructor
+ * @param oConfigs {Object} Object literal of configuration params.
+ */
+ YAHOO.widget.LogMsg = function(oConfigs) {
+ // Parse configs
+ if (typeof oConfigs == "object") {
+ for(var param in oConfigs) {
+ this[param] = oConfigs[param];
+ }
+ }
+ };
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Log message.
+ *
+ * @property msg
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.msg = null;
+
+/**
+ * Log timestamp.
+ *
+ * @property time
+ * @type Date
+ */
+YAHOO.widget.LogMsg.prototype.time = null;
+
+/**
+ * Log category.
+ *
+ * @property category
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.category = null;
+
+/**
+ * Log source. The first word passed in as the source argument.
+ *
+ * @property source
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.source = null;
+
+/**
+ * Log source detail. The remainder of the string passed in as the source argument, not
+ * including the first word (if any).
+ *
+ * @property sourceDetail
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.sourceDetail = null;
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogWriter class provides a mechanism to log messages through
+ * YAHOO.widget.Logger from a named source.
+ *
+ * @class LogWriter
+ * @constructor
+ * @param sSource {String} Source of LogWriter instance.
+ */
+YAHOO.widget.LogWriter = function(sSource) {
+ if(!sSource) {
+ YAHOO.log("Could not instantiate LogWriter due to invalid source.",
+ "error", "LogWriter");
+ return;
+ }
+ this._source = sSource;
+ };
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the LogWriter instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the LogWriter instance.
+ */
+YAHOO.widget.LogWriter.prototype.toString = function() {
+ return "LogWriter " + this._sSource;
+};
+
+/**
+ * Logs a message attached to the source of the LogWriter.
+ *
+ * @method log
+ * @param sMsg {String} The log message.
+ * @param sCategory {String} Category name.
+ */
+YAHOO.widget.LogWriter.prototype.log = function(sMsg, sCategory) {
+ YAHOO.widget.Logger.log(sMsg, sCategory, this._source);
+};
+
+/**
+ * Public accessor to get the source name.
+ *
+ * @method getSource
+ * @return {String} The LogWriter source.
+ */
+YAHOO.widget.LogWriter.prototype.getSource = function() {
+ return this._sSource;
+};
+
+/**
+ * Public accessor to set the source name.
+ *
+ * @method setSource
+ * @param sSource {String} Source of LogWriter instance.
+ */
+YAHOO.widget.LogWriter.prototype.setSource = function(sSource) {
+ if(!sSource) {
+ YAHOO.log("Could not set source due to invalid source.", "error", this.toString());
+ return;
+ }
+ else {
+ this._sSource = sSource;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Source of the LogWriter instance.
+ *
+ * @property _source
+ * @type String
+ * @private
+ */
+YAHOO.widget.LogWriter.prototype._source = null;
+
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogReader class provides UI to read messages logged to YAHOO.widget.Logger.
+ *
+ * @class LogReader
+ * @constructor
+ * @param elContainer {HTMLElement} (optional) DOM element reference of an existing DIV.
+ * @param elContainer {String} (optional) String ID of an existing DIV.
+ * @param oConfigs {Object} (optional) Object literal of configuration params.
+ */
+YAHOO.widget.LogReader = function(elContainer, oConfigs) {
+ var oSelf = this;
+ this._sName = YAHOO.widget.LogReader._index;
+ YAHOO.widget.LogReader._index++;
+
+ // Parse config vars here
+ if (typeof oConfigs == "object") {
+ for(var param in oConfigs) {
+ this[param] = oConfigs[param];
+ }
+ }
+
+ // Attach container...
+ if(elContainer) {
+ if(typeof elContainer == "string") {
+ this._elContainer = document.getElementById(elContainer);
+ }
+ else if(elContainer.tagName) {
+ this._elContainer = elContainer;
+ }
+ this._elContainer.className = "yui-log";
+ }
+ // ...or create container from scratch
+ if(!this._elContainer) {
+ if(YAHOO.widget.LogReader._elDefaultContainer) {
+ this._elContainer = YAHOO.widget.LogReader._elDefaultContainer;
+ }
+ else {
+ this._elContainer = document.body.appendChild(document.createElement("div"));
+ this._elContainer.id = "yui-log";
+ this._elContainer.className = "yui-log";
+
+ YAHOO.widget.LogReader._elDefaultContainer = this._elContainer;
+ }
+
+ // If implementer has provided container values, trust and set those
+ var containerStyle = this._elContainer.style;
+ if(this.width) {
+ containerStyle.width = this.width;
+ }
+ if(this.right) {
+ containerStyle.right = this.right;
+ }
+ if(this.top) {
+ containerStyle.top = this.top;
+ }
+ if(this.left) {
+ containerStyle.left = this.left;
+ containerStyle.right = "auto";
+ }
+ if(this.bottom) {
+ containerStyle.bottom = this.bottom;
+ containerStyle.top = "auto";
+ }
+ if(this.fontSize) {
+ containerStyle.fontSize = this.fontSize;
+ }
+ if(window.opera) {
+ document.body.style += '';
+ }
+ }
+
+ if(this._elContainer) {
+ // Create header
+ if(!this._elHd) {
+ this._elHd = this._elContainer.appendChild(document.createElement("div"));
+ this._elHd.id = "yui-log-hd" + this._sName;
+ this._elHd.className = "yui-log-hd";
+
+ this._elCollapse = this._elHd.appendChild(document.createElement("div"));
+ this._elCollapse.className = "yui-log-btns";
+
+ this._btnCollapse = document.createElement("input");
+ this._btnCollapse.type = "button";
+ this._btnCollapse.style.fontSize =
+ YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");
+ this._btnCollapse.className = "yui-log-button";
+ this._btnCollapse.value = "Collapse";
+ this._btnCollapse = this._elCollapse.appendChild(this._btnCollapse);
+ YAHOO.util.Event.addListener(
+ oSelf._btnCollapse,'click',oSelf._onClickCollapseBtn,oSelf);
+
+ this._title = this._elHd.appendChild(document.createElement("h4"));
+ this._title.innerHTML = "Logger Console";
+
+ // If Drag and Drop utility is available...
+ // ...and this container was created from scratch...
+ // ...then make the header draggable
+ if(YAHOO.util.DD &&
+ (YAHOO.widget.LogReader._elDefaultContainer == this._elContainer)) {
+ var ylog_dd = new YAHOO.util.DD(this._elContainer.id);
+ ylog_dd.setHandleElId(this._elHd.id);
+ this._elHd.style.cursor = "move";
+ }
+ }
+ // Ceate console
+ if(!this._elConsole) {
+ this._elConsole =
+ this._elContainer.appendChild(document.createElement("div"));
+ this._elConsole.className = "yui-log-bd";
+
+ // If implementer has provided console, trust and set those
+ if(this.height) {
+ this._elConsole.style.height = this.height;
+ }
+ }
+ // Don't create footer if disabled
+ if(!this._elFt && this.footerEnabled) {
+ this._elFt = this._elContainer.appendChild(document.createElement("div"));
+ this._elFt.className = "yui-log-ft";
+
+ this._elBtns = this._elFt.appendChild(document.createElement("div"));
+ this._elBtns.className = "yui-log-btns";
+
+ this._btnPause = document.createElement("input");
+ this._btnPause.type = "button";
+ this._btnPause.style.fontSize =
+ YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");
+ this._btnPause.className = "yui-log-button";
+ this._btnPause.value = "Pause";
+ this._btnPause = this._elBtns.appendChild(this._btnPause);
+ YAHOO.util.Event.addListener(
+ oSelf._btnPause,'click',oSelf._onClickPauseBtn,oSelf);
+
+ this._btnClear = document.createElement("input");
+ this._btnClear.type = "button";
+ this._btnClear.style.fontSize =
+ YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");
+ this._btnClear.className = "yui-log-button";
+ this._btnClear.value = "Clear";
+ this._btnClear = this._elBtns.appendChild(this._btnClear);
+ YAHOO.util.Event.addListener(
+ oSelf._btnClear,'click',oSelf._onClickClearBtn,oSelf);
+
+ this._elCategoryFilters = this._elFt.appendChild(document.createElement("div"));
+ this._elCategoryFilters.className = "yui-log-categoryfilters";
+ this._elSourceFilters = this._elFt.appendChild(document.createElement("div"));
+ this._elSourceFilters.className = "yui-log-sourcefilters";
+ }
+ }
+
+ // Initialize internal vars
+ if(!this._buffer) {
+ this._buffer = []; // output buffer
+ }
+ // Timestamp of last log message to console
+ this._lastTime = YAHOO.widget.Logger.getStartTime();
+
+ // Subscribe to Logger custom events
+ YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog, this);
+ YAHOO.widget.Logger.logResetEvent.subscribe(this._onReset, this);
+
+ // Initialize category filters
+ this._categoryFilters = [];
+ var catsLen = YAHOO.widget.Logger.categories.length;
+ if(this._elCategoryFilters) {
+ for(var i=0; i < catsLen; i++) {
+ this._createCategoryCheckbox(YAHOO.widget.Logger.categories[i]);
+ }
+ }
+ // Initialize source filters
+ this._sourceFilters = [];
+ var sourcesLen = YAHOO.widget.Logger.sources.length;
+ if(this._elSourceFilters) {
+ for(var j=0; j < sourcesLen; j++) {
+ this._createSourceCheckbox(YAHOO.widget.Logger.sources[j]);
+ }
+ }
+ YAHOO.widget.Logger.categoryCreateEvent.subscribe(this._onCategoryCreate, this);
+ YAHOO.widget.Logger.sourceCreateEvent.subscribe(this._onSourceCreate, this);
+
+ this._filterLogs();
+ YAHOO.log("LogReader initialized", null, this.toString());
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Whether or not the log reader is enabled to output log messages.
+ *
+ * @property logReaderEnabled
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.logReaderEnabled = true;
+
+/**
+ * Public member to access CSS width of the log reader container.
+ *
+ * @property width
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.width = null;
+
+/**
+ * Public member to access CSS height of the log reader container.
+ *
+ * @property height
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.height = null;
+
+/**
+ * Public member to access CSS top position of the log reader container.
+ *
+ * @property top
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.top = null;
+
+/**
+ * Public member to access CSS left position of the log reader container.
+ *
+ * @property left
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.left = null;
+
+/**
+ * Public member to access CSS right position of the log reader container.
+ *
+ * @property right
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.right = null;
+
+/**
+ * Public member to access CSS bottom position of the log reader container.
+ *
+ * @property bottom
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.bottom = null;
+
+/**
+ * Public member to access CSS font size of the log reader container.
+ *
+ * @property fontSize
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.fontSize = null;
+
+/**
+ * Whether or not the footer UI is enabled for the log reader.
+ *
+ * @property footerEnabled
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.footerEnabled = true;
+
+/**
+ * Whether or not output is verbose (more readable). Setting to true will make
+ * output more compact (less readable).
+ *
+ * @property verboseOutput
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.verboseOutput = true;
+
+/**
+ * Whether or not newest message is printed on top.
+ *
+ * @property newestOnTop
+ * @type Boolean
+ */
+YAHOO.widget.LogReader.prototype.newestOnTop = true;
+
+/**
+ * Maximum number of messages a LogReader console will display.
+ *
+ * @property thresholdMax
+ * @type Number
+ * @default 500
+ */
+YAHOO.widget.LogReader.prototype.thresholdMax = 500;
+
+/**
+ * When a LogReader console reaches its thresholdMax, it will clear out messages
+ * and print out the latest thresholdMin number of messages.
+ *
+ * @property thresholdMin
+ * @type Number
+ * @default 100
+ */
+YAHOO.widget.LogReader.prototype.thresholdMin = 100;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the LogReader instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the LogReader instance.
+ */
+YAHOO.widget.LogReader.prototype.toString = function() {
+ return "LogReader instance" + this._sName;
+};
+/**
+ * Pauses output of log messages. While paused, log messages are not lost, but
+ * get saved to a buffer and then output upon resume of log reader.
+ *
+ * @method pause
+ */
+YAHOO.widget.LogReader.prototype.pause = function() {
+ this._timeout = null;
+ this.logReaderEnabled = false;
+};
+
+/**
+ * Resumes output of log messages, including outputting any log messages that
+ * have been saved to buffer while paused.
+ *
+ * @method resume
+ */
+YAHOO.widget.LogReader.prototype.resume = function() {
+ this.logReaderEnabled = true;
+ this._printBuffer();
+};
+
+/**
+ * Hides UI of log reader. Logging functionality is not disrupted.
+ *
+ * @method hide
+ */
+YAHOO.widget.LogReader.prototype.hide = function() {
+ this._elContainer.style.display = "none";
+};
+
+/**
+ * Shows UI of log reader. Logging functionality is not disrupted.
+ *
+ * @method show
+ */
+YAHOO.widget.LogReader.prototype.show = function() {
+ this._elContainer.style.display = "block";
+};
+
+/**
+ * Updates title to given string.
+ *
+ * @method setTitle
+ * @param sTitle {String} New title.
+ */
+YAHOO.widget.LogReader.prototype.setTitle = function(sTitle) {
+ this._title.innerHTML = this.html2Text(sTitle);
+};
+
+/**
+ * Gets timestamp of the last log.
+ *
+ * @method getLastTime
+ * @return {Date} Timestamp of the last log.
+ */
+YAHOO.widget.LogReader.prototype.getLastTime = function() {
+ return this._lastTime;
+};
+
+/**
+ * Formats message string to HTML for output to console.
+ *
+ * @method formatMsg
+ * @param oLogMsg {Object} Log message object.
+ * @return {String} HTML-formatted message for output to console.
+ */
+YAHOO.widget.LogReader.prototype.formatMsg = function(oLogMsg) {
+ var category = oLogMsg.category;
+
+ // Label for color-coded display
+ var label = category.substring(0,4).toUpperCase();
+
+ // Calculate the elapsed time to be from the last item that passed through the filter,
+ // not the absolute previous item in the stack
+
+ var time = oLogMsg.time;
+ if (time.toLocaleTimeString) {
+ var localTime = time.toLocaleTimeString();
+ }
+ else {
+ localTime = time.toString();
+ }
+
+ var msecs = time.getTime();
+ var startTime = YAHOO.widget.Logger.getStartTime();
+ var totalTime = msecs - startTime;
+ var elapsedTime = msecs - this.getLastTime();
+
+ var source = oLogMsg.source;
+ var sourceDetail = oLogMsg.sourceDetail;
+ var sourceAndDetail = (sourceDetail) ?
+ source + " " + sourceDetail : source;
+
+ // Escape HTML entities in the log message itself for output to console
+ var msg = this.html2Text(oLogMsg.msg);
+
+ // Verbose output includes extra line breaks
+ var output = (this.verboseOutput) ?
+ ["", label, " ",
+ totalTime, "ms (+", elapsedTime, ") ",
+ localTime, ": ",
+ "
",
+ sourceAndDetail,
+ ":
",
+ msg,
+ "
"] :
+
+ ["", label, " ",
+ totalTime, "ms (+", elapsedTime, ") ",
+ localTime, ": ",
+ sourceAndDetail, ": ",
+ msg,"
"];
+
+ return output.join("");
+};
+
+/**
+ * Converts input chars "<", ">", and "&" to HTML entities.
+ *
+ * @method html2Text
+ * @param sHtml {String} String to convert.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype.html2Text = function(sHtml) {
+ if(sHtml) {
+ sHtml += "";
+ return sHtml.replace(/&/g, "&").replace(//g, ">");
+ }
+ return "";
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Internal class member to index multiple log reader instances.
+ *
+ * @property _memberName
+ * @static
+ * @type Number
+ * @default 0
+ * @private
+ */
+YAHOO.widget.LogReader._index = 0;
+
+/**
+ * Name of LogReader instance.
+ *
+ * @property _sName
+ * @type String
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._sName = null;
+
+/**
+ * A class member shared by all log readers if a container needs to be
+ * created during instantiation. Will be null if a container element never needs to
+ * be created on the fly, such as when the implementer passes in their own element.
+ *
+ * @property _elDefaultContainer
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader._elDefaultContainer = null;
+
+/**
+ * Buffer of log message objects for batch output.
+ *
+ * @property _buffer
+ * @type Object[]
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._buffer = null;
+
+/**
+ * Number of log messages output to console.
+ *
+ * @property _consoleMsgCount
+ * @type Number
+ * @default 0
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._consoleMsgCount = 0;
+
+/**
+ * Date of last output log message.
+ *
+ * @property _lastTime
+ * @type Date
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._lastTime = null;
+
+/**
+ * Batched output timeout ID.
+ *
+ * @property _timeout
+ * @type Number
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._timeout = null;
+
+/**
+ * Array of filters for log message categories.
+ *
+ * @property _categoryFilters
+ * @type String[]
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._categoryFilters = null;
+
+/**
+ * Array of filters for log message sources.
+ *
+ * @property _sourceFilters
+ * @type String[]
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._sourceFilters = null;
+
+/**
+ * Log reader container element.
+ *
+ * @property _elContainer
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elContainer = null;
+
+/**
+ * Log reader header element.
+ *
+ * @property _elHd
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elHd = null;
+
+/**
+ * Log reader collapse element.
+ *
+ * @property _elCollapse
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elCollapse = null;
+
+/**
+ * Log reader collapse button element.
+ *
+ * @property _btnCollapse
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._btnCollapse = null;
+
+/**
+ * Log reader title header element.
+ *
+ * @property _title
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._title = null;
+
+/**
+ * Log reader console element.
+ *
+ * @property _elConsole
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elConsole = null;
+
+/**
+ * Log reader footer element.
+ *
+ * @property _elFt
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elFt = null;
+
+/**
+ * Log reader buttons container element.
+ *
+ * @property _elBtns
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elBtns = null;
+
+/**
+ * Container element for log reader category filter checkboxes.
+ *
+ * @property _elCategoryFilters
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elCategoryFilters = null;
+
+/**
+ * Container element for log reader source filter checkboxes.
+ *
+ * @property _elSourceFilters
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elSourceFilters = null;
+
+/**
+ * Log reader pause button element.
+ *
+ * @property _btnPause
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._btnPause = null;
+
+/**
+ * Clear button element.
+ *
+ * @property _btnClear
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._btnClear = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Creates the UI for a category filter in the log reader footer element.
+ *
+ * @method _createCategoryCheckbox
+ * @param sCategory {String} Category name.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(sCategory) {
+ var oSelf = this;
+
+ if(this._elFt) {
+ var elParent = this._elCategoryFilters;
+ var filters = this._categoryFilters;
+
+ var elFilter = elParent.appendChild(document.createElement("span"));
+ elFilter.className = "yui-log-filtergrp";
+ // Append el at the end so IE 5.5 can set "type" attribute
+ // and THEN set checked property
+ var chkCategory = document.createElement("input");
+ chkCategory.id = "yui-log-filter-" + sCategory + this._sName;
+ chkCategory.className = "yui-log-filter-" + sCategory;
+ chkCategory.type = "checkbox";
+ chkCategory.category = sCategory;
+ chkCategory = elFilter.appendChild(chkCategory);
+ chkCategory.checked = true;
+
+ // Add this checked filter to the internal array of filters
+ filters.push(sCategory);
+ // Subscribe to the click event
+ YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf);
+
+ // Create and class the text label
+ var lblCategory = elFilter.appendChild(document.createElement("label"));
+ lblCategory.htmlFor = chkCategory.id;
+ lblCategory.className = sCategory;
+ lblCategory.innerHTML = sCategory;
+ }
+};
+
+/**
+ * Creates a checkbox in the log reader footer element to filter by source.
+ *
+ * @method _createSourceCheckbox
+ * @param sSource {String} Source name.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(sSource) {
+ var oSelf = this;
+
+ if(this._elFt) {
+ var elParent = this._elSourceFilters;
+ var filters = this._sourceFilters;
+
+ var elFilter = elParent.appendChild(document.createElement("span"));
+ elFilter.className = "yui-log-filtergrp";
+
+ // Append el at the end so IE 5.5 can set "type" attribute
+ // and THEN set checked property
+ var chkSource = document.createElement("input");
+ chkSource.id = "yui-log-filter" + sSource + this._sName;
+ chkSource.className = "yui-log-filter" + sSource;
+ chkSource.type = "checkbox";
+ chkSource.source = sSource;
+ chkSource = elFilter.appendChild(chkSource);
+ chkSource.checked = true;
+
+ // Add this checked filter to the internal array of filters
+ filters.push(sSource);
+ // Subscribe to the click event
+ YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf);
+
+ // Create and class the text label
+ var lblSource = elFilter.appendChild(document.createElement("label"));
+ lblSource.htmlFor = chkSource.id;
+ lblSource.className = sSource;
+ lblSource.innerHTML = sSource;
+ }
+};
+
+/**
+ * Reprints all log messages in the stack through filters.
+ *
+ * @method _filterLogs
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._filterLogs = function() {
+ // Reprint stack with new filters
+ if (this._elConsole !== null) {
+ this._clearConsole();
+ this._printToConsole(YAHOO.widget.Logger.getStack());
+ }
+};
+
+/**
+ * Clears all outputted log messages from the console and resets the time of the
+ * last output log message.
+ *
+ * @method _clearConsole
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._clearConsole = function() {
+ // Clear the buffer of any pending messages
+ this._timeout = null;
+ this._buffer = [];
+ this._consoleMsgCount = 0;
+
+ // Reset the rolling timer
+ this._lastTime = YAHOO.widget.Logger.getStartTime();
+
+ var elConsole = this._elConsole;
+ while(elConsole.hasChildNodes()) {
+ elConsole.removeChild(elConsole.firstChild);
+ }
+};
+
+/**
+ * Sends buffer of log messages to output and clears buffer.
+ *
+ * @method _printBuffer
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._printBuffer = function() {
+ this._timeout = null;
+
+ if(this._elConsole !== null) {
+ var thresholdMax = this.thresholdMax;
+ thresholdMax = (thresholdMax && !isNaN(thresholdMax)) ? thresholdMax : 500;
+ if(this._consoleMsgCount < thresholdMax) {
+ var entries = [];
+ for (var i=0; i this.thresholdMax)) {
+ thresholdMin = 0;
+ }
+ var entriesStartIndex = (entriesLen > thresholdMin) ? (entriesLen - thresholdMin) : 0;
+
+ // Iterate through all log entries
+ var sourceFiltersLen = this._sourceFilters.length;
+ var categoryFiltersLen = this._categoryFilters.length;
+ for(var i=entriesStartIndex; i tag instead of tag (for wrapping)
+ var container = (this.verboseOutput) ? "CODE" : "PRE";
+ var oNewElement = (this.newestOnTop) ?
+ this._elConsole.insertBefore(
+ document.createElement(container),this._elConsole.firstChild):
+ this._elConsole.appendChild(document.createElement(container));
+
+ oNewElement.innerHTML = output;
+ this._consoleMsgCount++;
+ this._lastTime = entry.time.getTime();
+ }
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private event handlers
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Handles Logger's categoryCreateEvent.
+ *
+ * @method _onCategoryCreate
+ * @param sType {String} The event.
+ * @param aArgs {Object[]} Data passed from event firer.
+ * @param oSelf {Object} The LogReader instance.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCategoryCreate = function(sType, aArgs, oSelf) {
+ var category = aArgs[0];
+ if(oSelf._elFt) {
+ oSelf._createCategoryCheckbox(category);
+ }
+};
+
+/**
+ * Handles Logger's sourceCreateEvent.
+ *
+ * @method _onSourceCreate
+ * @param sType {String} The event.
+ * @param aArgs {Object[]} Data passed from event firer.
+ * @param oSelf {Object} The LogReader instance.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onSourceCreate = function(sType, aArgs, oSelf) {
+ var source = aArgs[0];
+ if(oSelf._elFt) {
+ oSelf._createSourceCheckbox(source);
+ }
+};
+
+/**
+ * Handles check events on the category filter checkboxes.
+ *
+ * @method _onCheckCategory
+ * @param v {HTMLEvent} The click event.
+ * @param oSelf {Object} The LogReader instance.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCheckCategory = function(v, oSelf) {
+ var newFilter = this.category;
+ var filtersArray = oSelf._categoryFilters;
+
+ if(!this.checked) { // Remove category from filters
+ for(var i=0; i 0) {
+ // Substring until first space
+ sClass = sSource.substring(0,spaceIndex);
+ // The rest of the source
+ sDetail = sSource.substring(spaceIndex,sSource.length);
+ }
+ else {
+ sClass = sSource;
+ }
+ if(this._isNewSource(sClass)) {
+ this._createNewSource(sClass);
+ }
+ }
+
+ var timestamp = new Date();
+ var logEntry = new YAHOO.widget.LogMsg({
+ msg: sMsg,
+ time: timestamp,
+ category: sCategory,
+ source: sClass,
+ sourceDetail: sDetail
+ });
+
+ var stack = this._stack;
+ var maxStackEntries = this.maxStackEntries;
+ if(maxStackEntries && !isNaN(maxStackEntries) &&
+ (stack.length >= maxStackEntries)) {
+ stack.shift();
+ }
+ stack.push(logEntry);
+ this.newLogEvent.fire(logEntry);
+
+ if(this._browserConsoleEnabled) {
+ this._printToBrowserConsole(logEntry);
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+};
+
+/**
+ * Resets internal stack and startTime, enables Logger, and fires logResetEvent.
+ *
+ * @method reset
+ */
+YAHOO.widget.Logger.reset = function() {
+ this._stack = [];
+ this._startTime = new Date().getTime();
+ this.loggerEnabled = true;
+ this.log("Logger reset");
+ this.logResetEvent.fire();
+};
+
+/**
+ * Public accessor to internal stack of log message objects.
+ *
+ * @method getStack
+ * @return {Object[]} Array of log message objects.
+ */
+YAHOO.widget.Logger.getStack = function() {
+ return this._stack;
+};
+
+/**
+ * Public accessor to internal start time.
+ *
+ * @method getStartTime
+ * @return {Date} Internal date of when Logger singleton was initialized.
+ */
+YAHOO.widget.Logger.getStartTime = function() {
+ return this._startTime;
+};
+
+/**
+ * Disables output to the browser's global console.log() function, which is used
+ * by the Firebug extension to Firefox as well as Safari.
+ *
+ * @method disableBrowserConsole
+ */
+YAHOO.widget.Logger.disableBrowserConsole = function() {
+ YAHOO.log("Logger output to the function console.log() has been disabled.");
+ this._browserConsoleEnabled = false;
+};
+
+/**
+ * Enables output to the browser's global console.log() function, which is used
+ * by the Firebug extension to Firefox as well as Safari.
+ *
+ * @method enableBrowserConsole
+ */
+YAHOO.widget.Logger.enableBrowserConsole = function() {
+ this._browserConsoleEnabled = true;
+ YAHOO.log("Logger output to the function console.log() has been enabled.");
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public events
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Fired when a new category has been created.
+ *
+ * @event categoryCreateEvent
+ * @param sCategory {String} Category name.
+ */
+YAHOO.widget.Logger.categoryCreateEvent =
+ new YAHOO.util.CustomEvent("categoryCreate", this, true);
+
+ /**
+ * Fired when a new source has been named.
+ *
+ * @event sourceCreateEvent
+ * @param sSource {String} Source name.
+ */
+YAHOO.widget.Logger.sourceCreateEvent =
+ new YAHOO.util.CustomEvent("sourceCreate", this, true);
+
+ /**
+ * Fired when a new log message has been created.
+ *
+ * @event newLogEvent
+ * @param sMsg {String} Log message.
+ */
+YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true);
+
+/**
+ * Fired when the Logger has been reset has been created.
+ *
+ * @event logResetEvent
+ */
+YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true);
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Creates a new category of log messages and fires categoryCreateEvent.
+ *
+ * @method _createNewCategory
+ * @param sCategory {String} Category name.
+ * @private
+ */
+YAHOO.widget.Logger._createNewCategory = function(sCategory) {
+ this.categories.push(sCategory);
+ this.categoryCreateEvent.fire(sCategory);
+};
+
+/**
+ * Checks to see if a category has already been created.
+ *
+ * @method _isNewCategory
+ * @param sCategory {String} Category name.
+ * @return {Boolean} Returns true if category is unknown, else returns false.
+ * @private
+ */
+YAHOO.widget.Logger._isNewCategory = function(sCategory) {
+ for(var i=0; i < this.categories.length; i++) {
+ if(sCategory == this.categories[i]) {
+ return false;
+ }
+ }
+ return true;
+};
+
+/**
+ * Creates a new source of log messages and fires sourceCreateEvent.
+ *
+ * @method _createNewSource
+ * @param sSource {String} Source name.
+ * @private
+ */
+YAHOO.widget.Logger._createNewSource = function(sSource) {
+ this.sources.push(sSource);
+ this.sourceCreateEvent.fire(sSource);
+};
+
+/**
+ * Checks to see if a source already exists.
+ *
+ * @method _isNewSource
+ * @param sSource {String} Source name.
+ * @return {Boolean} Returns true if source is unknown, else returns false.
+ * @private
+ */
+YAHOO.widget.Logger._isNewSource = function(sSource) {
+ if(sSource) {
+ for(var i=0; i < this.sources.length; i++) {
+ if(sSource == this.sources[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+};
+
+/**
+ * Outputs a log message to global console.log() function.
+ *
+ * @method _printToBrowserConsole
+ * @param oEntry {Object} Log entry object.
+ * @private
+ */
+YAHOO.widget.Logger._printToBrowserConsole = function(oEntry) {
+ if(window.console && console.log) {
+ var category = oEntry.category;
+ var label = oEntry.category.substring(0,4).toUpperCase();
+
+ var time = oEntry.time;
+ if (time.toLocaleTimeString) {
+ var localTime = time.toLocaleTimeString();
+ }
+ else {
+ localTime = time.toString();
+ }
+
+ var msecs = time.getTime();
+ var elapsedTime = (YAHOO.widget.Logger._lastTime) ?
+ (msecs - YAHOO.widget.Logger._lastTime) : 0;
+ YAHOO.widget.Logger._lastTime = msecs;
+
+ var output =
+ localTime + " (" +
+ elapsedTime + "ms): " +
+ oEntry.source + ": " +
+ oEntry.msg;
+
+ console.log(output);
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private event handlers
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Handles logging of messages due to window error events.
+ *
+ * @method _onWindowError
+ * @param sMsg {String} The error message.
+ * @param sUrl {String} URL of the error.
+ * @param sLine {String} Line number of the error.
+ * @private
+ */
+YAHOO.widget.Logger._onWindowError = function(sMsg,sUrl,sLine) {
+ // Logger is not in scope of this event handler
+ try {
+ YAHOO.widget.Logger.log(sMsg+' ('+sUrl+', line '+sLine+')', "window");
+ if(YAHOO.widget.Logger._origOnWindowError) {
+ YAHOO.widget.Logger._origOnWindowError();
+ }
+ }
+ catch(e) {
+ return false;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Enable handling of native JavaScript errors
+// NB: Not all browsers support the window.onerror event
+//
+/////////////////////////////////////////////////////////////////////////////
+
+if(window.onerror) {
+ // Save any previously defined handler to call
+ YAHOO.widget.Logger._origOnWindowError = window.onerror;
+}
+window.onerror = YAHOO.widget.Logger._onWindowError;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// First log
+//
+/////////////////////////////////////////////////////////////////////////////
+
+YAHOO.widget.Logger.log("Logger initialized");
+
diff --git a/lib/yui/logger/logger-min.js b/lib/yui/logger/logger-min.js
index 4c36916c9f..f41d323f30 100755
--- a/lib/yui/logger/logger-min.js
+++ b/lib/yui/logger/logger-min.js
@@ -1,57 +1,63 @@
-/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.txt version: 0.12.1 */
-YAHOO.widget.LogMsg=function(oConfigs){if(typeof oConfigs=="object"){for(var param in oConfigs){this[param]=oConfigs[param];}}};YAHOO.widget.LogMsg.prototype.msg=null;YAHOO.widget.LogMsg.prototype.time=null;YAHOO.widget.LogMsg.prototype.category=null;YAHOO.widget.LogMsg.prototype.source=null;YAHOO.widget.LogMsg.prototype.sourceDetail=null;YAHOO.widget.LogWriter=function(sSource){if(!sSource){YAHOO.log("Could not instantiate LogWriter due to invalid source.","error","LogWriter");return;}
-this._source=sSource;};YAHOO.widget.LogWriter.prototype.toString=function(){return"LogWriter "+this._sSource;};YAHOO.widget.LogWriter.prototype.log=function(sMsg,sCategory){YAHOO.widget.Logger.log(sMsg,sCategory,this._source);};YAHOO.widget.LogWriter.prototype.getSource=function(){return this._sSource;};YAHOO.widget.LogWriter.prototype.setSource=function(sSource){if(!sSource){YAHOO.log("Could not set source due to invalid source.","error",this.toString());return;}
-else{this._sSource=sSource;}};YAHOO.widget.LogWriter.prototype._source=null;YAHOO.widget.LogReader=function(elContainer,oConfigs){var oSelf=this;this._sName=YAHOO.widget.LogReader._index;YAHOO.widget.LogReader._index++;if(typeof oConfigs=="object"){for(var param in oConfigs){this[param]=oConfigs[param];}}
-if(elContainer){if(typeof elContainer=="string"){this._elContainer=document.getElementById(elContainer);}
-else if(elContainer.tagName){this._elContainer=elContainer;}
-this._elContainer.className="yui-log";}
-if(!this._elContainer){if(YAHOO.widget.LogReader._elDefaultContainer){this._elContainer=YAHOO.widget.LogReader._elDefaultContainer;}
-else{this._elContainer=document.body.appendChild(document.createElement("div"));this._elContainer.id="yui-log";this._elContainer.className="yui-log";YAHOO.widget.LogReader._elDefaultContainer=this._elContainer;}
-var containerStyle=this._elContainer.style;if(this.width){containerStyle.width=this.width;}
-if(this.right){containerStyle.right=this.right;}
-if(this.top){containerStyle.top=this.top;}
-if(this.left){containerStyle.left=this.left;containerStyle.right="auto";}
-if(this.bottom){containerStyle.bottom=this.bottom;containerStyle.top="auto";}
-if(this.fontSize){containerStyle.fontSize=this.fontSize;}
-if(window.opera){document.body.style+='';}}
-if(this._elContainer){if(!this._elHd){this._elHd=this._elContainer.appendChild(document.createElement("div"));this._elHd.id="yui-log-hd"+this._sName;this._elHd.className="yui-log-hd";this._elCollapse=this._elHd.appendChild(document.createElement("div"));this._elCollapse.className="yui-log-btns";this._btnCollapse=document.createElement("input");this._btnCollapse.type="button";this._btnCollapse.style.fontSize=YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");this._btnCollapse.className="yui-log-button";this._btnCollapse.value="Collapse";this._btnCollapse=this._elCollapse.appendChild(this._btnCollapse);YAHOO.util.Event.addListener(oSelf._btnCollapse,'click',oSelf._onClickCollapseBtn,oSelf);this._title=this._elHd.appendChild(document.createElement("h4"));this._title.innerHTML="Logger Console";if(YAHOO.util.DD&&(YAHOO.widget.LogReader._elDefaultContainer==this._elContainer)){var ylog_dd=new YAHOO.util.DD(this._elContainer.id);ylog_dd.setHandleElId(this._elHd.id);this._elHd.style.cursor="move";}}
-if(!this._elConsole){this._elConsole=this._elContainer.appendChild(document.createElement("div"));this._elConsole.className="yui-log-bd";if(this.height){this._elConsole.style.height=this.height;}}
-if(!this._elFt&&this.footerEnabled){this._elFt=this._elContainer.appendChild(document.createElement("div"));this._elFt.className="yui-log-ft";this._elBtns=this._elFt.appendChild(document.createElement("div"));this._elBtns.className="yui-log-btns";this._btnPause=document.createElement("input");this._btnPause.type="button";this._btnPause.style.fontSize=YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");this._btnPause.className="yui-log-button";this._btnPause.value="Pause";this._btnPause=this._elBtns.appendChild(this._btnPause);YAHOO.util.Event.addListener(oSelf._btnPause,'click',oSelf._onClickPauseBtn,oSelf);this._btnClear=document.createElement("input");this._btnClear.type="button";this._btnClear.style.fontSize=YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");this._btnClear.className="yui-log-button";this._btnClear.value="Clear";this._btnClear=this._elBtns.appendChild(this._btnClear);YAHOO.util.Event.addListener(oSelf._btnClear,'click',oSelf._onClickClearBtn,oSelf);this._elCategoryFilters=this._elFt.appendChild(document.createElement("div"));this._elCategoryFilters.className="yui-log-categoryfilters";this._elSourceFilters=this._elFt.appendChild(document.createElement("div"));this._elSourceFilters.className="yui-log-sourcefilters";}}
-if(!this._buffer){this._buffer=[];}
-this._lastTime=YAHOO.widget.Logger.getStartTime();YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog,this);YAHOO.widget.Logger.logResetEvent.subscribe(this._onReset,this);this._categoryFilters=[];var catsLen=YAHOO.widget.Logger.categories.length;if(this._elCategoryFilters){for(var i=0;i",label," ",totalTime,"ms (+",elapsedTime,") ",localTime,": ","",sourceAndDetail,":
",msg,"
"]:["",label," ",totalTime,"ms (+",elapsedTime,") ",localTime,": ",sourceAndDetail,": ",msg,"
"];return output.join("");};YAHOO.widget.LogReader.prototype.html2Text=function(sHtml){if(sHtml){sHtml+="";return sHtml.replace(/&/g,"&").replace(//g,">");}
-return"";};YAHOO.widget.LogReader._index=0;YAHOO.widget.LogReader.prototype._sName=null;YAHOO.widget.LogReader._elDefaultContainer=null;YAHOO.widget.LogReader.prototype._buffer=null;YAHOO.widget.LogReader.prototype._consoleMsgCount=0;YAHOO.widget.LogReader.prototype._lastTime=null;YAHOO.widget.LogReader.prototype._timeout=null;YAHOO.widget.LogReader.prototype._categoryFilters=null;YAHOO.widget.LogReader.prototype._sourceFilters=null;YAHOO.widget.LogReader.prototype._elContainer=null;YAHOO.widget.LogReader.prototype._elHd=null;YAHOO.widget.LogReader.prototype._elCollapse=null;YAHOO.widget.LogReader.prototype._btnCollapse=null;YAHOO.widget.LogReader.prototype._title=null;YAHOO.widget.LogReader.prototype._elConsole=null;YAHOO.widget.LogReader.prototype._elFt=null;YAHOO.widget.LogReader.prototype._elBtns=null;YAHOO.widget.LogReader.prototype._elCategoryFilters=null;YAHOO.widget.LogReader.prototype._elSourceFilters=null;YAHOO.widget.LogReader.prototype._btnPause=null;YAHOO.widget.LogReader.prototype._btnClear=null;YAHOO.widget.LogReader.prototype._createCategoryCheckbox=function(sCategory){var oSelf=this;if(this._elFt){var elParent=this._elCategoryFilters;var filters=this._categoryFilters;var elFilter=elParent.appendChild(document.createElement("span"));elFilter.className="yui-log-filtergrp";var chkCategory=document.createElement("input");chkCategory.id="yui-log-filter-"+sCategory+this._sName;chkCategory.className="yui-log-filter-"+sCategory;chkCategory.type="checkbox";chkCategory.category=sCategory;chkCategory=elFilter.appendChild(chkCategory);chkCategory.checked=true;filters.push(sCategory);YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf);var lblCategory=elFilter.appendChild(document.createElement("label"));lblCategory.htmlFor=chkCategory.id;lblCategory.className=sCategory;lblCategory.innerHTML=sCategory;}};YAHOO.widget.LogReader.prototype._createSourceCheckbox=function(sSource){var oSelf=this;if(this._elFt){var elParent=this._elSourceFilters;var filters=this._sourceFilters;var elFilter=elParent.appendChild(document.createElement("span"));elFilter.className="yui-log-filtergrp";var chkSource=document.createElement("input");chkSource.id="yui-log-filter"+sSource+this._sName;chkSource.className="yui-log-filter"+sSource;chkSource.type="checkbox";chkSource.source=sSource;chkSource=elFilter.appendChild(chkSource);chkSource.checked=true;filters.push(sSource);YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf);var lblSource=elFilter.appendChild(document.createElement("label"));lblSource.htmlFor=chkSource.id;lblSource.className=sSource;lblSource.innerHTML=sSource;}};YAHOO.widget.LogReader.prototype._filterLogs=function(){if(this._elConsole!==null){this._clearConsole();this._printToConsole(YAHOO.widget.Logger.getStack());}};YAHOO.widget.LogReader.prototype._clearConsole=function(){this._timeout=null;this._buffer=[];this._consoleMsgCount=0;this._lastTime=YAHOO.widget.Logger.getStartTime();var elConsole=this._elConsole;while(elConsole.hasChildNodes()){elConsole.removeChild(elConsole.firstChild);}};YAHOO.widget.LogReader.prototype._printBuffer=function(){this._timeout=null;if(this._elConsole!==null){var thresholdMax=this.thresholdMax;thresholdMax=(thresholdMax&&!isNaN(thresholdMax))?thresholdMax:500;if(this._consoleMsgCountthis.thresholdMax)){thresholdMin=0;}
-var entriesStartIndex=(entriesLen>thresholdMin)?(entriesLen-thresholdMin):0;var sourceFiltersLen=this._sourceFilters.length;var categoryFiltersLen=this._categoryFilters.length;for(var i=entriesStartIndex;i0){sClass=sSource.substring(0,spaceIndex);sDetail=sSource.substring(spaceIndex,sSource.length);}
-else{sClass=sSource;}
-if(this._isNewSource(sClass)){this._createNewSource(sClass);}}
-var timestamp=new Date();var logEntry=new YAHOO.widget.LogMsg({msg:sMsg,time:timestamp,category:sCategory,source:sClass,sourceDetail:sDetail});var stack=this._stack;var maxStackEntries=this.maxStackEntries;if(maxStackEntries&&!isNaN(maxStackEntries)&&(stack.length>=maxStackEntries)){stack.shift();}
-stack.push(logEntry);this.newLogEvent.fire(logEntry);if(this._browserConsoleEnabled){this._printToBrowserConsole(logEntry);}
-return true;}
-else{return false;}};YAHOO.widget.Logger.reset=function(){this._stack=[];this._startTime=new Date().getTime();this.loggerEnabled=true;this.log("Logger reset");this.logResetEvent.fire();};YAHOO.widget.Logger.getStack=function(){return this._stack;};YAHOO.widget.Logger.getStartTime=function(){return this._startTime;};YAHOO.widget.Logger.disableBrowserConsole=function(){YAHOO.log("Logger output to the function console.log() has been disabled.");this._browserConsoleEnabled=false;};YAHOO.widget.Logger.enableBrowserConsole=function(){this._browserConsoleEnabled=true;YAHOO.log("Logger output to the function console.log() has been enabled.");};YAHOO.widget.Logger.categoryCreateEvent=new YAHOO.util.CustomEvent("categoryCreate",this,true);YAHOO.widget.Logger.sourceCreateEvent=new YAHOO.util.CustomEvent("sourceCreate",this,true);YAHOO.widget.Logger.newLogEvent=new YAHOO.util.CustomEvent("newLog",this,true);YAHOO.widget.Logger.logResetEvent=new YAHOO.util.CustomEvent("logReset",this,true);YAHOO.widget.Logger._createNewCategory=function(sCategory){this.categories.push(sCategory);this.categoryCreateEvent.fire(sCategory);};YAHOO.widget.Logger._isNewCategory=function(sCategory){for(var i=0;i",label," ",totalTime,"ms (+",elapsedTime,") ",localTime,": ","",sourceAndDetail,":
",msg,"
"]:["",label," ",totalTime,"ms (+",elapsedTime,") ",localTime,": ",sourceAndDetail,": ",msg,"
"];return output.join("");};YAHOO.widget.LogReader.prototype.html2Text=function(sHtml){if(sHtml){sHtml+="";return sHtml.replace(/&/g,"&").replace(//g,">");}
+return"";};YAHOO.widget.LogReader._index=0;YAHOO.widget.LogReader.prototype._sName=null;YAHOO.widget.LogReader._elDefaultContainer=null;YAHOO.widget.LogReader.prototype._buffer=null;YAHOO.widget.LogReader.prototype._consoleMsgCount=0;YAHOO.widget.LogReader.prototype._lastTime=null;YAHOO.widget.LogReader.prototype._timeout=null;YAHOO.widget.LogReader.prototype._categoryFilters=null;YAHOO.widget.LogReader.prototype._sourceFilters=null;YAHOO.widget.LogReader.prototype._elContainer=null;YAHOO.widget.LogReader.prototype._elHd=null;YAHOO.widget.LogReader.prototype._elCollapse=null;YAHOO.widget.LogReader.prototype._btnCollapse=null;YAHOO.widget.LogReader.prototype._title=null;YAHOO.widget.LogReader.prototype._elConsole=null;YAHOO.widget.LogReader.prototype._elFt=null;YAHOO.widget.LogReader.prototype._elBtns=null;YAHOO.widget.LogReader.prototype._elCategoryFilters=null;YAHOO.widget.LogReader.prototype._elSourceFilters=null;YAHOO.widget.LogReader.prototype._btnPause=null;YAHOO.widget.LogReader.prototype._btnClear=null;YAHOO.widget.LogReader.prototype._createCategoryCheckbox=function(sCategory){var oSelf=this;if(this._elFt){var elParent=this._elCategoryFilters;var filters=this._categoryFilters;var elFilter=elParent.appendChild(document.createElement("span"));elFilter.className="yui-log-filtergrp";var chkCategory=document.createElement("input");chkCategory.id="yui-log-filter-"+sCategory+this._sName;chkCategory.className="yui-log-filter-"+sCategory;chkCategory.type="checkbox";chkCategory.category=sCategory;chkCategory=elFilter.appendChild(chkCategory);chkCategory.checked=true;filters.push(sCategory);YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf);var lblCategory=elFilter.appendChild(document.createElement("label"));lblCategory.htmlFor=chkCategory.id;lblCategory.className=sCategory;lblCategory.innerHTML=sCategory;}};YAHOO.widget.LogReader.prototype._createSourceCheckbox=function(sSource){var oSelf=this;if(this._elFt){var elParent=this._elSourceFilters;var filters=this._sourceFilters;var elFilter=elParent.appendChild(document.createElement("span"));elFilter.className="yui-log-filtergrp";var chkSource=document.createElement("input");chkSource.id="yui-log-filter"+sSource+this._sName;chkSource.className="yui-log-filter"+sSource;chkSource.type="checkbox";chkSource.source=sSource;chkSource=elFilter.appendChild(chkSource);chkSource.checked=true;filters.push(sSource);YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf);var lblSource=elFilter.appendChild(document.createElement("label"));lblSource.htmlFor=chkSource.id;lblSource.className=sSource;lblSource.innerHTML=sSource;}};YAHOO.widget.LogReader.prototype._filterLogs=function(){if(this._elConsole!==null){this._clearConsole();this._printToConsole(YAHOO.widget.Logger.getStack());}};YAHOO.widget.LogReader.prototype._clearConsole=function(){this._timeout=null;this._buffer=[];this._consoleMsgCount=0;this._lastTime=YAHOO.widget.Logger.getStartTime();var elConsole=this._elConsole;while(elConsole.hasChildNodes()){elConsole.removeChild(elConsole.firstChild);}};YAHOO.widget.LogReader.prototype._printBuffer=function(){this._timeout=null;if(this._elConsole!==null){var thresholdMax=this.thresholdMax;thresholdMax=(thresholdMax&&!isNaN(thresholdMax))?thresholdMax:500;if(this._consoleMsgCountthis.thresholdMax)){thresholdMin=0;}
+var entriesStartIndex=(entriesLen>thresholdMin)?(entriesLen-thresholdMin):0;var sourceFiltersLen=this._sourceFilters.length;var categoryFiltersLen=this._categoryFilters.length;for(var i=entriesStartIndex;i0){sClass=sSource.substring(0,spaceIndex);sDetail=sSource.substring(spaceIndex,sSource.length);}
+else{sClass=sSource;}
+if(this._isNewSource(sClass)){this._createNewSource(sClass);}}
+var timestamp=new Date();var logEntry=new YAHOO.widget.LogMsg({msg:sMsg,time:timestamp,category:sCategory,source:sClass,sourceDetail:sDetail});var stack=this._stack;var maxStackEntries=this.maxStackEntries;if(maxStackEntries&&!isNaN(maxStackEntries)&&(stack.length>=maxStackEntries)){stack.shift();}
+stack.push(logEntry);this.newLogEvent.fire(logEntry);if(this._browserConsoleEnabled){this._printToBrowserConsole(logEntry);}
+return true;}
+else{return false;}};YAHOO.widget.Logger.reset=function(){this._stack=[];this._startTime=new Date().getTime();this.loggerEnabled=true;this.log("Logger reset");this.logResetEvent.fire();};YAHOO.widget.Logger.getStack=function(){return this._stack;};YAHOO.widget.Logger.getStartTime=function(){return this._startTime;};YAHOO.widget.Logger.disableBrowserConsole=function(){YAHOO.log("Logger output to the function console.log() has been disabled.");this._browserConsoleEnabled=false;};YAHOO.widget.Logger.enableBrowserConsole=function(){this._browserConsoleEnabled=true;YAHOO.log("Logger output to the function console.log() has been enabled.");};YAHOO.widget.Logger.categoryCreateEvent=new YAHOO.util.CustomEvent("categoryCreate",this,true);YAHOO.widget.Logger.sourceCreateEvent=new YAHOO.util.CustomEvent("sourceCreate",this,true);YAHOO.widget.Logger.newLogEvent=new YAHOO.util.CustomEvent("newLog",this,true);YAHOO.widget.Logger.logResetEvent=new YAHOO.util.CustomEvent("logReset",this,true);YAHOO.widget.Logger._createNewCategory=function(sCategory){this.categories.push(sCategory);this.categoryCreateEvent.fire(sCategory);};YAHOO.widget.Logger._isNewCategory=function(sCategory){for(var i=0;i", label, " ",
- totalTime, "ms (+", elapsedTime, ") ",
- localTime, ": ",
- "",
- sourceAndDetail,
- ":
",
- msg,
- "
"] :
-
- ["", label, " ",
- totalTime, "ms (+", elapsedTime, ") ",
- localTime, ": ",
- sourceAndDetail, ": ",
- msg,"
"];
-
- return output.join("");
-};
-
-/**
- * Converts input chars "<", ">", and "&" to HTML entities.
- *
- * @method html2Text
- * @param sHtml {String} String to convert.
- * @private
- */
-YAHOO.widget.LogReader.prototype.html2Text = function(sHtml) {
- if(sHtml) {
- sHtml += "";
- return sHtml.replace(/&/g, "&").replace(//g, ">");
- }
- return "";
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Internal class member to index multiple log reader instances.
- *
- * @property _memberName
- * @static
- * @type Number
- * @default 0
- * @private
- */
-YAHOO.widget.LogReader._index = 0;
-
-/**
- * Name of LogReader instance.
- *
- * @property _sName
- * @type String
- * @private
- */
-YAHOO.widget.LogReader.prototype._sName = null;
-
-/**
- * A class member shared by all log readers if a container needs to be
- * created during instantiation. Will be null if a container element never needs to
- * be created on the fly, such as when the implementer passes in their own element.
- *
- * @property _elDefaultContainer
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader._elDefaultContainer = null;
-
-/**
- * Buffer of log message objects for batch output.
- *
- * @property _buffer
- * @type Object[]
- * @private
- */
-YAHOO.widget.LogReader.prototype._buffer = null;
-
-/**
- * Number of log messages output to console.
- *
- * @property _consoleMsgCount
- * @type Number
- * @default 0
- * @private
- */
-YAHOO.widget.LogReader.prototype._consoleMsgCount = 0;
-
-/**
- * Date of last output log message.
- *
- * @property _lastTime
- * @type Date
- * @private
- */
-YAHOO.widget.LogReader.prototype._lastTime = null;
-
-/**
- * Batched output timeout ID.
- *
- * @property _timeout
- * @type Number
- * @private
- */
-YAHOO.widget.LogReader.prototype._timeout = null;
-
-/**
- * Array of filters for log message categories.
- *
- * @property _categoryFilters
- * @type String[]
- * @private
- */
-YAHOO.widget.LogReader.prototype._categoryFilters = null;
-
-/**
- * Array of filters for log message sources.
- *
- * @property _sourceFilters
- * @type String[]
- * @private
- */
-YAHOO.widget.LogReader.prototype._sourceFilters = null;
-
-/**
- * Log reader container element.
- *
- * @property _elContainer
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elContainer = null;
-
-/**
- * Log reader header element.
- *
- * @property _elHd
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elHd = null;
-
-/**
- * Log reader collapse element.
- *
- * @property _elCollapse
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elCollapse = null;
-
-/**
- * Log reader collapse button element.
- *
- * @property _btnCollapse
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._btnCollapse = null;
-
-/**
- * Log reader title header element.
- *
- * @property _title
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._title = null;
-
-/**
- * Log reader console element.
- *
- * @property _elConsole
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elConsole = null;
-
-/**
- * Log reader footer element.
- *
- * @property _elFt
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elFt = null;
-
-/**
- * Log reader buttons container element.
- *
- * @property _elBtns
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elBtns = null;
-
-/**
- * Container element for log reader category filter checkboxes.
- *
- * @property _elCategoryFilters
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elCategoryFilters = null;
-
-/**
- * Container element for log reader source filter checkboxes.
- *
- * @property _elSourceFilters
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._elSourceFilters = null;
-
-/**
- * Log reader pause button element.
- *
- * @property _btnPause
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._btnPause = null;
-
-/**
- * Clear button element.
- *
- * @property _btnClear
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.LogReader.prototype._btnClear = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Creates the UI for a category filter in the log reader footer element.
- *
- * @method _createCategoryCheckbox
- * @param sCategory {String} Category name.
- * @private
- */
-YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(sCategory) {
- var oSelf = this;
-
- if(this._elFt) {
- var elParent = this._elCategoryFilters;
- var filters = this._categoryFilters;
-
- var elFilter = elParent.appendChild(document.createElement("span"));
- elFilter.className = "yui-log-filtergrp";
- // Append el at the end so IE 5.5 can set "type" attribute
- // and THEN set checked property
- var chkCategory = document.createElement("input");
- chkCategory.id = "yui-log-filter-" + sCategory + this._sName;
- chkCategory.className = "yui-log-filter-" + sCategory;
- chkCategory.type = "checkbox";
- chkCategory.category = sCategory;
- chkCategory = elFilter.appendChild(chkCategory);
- chkCategory.checked = true;
-
- // Add this checked filter to the internal array of filters
- filters.push(sCategory);
- // Subscribe to the click event
- YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf);
-
- // Create and class the text label
- var lblCategory = elFilter.appendChild(document.createElement("label"));
- lblCategory.htmlFor = chkCategory.id;
- lblCategory.className = sCategory;
- lblCategory.innerHTML = sCategory;
- }
-};
-
-/**
- * Creates a checkbox in the log reader footer element to filter by source.
- *
- * @method _createSourceCheckbox
- * @param sSource {String} Source name.
- * @private
- */
-YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(sSource) {
- var oSelf = this;
-
- if(this._elFt) {
- var elParent = this._elSourceFilters;
- var filters = this._sourceFilters;
-
- var elFilter = elParent.appendChild(document.createElement("span"));
- elFilter.className = "yui-log-filtergrp";
-
- // Append el at the end so IE 5.5 can set "type" attribute
- // and THEN set checked property
- var chkSource = document.createElement("input");
- chkSource.id = "yui-log-filter" + sSource + this._sName;
- chkSource.className = "yui-log-filter" + sSource;
- chkSource.type = "checkbox";
- chkSource.source = sSource;
- chkSource = elFilter.appendChild(chkSource);
- chkSource.checked = true;
-
- // Add this checked filter to the internal array of filters
- filters.push(sSource);
- // Subscribe to the click event
- YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf);
-
- // Create and class the text label
- var lblSource = elFilter.appendChild(document.createElement("label"));
- lblSource.htmlFor = chkSource.id;
- lblSource.className = sSource;
- lblSource.innerHTML = sSource;
- }
-};
-
-/**
- * Reprints all log messages in the stack through filters.
- *
- * @method _filterLogs
- * @private
- */
-YAHOO.widget.LogReader.prototype._filterLogs = function() {
- // Reprint stack with new filters
- if (this._elConsole !== null) {
- this._clearConsole();
- this._printToConsole(YAHOO.widget.Logger.getStack());
- }
-};
-
-/**
- * Clears all outputted log messages from the console and resets the time of the
- * last output log message.
- *
- * @method _clearConsole
- * @private
- */
-YAHOO.widget.LogReader.prototype._clearConsole = function() {
- // Clear the buffer of any pending messages
- this._timeout = null;
- this._buffer = [];
- this._consoleMsgCount = 0;
-
- // Reset the rolling timer
- this._lastTime = YAHOO.widget.Logger.getStartTime();
-
- var elConsole = this._elConsole;
- while(elConsole.hasChildNodes()) {
- elConsole.removeChild(elConsole.firstChild);
- }
-};
-
-/**
- * Sends buffer of log messages to output and clears buffer.
- *
- * @method _printBuffer
- * @private
- */
-YAHOO.widget.LogReader.prototype._printBuffer = function() {
- this._timeout = null;
-
- if(this._elConsole !== null) {
- var thresholdMax = this.thresholdMax;
- thresholdMax = (thresholdMax && !isNaN(thresholdMax)) ? thresholdMax : 500;
- if(this._consoleMsgCount < thresholdMax) {
- var entries = [];
- for (var i=0; i this.thresholdMax)) {
- thresholdMin = 0;
- }
- var entriesStartIndex = (entriesLen > thresholdMin) ? (entriesLen - thresholdMin) : 0;
-
- // Iterate through all log entries
- var sourceFiltersLen = this._sourceFilters.length;
- var categoryFiltersLen = this._categoryFilters.length;
- for(var i=entriesStartIndex; i tag instead of tag (for wrapping)
- var container = (this.verboseOutput) ? "CODE" : "PRE";
- var oNewElement = (this.newestOnTop) ?
- this._elConsole.insertBefore(
- document.createElement(container),this._elConsole.firstChild):
- this._elConsole.appendChild(document.createElement(container));
-
- oNewElement.innerHTML = output;
- this._consoleMsgCount++;
- this._lastTime = entry.time.getTime();
- }
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles Logger's categoryCreateEvent.
- *
- * @method _onCategoryCreate
- * @param sType {String} The event.
- * @param aArgs {Object[]} Data passed from event firer.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onCategoryCreate = function(sType, aArgs, oSelf) {
- var category = aArgs[0];
- if(oSelf._elFt) {
- oSelf._createCategoryCheckbox(category);
- }
-};
-
-/**
- * Handles Logger's sourceCreateEvent.
- *
- * @method _onSourceCreate
- * @param sType {String} The event.
- * @param aArgs {Object[]} Data passed from event firer.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onSourceCreate = function(sType, aArgs, oSelf) {
- var source = aArgs[0];
- if(oSelf._elFt) {
- oSelf._createSourceCheckbox(source);
- }
-};
-
-/**
- * Handles check events on the category filter checkboxes.
- *
- * @method _onCheckCategory
- * @param v {HTMLEvent} The click event.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onCheckCategory = function(v, oSelf) {
- var newFilter = this.category;
- var filtersArray = oSelf._categoryFilters;
-
- if(!this.checked) { // Remove category from filters
- for(var i=0; i 0) {
- // Substring until first space
- sClass = sSource.substring(0,spaceIndex);
- // The rest of the source
- sDetail = sSource.substring(spaceIndex,sSource.length);
- }
- else {
- sClass = sSource;
- }
- if(this._isNewSource(sClass)) {
- this._createNewSource(sClass);
- }
- }
-
- var timestamp = new Date();
- var logEntry = new YAHOO.widget.LogMsg({
- msg: sMsg,
- time: timestamp,
- category: sCategory,
- source: sClass,
- sourceDetail: sDetail
- });
-
- var stack = this._stack;
- var maxStackEntries = this.maxStackEntries;
- if(maxStackEntries && !isNaN(maxStackEntries) &&
- (stack.length >= maxStackEntries)) {
- stack.shift();
- }
- stack.push(logEntry);
- this.newLogEvent.fire(logEntry);
-
- if(this._browserConsoleEnabled) {
- this._printToBrowserConsole(logEntry);
- }
- return true;
- }
- else {
- return false;
- }
-};
-
-/**
- * Resets internal stack and startTime, enables Logger, and fires logResetEvent.
- *
- * @method reset
- */
-YAHOO.widget.Logger.reset = function() {
- this._stack = [];
- this._startTime = new Date().getTime();
- this.loggerEnabled = true;
- this.log("Logger reset");
- this.logResetEvent.fire();
-};
-
-/**
- * Public accessor to internal stack of log message objects.
- *
- * @method getStack
- * @return {Object[]} Array of log message objects.
- */
-YAHOO.widget.Logger.getStack = function() {
- return this._stack;
-};
-
-/**
- * Public accessor to internal start time.
- *
- * @method getStartTime
- * @return {Date} Internal date of when Logger singleton was initialized.
- */
-YAHOO.widget.Logger.getStartTime = function() {
- return this._startTime;
-};
-
-/**
- * Disables output to the browser's global console.log() function, which is used
- * by the Firebug extension to Firefox as well as Safari.
- *
- * @method disableBrowserConsole
- */
-YAHOO.widget.Logger.disableBrowserConsole = function() {
- YAHOO.log("Logger output to the function console.log() has been disabled.");
- this._browserConsoleEnabled = false;
-};
-
-/**
- * Enables output to the browser's global console.log() function, which is used
- * by the Firebug extension to Firefox as well as Safari.
- *
- * @method enableBrowserConsole
- */
-YAHOO.widget.Logger.enableBrowserConsole = function() {
- this._browserConsoleEnabled = true;
- YAHOO.log("Logger output to the function console.log() has been enabled.");
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Fired when a new category has been created.
- *
- * @event categoryCreateEvent
- * @param sCategory {String} Category name.
- */
-YAHOO.widget.Logger.categoryCreateEvent =
- new YAHOO.util.CustomEvent("categoryCreate", this, true);
-
- /**
- * Fired when a new source has been named.
- *
- * @event sourceCreateEvent
- * @param sSource {String} Source name.
- */
-YAHOO.widget.Logger.sourceCreateEvent =
- new YAHOO.util.CustomEvent("sourceCreate", this, true);
-
- /**
- * Fired when a new log message has been created.
- *
- * @event newLogEvent
- * @param sMsg {String} Log message.
- */
-YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true);
-
-/**
- * Fired when the Logger has been reset has been created.
- *
- * @event logResetEvent
- */
-YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true);
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Creates a new category of log messages and fires categoryCreateEvent.
- *
- * @method _createNewCategory
- * @param sCategory {String} Category name.
- * @private
- */
-YAHOO.widget.Logger._createNewCategory = function(sCategory) {
- this.categories.push(sCategory);
- this.categoryCreateEvent.fire(sCategory);
-};
-
-/**
- * Checks to see if a category has already been created.
- *
- * @method _isNewCategory
- * @param sCategory {String} Category name.
- * @return {Boolean} Returns true if category is unknown, else returns false.
- * @private
- */
-YAHOO.widget.Logger._isNewCategory = function(sCategory) {
- for(var i=0; i < this.categories.length; i++) {
- if(sCategory == this.categories[i]) {
- return false;
- }
- }
- return true;
-};
-
-/**
- * Creates a new source of log messages and fires sourceCreateEvent.
- *
- * @method _createNewSource
- * @param sSource {String} Source name.
- * @private
- */
-YAHOO.widget.Logger._createNewSource = function(sSource) {
- this.sources.push(sSource);
- this.sourceCreateEvent.fire(sSource);
-};
-
-/**
- * Checks to see if a source already exists.
- *
- * @method _isNewSource
- * @param sSource {String} Source name.
- * @return {Boolean} Returns true if source is unknown, else returns false.
- * @private
- */
-YAHOO.widget.Logger._isNewSource = function(sSource) {
- if(sSource) {
- for(var i=0; i < this.sources.length; i++) {
- if(sSource == this.sources[i]) {
- return false;
- }
- }
- return true;
- }
-};
-
-/**
- * Outputs a log message to global console.log() function.
- *
- * @method _printToBrowserConsole
- * @param oEntry {Object} Log entry object.
- * @private
- */
-YAHOO.widget.Logger._printToBrowserConsole = function(oEntry) {
- if(window.console && console.log) {
- var category = oEntry.category;
- var label = oEntry.category.substring(0,4).toUpperCase();
-
- var time = oEntry.time;
- if (time.toLocaleTimeString) {
- var localTime = time.toLocaleTimeString();
- }
- else {
- localTime = time.toString();
- }
-
- var msecs = time.getTime();
- var elapsedTime = (YAHOO.widget.Logger._lastTime) ?
- (msecs - YAHOO.widget.Logger._lastTime) : 0;
- YAHOO.widget.Logger._lastTime = msecs;
-
- var output =
- localTime + " (" +
- elapsedTime + "ms): " +
- oEntry.source + ": " +
- oEntry.msg;
-
- console.log(output);
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles logging of messages due to window error events.
- *
- * @method _onWindowError
- * @param sMsg {String} The error message.
- * @param sUrl {String} URL of the error.
- * @param sLine {String} Line number of the error.
- * @private
- */
-YAHOO.widget.Logger._onWindowError = function(sMsg,sUrl,sLine) {
- // Logger is not in scope of this event handler
- try {
- YAHOO.widget.Logger.log(sMsg+' ('+sUrl+', line '+sLine+')', "window");
- if(YAHOO.widget.Logger._origOnWindowError) {
- YAHOO.widget.Logger._origOnWindowError();
- }
- }
- catch(e) {
- return false;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Enable handling of native JavaScript errors
-// NB: Not all browsers support the window.onerror event
-//
-/////////////////////////////////////////////////////////////////////////////
-
-if(window.onerror) {
- // Save any previously defined handler to call
- YAHOO.widget.Logger._origOnWindowError = window.onerror;
-}
-window.onerror = YAHOO.widget.Logger._onWindowError;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// First log
-//
-/////////////////////////////////////////////////////////////////////////////
-
-YAHOO.widget.Logger.log("Logger initialized");
-
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogMsg class defines a single log message.
+ *
+ * @class LogMsg
+ * @constructor
+ * @param oConfigs {Object} Object literal of configuration params.
+ */
+ YAHOO.widget.LogMsg = function(oConfigs) {
+ // Parse configs
+ if (typeof oConfigs == "object") {
+ for(var param in oConfigs) {
+ this[param] = oConfigs[param];
+ }
+ }
+ };
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Log message.
+ *
+ * @property msg
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.msg = null;
+
+/**
+ * Log timestamp.
+ *
+ * @property time
+ * @type Date
+ */
+YAHOO.widget.LogMsg.prototype.time = null;
+
+/**
+ * Log category.
+ *
+ * @property category
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.category = null;
+
+/**
+ * Log source. The first word passed in as the source argument.
+ *
+ * @property source
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.source = null;
+
+/**
+ * Log source detail. The remainder of the string passed in as the source argument, not
+ * including the first word (if any).
+ *
+ * @property sourceDetail
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.sourceDetail = null;
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogWriter class provides a mechanism to log messages through
+ * YAHOO.widget.Logger from a named source.
+ *
+ * @class LogWriter
+ * @constructor
+ * @param sSource {String} Source of LogWriter instance.
+ */
+YAHOO.widget.LogWriter = function(sSource) {
+ if(!sSource) {
+ YAHOO.log("Could not instantiate LogWriter due to invalid source.",
+ "error", "LogWriter");
+ return;
+ }
+ this._source = sSource;
+ };
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the LogWriter instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the LogWriter instance.
+ */
+YAHOO.widget.LogWriter.prototype.toString = function() {
+ return "LogWriter " + this._sSource;
+};
+
+/**
+ * Logs a message attached to the source of the LogWriter.
+ *
+ * @method log
+ * @param sMsg {String} The log message.
+ * @param sCategory {String} Category name.
+ */
+YAHOO.widget.LogWriter.prototype.log = function(sMsg, sCategory) {
+ YAHOO.widget.Logger.log(sMsg, sCategory, this._source);
+};
+
+/**
+ * Public accessor to get the source name.
+ *
+ * @method getSource
+ * @return {String} The LogWriter source.
+ */
+YAHOO.widget.LogWriter.prototype.getSource = function() {
+ return this._sSource;
+};
+
+/**
+ * Public accessor to set the source name.
+ *
+ * @method setSource
+ * @param sSource {String} Source of LogWriter instance.
+ */
+YAHOO.widget.LogWriter.prototype.setSource = function(sSource) {
+ if(!sSource) {
+ YAHOO.log("Could not set source due to invalid source.", "error", this.toString());
+ return;
+ }
+ else {
+ this._sSource = sSource;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Source of the LogWriter instance.
+ *
+ * @property _source
+ * @type String
+ * @private
+ */
+YAHOO.widget.LogWriter.prototype._source = null;
+
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogReader class provides UI to read messages logged to YAHOO.widget.Logger.
+ *
+ * @class LogReader
+ * @constructor
+ * @param elContainer {HTMLElement} (optional) DOM element reference of an existing DIV.
+ * @param elContainer {String} (optional) String ID of an existing DIV.
+ * @param oConfigs {Object} (optional) Object literal of configuration params.
+ */
+YAHOO.widget.LogReader = function(elContainer, oConfigs) {
+ var oSelf = this;
+ this._sName = YAHOO.widget.LogReader._index;
+ YAHOO.widget.LogReader._index++;
+
+ // Parse config vars here
+ if (typeof oConfigs == "object") {
+ for(var param in oConfigs) {
+ this[param] = oConfigs[param];
+ }
+ }
+
+ // Attach container...
+ if(elContainer) {
+ if(typeof elContainer == "string") {
+ this._elContainer = document.getElementById(elContainer);
+ }
+ else if(elContainer.tagName) {
+ this._elContainer = elContainer;
+ }
+ this._elContainer.className = "yui-log";
+ }
+ // ...or create container from scratch
+ if(!this._elContainer) {
+ if(YAHOO.widget.LogReader._elDefaultContainer) {
+ this._elContainer = YAHOO.widget.LogReader._elDefaultContainer;
+ }
+ else {
+ this._elContainer = document.body.appendChild(document.createElement("div"));
+ this._elContainer.id = "yui-log";
+ this._elContainer.className = "yui-log";
+
+ YAHOO.widget.LogReader._elDefaultContainer = this._elContainer;
+ }
+
+ // If implementer has provided container values, trust and set those
+ var containerStyle = this._elContainer.style;
+ if(this.width) {
+ containerStyle.width = this.width;
+ }
+ if(this.right) {
+ containerStyle.right = this.right;
+ }
+ if(this.top) {
+ containerStyle.top = this.top;
+ }
+ if(this.left) {
+ containerStyle.left = this.left;
+ containerStyle.right = "auto";
+ }
+ if(this.bottom) {
+ containerStyle.bottom = this.bottom;
+ containerStyle.top = "auto";
+ }
+ if(this.fontSize) {
+ containerStyle.fontSize = this.fontSize;
+ }
+ if(window.opera) {
+ document.body.style += '';
+ }
+ }
+
+ if(this._elContainer) {
+ // Create header
+ if(!this._elHd) {
+ this._elHd = this._elContainer.appendChild(document.createElement("div"));
+ this._elHd.id = "yui-log-hd" + this._sName;
+ this._elHd.className = "yui-log-hd";
+
+ this._elCollapse = this._elHd.appendChild(document.createElement("div"));
+ this._elCollapse.className = "yui-log-btns";
+
+ this._btnCollapse = document.createElement("input");
+ this._btnCollapse.type = "button";
+ this._btnCollapse.style.fontSize =
+ YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");
+ this._btnCollapse.className = "yui-log-button";
+ this._btnCollapse.value = "Collapse";
+ this._btnCollapse = this._elCollapse.appendChild(this._btnCollapse);
+ YAHOO.util.Event.addListener(
+ oSelf._btnCollapse,'click',oSelf._onClickCollapseBtn,oSelf);
+
+ this._title = this._elHd.appendChild(document.createElement("h4"));
+ this._title.innerHTML = "Logger Console";
+
+ // If Drag and Drop utility is available...
+ // ...and this container was created from scratch...
+ // ...then make the header draggable
+ if(YAHOO.util.DD &&
+ (YAHOO.widget.LogReader._elDefaultContainer == this._elContainer)) {
+ var ylog_dd = new YAHOO.util.DD(this._elContainer.id);
+ ylog_dd.setHandleElId(this._elHd.id);
+ this._elHd.style.cursor = "move";
+ }
+ }
+ // Ceate console
+ if(!this._elConsole) {
+ this._elConsole =
+ this._elContainer.appendChild(document.createElement("div"));
+ this._elConsole.className = "yui-log-bd";
+
+ // If implementer has provided console, trust and set those
+ if(this.height) {
+ this._elConsole.style.height = this.height;
+ }
+ }
+ // Don't create footer if disabled
+ if(!this._elFt && this.footerEnabled) {
+ this._elFt = this._elContainer.appendChild(document.createElement("div"));
+ this._elFt.className = "yui-log-ft";
+
+ this._elBtns = this._elFt.appendChild(document.createElement("div"));
+ this._elBtns.className = "yui-log-btns";
+
+ this._btnPause = document.createElement("input");
+ this._btnPause.type = "button";
+ this._btnPause.style.fontSize =
+ YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");
+ this._btnPause.className = "yui-log-button";
+ this._btnPause.value = "Pause";
+ this._btnPause = this._elBtns.appendChild(this._btnPause);
+ YAHOO.util.Event.addListener(
+ oSelf._btnPause,'click',oSelf._onClickPauseBtn,oSelf);
+
+ this._btnClear = document.createElement("input");
+ this._btnClear.type = "button";
+ this._btnClear.style.fontSize =
+ YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");
+ this._btnClear.className = "yui-log-button";
+ this._btnClear.value = "Clear";
+ this._btnClear = this._elBtns.appendChild(this._btnClear);
+ YAHOO.util.Event.addListener(
+ oSelf._btnClear,'click',oSelf._onClickClearBtn,oSelf);
+
+ this._elCategoryFilters = this._elFt.appendChild(document.createElement("div"));
+ this._elCategoryFilters.className = "yui-log-categoryfilters";
+ this._elSourceFilters = this._elFt.appendChild(document.createElement("div"));
+ this._elSourceFilters.className = "yui-log-sourcefilters";
+ }
+ }
+
+ // Initialize internal vars
+ if(!this._buffer) {
+ this._buffer = []; // output buffer
+ }
+ // Timestamp of last log message to console
+ this._lastTime = YAHOO.widget.Logger.getStartTime();
+
+ // Subscribe to Logger custom events
+ YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog, this);
+ YAHOO.widget.Logger.logResetEvent.subscribe(this._onReset, this);
+
+ // Initialize category filters
+ this._categoryFilters = [];
+ var catsLen = YAHOO.widget.Logger.categories.length;
+ if(this._elCategoryFilters) {
+ for(var i=0; i < catsLen; i++) {
+ this._createCategoryCheckbox(YAHOO.widget.Logger.categories[i]);
+ }
+ }
+ // Initialize source filters
+ this._sourceFilters = [];
+ var sourcesLen = YAHOO.widget.Logger.sources.length;
+ if(this._elSourceFilters) {
+ for(var j=0; j < sourcesLen; j++) {
+ this._createSourceCheckbox(YAHOO.widget.Logger.sources[j]);
+ }
+ }
+ YAHOO.widget.Logger.categoryCreateEvent.subscribe(this._onCategoryCreate, this);
+ YAHOO.widget.Logger.sourceCreateEvent.subscribe(this._onSourceCreate, this);
+
+ this._filterLogs();
+ YAHOO.log("LogReader initialized", null, this.toString());
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Whether or not the log reader is enabled to output log messages.
+ *
+ * @property logReaderEnabled
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.logReaderEnabled = true;
+
+/**
+ * Public member to access CSS width of the log reader container.
+ *
+ * @property width
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.width = null;
+
+/**
+ * Public member to access CSS height of the log reader container.
+ *
+ * @property height
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.height = null;
+
+/**
+ * Public member to access CSS top position of the log reader container.
+ *
+ * @property top
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.top = null;
+
+/**
+ * Public member to access CSS left position of the log reader container.
+ *
+ * @property left
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.left = null;
+
+/**
+ * Public member to access CSS right position of the log reader container.
+ *
+ * @property right
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.right = null;
+
+/**
+ * Public member to access CSS bottom position of the log reader container.
+ *
+ * @property bottom
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.bottom = null;
+
+/**
+ * Public member to access CSS font size of the log reader container.
+ *
+ * @property fontSize
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.fontSize = null;
+
+/**
+ * Whether or not the footer UI is enabled for the log reader.
+ *
+ * @property footerEnabled
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.footerEnabled = true;
+
+/**
+ * Whether or not output is verbose (more readable). Setting to true will make
+ * output more compact (less readable).
+ *
+ * @property verboseOutput
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.verboseOutput = true;
+
+/**
+ * Whether or not newest message is printed on top.
+ *
+ * @property newestOnTop
+ * @type Boolean
+ */
+YAHOO.widget.LogReader.prototype.newestOnTop = true;
+
+/**
+ * Maximum number of messages a LogReader console will display.
+ *
+ * @property thresholdMax
+ * @type Number
+ * @default 500
+ */
+YAHOO.widget.LogReader.prototype.thresholdMax = 500;
+
+/**
+ * When a LogReader console reaches its thresholdMax, it will clear out messages
+ * and print out the latest thresholdMin number of messages.
+ *
+ * @property thresholdMin
+ * @type Number
+ * @default 100
+ */
+YAHOO.widget.LogReader.prototype.thresholdMin = 100;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the LogReader instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the LogReader instance.
+ */
+YAHOO.widget.LogReader.prototype.toString = function() {
+ return "LogReader instance" + this._sName;
+};
+/**
+ * Pauses output of log messages. While paused, log messages are not lost, but
+ * get saved to a buffer and then output upon resume of log reader.
+ *
+ * @method pause
+ */
+YAHOO.widget.LogReader.prototype.pause = function() {
+ this._timeout = null;
+ this.logReaderEnabled = false;
+};
+
+/**
+ * Resumes output of log messages, including outputting any log messages that
+ * have been saved to buffer while paused.
+ *
+ * @method resume
+ */
+YAHOO.widget.LogReader.prototype.resume = function() {
+ this.logReaderEnabled = true;
+ this._printBuffer();
+};
+
+/**
+ * Hides UI of log reader. Logging functionality is not disrupted.
+ *
+ * @method hide
+ */
+YAHOO.widget.LogReader.prototype.hide = function() {
+ this._elContainer.style.display = "none";
+};
+
+/**
+ * Shows UI of log reader. Logging functionality is not disrupted.
+ *
+ * @method show
+ */
+YAHOO.widget.LogReader.prototype.show = function() {
+ this._elContainer.style.display = "block";
+};
+
+/**
+ * Updates title to given string.
+ *
+ * @method setTitle
+ * @param sTitle {String} New title.
+ */
+YAHOO.widget.LogReader.prototype.setTitle = function(sTitle) {
+ this._title.innerHTML = this.html2Text(sTitle);
+};
+
+/**
+ * Gets timestamp of the last log.
+ *
+ * @method getLastTime
+ * @return {Date} Timestamp of the last log.
+ */
+YAHOO.widget.LogReader.prototype.getLastTime = function() {
+ return this._lastTime;
+};
+
+/**
+ * Formats message string to HTML for output to console.
+ *
+ * @method formatMsg
+ * @param oLogMsg {Object} Log message object.
+ * @return {String} HTML-formatted message for output to console.
+ */
+YAHOO.widget.LogReader.prototype.formatMsg = function(oLogMsg) {
+ var category = oLogMsg.category;
+
+ // Label for color-coded display
+ var label = category.substring(0,4).toUpperCase();
+
+ // Calculate the elapsed time to be from the last item that passed through the filter,
+ // not the absolute previous item in the stack
+
+ var time = oLogMsg.time;
+ if (time.toLocaleTimeString) {
+ var localTime = time.toLocaleTimeString();
+ }
+ else {
+ localTime = time.toString();
+ }
+
+ var msecs = time.getTime();
+ var startTime = YAHOO.widget.Logger.getStartTime();
+ var totalTime = msecs - startTime;
+ var elapsedTime = msecs - this.getLastTime();
+
+ var source = oLogMsg.source;
+ var sourceDetail = oLogMsg.sourceDetail;
+ var sourceAndDetail = (sourceDetail) ?
+ source + " " + sourceDetail : source;
+
+ // Escape HTML entities in the log message itself for output to console
+ var msg = this.html2Text(oLogMsg.msg);
+
+ // Verbose output includes extra line breaks
+ var output = (this.verboseOutput) ?
+ ["", label, " ",
+ totalTime, "ms (+", elapsedTime, ") ",
+ localTime, ": ",
+ "
",
+ sourceAndDetail,
+ ":
",
+ msg,
+ "
"] :
+
+ ["", label, " ",
+ totalTime, "ms (+", elapsedTime, ") ",
+ localTime, ": ",
+ sourceAndDetail, ": ",
+ msg,"
"];
+
+ return output.join("");
+};
+
+/**
+ * Converts input chars "<", ">", and "&" to HTML entities.
+ *
+ * @method html2Text
+ * @param sHtml {String} String to convert.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype.html2Text = function(sHtml) {
+ if(sHtml) {
+ sHtml += "";
+ return sHtml.replace(/&/g, "&").replace(//g, ">");
+ }
+ return "";
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Internal class member to index multiple log reader instances.
+ *
+ * @property _memberName
+ * @static
+ * @type Number
+ * @default 0
+ * @private
+ */
+YAHOO.widget.LogReader._index = 0;
+
+/**
+ * Name of LogReader instance.
+ *
+ * @property _sName
+ * @type String
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._sName = null;
+
+/**
+ * A class member shared by all log readers if a container needs to be
+ * created during instantiation. Will be null if a container element never needs to
+ * be created on the fly, such as when the implementer passes in their own element.
+ *
+ * @property _elDefaultContainer
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader._elDefaultContainer = null;
+
+/**
+ * Buffer of log message objects for batch output.
+ *
+ * @property _buffer
+ * @type Object[]
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._buffer = null;
+
+/**
+ * Number of log messages output to console.
+ *
+ * @property _consoleMsgCount
+ * @type Number
+ * @default 0
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._consoleMsgCount = 0;
+
+/**
+ * Date of last output log message.
+ *
+ * @property _lastTime
+ * @type Date
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._lastTime = null;
+
+/**
+ * Batched output timeout ID.
+ *
+ * @property _timeout
+ * @type Number
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._timeout = null;
+
+/**
+ * Array of filters for log message categories.
+ *
+ * @property _categoryFilters
+ * @type String[]
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._categoryFilters = null;
+
+/**
+ * Array of filters for log message sources.
+ *
+ * @property _sourceFilters
+ * @type String[]
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._sourceFilters = null;
+
+/**
+ * Log reader container element.
+ *
+ * @property _elContainer
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elContainer = null;
+
+/**
+ * Log reader header element.
+ *
+ * @property _elHd
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elHd = null;
+
+/**
+ * Log reader collapse element.
+ *
+ * @property _elCollapse
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elCollapse = null;
+
+/**
+ * Log reader collapse button element.
+ *
+ * @property _btnCollapse
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._btnCollapse = null;
+
+/**
+ * Log reader title header element.
+ *
+ * @property _title
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._title = null;
+
+/**
+ * Log reader console element.
+ *
+ * @property _elConsole
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elConsole = null;
+
+/**
+ * Log reader footer element.
+ *
+ * @property _elFt
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elFt = null;
+
+/**
+ * Log reader buttons container element.
+ *
+ * @property _elBtns
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elBtns = null;
+
+/**
+ * Container element for log reader category filter checkboxes.
+ *
+ * @property _elCategoryFilters
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elCategoryFilters = null;
+
+/**
+ * Container element for log reader source filter checkboxes.
+ *
+ * @property _elSourceFilters
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._elSourceFilters = null;
+
+/**
+ * Log reader pause button element.
+ *
+ * @property _btnPause
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._btnPause = null;
+
+/**
+ * Clear button element.
+ *
+ * @property _btnClear
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._btnClear = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Creates the UI for a category filter in the log reader footer element.
+ *
+ * @method _createCategoryCheckbox
+ * @param sCategory {String} Category name.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(sCategory) {
+ var oSelf = this;
+
+ if(this._elFt) {
+ var elParent = this._elCategoryFilters;
+ var filters = this._categoryFilters;
+
+ var elFilter = elParent.appendChild(document.createElement("span"));
+ elFilter.className = "yui-log-filtergrp";
+ // Append el at the end so IE 5.5 can set "type" attribute
+ // and THEN set checked property
+ var chkCategory = document.createElement("input");
+ chkCategory.id = "yui-log-filter-" + sCategory + this._sName;
+ chkCategory.className = "yui-log-filter-" + sCategory;
+ chkCategory.type = "checkbox";
+ chkCategory.category = sCategory;
+ chkCategory = elFilter.appendChild(chkCategory);
+ chkCategory.checked = true;
+
+ // Add this checked filter to the internal array of filters
+ filters.push(sCategory);
+ // Subscribe to the click event
+ YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf);
+
+ // Create and class the text label
+ var lblCategory = elFilter.appendChild(document.createElement("label"));
+ lblCategory.htmlFor = chkCategory.id;
+ lblCategory.className = sCategory;
+ lblCategory.innerHTML = sCategory;
+ }
+};
+
+/**
+ * Creates a checkbox in the log reader footer element to filter by source.
+ *
+ * @method _createSourceCheckbox
+ * @param sSource {String} Source name.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(sSource) {
+ var oSelf = this;
+
+ if(this._elFt) {
+ var elParent = this._elSourceFilters;
+ var filters = this._sourceFilters;
+
+ var elFilter = elParent.appendChild(document.createElement("span"));
+ elFilter.className = "yui-log-filtergrp";
+
+ // Append el at the end so IE 5.5 can set "type" attribute
+ // and THEN set checked property
+ var chkSource = document.createElement("input");
+ chkSource.id = "yui-log-filter" + sSource + this._sName;
+ chkSource.className = "yui-log-filter" + sSource;
+ chkSource.type = "checkbox";
+ chkSource.source = sSource;
+ chkSource = elFilter.appendChild(chkSource);
+ chkSource.checked = true;
+
+ // Add this checked filter to the internal array of filters
+ filters.push(sSource);
+ // Subscribe to the click event
+ YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf);
+
+ // Create and class the text label
+ var lblSource = elFilter.appendChild(document.createElement("label"));
+ lblSource.htmlFor = chkSource.id;
+ lblSource.className = sSource;
+ lblSource.innerHTML = sSource;
+ }
+};
+
+/**
+ * Reprints all log messages in the stack through filters.
+ *
+ * @method _filterLogs
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._filterLogs = function() {
+ // Reprint stack with new filters
+ if (this._elConsole !== null) {
+ this._clearConsole();
+ this._printToConsole(YAHOO.widget.Logger.getStack());
+ }
+};
+
+/**
+ * Clears all outputted log messages from the console and resets the time of the
+ * last output log message.
+ *
+ * @method _clearConsole
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._clearConsole = function() {
+ // Clear the buffer of any pending messages
+ this._timeout = null;
+ this._buffer = [];
+ this._consoleMsgCount = 0;
+
+ // Reset the rolling timer
+ this._lastTime = YAHOO.widget.Logger.getStartTime();
+
+ var elConsole = this._elConsole;
+ while(elConsole.hasChildNodes()) {
+ elConsole.removeChild(elConsole.firstChild);
+ }
+};
+
+/**
+ * Sends buffer of log messages to output and clears buffer.
+ *
+ * @method _printBuffer
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._printBuffer = function() {
+ this._timeout = null;
+
+ if(this._elConsole !== null) {
+ var thresholdMax = this.thresholdMax;
+ thresholdMax = (thresholdMax && !isNaN(thresholdMax)) ? thresholdMax : 500;
+ if(this._consoleMsgCount < thresholdMax) {
+ var entries = [];
+ for (var i=0; i this.thresholdMax)) {
+ thresholdMin = 0;
+ }
+ var entriesStartIndex = (entriesLen > thresholdMin) ? (entriesLen - thresholdMin) : 0;
+
+ // Iterate through all log entries
+ var sourceFiltersLen = this._sourceFilters.length;
+ var categoryFiltersLen = this._categoryFilters.length;
+ for(var i=entriesStartIndex; i tag instead of tag (for wrapping)
+ var container = (this.verboseOutput) ? "CODE" : "PRE";
+ var oNewElement = (this.newestOnTop) ?
+ this._elConsole.insertBefore(
+ document.createElement(container),this._elConsole.firstChild):
+ this._elConsole.appendChild(document.createElement(container));
+
+ oNewElement.innerHTML = output;
+ this._consoleMsgCount++;
+ this._lastTime = entry.time.getTime();
+ }
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private event handlers
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Handles Logger's categoryCreateEvent.
+ *
+ * @method _onCategoryCreate
+ * @param sType {String} The event.
+ * @param aArgs {Object[]} Data passed from event firer.
+ * @param oSelf {Object} The LogReader instance.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCategoryCreate = function(sType, aArgs, oSelf) {
+ var category = aArgs[0];
+ if(oSelf._elFt) {
+ oSelf._createCategoryCheckbox(category);
+ }
+};
+
+/**
+ * Handles Logger's sourceCreateEvent.
+ *
+ * @method _onSourceCreate
+ * @param sType {String} The event.
+ * @param aArgs {Object[]} Data passed from event firer.
+ * @param oSelf {Object} The LogReader instance.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onSourceCreate = function(sType, aArgs, oSelf) {
+ var source = aArgs[0];
+ if(oSelf._elFt) {
+ oSelf._createSourceCheckbox(source);
+ }
+};
+
+/**
+ * Handles check events on the category filter checkboxes.
+ *
+ * @method _onCheckCategory
+ * @param v {HTMLEvent} The click event.
+ * @param oSelf {Object} The LogReader instance.
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCheckCategory = function(v, oSelf) {
+ var newFilter = this.category;
+ var filtersArray = oSelf._categoryFilters;
+
+ if(!this.checked) { // Remove category from filters
+ for(var i=0; i 0) {
+ // Substring until first space
+ sClass = sSource.substring(0,spaceIndex);
+ // The rest of the source
+ sDetail = sSource.substring(spaceIndex,sSource.length);
+ }
+ else {
+ sClass = sSource;
+ }
+ if(this._isNewSource(sClass)) {
+ this._createNewSource(sClass);
+ }
+ }
+
+ var timestamp = new Date();
+ var logEntry = new YAHOO.widget.LogMsg({
+ msg: sMsg,
+ time: timestamp,
+ category: sCategory,
+ source: sClass,
+ sourceDetail: sDetail
+ });
+
+ var stack = this._stack;
+ var maxStackEntries = this.maxStackEntries;
+ if(maxStackEntries && !isNaN(maxStackEntries) &&
+ (stack.length >= maxStackEntries)) {
+ stack.shift();
+ }
+ stack.push(logEntry);
+ this.newLogEvent.fire(logEntry);
+
+ if(this._browserConsoleEnabled) {
+ this._printToBrowserConsole(logEntry);
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+};
+
+/**
+ * Resets internal stack and startTime, enables Logger, and fires logResetEvent.
+ *
+ * @method reset
+ */
+YAHOO.widget.Logger.reset = function() {
+ this._stack = [];
+ this._startTime = new Date().getTime();
+ this.loggerEnabled = true;
+ this.log("Logger reset");
+ this.logResetEvent.fire();
+};
+
+/**
+ * Public accessor to internal stack of log message objects.
+ *
+ * @method getStack
+ * @return {Object[]} Array of log message objects.
+ */
+YAHOO.widget.Logger.getStack = function() {
+ return this._stack;
+};
+
+/**
+ * Public accessor to internal start time.
+ *
+ * @method getStartTime
+ * @return {Date} Internal date of when Logger singleton was initialized.
+ */
+YAHOO.widget.Logger.getStartTime = function() {
+ return this._startTime;
+};
+
+/**
+ * Disables output to the browser's global console.log() function, which is used
+ * by the Firebug extension to Firefox as well as Safari.
+ *
+ * @method disableBrowserConsole
+ */
+YAHOO.widget.Logger.disableBrowserConsole = function() {
+ YAHOO.log("Logger output to the function console.log() has been disabled.");
+ this._browserConsoleEnabled = false;
+};
+
+/**
+ * Enables output to the browser's global console.log() function, which is used
+ * by the Firebug extension to Firefox as well as Safari.
+ *
+ * @method enableBrowserConsole
+ */
+YAHOO.widget.Logger.enableBrowserConsole = function() {
+ this._browserConsoleEnabled = true;
+ YAHOO.log("Logger output to the function console.log() has been enabled.");
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public events
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Fired when a new category has been created.
+ *
+ * @event categoryCreateEvent
+ * @param sCategory {String} Category name.
+ */
+YAHOO.widget.Logger.categoryCreateEvent =
+ new YAHOO.util.CustomEvent("categoryCreate", this, true);
+
+ /**
+ * Fired when a new source has been named.
+ *
+ * @event sourceCreateEvent
+ * @param sSource {String} Source name.
+ */
+YAHOO.widget.Logger.sourceCreateEvent =
+ new YAHOO.util.CustomEvent("sourceCreate", this, true);
+
+ /**
+ * Fired when a new log message has been created.
+ *
+ * @event newLogEvent
+ * @param sMsg {String} Log message.
+ */
+YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true);
+
+/**
+ * Fired when the Logger has been reset has been created.
+ *
+ * @event logResetEvent
+ */
+YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true);
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Creates a new category of log messages and fires categoryCreateEvent.
+ *
+ * @method _createNewCategory
+ * @param sCategory {String} Category name.
+ * @private
+ */
+YAHOO.widget.Logger._createNewCategory = function(sCategory) {
+ this.categories.push(sCategory);
+ this.categoryCreateEvent.fire(sCategory);
+};
+
+/**
+ * Checks to see if a category has already been created.
+ *
+ * @method _isNewCategory
+ * @param sCategory {String} Category name.
+ * @return {Boolean} Returns true if category is unknown, else returns false.
+ * @private
+ */
+YAHOO.widget.Logger._isNewCategory = function(sCategory) {
+ for(var i=0; i < this.categories.length; i++) {
+ if(sCategory == this.categories[i]) {
+ return false;
+ }
+ }
+ return true;
+};
+
+/**
+ * Creates a new source of log messages and fires sourceCreateEvent.
+ *
+ * @method _createNewSource
+ * @param sSource {String} Source name.
+ * @private
+ */
+YAHOO.widget.Logger._createNewSource = function(sSource) {
+ this.sources.push(sSource);
+ this.sourceCreateEvent.fire(sSource);
+};
+
+/**
+ * Checks to see if a source already exists.
+ *
+ * @method _isNewSource
+ * @param sSource {String} Source name.
+ * @return {Boolean} Returns true if source is unknown, else returns false.
+ * @private
+ */
+YAHOO.widget.Logger._isNewSource = function(sSource) {
+ if(sSource) {
+ for(var i=0; i < this.sources.length; i++) {
+ if(sSource == this.sources[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+};
+
+/**
+ * Outputs a log message to global console.log() function.
+ *
+ * @method _printToBrowserConsole
+ * @param oEntry {Object} Log entry object.
+ * @private
+ */
+YAHOO.widget.Logger._printToBrowserConsole = function(oEntry) {
+ if(window.console && console.log) {
+ var category = oEntry.category;
+ var label = oEntry.category.substring(0,4).toUpperCase();
+
+ var time = oEntry.time;
+ if (time.toLocaleTimeString) {
+ var localTime = time.toLocaleTimeString();
+ }
+ else {
+ localTime = time.toString();
+ }
+
+ var msecs = time.getTime();
+ var elapsedTime = (YAHOO.widget.Logger._lastTime) ?
+ (msecs - YAHOO.widget.Logger._lastTime) : 0;
+ YAHOO.widget.Logger._lastTime = msecs;
+
+ var output =
+ localTime + " (" +
+ elapsedTime + "ms): " +
+ oEntry.source + ": " +
+ oEntry.msg;
+
+ console.log(output);
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private event handlers
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Handles logging of messages due to window error events.
+ *
+ * @method _onWindowError
+ * @param sMsg {String} The error message.
+ * @param sUrl {String} URL of the error.
+ * @param sLine {String} Line number of the error.
+ * @private
+ */
+YAHOO.widget.Logger._onWindowError = function(sMsg,sUrl,sLine) {
+ // Logger is not in scope of this event handler
+ try {
+ YAHOO.widget.Logger.log(sMsg+' ('+sUrl+', line '+sLine+')', "window");
+ if(YAHOO.widget.Logger._origOnWindowError) {
+ YAHOO.widget.Logger._origOnWindowError();
+ }
+ }
+ catch(e) {
+ return false;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Enable handling of native JavaScript errors
+// NB: Not all browsers support the window.onerror event
+//
+/////////////////////////////////////////////////////////////////////////////
+
+if(window.onerror) {
+ // Save any previously defined handler to call
+ YAHOO.widget.Logger._origOnWindowError = window.onerror;
+}
+window.onerror = YAHOO.widget.Logger._onWindowError;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// First log
+//
+/////////////////////////////////////////////////////////////////////////////
+
+YAHOO.widget.Logger.log("Logger initialized");
+
diff --git a/lib/yui/menu/README b/lib/yui/menu/README
index 60478ec391..30e675ccb9 100755
--- a/lib/yui/menu/README
+++ b/lib/yui/menu/README
@@ -1,247 +1,251 @@
-Menu Release Notes
-
-*** version 0.10.0 ***
-
-* Initial release
-
-* Known issues:
-
- * Some Firefox extensions disable the ability for JavaScript to prevent
- the display of the browser's default context menu. These extensions
- can cause the YUI ContextMenu to stop working. If you encounter this
- problem, you can reset the context menu preference in Firefox back to
- the default by making sure the "Disable or replace context menus"
- preference is checked:
-
- Mac Firefox 1.0:
- -------------------
- Preferences > Web Features >
- Advanced... > Disable or replace context menus
-
- Mac Firefox 1.5
- -------------------
- Preferences > Context >
- Advanced... > Disable or replace context menus
-
- Windows Firefox 1.0
- -------------------
- Tools > Options > Web Features >
- Advanced... > Disable or replace context menus
-
- Windows Firefox 1.5
- -------------------
- Tools > Options > Context >
- Advanced... > Disable or replace context menus
-
-
-*** version 0.11.0 ***
-
-Added the following features:
------------------------------
-* Overloaded the "addItem" and "insertItem" methods of MenuModule to accept a
- string or a MenuModuleItem instance
-
-* Added the ability to define a MenuItem instance as being "checked"
-
-
-Fixed the following bugs:
--------------------------
-* Changing the path for the submenu indicator image of one MenuModuleItem
- subclass will no longer affect other subclasses
-
-* MenuItem instances built from existing markup without anchor tags will no
- longer trigger a JavaScript error when clicked
-
-* Modified the implementation of the "imageRoot" property for the
- MenuModuleItem class so that it is set to a secure/non-secure path when the
- object is instantiated
-
-* Menu instances now resize in response to changes to the browser's font size
-
-* Modified the propagation of the MenuModule class's "submenualignment"
- configuration property so that it only applies to instances of the same type
-
-* Adjusted the specificity of the style rule that controls the position of a
- MenuItem instance's submenu indicator image to prevent it from wrapping in IE
-
-* Specified a width and height for submenu indicator images in the Menu
- stylesheet to ensure that Menu instances are always rendered at the correct
- width
-
-* Clicking a MenuItem instance will no longer trigger two HTTP GET requests
-
-* Users can now control or shift-click on MenuItem links
-
-
-Changes:
---------
-* In the Menu stylesheet (menu.css), switched from using "first" class to
- "first-of-type" class
-
-* Changed case of MenuModuleItem class's "subMenuIndicator" property
- to "submenuIndicator"
-
-
-*** version 0.11.3 ***
-
-Added the following features:
------------------------------
-
-* Added a "target" configuration property to the MenuModuleItem object that
- allows the user to specify the target of an item's anchor element. Items
- that make use of the "target" configuration property will require the user
- to click exactly on the item's anchor element to navigate to the specified
- URL.
-
-* Items without a "url" property set will automatically hide their parent
- menu instance(s) when clicked.
-
-
-Fixed the following bugs:
--------------------------
-
-* Items in a submenu should now navigate to their specified URL when clicked.
-
-* Removed MenuBar's use of "overflow:hidden." This fixes an issue in Firefox
- 1.5 in which submenus of a Menubar instance cannot overlay other absolutely
- positioned elements on the page.
-
-* Submenus of a Menubar instance will now automatically have their iframe shim
- enabled in IE<7.
-
-* Statically positioned Menubar and Menu instances will now render with the
- correct position and dimensions in Safari.
-
-* MenuModuleItem's "focus" method now checks to make sure that an item's
- "display" style property is not "none" before trying to set focus to its
- anchor element.
-
-* A ContextMenu instance will now hide all other ContextMenu instances before
- displaying itself.
-
-* Removed the dead space in front of an item's submenu indicator image in IE.
- This space was causing an item's submenu to flicker when the user hovered
- over it.
-
-
-Changes:
---------
-
-* Moved the DOM event handlers for every menu from the root DIV node of each
- instance to the document object. This change reduces the number of DOM event
- handlers used by Menu to eight, improving the cleanup time required by the
- Event utility.
-
-
-*** version 0.12 ***
-
-Added the following features:
------------------------------
-
-* Added the YAHOO.widget.MenuManager singleton class.
-
-* Added two new methods to YAHOO.widget.Menu:
-
- * "addItems" - Adds an array of items to a menu.
-
- * "getRoot" - Returns the root menu in a menu hierarchy.
-
-* Added two new events to YAHOO.widget.Menu:
-
- * "itemAddedEvent" - Fires when an item is added to a menu.
-
- * "itemRemovedEvent" - Fires when an item is removed from a menu.
-
-* Added two new properties to YAHOO.widget.Menu:
-
- * "itemData" - Array of items to be added to the menu.
-
- * "lazyLoad" - Boolean indicating if the menu's "lazy load" feature
- is enabled.
-
-* Added new configuration properties to YAHOO.widget.Menu:
-
- * "hidedelay" - Hides the menu after the specified number of milliseconds.
-
- * "showdelay" - Shows the menu after the specified number of milliseconds.
-
- * "container" - The containing element the menu should be rendered into.
-
- * "clicktohide" - Boolean indicating if the menu will automatically be
- hidden if the user clicks outside of it.
-
- * "autosubmenudisplay" - Boolean indicating if submenus are automatically
- made visible when the user mouses over the menu's items.
-
-* Added a "toString" method to YAHOO.widget.MenuItem, YAHOO.widget.MenuBarItem
- and YAHOO.widget.ContextMenuItem that returns the class name followed by the
- value of the item's "text" configuration property.
-
-
-Fixed the following bugs:
--------------------------
-
-* Setting a YAHOO.widget.ContextMenu instance's "trigger" configuration
- property will remove all previous triggers before setting up the new ones.
-
-* "destroy" method of YAHOO.widget.ContextMenu cleans up all DOM event handlers.
-
-* Clicking on a menu item with a submenu no longer hides/collapses the
- entire menu.
-
-* Clicking an item's submenu indicator image no longer collapses the
- entire menu.
-
-
-Changes:
---------
-
-* Deprecated the YAHOO.widget.MenuModule and YAHOO.widget.MenuModuleItem
- classes. The Base classes are now YAHOO.widget.Menu and
- YAHOO.widget.MenuItem.
-
-* "addItem" and "insertItem" methods of YAHOO.widget.Menu now accept an
- object literal representing YAHOO.widget.MenuItem configuration properties.
-
-* "clearActiveItem" now takes an argument: flag indicating if the Menu
- instance's active item should be blurred.
-
-* Switched the default value of the "visible" configuration property for
- YAHOO.widget.Menu to "false."
-
-* Switched the default value of the "constraintoviewport" configuration
- property for YAHOO.widget.Menu to "true."
-
-* Overloaded the "submenu" configuration property for YAHOO.widget.MenuItem
- so that it now can accept any of the following:
-
- * YAHOO.widget.Menu instance
- * Object literal representation of a menu
- * Element id
- * Element reference
-
-* "hide" and "show" methods of statically positioned menus now toggle the their
- element's "display" style property between "block" and "none."
-
-
-*** version 0.12.1 ***
-
-Fixed the following bugs:
--------------------------
-
-* Placed the call to the DOM "focus" method used by the MenuItem class inside
- a zero-second timeout to resolve a race condition between menu positioning
- and focusing of a menu item that resulted in the browser viewport
- scrolling unnecessarily.
-
-* Switched to JSMin for JavaScript compression to resolve issues with the
- minified version.
-
-* Disabled menu item instances will no longer display a submenu if the item is
- clicked or moused over.
-
-* Can no longer select more than one item in a menu if using the keyboard and
- mouse simultaneously.
-
-* Calling the "destory" method on a menu will now unregister all of the menu's
- submenus from the MenuManager.
\ No newline at end of file
+Menu Release Notes
+
+*** version 0.12.1 ***
+
+Fixed the following bugs:
+-------------------------
+
+* Placed the call to the DOM "focus" method used by the MenuItem class inside
+ a zero-second timeout to resolve a race condition between menu positioning
+ and focusing of a menu item that resulted in the browser viewport
+ scrolling unnecessarily.
+
+* Switched to JSMin for JavaScript compression to resolve issues with the
+ minified version.
+
+* Disabled menu item instances will no longer display a submenu if the item is
+ clicked or moused over.
+
+* Can no longer select more than one item in a menu if using the keyboard and
+ mouse simultaneously.
+
+* Calling the "destory" method on a menu will now unregister all of the menu's
+ submenus from the MenuManager.
+
+
+
+*** version 0.12 ***
+
+Added the following features:
+-----------------------------
+
+* Added the YAHOO.widget.MenuManager singleton class.
+
+* Added two new methods to YAHOO.widget.Menu:
+
+ * "addItems" - Adds an array of items to a menu.
+
+ * "getRoot" - Returns the root menu in a menu hierarchy.
+
+* Added two new events to YAHOO.widget.Menu:
+
+ * "itemAddedEvent" - Fires when an item is added to a menu.
+
+ * "itemRemovedEvent" - Fires when an item is removed from a menu.
+
+* Added two new properties to YAHOO.widget.Menu:
+
+ * "itemData" - Array of items to be added to the menu.
+
+ * "lazyLoad" - Boolean indicating if the menu's "lazy load" feature
+ is enabled.
+
+* Added new configuration properties to YAHOO.widget.Menu:
+
+ * "hidedelay" - Hides the menu after the specified number of milliseconds.
+
+ * "showdelay" - Shows the menu after the specified number of milliseconds.
+
+ * "container" - The containing element the menu should be rendered into.
+
+ * "clicktohide" - Boolean indicating if the menu will automatically be
+ hidden if the user clicks outside of it.
+
+ * "autosubmenudisplay" - Boolean indicating if submenus are automatically
+ made visible when the user mouses over the menu's items.
+
+* Added a "toString" method to YAHOO.widget.MenuItem, YAHOO.widget.MenuBarItem
+ and YAHOO.widget.ContextMenuItem that returns the class name followed by the
+ value of the item's "text" configuration property.
+
+
+Fixed the following bugs:
+-------------------------
+
+* Setting a YAHOO.widget.ContextMenu instance's "trigger" configuration
+ property will remove all previous triggers before setting up the new ones.
+
+* "destroy" method of YAHOO.widget.ContextMenu cleans up all DOM event handlers.
+
+* Clicking on a menu item with a submenu no longer hides/collapses the
+ entire menu.
+
+* Clicking an item's submenu indicator image no longer collapses the
+ entire menu.
+
+
+Changes:
+--------
+
+* Deprecated the YAHOO.widget.MenuModule and YAHOO.widget.MenuModuleItem
+ classes. The Base classes are now YAHOO.widget.Menu and
+ YAHOO.widget.MenuItem.
+
+* "addItem" and "insertItem" methods of YAHOO.widget.Menu now accept an
+ object literal representing YAHOO.widget.MenuItem configuration properties.
+
+* "clearActiveItem" now takes an argument: flag indicating if the Menu
+ instance's active item should be blurred.
+
+* Switched the default value of the "visible" configuration property for
+ YAHOO.widget.Menu to "false."
+
+* Switched the default value of the "constraintoviewport" configuration
+ property for YAHOO.widget.Menu to "true."
+
+* Overloaded the "submenu" configuration property for YAHOO.widget.MenuItem
+ so that it now can accept any of the following:
+
+ * YAHOO.widget.Menu instance
+ * Object literal representation of a menu
+ * Element id
+ * Element reference
+
+* "hide" and "show" methods of statically positioned menus now toggle the their
+ element's "display" style property between "block" and "none."
+
+
+
+*** version 0.10.0 ***
+
+* Initial release
+
+* Known issues:
+
+ * Some Firefox extensions disable the ability for JavaScript to prevent
+ the display of the browser's default context menu. These extensions
+ can cause the YUI ContextMenu to stop working. If you encounter this
+ problem, you can reset the context menu preference in Firefox back to
+ the default by making sure the "Disable or replace context menus"
+ preference is checked:
+
+ Mac Firefox 1.0:
+ -------------------
+ Preferences > Web Features >
+ Advanced... > Disable or replace context menus
+
+ Mac Firefox 1.5
+ -------------------
+ Preferences > Context >
+ Advanced... > Disable or replace context menus
+
+ Windows Firefox 1.0
+ -------------------
+ Tools > Options > Web Features >
+ Advanced... > Disable or replace context menus
+
+ Windows Firefox 1.5
+ -------------------
+ Tools > Options > Context >
+ Advanced... > Disable or replace context menus
+
+
+
+*** version 0.11.3 ***
+
+Added the following features:
+-----------------------------
+
+* Added a "target" configuration property to the MenuModuleItem object that
+ allows the user to specify the target of an item's anchor element. Items
+ that make use of the "target" configuration property will require the user
+ to click exactly on the item's anchor element to navigate to the specified
+ URL.
+
+* Items without a "url" property set will automatically hide their parent
+ menu instance(s) when clicked.
+
+
+Fixed the following bugs:
+-------------------------
+
+* Items in a submenu should now navigate to their specified URL when clicked.
+
+* Removed MenuBar's use of "overflow:hidden." This fixes an issue in Firefox
+ 1.5 in which submenus of a Menubar instance cannot overlay other absolutely
+ positioned elements on the page.
+
+* Submenus of a Menubar instance will now automatically have their iframe shim
+ enabled in IE<7.
+
+* Statically positioned Menubar and Menu instances will now render with the
+ correct position and dimensions in Safari.
+
+* MenuModuleItem's "focus" method now checks to make sure that an item's
+ "display" style property is not "none" before trying to set focus to its
+ anchor element.
+
+* A ContextMenu instance will now hide all other ContextMenu instances before
+ displaying itself.
+
+* Removed the dead space in front of an item's submenu indicator image in IE.
+ This space was causing an item's submenu to flicker when the user hovered
+ over it.
+
+
+Changes:
+--------
+
+* Moved the DOM event handlers for every menu from the root DIV node of each
+ instance to the document object. This change reduces the number of DOM event
+ handlers used by Menu to eight, improving the cleanup time required by the
+ Event utility.
+
+
+
+*** version 0.11.0 ***
+
+Added the following features:
+-----------------------------
+* Overloaded the "addItem" and "insertItem" methods of MenuModule to accept a
+ string or a MenuModuleItem instance
+
+* Added the ability to define a MenuItem instance as being "checked"
+
+
+Fixed the following bugs:
+-------------------------
+* Changing the path for the submenu indicator image of one MenuModuleItem
+ subclass will no longer affect other subclasses
+
+* MenuItem instances built from existing markup without anchor tags will no
+ longer trigger a JavaScript error when clicked
+
+* Modified the implementation of the "imageRoot" property for the
+ MenuModuleItem class so that it is set to a secure/non-secure path when the
+ object is instantiated
+
+* Menu instances now resize in response to changes to the browser's font size
+
+* Modified the propagation of the MenuModule class's "submenualignment"
+ configuration property so that it only applies to instances of the same type
+
+* Adjusted the specificity of the style rule that controls the position of a
+ MenuItem instance's submenu indicator image to prevent it from wrapping in IE
+
+* Specified a width and height for submenu indicator images in the Menu
+ stylesheet to ensure that Menu instances are always rendered at the correct
+ width
+
+* Clicking a MenuItem instance will no longer trigger two HTTP GET requests
+
+* Users can now control or shift-click on MenuItem links
+
+
+Changes:
+--------
+* In the Menu stylesheet (menu.css), switched from using "first" class to
+ "first-of-type" class
+
+* Changed case of MenuModuleItem class's "subMenuIndicator" property
+ to "submenuIndicator"
\ No newline at end of file
diff --git a/lib/yui/menu/assets/menu.css b/lib/yui/menu/assets/menu.css
index 0f9e8d2739..d341474dc1 100755
--- a/lib/yui/menu/assets/menu.css
+++ b/lib/yui/menu/assets/menu.css
@@ -1,297 +1,297 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.com/yui/license.txt
-Version: 0.12.1
-*/
-
-
-
-/* Menu styles */
-
-div.yuimenu {
-
- background-color:#f6f7ee;
- border:solid 1px #c4c4be;
- padding:1px;
-
-}
-
-/* Submenus are positioned absolute and hidden by default */
-
-div.yuimenu div.yuimenu,
-div.yuimenubar div.yuimenu {
-
- position:absolute;
- visibility:hidden;
-
-}
-
-/* MenuBar Styles */
-
-div.yuimenubar {
-
- background-color:#f6f7ee;
-
-}
-
-/*
- Applying a width triggers "haslayout" in IE so that the module's
- body clears its floated elements
-*/
-div.yuimenubar div.bd {
-
- width:100%;
-
-}
-
-/*
- Clear the module body for other browsers
-*/
-div.yuimenubar div.bd:after {
-
- content:'.';
- display:block;
- clear:both;
- visibility:hidden;
- height:0;
-
-}
-
-
-/* Matches the group title (H6) inside a Menu or MenuBar instance */
-
-div.yuimenu h6,
-div.yuimenubar h6 {
-
- font-size:100%;
- font-weight:normal;
- margin:0;
- border:solid 1px #c4c4be;
- color:#b9b9b9;
-
-}
-
-div.yuimenubar h6 {
-
- float:left;
- display:inline; /* Prevent margin doubling in IE */
- padding:4px 12px;
- border-width:0 1px 0 0;
-
-}
-
-div.yuimenu h6 {
-
- float:none;
- display:block;
- border-width:1px 0 0 0;
- padding:5px 10px 0 10px;
-
-}
-
-
-/* Matches the UL inside a Menu or MenuBar instance */
-
-div.yuimenubar ul {
-
- list-style-type:none;
- margin:0;
- padding:0;
-
-}
-
-div.yuimenu ul {
-
- list-style-type:none;
- border:solid 1px #c4c4be;
- border-width:1px 0 0 0;
- margin:0;
- padding:10px 0;
-
-}
-
-
-div.yuimenu ul.first-of-type,
-div.yuimenu ul.hastitle,
-div.yuimenu h6.first-of-type {
-
- border-width:0;
-
-}
-
-
-/* MenuItem and MenuBarItem styles */
-
-div.yuimenu li,
-div.yuimenubar li {
-
- font-size:85%;
- cursor:pointer;
- cursor:hand;
- white-space:nowrap;
- text-align:left;
-
-}
-
-div.yuimenu li.yuimenuitem {
-
- padding:2px 24px;
-
-}
-
-div.yuimenu li li,
-div.yuimenubar li li {
-
- font-size:100%;
-
-}
-
-
-/* Matches the help text for a menu item */
-
-div.yuimenu li em {
-
- font-style:normal;
- margin:0 0 0 40px;
-
-}
-
-div.yuimenu li a em {
-
- margin:0;
-
-}
-
-div.yuimenu li a,
-div.yuimenubar li a {
-
- /*
- "zoom:1" triggers "haslayout" in IE to ensure that the mouseover and
- mouseout events bubble to the parent LI in IE.
- */
- zoom:1;
- color:#000;
- text-decoration:none;
-
-}
-
-div.yuimenu li.hassubmenu,
-div.yuimenu li.hashelptext {
-
- text-align:right;
-
-}
-
-div.yuimenu li.hassubmenu a.hassubmenu,
-div.yuimenu li.hashelptext a.hashelptext {
-
- float:left;
- display:inline; /* Prevent margin doubling in IE */
- text-align:left;
-
-}
-
-
-/* Matches focused and selected menu items */
-
-div.yuimenu li.selected,
-div.yuimenubar li.selected {
-
- background-color:#8c8ad0;
-
-}
-
-div.yuimenu li.selected a.selected,
-div.yuimenubar li.selected a.selected {
-
- text-decoration:underline;
-
-}
-
-div.yuimenu li.selected a.selected,
-div.yuimenu li.selected em.selected,
-div.yuimenubar li.selected a.selected {
-
- color:#fff;
-
-}
-
-
-/* Matches disabled menu items */
-
-div.yuimenu li.disabled,
-div.yuimenubar li.disabled {
-
- cursor:default;
-
-}
-
-div.yuimenu li.disabled a.disabled,
-div.yuimenu li.disabled em.disabled,
-div.yuimenubar li.disabled a.disabled {
-
- color:#b9b9b9;
- cursor:default;
-
-}
-
-div.yuimenubar li.yuimenubaritem {
-
- float:left;
- display:inline; /* Prevent margin doubling in IE */
- border-width:0 0 0 1px;
- border-style:solid;
- border-color:#c4c4be;
- padding:4px 24px;
- margin:0;
-
-}
-
-div.yuimenubar li.yuimenubaritem.first-of-type {
-
- border-width:0;
-
-}
-
-
-/* Matches the submenu indicator for menu items */
-
-div.yuimenubar li.yuimenubaritem img {
-
- height:8px;
- width:8px;
- margin:0 0 0 10px;
- vertical-align:middle;
-
-}
-
-div.yuimenu li.yuimenuitem img {
-
- height:8px;
- width:8px;
- margin:0 -16px 0 0;
- padding-left:10px;
- border:0;
-
-}
-
-div.yuimenu li.checked {
-
- position:relative;
-
-}
-
-div.yuimenu li.checked img.checked {
-
- height:8px;
- width:8px;
- margin:0;
- padding:0;
- border:0;
- position:absolute;
- left:6px;
- _left:-16px; /* Underscore hack b/c this is for IE 6 only */
- top:.5em;
-
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.com/yui/license.txt
+Version: 0.12.1
+*/
+
+
+
+/* Menu styles */
+
+div.yuimenu {
+
+ background-color:#f6f7ee;
+ border:solid 1px #c4c4be;
+ padding:1px;
+
+}
+
+/* Submenus are positioned absolute and hidden by default */
+
+div.yuimenu div.yuimenu,
+div.yuimenubar div.yuimenu {
+
+ position:absolute;
+ visibility:hidden;
+
+}
+
+/* MenuBar Styles */
+
+div.yuimenubar {
+
+ background-color:#f6f7ee;
+
+}
+
+/*
+ Applying a width triggers "haslayout" in IE so that the module's
+ body clears its floated elements
+*/
+div.yuimenubar div.bd {
+
+ width:100%;
+
+}
+
+/*
+ Clear the module body for other browsers
+*/
+div.yuimenubar div.bd:after {
+
+ content:'.';
+ display:block;
+ clear:both;
+ visibility:hidden;
+ height:0;
+
+}
+
+
+/* Matches the group title (H6) inside a Menu or MenuBar instance */
+
+div.yuimenu h6,
+div.yuimenubar h6 {
+
+ font-size:100%;
+ font-weight:normal;
+ margin:0;
+ border:solid 1px #c4c4be;
+ color:#b9b9b9;
+
+}
+
+div.yuimenubar h6 {
+
+ float:left;
+ display:inline; /* Prevent margin doubling in IE */
+ padding:4px 12px;
+ border-width:0 1px 0 0;
+
+}
+
+div.yuimenu h6 {
+
+ float:none;
+ display:block;
+ border-width:1px 0 0 0;
+ padding:5px 10px 0 10px;
+
+}
+
+
+/* Matches the UL inside a Menu or MenuBar instance */
+
+div.yuimenubar ul {
+
+ list-style-type:none;
+ margin:0;
+ padding:0;
+
+}
+
+div.yuimenu ul {
+
+ list-style-type:none;
+ border:solid 1px #c4c4be;
+ border-width:1px 0 0 0;
+ margin:0;
+ padding:10px 0;
+
+}
+
+
+div.yuimenu ul.first-of-type,
+div.yuimenu ul.hastitle,
+div.yuimenu h6.first-of-type {
+
+ border-width:0;
+
+}
+
+
+/* MenuItem and MenuBarItem styles */
+
+div.yuimenu li,
+div.yuimenubar li {
+
+ font-size:85%;
+ cursor:pointer;
+ cursor:hand;
+ white-space:nowrap;
+ text-align:left;
+
+}
+
+div.yuimenu li.yuimenuitem {
+
+ padding:2px 24px;
+
+}
+
+div.yuimenu li li,
+div.yuimenubar li li {
+
+ font-size:100%;
+
+}
+
+
+/* Matches the help text for a menu item */
+
+div.yuimenu li em {
+
+ font-style:normal;
+ margin:0 0 0 40px;
+
+}
+
+div.yuimenu li a em {
+
+ margin:0;
+
+}
+
+div.yuimenu li a,
+div.yuimenubar li a {
+
+ /*
+ "zoom:1" triggers "haslayout" in IE to ensure that the mouseover and
+ mouseout events bubble to the parent LI in IE.
+ */
+ zoom:1;
+ color:#000;
+ text-decoration:none;
+
+}
+
+div.yuimenu li.hassubmenu,
+div.yuimenu li.hashelptext {
+
+ text-align:right;
+
+}
+
+div.yuimenu li.hassubmenu a.hassubmenu,
+div.yuimenu li.hashelptext a.hashelptext {
+
+ float:left;
+ display:inline; /* Prevent margin doubling in IE */
+ text-align:left;
+
+}
+
+
+/* Matches focused and selected menu items */
+
+div.yuimenu li.selected,
+div.yuimenubar li.selected {
+
+ background-color:#8c8ad0;
+
+}
+
+div.yuimenu li.selected a.selected,
+div.yuimenubar li.selected a.selected {
+
+ text-decoration:underline;
+
+}
+
+div.yuimenu li.selected a.selected,
+div.yuimenu li.selected em.selected,
+div.yuimenubar li.selected a.selected {
+
+ color:#fff;
+
+}
+
+
+/* Matches disabled menu items */
+
+div.yuimenu li.disabled,
+div.yuimenubar li.disabled {
+
+ cursor:default;
+
+}
+
+div.yuimenu li.disabled a.disabled,
+div.yuimenu li.disabled em.disabled,
+div.yuimenubar li.disabled a.disabled {
+
+ color:#b9b9b9;
+ cursor:default;
+
+}
+
+div.yuimenubar li.yuimenubaritem {
+
+ float:left;
+ display:inline; /* Prevent margin doubling in IE */
+ border-width:0 0 0 1px;
+ border-style:solid;
+ border-color:#c4c4be;
+ padding:4px 24px;
+ margin:0;
+
+}
+
+div.yuimenubar li.yuimenubaritem.first-of-type {
+
+ border-width:0;
+
+}
+
+
+/* Matches the submenu indicator for menu items */
+
+div.yuimenubar li.yuimenubaritem img {
+
+ height:8px;
+ width:8px;
+ margin:0 0 0 10px;
+ vertical-align:middle;
+
+}
+
+div.yuimenu li.yuimenuitem img {
+
+ height:8px;
+ width:8px;
+ margin:0 -16px 0 0;
+ padding-left:10px;
+ border:0;
+
+}
+
+div.yuimenu li.checked {
+
+ position:relative;
+
+}
+
+div.yuimenu li.checked img.checked {
+
+ height:8px;
+ width:8px;
+ margin:0;
+ padding:0;
+ border:0;
+ position:absolute;
+ left:6px;
+ _left:-16px; /* Underscore hack b/c this is for IE 6 only */
+ top:.5em;
+
}
\ No newline at end of file
diff --git a/lib/yui/menu/menu-debug.js b/lib/yui/menu/menu-debug.js
index 4c3cb5301d..a6bc83a6ba 100755
--- a/lib/yui/menu/menu-debug.js
+++ b/lib/yui/menu/menu-debug.js
@@ -1,26 +1,23 @@
-/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.com/yui/license.txt
-version: 0.12.1
-*/
-
-
-
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.12.2
+*/
/**
* @module menu
-* @description The Menu Library features a collection of widgets that make
-* it easy to add menus to your website or web application. With the Menu
-* Library you can create website fly-out menus, customized context menus, or
+* @description
The Menu Library features a collection of widgets that make
+* it easy to add menus to your website or web application. With the Menu
+* Library you can create website fly-out menus, customized context menus, or
* application-style menu bars with just a small amount of scripting.
*
* Screen-reader accessibility.
* Keyboard and mouse navigation.
-* A rich event model that provides access to all of a menu's
+* A rich event model that provides access to all of a menu's
* interesting moments.
-* Support for
+* Support for
* Progressive
-* Enhancement ; Menus can be created from simple,
+* Enhancement; Menus can be created from simple,
* semantic markup on the page or purely through JavaScript.
*
* @title Menu Library
@@ -33,8 +30,8 @@ var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
/**
-* Singleton that manages a collection of all menus and menu items. Listens for
-* DOM events at the document level and dispatches the events to the
+* Singleton that manages a collection of all menus and menu items. Listens for
+* DOM events at the document level and dispatches the events to the
* corresponding menu or menu item.
*
* @namespace YAHOO.widget
@@ -54,15 +51,15 @@ YAHOO.widget.MenuManager = function() {
// Collection of menus
m_oMenus = {},
-
-
- // Collection of menu items
+
+
+ // Collection of menu items
m_oItems = {},
// Collection of visible menus
-
+
m_oVisibleMenus = {},
@@ -81,7 +78,7 @@ YAHOO.widget.MenuManager = function() {
* @method addItem
* @description Adds an item to the collection of known menu items.
* @private
- * @param {YAHOO.widget.MenuItem} p_oItem Object specifying the MenuItem
+ * @param {YAHOO.widget.MenuItem} p_oItem Object specifying the MenuItem
* instance to be added.
*/
function addItem(p_oItem) {
@@ -91,16 +88,16 @@ YAHOO.widget.MenuManager = function() {
if(p_oItem && m_oItems[sYUIId] != p_oItem) {
p_oItem.element.setAttribute("yuiid", sYUIId);
-
+
m_oItems[sYUIId] = p_oItem;
-
+
p_oItem.destroyEvent.subscribe(onItemDestroy, p_oItem);
- m_oLogger.log("Item: " +
+ m_oLogger.log("Item: " +
p_oItem.toString() + " successfully registered.");
}
-
+
}
@@ -108,86 +105,86 @@ YAHOO.widget.MenuManager = function() {
* @method removeItem
* @description Removes an item from the collection of known menu items.
* @private
- * @param {YAHOO.widget.MenuItem} p_oItem Object specifying the MenuItem
+ * @param {YAHOO.widget.MenuItem} p_oItem Object specifying the MenuItem
* instance to be removed.
*/
function removeItem(p_oItem) {
-
+
var sYUIId = p_oItem.element.getAttribute("yuiid");
if(sYUIId && m_oItems[sYUIId]) {
delete m_oItems[sYUIId];
- m_oLogger.log("Item: " +
+ m_oLogger.log("Item: " +
p_oItem.toString() + " successfully unregistered.");
}
-
+
}
/**
* @method getMenuRootElement
- * @description Finds the root DIV node of a menu or the root LI node of a
+ * @description Finds the root DIV node of a menu or the root LI node of a
* menu item.
* @private
* @param {HTMLElement } p_oElement Object specifying
+ * one-html.html#ID-58190037">HTMLElement} p_oElement Object specifying
* an HTML element.
*/
function getMenuRootElement(p_oElement) {
-
+
var oParentNode;
if(p_oElement && p_oElement.tagName) {
-
+
switch(p_oElement.tagName.toUpperCase()) {
-
+
case "DIV":
-
+
oParentNode = p_oElement.parentNode;
-
+
// Check if the DIV is the inner "body" node of a menu
if(
- Dom.hasClass(p_oElement, "bd") &&
- oParentNode &&
- oParentNode.tagName &&
+ Dom.hasClass(p_oElement, "bd") &&
+ oParentNode &&
+ oParentNode.tagName &&
oParentNode.tagName.toUpperCase() == "DIV"
) {
-
+
return oParentNode;
-
+
}
else {
-
+
return p_oElement;
-
+
}
-
+
break;
case "LI":
-
+
return p_oElement;
default:
-
+
oParentNode = p_oElement.parentNode;
-
+
if(oParentNode) {
-
+
return getMenuRootElement(oParentNode);
-
+
}
-
+
break;
-
+
}
}
-
+
}
@@ -197,18 +194,18 @@ YAHOO.widget.MenuManager = function() {
/**
* @method onDOMEvent
- * @description Generic, global event handler for all of a menu's DOM-based
- * events. This listens for events against the document object. If the
- * target of a given event is a member of a menu or menu item's DOM, the
+ * @description Generic, global event handler for all of a menu's DOM-based
+ * events. This listens for events against the document object. If the
+ * target of a given event is a member of a menu or menu item's DOM, the
* instance's corresponding Custom Event is fired.
* @private
- * @param {Event} p_oEvent Object representing the DOM event object passed
+ * @param {Event} p_oEvent Object representing the DOM event object passed
* back by the event utility (YAHOO.util.Event).
*/
function onDOMEvent(p_oEvent) {
// Get the target node of the DOM event
-
+
var oTarget = Event.getTarget(p_oEvent),
@@ -216,33 +213,33 @@ YAHOO.widget.MenuManager = function() {
oElement = getMenuRootElement(oTarget),
oMenuItem,
- oMenu;
+ oMenu;
if(oElement) {
var sTagName = oElement.tagName.toUpperCase();
-
+
if(sTagName == "LI") {
-
+
var sYUIId = oElement.getAttribute("yuiid");
-
+
if(sYUIId) {
-
+
oMenuItem = m_oItems[sYUIId];
oMenu = oMenuItem.parent;
-
+
}
-
+
}
else if(sTagName == "DIV") {
-
+
if(oElement.id) {
-
+
oMenu = m_oMenus[oElement.id];
-
+
}
-
+
}
}
@@ -250,7 +247,7 @@ YAHOO.widget.MenuManager = function() {
if(oMenu) {
// Map of DOM event names to CustomEvent names
-
+
var oEventTypes = {
"click": "clickEvent",
"mousedown": "mouseDownEvent",
@@ -261,54 +258,54 @@ YAHOO.widget.MenuManager = function() {
"keyup": "keyUpEvent",
"keypress": "keyPressEvent"
},
-
+
sCustomEventType = oEventTypes[p_oEvent.type];
- // Fire the Custom Even that corresponds the current DOM event
-
+ // Fire the Custom Even that corresponds the current DOM event
+
if(oMenuItem && !oMenuItem.cfg.getProperty("disabled")) {
-
- oMenuItem[sCustomEventType].fire(p_oEvent);
-
+
+ oMenuItem[sCustomEventType].fire(p_oEvent);
+
}
-
+
oMenu[sCustomEventType].fire(p_oEvent, oMenuItem);
-
+
}
else if(p_oEvent.type == "mousedown") {
/*
- If the target of the event wasn't a menu, hide all
+ If the target of the event wasn't a menu, hide all
dynamically positioned menus
*/
-
+
var oActiveItem;
-
+
for(var i in m_oMenus) {
-
+
if(m_oMenus.hasOwnProperty(i)) {
-
+
oMenu = m_oMenus[i];
-
+
if(
- oMenu.cfg.getProperty("clicktohide") &&
+ oMenu.cfg.getProperty("clicktohide") &&
oMenu.cfg.getProperty("position") == "dynamic"
) {
-
+
oMenu.hide();
-
+
}
else {
oMenu.clearActiveItem(true);
-
+
}
-
+
}
-
- }
+
+ }
}
@@ -319,10 +316,10 @@ YAHOO.widget.MenuManager = function() {
* @method onMenuDestroy
* @description "destroy" event handler for a menu.
* @private
- * @param {String} p_sType String representing the name of the event that
+ * @param {String} p_sType String representing the name of the event that
* was fired.
* @param {Array} p_aArgs Array of arguments sent when the event was fired.
- * @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
+ * @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
* fired the event.
*/
function onMenuDestroy(p_sType, p_aArgs, p_oMenu) {
@@ -331,7 +328,7 @@ YAHOO.widget.MenuManager = function() {
delete m_oMenus[p_oMenu.id];
- m_oLogger.log("Menu: " +
+ m_oLogger.log("Menu: " +
p_oMenu.toString() + " successfully unregistered.");
}
@@ -343,10 +340,10 @@ YAHOO.widget.MenuManager = function() {
* @method onItemDestroy
* @description "destroy" event handler for a MenuItem instance.
* @private
- * @param {String} p_sType String representing the name of the event that
+ * @param {String} p_sType String representing the name of the event that
* was fired.
* @param {Array} p_aArgs Array of arguments sent when the event was fired.
- * @param {YAHOO.widget.MenuItem} p_oItem Object representing the menu item
+ * @param {YAHOO.widget.MenuItem} p_oItem Object representing the menu item
* that fired the event.
*/
function onItemDestroy(p_sType, p_aArgs, p_oItem) {
@@ -364,38 +361,38 @@ YAHOO.widget.MenuManager = function() {
/**
* @method onMenuVisibleConfigChange
- * @description Event handler for when the "visible" configuration property
+ * @description Event handler for when the "visible" configuration property
* of a Menu instance changes.
* @private
- * @param {String} p_sType String representing the name of the event that
+ * @param {String} p_sType String representing the name of the event that
* was fired.
* @param {Array} p_aArgs Array of arguments sent when the event was fired.
- * @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
+ * @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
* fired the event.
*/
function onMenuVisibleConfigChange(p_sType, p_aArgs, p_oMenu) {
var bVisible = p_aArgs[0];
-
+
if(bVisible) {
m_oVisibleMenus[p_oMenu.id] = p_oMenu;
-
- m_oLogger.log("Menu: " +
- p_oMenu.toString() +
+
+ m_oLogger.log("Menu: " +
+ p_oMenu.toString() +
" registered with the collection of visible menus.");
-
+
}
else if(m_oVisibleMenus[p_oMenu.id]) {
-
+
delete m_oVisibleMenus[p_oMenu.id];
-
- m_oLogger.log("Menu: " +
- p_oMenu.toString() +
+
+ m_oLogger.log("Menu: " +
+ p_oMenu.toString() +
" unregistered from the collection of visible menus.");
-
+
}
-
+
}
@@ -403,29 +400,29 @@ YAHOO.widget.MenuManager = function() {
* @method onItemAdded
* @description "itemadded" event handler for a Menu instance.
* @private
- * @param {String} p_sType String representing the name of the event that
+ * @param {String} p_sType String representing the name of the event that
* was fired.
* @param {Array} p_aArgs Array of arguments sent when the event was fired.
*/
function onItemAdded(p_sType, p_aArgs) {
-
+
addItem(p_aArgs[0]);
-
+
}
-
+
/**
* @method onItemRemoved
* @description "itemremoved" event handler for a Menu instance.
* @private
- * @param {String} p_sType String representing the name of the event that
+ * @param {String} p_sType String representing the name of the event that
* was fired.
* @param {Array} p_aArgs Array of arguments sent when the event was fired.
*/
function onItemRemoved(p_sType, p_aArgs) {
removeItem(p_aArgs[0]);
-
+
}
@@ -438,20 +435,20 @@ YAHOO.widget.MenuManager = function() {
/**
* @method addMenu
* @description Adds a menu to the collection of known menus.
- * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu
+ * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu
* instance to be added.
*/
addMenu: function(p_oMenu) {
-
+
if(p_oMenu && p_oMenu.id && !m_oMenus[p_oMenu.id]) {
-
+
m_oMenus[p_oMenu.id] = p_oMenu;
-
-
+
+
if(!m_bInitializedEventHandlers) {
-
+
var oDoc = document;
-
+
Event.addListener(oDoc, "mouseover", onDOMEvent, me, true);
Event.addListener(oDoc, "mouseout", onDOMEvent, me, true);
Event.addListener(oDoc, "mousedown", onDOMEvent, me, true);
@@ -460,89 +457,89 @@ YAHOO.widget.MenuManager = function() {
Event.addListener(oDoc, "keydown", onDOMEvent, me, true);
Event.addListener(oDoc, "keyup", onDOMEvent, me, true);
Event.addListener(oDoc, "keypress", onDOMEvent, me, true);
-
+
m_bInitializedEventHandlers = true;
-
+
m_oLogger.log("DOM event handlers initialized.");
-
+
}
-
+
p_oMenu.destroyEvent.subscribe(onMenuDestroy, p_oMenu, me);
-
+
p_oMenu.cfg.subscribeToConfigEvent(
- "visible",
- onMenuVisibleConfigChange,
+ "visible",
+ onMenuVisibleConfigChange,
p_oMenu
);
-
+
p_oMenu.itemAddedEvent.subscribe(onItemAdded);
p_oMenu.itemRemovedEvent.subscribe(onItemRemoved);
-
- m_oLogger.log("Menu: " +
+
+ m_oLogger.log("Menu: " +
p_oMenu.toString() + " successfully registered.");
-
+
}
-
+
},
-
+
/**
* @method removeMenu
* @description Removes a menu from the collection of known menus.
- * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu
+ * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu
* instance to be removed.
*/
removeMenu: function(p_oMenu) {
-
+
if(p_oMenu && m_oMenus[p_oMenu.id]) {
-
+
delete m_oMenus[p_oMenu.id];
-
- m_oLogger.log("Menu: " +
+
+ m_oLogger.log("Menu: " +
p_oMenu.toString() + " successfully unregistered.");
-
+
}
-
+
},
-
-
+
+
/**
* @method hideVisible
* @description Hides all visible, dynamically positioned menus.
*/
hideVisible: function() {
-
+
var oMenu;
-
+
for(var i in m_oVisibleMenus) {
-
+
if(m_oVisibleMenus.hasOwnProperty(i)) {
-
+
oMenu = m_oVisibleMenus[i];
-
+
if(oMenu.cfg.getProperty("position") == "dynamic") {
-
+
oMenu.hide();
-
+
}
-
+
}
-
- }
-
+
+ }
+
},
/**
* @method getMenus
- * @description Returns an array of all menus registered with the
+ * @description Returns an array of all menus registered with the
* menu manger.
* @return {Array}
*/
getMenus: function() {
-
+
return m_oMenus;
-
+
},
@@ -554,3620 +551,3620 @@ YAHOO.widget.MenuManager = function() {
* @return {YAHOO.widget.Menu}
*/
getMenu: function(p_sId) {
-
+
if(m_oMenus[p_sId]) {
-
+
return m_oMenus[p_sId];
-
+
}
-
+
},
-
+
/**
* @method toString
* @description Returns a string representing the menu manager.
* @return {String}
*/
toString: function() {
-
+
return ("MenuManager");
-
+
}
};
}();
-})();
-
-
-(function() {
-
-var Dom = YAHOO.util.Dom,
- Event = YAHOO.util.Event;
-
-
-/**
-* The Menu class creates a container that holds a vertical list representing
-* a set of options or commands. Menu is the base class for all
-* menu containers.
-* @param {String} p_oElement String specifying the id attribute of the
-* <div>
element of the menu.
-* @param {String} p_oElement String specifying the id attribute of the
-* <select>
element to be used as the data source
-* for the menu.
-* @param {HTMLDivElement } p_oElement Object
-* specifying the <div>
element of the menu.
-* @param {HTMLSelectElement } p_oElement
-* Object specifying the <select>
element to be used as
-* the data source for the menu.
-* @param {Object} p_oConfig Optional. Object literal specifying the
-* configuration for the menu. See configuration class documentation for
-* more details.
-* @namespace YAHOO.widget
-* @class Menu
-* @constructor
-* @extends YAHOO.widget.Overlay
-*/
-YAHOO.widget.Menu = function(p_oElement, p_oConfig) {
-
- if(p_oConfig) {
-
- this.parent = p_oConfig.parent;
-
- this.lazyLoad = p_oConfig.lazyLoad || p_oConfig.lazyload;
-
- this.itemData = p_oConfig.itemData || p_oConfig.itemdata;
-
- }
-
-
- YAHOO.widget.Menu.superclass.constructor.call(
- this,
- p_oElement,
- p_oConfig
- );
-
-};
-
-YAHOO.extend(YAHOO.widget.Menu, YAHOO.widget.Overlay, {
-
-
-
-// Constants
-
-
-/**
-* @property CSS_CLASS_NAME
-* @description String representing the CSS class(es) to be applied to the
-* menu's <div>
element.
-* @default "yuimenu"
-* @final
-* @type String
-*/
-CSS_CLASS_NAME: "yuimenu",
-
-
-/**
-* @property ITEM_TYPE
-* @description Object representing the type of menu item to instantiate and
-* add when parsing the child nodes (either <li>
element,
-* <optgroup>
element or <option>
)
-* of the menu's source HTML element.
-* @default YAHOO.widget.MenuItem
-* @final
-* @type YAHOO.widget.MenuItem
-*/
-ITEM_TYPE: null,
-
-
-/**
-* @property GROUP_TITLE_TAG_NAME
-* @description String representing the tagname of the HTML element used to
-* title the menu's item groups.
-* @default H6
-* @final
-* @type String
-*/
-GROUP_TITLE_TAG_NAME: "h6",
-
-
-
-// Private properties
-
-
-/**
-* @property _nHideDelayId
-* @description Number representing the time-out setting used to cancel the
-* hiding of a menu.
-* @default null
-* @private
-* @type Number
-*/
-_nHideDelayId: null,
-
-
-/**
-* @property _nShowDelayId
-* @description Number representing the time-out setting used to cancel the
-* showing of a menu.
-* @default null
-* @private
-* @type Number
-*/
-_nShowDelayId: null,
-
-
-/**
-* @property _hideDelayEventHandlersAssigned
-* @description Boolean indicating if the "mouseover" and "mouseout" event
-* handlers used for hiding the menu via a call to "window.setTimeout" have
-* already been assigned.
-* @default false
-* @private
-* @type Boolean
-*/
-_hideDelayEventHandlersAssigned: false,
-
-
-/**
-* @property _bHandledMouseOverEvent
-* @description Boolean indicating the current state of the menu's
-* "mouseover" event.
-* @default false
-* @private
-* @type Boolean
-*/
-_bHandledMouseOverEvent: false,
-
-
-/**
-* @property _bHandledMouseOutEvent
-* @description Boolean indicating the current state of the menu's
-* "mouseout" event.
-* @default false
-* @private
-* @type Boolean
-*/
-_bHandledMouseOutEvent: false,
-
-
-/**
-* @property _aGroupTitleElements
-* @description Array of HTML element used to title groups of menu items.
-* @default []
-* @private
-* @type Array
-*/
-_aGroupTitleElements: null,
-
-
-/**
-* @property _aItemGroups
-* @description Array of menu items.
-* @default []
-* @private
-* @type Array
-*/
-_aItemGroups: null,
-
-
-/**
-* @property _aListElements
-* @description Array of <ul>
elements, each of which is
-* the parent node for each item's <li>
element.
-* @default []
-* @private
-* @type Array
-*/
-_aListElements: null,
-
-
-
-// Public properties
-
-
-/**
-* @property lazyLoad
-* @description Boolean indicating if the menu's "lazy load" feature is
-* enabled. If set to "true," initialization and rendering of the menu's
-* items will be deferred until the first time it is made visible. This
-* property should be set via the constructor using the configuration
-* object literal.
-* @default false
-* @type Boolean
-*/
-lazyLoad: false,
-
-
-/**
-* @property itemData
-* @description Array of items to be added to the menu. The array can contain
-* strings representing the text for each item to be created, object literals
-* representing the menu item configuration properties, or MenuItem instances.
-* This property should be set via the constructor using the configuration
-* object literal.
-* @default null
-* @type Array
-*/
-itemData: null,
-
-
-/**
-* @property activeItem
-* @description Object reference to the item in the menu that has focus.
-* @default null
-* @type YAHOO.widget.MenuItem
-*/
-activeItem: null,
-
-
-/**
-* @property parent
-* @description Object reference to the menu's parent menu or menu item.
-* This property can be set via the constructor using the configuration
-* object literal.
-* @default null
-* @type YAHOO.widget.MenuItem
-*/
-parent: null,
-
-
-/**
-* @property srcElement
-* @description Object reference to the HTML element (either
-* <select>
or <div>
) used to
-* create the menu.
-* @default null
-* @type HTMLSelectElement |HTMLDivElement
-*/
-srcElement: null,
-
-
-
-// Events
-
-
-/**
-* @event mouseOverEvent
-* @description Fires when the mouse has entered the menu. Passes back
-* the DOM Event object as an argument.
-*/
-mouseOverEvent: null,
-
-
-/**
-* @event mouseOutEvent
-* @description Fires when the mouse has left the menu. Passes back the DOM
-* Event object as an argument.
-* @type YAHOO.util.CustomEvent
-*/
-mouseOutEvent: null,
-
-
-/**
-* @event mouseDownEvent
-* @description Fires when the user mouses down on the menu. Passes back the
-* DOM Event object as an argument.
-* @type YAHOO.util.CustomEvent
-*/
-mouseDownEvent: null,
-
-
-/**
-* @event mouseUpEvent
-* @description Fires when the user releases a mouse button while the mouse is
-* over the menu. Passes back the DOM Event object as an argument.
-* @type YAHOO.util.CustomEvent
-*/
-mouseUpEvent: null,
-
-
-/**
-* @event clickEvent
-* @description Fires when the user clicks the on the menu. Passes back the
-* DOM Event object as an argument.
-* @type YAHOO.util.CustomEvent
-*/
-clickEvent: null,
-
-
-/**
-* @event keyPressEvent
-* @description Fires when the user presses an alphanumeric key when one of the
-* menu's items has focus. Passes back the DOM Event object as an argument.
-* @type YAHOO.util.CustomEvent
-*/
-keyPressEvent: null,
-
-
-/**
-* @event keyDownEvent
-* @description Fires when the user presses a key when one of the menu's items
-* has focus. Passes back the DOM Event object as an argument.
-* @type YAHOO.util.CustomEvent
-*/
-keyDownEvent: null,
-
-
-/**
-* @event keyUpEvent
-* @description Fires when the user releases a key when one of the menu's items
-* has focus. Passes back the DOM Event object as an argument.
-* @type YAHOO.util.CustomEvent
-*/
-keyUpEvent: null,
-
-
-/**
-* @event itemAddedEvent
-* @description Fires when an item is added to the menu.
-* @type YAHOO.util.CustomEvent
-*/
-itemAddedEvent: null,
-
-
-/**
-* @event itemRemovedEvent
-* @description Fires when an item is removed to the menu.
-* @type YAHOO.util.CustomEvent
-*/
-itemRemovedEvent: null,
-
-
-/**
-* @method init
-* @description The Menu class's initialization method. This method is
-* automatically called by the constructor, and sets up all DOM references
-* for pre-existing markup, and creates required markup if it is not
-* already present.
-* @param {String} p_oElement String specifying the id attribute of the
-* <div>
element of the menu.
-* @param {String} p_oElement String specifying the id attribute of the
-* <select>
element to be used as the data source
-* for the menu.
-* @param {HTMLDivElement } p_oElement Object
-* specifying the <div>
element of the menu.
-* @param {HTMLSelectElement } p_oElement
-* Object specifying the <select>
element to be used as
-* the data source for the menu.
-* @param {Object} p_oConfig Optional. Object literal specifying the
-* configuration for the menu. See configuration class documentation for
-* more details.
-*/
-init: function(p_oElement, p_oConfig) {
-
- this._aItemGroups = [];
- this._aListElements = [];
- this._aGroupTitleElements = [];
-
-
- if(!this.ITEM_TYPE) {
-
- this.ITEM_TYPE = YAHOO.widget.MenuItem;
-
- }
-
-
- var oElement;
-
- if(typeof p_oElement == "string") {
-
- oElement = document.getElementById(p_oElement);
-
- }
- else if(p_oElement.tagName) {
-
- oElement = p_oElement;
-
- }
-
-
- if(oElement && oElement.tagName) {
-
- switch(oElement.tagName.toUpperCase()) {
-
- case "DIV":
-
- this.srcElement = oElement;
-
- if(!oElement.id) {
-
- oElement.setAttribute("id", Dom.generateId());
-
- }
-
-
- /*
- Note: we don't pass the user config in here yet
- because we only want it executed once, at the lowest
- subclass level.
- */
-
- YAHOO.widget.Menu.superclass.init.call(this, oElement);
-
- this.beforeInitEvent.fire(YAHOO.widget.Menu);
-
- this.logger = new YAHOO.widget.LogWriter(this.toString());
-
- this.logger.log("Source element: " + this.srcElement.tagName);
-
- break;
-
- case "SELECT":
-
- this.srcElement = oElement;
-
-
- /*
- The source element is not something that we can use
- outright, so we need to create a new Overlay
-
- Note: we don't pass the user config in here yet
- because we only want it executed once, at the lowest
- subclass level.
- */
-
- YAHOO.widget.Menu.superclass.init.call(this, Dom.generateId());
-
- this.beforeInitEvent.fire(YAHOO.widget.Menu);
-
- this.logger = new YAHOO.widget.LogWriter(this.toString());
-
- this.logger.log("Source element: " + this.srcElement.tagName);
-
- break;
-
- }
-
- }
- else {
-
- /*
- Note: we don't pass the user config in here yet
- because we only want it executed once, at the lowest
- subclass level.
- */
-
- YAHOO.widget.Menu.superclass.init.call(this, p_oElement);
-
- this.beforeInitEvent.fire(YAHOO.widget.Menu);
-
- this.logger = new YAHOO.widget.LogWriter(this.toString());
-
- this.logger.log("No source element found. " +
- "Created element with id: " + this.id);
-
- }
-
-
- if(this.element) {
-
- var oEl = this.element;
-
- Dom.addClass(oEl, this.CSS_CLASS_NAME);
-
-
- // Subscribe to Custom Events
-
- this.initEvent.subscribe(this._onInit, this, true);
- this.beforeRenderEvent.subscribe(this._onBeforeRender, this, true);
- this.renderEvent.subscribe(this._onRender, this, true);
- this.beforeShowEvent.subscribe(this._onBeforeShow, this, true);
- this.showEvent.subscribe(this._onShow, this, true);
- this.beforeHideEvent.subscribe(this._onBeforeHide, this, true);
- this.mouseOverEvent.subscribe(this._onMouseOver, this, true);
- this.mouseOutEvent.subscribe(this._onMouseOut, this, true);
- this.clickEvent.subscribe(this._onClick, this, true);
- this.keyDownEvent.subscribe(this._onKeyDown, this, true);
-
- YAHOO.widget.Module.textResizeEvent.subscribe(
- this._onTextResize,
- this,
- true
- );
-
-
- if(p_oConfig) {
-
- this.cfg.applyConfig(p_oConfig, true);
-
- }
-
-
- // Register the Menu instance with the MenuManager
-
- YAHOO.widget.MenuManager.addMenu(this);
-
-
- this.initEvent.fire(YAHOO.widget.Menu);
-
- }
-
-},
-
-
-
-// Private methods
-
-
-/**
-* @method _initSubTree
-* @description Iterates the childNodes of the source element to find nodes
-* used to instantiate menu and menu items.
-* @private
-*/
-_initSubTree: function() {
-
- var oNode;
-
- if(this.srcElement.tagName == "DIV") {
-
- /*
- Populate the collection of item groups and item
- group titles
- */
-
- oNode = this.body.firstChild;
-
- var nGroup = 0,
- sGroupTitleTagName = this.GROUP_TITLE_TAG_NAME.toUpperCase();
-
- do {
-
- if(oNode && oNode.tagName) {
-
- switch(oNode.tagName.toUpperCase()) {
-
- case sGroupTitleTagName:
-
- this._aGroupTitleElements[nGroup] = oNode;
-
- break;
-
- case "UL":
-
- this._aListElements[nGroup] = oNode;
- this._aItemGroups[nGroup] = [];
- nGroup++;
-
- break;
-
- }
-
- }
-
- }
- while((oNode = oNode.nextSibling));
-
-
- /*
- Apply the "first-of-type" class to the first UL to mimic
- the "first-of-type" CSS3 psuedo class.
- */
-
- if(this._aListElements[0]) {
-
- Dom.addClass(this._aListElements[0], "first-of-type");
-
- }
-
- }
-
-
- oNode = null;
-
- this.logger.log("Searching DOM for items to initialize.");
-
- if(this.srcElement.tagName) {
-
- var sSrcElementTagName = this.srcElement.tagName.toUpperCase();
-
-
- switch(sSrcElementTagName) {
-
- case "DIV":
-
- if(this._aListElements.length > 0) {
-
- this.logger.log("Found " +
- this._aListElements.length +
- " item groups to initialize.");
-
- var i = this._aListElements.length - 1;
-
- do {
-
- oNode = this._aListElements[i].firstChild;
-
- this.logger.log("Scanning " +
- this._aListElements[i].childNodes.length +
- " child nodes for items to initialize.");
-
- do {
-
- if(
- oNode &&
- oNode.tagName &&
- oNode.tagName.toUpperCase() == "LI"
- ) {
-
- this.logger.log("Initializing " +
- oNode.tagName + " node.");
-
- this.addItem(
- new this.ITEM_TYPE(
- oNode,
- { parent: this }
- ),
- i
- );
-
- }
-
- }
- while((oNode = oNode.nextSibling));
-
- }
- while(i--);
-
- }
-
- break;
-
- case "SELECT":
-
- this.logger.log("Scanning " +
- this.srcElement.childNodes.length +
- " child nodes for items to initialize.");
-
- oNode = this.srcElement.firstChild;
-
- do {
-
- if(oNode && oNode.tagName) {
-
- switch(oNode.tagName.toUpperCase()) {
-
- case "OPTGROUP":
- case "OPTION":
-
- this.logger.log("Initializing " +
- oNode.tagName + " node.");
-
- this.addItem(
- new this.ITEM_TYPE(
- oNode,
- { parent: this }
- )
- );
-
- break;
-
- }
-
- }
-
- }
- while((oNode = oNode.nextSibling));
-
- break;
-
- }
-
- }
-
-},
-
-
-/**
-* @method _getFirstEnabledItem
-* @description Returns the first enabled item in the menu.
-* @return {YAHOO.widget.MenuItem}
-* @private
-*/
-_getFirstEnabledItem: function() {
-
- var nGroups = this._aItemGroups.length,
- oItem,
- aItemGroup;
-
- for(var i=0; i= aGroup.length);
-
-
- if(aGroup[p_nItemIndex]) {
-
- aGroup.splice(p_nItemIndex, 0, oItem);
-
- }
- else {
-
- aGroup[p_nItemIndex] = oItem;
-
- }
-
-
- oGroupItem = aGroup[p_nItemIndex];
-
- if(oGroupItem) {
-
- if(
- bAppend &&
- (
- !oGroupItem.element.parentNode ||
- oGroupItem.element.parentNode.nodeType == 11
- )
- ) {
-
- this._aListElements[nGroupIndex].appendChild(
- oGroupItem.element
- );
-
- }
- else {
-
-
- /**
- * Returns the next sibling of an item in an array.
- * @private
- * @param {p_aArray} Array to search.
- * @param {p_nStartIndex} Number indicating the index to
- * start searching the array.
- * @return {Object}
- */
- function getNextItemSibling(p_aArray, p_nStartIndex) {
-
- return (
- p_aArray[p_nStartIndex] ||
- getNextItemSibling(
- p_aArray,
- (p_nStartIndex+1)
- )
- );
-
- }
-
-
- var oNextItemSibling =
- getNextItemSibling(aGroup, (p_nItemIndex+1));
-
- if(
- oNextItemSibling &&
- (
- !oGroupItem.element.parentNode ||
- oGroupItem.element.parentNode.nodeType == 11
- )
- ) {
-
- this._aListElements[nGroupIndex].insertBefore(
- oGroupItem.element,
- oNextItemSibling.element
- );
-
- }
-
- }
-
-
- oGroupItem.parent = this;
-
- this._subscribeToItemEvents(oGroupItem);
-
- this._configureSubmenu(oGroupItem);
-
- this._updateItemProperties(nGroupIndex);
-
- this.logger.log("Item inserted." +
- " Text: " + oGroupItem.cfg.getProperty("text") + ", " +
- " Index: " + oGroupItem.index + ", " +
- " Group Index: " + oGroupItem.groupIndex);
-
- this.itemAddedEvent.fire(oGroupItem);
-
- return oGroupItem;
-
- }
-
- }
- else {
-
- var nItemIndex = aGroup.length;
-
- aGroup[nItemIndex] = oItem;
-
- oGroupItem = aGroup[nItemIndex];
-
-
- if(oGroupItem) {
-
- if(
- !Dom.isAncestor(
- this._aListElements[nGroupIndex],
- oGroupItem.element
- )
- ) {
-
- this._aListElements[nGroupIndex].appendChild(
- oGroupItem.element
- );
-
- }
-
- oGroupItem.element.setAttribute("groupindex", nGroupIndex);
- oGroupItem.element.setAttribute("index", nItemIndex);
-
- oGroupItem.parent = this;
-
- oGroupItem.index = nItemIndex;
- oGroupItem.groupIndex = nGroupIndex;
-
- this._subscribeToItemEvents(oGroupItem);
-
- this._configureSubmenu(oGroupItem);
-
- if(nItemIndex === 0) {
-
- Dom.addClass(oGroupItem.element, "first-of-type");
-
- }
-
- this.logger.log("Item added." +
- " Text: " + oGroupItem.cfg.getProperty("text") + ", " +
- " Index: " + oGroupItem.index + ", " +
- " Group Index: " + oGroupItem.groupIndex);
-
-
- this.itemAddedEvent.fire(oGroupItem);
-
- return oGroupItem;
-
- }
-
- }
-
- }
-
-},
-
-
-/**
-* @method _removeItemFromGroupByIndex
-* @description Removes a menu item from a group by index. Returns the menu
-* item that was removed.
-* @private
-* @param {Number} p_nGroupIndex Number indicating the group to which the menu
-* item belongs.
-* @param {Number} p_nItemIndex Number indicating the index of the menu item
-* to be removed.
-* @return {YAHOO.widget.MenuItem}
-*/
-_removeItemFromGroupByIndex: function(p_nGroupIndex, p_nItemIndex) {
-
- var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0,
- aGroup = this._getItemGroup(nGroupIndex);
-
- if(aGroup) {
-
- var aArray = aGroup.splice(p_nItemIndex, 1),
- oItem = aArray[0];
-
- if(oItem) {
-
- // Update the index and className properties of each member
-
- this._updateItemProperties(nGroupIndex);
-
- if(aGroup.length === 0) {
-
- // Remove the UL
-
- var oUL = this._aListElements[nGroupIndex];
-
- if(this.body && oUL) {
-
- this.body.removeChild(oUL);
-
- }
-
- // Remove the group from the array of items
-
- this._aItemGroups.splice(nGroupIndex, 1);
-
-
- // Remove the UL from the array of ULs
-
- this._aListElements.splice(nGroupIndex, 1);
-
-
- /*
- Assign the "first-of-type" class to the new first UL
- in the collection
- */
-
- oUL = this._aListElements[0];
-
- if(oUL) {
-
- Dom.addClass(oUL, "first-of-type");
-
- }
-
- }
-
-
- this.itemRemovedEvent.fire(oItem);
-
-
- // Return a reference to the item that was removed
-
- return oItem;
-
- }
-
- }
-
-},
-
-
-/**
-* @method _removeItemFromGroupByValue
-* @description Removes a menu item from a group by reference. Returns the
-* menu item that was removed.
-* @private
-* @param {Number} p_nGroupIndex Number indicating the group to which the
-* menu item belongs.
-* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem
-* instance to be removed.
-* @return {YAHOO.widget.MenuItem}
-*/
-_removeItemFromGroupByValue: function(p_nGroupIndex, p_oItem) {
-
- var aGroup = this._getItemGroup(p_nGroupIndex);
-
- if(aGroup) {
-
- var nItems = aGroup.length,
- nItemIndex = -1;
-
- if(nItems > 0) {
-
- var i = nItems-1;
-
- do {
-
- if(aGroup[i] == p_oItem) {
-
- nItemIndex = i;
- break;
-
- }
-
- }
- while(i--);
-
- if(nItemIndex > -1) {
-
- return this._removeItemFromGroupByIndex(
- p_nGroupIndex,
- nItemIndex
- );
-
- }
-
- }
-
- }
-
-},
-
-
-/**
-* @method _updateItemProperties
-* @description Updates the "index," "groupindex," and "className" properties
-* of the menu items in the specified group.
-* @private
-* @param {Number} p_nGroupIndex Number indicating the group of items to update.
-*/
-_updateItemProperties: function(p_nGroupIndex) {
-
- var aGroup = this._getItemGroup(p_nGroupIndex),
- nItems = aGroup.length;
-
- if(nItems > 0) {
-
- var i = nItems - 1,
- oItem,
- oLI;
-
- // Update the index and className properties of each member
-
- do {
-
- oItem = aGroup[i];
-
- if(oItem) {
-
- oLI = oItem.element;
-
- oItem.index = i;
- oItem.groupIndex = p_nGroupIndex;
-
- oLI.setAttribute("groupindex", p_nGroupIndex);
- oLI.setAttribute("index", i);
-
- Dom.removeClass(oLI, "first-of-type");
-
- }
-
- }
- while(i--);
-
-
- if(oLI) {
-
- Dom.addClass(oLI, "first-of-type");
-
- }
-
- }
-
-},
-
-
-/**
-* @method _createItemGroup
-* @description Creates a new menu item group (array) and its associated
-* <ul>
element. Returns an aray of menu item groups.
-* @private
-* @param {Number} p_nIndex Number indicating the group to create.
-* @return {Array}
-*/
-_createItemGroup: function(p_nIndex) {
-
- if(!this._aItemGroups[p_nIndex]) {
-
- this._aItemGroups[p_nIndex] = [];
-
- var oUL = document.createElement("ul");
-
- this._aListElements[p_nIndex] = oUL;
-
- return this._aItemGroups[p_nIndex];
-
- }
-
-},
-
-
-/**
-* @method _getItemGroup
-* @description Returns the menu item group at the specified index.
-* @private
-* @param {Number} p_nIndex Number indicating the index of the menu item group
-* to be retrieved.
-* @return {Array}
-*/
-_getItemGroup: function(p_nIndex) {
-
- var nIndex = ((typeof p_nIndex == "number") ? p_nIndex : 0);
-
- return this._aItemGroups[nIndex];
-
-},
-
-
-/**
-* @method _configureSubmenu
-* @description Subscribes the menu item's submenu to its parent menu's events.
-* @private
-* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem
-* instance with the submenu to be configured.
-*/
-_configureSubmenu: function(p_oItem) {
-
- var oSubmenu = p_oItem.cfg.getProperty("submenu");
-
- if(oSubmenu) {
-
- /*
- Listen for configuration changes to the parent menu
- so they they can be applied to the submenu.
- */
-
- this.cfg.configChangedEvent.subscribe(
- this._onParentMenuConfigChange,
- oSubmenu,
- true
- );
-
- this.renderEvent.subscribe(
- this._onParentMenuRender,
- oSubmenu,
- true
- );
-
- oSubmenu.beforeShowEvent.subscribe(
- this._onSubmenuBeforeShow,
- oSubmenu,
- true
- );
-
- oSubmenu.showEvent.subscribe(
- this._onSubmenuShow,
- oSubmenu,
- true
- );
-
- oSubmenu.hideEvent.subscribe(
- this._onSubmenuHide,
- oSubmenu,
- true
- );
-
- }
-
-},
-
-
-/**
-* @method _subscribeToItemEvents
-* @description Subscribes a menu to a menu item's event.
-* @private
-* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem
-* instance whose events should be subscribed to.
-*/
-_subscribeToItemEvents: function(p_oItem) {
-
- p_oItem.focusEvent.subscribe(this._onMenuItemFocus, p_oItem, this);
-
- p_oItem.blurEvent.subscribe(this._onMenuItemBlur, this, true);
-
- p_oItem.cfg.configChangedEvent.subscribe(
- this._onMenuItemConfigChange,
- p_oItem,
- this
- );
-
-},
-
-
-/**
-* @method _getOffsetWidth
-* @description Returns the offset width of the menu's
-* <div>
element.
-* @private
-*/
-_getOffsetWidth: function() {
-
- var oClone = this.element.cloneNode(true);
-
- Dom.setStyle(oClone, "width", "");
-
- document.body.appendChild(oClone);
-
- var sWidth = oClone.offsetWidth;
-
- document.body.removeChild(oClone);
-
- return sWidth;
-
-},
-
-
-/**
-* @method _cancelHideDelay
-* @description Cancels the call to "hideMenu."
-* @private
-*/
-_cancelHideDelay: function() {
-
- var oRoot = this.getRoot();
-
- if(oRoot._nHideDelayId) {
-
- window.clearTimeout(oRoot._nHideDelayId);
-
- }
-
-},
-
-
-/**
-* @method _execHideDelay
-* @description Hides the menu after the number of milliseconds specified by
-* the "hidedelay" configuration property.
-* @private
-*/
-_execHideDelay: function() {
-
- this._cancelHideDelay();
-
- var oRoot = this.getRoot(),
- me = this;
-
- function hideMenu() {
-
- if(oRoot.activeItem) {
-
- oRoot.clearActiveItem();
-
- }
-
- if(oRoot == me && me.cfg.getProperty("position") == "dynamic") {
-
- me.hide();
-
- }
-
- }
-
-
- oRoot._nHideDelayId =
- window.setTimeout(hideMenu, oRoot.cfg.getProperty("hidedelay"));
-
-},
-
-
-/**
-* @method _cancelShowDelay
-* @description Cancels the call to the "showMenu."
-* @private
-*/
-_cancelShowDelay: function() {
-
- var oRoot = this.getRoot();
-
- if(oRoot._nShowDelayId) {
-
- window.clearTimeout(oRoot._nShowDelayId);
-
- }
-
-},
-
-
-/**
-* @method _execShowDelay
-* @description Shows the menu after the number of milliseconds specified by
-* the "showdelay" configuration property have ellapsed.
-* @private
-* @param {YAHOO.widget.Menu} p_oMenu Object specifying the menu that should
-* be made visible.
-*/
-_execShowDelay: function(p_oMenu) {
-
- var oRoot = this.getRoot();
-
- function showMenu() {
-
- p_oMenu.show();
-
- }
-
-
- oRoot._nShowDelayId =
- window.setTimeout(showMenu, oRoot.cfg.getProperty("showdelay"));
-
-},
-
-
-
-// Protected methods
-
-
-/**
-* @method _onMouseOver
-* @description "mouseover" event handler for the menu.
-* @protected
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-_onMouseOver: function(p_sType, p_aArgs, p_oMenu) {
-
- var oEvent = p_aArgs[0],
- oItem = p_aArgs[1],
- oTarget = Event.getTarget(oEvent);
-
-
- if(
- !this._bHandledMouseOverEvent &&
- (oTarget == this.element || Dom.isAncestor(this.element, oTarget))
- ) {
-
- this.clearActiveItem();
-
- this._bHandledMouseOverEvent = true;
- this._bHandledMouseOutEvent = false;
-
- }
-
-
- if(
- oItem && !oItem.handledMouseOverEvent &&
- !oItem.cfg.getProperty("disabled") &&
- (oTarget == oItem.element || Dom.isAncestor(oItem.element, oTarget))
- ) {
-
- var nShowDelay = this.cfg.getProperty("showdelay"),
- bShowDelay = (nShowDelay > 0);
-
-
- if(bShowDelay) {
-
- this._cancelShowDelay();
-
- }
-
-
- var oActiveItem = this.activeItem;
-
- if(oActiveItem) {
-
- oActiveItem.cfg.setProperty("selected", false);
-
- var oActiveSubmenu = oActiveItem.cfg.getProperty("submenu");
-
- if(oActiveSubmenu) {
-
- oActiveSubmenu.hide();
-
- }
-
- }
-
-
- var oItemCfg = oItem.cfg;
-
- // Select and focus the current menu item
-
- oItemCfg.setProperty("selected", true);
- oItem.focus();
-
-
- if(this.cfg.getProperty("autosubmenudisplay")) {
-
- // Show the submenu this menu item
-
- var oSubmenu = oItemCfg.getProperty("submenu");
-
- if(oSubmenu) {
-
- if(bShowDelay) {
-
- this._execShowDelay(oSubmenu);
-
- }
- else {
-
- oSubmenu.show();
-
- }
-
- }
-
- }
-
- oItem.handledMouseOverEvent = true;
- oItem.handledMouseOutEvent = false;
-
- }
-
-},
-
-
-/**
-* @method _onMouseOut
-* @description "mouseout" event handler for the menu.
-* @protected
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-_onMouseOut: function(p_sType, p_aArgs, p_oMenu) {
-
- var oEvent = p_aArgs[0],
- oItem = p_aArgs[1],
- oRelatedTarget = Event.getRelatedTarget(oEvent),
- bMovingToSubmenu = false;
-
-
- if(oItem && !oItem.cfg.getProperty("disabled")) {
-
- var oItemCfg = oItem.cfg,
- oSubmenu = oItemCfg.getProperty("submenu");
-
-
- if(
- oSubmenu &&
- (
- oRelatedTarget == oSubmenu.element ||
- Dom.isAncestor(oSubmenu.element, oRelatedTarget)
- )
- ) {
-
- bMovingToSubmenu = true;
-
- }
-
-
- if(
- !oItem.handledMouseOutEvent &&
- (
- (
- oRelatedTarget != oItem.element &&
- !Dom.isAncestor(oItem.element, oRelatedTarget)
- ) || bMovingToSubmenu
- )
- ) {
-
- if(
- !oSubmenu ||
- (oSubmenu && !oSubmenu.cfg.getProperty("visible"))
- ) {
-
- oItem.cfg.setProperty("selected", false);
-
- if(
- oSubmenu &&
- oSubmenu.cfg.getProperty("showdelay") &&
- !oSubmenu.cfg.getProperty("visible")
- ) {
-
- this._cancelShowDelay();
-
- }
-
- }
-
-
- oItem.handledMouseOutEvent = true;
- oItem.handledMouseOverEvent = false;
-
- }
-
- }
-
-
- if(
- !this._bHandledMouseOutEvent &&
- (
- (
- oRelatedTarget != this.element &&
- !Dom.isAncestor(this.element, oRelatedTarget)
- )
- || bMovingToSubmenu
- )
- ) {
-
- this._bHandledMouseOutEvent = true;
- this._bHandledMouseOverEvent = false;
-
- }
-
-},
-
-
-/**
-* @method _onClick
-* @description "click" event handler for the menu.
-* @protected
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-_onClick: function(p_sType, p_aArgs, p_oMenu) {
-
- var oEvent = p_aArgs[0],
- oItem = p_aArgs[1],
- oTarget = Event.getTarget(oEvent);
-
- if(oItem && !oItem.cfg.getProperty("disabled")) {
-
- var oItemCfg = oItem.cfg,
- oSubmenu = oItemCfg.getProperty("submenu");
-
-
- /*
- ACCESSIBILITY FEATURE FOR SCREEN READERS:
- Expand/collapse the submenu when the user clicks
- on the submenu indicator image.
- */
-
- if(oTarget == oItem.submenuIndicator && oSubmenu) {
-
- if(oSubmenu.cfg.getProperty("visible")) {
-
- oSubmenu.hide();
-
- }
- else {
-
- this.clearActiveItem();
-
- this.activeItem = oItem;
-
- oItem.cfg.setProperty("selected", true);
-
- oSubmenu.show();
-
- }
-
- }
- else {
-
- var sURL = oItemCfg.getProperty("url"),
- bCurrentPageURL = (sURL.substr((sURL.length-1),1) == "#"),
- sTarget = oItemCfg.getProperty("target"),
- bHasTarget = (sTarget && sTarget.length > 0);
-
- /*
- Prevent the browser from following links
- equal to "#"
- */
-
- if(
- oTarget.tagName.toUpperCase() == "A" &&
- bCurrentPageURL && !bHasTarget
- ) {
-
- Event.preventDefault(oEvent);
-
- }
-
- if(
- oTarget.tagName.toUpperCase() != "A" &&
- !bCurrentPageURL && !bHasTarget
- ) {
-
- /*
- Follow the URL of the item regardless of
- whether or not the user clicked specifically
- on the anchor element.
- */
-
- document.location = sURL;
-
- }
-
-
- /*
- If the item doesn't navigate to a URL and it doesn't have
- a submenu, then collapse the menu tree.
- */
-
- if(bCurrentPageURL && !oSubmenu) {
-
- var oRoot = this.getRoot();
-
- if(oRoot.cfg.getProperty("position") == "static") {
-
- oRoot.clearActiveItem();
-
- }
- else {
-
- oRoot.hide();
-
- }
-
- }
-
- }
-
- }
-
-},
-
-
-/**
-* @method _onKeyDown
-* @description "keydown" event handler for the menu.
-* @protected
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-_onKeyDown: function(p_sType, p_aArgs, p_oMenu) {
-
- var oEvent = p_aArgs[0],
- oItem = p_aArgs[1],
- oSubmenu;
-
- if(oItem && !oItem.cfg.getProperty("disabled")) {
-
- var oItemCfg = oItem.cfg,
- oParentItem = this.parent,
- oRoot,
- oNextItem;
-
-
- switch(oEvent.keyCode) {
-
- case 38: // Up arrow
- case 40: // Down arrow
-
- if(
- oItem == this.activeItem &&
- !oItemCfg.getProperty("selected")
- ) {
-
- oItemCfg.setProperty("selected", true);
-
- }
- else {
-
- oNextItem = (oEvent.keyCode == 38) ?
- oItem.getPreviousEnabledSibling() :
- oItem.getNextEnabledSibling();
-
- if(oNextItem) {
-
- this.clearActiveItem();
-
- oNextItem.cfg.setProperty("selected", true);
- oNextItem.focus();
-
- }
-
- }
-
- Event.preventDefault(oEvent);
-
- break;
-
-
- case 39: // Right arrow
-
- oSubmenu = oItemCfg.getProperty("submenu");
-
- if(oSubmenu) {
-
- if(!oItemCfg.getProperty("selected")) {
-
- oItemCfg.setProperty("selected", true);
-
- }
-
- oSubmenu.show();
-
- oSubmenu.setInitialSelection();
-
- }
- else {
-
- oRoot = this.getRoot();
-
- if(oRoot instanceof YAHOO.widget.MenuBar) {
-
- oNextItem = oRoot.activeItem.getNextEnabledSibling();
-
- if(oNextItem) {
-
- oRoot.clearActiveItem();
-
- oNextItem.cfg.setProperty("selected", true);
-
- oSubmenu = oNextItem.cfg.getProperty("submenu");
-
- if(oSubmenu) {
-
- oSubmenu.show();
-
- }
-
- oNextItem.focus();
-
- }
-
- }
-
- }
-
-
- Event.preventDefault(oEvent);
-
- break;
-
-
- case 37: // Left arrow
-
- if(oParentItem) {
-
- var oParentMenu = oParentItem.parent;
-
- if(oParentMenu instanceof YAHOO.widget.MenuBar) {
-
- oNextItem =
- oParentMenu.activeItem.getPreviousEnabledSibling();
-
- if(oNextItem) {
-
- oParentMenu.clearActiveItem();
-
- oNextItem.cfg.setProperty("selected", true);
-
- oSubmenu = oNextItem.cfg.getProperty("submenu");
-
- if(oSubmenu) {
-
- oSubmenu.show();
-
- }
-
- oNextItem.focus();
-
- }
-
- }
- else {
-
- this.hide();
-
- oParentItem.focus();
-
- }
-
- }
-
- Event.preventDefault(oEvent);
-
- break;
-
- }
-
-
- }
-
-
- if(oEvent.keyCode == 27) { // Esc key
-
- if(this.cfg.getProperty("position") == "dynamic") {
-
- this.hide();
-
- if(this.parent) {
-
- this.parent.focus();
-
- }
-
- }
- else if(this.activeItem) {
-
- oSubmenu = this.activeItem.cfg.getProperty("submenu");
-
- if(oSubmenu && oSubmenu.cfg.getProperty("visible")) {
-
- oSubmenu.hide();
- this.activeItem.focus();
-
- }
- else {
-
- this.activeItem.cfg.setProperty("selected", false);
- this.activeItem.blur();
-
- }
-
- }
-
-
- Event.preventDefault(oEvent);
-
- }
-
-},
-
-
-/**
-* @method _onTextResize
-* @description "textresize" event handler for the menu.
-* @protected
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-_onTextResize: function(p_sType, p_aArgs, p_oMenu) {
-
- if(this.browser == "gecko" && !this._handleResize) {
-
- this._handleResize = true;
- return;
-
- }
-
-
- var oConfig = this.cfg;
-
- if(oConfig.getProperty("position") == "dynamic") {
-
- oConfig.setProperty("width", (this._getOffsetWidth() + "px"));
-
- }
-
-},
-
-
-
-// Private methods
-
-
-/**
-* @method _onInit
-* @description "init" event handler for the menu.
-* @private
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-_onInit: function(p_sType, p_aArgs, p_oMenu) {
-
- if(
- (
- (this.parent && !this.lazyLoad) ||
- (!this.parent && this.cfg.getProperty("position") == "static") ||
- (
- !this.parent &&
- !this.lazyLoad &&
- this.cfg.getProperty("position") == "dynamic"
- )
- ) &&
- this.getItemGroups().length === 0
- ) {
-
- if(this.srcElement) {
-
- this._initSubTree();
-
- }
-
-
- if(this.itemData) {
-
- this.addItems(this.itemData);
-
- }
-
- }
- else if(this.lazyLoad) {
-
- this.cfg.fireQueue();
-
- }
-
-},
-
-
-/**
-* @method _onBeforeRender
-* @description "beforerender" event handler for the menu. Appends all of the
-* <ul>
, <li>
and their accompanying
-* title elements to the body element of the menu.
-* @private
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-_onBeforeRender: function(p_sType, p_aArgs, p_oMenu) {
-
- var oConfig = this.cfg,
- oEl = this.element,
- nListElements = this._aListElements.length;
-
-
- if(nListElements > 0) {
-
- var i = 0,
- bFirstList = true,
- oUL,
- oGroupTitle;
-
-
- do {
-
- oUL = this._aListElements[i];
-
- if(oUL) {
-
- if(bFirstList) {
-
- Dom.addClass(oUL, "first-of-type");
- bFirstList = false;
-
- }
-
-
- if(!Dom.isAncestor(oEl, oUL)) {
-
- this.appendToBody(oUL);
-
- }
-
-
- oGroupTitle = this._aGroupTitleElements[i];
-
- if(oGroupTitle) {
-
- if(!Dom.isAncestor(oEl, oGroupTitle)) {
-
- oUL.parentNode.insertBefore(oGroupTitle, oUL);
-
- }
-
-
- Dom.addClass(oUL, "hastitle");
-
- }
-
- }
-
- i++;
-
- }
- while(i < nListElements);
-
- }
-
-},
-
-
-/**
-* @method _onRender
-* @description "render" event handler for the menu.
-* @private
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-_onRender: function(p_sType, p_aArgs, p_oMenu) {
-
- if(this.cfg.getProperty("position") == "dynamic") {
-
- var sWidth =
- this.element.parentNode.tagName.toUpperCase() == "BODY" ?
- this.element.offsetWidth : this._getOffsetWidth();
-
- this.cfg.setProperty("width", (sWidth + "px"));
-
- }
-
-},
-
-
-/**
-* @method _onBeforeShow
-* @description "beforeshow" event handler for the menu.
-* @private
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-_onBeforeShow: function(p_sType, p_aArgs, p_oMenu) {
-
- if(this.lazyLoad && this.getItemGroups().length === 0) {
-
- if(this.srcElement) {
-
- this._initSubTree();
-
- }
-
-
- if(this.itemData) {
-
- if(
- this.parent && this.parent.parent &&
- this.parent.parent.srcElement &&
- this.parent.parent.srcElement.tagName.toUpperCase() == "SELECT"
- ) {
-
- var nOptions = this.itemData.length;
-
- for(var n=0; n viewPortWidth) {
-
- if(
- oContextElement &&
- ((x - oContextElement.offsetWidth) > offsetWidth)
- ) {
-
- x = (x - (oContextElement.offsetWidth + offsetWidth));
-
- }
- else {
-
- x = rightConstraint;
-
- }
-
- }
-
- if (y < 10) {
-
- y = topConstraint;
-
- } else if (y > bottomConstraint) {
-
- if(oContextElement && (y > offsetHeight)) {
-
- y = ((y + oContextElement.offsetHeight) - offsetHeight);
-
- }
- else {
-
- y = bottomConstraint;
-
- }
-
- }
-
- oConfig.setProperty("x", x, true);
- oConfig.setProperty("y", y, true);
- oConfig.setProperty("xy", [x,y], true);
-
-},
-
-
-/**
-* @method configVisible
-* @description Event handler for when the "visible" configuration property
-* the menu changes.
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-configVisible: function(p_sType, p_aArgs, p_oMenu) {
-
- if(this.cfg.getProperty("position") == "dynamic") {
-
- YAHOO.widget.Menu.superclass.configVisible.call(
- this,
- p_sType,
- p_aArgs,
- p_oMenu
- );
-
- }
- else {
-
- var bVisible = p_aArgs[0],
- sDisplay = Dom.getStyle(this.element, "display");
-
- if(bVisible) {
-
- if(sDisplay != "block") {
- this.beforeShowEvent.fire();
- Dom.setStyle(this.element, "display", "block");
- this.showEvent.fire();
- }
-
- }
- else {
-
- if(sDisplay == "block") {
- this.beforeHideEvent.fire();
- Dom.setStyle(this.element, "display", "none");
- this.hideEvent.fire();
- }
-
- }
-
- }
-
-},
-
-
-/**
-* @method configPosition
-* @description Event handler for when the "position" configuration property
-* of the menu changes.
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-configPosition: function(p_sType, p_aArgs, p_oMenu) {
-
- var sCSSPosition = p_aArgs[0] == "static" ? "static" : "absolute",
- oCfg = this.cfg;
-
- Dom.setStyle(this.element, "position", sCSSPosition);
-
-
- if(sCSSPosition == "static") {
-
- /*
- Remove the iframe for statically positioned menus since it will
- intercept mouse events.
- */
-
- oCfg.setProperty("iframe", false);
-
-
- // Statically positioned menus are visible by default
-
- Dom.setStyle(this.element, "display", "block");
-
- oCfg.setProperty("visible", true);
-
- }
- else {
-
- /*
- Even though the "visible" property is queued to
- "false" by default, we need to set the "visibility" property to
- "hidden" since Overlay's "configVisible" implementation checks the
- element's "visibility" style property before deciding whether
- or not to show an Overlay instance.
- */
-
- Dom.setStyle(this.element, "visibility", "hidden");
-
- }
-
-
- if(sCSSPosition == "absolute") {
-
- var nZIndex = oCfg.getProperty("zindex");
-
- if(!nZIndex || nZIndex === 0) {
-
- nZIndex = this.parent ?
- (this.parent.parent.cfg.getProperty("zindex") + 1) : 1;
-
- oCfg.setProperty("zindex", nZIndex);
-
- }
-
- }
-
-},
-
-
-/**
-* @method configIframe
-* @description Event handler for when the "iframe" configuration property of
-* the menu changes.
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-configIframe: function(p_sType, p_aArgs, p_oMenu) {
-
- if(this.cfg.getProperty("position") == "dynamic") {
-
- YAHOO.widget.Menu.superclass.configIframe.call(
- this,
- p_sType,
- p_aArgs,
- p_oMenu
- );
-
- }
-
-},
-
-
-/**
-* @method configHideDelay
-* @description Event handler for when the "hidedelay" configuration property
-* of the menu changes.
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-configHideDelay: function(p_sType, p_aArgs, p_oMenu) {
-
- var nHideDelay = p_aArgs[0],
- oMouseOutEvent = this.mouseOutEvent,
- oMouseOverEvent = this.mouseOverEvent,
- oKeyDownEvent = this.keyDownEvent;
-
- if(nHideDelay > 0) {
-
- /*
- Only assign event handlers once. This way the user change
- the value for the hidedelay as many times as they want.
- */
-
- if(!this._hideDelayEventHandlersAssigned) {
-
- oMouseOutEvent.subscribe(this._execHideDelay, true);
- oMouseOverEvent.subscribe(this._cancelHideDelay, this, true);
- oKeyDownEvent.subscribe(this._cancelHideDelay, this, true);
-
- this._hideDelayEventHandlersAssigned = true;
-
- }
-
- }
- else {
-
- oMouseOutEvent.unsubscribe(this._execHideDelay, this);
- oMouseOverEvent.unsubscribe(this._cancelHideDelay, this);
- oKeyDownEvent.unsubscribe(this._cancelHideDelay, this);
-
- this._hideDelayEventHandlersAssigned = false;
-
- }
-
-},
-
-
-/**
-* @method configContainer
-* @description Event handler for when the "container" configuration property
-of the menu changes.
-* @param {String} p_sType String representing the name of the event that
-* was fired.
-* @param {Array} p_aArgs Array of arguments sent when the event was fired.
-* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that
-* fired the event.
-*/
-configContainer: function(p_sType, p_aArgs, p_oMenu) {
-
- var oElement = p_aArgs[0];
-
- if(typeof oElement == 'string') {
-
- this.cfg.setProperty(
- "container",
- document.getElementById(oElement),
- true
- );
-
- }
-
-},
-
-
-
-// Public methods
-
-
-/**
-* @method initEvents
-* @description Initializes the custom events for the menu.
-*/
-initEvents: function() {
-
- YAHOO.widget.Menu.superclass.initEvents.call(this);
-
- // Create custom events
-
- var CustomEvent = YAHOO.util.CustomEvent;
-
- this.mouseOverEvent = new CustomEvent("mouseOverEvent", this);
- this.mouseOutEvent = new CustomEvent("mouseOutEvent", this);
- this.mouseDownEvent = new CustomEvent("mouseDownEvent", this);
- this.mouseUpEvent = new CustomEvent("mouseUpEvent", this);
- this.clickEvent = new CustomEvent("clickEvent", this);
- this.keyPressEvent = new CustomEvent("keyPressEvent", this);
- this.keyDownEvent = new CustomEvent("keyDownEvent", this);
- this.keyUpEvent = new CustomEvent("keyUpEvent", this);
- this.itemAddedEvent = new CustomEvent("itemAddedEvent", this);
- this.itemRemovedEvent = new CustomEvent("itemRemovedEvent", this);
-
-},
-
-
-/**
-* @method getRoot
-* @description Finds the menu's root menu.
-*/
-getRoot: function() {
-
- var oItem = this.parent;
-
- if(oItem) {
-
- var oParentMenu = oItem.parent;
-
- return oParentMenu ? oParentMenu.getRoot() : this;
-
- }
- else {
-
- return this;
-
- }
-
-},
-
-
-/**
-* @method toString
-* @description Returns a string representing the menu.
-* @return {String}
-*/
-toString: function() {
-
- return ("Menu " + this.id);
-
-},
-
-
-/**
-* @method setItemGroupTitle
-* @description Sets the title of a group of menu items.
-* @param {String} p_sGroupTitle String specifying the title of the group.
-* @param {Number} p_nGroupIndex Optional. Number specifying the group to which
-* the title belongs.
-*/
-setItemGroupTitle: function(p_sGroupTitle, p_nGroupIndex) {
-
- if(typeof p_sGroupTitle == "string" && p_sGroupTitle.length > 0) {
-
- var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0,
- oTitle = this._aGroupTitleElements[nGroupIndex];
-
-
- if(oTitle) {
-
- oTitle.innerHTML = p_sGroupTitle;
-
- }
- else {
-
- oTitle = document.createElement(this.GROUP_TITLE_TAG_NAME);
-
- oTitle.innerHTML = p_sGroupTitle;
-
- this._aGroupTitleElements[nGroupIndex] = oTitle;
-
- }
-
-
- var i = this._aGroupTitleElements.length - 1,
- nFirstIndex;
-
- do {
-
- if(this._aGroupTitleElements[i]) {
-
- Dom.removeClass(this._aGroupTitleElements[i], "first-of-type");
-
- nFirstIndex = i;
-
- }
-
- }
- while(i--);
-
-
- if(nFirstIndex !== null) {
-
- Dom.addClass(
- this._aGroupTitleElements[nFirstIndex],
- "first-of-type"
- );
-
- }
-
- }
-
-},
-
-
-
-/**
-* @method addItem
-* @description Appends an item to the menu.
-* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem
-* instance to be added to the menu.
-* @param {String} p_oItem String specifying the text of the item to be added
-* to the menu.
-* @param {Object} p_oItem Object literal containing a set of menu item
-* configuration properties.
-* @param {Number} p_nGroupIndex Optional. Number indicating the group to
-* which the item belongs.
-* @return {YAHOO.widget.MenuItem}
-*/
-addItem: function(p_oItem, p_nGroupIndex) {
-
- if(p_oItem) {
-
- return this._addItemToGroup(p_nGroupIndex, p_oItem);
-
- }
-
-},
-
-
-/**
-* @method addItems
-* @description Adds an array of items to the menu.
-* @param {Array} p_aItems Array of items to be added to the menu. The array
-* can contain strings specifying the text for each item to be created, object
-* literals specifying each of the menu item configuration properties,
-* or MenuItem instances.
-* @param {Number} p_nGroupIndex Optional. Number specifying the group to
-* which the items belongs.
-* @return {Array}
-*/
-addItems: function(p_aItems, p_nGroupIndex) {
-
- function isArray(p_oValue) {
-
- return (typeof p_oValue == "object" && p_oValue.constructor == Array);
-
- }
-
-
- if(isArray(p_aItems)) {
-
- var nItems = p_aItems.length,
- aItems = [],
- oItem;
-
-
- for(var i=0; i<div> element
-* (and accompanying child nodes) from the document.
-*/
-destroy: function() {
-
- // Remove Custom Event listeners
-
- this.mouseOverEvent.unsubscribeAll();
- this.mouseOutEvent.unsubscribeAll();
- this.mouseDownEvent.unsubscribeAll();
- this.mouseUpEvent.unsubscribeAll();
- this.clickEvent.unsubscribeAll();
- this.keyPressEvent.unsubscribeAll();
- this.keyDownEvent.unsubscribeAll();
- this.keyUpEvent.unsubscribeAll();
- this.itemAddedEvent.unsubscribeAll();
- this.itemRemovedEvent.unsubscribeAll();
-
- var nItemGroups = this._aItemGroups.length,
- nItems,
- oItemGroup,
- oItem,
- i,
- n;
-
-
- // Remove all items
-
- if(nItemGroups > 0) {
-
- i = nItemGroups - 1;
-
- do {
-
- oItemGroup = this._aItemGroups[i];
-
- if(oItemGroup) {
-
- nItems = oItemGroup.length;
-
- if(nItems > 0) {
-
- n = nItems - 1;
-
- do {
-
- oItem = this._aItemGroups[i][n];
-
- if(oItem) {
-
- oItem.destroy();
- }
-
- }
- while(n--);
-
- }
-
- }
-
- }
- while(i--);
-
- }
-
-
- // Continue with the superclass implementation of this method
-
- YAHOO.widget.Menu.superclass.destroy.call(this);
-
- this.logger.log("Destroyed.");
-
-},
-
-
-/**
-* @method setInitialFocus
-* @description Sets focus to the menu's first enabled item.
-*/
-setInitialFocus: function() {
-
- var oItem = this._getFirstEnabledItem();
-
- if(oItem) {
-
- oItem.focus();
- }
-
-},
-
-
-/**
-* @method setInitialSelection
-* @description Sets the "selected" configuration property of the menu's first
-* enabled item to "true."
-*/
-setInitialSelection: function() {
-
- var oItem = this._getFirstEnabledItem();
-
- if(oItem) {
-
- oItem.cfg.setProperty("selected", true);
- }
-
-},
-
-
-/**
-* @method clearActiveItem
-* @description Sets the "selected" configuration property of the menu's active
-* item to "false" and hides the item's submenu.
-* @param {Boolean} p_bBlur Boolean indicating if the menu's active item
-* should be blurred.
-*/
-clearActiveItem: function(p_bBlur) {
-
- if(this.cfg.getProperty("showdelay") > 0) {
-
- this._cancelShowDelay();
-
- }
-
-
- var oActiveItem = this.activeItem;
-
- if(oActiveItem) {
-
- var oConfig = oActiveItem.cfg;
-
- oConfig.setProperty("selected", false);
-
- var oSubmenu = oConfig.getProperty("submenu");
-
- if(oSubmenu) {
-
- oSubmenu.hide();
-
- }
-
- if(p_bBlur) {
-
- oActiveItem.blur();
-
- }
-
- }
-
-},
-
-
-/**
-* @description Initializes the class's configurable properties which can be
-* changed using the menu's Config object ("cfg").
-* @method initDefaultConfig
-*/
-initDefaultConfig: function() {
-
- YAHOO.widget.Menu.superclass.initDefaultConfig.call(this);
-
- var oConfig = this.cfg;
-
- // Add configuration properties
-
- /*
- Change the default value for the "visible" configuration
- property to "false" by re-adding the property.
- */
-
- /**
- * @config visible
- * @description Boolean indicating whether or not the menu is visible. If
- * the menu's "position" configuration property is set to "dynamic" (the
- * default), this property toggles the menu's