From: toyomoyo
Date: Thu, 2 Aug 2007 09:13:40 +0000 (+0000)
Subject: MDL-10336, upgrading YUI to 2.3.0
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=489a965500d4101b147a4a106fdbef051f97dcc7;p=moodle.git
MDL-10336, upgrading YUI to 2.3.0
---
diff --git a/lib/yui/animation/README b/lib/yui/animation/README
index d6ea69a4be..f5dc0bda21 100755
--- a/lib/yui/animation/README
+++ b/lib/yui/animation/README
@@ -1,5 +1,23 @@
Animation Release Notes
+*** version 2.3.0 ***
+
+* duration of zero now executes 1 frame animation
+* added setEl() method to enable reuse
+* fixed stop() for multiple animations
+
+*** version 2.2.2 **
+
+* no change
+
+*** version 2.2.1 **
+
+* no change
+
+*** version 2.2.0 **
+
+* Fixed AnimMgr.stop() when called without tween
+
*** version 0.12.2 ***
* raised AnimMgr.fps to 1000
diff --git a/lib/yui/animation/animation-debug.js b/lib/yui/animation/animation-debug.js
index 7745b235b7..4980ffadb3 100755
--- a/lib/yui/animation/animation-debug.js
+++ b/lib/yui/animation/animation-debug.js
@@ -1,9 +1,15 @@
/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.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
*/
+
/**
* The animation module provides allows effects to be added to HTMLElements.
* @module animation
@@ -32,9 +38,10 @@ version: 0.12.2
*/
YAHOO.util.Anim = function(el, attributes, duration, method) {
- if (el) {
- this.init(el, attributes, duration, method);
+ if (!el) {
+ YAHOO.log('element required to create Anim instance', 'error', 'Anim');
}
+ this.init(el, attributes, duration, method);
};
YAHOO.util.Anim.prototype = {
@@ -45,7 +52,7 @@ YAHOO.util.Anim.prototype = {
*/
toString: function() {
var el = this.getEl();
- var id = el.id || el.tagName;
+ var id = el.id || el.tagName || el;
return ("Anim " + id);
},
@@ -155,10 +162,10 @@ YAHOO.util.Anim.prototype = {
if (start.constructor == Array) {
end = [];
for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + attributes[attr]['by'][i];
+ end[i] = start[i] + attributes[attr]['by'][i] * 1; // times 1 to cast "by"
}
} else {
- end = start + attributes[attr]['by'];
+ end = start + attributes[attr]['by'] * 1;
}
}
@@ -166,7 +173,9 @@ YAHOO.util.Anim.prototype = {
this.runtimeAttributes[attr].end = end;
// set units if needed
- this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
+ this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ?
+ attributes[attr]['unit'] : this.getDefaultUnit(attr);
+ return true;
},
/**
@@ -230,7 +239,7 @@ YAHOO.util.Anim.prototype = {
* @property duration
* @type Number
*/
- this.duration = duration || 1;
+ this.duration = !YAHOO.lang.isUndefined(duration) ? duration : 1;
/**
* The method that will provide values to the attribute(s) during the animation.
@@ -264,6 +273,13 @@ YAHOO.util.Anim.prototype = {
*/
this.totalFrames = YAHOO.util.AnimMgr.fps;
+ /**
+ * Changes the animated element
+ * @method setEl
+ */
+ this.setEl = function(element) {
+ el = YAHOO.util.Dom.get(element);
+ };
/**
* Returns a reference to the animated element.
@@ -310,7 +326,11 @@ YAHOO.util.Anim.prototype = {
this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration;
+ if (this.duration === 0 && this.useSeconds) {
+ this.totalFrames = 1; // jump to last frame if no duration
+ }
YAHOO.util.AnimMgr.registerElement(this);
+ return true;
};
/**
@@ -506,10 +526,18 @@ YAHOO.util.AnimMgr = new function() {
this.unRegister = function(tween, index) {
tween._onComplete.fire();
index = index || getIndex(tween);
- if (index != -1) { queue.splice(index, 1); }
+ if (index == -1) {
+ return false;
+ }
+ queue.splice(index, 1);
+
tweenCount -= 1;
- if (tweenCount <= 0) { this.stop(); }
+ if (tweenCount <= 0) {
+ this.stop();
+ }
+
+ return true;
};
/**
@@ -518,7 +546,9 @@ YAHOO.util.AnimMgr = new function() {
* @method start
*/
this.start = function() {
- if (thread === null) { thread = setInterval(this.run, this.delay); }
+ if (thread === null) {
+ thread = setInterval(this.run, this.delay);
+ }
};
/**
@@ -530,11 +560,13 @@ YAHOO.util.AnimMgr = new function() {
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);
+ if ( queue[0].isAnimated() ) {
+ this.unRegister(queue[0], 0);
}
}
+
queue = [];
thread = null;
tweenCount = 0;
@@ -774,7 +806,8 @@ YAHOO.util.Bezier = new function() {
this.runtimeAttributes[attr].end = end;
}
};
-})();/*
+})();
+/*
TERMS OF USE - EASING EQUATIONS
Open source under the BSD License.
Copyright 2001 Robert Penner All rights reserved.
@@ -1343,3 +1376,4 @@ YAHOO.util.Easing = {
}
};
})();
+YAHOO.register("animation", YAHOO.util.Anim, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/animation/animation-min.js b/lib/yui/animation/animation-min.js
index 9e1291f510..284ff25f75 100755
--- a/lib/yui/animation/animation-min.js
+++ b/lib/yui/animation/animation-min.js
@@ -1,22 +1,25 @@
/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 0.12.2
+version: 2.3.0
*/
-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.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||el;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){this.runtimeAttributes
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
+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);}};})();YAHOO.register("animation",YAHOO.util.Anim,{version:"2.3.0",build:"442"});
\ No newline at end of file
diff --git a/lib/yui/animation/animation.js b/lib/yui/animation/animation.js
index 3b34cf4af3..236d338353 100755
--- a/lib/yui/animation/animation.js
+++ b/lib/yui/animation/animation.js
@@ -1,9 +1,15 @@
/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.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
*/
+
/**
* The animation module provides allows effects to be added to HTMLElements.
* @module animation
@@ -32,9 +38,9 @@ version: 0.12.2
*/
YAHOO.util.Anim = function(el, attributes, duration, method) {
- if (el) {
- this.init(el, attributes, duration, method);
+ if (!el) {
}
+ this.init(el, attributes, duration, method);
};
YAHOO.util.Anim.prototype = {
@@ -45,7 +51,7 @@ YAHOO.util.Anim.prototype = {
*/
toString: function() {
var el = this.getEl();
- var id = el.id || el.tagName;
+ var id = el.id || el.tagName || el;
return ("Anim " + id);
},
@@ -155,10 +161,10 @@ YAHOO.util.Anim.prototype = {
if (start.constructor == Array) {
end = [];
for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + attributes[attr]['by'][i];
+ end[i] = start[i] + attributes[attr]['by'][i] * 1; // times 1 to cast "by"
}
} else {
- end = start + attributes[attr]['by'];
+ end = start + attributes[attr]['by'] * 1;
}
}
@@ -166,7 +172,9 @@ YAHOO.util.Anim.prototype = {
this.runtimeAttributes[attr].end = end;
// set units if needed
- this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
+ this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ?
+ attributes[attr]['unit'] : this.getDefaultUnit(attr);
+ return true;
},
/**
@@ -230,7 +238,7 @@ YAHOO.util.Anim.prototype = {
* @property duration
* @type Number
*/
- this.duration = duration || 1;
+ this.duration = !YAHOO.lang.isUndefined(duration) ? duration : 1;
/**
* The method that will provide values to the attribute(s) during the animation.
@@ -264,6 +272,13 @@ YAHOO.util.Anim.prototype = {
*/
this.totalFrames = YAHOO.util.AnimMgr.fps;
+ /**
+ * Changes the animated element
+ * @method setEl
+ */
+ this.setEl = function(element) {
+ el = YAHOO.util.Dom.get(element);
+ };
/**
* Returns a reference to the animated element.
@@ -307,7 +322,11 @@ YAHOO.util.Anim.prototype = {
this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration;
+ if (this.duration === 0 && this.useSeconds) {
+ this.totalFrames = 1; // jump to last frame if no duration
+ }
YAHOO.util.AnimMgr.registerElement(this);
+ return true;
};
/**
@@ -503,10 +522,18 @@ YAHOO.util.AnimMgr = new function() {
this.unRegister = function(tween, index) {
tween._onComplete.fire();
index = index || getIndex(tween);
- if (index != -1) { queue.splice(index, 1); }
+ if (index == -1) {
+ return false;
+ }
+ queue.splice(index, 1);
+
tweenCount -= 1;
- if (tweenCount <= 0) { this.stop(); }
+ if (tweenCount <= 0) {
+ this.stop();
+ }
+
+ return true;
};
/**
@@ -515,7 +542,9 @@ YAHOO.util.AnimMgr = new function() {
* @method start
*/
this.start = function() {
- if (thread === null) { thread = setInterval(this.run, this.delay); }
+ if (thread === null) {
+ thread = setInterval(this.run, this.delay);
+ }
};
/**
@@ -527,11 +556,13 @@ YAHOO.util.AnimMgr = new function() {
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);
+ if ( queue[0].isAnimated() ) {
+ this.unRegister(queue[0], 0);
}
}
+
queue = [];
thread = null;
tweenCount = 0;
@@ -771,7 +802,8 @@ YAHOO.util.Bezier = new function() {
this.runtimeAttributes[attr].end = end;
}
};
-})();/*
+})();
+/*
TERMS OF USE - EASING EQUATIONS
Open source under the BSD License.
Copyright 2001 Robert Penner All rights reserved.
@@ -999,6 +1031,7 @@ YAHOO.util.Easing = {
Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
},
+
/**
* Backtracks slightly, then reverses direction and moves to end.
* @method backIn
@@ -1339,3 +1372,4 @@ YAHOO.util.Easing = {
}
};
})();
+YAHOO.register("animation", YAHOO.util.Anim, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/assets/skins/sam/autocomplete.css b/lib/yui/assets/skins/sam/autocomplete.css
new file mode 100755
index 0000000000..98b473e26a
--- /dev/null
+++ b/lib/yui/assets/skins/sam/autocomplete.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-skin-sam .yui-ac{position:relative;font-family:arial;font-size:100%;}.yui-skin-sam .yui-ac-input{position:absolute;width:100%;}.yui-skin-sam .yui-ac-container{position:absolute;top:1.6em;width:100%;}.yui-skin-sam .yui-ac-content{position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050;}.yui-skin-sam .yui-ac-shadow{position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity:0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049;}.yui-skin-sam .yui-ac-content ul{margin:0;padding:0;width:100%;}.yui-skin-sam .yui-ac-content li{margin:0;padding:2px 5px;cursor:default;white-space:nowrap;}.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight{background:#B3D4FF;}.yui-skin-sam .yui-ac-content li.yui-ac-highlight{background:#426FD9;color:#FFF;}
diff --git a/lib/yui/assets/skins/sam/blankimage.png b/lib/yui/assets/skins/sam/blankimage.png
new file mode 100755
index 0000000000..b87bb24850
Binary files /dev/null and b/lib/yui/assets/skins/sam/blankimage.png differ
diff --git a/lib/yui/assets/skins/sam/button.css b/lib/yui/assets/skins/sam/button.css
new file mode 100755
index 0000000000..c1e05f48a2
--- /dev/null
+++ b/lib/yui/assets/skins/sam/button.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-skin-sam .yui-button{display:-moz-inline-box;display:inline-block;border-width:1px 0;border-style:solid;border-color:#808080;background:url(sprite.png) repeat-x 0 0;margin:auto .25em;}.yui-skin-sam .yui-button .first-child{display:block;*display:inline-block;border-width:0 1px;border-style:solid;border-color:#808080;margin:0 -1px;*position:relative;*left:-1px;}.yui-skin-sam .yui-button button,.yui-skin-sam .yui-button a{display:block;*display:inline-block;padding:0 10px;border:none;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-button button{*overflow:visible;background-color:transparent;cursor:pointer;cursor:hand;}.yui-skin-sam .yui-button a{text-decoration:none;}.yui-skin-sam .yui-split-button button,.yui-skin-sam .yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}.yui-skin-sam .yui-menu-button button{background-image:url(menu-button-arrow.png);}.yui-skin-sam .yui-split-button button{background-image:url(split-button-arrow.png);}.yui-skin-sam .yui-button-focus{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-focus .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-focus button,.yui-skin-sam .yui-button-focus a{color:#000;}.yui-skin-sam .yui-split-button-focus button{background-image:url(split-button-arrow-focus.png);}.yui-skin-sam .yui-button-hover{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-hover .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-hover button,.yui-skin-sam .yui-button-hover a{color:#000;}.yui-skin-sam .yui-split-button-hover button{background-image:url(split-button-arrow-hover.png);}.yui-skin-sam .yui-button-active{border-color:#7D98B8;background-position:0 -1700px;}.yui-skin-sam .yui-button-active .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-active button,.yui-skin-sam .yui-button-active a{color:#000;}.yui-skin-sam .yui-split-button-activeoption{border-color:#808080;background-position:0 0;}.yui-skin-sam .yui-split-button-activeoption .first-child{border-color:#808080;}.yui-skin-sam .yui-split-button-activeoption button{background-image:url(split-button-arrow-active.png);}.yui-skin-sam .yui-radio-button-checked,.yui-skin-sam .yui-checkbox-button-checked{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-radio-button-checked .first-child,.yui-skin-sam .yui-checkbox-button-checked .first-child{border-color:#304369;}.yui-skin-sam .yui-radio-button-checked button,.yui-skin-sam .yui-checkbox-button-checked button{color:#fff;}.yui-skin-sam .yui-button-disabled{border-color:#ccc;background-position:0 -1500px;}.yui-skin-sam .yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-button-disabled button,.yui-skin-sam .yui-button-disabled a{color:#A6A6A6;cursor:default;}.yui-skin-sam .yui-menu-button-disabled button{background-image:url(menu-button-arrow-disabled.png);}.yui-skin-sam .yui-split-button-disabled button{background-image:url(split-button-arrow-disabled.png);}
diff --git a/lib/yui/assets/skins/sam/calendar.css b/lib/yui/assets/skins/sam/calendar.css
new file mode 100755
index 0000000000..18e466b658
--- /dev/null
+++ b/lib/yui/assets/skins/sam/calendar.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-calcontainer{position:relative;float:left;_overflow:hidden;}.yui-calcontainer iframe{position:absolute;border:none;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0px;top:0px;}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px;}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative;}.yui-calcontainer .title{position:relative;z-index:1;}.yui-calcontainer .close-icon{position:absolute;z-index:1;}.yui-calendar{position:relative;}.yui-calendar .calnavleft{position:absolute;z-index:1;}.yui-calendar .calnavright{position:absolute;z-index:1;}.yui-calendar .calheader{position:relative;width:100%;text-align:center;}.yui-calendar .calbody a:hover{background:inherit;}p#clear{clear:left;padding-top:10px;}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px;}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px;}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:none;padding:10px 5px 10px 5px;margin:0;}.yui-skin-sam .yui-calcontainer .title{background:url(sprite.png) repeat-x 0 0;border-bottom:1px solid #cccccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left;}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px;}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0;}.yui-skin-sam .yui-calcontainer .calclose{background:url(sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:none;vertical-align:middle;}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center;}.yui-skin-sam .yui-calendar .calheader img{border:none;}.yui-skin-sam .yui-calendar .calnavleft{background:url(sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calnavright{background:url(sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em;}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em;}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2;}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding-right:2px;}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding-left:2px;}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #cccccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap;}.yui-skin-sam .yui-calendar td.calcell a{color:#0066cc;display:block;height:100%;text-decoration:none;}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000;}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff;}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#cccccc;color:#a6a6a6;cursor:default;}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer;}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff;}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0;}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through;}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#ccff99;}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#99ccff;}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#ffcccc;}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#ccff99;}
diff --git a/lib/yui/assets/skins/sam/colorpicker.css b/lib/yui/assets/skins/sam/colorpicker.css
new file mode 100755
index 0000000000..f07aa5140b
--- /dev/null
+++ b/lib/yui/assets/skins/sam/colorpicker.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-picker-panel{background:#e3e3e3;border-color:#888;}.yui-picker-panel .hd{background-color:#ccc;font-size:100%;line-height:100%;border:1px solid #e3e3e3;font-weight:bold;overflow:hidden;padding:6px;color:#000;}.yui-picker-panel .bd{background:#e8e8e8;margin:1px;height:200px;}.yui-picker-panel .ft{background:#e8e8e8;margin:1px;padding:1px;}.yui-picker{position:relative;}.yui-picker-hue-thumb{cursor:default;width:18px;height:18px;top:-8px;left:-2px;z-index:9;position:absolute;}.yui-picker-hue-bg{-moz-outline:none;outline:0px none;position:absolute;left:200px;height:183px;width:14px;background:url(hue_bg.png) no-repeat;top:4px;}.yui-picker-bg{-moz-outline:none;outline:0px none;position:absolute;top:4px;left:4px;height:182px;width:182px;background-color:#F00;background-image:url(picker_mask.png);}*html .yui-picker-bg{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../build/colorpicker/assets/picker_mask.png',sizingMethod='scale');}.yui-picker-mask{position:absolute;z-index:1;top:0px;left:0px;}.yui-picker-thumb{cursor:default;width:11px;height:11px;z-index:9;position:absolute;top:-4px;left:-4px;}.yui-picker-swatch{position:absolute;left:240px;top:4px;height:60px;width:55px;border:1px solid #888;}.yui-picker-websafe-swatch{position:absolute;left:304px;top:4px;height:24px;width:24px;border:1px solid #888;}.yui-picker-controls{position:absolute;top:72px;left:226px;font:1em monospace;}.yui-picker-controls .hd{background:transparent;border-width:0px !important;}.yui-picker-controls .bd{height:100px;border-width:0px !important;}.yui-picker-controls ul{float:left;list-style:none;padding:0 2px 0 0;margin:0}.yui-picker-controls li{padding:2px;margin:0}.yui-picker-controls input{font-size:0.85em;width:2.4em;}.yui-picker-hex-controls{clear:both;padding:2px;}.yui-picker-hex-controls input{width:4.6em;}.yui-picker-controls a{font:1em arial,helvetica,clean,sans-serif;display:block;*display:inline-block;padding:0;color:#000;}
diff --git a/lib/yui/assets/skins/sam/container.css b/lib/yui/assets/skins/sam/container.css
new file mode 100755
index 0000000000..39eb8f52f8
--- /dev/null
+++ b/lib/yui/assets/skins/sam/container.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-overlay,.yui-panel-container{visibility:hidden;position:absolute;z-index:1;}yui-panel-container form{margin:0;}.masked .yui-panel-container{z-index:2;}.mask{z-index:1;display:none;position:absolute;top:0;left:0;right:0;bottom:0;overflow:auto;}.masked select,.drag select,.hide-select select{_visibility:hidden;}.yui-panel-container select{_visibility:inherit;}.hide-scrollbars,.hide-scrollbars *{overflow:hidden;}.hide-scrollbars select{display:none;}.show-scrollbars{overflow:auto;}.yui-panel-container.show-scrollbars,.yui-tt.show-scrollbars{overflow:visible;}.yui-panel-container.show-scrollbars .underlay,.yui-tt.show-scrollbars .yui-tt-shadow{overflow:auto;}.yui-tt-shadow{position:absolute;}.yui-skin-sam .mask{background-color:#000;opacity:.25;*filter:alpha(opacity=25);}.yui-skin-sam .yui-panel-container{padding:0 1px;*padding:2px 3px;}.yui-skin-sam .yui-panel{position:relative;*zoom:1;left:0;top:0;border-style:solid;border-width:1px 0;border-color:#808080;z-index:1;}.yui-skin-sam .yui-panel .hd,.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{*zoom:1;*position:relative;border-style:solid;border-width:0 1px;border-color:#808080;margin:0 -1px;}.yui-skin-sam .yui-panel .hd{border-bottom:solid 1px #ccc;}.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{background-color:#F2F2F2;}.yui-skin-sam .yui-panel .hd{padding:0 10px;font-size:93%;line-height:2;*line-height:1.9;font-weight:bold;color:#000;background:url(sprite.png) repeat-x 0 -200px;}.yui-skin-sam .yui-panel .bd{padding:10px;}.yui-skin-sam .yui-panel .ft{border-top:solid 1px #808080;padding:5px 10px;font-size:77%;}.yui-skin-sam .yui-panel-container.focused .yui-panel .hd{}.yui-skin-sam .container-close{position:absolute;top:5px;right:6px;width:25px;height:15px;background:url(sprite.png) no-repeat 0 -300px;}.yui-skin-sam .yui-panel-container .underlay{right:-1px;left:-1px;}.yui-skin-sam .yui-panel-container.matte{padding:9px 10px;background-color:#fff;}.yui-skin-sam .yui-panel-container.shadow{_padding:2px 5px 0 3px;}.yui-skin-sam .yui-panel-container.shadow .underlay{position:absolute;top:2px;right:-3px;bottom:-3px;left:-3px;*top:3px;*left:-1px;*right:-1px;*bottom:-1px;_top:0;_right:0;_bottom:0;_left:0;_margin-top:3px;_margin-left:-1px;background-color:#000;opacity:.12;*filter:alpha(opacity=12);}.yui-skin-sam .yui-dialog .ft{border-top:none;padding:0 10px 10px 10px;font-size:100%;}.yui-skin-sam .yui-dialog .ft .button-group{display:block;text-align:right;}.yui-skin-sam .yui-dialog .ft .default{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-dialog .ft .default .first-child{border-color:#304369;}.yui-skin-sam .yui-dialog .ft .default button{color:#fff;}.yui-skin-sam .yui-simple-dialog .bd .yui-icon{background:url(sprite.png) no-repeat 0 0;width:16px;height:16px;margin-right:10px;float:left;}.yui-skin-sam .yui-simple-dialog .bd span.blckicon{background-position:0 -1100px;}.yui-skin-sam .yui-simple-dialog .bd span.alrticon{background-position:0 -1050px;}.yui-skin-sam .yui-simple-dialog .bd span.hlpicon{background-position:0 -1150px;}.yui-skin-sam .yui-simple-dialog .bd span.infoicon{background-position:0 -1200px;}.yui-skin-sam .yui-simple-dialog .bd span.warnicon{background-position:0 -1900px;}.yui-skin-sam .yui-simple-dialog .bd span.tipicon{background-position:0 -1250px;}.yui-skin-sam .yui-tt .bd{position:relative;top:0;left:0;z-index:1;color:#000;padding:2px 5px;border-color:#D4C237 #A6982B #A6982B #A6982B;border-width:1px;border-style:solid;background-color:#FFEE69;}.yui-skin-sam .yui-tt.show-scrollbars .bd{overflow:auto;}.yui-skin-sam .yui-tt-shadow{top:2px;right:-3px;left:-3px;bottom:-3px;background-color:#000;}.yui-skin-sam .yui-tt-shadow-visible{opacity:.12;*filter:alpha(opacity=12);}
diff --git a/lib/yui/assets/skins/sam/datatable.css b/lib/yui/assets/skins/sam/datatable.css
new file mode 100755
index 0000000000..bff0dbf339
--- /dev/null
+++ b/lib/yui/assets/skins/sam/datatable.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-dt-table th,.yui-dt-table td{overflow:hidden;}th .yui-dt-header{position:relative;}th .yui-dt-label{position:relative;}th .yui-dt-resizer{position:absolute;margin-right:-6px;right:0;bottom:0;width:6px;height:100%;cursor:w-resize;cursor:col-resize;}.yui-dt-scrollable{*overflow-y:auto;}.yui-dt-scrollable thead{display:block;}.yui-dt-scrollable thead tr{position:relative;}.yui-dt-scrollbody{display:block;overflow:auto;}.yui-dt-editor{position:absolute;z-index:9000;}.yui-skin-sam .yui-dt-table{margin:0;padding:0;font-family:arial;font-size:inherit;border-collapse:collapse;border:1px solid #7F7F7F;}.yui-skin-sam .yui-dt-table caption{padding-bottom:1em;text-align:left;}.yui-skin-sam .yui-dt-table th{background:url(sprite.png) repeat-x 0 0;}.yui-skin-sam .yui-dt-table th,.yui-skin-sam .yui-dt-table th a{font-weight:normal;text-decoration:none;color:#000;vertical-align:bottom;}.yui-skin-sam .yui-dt-table th,.yui-skin-sam .yui-dt-table td{padding:4px 10px 4px 10px;border-right:1px solid #CBCBCB;}.yui-skin-sam .yui-dt-table td{white-space:nowrap;text-align:left;}.yui-skin-sam .yui-dt-table th.yui-dt-last,.yui-skin-sam .yui-dt-table td.yui-dt-last{border-right:1px solid #7F7F7F;}.yui-skin-sam .yui-dt-list td{border-right:none;}.yui-skin-sam .yui-dt-table thead{border:1px solid #989898;}.yui-skin-sam .yui-dt-table tbody{border-left:1px solid #7F7F7F;border-right:1px solid #7F7F7F;border-bottom:1px solid #7F7F7F;}.yui-skin-sam .yui-dt-loading{background-color:#FFF;}.yui-skin-sam .yui-dt-loading{background-color:#FFF;}.yui-skin-sam .yui-dt-sortable{cursor:pointer;}.yui-skin-sam th.yui-dt-sortable{padding-right:5px;}.yui-skin-sam th.yui-dt-sortable .yui-dt-label{margin-right:15px;}.yui-skin-sam th.yui-dt-asc,.yui-skin-sam th.yui-dt-desc{background:url(sprite.png) repeat-x 0 -100px;}.yui-skin-sam th.yui-dt-asc .yui-dt-header{background:url(dt-arrow-up.png) no-repeat right;}.yui-skin-sam th.yui-dt-desc .yui-dt-header{background:url(dt-arrow-dn.png) no-repeat right;}.yui-dt-editable{cursor:pointer;}.yui-dt-editor{text-align:left;background-color:#F2F2F2;border:1px solid #808080;padding:6px;}.yui-dt-editor label{padding-left:4px;padding-right:6px;}.yui-dt-editor .yui-dt-button{padding-top:6px;text-align:right;}.yui-dt-editor .yui-dt-button button{background:url(sprite.png) repeat-x 0 0;border:1px solid #999;width:4em;height:1.8em;margin-left:6px;}.yui-dt-editor .yui-dt-button button.yui-dt-default{background:url(sprite.png) repeat-x 0 -1400px;background-color:#5584E0;border:1px solid #304369;color:#FFF}.yui-dt-editor .yui-dt-button button:hover{background:url(sprite.png) repeat-x 0 -1300px;color:#000;}.yui-dt-editor .yui-dt-button button:active{background:url(sprite.png) repeat-x 0 -1700px;color:#000;}.yui-skin-sam tr.yui-dt-even{background-color:#FFF;}.yui-skin-sam tr.yui-dt-odd{background-color:#EDF5FF;}.yui-skin-sam tr.yui-dt-even td.yui-dt-asc,.yui-skin-sam tr.yui-dt-even td.yui-dt-desc{background-color:#EDF5FF;}.yui-skin-sam tr.yui-dt-odd td.yui-dt-asc,.yui-skin-sam tr.yui-dt-odd td.yui-dt-desc{background-color:#DBEAFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-even{background-color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-odd{background-color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-desc{background-color:#EDF5FF;}.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-desc{background-color:#EDF5FF;}.yui-skin-sam tr.yui-dt-highlighted,.yui-skin-sam tr.yui-dt-highlighted td.yui-dt-asc,.yui-skin-sam tr.yui-dt-highlighted td.yui-dt-desc,.yui-skin-sam tr.yui-dt-even td.yui-dt-highlighted,.yui-skin-sam tr.yui-dt-odd td.yui-dt-highlighted{cursor:pointer;background-color:#B2D2FF;}.yui-skin-sam .yui-dt-list tr.yui-dt-highlighted,.yui-skin-sam .yui-dt-list tr.yui-dt-highlighted td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-highlighted td.yui-dt-desc,.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-highlighted,.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-highlighted{cursor:pointer;background-color:#B2D2FF;}.yui-skin-sam tr.yui-dt-selected td,.yui-skin-sam tr.yui-dt-selected td.yui-dt-asc,.yui-skin-sam tr.yui-dt-selected td.yui-dt-desc{background-color:#426FD9;color:#FFF;}.yui-skin-sam tr.yui-dt-even td.yui-dt-selected,.yui-skin-sam tr.yui-dt-odd td.yui-dt-selected{background-color:#446CD7;color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-selected td,.yui-skin-sam .yui-dt-list tr.yui-dt-selected td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-selected td.yui-dt-desc{background-color:#426FD9;color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-selected,.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-selected{background-color:#446CD7;color:#FFF;}.yui-skin-sam .yui-dt-paginator{display:block;margin:6px 0;white-space:nowrap;}.yui-skin-sam .yui-dt-paginator .yui-dt-first,.yui-skin-sam .yui-dt-paginator .yui-dt-last,.yui-skin-sam .yui-dt-paginator .yui-dt-selected{padding:2px 6px;}.yui-skin-sam .yui-dt-paginator a.yui-dt-first,.yui-skin-sam .yui-dt-paginator a.yui-dt-last{text-decoration:none;}.yui-skin-sam .yui-dt-paginator .yui-dt-previous,.yui-skin-sam .yui-dt-paginator .yui-dt-next{display:none;}.yui-skin-sam a.yui-dt-page{border:1px solid #CBCBCB;padding:2px 6px;text-decoration:none;}
diff --git a/lib/yui/assets/skins/sam/dt-arrow-dn.png b/lib/yui/assets/skins/sam/dt-arrow-dn.png
new file mode 100755
index 0000000000..2178f11e32
Binary files /dev/null and b/lib/yui/assets/skins/sam/dt-arrow-dn.png differ
diff --git a/lib/yui/assets/skins/sam/dt-arrow-up.png b/lib/yui/assets/skins/sam/dt-arrow-up.png
new file mode 100755
index 0000000000..5a543a573e
Binary files /dev/null and b/lib/yui/assets/skins/sam/dt-arrow-up.png differ
diff --git a/lib/yui/assets/skins/sam/editor-knob.gif b/lib/yui/assets/skins/sam/editor-knob.gif
new file mode 100755
index 0000000000..03feab3b00
Binary files /dev/null and b/lib/yui/assets/skins/sam/editor-knob.gif differ
diff --git a/lib/yui/assets/skins/sam/editor-sprite-active.gif b/lib/yui/assets/skins/sam/editor-sprite-active.gif
new file mode 100755
index 0000000000..04ac4e46ad
Binary files /dev/null and b/lib/yui/assets/skins/sam/editor-sprite-active.gif differ
diff --git a/lib/yui/assets/skins/sam/editor-sprite.gif b/lib/yui/assets/skins/sam/editor-sprite.gif
new file mode 100755
index 0000000000..dd36c3ee7d
Binary files /dev/null and b/lib/yui/assets/skins/sam/editor-sprite.gif differ
diff --git a/lib/yui/assets/skins/sam/editor.css b/lib/yui/assets/skins/sam/editor.css
new file mode 100755
index 0000000000..950a2a69d4
--- /dev/null
+++ b/lib/yui/assets/skins/sam/editor.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-toolbar-container .yui-toolbar-subcont{padding:.25em 0;zoom:1;}.yui-toolbar-container .yui-toolbar-subcont:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-container span.yui-toolbar-draghandle{cursor:move;border-left:1px solid #999;border-right:1px solid #999;overflow:hidden;text-indent:77777px;width:2px;height:20px;display:block;clear:none;float:left;margin:0 0 0 .2em;}.yui-toolbar-container .yui-toolbar-titlebar.draggable{cursor:move;}.yui-toolbar-container .yui-toolbar-titlebar{position:relative;}.yui-toolbar-container .yui-toolbar-titlebar h2{font-weight:bold;border:none;color:#000;margin:0;padding:.2em;}.yui-toolbar-container.yui-toolbar-grouped span.yui-toolbar-draghandle{height:40px;}.yui-toolbar-container .yui-toolbar-group{float:left;zoom:1;}.yui-toolbar-container .yui-toolbar-group:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-container .yui-toolbar-group h3{font-size:75%;color:#999;padding-left:.25em;}.yui-toolbar-container span.yui-toolbar-separator{border-left:1px solid #999;overflow:hidden;text-indent:77777px;width:2px;height:18px;margin:.2em 0 .2em .1em;display:block;clear:none;float:left;}.yui-toolbar-container.yui-toolbar-grouped span.yui-toolbar-separator{height:35px;}.yui-toolbar-container.yui-toolbar-grouped .yui-toolbar-group span.yui-toolbar-separator{height:18px;}.yui-toolbar-container ul li{margin:0;float:left;}.yui-toolbar-container .yui-button{border:1px solid #999999;background:none;padding:0;cursor:pointer;height:20px;width:30px;overflow:hidden;display:block;float:left;margin:0 1px;position:relative;filter:none;}.yui-toolbar-container .yui-button .first-child,.yui-toolbar-container .yui-button .first-child a{margin:0;border:0;display:block;text-indent:50px !important;width:200px;overflow:hidden;}.yui-toolbar-container .yui-button-disabled{opacity:.5;filter:alpha(opacity=50);cursor:default;}.yui-toolbar-container .yui-button a{padding:0;}.yui-toolbar-container .yui-button.ie6.hover{background-color:#98D5FC !important;}.yui-toolbar-container .yui-toolbar-select{height:20px;width:auto;}.yui-toolbar-container .yui-toolbar-select a{border:none;background-color:transparent;height:19px;width:100%;text-align:left;cursor:pointer;opacity:1;filter:none;}.yui-toolbar-container .yui-toolbar-select .first-child{width:100% !important;}.yui-toolbar-container .yui-toolbar-select .first-child a{text-indent:3px !important;width:100% !important;}.yui-toolbar-container .yui-toolbar-select.yui-button-disabled a{cursor:default;opacity:1;filter:none;display:block;}.yui-toolbar-container .yui-toolbar-fontname{width:125px;}.yui-toolbar-container .yui-toolbar-heading{width:80px;}.yui-toolbar-fontname-arial{font-family:Arial;}.yui-toolbar-fontname-arial-black{font-family:Arial Black;}.yui-toolbar-fontname-comic-sans-ms{font-family:Comic Sans MS;}.yui-toolbar-fontname-courier-new{font-family:Courier New;}.yui-toolbar-fontname-times-new-roman{font-family:Times New Roman;}.yui-toolbar-fontname-verdana{font-family:Verdana;}.yui-toolbar-fontname-impact{font-family:Impact;}.yui-toolbar-fontname-lucida-console{font-family:Lucida Console;}.yui-toolbar-fontname-tahoma{font-family:Tahoma;}.yui-toolbar-fontname-trebuchet-ms{font-family:Trebuchet MS;}.yui-toolbar-container .yui-push-button-focus{border:1px dotted #999;}.yui-toolbar-container .yui-toolbar-spinbutton{position:relative;width:35px;}.yui-toolbar-container .yui-toolbar-spinbutton .first-child{width:35px;}.yui-toolbar-container .yui-toolbar-spinbutton .first-child a{border:none;background-color:transparent;background-image:none;background-repeat:no-repeat;width:28px;height:20px;text-align:left;text-indent:2px !important;z-index:0;opacity:1;filter:none;}.yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.up,.yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.down{position:absolute;display:block right:0;cursor:pointer;text-indent:999px;overflow:hidden;z-index:1;border:none;}.yui-toolbar-container .yui-overlay{position:absolute;}.yui-toolbar-container .yui-overlay ul li{float:none;}.yui-toolbar-colors{width:133px;zoom:1;display:none;z-index:100;overflow:hidden;}.yui-toolbar-colors:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-colors a{height:9px;width:9px;float:left;display:block;overflow:hidden;text-indent:999px;margin:0;cursor:pointer;border:1px solid #F6F7EE;}.yui-toolbar-colors a:hover{border:1px solid black;}.yui-color-button-menu{overflow:hidden;background-color:transparent;}.yui-toolbar-colors span{position:relative;display:block;padding:3px;overflow:hidden;float:left;width:100%;zoom:1;}.yui-toolbar-colors span:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-colors span em{height:35px;width:30px;float:left;display:block;overflow:hidden;text-indent:999px;margin:0.75px;border:1px solid black;}.yui-toolbar-colors span strong{font-weight:normal;padding-left:3px;display:block;font-size:85%;float:left;width:65%;}.yui-toolbar-container{z-index:1;}.yui-editor-container .yui-editor-editable-container{position:relative;z-index:0;}.yui-editor-container .yui-editor-masked{background-color:#CCC;}.yui-editor-container iframe{border:0px;padding:0;margin:0;}.yui-editor-container .yui-editor-editable{padding:0;margin:0;}.yui-editor-container .dompath{height:1em;padding:0.25em;font-size:85%;}.yui-editor-panel .hd{text-align:left;position:relative;}.yui-editor-panel .hd h3{font-weight:bold;padding:0.25em 0pt 0.25em 0.25em;}.yui-editor-panel .bd{width:100%;zoom:1;position:relative;}.yui-editor-panel .bd div.yui-editor-body-cont{padding:.25em .1em;zoom:1;}.yui-editor-panel .bd div.yui-editor-body-cont:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-editor-panel .ft{text-align:right;width:99%;float:left;clear:both;}.yui-editor-panel .ft span.tip{display:block;position:relative;padding-left:23px;text-align:left;margin:.5em;zoom:1;}.yui-editor-panel label{clear:both;float:left;padding:0;overflow:auto;width:100%;zoom:1;text-align:left;}.yui-editor-panel label strong{float:left;width:6em;}.yui-editor-panel .removeLink{width:80%;text-align:right;}.yui-editor-panel label input{margin-left:.25em;float:left;}.yui-editor-panel .yui-toolbar-group-padding{width:100px;}.yui-editor-panel .yui-toolbar-group-border{width:175px;*width:190px;}.yui-editor-panel .yui-toolbar-group-textflow{width:150px;*width:180px;}.yui-editor-panel .height-width{float:left;width:68%;}.yui-editor-panel .height-width h3{padding-right:11px;}.yui-editor-panel .height-width span{font-style:italic;display:block;float:left;overflow:auto;}.yui-editor-panel .height-width span.info{font-size:70%;}.yui-editor-panel .yui-toolbar-bordersize,.yui-editor-panel .yui-toolbar-bordertype{width:50px;font-size:75%;}.yui-editor-panel .yui-toolbar-container span.yui-toolbar-separator{border:none;}.yui-editor-panel .yui-toolbar-container div.yuimenu li.yuimenuitem a{float:none;}.yui-editor-panel .yui-toolbar-bordertype span a span.yui-toolbar-bordertype-solid{border-bottom:1px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordertype span a span.yui-toolbar-bordertype-dotted{border-bottom:1px dotted black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordertype span a span.yui-toolbar-bordertype-dashed{border-bottom:1px dashed black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-1{border-bottom:1px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-2{border-bottom:2px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-3{border-bottom:3px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-4{border-bottom:4px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-5{border-bottom:5px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-toolbar-container .yui-toolbar-bordersize-menu{width:30px;}.yui-toolbar-bordersize-menu .yuimenuitemlabel,.yui-toolbar-bordertype-menu .yuimenuitemlabel{display:block;width:50px;color:#ffffff;position:relative;margin-left:20px;padding:0;}.yui-toolbar-bordersize-menu .yuimenuitemlabel .checkedindicator,.yui-toolbar-bordertype-menu .yuimenuitemlabel .checkedindicator{position:absolute;left:-14px;}.yui-toolbar-bordersize-menu .yuimenuitem a.selected,.yui-toolbar-bordertype-menu .yuimenuitem a.selected{color:#B3D4FF;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-0 a{color:#000;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-0 a.selected{color:#fff;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-1 a{border-bottom:1px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-2 a{border-bottom:2px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-3 a{border-bottom:3px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-4 a{border-bottom:4px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-5 a{border-bottom:5px solid black;}div.yuimenu.yui-toolbar-bordertype-menu li.yui-toolbar-bordertype-solid a{border-bottom:1px solid black;}div.yuimenu.yui-toolbar-bordertype-menu li.yui-toolbar-bordertype-dashed a{border-bottom:1px dashed black;}div.yuimenu.yui-toolbar-bordertype-menu li.yui-toolbar-bordertype-dotted a{border-bottom:1px dotted black;}h2.yui-editor-skipheader,h3.yui-editor-skipheader{height:0;margin:0;padding:0;border:none;width:0;overflow:hidden;position:absolute;}.yui-skin-sam .yui-toolbar-container{border:1px solid #808080;zoom:1;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-titlebar{background:url(sprite.png) repeat-x 0 -200px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-titlebar h2{color:#000000;font-weight:bold;margin:0;padding:0.3em 1em;font-size:100%;text-align:left;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-group h3{color:#808080;font-size:75%;margin:1em 0 0.25em;padding-bottom:0;padding-left:0.25em;text-align:left;}.yui-toolbar-container span.yui-toolbar-separator{border:none;}.yui-skin-sam .yui-toolbar-container{background-color:#F2F2F2;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-subcont{padding:0 1em 0.35em;}.yui-skin-sam .yui-editor-container .visible .yui-menu-shadow,.yui-skin-sam .yui-editor-panel .visible .yui-menu-shadow{display:none;}.yui-skin-sam .yui-editor-container ul{list-style-type:none;margin:0;padding:0;}.yui-skin-sam .yui-editor-container ul li{margin:0;padding:0;}.yui-skin-sam .yui-editor-container .yui-editor-editable-container{border:1px solid #808080;border-top:none;}.yui-skin-sam .yui-editor-container .dompath{background-color:#F2F2F2;border:1px solid #808080;border-top:none;color:#999;text-align:left;}.yui-skin-sam .yui-toolbar-container .collapse{background:url(sprite.png) no-repeat 0 -400px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-titlebar span.collapse{cursor:pointer;position:absolute;top:2px;right:2px;display:block;overflow:hidden;height:15px;width:15px;text-indent:9999px;}.yui-toolbar-container .yui-toolbar-select .first-child a{padding-top:0;}.yui-skin-sam .yui-toolbar-container .yui-button{background:url(sprite.png) repeat-x 0 0;border:1px solid #808080;cursor:pointer;height:22px;margin:0;overflow:hidden;position:relative;display:block;}.yui-skin-sam .yui-toolbar-container .yui-button-hover{background:url(sprite.png) repeat-x 0 -1300px;border-color:#808080;}.yui-skin-sam .yui-toolbar-container .yui-button-selected{background:url(sprite.png) no-repeat 0 -1700px;border-color:#808080;}.yui-skin-sam .yui-toolbar-container .yui-button span.yui-toolbar-icon{display:block;position:absolute;top:2px;height:18px;width:18px;overflow:hidden;background-image:url( editor-sprite.gif );background-repeat:no-repeat;background-position:30px 30px;}.yui-skin-sam .yui-toolbar-container .yui-button-selected span.yui-toolbar-icon,.yui-skin-sam .yui-toolbar-container .yui-button-hover span.yui-toolbar-icon{background-image:url(editor-sprite-active.gif);}.yui-skin-sam .visible .yuimenuitemlabel{text-align:left;}.yui-skin-sam .yui-button-menu{background-color:#ffffff;}.yui-skin-sam div.yuimenu li.selected{background-color:#B3D4FF;}.yui-skin-sam div.yuimenu li.selected a.selected{color:#000;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-bold span.yui-toolbar-icon{background-position:0 0;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-italic span.yui-toolbar-icon{background-position:0 -36px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-underline span.yui-toolbar-icon{background-position:0 -72px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-subscript span.yui-toolbar-icon{background-position:0 -180px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-superscript span.yui-toolbar-icon{background-position:0 -144px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-forecolor span.yui-toolbar-icon{background-position:0 -216px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-backcolor span.yui-toolbar-icon{background-position:0 -288px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyleft span.yui-toolbar-icon{background-position:0 -324px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifycenter span.yui-toolbar-icon{background-position:0 -360px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyright span.yui-toolbar-icon{background-position:0 -396px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyfull span.yui-toolbar-icon{background-position:0 -432px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-indent span.yui-toolbar-icon{background-position:0 -720px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-outdent span.yui-toolbar-icon{background-position:0 -684px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-createlink span.yui-toolbar-icon{background-position:0 -792px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertimage span.yui-toolbar-icon{background-position:1px -756px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-left span.yui-toolbar-icon{background-position:0 -972px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-right span.yui-toolbar-icon{background-position:0 -936px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-inline span.yui-toolbar-icon{background-position:0 -900px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-block span.yui-toolbar-icon{background-position:0 -864px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-bordercolor span.yui-toolbar-icon{background-position:0 -252px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-removeformat span.yui-toolbar-icon{background-position:0 -1080px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-hiddenelements span.yui-toolbar-icon{background-position:0 -1044px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertunorderedlist span.yui-toolbar-icon{background-position:0 -468px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertorderedlist span.yui-toolbar-icon{background-position:0 -504px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-fontname,.yui-skin-sam .yui-toolbar-container .yui-toolbar-bold,.yui-skin-sam .yui-toolbar-container .yui-toolbar-italic,.yui-skin-sam .yui-toolbar-container .yui-toolbar-subscript,.yui-skin-sam .yui-toolbar-container .yui-toolbar-forecolor,.yui-skin-sam .yui-toolbar-container .yui-toolbar-removeformat,.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyleft,.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifycenter,.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyright,.yui-skin-sam .yui-toolbar-container .yui-toolbar-indent,.yui-skin-sam .yui-toolbar-container .yui-toolbar-outdent,.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertunorderedlist,.yui-skin-sam .yui-toolbar-container .yui-toolbar-createlink,.yui-skin-sam .yui-toolbar-container .yui-toolbar-left,.yui-skin-sam .yui-toolbar-container .yui-toolbar-inline,.yui-skin-sam .yui-toolbar-container .yui-toolbar-block,.yui-skin-sam .yui-toolbar-container .yui-toolbar-bordersize,.yui-skin-sam .yui-toolbar-container .yui-toolbar-bordertype{border-right:none;}.yui-skin-sam .yui-toolbar-container .yui-button .first-child,.yui-skin-sam .yui-toolbar-container .yui-button .first-child a{width:500px;position:absolute;_position:static;top:-1px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-select .first-child,.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton .first-child{position:static;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-select .first-child a,.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton .first-child a{height:19px;left:0;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton span.yui-toolbar-icon{display:none;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.up{top:0;right:0;background-image:url( editor-sprite.gif );background-position:0 -1221px;overflow:hidden;height:8px;width:8px;min-height:0;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.down{bottom:0;right:0;background-image:url( editor-sprite.gif );background-position:0 -1187px;overflow:hidden;height:8px;width:8px;min-height:0;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-select span.yui-toolbar-icon{background-image:url( editor-sprite.gif );background-position:0px -1144px;overflow:hidden;right:-2px;top:0px;height:20px;}.yui-skin-sam .yui-editor-panel .yui-color-button-menu .bd{background-color:transparent;border:none;width:135px;}.yui-skin-sam .yui-color-button-menu .yui-toolbar-colors{border:1px solid #808080;}.yui-editor-panel label input.warning{background-color:#FFEE69;}.yui-skin-sam .yui-editor-panel .yui-panel{padding:0;margin:0;border:none;background-color:transparent;overflow:visible;}.yui-skin-sam .yui-editor-panel .yui-toolbar-group-border{width:190px;*width:195px;}.yui-skin-sam .yui-editor-panel .yui-toolbar-group-textflow{width:185px;}.yui-skin-sam .yui-editor-panel .hd{margin:13px 0 0;padding:0;border:none;}.yui-skin-sam .yui-editor-panel .hd h3{color:#000;border:1px solid #808080;background:url(sprite.png) repeat-x 0 -200px;width:99%;position:relative;margin:0;padding:0;font-size:93%;text-indent:5px;height:20px;}.yui-skin-sam .yui-editor-panel .bd{background-color:#F2F2F2;border-left:1px solid #808080;border-right:1px solid #808080;width:99%;margin:0;*margin-left:-1px;padding:0;overflow:visible;}.yui-skin-sam .yui-editor-panel ul{list-style-type:none;margin:0;padding:0;}.yui-skin-sam .yui-editor-panel ul li{margin:0;padding:0;}.yui-skin-sam .yui-editor-panel label strong{font-weight:normal;font-size:93%;}.yui-skin-sam .yui-editor-panel .hd{background:none;}.yui-skin-sam .yui-editor-panel .ft{background-color:#F2F2F2;border:1px solid #808080;border-top:none;padding:0;margin:0;z-index:-1;}.yui-skin-sam .yui-editor-panel .hd span.close{background:url(sprite.png) no-repeat 0 -300px;cursor:pointer;display:block;height:16px;overflow:hidden;position:absolute;right:5px;text-indent:500px;top:2px;width:26px;}.yui-skin-sam .yui-editor-panel .ft span.tip span.icon{background-image:url( editor-sprite.gif );background-position:0 -1260px;display:block;height:20px;left:0;position:absolute;top:0;width:20px;}.yui-skin-sam .yui-editor-panel .ft span.tip span.icon-info{background-position:2px -1260px;}.yui-skin-sam .yui-editor-panel .ft span.tip span.icon-warn{background-position:2px -1296px;}.yui-skin-sam .yui-editor-panel .hd span.knob{position:absolute;height:10px;width:28px;top:-10px;left:25px;text-indent:9999px;overflow:hidden;background-image:url( editor-knob.gif );background-repeat:no-repeat;}.yui-skin-sam .yui-editor-panel .yui-toolbar-container{float:left;width:100%;background-image:none;border:none;}.yui-skin-sam .yui-editor-panel .yui-toolbar-container .bd{background-color:#ffffff;border-bottom:1px solid #808080;}.yui-skin-sam .yui-editor-panel .yui-toolbar-group h3{color:#000;float:left;padding-top:5px;}.yui-editor-blankimage{background-image:url( blankimage.png );}
diff --git a/lib/yui/assets/skins/sam/hue_bg.png b/lib/yui/assets/skins/sam/hue_bg.png
new file mode 100755
index 0000000000..d9bcdeb5c4
Binary files /dev/null and b/lib/yui/assets/skins/sam/hue_bg.png differ
diff --git a/lib/yui/assets/skins/sam/logger.css b/lib/yui/assets/skins/sam/logger.css
new file mode 100755
index 0000000000..5b8077f184
--- /dev/null
+++ b/lib/yui/assets/skins/sam/logger.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-skin-sam .yui-log{padding:1em;width:31em;background-color:#AAA;color:#000;border:1px solid black;font-family:monospace;font-size:77%;text-align:left;z-index:9000;}.yui-skin-sam .yui-log-container{position:absolute;top:1em;right:1em;}.yui-skin-sam .yui-log input{margin:0;padding:0;font-family:arial;font-size:100%;font-weight:normal;}.yui-skin-sam .yui-log .yui-log-btns{position:relative;float:right;bottom:.25em;}.yui-skin-sam .yui-log .yui-log-hd{margin-top:1em;padding:.5em;background-color:#575757;}.yui-skin-sam .yui-log .yui-log-hd h4{margin:0;padding:0;font-size:108%;font-weight:bold;color:#FFF;}.yui-skin-sam .yui-log .yui-log-bd{width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}.yui-skin-sam .yui-log p{margin:1px;padding:.1em;}.yui-skin-sam .yui-log pre{margin:0;padding:0;}.yui-skin-sam .yui-log pre.yui-log-verbose{white-space:pre-wrap;white-space:-moz-pre-wrap !important;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;}.yui-skin-sam .yui-log .yui-log-ft{margin-top:.5em;}.yui-skin-sam .yui-log .yui-log-ft .yui-log-categoryfilters{}.yui-skin-sam .yui-log .yui-log-ft .yui-log-sourcefilters{width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}.yui-skin-sam .yui-log .yui-log-filtergrp{margin-right:.5em;}.yui-skin-sam .yui-log .info{background-color:#A7CC25;}.yui-skin-sam .yui-log .warn{background-color:#F58516;}.yui-skin-sam .yui-log .error{background-color:#E32F0B;}.yui-skin-sam .yui-log .time{background-color:#A6C9D7;}.yui-skin-sam .yui-log .window{background-color:#F2E886;}
diff --git a/lib/yui/assets/skins/sam/menu-button-arrow-disabled.png b/lib/yui/assets/skins/sam/menu-button-arrow-disabled.png
new file mode 100755
index 0000000000..8cef2abb31
Binary files /dev/null and b/lib/yui/assets/skins/sam/menu-button-arrow-disabled.png differ
diff --git a/lib/yui/assets/skins/sam/menu-button-arrow.png b/lib/yui/assets/skins/sam/menu-button-arrow.png
new file mode 100755
index 0000000000..f03dfee4e4
Binary files /dev/null and b/lib/yui/assets/skins/sam/menu-button-arrow.png differ
diff --git a/lib/yui/assets/skins/sam/menu.css b/lib/yui/assets/skins/sam/menu.css
new file mode 100755
index 0000000000..046a9c6a4f
--- /dev/null
+++ b/lib/yui/assets/skins/sam/menu.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yuimenu .yuimenu,.yuimenubar .yuimenu{position:absolute;visibility:hidden;}.yuimenubar ul,.yuimenu ul{list-style-type:none;}.yuimenubar ul,.yuimenu ul,.yuimenubar li,.yuimenu li,.yuimenu h6,.yuimenubar h6{margin:0;padding:0;}.yuimenuitemlabel,.yuimenubaritemlabel{white-space:nowrap;}.yui-menu-shadow{position:absolute;}.hide-scrollbars *{overflow:hidden;}.hide-scrollbars select{display:none;}.yuimenu.show-scrollbars{overflow:visible;}.yuimenu.hide-scrollbars .yui-menu-shadow{overflow:hidden;}.yuimenu.show-scrollbars .yui-menu-shadow{overflow:auto;}.yui-skin-sam .yuimenubar{border:solid 1px #808080;background:url(sprite.png) repeat-x 0 0;}.yui-skin-sam .yuimenubar .bd,.yui-skin-sam .yuimenubar ul{*zoom:1;}.yui-skin-sam .yuimenubar>.bd>ul:after{content:".";display:block;clear:both;visibility:hidden;height:0;line-height:0;}.yui-skin-sam .yuimenubaritem{float:left;}.yui-skin-sam .yuimenubarnav .yuimenubaritem{border-right:solid 1px #ccc;}.yui-skin-sam .yuimenubaritemlabel{display:block;*display:inline-block;font-size:93%;line-height:2;*line-height:1.9;padding:0 10px;color:#000;text-decoration:none;outline:none;cursor:default;border-style:solid;border-color:#808080;border-width:1px 0;position:relative;margin:-1px 0;}.yui-skin-sam .yuimenubarnav .yuimenubaritemlabel{padding-right:20px;}.yui-skin-sam .yuimenubaritemlabel .submenuindicator{width:1px;height:1px;top:0;left:0;}.yui-skin-sam .yuimenubarnav .yuimenubaritemlabel .submenuindicator{top:50%;right:8px;left:auto;margin-top:-3px;height:4px;width:7px;text-indent:8px;background-position:-16px -856px;}.yui-skin-sam .yuimenubaritem a.selected{background:url(sprite.png) repeat-x 0 -1700px;border-color:#7D98B8;}.yui-skin-sam .yuimenubarnav .yuimenubaritem a.selected{border-left-width:1px;margin-left:-1px;*left:-1px;}.yui-skin-sam .yuimenubar a.selected .submenuindicator{background:transparent;}.yui-skin-sam .yuimenubarnav a.selected .submenuindicator{background:url(sprite.png) repeat-x -16px -856px;}.yui-skin-sam .yuimenubaritem a.disabled{cursor:default;color:#A6A6A6;}.yui-skin-sam .yuimenubarnav .yuimenubaritem a.disabled .submenuindicator{background-position:-16px -881px;}.yui-skin-sam .yuimenu .bd{position:relative;top:0;left:0;border:solid 1px #808080;background-color:#fff;z-index:1;}.yui-skin-sam .yuimenu ul{padding:3px 0;border-width:1px 0 0 0;border-color:#ccc;border-style:solid;}.yui-skin-sam .yuimenu ul.first-of-type{border-width:0;}.yui-skin-sam .yuimenu h6{font-size:93%;font-weight:bold;line-height:1.5;*line-height:1.45;border-style:solid;border-color:#ccc;border-width:1px 0 0 0;color:#a4a4a4;padding:3px 10px 0 10px;}.yui-skin-sam .yuimenu ul.hastitle,.yui-skin-sam .yuimenu h6.first-of-type{border-width:0;}.yui-skin-sam .yuimenu .topscrollbar,.yui-skin-sam .yuimenu .bottomscrollbar{position:relative;height:16px;border:solid 1px #808080;background:#fff url(sprite.png) no-repeat 0 0;}.yui-skin-sam .yuimenu .topscrollbar{z-index:2;border-bottom-color:#ccc;margin-bottom:-1px;background-position:center -950px;}.yui-skin-sam .yuimenu .topscrollbar_disabled{background-position:center -975px;}.yui-skin-sam .yuimenu .bottomscrollbar{z-index:3;border-top-color:#ccc;margin-top:-1px;background-position:center -850px;}.yui-skin-sam .yuimenu .bottomscrollbar_disabled{background-position:center -875px;}.yui-skin-sam .yuimenuitemlabel{font-size:93%;line-height:1.5;*line-height:1.45;padding:0 20px;display:block;color:#000;text-decoration:none;outline:none;position:relative;cursor:default;}.yui-skin-sam .yuimenuitemlabel .helptext{font-style:normal;margin:0 0 0 40px;}.yui-skin-sam .yuimenuitemlabel .submenuindicator,.yui-skin-sam .yuimenuitemlabel .checkedindicator,.yui-skin-sam .yuimenubaritemlabel .submenuindicator{position:absolute;overflow:hidden;background:url(sprite.png) no-repeat;}.yui-skin-sam .yuimenuitemlabel .submenuindicator{top:50%;right:8px;margin-top:-3px;height:7px;width:4px;text-indent:5px;background-position:0 -906px;}.yui-skin-sam .yuimenuitemlabel .checkedindicator{top:50%;left:8px;margin-top:-3px;height:7px;width:7px;text-indent:8px;background-position:0 -1006px;}.yui-skin-sam .yui-menu-shadow-visible{top:2px;right:-3px;left:-3px;bottom:-3px;background-color:#000;opacity:.12;*filter:alpha(opacity=12);visibility:visible;}.yui-skin-sam .visible .bd,.yui-skin-sam .visible .yuimenuitem{_zoom:1;}.yui-skin-sam .visible .yuimenuitemlabel{*zoom:1;}.yui-skin-sam .visible .yuimenuitemlabel .helptext{float:right;width:100%;text-align:right;margin:-1.5em 0 0 0;*margin:-1.45em 0 0 0;}.yui-skin-sam .yuimenuitem a.selected{background:#B3D4FF;}.yui-skin-sam .yuimenubar .yuimenuitem a.selected .submenuindicator{background:url(sprite.png) no-repeat 0 -906px;}.yui-skin-sam .yuimenubarnav .yuimenuitem a.selected{border-width:0;margin:0;*left:0;}.yui-skin-sam .yuimenuitem a.disabled{cursor:default;color:#A6A6A6;}.yui-skin-sam .yuimenuitem a.disabled .submenuindicator{background-position:0 -931px;}.yui-skin-sam .yuimenuitem a.disabled .checkedindicator{background-position:0 -1031px;}
diff --git a/lib/yui/assets/skins/sam/picker_mask.png b/lib/yui/assets/skins/sam/picker_mask.png
new file mode 100755
index 0000000000..f8d91932b3
Binary files /dev/null and b/lib/yui/assets/skins/sam/picker_mask.png differ
diff --git a/lib/yui/assets/skins/sam/skin.css b/lib/yui/assets/skins/sam/skin.css
new file mode 100755
index 0000000000..66c2fc5612
--- /dev/null
+++ b/lib/yui/assets/skins/sam/skin.css
@@ -0,0 +1,18 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-skin-sam .yui-ac{position:relative;font-family:arial;font-size:100%;}.yui-skin-sam .yui-ac-input{position:absolute;width:100%;}.yui-skin-sam .yui-ac-container{position:absolute;top:1.6em;width:100%;}.yui-skin-sam .yui-ac-content{position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050;}.yui-skin-sam .yui-ac-shadow{position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity:0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049;}.yui-skin-sam .yui-ac-content ul{margin:0;padding:0;width:100%;}.yui-skin-sam .yui-ac-content li{margin:0;padding:2px 5px;cursor:default;white-space:nowrap;}.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight{background:#B3D4FF;}.yui-skin-sam .yui-ac-content li.yui-ac-highlight{background:#426FD9;color:#FFF;}
+.yui-skin-sam .yui-button{display:-moz-inline-box;display:inline-block;border-width:1px 0;border-style:solid;border-color:#808080;background:url(sprite.png) repeat-x 0 0;margin:auto .25em;}.yui-skin-sam .yui-button .first-child{display:block;*display:inline-block;border-width:0 1px;border-style:solid;border-color:#808080;margin:0 -1px;*position:relative;*left:-1px;}.yui-skin-sam .yui-button button,.yui-skin-sam .yui-button a{display:block;*display:inline-block;padding:0 10px;border:none;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-button button{*overflow:visible;background-color:transparent;cursor:pointer;cursor:hand;}.yui-skin-sam .yui-button a{text-decoration:none;}.yui-skin-sam .yui-split-button button,.yui-skin-sam .yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}.yui-skin-sam .yui-menu-button button{background-image:url(menu-button-arrow.png);}.yui-skin-sam .yui-split-button button{background-image:url(split-button-arrow.png);}.yui-skin-sam .yui-button-focus{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-focus .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-focus button,.yui-skin-sam .yui-button-focus a{color:#000;}.yui-skin-sam .yui-split-button-focus button{background-image:url(split-button-arrow-focus.png);}.yui-skin-sam .yui-button-hover{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-hover .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-hover button,.yui-skin-sam .yui-button-hover a{color:#000;}.yui-skin-sam .yui-split-button-hover button{background-image:url(split-button-arrow-hover.png);}.yui-skin-sam .yui-button-active{border-color:#7D98B8;background-position:0 -1700px;}.yui-skin-sam .yui-button-active .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-active button,.yui-skin-sam .yui-button-active a{color:#000;}.yui-skin-sam .yui-split-button-activeoption{border-color:#808080;background-position:0 0;}.yui-skin-sam .yui-split-button-activeoption .first-child{border-color:#808080;}.yui-skin-sam .yui-split-button-activeoption button{background-image:url(split-button-arrow-active.png);}.yui-skin-sam .yui-radio-button-checked,.yui-skin-sam .yui-checkbox-button-checked{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-radio-button-checked .first-child,.yui-skin-sam .yui-checkbox-button-checked .first-child{border-color:#304369;}.yui-skin-sam .yui-radio-button-checked button,.yui-skin-sam .yui-checkbox-button-checked button{color:#fff;}.yui-skin-sam .yui-button-disabled{border-color:#ccc;background-position:0 -1500px;}.yui-skin-sam .yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-button-disabled button,.yui-skin-sam .yui-button-disabled a{color:#A6A6A6;cursor:default;}.yui-skin-sam .yui-menu-button-disabled button{background-image:url(menu-button-arrow-disabled.png);}.yui-skin-sam .yui-split-button-disabled button{background-image:url(split-button-arrow-disabled.png);}
+.yui-calcontainer{position:relative;float:left;_overflow:hidden;}.yui-calcontainer iframe{position:absolute;border:none;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0px;top:0px;}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px;}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative;}.yui-calcontainer .title{position:relative;z-index:1;}.yui-calcontainer .close-icon{position:absolute;z-index:1;}.yui-calendar{position:relative;}.yui-calendar .calnavleft{position:absolute;z-index:1;}.yui-calendar .calnavright{position:absolute;z-index:1;}.yui-calendar .calheader{position:relative;width:100%;text-align:center;}.yui-calendar .calbody a:hover{background:inherit;}p#clear{clear:left;padding-top:10px;}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px;}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px;}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:none;padding:10px 5px 10px 5px;margin:0;}.yui-skin-sam .yui-calcontainer .title{background:url(sprite.png) repeat-x 0 0;border-bottom:1px solid #cccccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left;}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px;}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0;}.yui-skin-sam .yui-calcontainer .calclose{background:url(sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:none;vertical-align:middle;}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center;}.yui-skin-sam .yui-calendar .calheader img{border:none;}.yui-skin-sam .yui-calendar .calnavleft{background:url(sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calnavright{background:url(sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em;}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em;}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2;}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding-right:2px;}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding-left:2px;}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #cccccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap;}.yui-skin-sam .yui-calendar td.calcell a{color:#0066cc;display:block;height:100%;text-decoration:none;}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000;}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff;}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#cccccc;color:#a6a6a6;cursor:default;}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer;}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff;}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0;}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through;}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#ccff99;}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#99ccff;}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#ffcccc;}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#ccff99;}
+.yui-picker-panel{background:#e3e3e3;border-color:#888;}.yui-picker-panel .hd{background-color:#ccc;font-size:100%;line-height:100%;border:1px solid #e3e3e3;font-weight:bold;overflow:hidden;padding:6px;color:#000;}.yui-picker-panel .bd{background:#e8e8e8;margin:1px;height:200px;}.yui-picker-panel .ft{background:#e8e8e8;margin:1px;padding:1px;}.yui-picker{position:relative;}.yui-picker-hue-thumb{cursor:default;width:18px;height:18px;top:-8px;left:-2px;z-index:9;position:absolute;}.yui-picker-hue-bg{-moz-outline:none;outline:0px none;position:absolute;left:200px;height:183px;width:14px;background:url(hue_bg.png) no-repeat;top:4px;}.yui-picker-bg{-moz-outline:none;outline:0px none;position:absolute;top:4px;left:4px;height:182px;width:182px;background-color:#F00;background-image:url(picker_mask.png);}*html .yui-picker-bg{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../build/colorpicker/assets/picker_mask.png',sizingMethod='scale');}.yui-picker-mask{position:absolute;z-index:1;top:0px;left:0px;}.yui-picker-thumb{cursor:default;width:11px;height:11px;z-index:9;position:absolute;top:-4px;left:-4px;}.yui-picker-swatch{position:absolute;left:240px;top:4px;height:60px;width:55px;border:1px solid #888;}.yui-picker-websafe-swatch{position:absolute;left:304px;top:4px;height:24px;width:24px;border:1px solid #888;}.yui-picker-controls{position:absolute;top:72px;left:226px;font:1em monospace;}.yui-picker-controls .hd{background:transparent;border-width:0px !important;}.yui-picker-controls .bd{height:100px;border-width:0px !important;}.yui-picker-controls ul{float:left;list-style:none;padding:0 2px 0 0;margin:0}.yui-picker-controls li{padding:2px;margin:0}.yui-picker-controls input{font-size:0.85em;width:2.4em;}.yui-picker-hex-controls{clear:both;padding:2px;}.yui-picker-hex-controls input{width:4.6em;}.yui-picker-controls a{font:1em arial,helvetica,clean,sans-serif;display:block;*display:inline-block;padding:0;color:#000;}
+.yui-overlay,.yui-panel-container{visibility:hidden;position:absolute;z-index:1;}yui-panel-container form{margin:0;}.masked .yui-panel-container{z-index:2;}.mask{z-index:1;display:none;position:absolute;top:0;left:0;right:0;bottom:0;overflow:auto;}.masked select,.drag select,.hide-select select{_visibility:hidden;}.yui-panel-container select{_visibility:inherit;}.hide-scrollbars,.hide-scrollbars *{overflow:hidden;}.hide-scrollbars select{display:none;}.show-scrollbars{overflow:auto;}.yui-panel-container.show-scrollbars,.yui-tt.show-scrollbars{overflow:visible;}.yui-panel-container.show-scrollbars .underlay,.yui-tt.show-scrollbars .yui-tt-shadow{overflow:auto;}.yui-tt-shadow{position:absolute;}.yui-skin-sam .mask{background-color:#000;opacity:.25;*filter:alpha(opacity=25);}.yui-skin-sam .yui-panel-container{padding:0 1px;*padding:2px 3px;}.yui-skin-sam .yui-panel{position:relative;*zoom:1;left:0;top:0;border-style:solid;border-width:1px 0;border-color:#808080;z-index:1;}.yui-skin-sam .yui-panel .hd,.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{*zoom:1;*position:relative;border-style:solid;border-width:0 1px;border-color:#808080;margin:0 -1px;}.yui-skin-sam .yui-panel .hd{border-bottom:solid 1px #ccc;}.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{background-color:#F2F2F2;}.yui-skin-sam .yui-panel .hd{padding:0 10px;font-size:93%;line-height:2;*line-height:1.9;font-weight:bold;color:#000;background:url(sprite.png) repeat-x 0 -200px;}.yui-skin-sam .yui-panel .bd{padding:10px;}.yui-skin-sam .yui-panel .ft{border-top:solid 1px #808080;padding:5px 10px;font-size:77%;}.yui-skin-sam .yui-panel-container.focused .yui-panel .hd{}.yui-skin-sam .container-close{position:absolute;top:5px;right:6px;width:25px;height:15px;background:url(sprite.png) no-repeat 0 -300px;}.yui-skin-sam .yui-panel-container .underlay{right:-1px;left:-1px;}.yui-skin-sam .yui-panel-container.matte{padding:9px 10px;background-color:#fff;}.yui-skin-sam .yui-panel-container.shadow{_padding:2px 5px 0 3px;}.yui-skin-sam .yui-panel-container.shadow .underlay{position:absolute;top:2px;right:-3px;bottom:-3px;left:-3px;*top:3px;*left:-1px;*right:-1px;*bottom:-1px;_top:0;_right:0;_bottom:0;_left:0;_margin-top:3px;_margin-left:-1px;background-color:#000;opacity:.12;*filter:alpha(opacity=12);}.yui-skin-sam .yui-dialog .ft{border-top:none;padding:0 10px 10px 10px;font-size:100%;}.yui-skin-sam .yui-dialog .ft .button-group{display:block;text-align:right;}.yui-skin-sam .yui-dialog .ft .default{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-dialog .ft .default .first-child{border-color:#304369;}.yui-skin-sam .yui-dialog .ft .default button{color:#fff;}.yui-skin-sam .yui-simple-dialog .bd .yui-icon{background:url(sprite.png) no-repeat 0 0;width:16px;height:16px;margin-right:10px;float:left;}.yui-skin-sam .yui-simple-dialog .bd span.blckicon{background-position:0 -1100px;}.yui-skin-sam .yui-simple-dialog .bd span.alrticon{background-position:0 -1050px;}.yui-skin-sam .yui-simple-dialog .bd span.hlpicon{background-position:0 -1150px;}.yui-skin-sam .yui-simple-dialog .bd span.infoicon{background-position:0 -1200px;}.yui-skin-sam .yui-simple-dialog .bd span.warnicon{background-position:0 -1900px;}.yui-skin-sam .yui-simple-dialog .bd span.tipicon{background-position:0 -1250px;}.yui-skin-sam .yui-tt .bd{position:relative;top:0;left:0;z-index:1;color:#000;padding:2px 5px;border-color:#D4C237 #A6982B #A6982B #A6982B;border-width:1px;border-style:solid;background-color:#FFEE69;}.yui-skin-sam .yui-tt.show-scrollbars .bd{overflow:auto;}.yui-skin-sam .yui-tt-shadow{top:2px;right:-3px;left:-3px;bottom:-3px;background-color:#000;}.yui-skin-sam .yui-tt-shadow-visible{opacity:.12;*filter:alpha(opacity=12);}
+.yui-dt-table th,.yui-dt-table td{overflow:hidden;}th .yui-dt-header{position:relative;}th .yui-dt-label{position:relative;}th .yui-dt-resizer{position:absolute;margin-right:-6px;right:0;bottom:0;width:6px;height:100%;cursor:w-resize;cursor:col-resize;}.yui-dt-scrollable{*overflow-y:auto;}.yui-dt-scrollable thead{display:block;}.yui-dt-scrollable thead tr{position:relative;}.yui-dt-scrollbody{display:block;overflow:auto;}.yui-dt-editor{position:absolute;z-index:9000;}.yui-skin-sam .yui-dt-table{margin:0;padding:0;font-family:arial;font-size:inherit;border-collapse:collapse;border:1px solid #7F7F7F;}.yui-skin-sam .yui-dt-table caption{padding-bottom:1em;text-align:left;}.yui-skin-sam .yui-dt-table th{background:url(sprite.png) repeat-x 0 0;}.yui-skin-sam .yui-dt-table th,.yui-skin-sam .yui-dt-table th a{font-weight:normal;text-decoration:none;color:#000;vertical-align:bottom;}.yui-skin-sam .yui-dt-table th,.yui-skin-sam .yui-dt-table td{padding:4px 10px 4px 10px;border-right:1px solid #CBCBCB;}.yui-skin-sam .yui-dt-table td{white-space:nowrap;text-align:left;}.yui-skin-sam .yui-dt-table th.yui-dt-last,.yui-skin-sam .yui-dt-table td.yui-dt-last{border-right:1px solid #7F7F7F;}.yui-skin-sam .yui-dt-list td{border-right:none;}.yui-skin-sam .yui-dt-table thead{border:1px solid #989898;}.yui-skin-sam .yui-dt-table tbody{border-left:1px solid #7F7F7F;border-right:1px solid #7F7F7F;border-bottom:1px solid #7F7F7F;}.yui-skin-sam .yui-dt-loading{background-color:#FFF;}.yui-skin-sam .yui-dt-loading{background-color:#FFF;}.yui-skin-sam .yui-dt-sortable{cursor:pointer;}.yui-skin-sam th.yui-dt-sortable{padding-right:5px;}.yui-skin-sam th.yui-dt-sortable .yui-dt-label{margin-right:15px;}.yui-skin-sam th.yui-dt-asc,.yui-skin-sam th.yui-dt-desc{background:url(sprite.png) repeat-x 0 -100px;}.yui-skin-sam th.yui-dt-asc .yui-dt-header{background:url(dt-arrow-up.png) no-repeat right;}.yui-skin-sam th.yui-dt-desc .yui-dt-header{background:url(dt-arrow-dn.png) no-repeat right;}.yui-dt-editable{cursor:pointer;}.yui-dt-editor{text-align:left;background-color:#F2F2F2;border:1px solid #808080;padding:6px;}.yui-dt-editor label{padding-left:4px;padding-right:6px;}.yui-dt-editor .yui-dt-button{padding-top:6px;text-align:right;}.yui-dt-editor .yui-dt-button button{background:url(sprite.png) repeat-x 0 0;border:1px solid #999;width:4em;height:1.8em;margin-left:6px;}.yui-dt-editor .yui-dt-button button.yui-dt-default{background:url(sprite.png) repeat-x 0 -1400px;background-color:#5584E0;border:1px solid #304369;color:#FFF}.yui-dt-editor .yui-dt-button button:hover{background:url(sprite.png) repeat-x 0 -1300px;color:#000;}.yui-dt-editor .yui-dt-button button:active{background:url(sprite.png) repeat-x 0 -1700px;color:#000;}.yui-skin-sam tr.yui-dt-even{background-color:#FFF;}.yui-skin-sam tr.yui-dt-odd{background-color:#EDF5FF;}.yui-skin-sam tr.yui-dt-even td.yui-dt-asc,.yui-skin-sam tr.yui-dt-even td.yui-dt-desc{background-color:#EDF5FF;}.yui-skin-sam tr.yui-dt-odd td.yui-dt-asc,.yui-skin-sam tr.yui-dt-odd td.yui-dt-desc{background-color:#DBEAFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-even{background-color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-odd{background-color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-desc{background-color:#EDF5FF;}.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-desc{background-color:#EDF5FF;}.yui-skin-sam tr.yui-dt-highlighted,.yui-skin-sam tr.yui-dt-highlighted td.yui-dt-asc,.yui-skin-sam tr.yui-dt-highlighted td.yui-dt-desc,.yui-skin-sam tr.yui-dt-even td.yui-dt-highlighted,.yui-skin-sam tr.yui-dt-odd td.yui-dt-highlighted{cursor:pointer;background-color:#B2D2FF;}.yui-skin-sam .yui-dt-list tr.yui-dt-highlighted,.yui-skin-sam .yui-dt-list tr.yui-dt-highlighted td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-highlighted td.yui-dt-desc,.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-highlighted,.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-highlighted{cursor:pointer;background-color:#B2D2FF;}.yui-skin-sam tr.yui-dt-selected td,.yui-skin-sam tr.yui-dt-selected td.yui-dt-asc,.yui-skin-sam tr.yui-dt-selected td.yui-dt-desc{background-color:#426FD9;color:#FFF;}.yui-skin-sam tr.yui-dt-even td.yui-dt-selected,.yui-skin-sam tr.yui-dt-odd td.yui-dt-selected{background-color:#446CD7;color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-selected td,.yui-skin-sam .yui-dt-list tr.yui-dt-selected td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-selected td.yui-dt-desc{background-color:#426FD9;color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-selected,.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-selected{background-color:#446CD7;color:#FFF;}.yui-skin-sam .yui-dt-paginator{display:block;margin:6px 0;white-space:nowrap;}.yui-skin-sam .yui-dt-paginator .yui-dt-first,.yui-skin-sam .yui-dt-paginator .yui-dt-last,.yui-skin-sam .yui-dt-paginator .yui-dt-selected{padding:2px 6px;}.yui-skin-sam .yui-dt-paginator a.yui-dt-first,.yui-skin-sam .yui-dt-paginator a.yui-dt-last{text-decoration:none;}.yui-skin-sam .yui-dt-paginator .yui-dt-previous,.yui-skin-sam .yui-dt-paginator .yui-dt-next{display:none;}.yui-skin-sam a.yui-dt-page{border:1px solid #CBCBCB;padding:2px 6px;text-decoration:none;}
+.yui-toolbar-container .yui-toolbar-subcont{padding:.25em 0;zoom:1;}.yui-toolbar-container .yui-toolbar-subcont:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-container span.yui-toolbar-draghandle{cursor:move;border-left:1px solid #999;border-right:1px solid #999;overflow:hidden;text-indent:77777px;width:2px;height:20px;display:block;clear:none;float:left;margin:0 0 0 .2em;}.yui-toolbar-container .yui-toolbar-titlebar.draggable{cursor:move;}.yui-toolbar-container .yui-toolbar-titlebar{position:relative;}.yui-toolbar-container .yui-toolbar-titlebar h2{font-weight:bold;border:none;color:#000;margin:0;padding:.2em;}.yui-toolbar-container.yui-toolbar-grouped span.yui-toolbar-draghandle{height:40px;}.yui-toolbar-container .yui-toolbar-group{float:left;zoom:1;}.yui-toolbar-container .yui-toolbar-group:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-container .yui-toolbar-group h3{font-size:75%;color:#999;padding-left:.25em;}.yui-toolbar-container span.yui-toolbar-separator{border-left:1px solid #999;overflow:hidden;text-indent:77777px;width:2px;height:18px;margin:.2em 0 .2em .1em;display:block;clear:none;float:left;}.yui-toolbar-container.yui-toolbar-grouped span.yui-toolbar-separator{height:35px;}.yui-toolbar-container.yui-toolbar-grouped .yui-toolbar-group span.yui-toolbar-separator{height:18px;}.yui-toolbar-container ul li{margin:0;float:left;}.yui-toolbar-container .yui-button{border:1px solid #999999;background:none;padding:0;cursor:pointer;height:20px;width:30px;overflow:hidden;display:block;float:left;margin:0 1px;position:relative;filter:none;}.yui-toolbar-container .yui-button .first-child,.yui-toolbar-container .yui-button .first-child a{margin:0;border:0;display:block;text-indent:50px !important;width:200px;overflow:hidden;}.yui-toolbar-container .yui-button-disabled{opacity:.5;filter:alpha(opacity=50);cursor:default;}.yui-toolbar-container .yui-button a{padding:0;}.yui-toolbar-container .yui-button.ie6.hover{background-color:#98D5FC !important;}.yui-toolbar-container .yui-toolbar-select{height:20px;width:auto;}.yui-toolbar-container .yui-toolbar-select a{border:none;background-color:transparent;height:19px;width:100%;text-align:left;cursor:pointer;opacity:1;filter:none;}.yui-toolbar-container .yui-toolbar-select .first-child{width:100% !important;}.yui-toolbar-container .yui-toolbar-select .first-child a{text-indent:3px !important;width:100% !important;}.yui-toolbar-container .yui-toolbar-select.yui-button-disabled a{cursor:default;opacity:1;filter:none;display:block;}.yui-toolbar-container .yui-toolbar-fontname{width:125px;}.yui-toolbar-container .yui-toolbar-heading{width:80px;}.yui-toolbar-fontname-arial{font-family:Arial;}.yui-toolbar-fontname-arial-black{font-family:Arial Black;}.yui-toolbar-fontname-comic-sans-ms{font-family:Comic Sans MS;}.yui-toolbar-fontname-courier-new{font-family:Courier New;}.yui-toolbar-fontname-times-new-roman{font-family:Times New Roman;}.yui-toolbar-fontname-verdana{font-family:Verdana;}.yui-toolbar-fontname-impact{font-family:Impact;}.yui-toolbar-fontname-lucida-console{font-family:Lucida Console;}.yui-toolbar-fontname-tahoma{font-family:Tahoma;}.yui-toolbar-fontname-trebuchet-ms{font-family:Trebuchet MS;}.yui-toolbar-container .yui-push-button-focus{border:1px dotted #999;}.yui-toolbar-container .yui-toolbar-spinbutton{position:relative;width:35px;}.yui-toolbar-container .yui-toolbar-spinbutton .first-child{width:35px;}.yui-toolbar-container .yui-toolbar-spinbutton .first-child a{border:none;background-color:transparent;background-image:none;background-repeat:no-repeat;width:28px;height:20px;text-align:left;text-indent:2px !important;z-index:0;opacity:1;filter:none;}.yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.up,.yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.down{position:absolute;display:block right:0;cursor:pointer;text-indent:999px;overflow:hidden;z-index:1;border:none;}.yui-toolbar-container .yui-overlay{position:absolute;}.yui-toolbar-container .yui-overlay ul li{float:none;}.yui-toolbar-colors{width:133px;zoom:1;display:none;z-index:100;overflow:hidden;}.yui-toolbar-colors:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-colors a{height:9px;width:9px;float:left;display:block;overflow:hidden;text-indent:999px;margin:0;cursor:pointer;border:1px solid #F6F7EE;}.yui-toolbar-colors a:hover{border:1px solid black;}.yui-color-button-menu{overflow:hidden;background-color:transparent;}.yui-toolbar-colors span{position:relative;display:block;padding:3px;overflow:hidden;float:left;width:100%;zoom:1;}.yui-toolbar-colors span:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-colors span em{height:35px;width:30px;float:left;display:block;overflow:hidden;text-indent:999px;margin:0.75px;border:1px solid black;}.yui-toolbar-colors span strong{font-weight:normal;padding-left:3px;display:block;font-size:85%;float:left;width:65%;}.yui-toolbar-container{z-index:1;}.yui-editor-container .yui-editor-editable-container{position:relative;z-index:0;}.yui-editor-container .yui-editor-masked{background-color:#CCC;}.yui-editor-container iframe{border:0px;padding:0;margin:0;}.yui-editor-container .yui-editor-editable{padding:0;margin:0;}.yui-editor-container .dompath{height:1em;padding:0.25em;font-size:85%;}.yui-editor-panel .hd{text-align:left;position:relative;}.yui-editor-panel .hd h3{font-weight:bold;padding:0.25em 0pt 0.25em 0.25em;}.yui-editor-panel .bd{width:100%;zoom:1;position:relative;}.yui-editor-panel .bd div.yui-editor-body-cont{padding:.25em .1em;zoom:1;}.yui-editor-panel .bd div.yui-editor-body-cont:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-editor-panel .ft{text-align:right;width:99%;float:left;clear:both;}.yui-editor-panel .ft span.tip{display:block;position:relative;padding-left:23px;text-align:left;margin:.5em;zoom:1;}.yui-editor-panel label{clear:both;float:left;padding:0;overflow:auto;width:100%;zoom:1;text-align:left;}.yui-editor-panel label strong{float:left;width:6em;}.yui-editor-panel .removeLink{width:80%;text-align:right;}.yui-editor-panel label input{margin-left:.25em;float:left;}.yui-editor-panel .yui-toolbar-group-padding{width:100px;}.yui-editor-panel .yui-toolbar-group-border{width:175px;*width:190px;}.yui-editor-panel .yui-toolbar-group-textflow{width:150px;*width:180px;}.yui-editor-panel .height-width{float:left;width:68%;}.yui-editor-panel .height-width h3{padding-right:11px;}.yui-editor-panel .height-width span{font-style:italic;display:block;float:left;overflow:auto;}.yui-editor-panel .height-width span.info{font-size:70%;}.yui-editor-panel .yui-toolbar-bordersize,.yui-editor-panel .yui-toolbar-bordertype{width:50px;font-size:75%;}.yui-editor-panel .yui-toolbar-container span.yui-toolbar-separator{border:none;}.yui-editor-panel .yui-toolbar-container div.yuimenu li.yuimenuitem a{float:none;}.yui-editor-panel .yui-toolbar-bordertype span a span.yui-toolbar-bordertype-solid{border-bottom:1px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordertype span a span.yui-toolbar-bordertype-dotted{border-bottom:1px dotted black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordertype span a span.yui-toolbar-bordertype-dashed{border-bottom:1px dashed black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-1{border-bottom:1px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-2{border-bottom:2px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-3{border-bottom:3px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-4{border-bottom:4px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-5{border-bottom:5px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-toolbar-container .yui-toolbar-bordersize-menu{width:30px;}.yui-toolbar-bordersize-menu .yuimenuitemlabel,.yui-toolbar-bordertype-menu .yuimenuitemlabel{display:block;width:50px;color:#ffffff;position:relative;margin-left:20px;padding:0;}.yui-toolbar-bordersize-menu .yuimenuitemlabel .checkedindicator,.yui-toolbar-bordertype-menu .yuimenuitemlabel .checkedindicator{position:absolute;left:-14px;}.yui-toolbar-bordersize-menu .yuimenuitem a.selected,.yui-toolbar-bordertype-menu .yuimenuitem a.selected{color:#B3D4FF;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-0 a{color:#000;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-0 a.selected{color:#fff;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-1 a{border-bottom:1px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-2 a{border-bottom:2px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-3 a{border-bottom:3px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-4 a{border-bottom:4px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-5 a{border-bottom:5px solid black;}div.yuimenu.yui-toolbar-bordertype-menu li.yui-toolbar-bordertype-solid a{border-bottom:1px solid black;}div.yuimenu.yui-toolbar-bordertype-menu li.yui-toolbar-bordertype-dashed a{border-bottom:1px dashed black;}div.yuimenu.yui-toolbar-bordertype-menu li.yui-toolbar-bordertype-dotted a{border-bottom:1px dotted black;}h2.yui-editor-skipheader,h3.yui-editor-skipheader{height:0;margin:0;padding:0;border:none;width:0;overflow:hidden;position:absolute;}.yui-skin-sam .yui-toolbar-container{border:1px solid #808080;zoom:1;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-titlebar{background:url(sprite.png) repeat-x 0 -200px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-titlebar h2{color:#000000;font-weight:bold;margin:0;padding:0.3em 1em;font-size:100%;text-align:left;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-group h3{color:#808080;font-size:75%;margin:1em 0 0.25em;padding-bottom:0;padding-left:0.25em;text-align:left;}.yui-toolbar-container span.yui-toolbar-separator{border:none;}.yui-skin-sam .yui-toolbar-container{background-color:#F2F2F2;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-subcont{padding:0 1em 0.35em;}.yui-skin-sam .yui-editor-container .visible .yui-menu-shadow,.yui-skin-sam .yui-editor-panel .visible .yui-menu-shadow{display:none;}.yui-skin-sam .yui-editor-container ul{list-style-type:none;margin:0;padding:0;}.yui-skin-sam .yui-editor-container ul li{margin:0;padding:0;}.yui-skin-sam .yui-editor-container .yui-editor-editable-container{border:1px solid #808080;border-top:none;}.yui-skin-sam .yui-editor-container .dompath{background-color:#F2F2F2;border:1px solid #808080;border-top:none;color:#999;text-align:left;}.yui-skin-sam .yui-toolbar-container .collapse{background:url(sprite.png) no-repeat 0 -400px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-titlebar span.collapse{cursor:pointer;position:absolute;top:2px;right:2px;display:block;overflow:hidden;height:15px;width:15px;text-indent:9999px;}.yui-toolbar-container .yui-toolbar-select .first-child a{padding-top:0;}.yui-skin-sam .yui-toolbar-container .yui-button{background:url(sprite.png) repeat-x 0 0;border:1px solid #808080;cursor:pointer;height:22px;margin:0;overflow:hidden;position:relative;display:block;}.yui-skin-sam .yui-toolbar-container .yui-button-hover{background:url(sprite.png) repeat-x 0 -1300px;border-color:#808080;}.yui-skin-sam .yui-toolbar-container .yui-button-selected{background:url(sprite.png) no-repeat 0 -1700px;border-color:#808080;}.yui-skin-sam .yui-toolbar-container .yui-button span.yui-toolbar-icon{display:block;position:absolute;top:2px;height:18px;width:18px;overflow:hidden;background-image:url( editor-sprite.gif );background-repeat:no-repeat;background-position:30px 30px;}.yui-skin-sam .yui-toolbar-container .yui-button-selected span.yui-toolbar-icon,.yui-skin-sam .yui-toolbar-container .yui-button-hover span.yui-toolbar-icon{background-image:url(editor-sprite-active.gif);}.yui-skin-sam .visible .yuimenuitemlabel{text-align:left;}.yui-skin-sam .yui-button-menu{background-color:#ffffff;}.yui-skin-sam div.yuimenu li.selected{background-color:#B3D4FF;}.yui-skin-sam div.yuimenu li.selected a.selected{color:#000;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-bold span.yui-toolbar-icon{background-position:0 0;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-italic span.yui-toolbar-icon{background-position:0 -36px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-underline span.yui-toolbar-icon{background-position:0 -72px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-subscript span.yui-toolbar-icon{background-position:0 -180px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-superscript span.yui-toolbar-icon{background-position:0 -144px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-forecolor span.yui-toolbar-icon{background-position:0 -216px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-backcolor span.yui-toolbar-icon{background-position:0 -288px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyleft span.yui-toolbar-icon{background-position:0 -324px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifycenter span.yui-toolbar-icon{background-position:0 -360px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyright span.yui-toolbar-icon{background-position:0 -396px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyfull span.yui-toolbar-icon{background-position:0 -432px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-indent span.yui-toolbar-icon{background-position:0 -720px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-outdent span.yui-toolbar-icon{background-position:0 -684px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-createlink span.yui-toolbar-icon{background-position:0 -792px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertimage span.yui-toolbar-icon{background-position:1px -756px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-left span.yui-toolbar-icon{background-position:0 -972px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-right span.yui-toolbar-icon{background-position:0 -936px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-inline span.yui-toolbar-icon{background-position:0 -900px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-block span.yui-toolbar-icon{background-position:0 -864px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-bordercolor span.yui-toolbar-icon{background-position:0 -252px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-removeformat span.yui-toolbar-icon{background-position:0 -1080px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-hiddenelements span.yui-toolbar-icon{background-position:0 -1044px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertunorderedlist span.yui-toolbar-icon{background-position:0 -468px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertorderedlist span.yui-toolbar-icon{background-position:0 -504px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-fontname,.yui-skin-sam .yui-toolbar-container .yui-toolbar-bold,.yui-skin-sam .yui-toolbar-container .yui-toolbar-italic,.yui-skin-sam .yui-toolbar-container .yui-toolbar-subscript,.yui-skin-sam .yui-toolbar-container .yui-toolbar-forecolor,.yui-skin-sam .yui-toolbar-container .yui-toolbar-removeformat,.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyleft,.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifycenter,.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyright,.yui-skin-sam .yui-toolbar-container .yui-toolbar-indent,.yui-skin-sam .yui-toolbar-container .yui-toolbar-outdent,.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertunorderedlist,.yui-skin-sam .yui-toolbar-container .yui-toolbar-createlink,.yui-skin-sam .yui-toolbar-container .yui-toolbar-left,.yui-skin-sam .yui-toolbar-container .yui-toolbar-inline,.yui-skin-sam .yui-toolbar-container .yui-toolbar-block,.yui-skin-sam .yui-toolbar-container .yui-toolbar-bordersize,.yui-skin-sam .yui-toolbar-container .yui-toolbar-bordertype{border-right:none;}.yui-skin-sam .yui-toolbar-container .yui-button .first-child,.yui-skin-sam .yui-toolbar-container .yui-button .first-child a{width:500px;position:absolute;_position:static;top:-1px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-select .first-child,.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton .first-child{position:static;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-select .first-child a,.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton .first-child a{height:19px;left:0;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton span.yui-toolbar-icon{display:none;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.up{top:0;right:0;background-image:url( editor-sprite.gif );background-position:0 -1221px;overflow:hidden;height:8px;width:8px;min-height:0;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.down{bottom:0;right:0;background-image:url( editor-sprite.gif );background-position:0 -1187px;overflow:hidden;height:8px;width:8px;min-height:0;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-select span.yui-toolbar-icon{background-image:url( editor-sprite.gif );background-position:0px -1144px;overflow:hidden;right:-2px;top:0px;height:20px;}.yui-skin-sam .yui-editor-panel .yui-color-button-menu .bd{background-color:transparent;border:none;width:135px;}.yui-skin-sam .yui-color-button-menu .yui-toolbar-colors{border:1px solid #808080;}.yui-editor-panel label input.warning{background-color:#FFEE69;}.yui-skin-sam .yui-editor-panel .yui-panel{padding:0;margin:0;border:none;background-color:transparent;overflow:visible;}.yui-skin-sam .yui-editor-panel .yui-toolbar-group-border{width:190px;*width:195px;}.yui-skin-sam .yui-editor-panel .yui-toolbar-group-textflow{width:185px;}.yui-skin-sam .yui-editor-panel .hd{margin:13px 0 0;padding:0;border:none;}.yui-skin-sam .yui-editor-panel .hd h3{color:#000;border:1px solid #808080;background:url(sprite.png) repeat-x 0 -200px;width:99%;position:relative;margin:0;padding:0;font-size:93%;text-indent:5px;height:20px;}.yui-skin-sam .yui-editor-panel .bd{background-color:#F2F2F2;border-left:1px solid #808080;border-right:1px solid #808080;width:99%;margin:0;*margin-left:-1px;padding:0;overflow:visible;}.yui-skin-sam .yui-editor-panel ul{list-style-type:none;margin:0;padding:0;}.yui-skin-sam .yui-editor-panel ul li{margin:0;padding:0;}.yui-skin-sam .yui-editor-panel label strong{font-weight:normal;font-size:93%;}.yui-skin-sam .yui-editor-panel .hd{background:none;}.yui-skin-sam .yui-editor-panel .ft{background-color:#F2F2F2;border:1px solid #808080;border-top:none;padding:0;margin:0;z-index:-1;}.yui-skin-sam .yui-editor-panel .hd span.close{background:url(sprite.png) no-repeat 0 -300px;cursor:pointer;display:block;height:16px;overflow:hidden;position:absolute;right:5px;text-indent:500px;top:2px;width:26px;}.yui-skin-sam .yui-editor-panel .ft span.tip span.icon{background-image:url( editor-sprite.gif );background-position:0 -1260px;display:block;height:20px;left:0;position:absolute;top:0;width:20px;}.yui-skin-sam .yui-editor-panel .ft span.tip span.icon-info{background-position:2px -1260px;}.yui-skin-sam .yui-editor-panel .ft span.tip span.icon-warn{background-position:2px -1296px;}.yui-skin-sam .yui-editor-panel .hd span.knob{position:absolute;height:10px;width:28px;top:-10px;left:25px;text-indent:9999px;overflow:hidden;background-image:url( editor-knob.gif );background-repeat:no-repeat;}.yui-skin-sam .yui-editor-panel .yui-toolbar-container{float:left;width:100%;background-image:none;border:none;}.yui-skin-sam .yui-editor-panel .yui-toolbar-container .bd{background-color:#ffffff;border-bottom:1px solid #808080;}.yui-skin-sam .yui-editor-panel .yui-toolbar-group h3{color:#000;float:left;padding-top:5px;}.yui-editor-blankimage{background-image:url( blankimage.png );}
+.yui-skin-sam .yui-log{padding:1em;width:31em;background-color:#AAA;color:#000;border:1px solid black;font-family:monospace;font-size:77%;text-align:left;z-index:9000;}.yui-skin-sam .yui-log-container{position:absolute;top:1em;right:1em;}.yui-skin-sam .yui-log input{margin:0;padding:0;font-family:arial;font-size:100%;font-weight:normal;}.yui-skin-sam .yui-log .yui-log-btns{position:relative;float:right;bottom:.25em;}.yui-skin-sam .yui-log .yui-log-hd{margin-top:1em;padding:.5em;background-color:#575757;}.yui-skin-sam .yui-log .yui-log-hd h4{margin:0;padding:0;font-size:108%;font-weight:bold;color:#FFF;}.yui-skin-sam .yui-log .yui-log-bd{width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}.yui-skin-sam .yui-log p{margin:1px;padding:.1em;}.yui-skin-sam .yui-log pre{margin:0;padding:0;}.yui-skin-sam .yui-log pre.yui-log-verbose{white-space:pre-wrap;white-space:-moz-pre-wrap !important;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;}.yui-skin-sam .yui-log .yui-log-ft{margin-top:.5em;}.yui-skin-sam .yui-log .yui-log-ft .yui-log-categoryfilters{}.yui-skin-sam .yui-log .yui-log-ft .yui-log-sourcefilters{width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}.yui-skin-sam .yui-log .yui-log-filtergrp{margin-right:.5em;}.yui-skin-sam .yui-log .info{background-color:#A7CC25;}.yui-skin-sam .yui-log .warn{background-color:#F58516;}.yui-skin-sam .yui-log .error{background-color:#E32F0B;}.yui-skin-sam .yui-log .time{background-color:#A6C9D7;}.yui-skin-sam .yui-log .window{background-color:#F2E886;}
+.yuimenu .yuimenu,.yuimenubar .yuimenu{position:absolute;visibility:hidden;}.yuimenubar ul,.yuimenu ul{list-style-type:none;}.yuimenubar ul,.yuimenu ul,.yuimenubar li,.yuimenu li,.yuimenu h6,.yuimenubar h6{margin:0;padding:0;}.yuimenuitemlabel,.yuimenubaritemlabel{white-space:nowrap;}.yui-menu-shadow{position:absolute;}.hide-scrollbars *{overflow:hidden;}.hide-scrollbars select{display:none;}.yuimenu.show-scrollbars{overflow:visible;}.yuimenu.hide-scrollbars .yui-menu-shadow{overflow:hidden;}.yuimenu.show-scrollbars .yui-menu-shadow{overflow:auto;}.yui-skin-sam .yuimenubar{border:solid 1px #808080;background:url(sprite.png) repeat-x 0 0;}.yui-skin-sam .yuimenubar .bd,.yui-skin-sam .yuimenubar ul{*zoom:1;}.yui-skin-sam .yuimenubar>.bd>ul:after{content:".";display:block;clear:both;visibility:hidden;height:0;line-height:0;}.yui-skin-sam .yuimenubaritem{float:left;}.yui-skin-sam .yuimenubarnav .yuimenubaritem{border-right:solid 1px #ccc;}.yui-skin-sam .yuimenubaritemlabel{display:block;*display:inline-block;font-size:93%;line-height:2;*line-height:1.9;padding:0 10px;color:#000;text-decoration:none;outline:none;cursor:default;border-style:solid;border-color:#808080;border-width:1px 0;position:relative;margin:-1px 0;}.yui-skin-sam .yuimenubarnav .yuimenubaritemlabel{padding-right:20px;}.yui-skin-sam .yuimenubaritemlabel .submenuindicator{width:1px;height:1px;top:0;left:0;}.yui-skin-sam .yuimenubarnav .yuimenubaritemlabel .submenuindicator{top:50%;right:8px;left:auto;margin-top:-3px;height:4px;width:7px;text-indent:8px;background-position:-16px -856px;}.yui-skin-sam .yuimenubaritem a.selected{background:url(sprite.png) repeat-x 0 -1700px;border-color:#7D98B8;}.yui-skin-sam .yuimenubarnav .yuimenubaritem a.selected{border-left-width:1px;margin-left:-1px;*left:-1px;}.yui-skin-sam .yuimenubar a.selected .submenuindicator{background:transparent;}.yui-skin-sam .yuimenubarnav a.selected .submenuindicator{background:url(sprite.png) repeat-x -16px -856px;}.yui-skin-sam .yuimenubaritem a.disabled{cursor:default;color:#A6A6A6;}.yui-skin-sam .yuimenubarnav .yuimenubaritem a.disabled .submenuindicator{background-position:-16px -881px;}.yui-skin-sam .yuimenu .bd{position:relative;top:0;left:0;border:solid 1px #808080;background-color:#fff;z-index:1;}.yui-skin-sam .yuimenu ul{padding:3px 0;border-width:1px 0 0 0;border-color:#ccc;border-style:solid;}.yui-skin-sam .yuimenu ul.first-of-type{border-width:0;}.yui-skin-sam .yuimenu h6{font-size:93%;font-weight:bold;line-height:1.5;*line-height:1.45;border-style:solid;border-color:#ccc;border-width:1px 0 0 0;color:#a4a4a4;padding:3px 10px 0 10px;}.yui-skin-sam .yuimenu ul.hastitle,.yui-skin-sam .yuimenu h6.first-of-type{border-width:0;}.yui-skin-sam .yuimenu .topscrollbar,.yui-skin-sam .yuimenu .bottomscrollbar{position:relative;height:16px;border:solid 1px #808080;background:#fff url(sprite.png) no-repeat 0 0;}.yui-skin-sam .yuimenu .topscrollbar{z-index:2;border-bottom-color:#ccc;margin-bottom:-1px;background-position:center -950px;}.yui-skin-sam .yuimenu .topscrollbar_disabled{background-position:center -975px;}.yui-skin-sam .yuimenu .bottomscrollbar{z-index:3;border-top-color:#ccc;margin-top:-1px;background-position:center -850px;}.yui-skin-sam .yuimenu .bottomscrollbar_disabled{background-position:center -875px;}.yui-skin-sam .yuimenuitemlabel{font-size:93%;line-height:1.5;*line-height:1.45;padding:0 20px;display:block;color:#000;text-decoration:none;outline:none;position:relative;cursor:default;}.yui-skin-sam .yuimenuitemlabel .helptext{font-style:normal;margin:0 0 0 40px;}.yui-skin-sam .yuimenuitemlabel .submenuindicator,.yui-skin-sam .yuimenuitemlabel .checkedindicator,.yui-skin-sam .yuimenubaritemlabel .submenuindicator{position:absolute;overflow:hidden;background:url(sprite.png) no-repeat;}.yui-skin-sam .yuimenuitemlabel .submenuindicator{top:50%;right:8px;margin-top:-3px;height:7px;width:4px;text-indent:5px;background-position:0 -906px;}.yui-skin-sam .yuimenuitemlabel .checkedindicator{top:50%;left:8px;margin-top:-3px;height:7px;width:7px;text-indent:8px;background-position:0 -1006px;}.yui-skin-sam .yui-menu-shadow-visible{top:2px;right:-3px;left:-3px;bottom:-3px;background-color:#000;opacity:.12;*filter:alpha(opacity=12);visibility:visible;}.yui-skin-sam .visible .bd,.yui-skin-sam .visible .yuimenuitem{_zoom:1;}.yui-skin-sam .visible .yuimenuitemlabel{*zoom:1;}.yui-skin-sam .visible .yuimenuitemlabel .helptext{float:right;width:100%;text-align:right;margin:-1.5em 0 0 0;*margin:-1.45em 0 0 0;}.yui-skin-sam .yuimenuitem a.selected{background:#B3D4FF;}.yui-skin-sam .yuimenubar .yuimenuitem a.selected .submenuindicator{background:url(sprite.png) no-repeat 0 -906px;}.yui-skin-sam .yuimenubarnav .yuimenuitem a.selected{border-width:0;margin:0;*left:0;}.yui-skin-sam .yuimenuitem a.disabled{cursor:default;color:#A6A6A6;}.yui-skin-sam .yuimenuitem a.disabled .submenuindicator{background-position:0 -931px;}.yui-skin-sam .yuimenuitem a.disabled .checkedindicator{background-position:0 -1031px;}
+.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{margin:0 0.5em 0 0;}.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{margin:0 0 0.5em;}.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{width:6em;}.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{width:auto;}.yui-navset .yui-navset-left,.yui-navset-left{padding:0 0 0 6em;}.yui-navset-right{padding:0 6em 0 0;}.yui-navset-top,.yui-navset-bottom{padding:auto;}.yui-nav,.yui-nav li{margin:0;padding:0;list-style:none;}.yui-navset li em{font-style:normal;}.yui-navset{position:relative;zoom:1;}.yui-navset .yui-content{zoom:1;}.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{display:inline-block;display:-moz-inline-stack;*display:inline;vertical-align:bottom;cursor:pointer;zoom:1;}.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{display:block;}.yui-navset .yui-nav a{Xoutline:0;}.yui-navset .yui-nav a{Xposition:relative;}.yui-navset .yui-nav li a,.yui-navset-top .yui-nav li a,.yui-navset-bottom .yui-nav li a{display:block;display:inline-block;vertical-align:bottom;zoom:1;}.yui-navset-left .yui-nav li a,.yui-navset-right .yui-nav li a{display:block;}.yui-navset-bottom .yui-nav li a{vertical-align:text-top;}.yui-navset .yui-nav li a em,.yui-navset-top .yui-nav li a em,.yui-navset-bottom .yui-nav li a em{display:block;}.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{position:absolute;z-index:1;}.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{position:static;}.yui-navset .yui-navset-left .yui-nav,.yui-navset-left .yui-nav{left:0;right:auto;}.yui-navset .yui-navset-right .yui-nav,.yui-navset-right .yui-nav{right:0;left:auto;}.yui-skin-sam .yui-navset .yui-nav,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav{border:solid #2647a0;border-width:0 0 5px;Xposition:relative;zoom:1;}.yui-skin-sam .yui-navset .yui-nav li,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav li{margin:0 0.16em 0 0;padding:1px 0 0;zoom:1;}.yui-skin-sam .yui-navset .yui-nav .selected,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav .selected{margin:0 0.16em -1px 0;}.yui-skin-sam .yui-navset .yui-nav a,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a{background:#d8d8d8 url(sprite.png) repeat-x;border:solid #a3a3a3;border-width:0 1px;color:#000;position:relative;text-decoration:none;}.yui-skin-sam .yui-navset .yui-nav a em,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a em{border:solid #a3a3a3;border-width:1px 0 0;cursor:hand;padding:0.25em .75em;left:0;right:0;bottom:0;top:-1px;position:relative;}.yui-skin-sam .yui-navset .yui-nav .selected a,.yui-skin-sam .yui-navset .yui-nav .selected a:focus,.yui-skin-sam .yui-navset .yui-nav .selected a:hover{background:#2647a0 url(sprite.png) repeat-x left -1400px;color:#fff;}.yui-skin-sam .yui-navset .yui-nav a:hover,.yui-skin-sam .yui-navset .yui-nav a:focus{background:#bfdaff url(sprite.png) repeat-x left -1300px;outline:0;}.yui-skin-sam .yui-navset .yui-nav .selected a em{padding:0.35em 0.75em;}.yui-skin-sam .yui-navset .yui-nav .selected a,.yui-skin-sam .yui-navset .yui-nav .selected a em{border-color:#243356;}.yui-skin-sam .yui-navset .yui-content{background:#edf5ff;}.yui-skin-sam .yui-navset .yui-content,.yui-skin-sam .yui-navset .yui-navset-top .yui-content{border:1px solid #808080;border-top-color:#243356;padding:0.25em 0.5em;}.yui-skin-sam .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 5px 0 0;Xposition:absolute;top:0;bottom:0;}.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 0 0 5px;}.yui-skin-sam .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset-right .yui-nav li{margin:0 0 0.16em;padding:0 0 0 1px;}.yui-skin-sam .yui-navset-right .yui-nav li{padding:0 1px 0 0;}.yui-skin-sam .yui-navset-left .yui-nav .selected,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav .selected{margin:0 -1px 0.16em 0;}.yui-skin-sam .yui-navset-right .yui-nav .selected{margin:0 0 0.16em -1px;}.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav a{border-width:1px 0;}.yui-skin-sam .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 0 0 1px;padding:0.2em .75em;top:auto;left:-1px;}.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 1px 0 0;left:auto;right:-1px;}.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-left .yui-nav .selected a,.yui-skin-sam .yui-navset-left .yui-nav a:hover,.yui-skin-sam .yui-navset-right .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav .selected a,.yui-skin-sam .yui-navset-right .yui-nav a:hover,.yui-skin-sam .yui-navset-bottom .yui-nav a,.yui-skin-sam .yui-navset-bottom .yui-nav .selected a,.yui-skin-sam .yui-navset-bottom .yui-nav a:hover{background-image:none;}.yui-skin-sam .yui-navset-left .yui-content{border:1px solid #808080;border-left-color:#243356;}.yui-skin-sam .yui-navset-bottom .yui-nav,.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav{border-width:5px 0 0;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav .selected,.yui-skin-sam .yui-navset-bottom .yui-nav .selected{margin:-1px 0.16em 0 0;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li,.yui-skin-sam .yui-navset-bottom .yui-nav li{padding:0 0 1px 0;vertical-align:top;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li a,.yui-skin-sam .yui-navset-bottom .yui-nav li a{}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav a em,.yui-skin-sam .yui-navset-bottom .yui-nav a em{border-width:0 0 1px;top:auto;bottom:-1px;}.yui-skin-sam .yui-navset-bottom .yui-content,.yui-skin-sam .yui-navset .yui-navset-bottom .yui-content{border:1px solid #808080;border-bottom-color:#243356;}
+.ygtvtn{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -5600px no-repeat;}.ygtvtm{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -4000px no-repeat;}.ygtvtmh{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -4800px no-repeat;}.ygtvtp{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -6400px no-repeat;}.ygtvtph{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -7200px no-repeat;}.ygtvln{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -1600px no-repeat;}.ygtvlm{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 0px no-repeat;}.ygtvlmh{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -800px no-repeat;}.ygtvlp{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -2400px no-repeat;}.ygtvlph{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -3200px no-repeat;}.ygtvloading{width:18px;height:22px;background:url(treeview-loading.gif) 0 0 no-repeat;}.ygtvdepthcell{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -8000px no-repeat;}.ygtvblankdepthcell{width:18px;height:22px;}.ygtvitem{}.ygtvchildren{*zoom:1;}.ygtvlabel,.ygtvlabel:link,.ygtvlabel:visited,.ygtvlabel:hover{margin-left:2px;text-decoration:none;background-color:white;}.ygtvspacer{height:22px;width:18px;}
+
diff --git a/lib/yui/assets/skins/sam/split-button-arrow-active.png b/lib/yui/assets/skins/sam/split-button-arrow-active.png
new file mode 100755
index 0000000000..fa58c5030e
Binary files /dev/null and b/lib/yui/assets/skins/sam/split-button-arrow-active.png differ
diff --git a/lib/yui/assets/skins/sam/split-button-arrow-disabled.png b/lib/yui/assets/skins/sam/split-button-arrow-disabled.png
new file mode 100755
index 0000000000..0a6a82c640
Binary files /dev/null and b/lib/yui/assets/skins/sam/split-button-arrow-disabled.png differ
diff --git a/lib/yui/assets/skins/sam/split-button-arrow-focus.png b/lib/yui/assets/skins/sam/split-button-arrow-focus.png
new file mode 100755
index 0000000000..167d71eb72
Binary files /dev/null and b/lib/yui/assets/skins/sam/split-button-arrow-focus.png differ
diff --git a/lib/yui/assets/skins/sam/split-button-arrow-hover.png b/lib/yui/assets/skins/sam/split-button-arrow-hover.png
new file mode 100755
index 0000000000..167d71eb72
Binary files /dev/null and b/lib/yui/assets/skins/sam/split-button-arrow-hover.png differ
diff --git a/lib/yui/assets/skins/sam/split-button-arrow.png b/lib/yui/assets/skins/sam/split-button-arrow.png
new file mode 100755
index 0000000000..b33a93ff2d
Binary files /dev/null and b/lib/yui/assets/skins/sam/split-button-arrow.png differ
diff --git a/lib/yui/assets/skins/sam/sprite.png b/lib/yui/assets/skins/sam/sprite.png
new file mode 100755
index 0000000000..afd65e05aa
Binary files /dev/null and b/lib/yui/assets/skins/sam/sprite.png differ
diff --git a/lib/yui/assets/skins/sam/tabview.css b/lib/yui/assets/skins/sam/tabview.css
new file mode 100755
index 0000000000..247414abb6
--- /dev/null
+++ b/lib/yui/assets/skins/sam/tabview.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{margin:0 0.5em 0 0;}.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{margin:0 0 0.5em;}.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{width:6em;}.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{width:auto;}.yui-navset .yui-navset-left,.yui-navset-left{padding:0 0 0 6em;}.yui-navset-right{padding:0 6em 0 0;}.yui-navset-top,.yui-navset-bottom{padding:auto;}.yui-nav,.yui-nav li{margin:0;padding:0;list-style:none;}.yui-navset li em{font-style:normal;}.yui-navset{position:relative;zoom:1;}.yui-navset .yui-content{zoom:1;}.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{display:inline-block;display:-moz-inline-stack;*display:inline;vertical-align:bottom;cursor:pointer;zoom:1;}.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{display:block;}.yui-navset .yui-nav a{Xoutline:0;}.yui-navset .yui-nav a{Xposition:relative;}.yui-navset .yui-nav li a,.yui-navset-top .yui-nav li a,.yui-navset-bottom .yui-nav li a{display:block;display:inline-block;vertical-align:bottom;zoom:1;}.yui-navset-left .yui-nav li a,.yui-navset-right .yui-nav li a{display:block;}.yui-navset-bottom .yui-nav li a{vertical-align:text-top;}.yui-navset .yui-nav li a em,.yui-navset-top .yui-nav li a em,.yui-navset-bottom .yui-nav li a em{display:block;}.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{position:absolute;z-index:1;}.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{position:static;}.yui-navset .yui-navset-left .yui-nav,.yui-navset-left .yui-nav{left:0;right:auto;}.yui-navset .yui-navset-right .yui-nav,.yui-navset-right .yui-nav{right:0;left:auto;}.yui-skin-sam .yui-navset .yui-nav,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav{border:solid #2647a0;border-width:0 0 5px;Xposition:relative;zoom:1;}.yui-skin-sam .yui-navset .yui-nav li,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav li{margin:0 0.16em 0 0;padding:1px 0 0;zoom:1;}.yui-skin-sam .yui-navset .yui-nav .selected,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav .selected{margin:0 0.16em -1px 0;}.yui-skin-sam .yui-navset .yui-nav a,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a{background:#d8d8d8 url(sprite.png) repeat-x;border:solid #a3a3a3;border-width:0 1px;color:#000;position:relative;text-decoration:none;}.yui-skin-sam .yui-navset .yui-nav a em,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a em{border:solid #a3a3a3;border-width:1px 0 0;cursor:hand;padding:0.25em .75em;left:0;right:0;bottom:0;top:-1px;position:relative;}.yui-skin-sam .yui-navset .yui-nav .selected a,.yui-skin-sam .yui-navset .yui-nav .selected a:focus,.yui-skin-sam .yui-navset .yui-nav .selected a:hover{background:#2647a0 url(sprite.png) repeat-x left -1400px;color:#fff;}.yui-skin-sam .yui-navset .yui-nav a:hover,.yui-skin-sam .yui-navset .yui-nav a:focus{background:#bfdaff url(sprite.png) repeat-x left -1300px;outline:0;}.yui-skin-sam .yui-navset .yui-nav .selected a em{padding:0.35em 0.75em;}.yui-skin-sam .yui-navset .yui-nav .selected a,.yui-skin-sam .yui-navset .yui-nav .selected a em{border-color:#243356;}.yui-skin-sam .yui-navset .yui-content{background:#edf5ff;}.yui-skin-sam .yui-navset .yui-content,.yui-skin-sam .yui-navset .yui-navset-top .yui-content{border:1px solid #808080;border-top-color:#243356;padding:0.25em 0.5em;}.yui-skin-sam .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 5px 0 0;Xposition:absolute;top:0;bottom:0;}.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 0 0 5px;}.yui-skin-sam .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset-right .yui-nav li{margin:0 0 0.16em;padding:0 0 0 1px;}.yui-skin-sam .yui-navset-right .yui-nav li{padding:0 1px 0 0;}.yui-skin-sam .yui-navset-left .yui-nav .selected,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav .selected{margin:0 -1px 0.16em 0;}.yui-skin-sam .yui-navset-right .yui-nav .selected{margin:0 0 0.16em -1px;}.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav a{border-width:1px 0;}.yui-skin-sam .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 0 0 1px;padding:0.2em .75em;top:auto;left:-1px;}.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 1px 0 0;left:auto;right:-1px;}.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-left .yui-nav .selected a,.yui-skin-sam .yui-navset-left .yui-nav a:hover,.yui-skin-sam .yui-navset-right .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav .selected a,.yui-skin-sam .yui-navset-right .yui-nav a:hover,.yui-skin-sam .yui-navset-bottom .yui-nav a,.yui-skin-sam .yui-navset-bottom .yui-nav .selected a,.yui-skin-sam .yui-navset-bottom .yui-nav a:hover{background-image:none;}.yui-skin-sam .yui-navset-left .yui-content{border:1px solid #808080;border-left-color:#243356;}.yui-skin-sam .yui-navset-bottom .yui-nav,.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav{border-width:5px 0 0;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav .selected,.yui-skin-sam .yui-navset-bottom .yui-nav .selected{margin:-1px 0.16em 0 0;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li,.yui-skin-sam .yui-navset-bottom .yui-nav li{padding:0 0 1px 0;vertical-align:top;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li a,.yui-skin-sam .yui-navset-bottom .yui-nav li a{}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav a em,.yui-skin-sam .yui-navset-bottom .yui-nav a em{border-width:0 0 1px;top:auto;bottom:-1px;}.yui-skin-sam .yui-navset-bottom .yui-content,.yui-skin-sam .yui-navset .yui-navset-bottom .yui-content{border:1px solid #808080;border-bottom-color:#243356;}
diff --git a/lib/yui/assets/skins/sam/treeview-loading.gif b/lib/yui/assets/skins/sam/treeview-loading.gif
new file mode 100755
index 0000000000..0bbf3bc0c0
Binary files /dev/null and b/lib/yui/assets/skins/sam/treeview-loading.gif differ
diff --git a/lib/yui/assets/skins/sam/treeview-sprite.gif b/lib/yui/assets/skins/sam/treeview-sprite.gif
new file mode 100755
index 0000000000..a04eff6af4
Binary files /dev/null and b/lib/yui/assets/skins/sam/treeview-sprite.gif differ
diff --git a/lib/yui/assets/skins/sam/treeview.css b/lib/yui/assets/skins/sam/treeview.css
new file mode 100755
index 0000000000..b82d34e6e8
--- /dev/null
+++ b/lib/yui/assets/skins/sam/treeview.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.ygtvtn{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -5600px no-repeat;}.ygtvtm{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -4000px no-repeat;}.ygtvtmh{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -4800px no-repeat;}.ygtvtp{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -6400px no-repeat;}.ygtvtph{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -7200px no-repeat;}.ygtvln{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -1600px no-repeat;}.ygtvlm{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 0px no-repeat;}.ygtvlmh{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -800px no-repeat;}.ygtvlp{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -2400px no-repeat;}.ygtvlph{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -3200px no-repeat;}.ygtvloading{width:18px;height:22px;background:url(treeview-loading.gif) 0 0 no-repeat;}.ygtvdepthcell{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -8000px no-repeat;}.ygtvblankdepthcell{width:18px;height:22px;}.ygtvitem{}.ygtvchildren{*zoom:1;}.ygtvlabel,.ygtvlabel:link,.ygtvlabel:visited,.ygtvlabel:hover{margin-left:2px;text-decoration:none;background-color:white;}.ygtvspacer{height:22px;width:18px;}
diff --git a/lib/yui/assets/skins/sam/yuitest.css b/lib/yui/assets/skins/sam/yuitest.css
new file mode 100755
index 0000000000..8b4d7cdee7
--- /dev/null
+++ b/lib/yui/assets/skins/sam/yuitest.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+
diff --git a/lib/yui/autocomplete/README b/lib/yui/autocomplete/README
index 39c1cd89cf..89659ae9fb 100755
--- a/lib/yui/autocomplete/README
+++ b/lib/yui/autocomplete/README
@@ -1,5 +1,56 @@
AutoComplete Release Notes
+*** version 2.3.0 ***
+
+* Applied new skinning model.
+
+* The default queryDelay value has been changed to 0.2. In low-latency
+implementations (e.g., when queryDelay is set to 0 against a local
+JavaScript DataSource), typeAhead functionality may experience a race condition
+when retrieving the value of the textbox. To avoid this problem, implementers
+are advised not to set the queryDelay value too low.
+
+* Fixed runtime property value validation.
+
+* Implemented new method doBeforeSendQuery().
+
+* Implemented new method destroy().
+
+* Added support for latest JSON lib http://www.json.org/json.js.
+
+* Fixed forceSelection issues with matched selections and multiple selections.
+
+* No longer create var oAnim in global scope.
+
+* The properties alwaysShowContainer and useShadow should not be enabled together.
+
+* There is a known issue in Firefox where the native browser autocomplete
+attribute cannot be disabled programmatically on input boxes that are in use.
+
+
+
+
+
+**** version 2.2.2 ***
+
+* No changes.
+
+
+
+*** version 2.2.1 ***
+
+* Fixed form submission in Safari bug.
+* Fixed broken DS_JSArray support for minQueryLength=0.
+* Improved type checking with YAHOO.lang.
+
+
+
+*** version 2.2.0 ***
+
+* No changes.
+
+
+
*** version 0.12.2 ***
* No changes.
diff --git a/lib/yui/autocomplete/assets/autocomplete-core.css b/lib/yui/autocomplete/assets/autocomplete-core.css
new file mode 100755
index 0000000000..921fad9617
--- /dev/null
+++ b/lib/yui/autocomplete/assets/autocomplete-core.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+/* This file intentionally left blank */
diff --git a/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css b/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css
new file mode 100755
index 0000000000..a2d2359072
--- /dev/null
+++ b/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css
@@ -0,0 +1,50 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+/* styles for entire widget */
+.yui-skin-sam .yui-ac {
+ position:relative;font-family:arial;font-size:100%;
+}
+
+/* styles for input field */
+.yui-skin-sam .yui-ac-input {
+ position:absolute;width:100%;
+}
+
+/* styles for results container */
+.yui-skin-sam .yui-ac-container {
+ position:absolute;top:1.6em;width:100%;
+}
+
+/* styles for header/body/footer wrapper within container */
+.yui-skin-sam .yui-ac-content {
+ position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050;
+}
+
+/* styles for container shadow */
+.yui-skin-sam .yui-ac-shadow {
+ position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity: 0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049;
+}
+
+/* styles for results list */
+.yui-skin-sam .yui-ac-content ul{
+ margin:0;padding:0;width:100%;
+}
+
+/* styles for result item */
+.yui-skin-sam .yui-ac-content li {
+ margin:0;padding:2px 5px;cursor:default;white-space:nowrap;
+}
+
+/* styles for prehighlighted result item */
+.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight {
+ background:#B3D4FF;
+}
+
+/* styles for highlighted result item */
+.yui-skin-sam .yui-ac-content li.yui-ac-highlight {
+ background:#426FD9;color:#FFF;
+}
diff --git a/lib/yui/autocomplete/assets/skins/sam/autocomplete.css b/lib/yui/autocomplete/assets/skins/sam/autocomplete.css
new file mode 100755
index 0000000000..98b473e26a
--- /dev/null
+++ b/lib/yui/autocomplete/assets/skins/sam/autocomplete.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-skin-sam .yui-ac{position:relative;font-family:arial;font-size:100%;}.yui-skin-sam .yui-ac-input{position:absolute;width:100%;}.yui-skin-sam .yui-ac-container{position:absolute;top:1.6em;width:100%;}.yui-skin-sam .yui-ac-content{position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050;}.yui-skin-sam .yui-ac-shadow{position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity:0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049;}.yui-skin-sam .yui-ac-content ul{margin:0;padding:0;width:100%;}.yui-skin-sam .yui-ac-content li{margin:0;padding:2px 5px;cursor:default;white-space:nowrap;}.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight{background:#B3D4FF;}.yui-skin-sam .yui-ac-content li.yui-ac-highlight{background:#426FD9;color:#FFF;}
diff --git a/lib/yui/autocomplete/autocomplete-debug.js b/lib/yui/autocomplete/autocomplete-debug.js
index 45dc20894d..522add11f0 100755
--- a/lib/yui/autocomplete/autocomplete-debug.js
+++ b/lib/yui/autocomplete/autocomplete-debug.js
@@ -1,3097 +1,3253 @@
/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 0.12.2
+version: 2.3.0
*/
- /**
- * The AutoComplete control provides the front-end logic for text-entry suggestion and
- * completion functionality.
- *
- * @module autocomplete
- * @requires yahoo, dom, event, datasource
- * @optional animation, connection, json
- * @namespace YAHOO.widget
- * @title AutoComplete Widget
- */
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * The AutoComplete class provides the customizable functionality of a plug-and-play DHTML
- * auto completion widget. Some key features:
- *
- * Navigate with up/down arrow keys and/or mouse to pick a selection
- * The drop down container can "roll down" or "fly out" via configurable
- * animation
- * UI look-and-feel customizable through CSS, including container
- * attributes, borders, position, fonts, etc
- *
- *
- * @class AutoComplete
- * @constructor
- * @param elInput {HTMLElement} DOM element reference of an input field.
- * @param elInput {String} String ID of an input field.
- * @param elContainer {HTMLElement} DOM element reference of an existing DIV.
- * @param elContainer {String} String ID of an existing DIV.
- * @param oDataSource {Object} Instance of YAHOO.widget.DataSource for query/results.
- * @param oConfigs {Object} (optional) Object literal of configuration params.
- */
-YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
- if(elInput && elContainer && oDataSource) {
- // Validate DataSource
- if (oDataSource && (oDataSource instanceof YAHOO.widget.DataSource)) {
- this.dataSource = oDataSource;
- }
- else {
- YAHOO.log("Could not instantiate AutoComplete due to an invalid DataSource", "error", this.toString());
- return;
- }
-
- // Validate input element
- 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 {
- YAHOO.log("Could not instantiate AutoComplete due to an invalid input element", "error", this.toString());
- return;
- }
-
- // Validate container element
- 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") {
- YAHOO.log("The container may not display properly if display is set to \"none\" in CSS", "warn", this.toString());
- }
- }
- else {
- YAHOO.log("Could not instantiate AutoComplete due to an invalid container element", "error", this.toString());
- return;
- }
-
- // Set any config params passed in to override defaults
- if (typeof oConfigs == "object") {
- for(var sConfig in oConfigs) {
- if (sConfig) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
- }
-
- // Initialization sequence
- this._initContainer();
- this._initProps();
- this._initList();
- this._initContainerHelpers();
-
- // Set up events
- var oSelf = this;
- var oTextbox = this._oTextbox;
- // Events are actually for the content module within the container
- var oContent = this._oContainer._oContent;
-
- // Dom events
- 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);
-
- // Custom events
- 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);
-
- // Finish up
- oTextbox.setAttribute("autocomplete","off");
- YAHOO.widget.AutoComplete._nIndex++;
- YAHOO.log("AutoComplete initialized","info",this.toString());
- }
- // Required arguments were not found
- else {
- YAHOO.log("Could not instantiate AutoComplete due invalid arguments", "error", this.toString());
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * The DataSource object that encapsulates the data used for auto completion.
- * This object should be an inherited object from YAHOO.widget.DataSource.
- *
- * @property dataSource
- * @type Object
- */
-YAHOO.widget.AutoComplete.prototype.dataSource = null;
-
-/**
- * Number of characters that must be entered before querying for results. A negative value
- * effectively turns off the widget. A value of 0 allows queries of null or empty string
- * values.
- *
- * @property minQueryLength
- * @type Number
- * @default 1
- */
-YAHOO.widget.AutoComplete.prototype.minQueryLength = 1;
-
-/**
- * Maximum number of results to display in results container.
- *
- * @property maxResultsDisplayed
- * @type Number
- * @default 10
- */
-YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed = 10;
-
-/**
- * Number of seconds to delay before submitting a query request. If a query
- * request is received before a previous one has completed its delay, the
- * previous request is cancelled and the new request is set to the delay.
- *
- * @property queryDelay
- * @type Number
- * @default 0.5
- */
-YAHOO.widget.AutoComplete.prototype.queryDelay = 0.5;
-
-/**
- * Class name of a highlighted item within results container.
- *
- * @property highlighClassName
- * @type String
- * @default "yui-ac-highlight"
- */
-YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight";
-
-/**
- * Class name of a pre-highlighted item within results container.
- *
- * @property prehighlightClassName
- * @type String
- */
-YAHOO.widget.AutoComplete.prototype.prehighlightClassName = null;
-
-/**
- * Query delimiter. A single character separator for multiple delimited
- * selections. Multiple delimiter characteres may be defined as an array of
- * strings. A null value or empty string indicates that query results cannot
- * be delimited. This feature is not recommended if you need forceSelection to
- * be true.
- *
- * @property delimChar
- * @type String | String[]
- */
-YAHOO.widget.AutoComplete.prototype.delimChar = null;
-
-/**
- * Whether or not the first item in results container should be automatically highlighted
- * on expand.
- *
- * @property autoHighlight
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.autoHighlight = true;
-
-/**
- * Whether or not the input field should be automatically updated
- * with the first query result as the user types, auto-selecting the substring
- * that the user has not typed.
- *
- * @property typeAhead
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.typeAhead = false;
-
-/**
- * Whether or not to animate the expansion/collapse of the results container in the
- * horizontal direction.
- *
- * @property animHoriz
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.animHoriz = false;
-
-/**
- * Whether or not to animate the expansion/collapse of the results container in the
- * vertical direction.
- *
- * @property animVert
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.animVert = true;
-
-/**
- * Speed of container expand/collapse animation, in seconds..
- *
- * @property animSpeed
- * @type Number
- * @default 0.3
- */
-YAHOO.widget.AutoComplete.prototype.animSpeed = 0.3;
-
-/**
- * Whether or not to force the user's selection to match one of the query
- * results. Enabling this feature essentially transforms the input field into a
- * <select> field. This feature is not recommended with delimiter character(s)
- * defined.
- *
- * @property forceSelection
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.forceSelection = false;
-
-/**
- * Whether or not to allow browsers to cache user-typed input in the input
- * field. Disabling this feature will prevent the widget from setting the
- * autocomplete="off" on the input field. When autocomplete="off"
- * and users click the back button after form submission, user-typed input can
- * be prefilled by the browser from its cache. This caching of user input may
- * not be desired for sensitive data, such as credit card numbers, in which
- * case, implementers should consider setting allowBrowserAutocomplete to false.
- *
- * @property allowBrowserAutocomplete
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true;
-
-/**
- * Whether or not the results container should always be displayed.
- * Enabling this feature displays the container when the widget is instantiated
- * and prevents the toggling of the container to a collapsed state.
- *
- * @property alwaysShowContainer
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.alwaysShowContainer = false;
-
-/**
- * Whether or not to use an iFrame to layer over Windows form elements in
- * IE. Set to true only when the results container will be on top of a
- * <select> field in IE and thus exposed to the IE z-index bug (i.e.,
- * 5.5 < IE < 7).
- *
- * @property useIFrame
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.useIFrame = false;
-
-/**
- * Whether or not the results container should have a shadow.
- *
- * @property useShadow
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.useShadow = false;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Public accessor to the unique name of the AutoComplete instance.
- *
- * @method toString
- * @return {String} Unique name of the AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.toString = function() {
- return "AutoComplete " + this._sName;
-};
-
- /**
- * Returns true if container is in an expanded state, false otherwise.
- *
- * @method isContainerOpen
- * @return {Boolean} Returns true if container is in an expanded state, false otherwise.
- */
-YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() {
- return this._bContainerOpen;
-};
-
-/**
- * Public accessor to the internal array of DOM <li> elements that
- * display query results within the results container.
- *
- * @method getListItems
- * @return {HTMLElement[]} Array of <li> elements within the results container.
- */
-YAHOO.widget.AutoComplete.prototype.getListItems = function() {
- return this._aListItems;
-};
-
-/**
- * Public accessor to the data held in an <li> element of the
- * results container.
- *
- * @method getListItemData
- * @return {Object | Array} Object or array of result data or null
- */
-YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
- if(oListItem._oResultData) {
- return oListItem._oResultData;
- }
- else {
- return false;
- }
-};
-
-/**
- * Sets HTML markup for the results container header. This markup will be
- * inserted within a <div> tag with a class of "ac_hd".
- *
- * @method setHeader
- * @param sHeader {String} HTML markup for results container header.
- */
-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";
- }
-};
-
-/**
- * Sets HTML markup for the results container footer. This markup will be
- * inserted within a <div> tag with a class of "ac_ft".
- *
- * @method setFooter
- * @param sFooter {String} HTML markup for results container footer.
- */
-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";
- }
-};
-
-/**
- * Sets HTML markup for the results container body. This markup will be
- * inserted within a <div> tag with a class of "ac_bd".
- *
- * @method setBody
- * @param sHeader {String} HTML markup for results container body.
- */
-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;
-};
-
-/**
- * Overridable method that converts a result item object into HTML markup
- * for display. Return data values are accessible via the oResultItem object,
- * and the key return value will always be oResultItem[0]. Markup will be
- * displayed within <li> element tags in the container.
- *
- * @method formatResult
- * @param oResultItem {Object} Result item representing one query result. Data is held in an array.
- * @param sQuery {String} The current query string.
- * @return {String} HTML markup of formatted result data.
- */
-YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery) {
- var sResult = oResultItem[0];
- if(sResult) {
- return sResult;
- }
- else {
- return "";
- }
-};
-
-/**
- * Overridable method called before container expands allows implementers to access data
- * and DOM elements.
- *
- * @method doBeforeExpandContainer
- * @return {Boolean} Return true to continue expanding container, false to cancel the expand.
- */
-YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oResultItem, sQuery) {
- return true;
-};
-
-/**
- * Makes query request to the DataSource.
- *
- * @method sendQuery
- * @param sQuery {String} Query string.
- */
-YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) {
- this._sendQuery(sQuery);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Fired when the input field receives focus.
- *
- * @event textboxFocusEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null;
-
-/**
- * Fired when the input field receives key input.
- *
- * @event textboxKeyEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param nKeycode {Number} The keycode number.
- */
-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.
- */
-YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null;
-
-/**
- * Fired when the AutoComplete instance receives query results from the data
- * source.
- *
- * @event dataReturnEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param sQuery {String} The query string.
- * @param aResults {Array} Results array.
- */
-YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
-
-/**
- * Fired when the AutoComplete instance does not receive query results from the
- * DataSource due to an error.
- *
- * @event dataErrorEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
-
-/**
- * Fired when the results container is expanded.
- *
- * @event containerExpandEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
-
-/**
- * Fired when the input field has been prefilled by the type-ahead
- * feature.
- *
- * @event typeAheadEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param sQuery {String} The query string.
- * @param sPrefill {String} The prefill string.
- */
-YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null;
-
-/**
- * Fired when result item has been moused over.
- *
- * @event itemMouseOverEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item moused to.
- */
-YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
-
-/**
- * Fired when result item has been moused out.
- *
- * @event itemMouseOutEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item moused from.
- */
-YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
-
-/**
- * Fired when result item has been arrowed to.
- *
- * @event itemArrowToEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item arrowed to.
- */
-YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null;
-
-/**
- * Fired when result item has been arrowed away from.
- *
- * @event itemArrowFromEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item arrowed from.
- */
-YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent = null;
-
-/**
- * Fired when an item is selected via mouse click, ENTER key, or TAB key.
- *
- * @event itemSelectEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The selected <li> element item.
- * @param oData {Object} The data returned for the item, either as an object,
- * or mapped from the schema into an array.
- */
-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.
- *
- * @event unmatchedItemSelectEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param sQuery {String} The user-typed query string.
- */
-YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
-
-/**
- * Fired if forceSelection is enabled and the user's input has been cleared
- * because it did not match one of the returned query results.
- *
- * @event selectionEnforceEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
-
-/**
- * Fired when the results container is collapsed.
- *
- * @event containerCollapseEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null;
-
-/**
- * Fired when the input field loses focus.
- *
- * @event textboxBlurEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Internal class variable to index multiple AutoComplete instances.
- *
- * @property _nIndex
- * @type Number
- * @default 0
- * @private
- */
-YAHOO.widget.AutoComplete._nIndex = 0;
-
-/**
- * Name of AutoComplete instance.
- *
- * @property _sName
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sName = null;
-
-/**
- * Text input field DOM element.
- *
- * @property _oTextbox
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oTextbox = null;
-
-/**
- * Whether or not the input field is currently in focus. If query results come back
- * but the user has already moved on, do not proceed with auto complete behavior.
- *
- * @property _bFocused
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bFocused = true;
-
-/**
- * Animation instance for container expand/collapse.
- *
- * @property _oAnim
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oAnim = null;
-
-/**
- * Container DOM element.
- *
- * @property _oContainer
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oContainer = null;
-
-/**
- * Whether or not the results container is currently open.
- *
- * @property _bContainerOpen
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;
-
-/**
- * Whether or not the mouse is currently over the results
- * container. This is necessary in order to prevent clicks on container items
- * from being text input field blur events.
- *
- * @property _bOverContainer
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bOverContainer = false;
-
-/**
- * Array of <li> elements references that contain query results within the
- * results container.
- *
- * @property _aListItems
- * @type Array
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._aListItems = null;
-
-/**
- * Number of <li> elements currently displayed in results container.
- *
- * @property _nDisplayedItems
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0;
-
-/**
- * Internal count of <li> elements displayed and hidden in results container.
- *
- * @property _maxResultsDisplayed
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0;
-
-/**
- * Current query string
- *
- * @property _sCurQuery
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sCurQuery = null;
-
-/**
- * Past queries this session (for saving delimited queries).
- *
- * @property _sSavedQuery
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sSavedQuery = null;
-
-/**
- * Pointer to the currently highlighted <li> element in the container.
- *
- * @property _oCurItem
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oCurItem = null;
-
-/**
- * Whether or not an item has been selected since the container was populated
- * with results. Reset to false by _populateList, and set to true when item is
- * selected.
- *
- * @property _bItemSelected
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bItemSelected = false;
-
-/**
- * Key code of the last key pressed in textbox.
- *
- * @property _nKeyCode
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nKeyCode = null;
-
-/**
- * Delay timeout ID.
- *
- * @property _nDelayID
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nDelayID = -1;
-
-/**
- * Src to iFrame used when useIFrame = true. Supports implementations over SSL
- * as well.
- *
- * @property _iFrameSrc
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;";
-
-/**
- * For users typing via certain IMEs, queries must be triggered by intervals,
- * since key events yet supported across all browsers for all IMEs.
- *
- * @property _queryInterval
- * @type Object
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._queryInterval = null;
-
-/**
- * Internal tracker to last known textbox value, used to determine whether or not
- * to trigger a query via interval for certain IME users.
- *
- * @event _sLastTextboxValue
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Updates and validates latest public config properties.
- *
- * @method __initProps
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initProps = function() {
- // Correct any invalid values
- 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.log("The forceSelection feature has been enabled with delimChar defined.","warn", this.toString());
- }
-};
-
-/**
- * Initializes the results container helpers if they are enabled and do
- * not exist
- *
- * @method _initContainerHelpers
- * @private
- */
-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);
- }
-};
-
-/**
- * Initializes the results container once at object creation
- *
- * @method _initContainer
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initContainer = function() {
- if(!this._oContainer._oContent) {
- // The oContent div helps size the iframe and shadow properly
- 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.log("Could not initialize the container","warn",this.toString());
- }
-};
-
-/**
- * Clears out contents of container body and creates up to
- * YAHOO.widget.AutoComplete#maxResultsDisplayed <li> elements in an
- * <ul> element.
- *
- * @method _initList
- * @private
- */
-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) || // alt,pause/break,caps lock
- (nKeyCode == 27) || // esc
- (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end
- (nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up
- (nKeyCode == 40) || // down
- (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert
- return true;
- }
- return false;
-};
-
-/**
- * Makes query request to the DataSource.
- *
- * @method _sendQuery
- * @param sQuery {String} Query string.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) {
- // Widget has been effectively turned off
- if(this.minQueryLength == -1) {
- this._toggleContainer(false);
- return;
- }
- // Delimiter has been enabled
- var aDelimChar = (this.delimChar) ? this.delimChar : null;
- if(aDelimChar) {
- // Loop through all possible delimiters and find the latest one
- // A " " may be a false positive if they are defined as delimiters AND
- // are used to separate delimited queries
- var nDelimIndex = -1;
- for(var i = aDelimChar.length-1; i >= 0; i--) {
- var nNewIndex = sQuery.lastIndexOf(aDelimChar[i]);
- if(nNewIndex > nDelimIndex) {
- nDelimIndex = nNewIndex;
- }
- }
- // If we think the last delimiter is a space (" "), make sure it is NOT
- // a false positive by also checking the char directly before it
- if(aDelimChar[i] == " ") {
- for (var j = aDelimChar.length-1; j >= 0; j--) {
- if(sQuery[nDelimIndex - 1] == aDelimChar[j]) {
- nDelimIndex--;
- break;
- }
- }
- }
- // A delimiter has been found so extract the latest query
- if (nDelimIndex > -1) {
- var nQueryStart = nDelimIndex + 1;
- // Trim any white space from the beginning...
- while(sQuery.charAt(nQueryStart) == " ") {
- nQueryStart += 1;
- }
- // ...and save the rest of the string for later
- this._sSavedQuery = sQuery.substring(0,nQueryStart);
- // Here is the query itself
- sQuery = sQuery.substr(nQueryStart);
- }
- else if(sQuery.indexOf(this._sSavedQuery) < 0){
- this._sSavedQuery = null;
- }
- }
-
- // Don't search queries that are too short
- if (sQuery && (sQuery.length < this.minQueryLength) || (!sQuery && this.minQueryLength > 0)) {
- if (this._nDelayID != -1) {
- clearTimeout(this._nDelayID);
- }
- this._toggleContainer(false);
- return;
- }
-
- sQuery = encodeURIComponent(sQuery);
- this._nDelayID = -1; // Reset timeout ID because request has been made
- this.dataRequestEvent.fire(this, sQuery);
- this.dataSource.getResults(this._populateList, sQuery, this);
-};
-
-/**
- * Populates the array of <li> elements in the container with query
- * results. This method is passed to YAHOO.widget.DataSource#getResults as a
- * callback function so results from the DataSource instance are returned to the
- * AutoComplete instance.
- *
- * @method _populateList
- * @param sQuery {String} The query string.
- * @param aResults {Array} An array of query result objects from the DataSource.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-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;
-
- // Fill items with data
- 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;
-
- }
-
- // Empty out remaining items if any
- 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) {
- // Go to the first item
- var oFirstItem = aItems[0];
- oSelf._toggleHighlight(oFirstItem,"to");
- oSelf.itemArrowToEvent.fire(oSelf, oFirstItem);
- oSelf._typeAhead(oFirstItem,sQuery);
- }
- else {
- oSelf._oCurItem = null;
- }
-
- // Expand the container
- var ok = oSelf.doBeforeExpandContainer(oSelf._oTextbox, oSelf._oContainer, sQuery, aResults);
- oSelf._toggleContainer(ok);
- }
- else {
- oSelf._toggleContainer(false);
- }
- oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults);
-};
-
-/**
- * When forceSelection is true and the user attempts
- * leave the text input box without selecting an item from the query results,
- * the user selection is cleared.
- *
- * @method _clearSelection
- * @private
- */
-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;
-
- // Fire custom event
- this.selectionEnforceEvent.fire(this);
-};
-
-/**
- * Whether or not user-typed value in the text input box matches any of the
- * query results.
- *
- * @method _textMatchesOption
- * @return {Boolean} True if user-input text matches a result, false otherwise.
- * @private
- */
-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);
-};
-
-/**
- * Updates in the text input box with the first query result as the user types,
- * selecting the substring that the user has not typed.
- *
- * @method _typeAhead
- * @param oItem {HTMLElement} The <li> element item whose data populates the input field.
- * @param sQuery {String} Query string.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
- // Don't update if turned off
- if (!this.typeAhead || (this._nKeyCode == 8)) {
- return;
- }
-
- var oTextbox = this._oTextbox;
- var sValue = this._oTextbox.value; // any saved queries plus what user has typed
-
- // Don't update with type-ahead if text selection is not supported
- if(!oTextbox.setSelectionRange && !oTextbox.createTextRange) {
- return;
- }
-
- // Select the portion of text that the user has not typed
- 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);
-};
-
-/**
- * Selects text in the input field.
- *
- * @method _selectText
- * @param oTextbox {HTMLElement} Text input box element in which to select text.
- * @param nStart {Number} Starting index of text string to select.
- * @param nEnd {Number} Ending index of text selection.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEnd) {
- if (oTextbox.setSelectionRange) { // For Mozilla
- oTextbox.setSelectionRange(nStart,nEnd);
- }
- else if (oTextbox.createTextRange) { // For IE
- var oTextRange = oTextbox.createTextRange();
- oTextRange.moveStart("character", nStart);
- oTextRange.moveEnd("character", nEnd-oTextbox.value.length);
- oTextRange.select();
- }
- else {
- oTextbox.select();
- }
-};
-
-/**
- * Syncs results container with its helpers.
- *
- * @method _toggleContainerHelpers
- * @param bShow {Boolean} True if container is expanded, false if collapsed
- * @private
- */
-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;
- }
- }
-};
-
-/**
- * Animates expansion or collapse of the container.
- *
- * @method _toggleContainer
- * @param bShow {Boolean} True if container should be expanded, false if container should be collapsed
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
- var oContainer = this._oContainer;
-
- // Implementer has container always open so don't mess with it
- if(this.alwaysShowContainer && this._bContainerOpen) {
- return;
- }
-
- // Clear contents of container
- 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;
- }
-
- // Container is already closed
- if (!bShow && !this._bContainerOpen) {
- oContainer._oContent.style.display = "none";
- return;
- }
-
- // If animation is enabled...
- var oAnim = this._oAnim;
- if (oAnim && oAnim.getEl() && (this.animHoriz || this.animVert)) {
- // If helpers need to be collapsed, do it right away...
- // but if helpers need to be expanded, wait until after the container expands
- if(!bShow) {
- this._toggleContainerHelpers(bShow);
- }
-
- if(oAnim.isAnimated()) {
- oAnim.stop();
- }
-
- // Clone container to grab current size offscreen
- var oClone = oContainer._oContent.cloneNode(true);
- oContainer.appendChild(oClone);
- oClone.style.top = "-9000px";
- oClone.style.display = "block";
-
- // Current size of the container is the EXPANDED size
- var wExp = oClone.offsetWidth;
- var hExp = oClone.offsetHeight;
-
- // Calculate COLLAPSED sizes based on horiz and vert anim
- var wColl = (this.animHoriz) ? 0 : wExp;
- var hColl = (this.animVert) ? 0 : hExp;
-
- // Set animation sizes
- oAnim.attributes = (bShow) ?
- {width: { to: wExp }, height: { to: hExp }} :
- {width: { to: wColl}, height: { to: hColl }};
-
- // If opening anew, set to a collapsed size...
- if(bShow && !this._bContainerOpen) {
- oContainer._oContent.style.width = wColl+"px";
- oContainer._oContent.style.height = hColl+"px";
- }
- // Else, set it to its last known size.
- else {
- oContainer._oContent.style.width = wExp+"px";
- oContainer._oContent.style.height = hExp+"px";
- }
-
- oContainer.removeChild(oClone);
- oClone = null;
-
- var oSelf = this;
- var onAnimComplete = function() {
- // Finish the collapse
- oAnim.onComplete.unsubscribeAll();
-
- if(bShow) {
- oSelf.containerExpandEvent.fire(oSelf);
- }
- else {
- oContainer._oContent.style.display = "none";
- oSelf.containerCollapseEvent.fire(oSelf);
- }
- oSelf._toggleContainerHelpers(bShow);
- };
-
- // Display container and animate it
- oContainer._oContent.style.display = "block";
- oAnim.onComplete.subscribe(onAnimComplete);
- oAnim.animate();
- this._bContainerOpen = bShow;
- }
- // Else don't animate, just show or hide
- 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;
- }
-
-};
-
-/**
- * Toggles the highlight on or off for an item in the container, and also cleans
- * up highlighting of any previous item.
- *
- * @method _toggleHighlight
- * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
- * @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._toggleHighlight = function(oNewItem, sType) {
- var sHighlight = this.highlightClassName;
- if(this._oCurItem) {
- // Remove highlight from old item
- YAHOO.util.Dom.removeClass(this._oCurItem, sHighlight);
- }
-
- if((sType == "to") && sHighlight) {
- // Apply highlight to new item
- YAHOO.util.Dom.addClass(oNewItem, sHighlight);
- this._oCurItem = oNewItem;
- }
-};
-
-/**
- * Toggles the pre-highlight on or off for an item in the container.
- *
- * @method _togglePrehighlight
- * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
- * @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function(oNewItem, sType) {
- if(oNewItem == this._oCurItem) {
- return;
- }
-
- var sPrehighlight = this.prehighlightClassName;
- if((sType == "mouseover") && sPrehighlight) {
- // Apply prehighlight to new item
- YAHOO.util.Dom.addClass(oNewItem, sPrehighlight);
- }
- else {
- // Remove prehighlight from old item
- YAHOO.util.Dom.removeClass(oNewItem, sPrehighlight);
- }
-};
-
-/**
- * Updates the text input box value with selected query result. If a delimiter
- * has been defined, then the value gets appended with the delimiter.
- *
- * @method _updateValue
- * @param oItem {HTMLElement} The <li> element item with which to update the value.
- * @private
- */
-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();
-
- // First clear text field
- oTextbox.value = "";
- // Grab data to put into text field
- if(sDelimChar) {
- if(sSavedQuery) {
- oTextbox.value = sSavedQuery;
- }
- oTextbox.value += sResultKey + sDelimChar;
- if(sDelimChar != " ") {
- oTextbox.value += " ";
- }
- }
- else { oTextbox.value = sResultKey; }
-
- // scroll to bottom of textarea if necessary
- if(oTextbox.type == "textarea") {
- oTextbox.scrollTop = oTextbox.scrollHeight;
- }
-
- // move cursor to end
- var end = oTextbox.value.length;
- this._selectText(oTextbox,end,end);
-
- this._oCurItem = oItem;
-};
-
-/**
- * Selects a result item from the container
- *
- * @method _selectItem
- * @param oItem {HTMLElement} The selected <li> element item.
- * @private
- */
-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);
-};
-
-/**
- * For values updated by type-ahead, the right arrow key jumps to the end
- * of the textbox, otherwise the container is closed.
- *
- * @method _jumpSelection
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._jumpSelection = function() {
- if(!this.typeAhead) {
- return;
- }
- else {
- this._toggleContainer(false);
- }
-};
-
-/**
- * Triggered by up and down arrow keys, changes the current highlighted
- * <li> element item. Scrolls container if necessary.
- *
- * @method _moveSelection
- * @param nKeyCode {Number} Code of key pressed.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
- if(this._bContainerOpen) {
- // Determine current item's id number
- var oCurItem = this._oCurItem;
- var nCurItemIndex = -1;
-
- if (oCurItem) {
- nCurItemIndex = oCurItem._nItemIndex;
- }
-
- var nNewItemIndex = (nKeyCode == 40) ?
- (nCurItemIndex + 1) : (nCurItemIndex - 1);
-
- // Out of bounds
- if (nNewItemIndex < -2 || nNewItemIndex >= this._nDisplayedItems) {
- return;
- }
-
- if (oCurItem) {
- // Unhighlight current item
- this._toggleHighlight(oCurItem, "from");
- this.itemArrowFromEvent.fire(this, oCurItem);
- }
- if (nNewItemIndex == -1) {
- // Go back to query (remove type-ahead string)
- 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) {
- // Close container
- this._toggleContainer(false);
- return;
- }
-
- var oNewItem = this._aListItems[nNewItemIndex];
-
- // Scroll the container if necessary
- 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 < this._nDisplayedItems)) {
- // User is keying down
- if(nKeyCode == 40) {
- // Bottom of selected item is below scroll area...
- if((oNewItem.offsetTop+oNewItem.offsetHeight) > (oContent.scrollTop + oContent.offsetHeight)) {
- // Set bottom of scroll area to bottom of selected item
- oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
- }
- // Bottom of selected item is above scroll area...
- else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) {
- // Set top of selected item to top of scroll area
- oContent.scrollTop = oNewItem.offsetTop;
-
- }
- }
- // User is keying up
- else {
- // Top of selected item is above scroll area
- if(oNewItem.offsetTop < oContent.scrollTop) {
- // Set top of scroll area to top of selected item
- this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
- }
- // Top of selected item is below scroll area
- else if(oNewItem.offsetTop > (oContent.scrollTop + oContent.offsetHeight)) {
- // Set bottom of selected item to bottom of scroll area
- 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);
- }
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles <li> element mouseover events in the container.
- *
- * @method _onItemMouseover
- * @param v {HTMLEvent} The mouseover event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-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);
-};
-
-/**
- * Handles <li> element mouseout events in the container.
- *
- * @method _onItemMouseout
- * @param v {HTMLEvent} The mouseout event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-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);
-};
-
-/**
- * Handles <li> element click events in the container.
- *
- * @method _onItemMouseclick
- * @param v {HTMLEvent} The click event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onItemMouseclick = function(v,oSelf) {
- // In case item has not been moused over
- oSelf._toggleHighlight(this,"to");
- oSelf._selectItem(this);
-};
-
-/**
- * Handles container mouseover events.
- *
- * @method _onContainerMouseover
- * @param v {HTMLEvent} The mouseover event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) {
- oSelf._bOverContainer = true;
-};
-
-/**
- * Handles container mouseout events.
- *
- * @method _onContainerMouseout
- * @param v {HTMLEvent} The mouseout event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onContainerMouseout = function(v,oSelf) {
- oSelf._bOverContainer = false;
- // If container is still active
- if(oSelf._oCurItem) {
- oSelf._toggleHighlight(oSelf._oCurItem,"to");
- }
-};
-
-/**
- * Handles container scroll events.
- *
- * @method _onContainerScroll
- * @param v {HTMLEvent} The scroll event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) {
- oSelf._oTextbox.focus();
-};
-
-/**
- * Handles container resize events.
- *
- * @method _onContainerResize
- * @param v {HTMLEvent} The resize event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onContainerResize = function(v,oSelf) {
- oSelf._toggleContainerHelpers(oSelf._bContainerOpen);
-};
-
-
-/**
- * Handles textbox keydown events of functional keys, mainly for UI behavior.
- *
- * @method _onTextboxKeyDown
- * @param v {HTMLEvent} The keydown event.
- * @param oSelf {object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) {
- var nKeyCode = v.keyCode;
-
- switch (nKeyCode) {
- case 9: // tab
- if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
- if(oSelf._bContainerOpen) {
- YAHOO.util.Event.stopEvent(v);
- }
- }
- // select an item or clear out
- if(oSelf._oCurItem) {
- oSelf._selectItem(oSelf._oCurItem);
- }
- else {
- oSelf._toggleContainer(false);
- }
- break;
- case 13: // enter
- 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: // esc
- oSelf._toggleContainer(false);
- return;
- case 39: // right
- oSelf._jumpSelection();
- break;
- case 38: // up
- YAHOO.util.Event.stopEvent(v);
- oSelf._moveSelection(nKeyCode);
- break;
- case 40: // down
- YAHOO.util.Event.stopEvent(v);
- oSelf._moveSelection(nKeyCode);
- break;
- default:
- break;
- }
-};
-
-/**
- * Handles textbox keypress events.
- * @method _onTextboxKeyPress
- * @param v {HTMLEvent} The keypress event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) {
- var nKeyCode = v.keyCode;
-
- //Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337)
- var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1);
- if(isMac) {
- switch (nKeyCode) {
- case 9: // tab
- if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
- if(oSelf._bContainerOpen) {
- YAHOO.util.Event.stopEvent(v);
- }
- }
- break;
- case 13: // enter
- if(oSelf._nKeyCode != nKeyCode) {
- if(oSelf._bContainerOpen) {
- YAHOO.util.Event.stopEvent(v);
- }
- }
- break;
- case 38: // up
- case 40: // down
- YAHOO.util.Event.stopEvent(v);
- break;
- default:
- break;
- }
- }
-
- //TODO: (?) limit only to non-IE, non-Mac-FF for Korean IME support (bug 811948)
- // Korean IME detected
- else if(nKeyCode == 229) {
- oSelf._queryInterval = setInterval(function() { oSelf._onIMEDetected(oSelf); },500);
- }
-};
-
-/**
- * Handles textbox keyup events that trigger queries.
- *
- * @method _onTextboxKeyUp
- * @param v {HTMLEvent} The keyup event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
- // Check to see if any of the public properties have been updated
- oSelf._initProps();
-
- var nKeyCode = v.keyCode;
- oSelf._nKeyCode = nKeyCode;
- var sText = this.value; //string in textbox
-
- // Filter out chars that don't trigger queries
- if (oSelf._isIgnoreKey(nKeyCode) || (sText.toLowerCase() == oSelf._sCurQuery)) {
- return;
- }
- else {
- oSelf.textboxKeyEvent.fire(oSelf, nKeyCode);
- }
-
- // Set timeout on the request
- 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 {
- // No delay so send request immediately
- oSelf._sendQuery(sText);
- }
-};
-
-/**
- * Handles text input box receiving focus.
- *
- * @method _onTextboxFocus
- * @param v {HTMLEvent} The focus event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
- oSelf._oTextbox.setAttribute("autocomplete","off");
- oSelf._bFocused = true;
- oSelf.textboxFocusEvent.fire(oSelf);
-};
-
-/**
- * Handles text input box losing focus.
- *
- * @method _onTextboxBlur
- * @param v {HTMLEvent} The focus event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
- // Don't treat as a blur if it was a selection via mouse click
- if(!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
- // Current query needs to be validated
- 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);
- }
-};
-
-/**
- * Handles form submission event.
- *
- * @method _onFormSubmit
- * @param v {HTMLEvent} The submit event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
- if(oSelf.allowBrowserAutocomplete) {
- oSelf._oTextbox.setAttribute("autocomplete","on");
- }
- else {
- 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 AutoComplete control provides the front-end logic for text-entry suggestion and
+ * completion functionality.
+ *
+ * @module autocomplete
+ * @requires yahoo, dom, event, datasource
+ * @optional animation, connection
+ * @namespace YAHOO.widget
+ * @title AutoComplete Widget
+ */
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The AutoComplete class provides the customizable functionality of a plug-and-play DHTML
+ * auto completion widget. Some key features:
+ *
+ * Navigate with up/down arrow keys and/or mouse to pick a selection
+ * The drop down container can "roll down" or "fly out" via configurable
+ * animation
+ * UI look-and-feel customizable through CSS, including container
+ * attributes, borders, position, fonts, etc
+ *
+ *
+ * @class AutoComplete
+ * @constructor
+ * @param elInput {HTMLElement} DOM element reference of an input field.
+ * @param elInput {String} String ID of an input field.
+ * @param elContainer {HTMLElement} DOM element reference of an existing DIV.
+ * @param elContainer {String} String ID of an existing DIV.
+ * @param oDataSource {YAHOO.widget.DataSource} DataSource instance.
+ * @param oConfigs {Object} (optional) Object literal of configuration params.
+ */
+YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
+ if(elInput && elContainer && oDataSource) {
+ // Validate DataSource
+ if(oDataSource instanceof YAHOO.widget.DataSource) {
+ this.dataSource = oDataSource;
+ }
+ else {
+ YAHOO.log("Could not instantiate AutoComplete due to an invalid DataSource", "error", this.toString());
+ return;
+ }
+
+ // Validate input element
+ if(YAHOO.util.Dom.inDocument(elInput)) {
+ if(YAHOO.lang.isString(elInput)) {
+ 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;
+ }
+ YAHOO.util.Dom.addClass(this._oTextbox, "yui-ac-input");
+ }
+ else {
+ YAHOO.log("Could not instantiate AutoComplete due to an invalid input element", "error", this.toString());
+ return;
+ }
+
+ // Validate container element
+ if(YAHOO.util.Dom.inDocument(elContainer)) {
+ if(YAHOO.lang.isString(elContainer)) {
+ this._oContainer = document.getElementById(elContainer);
+ }
+ else {
+ this._oContainer = elContainer;
+ }
+ if(this._oContainer.style.display == "none") {
+ YAHOO.log("The container may not display properly if display is set to \"none\" in CSS", "warn", this.toString());
+ }
+
+ // For skinning
+ var elParent = this._oContainer.parentNode;
+ var elTag = elParent.tagName.toLowerCase();
+ while(elParent && (elParent != "document")) {
+ if(elTag == "div") {
+ YAHOO.util.Dom.addClass(elParent, "yui-ac");
+ break;
+ }
+ else {
+ elParent = elParent.parentNode;
+ elTag = elParent.tagName.toLowerCase();
+ }
+ }
+ if(elTag != "div") {
+ YAHOO.log("Could not find an appropriate parent container for skinning", "warn", this.toString());
+ }
+ }
+ else {
+ YAHOO.log("Could not instantiate AutoComplete due to an invalid container element", "error", this.toString());
+ return;
+ }
+
+ // Set any config params passed in to override defaults
+ if(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ if(sConfig) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+ }
+
+ // Initialization sequence
+ this._initContainer();
+ this._initProps();
+ this._initList();
+ this._initContainerHelpers();
+
+ // Set up events
+ var oSelf = this;
+ var oTextbox = this._oTextbox;
+ // Events are actually for the content module within the container
+ var oContent = this._oContainer._oContent;
+
+ // Dom events
+ 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);
+
+ // Custom events
+ 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);
+
+ // Finish up
+ oTextbox.setAttribute("autocomplete","off");
+ YAHOO.widget.AutoComplete._nIndex++;
+ YAHOO.log("AutoComplete initialized","info",this.toString());
+ }
+ // Required arguments were not found
+ else {
+ YAHOO.log("Could not instantiate AutoComplete due invalid arguments", "error", this.toString());
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * The DataSource object that encapsulates the data used for auto completion.
+ * This object should be an inherited object from YAHOO.widget.DataSource.
+ *
+ * @property dataSource
+ * @type YAHOO.widget.DataSource
+ */
+YAHOO.widget.AutoComplete.prototype.dataSource = null;
+
+/**
+ * Number of characters that must be entered before querying for results. A negative value
+ * effectively turns off the widget. A value of 0 allows queries of null or empty string
+ * values.
+ *
+ * @property minQueryLength
+ * @type Number
+ * @default 1
+ */
+YAHOO.widget.AutoComplete.prototype.minQueryLength = 1;
+
+/**
+ * Maximum number of results to display in results container.
+ *
+ * @property maxResultsDisplayed
+ * @type Number
+ * @default 10
+ */
+YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed = 10;
+
+/**
+ * Number of seconds to delay before submitting a query request. If a query
+ * request is received before a previous one has completed its delay, the
+ * previous request is cancelled and the new request is set to the delay.
+ * Implementers should take care when setting this value very low (i.e., less
+ * than 0.2) with low latency DataSources and the typeAhead feature enabled, as
+ * fast typers may see unexpected behavior.
+ *
+ * @property queryDelay
+ * @type Number
+ * @default 0.2
+ */
+YAHOO.widget.AutoComplete.prototype.queryDelay = 0.2;
+
+/**
+ * Class name of a highlighted item within results container.
+ *
+ * @property highlightClassName
+ * @type String
+ * @default "yui-ac-highlight"
+ */
+YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight";
+
+/**
+ * Class name of a pre-highlighted item within results container.
+ *
+ * @property prehighlightClassName
+ * @type String
+ */
+YAHOO.widget.AutoComplete.prototype.prehighlightClassName = null;
+
+/**
+ * Query delimiter. A single character separator for multiple delimited
+ * selections. Multiple delimiter characteres may be defined as an array of
+ * strings. A null value or empty string indicates that query results cannot
+ * be delimited. This feature is not recommended if you need forceSelection to
+ * be true.
+ *
+ * @property delimChar
+ * @type String | String[]
+ */
+YAHOO.widget.AutoComplete.prototype.delimChar = null;
+
+/**
+ * Whether or not the first item in results container should be automatically highlighted
+ * on expand.
+ *
+ * @property autoHighlight
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.AutoComplete.prototype.autoHighlight = true;
+
+/**
+ * Whether or not the input field should be automatically updated
+ * with the first query result as the user types, auto-selecting the substring
+ * that the user has not typed.
+ *
+ * @property typeAhead
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.typeAhead = false;
+
+/**
+ * Whether or not to animate the expansion/collapse of the results container in the
+ * horizontal direction.
+ *
+ * @property animHoriz
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.animHoriz = false;
+
+/**
+ * Whether or not to animate the expansion/collapse of the results container in the
+ * vertical direction.
+ *
+ * @property animVert
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.AutoComplete.prototype.animVert = true;
+
+/**
+ * Speed of container expand/collapse animation, in seconds..
+ *
+ * @property animSpeed
+ * @type Number
+ * @default 0.3
+ */
+YAHOO.widget.AutoComplete.prototype.animSpeed = 0.3;
+
+/**
+ * Whether or not to force the user's selection to match one of the query
+ * results. Enabling this feature essentially transforms the input field into a
+ * <select> field. This feature is not recommended with delimiter character(s)
+ * defined.
+ *
+ * @property forceSelection
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.forceSelection = false;
+
+/**
+ * Whether or not to allow browsers to cache user-typed input in the input
+ * field. Disabling this feature will prevent the widget from setting the
+ * autocomplete="off" on the input field. When autocomplete="off"
+ * and users click the back button after form submission, user-typed input can
+ * be prefilled by the browser from its cache. This caching of user input may
+ * not be desired for sensitive data, such as credit card numbers, in which
+ * case, implementers should consider setting allowBrowserAutocomplete to false.
+ *
+ * @property allowBrowserAutocomplete
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true;
+
+/**
+ * Whether or not the results container should always be displayed.
+ * Enabling this feature displays the container when the widget is instantiated
+ * and prevents the toggling of the container to a collapsed state.
+ *
+ * @property alwaysShowContainer
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.alwaysShowContainer = false;
+
+/**
+ * Whether or not to use an iFrame to layer over Windows form elements in
+ * IE. Set to true only when the results container will be on top of a
+ * <select> field in IE and thus exposed to the IE z-index bug (i.e.,
+ * 5.5 < IE < 7).
+ *
+ * @property useIFrame
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.useIFrame = false;
+
+/**
+ * Whether or not the results container should have a shadow.
+ *
+ * @property useShadow
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.useShadow = false;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the AutoComplete instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.toString = function() {
+ return "AutoComplete " + this._sName;
+};
+
+ /**
+ * Returns true if container is in an expanded state, false otherwise.
+ *
+ * @method isContainerOpen
+ * @return {Boolean} Returns true if container is in an expanded state, false otherwise.
+ */
+YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() {
+ return this._bContainerOpen;
+};
+
+/**
+ * Public accessor to the internal array of DOM <li> elements that
+ * display query results within the results container.
+ *
+ * @method getListItems
+ * @return {HTMLElement[]} Array of <li> elements within the results container.
+ */
+YAHOO.widget.AutoComplete.prototype.getListItems = function() {
+ return this._aListItems;
+};
+
+/**
+ * Public accessor to the data held in an <li> element of the
+ * results container.
+ *
+ * @method getListItemData
+ * @return {Object | Object[]} Object or array of result data or null
+ */
+YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
+ if(oListItem._oResultData) {
+ return oListItem._oResultData;
+ }
+ else {
+ return false;
+ }
+};
+
+/**
+ * Sets HTML markup for the results container header. This markup will be
+ * inserted within a <div> tag with a class of "yui-ac-hd".
+ *
+ * @method setHeader
+ * @param sHeader {String} HTML markup for results container header.
+ */
+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";
+ }
+};
+
+/**
+ * Sets HTML markup for the results container footer. This markup will be
+ * inserted within a <div> tag with a class of "yui-ac-ft".
+ *
+ * @method setFooter
+ * @param sFooter {String} HTML markup for results container footer.
+ */
+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";
+ }
+};
+
+/**
+ * Sets HTML markup for the results container body. This markup will be
+ * inserted within a <div> tag with a class of "yui-ac-bd".
+ *
+ * @method setBody
+ * @param sBody {String} HTML markup for results container body.
+ */
+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;
+};
+
+/**
+ * Overridable method that converts a result item object into HTML markup
+ * for display. Return data values are accessible via the oResultItem object,
+ * and the key return value will always be oResultItem[0]. Markup will be
+ * displayed within <li> element tags in the container.
+ *
+ * @method formatResult
+ * @param oResultItem {Object} Result item representing one query result. Data is held in an array.
+ * @param sQuery {String} The current query string.
+ * @return {String} HTML markup of formatted result data.
+ */
+YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery) {
+ var sResult = oResultItem[0];
+ if(sResult) {
+ return sResult;
+ }
+ else {
+ return "";
+ }
+};
+
+/**
+ * Overridable method called before container expands allows implementers to access data
+ * and DOM elements.
+ *
+ * @method doBeforeExpandContainer
+ * @param oTextbox {HTMLElement} The text input box.
+ * @param oContainer {HTMLElement} The container element.
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} An array of query results.
+ * @return {Boolean} Return true to continue expanding container, false to cancel the expand.
+ */
+YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {
+ return true;
+};
+
+/**
+ * Makes query request to the DataSource.
+ *
+ * @method sendQuery
+ * @param sQuery {String} Query string.
+ */
+YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) {
+ this._sendQuery(sQuery);
+};
+
+/**
+ * Overridable method gives implementers access to the query before it gets sent.
+ *
+ * @method doBeforeSendQuery
+ * @param sQuery {String} Query string.
+ * @return {String} Query string.
+ */
+YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery = function(sQuery) {
+ return sQuery;
+};
+
+/**
+ * Nulls out the entire AutoComplete instance and related objects, removes attached
+ * event listeners, and clears out DOM elements inside the container. After
+ * calling this method, the instance reference should be expliclitly nulled by
+ * implementer, as in myDataTable = null. Use with caution!
+ *
+ * @method destroy
+ */
+YAHOO.widget.AutoComplete.prototype.destroy = function() {
+ var instanceName = this.toString();
+ var elInput = this._oTextbox;
+ var elContainer = this._oContainer;
+
+ // Unhook custom events
+ this.textboxFocusEvent.unsubscribe();
+ this.textboxKeyEvent.unsubscribe();
+ this.dataRequestEvent.unsubscribe();
+ this.dataReturnEvent.unsubscribe();
+ this.dataErrorEvent.unsubscribe();
+ this.containerExpandEvent.unsubscribe();
+ this.typeAheadEvent.unsubscribe();
+ this.itemMouseOverEvent.unsubscribe();
+ this.itemMouseOutEvent.unsubscribe();
+ this.itemArrowToEvent.unsubscribe();
+ this.itemArrowFromEvent.unsubscribe();
+ this.itemSelectEvent.unsubscribe();
+ this.unmatchedItemSelectEvent.unsubscribe();
+ this.selectionEnforceEvent.unsubscribe();
+ this.containerCollapseEvent.unsubscribe();
+ this.textboxBlurEvent.unsubscribe();
+
+ // Unhook DOM events
+ YAHOO.util.Event.purgeElement(elInput, true);
+ YAHOO.util.Event.purgeElement(elContainer, true);
+
+ // Remove DOM elements
+ elContainer.innerHTML = "";
+
+ // Null out objects
+ for(var key in this) {
+ if(this.hasOwnProperty(key)) {
+ this[key] = null;
+ }
+ }
+
+ YAHOO.log("AutoComplete instance destroyed: " + instanceName);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public events
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Fired when the input field receives focus.
+ *
+ * @event textboxFocusEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null;
+
+/**
+ * Fired when the input field receives key input.
+ *
+ * @event textboxKeyEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param nKeycode {Number} The keycode number.
+ */
+YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null;
+
+/**
+ * Fired when the AutoComplete instance makes a query to the DataSource.
+ *
+ * @event dataRequestEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The query string.
+ */
+YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null;
+
+/**
+ * Fired when the AutoComplete instance receives query results from the data
+ * source.
+ *
+ * @event dataReturnEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} Results array.
+ */
+YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
+
+/**
+ * Fired when the AutoComplete instance does not receive query results from the
+ * DataSource due to an error.
+ *
+ * @event dataErrorEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The query string.
+ */
+YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
+
+/**
+ * Fired when the results container is expanded.
+ *
+ * @event containerExpandEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
+
+/**
+ * Fired when the input field has been prefilled by the type-ahead
+ * feature.
+ *
+ * @event typeAheadEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The query string.
+ * @param sPrefill {String} The prefill string.
+ */
+YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null;
+
+/**
+ * Fired when result item has been moused over.
+ *
+ * @event itemMouseOverEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The <li> element item moused to.
+ */
+YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
+
+/**
+ * Fired when result item has been moused out.
+ *
+ * @event itemMouseOutEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The <li> element item moused from.
+ */
+YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
+
+/**
+ * Fired when result item has been arrowed to.
+ *
+ * @event itemArrowToEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The <li> element item arrowed to.
+ */
+YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null;
+
+/**
+ * Fired when result item has been arrowed away from.
+ *
+ * @event itemArrowFromEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The <li> element item arrowed from.
+ */
+YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent = null;
+
+/**
+ * Fired when an item is selected via mouse click, ENTER key, or TAB key.
+ *
+ * @event itemSelectEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The selected <li> element item.
+ * @param oData {Object} The data returned for the item, either as an object,
+ * or mapped from the schema into an array.
+ */
+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.
+ *
+ * @event unmatchedItemSelectEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The user-typed query string.
+ */
+YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
+
+/**
+ * Fired if forceSelection is enabled and the user's input has been cleared
+ * because it did not match one of the returned query results.
+ *
+ * @event selectionEnforceEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
+
+/**
+ * Fired when the results container is collapsed.
+ *
+ * @event containerCollapseEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null;
+
+/**
+ * Fired when the input field loses focus.
+ *
+ * @event textboxBlurEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Internal class variable to index multiple AutoComplete instances.
+ *
+ * @property _nIndex
+ * @type Number
+ * @default 0
+ * @private
+ */
+YAHOO.widget.AutoComplete._nIndex = 0;
+
+/**
+ * Name of AutoComplete instance.
+ *
+ * @property _sName
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sName = null;
+
+/**
+ * Text input field DOM element.
+ *
+ * @property _oTextbox
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oTextbox = null;
+
+/**
+ * Whether or not the input field is currently in focus. If query results come back
+ * but the user has already moved on, do not proceed with auto complete behavior.
+ *
+ * @property _bFocused
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bFocused = true;
+
+/**
+ * Animation instance for container expand/collapse.
+ *
+ * @property _oAnim
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oAnim = null;
+
+/**
+ * Container DOM element.
+ *
+ * @property _oContainer
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oContainer = null;
+
+/**
+ * Whether or not the results container is currently open.
+ *
+ * @property _bContainerOpen
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;
+
+/**
+ * Whether or not the mouse is currently over the results
+ * container. This is necessary in order to prevent clicks on container items
+ * from being text input field blur events.
+ *
+ * @property _bOverContainer
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bOverContainer = false;
+
+/**
+ * Array of <li> elements references that contain query results within the
+ * results container.
+ *
+ * @property _aListItems
+ * @type HTMLElement[]
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._aListItems = null;
+
+/**
+ * Number of <li> elements currently displayed in results container.
+ *
+ * @property _nDisplayedItems
+ * @type Number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0;
+
+/**
+ * Internal count of <li> elements displayed and hidden in results container.
+ *
+ * @property _maxResultsDisplayed
+ * @type Number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0;
+
+/**
+ * Current query string
+ *
+ * @property _sCurQuery
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sCurQuery = null;
+
+/**
+ * Past queries this session (for saving delimited queries).
+ *
+ * @property _sSavedQuery
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sSavedQuery = null;
+
+/**
+ * Pointer to the currently highlighted <li> element in the container.
+ *
+ * @property _oCurItem
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oCurItem = null;
+
+/**
+ * Whether or not an item has been selected since the container was populated
+ * with results. Reset to false by _populateList, and set to true when item is
+ * selected.
+ *
+ * @property _bItemSelected
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bItemSelected = false;
+
+/**
+ * Key code of the last key pressed in textbox.
+ *
+ * @property _nKeyCode
+ * @type Number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nKeyCode = null;
+
+/**
+ * Delay timeout ID.
+ *
+ * @property _nDelayID
+ * @type Number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nDelayID = -1;
+
+/**
+ * Src to iFrame used when useIFrame = true. Supports implementations over SSL
+ * as well.
+ *
+ * @property _iFrameSrc
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;";
+
+/**
+ * For users typing via certain IMEs, queries must be triggered by intervals,
+ * since key events yet supported across all browsers for all IMEs.
+ *
+ * @property _queryInterval
+ * @type Object
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._queryInterval = null;
+
+/**
+ * Internal tracker to last known textbox value, used to determine whether or not
+ * to trigger a query via interval for certain IME users.
+ *
+ * @event _sLastTextboxValue
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Updates and validates latest public config properties.
+ *
+ * @method __initProps
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initProps = function() {
+ // Correct any invalid values
+ var minQueryLength = this.minQueryLength;
+ if(!YAHOO.lang.isNumber(minQueryLength)) {
+ this.minQueryLength = 1;
+ }
+ var maxResultsDisplayed = this.maxResultsDisplayed;
+ if(!YAHOO.lang.isNumber(maxResultsDisplayed) || (maxResultsDisplayed < 1)) {
+ this.maxResultsDisplayed = 10;
+ }
+ var queryDelay = this.queryDelay;
+ if(!YAHOO.lang.isNumber(queryDelay) || (queryDelay < 0)) {
+ this.queryDelay = 0.2;
+ }
+ var delimChar = this.delimChar;
+ if(YAHOO.lang.isString(delimChar)) {
+ this.delimChar = [delimChar];
+ }
+ else if(!YAHOO.lang.isArray(delimChar)) {
+ this.delimChar = null;
+ }
+ var animSpeed = this.animSpeed;
+ if((this.animHoriz || this.animVert) && YAHOO.util.Anim) {
+ if(!YAHOO.lang.isNumber(animSpeed) || (animSpeed < 0)) {
+ this.animSpeed = 0.3;
+ }
+ if(!this._oAnim ) {
+ this._oAnim = new YAHOO.util.Anim(this._oContainer._oContent, {}, this.animSpeed);
+ }
+ else {
+ this._oAnim.duration = this.animSpeed;
+ }
+ }
+ if(this.forceSelection && delimChar) {
+ YAHOO.log("The forceSelection feature has been enabled with delimChar defined.","warn", this.toString());
+ }
+};
+
+/**
+ * Initializes the results container helpers if they are enabled and do
+ * not exist
+ *
+ * @method _initContainerHelpers
+ * @private
+ */
+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);
+ }
+};
+
+/**
+ * Initializes the results container once at object creation
+ *
+ * @method _initContainer
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initContainer = function() {
+ YAHOO.util.Dom.addClass(this._oContainer, "yui-ac-container");
+
+ if(!this._oContainer._oContent) {
+ // The oContent div helps size the iframe and shadow properly
+ 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.log("Could not initialize the container","warn",this.toString());
+ }
+};
+
+/**
+ * Clears out contents of container body and creates up to
+ * YAHOO.widget.AutoComplete#maxResultsDisplayed <li> elements in an
+ * <ul> element.
+ *
+ * @method _initList
+ * @private
+ */
+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; oldi--) {
+ 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) || // alt,pause/break,caps lock
+ (nKeyCode == 27) || // esc
+ (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end
+ /*(nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up
+ (nKeyCode == 40) || // down*/
+ (nKeyCode >= 36 && nKeyCode <= 40) || // home,left,up, right, down
+ (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert
+ return true;
+ }
+ return false;
+};
+
+/**
+ * Makes query request to the DataSource.
+ *
+ * @method _sendQuery
+ * @param sQuery {String} Query string.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) {
+ // Widget has been effectively turned off
+ if(this.minQueryLength == -1) {
+ this._toggleContainer(false);
+ YAHOO.log("Property minQueryLength is set to -1", "info", this.toString());
+ return;
+ }
+ // Delimiter has been enabled
+ var aDelimChar = (this.delimChar) ? this.delimChar : null;
+ if(aDelimChar) {
+ // Loop through all possible delimiters and find the latest one
+ // A " " may be a false positive if they are defined as delimiters AND
+ // are used to separate delimited queries
+ var nDelimIndex = -1;
+ for(var i = aDelimChar.length-1; i >= 0; i--) {
+ var nNewIndex = sQuery.lastIndexOf(aDelimChar[i]);
+ if(nNewIndex > nDelimIndex) {
+ nDelimIndex = nNewIndex;
+ }
+ }
+ // If we think the last delimiter is a space (" "), make sure it is NOT
+ // a false positive by also checking the char directly before it
+ if(aDelimChar[i] == " ") {
+ for (var j = aDelimChar.length-1; j >= 0; j--) {
+ if(sQuery[nDelimIndex - 1] == aDelimChar[j]) {
+ nDelimIndex--;
+ break;
+ }
+ }
+ }
+ // A delimiter has been found so extract the latest query
+ if(nDelimIndex > -1) {
+ var nQueryStart = nDelimIndex + 1;
+ // Trim any white space from the beginning...
+ while(sQuery.charAt(nQueryStart) == " ") {
+ nQueryStart += 1;
+ }
+ // ...and save the rest of the string for later
+ this._sSavedQuery = sQuery.substring(0,nQueryStart);
+ // Here is the query itself
+ sQuery = sQuery.substr(nQueryStart);
+ }
+ else if(sQuery.indexOf(this._sSavedQuery) < 0){
+ this._sSavedQuery = null;
+ }
+ }
+
+ // Don't search queries that are too short
+ if((sQuery && (sQuery.length < this.minQueryLength)) || (!sQuery && this.minQueryLength > 0)) {
+ if(this._nDelayID != -1) {
+ clearTimeout(this._nDelayID);
+ }
+ this._toggleContainer(false);
+ YAHOO.log("Query \"" + sQuery + "\" is too short", "info", this.toString());
+ return;
+ }
+
+ sQuery = encodeURIComponent(sQuery);
+ this._nDelayID = -1; // Reset timeout ID because request has been made
+ sQuery = this.doBeforeSendQuery(sQuery);
+ this.dataRequestEvent.fire(this, sQuery);
+ YAHOO.log("Sending query \"" + sQuery + "\"", "info", this.toString());
+ this.dataSource.getResults(this._populateList, sQuery, this);
+};
+
+/**
+ * Populates the array of <li> elements in the container with query
+ * results. This method is passed to YAHOO.widget.DataSource#getResults as a
+ * callback function so results from the DataSource instance are returned to the
+ * AutoComplete instance.
+ *
+ * @method _populateList
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} An array of query result objects from the DataSource.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._populateList = function(sQuery, aResults, oSelf) {
+ if(aResults === null) {
+ oSelf.dataErrorEvent.fire(oSelf, sQuery);
+ }
+ if(!oSelf._bFocused || !aResults) {
+ YAHOO.log("Could not populate list", "info", oSelf.toString());
+ 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;
+
+ // Fill items with data
+ 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;
+
+ }
+
+ // Empty out remaining items if any
+ 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;
+ }
+
+ // Expand the container
+ var ok = oSelf.doBeforeExpandContainer(oSelf._oTextbox, oSelf._oContainer, sQuery, aResults);
+ oSelf._toggleContainer(ok);
+
+ if(oSelf.autoHighlight) {
+ // Go to the first item
+ var oFirstItem = aItems[0];
+ oSelf._toggleHighlight(oFirstItem,"to");
+ oSelf.itemArrowToEvent.fire(oSelf, oFirstItem);
+ YAHOO.log("Arrowed to first item", "info", oSelf.toString());
+ oSelf._typeAhead(oFirstItem,sQuery);
+ }
+ else {
+ oSelf._oCurItem = null;
+ }
+ }
+ else {
+ oSelf._toggleContainer(false);
+ }
+ oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults);
+ YAHOO.log("Container populated with list items", "info", oSelf.toString());
+
+};
+
+/**
+ * When forceSelection is true and the user attempts
+ * leave the text input box without selecting an item from the query results,
+ * the user selection is cleared.
+ *
+ * @method _clearSelection
+ * @private
+ */
+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;
+
+ // Fire custom event
+ this.selectionEnforceEvent.fire(this);
+ YAHOO.log("Selection enforced", "info", this.toString());
+};
+
+/**
+ * Whether or not user-typed value in the text input box matches any of the
+ * query results.
+ *
+ * @method _textMatchesOption
+ * @return {HTMLElement} Matching list item element if user-input text matches
+ * a result, null otherwise.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._textMatchesOption = function() {
+ var foundMatch = null;
+
+ 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 = oItem;
+ break;
+ }
+ }
+ return(foundMatch);
+};
+
+/**
+ * Updates in the text input box with the first query result as the user types,
+ * selecting the substring that the user has not typed.
+ *
+ * @method _typeAhead
+ * @param oItem {HTMLElement} The <li> element item whose data populates the input field.
+ * @param sQuery {String} Query string.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
+ // Don't update if turned off
+ if(!this.typeAhead || (this._nKeyCode == 8)) {
+ return;
+ }
+
+ var oTextbox = this._oTextbox;
+ var sValue = this._oTextbox.value; // any saved queries plus what user has typed
+
+ // Don't update with type-ahead if text selection is not supported
+ if(!oTextbox.setSelectionRange && !oTextbox.createTextRange) {
+ return;
+ }
+
+ // Select the portion of text that the user has not typed
+ 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.log("Typeahead occured with prefill string \"" + sPrefill + "\"", "info", this.toString());
+};
+
+/**
+ * Selects text in the input field.
+ *
+ * @method _selectText
+ * @param oTextbox {HTMLElement} Text input box element in which to select text.
+ * @param nStart {Number} Starting index of text string to select.
+ * @param nEnd {Number} Ending index of text selection.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEnd) {
+ if(oTextbox.setSelectionRange) { // For Mozilla
+ oTextbox.setSelectionRange(nStart,nEnd);
+ }
+ else if(oTextbox.createTextRange) { // For IE
+ var oTextRange = oTextbox.createTextRange();
+ oTextRange.moveStart("character", nStart);
+ oTextRange.moveEnd("character", nEnd-oTextbox.value.length);
+ oTextRange.select();
+ }
+ else {
+ oTextbox.select();
+ }
+};
+
+/**
+ * Syncs results container with its helpers.
+ *
+ * @method _toggleContainerHelpers
+ * @param bShow {Boolean} True if container is expanded, false if collapsed
+ * @private
+ */
+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;
+ }
+ }
+};
+
+/**
+ * Animates expansion or collapse of the container.
+ *
+ * @method _toggleContainer
+ * @param bShow {Boolean} True if container should be expanded, false if container should be collapsed
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
+ var oContainer = this._oContainer;
+
+ // Implementer has container always open so don't mess with it
+ if(this.alwaysShowContainer && this._bContainerOpen) {
+ return;
+ }
+
+ // Clear contents of container
+ 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;
+ }
+
+ // Container is already closed
+ if(!bShow && !this._bContainerOpen) {
+ oContainer._oContent.style.display = "none";
+ return;
+ }
+
+ // If animation is enabled...
+ var oAnim = this._oAnim;
+ if(oAnim && oAnim.getEl() && (this.animHoriz || this.animVert)) {
+ // If helpers need to be collapsed, do it right away...
+ // but if helpers need to be expanded, wait until after the container expands
+ if(!bShow) {
+ this._toggleContainerHelpers(bShow);
+ }
+
+ if(oAnim.isAnimated()) {
+ oAnim.stop();
+ }
+
+ // Clone container to grab current size offscreen
+ var oClone = oContainer._oContent.cloneNode(true);
+ oContainer.appendChild(oClone);
+ oClone.style.top = "-9000px";
+ oClone.style.display = "block";
+
+ // Current size of the container is the EXPANDED size
+ var wExp = oClone.offsetWidth;
+ var hExp = oClone.offsetHeight;
+
+ // Calculate COLLAPSED sizes based on horiz and vert anim
+ var wColl = (this.animHoriz) ? 0 : wExp;
+ var hColl = (this.animVert) ? 0 : hExp;
+
+ // Set animation sizes
+ oAnim.attributes = (bShow) ?
+ {width: { to: wExp }, height: { to: hExp }} :
+ {width: { to: wColl}, height: { to: hColl }};
+
+ // If opening anew, set to a collapsed size...
+ if(bShow && !this._bContainerOpen) {
+ oContainer._oContent.style.width = wColl+"px";
+ oContainer._oContent.style.height = hColl+"px";
+ }
+ // Else, set it to its last known size.
+ else {
+ oContainer._oContent.style.width = wExp+"px";
+ oContainer._oContent.style.height = hExp+"px";
+ }
+
+ oContainer.removeChild(oClone);
+ oClone = null;
+
+ var oSelf = this;
+ var onAnimComplete = function() {
+ // Finish the collapse
+ oAnim.onComplete.unsubscribeAll();
+
+ if(bShow) {
+ oSelf.containerExpandEvent.fire(oSelf);
+ YAHOO.log("Container expanded", "info", oSelf.toString());
+ }
+ else {
+ oContainer._oContent.style.display = "none";
+ oSelf.containerCollapseEvent.fire(oSelf);
+ YAHOO.log("Container collapsed", "info", oSelf.toString());
+ }
+ oSelf._toggleContainerHelpers(bShow);
+ };
+
+ // Display container and animate it
+ oContainer._oContent.style.display = "block";
+ oAnim.onComplete.subscribe(onAnimComplete);
+ oAnim.animate();
+ this._bContainerOpen = bShow;
+ }
+ // Else don't animate, just show or hide
+ else {
+ if(bShow) {
+ oContainer._oContent.style.display = "block";
+ this.containerExpandEvent.fire(this);
+ YAHOO.log("Container expanded", "info", this.toString());
+ }
+ else {
+ oContainer._oContent.style.display = "none";
+ this.containerCollapseEvent.fire(this);
+ YAHOO.log("Container collapsed", "info", this.toString());
+ }
+ this._toggleContainerHelpers(bShow);
+ this._bContainerOpen = bShow;
+ }
+
+};
+
+/**
+ * Toggles the highlight on or off for an item in the container, and also cleans
+ * up highlighting of any previous item.
+ *
+ * @method _toggleHighlight
+ * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
+ * @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleHighlight = function(oNewItem, sType) {
+ var sHighlight = this.highlightClassName;
+ if(this._oCurItem) {
+ // Remove highlight from old item
+ YAHOO.util.Dom.removeClass(this._oCurItem, sHighlight);
+ }
+
+ if((sType == "to") && sHighlight) {
+ // Apply highlight to new item
+ YAHOO.util.Dom.addClass(oNewItem, sHighlight);
+ this._oCurItem = oNewItem;
+ }
+};
+
+/**
+ * Toggles the pre-highlight on or off for an item in the container.
+ *
+ * @method _togglePrehighlight
+ * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
+ * @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function(oNewItem, sType) {
+ if(oNewItem == this._oCurItem) {
+ return;
+ }
+
+ var sPrehighlight = this.prehighlightClassName;
+ if((sType == "mouseover") && sPrehighlight) {
+ // Apply prehighlight to new item
+ YAHOO.util.Dom.addClass(oNewItem, sPrehighlight);
+ }
+ else {
+ // Remove prehighlight from old item
+ YAHOO.util.Dom.removeClass(oNewItem, sPrehighlight);
+ }
+};
+
+/**
+ * Updates the text input box value with selected query result. If a delimiter
+ * has been defined, then the value gets appended with the delimiter.
+ *
+ * @method _updateValue
+ * @param oItem {HTMLElement} The <li> element item with which to update the value.
+ * @private
+ */
+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();
+
+ // First clear text field
+ oTextbox.value = "";
+ // Grab data to put into text field
+ if(sDelimChar) {
+ if(sSavedQuery) {
+ oTextbox.value = sSavedQuery;
+ }
+ oTextbox.value += sResultKey + sDelimChar;
+ if(sDelimChar != " ") {
+ oTextbox.value += " ";
+ }
+ }
+ else { oTextbox.value = sResultKey; }
+
+ // scroll to bottom of textarea if necessary
+ if(oTextbox.type == "textarea") {
+ oTextbox.scrollTop = oTextbox.scrollHeight;
+ }
+
+ // move cursor to end
+ var end = oTextbox.value.length;
+ this._selectText(oTextbox,end,end);
+
+ this._oCurItem = oItem;
+};
+
+/**
+ * Selects a result item from the container
+ *
+ * @method _selectItem
+ * @param oItem {HTMLElement} The selected <li> element item.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._selectItem = function(oItem) {
+ this._bItemSelected = true;
+ this._updateValue(oItem);
+ this._cancelIntervalDetection(this);
+ this.itemSelectEvent.fire(this, oItem, oItem._oResultData);
+ YAHOO.log("Item selected: " + YAHOO.lang.dump(oItem._oResultData), "info", this.toString());
+ this._toggleContainer(false);
+};
+
+/**
+ * If an item is highlighted in the container, the right arrow key jumps to the
+ * end of the textbox and selects the highlighted item, otherwise the container
+ * is closed.
+ *
+ * @method _jumpSelection
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._jumpSelection = function() {
+ if(this._oCurItem) {
+ this._selectItem(this._oCurItem);
+ }
+ else {
+ this._toggleContainer(false);
+ }
+};
+
+/**
+ * Triggered by up and down arrow keys, changes the current highlighted
+ * <li> element item. Scrolls container if necessary.
+ *
+ * @method _moveSelection
+ * @param nKeyCode {Number} Code of key pressed.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
+ if(this._bContainerOpen) {
+ // Determine current item's id number
+ var oCurItem = this._oCurItem;
+ var nCurItemIndex = -1;
+
+ if(oCurItem) {
+ nCurItemIndex = oCurItem._nItemIndex;
+ }
+
+ var nNewItemIndex = (nKeyCode == 40) ?
+ (nCurItemIndex + 1) : (nCurItemIndex - 1);
+
+ // Out of bounds
+ if(nNewItemIndex < -2 || nNewItemIndex >= this._nDisplayedItems) {
+ return;
+ }
+
+ if(oCurItem) {
+ // Unhighlight current item
+ this._toggleHighlight(oCurItem, "from");
+ this.itemArrowFromEvent.fire(this, oCurItem);
+ YAHOO.log("Item arrowed from", "info", this.toString());
+ }
+ if(nNewItemIndex == -1) {
+ // Go back to query (remove type-ahead string)
+ 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) {
+ // Close container
+ this._toggleContainer(false);
+ return;
+ }
+
+ var oNewItem = this._aListItems[nNewItemIndex];
+
+ // Scroll the container if necessary
+ 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 < this._nDisplayedItems)) {
+ // User is keying down
+ if(nKeyCode == 40) {
+ // Bottom of selected item is below scroll area...
+ if((oNewItem.offsetTop+oNewItem.offsetHeight) > (oContent.scrollTop + oContent.offsetHeight)) {
+ // Set bottom of scroll area to bottom of selected item
+ oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
+ }
+ // Bottom of selected item is above scroll area...
+ else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) {
+ // Set top of selected item to top of scroll area
+ oContent.scrollTop = oNewItem.offsetTop;
+
+ }
+ }
+ // User is keying up
+ else {
+ // Top of selected item is above scroll area
+ if(oNewItem.offsetTop < oContent.scrollTop) {
+ // Set top of scroll area to top of selected item
+ this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
+ }
+ // Top of selected item is below scroll area
+ else if(oNewItem.offsetTop > (oContent.scrollTop + oContent.offsetHeight)) {
+ // Set bottom of selected item to bottom of scroll area
+ this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
+ }
+ }
+ }
+
+ this._toggleHighlight(oNewItem, "to");
+ this.itemArrowToEvent.fire(this, oNewItem);
+ YAHOO.log("Item arrowed to", "info", this.toString());
+ if(this.typeAhead) {
+ this._updateValue(oNewItem);
+ }
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private event handlers
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Handles <li> element mouseover events in the container.
+ *
+ * @method _onItemMouseover
+ * @param v {HTMLEvent} The mouseover event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+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.log("Item moused over", "info", oSelf.toString());
+};
+
+/**
+ * Handles <li> element mouseout events in the container.
+ *
+ * @method _onItemMouseout
+ * @param v {HTMLEvent} The mouseout event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+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.log("Item moused out", "info", oSelf.toString());
+};
+
+/**
+ * Handles <li> element click events in the container.
+ *
+ * @method _onItemMouseclick
+ * @param v {HTMLEvent} The click event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onItemMouseclick = function(v,oSelf) {
+ // In case item has not been moused over
+ oSelf._toggleHighlight(this,"to");
+ oSelf._selectItem(this);
+};
+
+/**
+ * Handles container mouseover events.
+ *
+ * @method _onContainerMouseover
+ * @param v {HTMLEvent} The mouseover event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) {
+ oSelf._bOverContainer = true;
+};
+
+/**
+ * Handles container mouseout events.
+ *
+ * @method _onContainerMouseout
+ * @param v {HTMLEvent} The mouseout event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerMouseout = function(v,oSelf) {
+ oSelf._bOverContainer = false;
+ // If container is still active
+ if(oSelf._oCurItem) {
+ oSelf._toggleHighlight(oSelf._oCurItem,"to");
+ }
+};
+
+/**
+ * Handles container scroll events.
+ *
+ * @method _onContainerScroll
+ * @param v {HTMLEvent} The scroll event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) {
+ oSelf._oTextbox.focus();
+};
+
+/**
+ * Handles container resize events.
+ *
+ * @method _onContainerResize
+ * @param v {HTMLEvent} The resize event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerResize = function(v,oSelf) {
+ oSelf._toggleContainerHelpers(oSelf._bContainerOpen);
+};
+
+
+/**
+ * Handles textbox keydown events of functional keys, mainly for UI behavior.
+ *
+ * @method _onTextboxKeyDown
+ * @param v {HTMLEvent} The keydown event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) {
+ var nKeyCode = v.keyCode;
+
+ switch (nKeyCode) {
+ case 9: // tab
+ // select an item or clear out
+ if(oSelf._oCurItem) {
+ if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._toggleContainer(false);
+ }
+ break;
+ case 13: // enter
+ if(oSelf._oCurItem) {
+ if(oSelf._nKeyCode != nKeyCode) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._toggleContainer(false);
+ }
+ break;
+ case 27: // esc
+ oSelf._toggleContainer(false);
+ return;
+ case 39: // right
+ oSelf._jumpSelection();
+ break;
+ case 38: // up
+ YAHOO.util.Event.stopEvent(v);
+ oSelf._moveSelection(nKeyCode);
+ break;
+ case 40: // down
+ YAHOO.util.Event.stopEvent(v);
+ oSelf._moveSelection(nKeyCode);
+ break;
+ default:
+ break;
+ }
+};
+
+/**
+ * Handles textbox keypress events.
+ * @method _onTextboxKeyPress
+ * @param v {HTMLEvent} The keypress event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) {
+ var nKeyCode = v.keyCode;
+
+ //Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337)
+ var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1);
+ if(isMac) {
+ switch (nKeyCode) {
+ case 9: // tab
+ if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ break;
+ case 13: // enter
+ if(oSelf._nKeyCode != nKeyCode) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ break;
+ case 38: // up
+ case 40: // down
+ YAHOO.util.Event.stopEvent(v);
+ break;
+ default:
+ break;
+ }
+ }
+
+ //TODO: (?) limit only to non-IE, non-Mac-FF for Korean IME support (bug 811948)
+ // Korean IME detected
+ else if(nKeyCode == 229) {
+ oSelf._queryInterval = setInterval(function() { oSelf._onIMEDetected(oSelf); },500);
+ }
+};
+
+/**
+ * Handles textbox keyup events that trigger queries.
+ *
+ * @method _onTextboxKeyUp
+ * @param v {HTMLEvent} The keyup event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
+ // Check to see if any of the public properties have been updated
+ oSelf._initProps();
+
+ var nKeyCode = v.keyCode;
+ oSelf._nKeyCode = nKeyCode;
+ var sText = this.value; //string in textbox
+
+ // Filter out chars that don't trigger queries
+ if(oSelf._isIgnoreKey(nKeyCode) || (sText.toLowerCase() == oSelf._sCurQuery)) {
+ return;
+ }
+ else {
+ oSelf._bItemSelected = false;
+ YAHOO.util.Dom.removeClass(oSelf._oCurItem, oSelf.highlightClassName);
+ oSelf._oCurItem = null;
+
+ oSelf.textboxKeyEvent.fire(oSelf, nKeyCode);
+ YAHOO.log("Textbox keyed", "info", oSelf.toString());
+ }
+
+ // Set timeout on the request
+ 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 {
+ // No delay so send request immediately
+ oSelf._sendQuery(sText);
+ }
+};
+
+/**
+ * Handles text input box receiving focus.
+ *
+ * @method _onTextboxFocus
+ * @param v {HTMLEvent} The focus event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
+ oSelf._oTextbox.setAttribute("autocomplete","off");
+ oSelf._bFocused = true;
+ if(!oSelf._bItemSelected) {
+ oSelf.textboxFocusEvent.fire(oSelf);
+ YAHOO.log("Textbox focused", "info", oSelf.toString());
+ }
+};
+
+/**
+ * Handles text input box losing focus.
+ *
+ * @method _onTextboxBlur
+ * @param v {HTMLEvent} The focus event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
+ // Don't treat as a blur if it was a selection via mouse click
+ if(!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
+ // Current query needs to be validated
+ if(!oSelf._bItemSelected) {
+ var oMatch = oSelf._textMatchesOption();
+ if(!oSelf._bContainerOpen || (oSelf._bContainerOpen && (oMatch === null))) {
+ if(oSelf.forceSelection) {
+ oSelf._clearSelection();
+ }
+ else {
+ oSelf.unmatchedItemSelectEvent.fire(oSelf, oSelf._sCurQuery);
+ YAHOO.log("Unmatched item selected", "info", oSelf.toString());
+ }
+ }
+ else {
+ oSelf._selectItem(oMatch);
+ }
+ }
+
+ if(oSelf._bContainerOpen) {
+ oSelf._toggleContainer(false);
+ }
+ oSelf._cancelIntervalDetection(oSelf);
+ oSelf._bFocused = false;
+ oSelf.textboxBlurEvent.fire(oSelf);
+ YAHOO.log("Textbox blurred", "info", oSelf.toString());
+ }
+};
+
+/**
+ * Handles form submission event.
+ *
+ * @method _onFormSubmit
+ * @param v {HTMLEvent} The submit event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
+ if(oSelf.allowBrowserAutocomplete) {
+ oSelf._oTextbox.setAttribute("autocomplete","on");
+ }
+ else {
+ 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 fine-tune the matching algorithm used against JS Array types of
+ * DataSource and DataSource caches. If queryMatchContains is true, then the JS
+ * Array or cache returns results that "contain" the query string. By default,
+ * queryMatchContains is set to false, so that only results that "start with"
+ * the query string are returned.
+ *
+ * @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 case-sensitivity in the matching algorithm used against JS Array
+ * types of DataSources and DataSource caches. If queryMatchCase is true, only
+ * case-sensitive matches will return.
+ *
+ * @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);
+ YAHOO.log("Query received \"" + sQuery, "info", this.toString());
+ 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);
+ YAHOO.log("Cache flushed", "info", this.toString());
+
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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(!YAHOO.lang.isNumber(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);
+ YAHOO.log("Querying cache: \"" + sQuery + "\"", "info", this.toString());
+ // 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);
+ YAHOO.log("Cached results found for query \"" + sQuery + "\": " +
+ YAHOO.lang.dump(aResults), "info", this.toString());
+ 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(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!YAHOO.lang.isArray(aSchema) || !YAHOO.lang.isString(sScriptURI)) {
+ YAHOO.log("Could not instantiate XHR DataSource due to invalid arguments", "error", this.toString());
+ return;
+ }
+
+ 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", oSelf.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);
+ YAHOO.log("Results returned for query \"" + sQuery + "\": " +
+ YAHOO.lang.dump(aResults), "info", oSelf.toString());
+ 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(YAHOO.lang.isNumber(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, jsonObjParsed;
+ // Check for JSON lib but divert KHTML clients
+ var isNotMac = (navigator.userAgent.toLowerCase().indexOf('khtml')== -1);
+ if(oResponse.parseJSON && isNotMac) {
+ // Use the new JSON utility if available
+ jsonObjParsed = oResponse.parseJSON();
+ if(!jsonObjParsed) {
+ bError = true;
+ }
+ else {
+ try {
+ // eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("jsonObjParsed." + aSchema[0]);
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+ }
+ else if(window.JSON && isNotMac) {
+ // Use older JSON lib if available
+ 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(!YAHOO.lang.isArray(jsonList)) {
+ 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(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!YAHOO.lang.isFunction(oFunction)) {
+ 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);
+ YAHOO.log("Results returned for query \"" + sQuery +
+ "\": " + YAHOO.lang.dump(aResults), "info", this.toString());
+ 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(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!YAHOO.lang.isArray(aData)) {
+ 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 i;
+ 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(i = aData.length-1; i >= 0; i--) {
+ var aDataset = [];
+
+ if(YAHOO.lang.isString(aData[i])) {
+ aDataset[0] = aData[i];
+ }
+ else if(YAHOO.lang.isArray(aData[i])) {
+ aDataset = aData[i];
+ }
+
+ if(YAHOO.lang.isString(aDataset[0])) {
+ 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);
+ }
+ }
+ }
+ }
+ else {
+ for(i = aData.length-1; i >= 0; i--) {
+ if(YAHOO.lang.isString(aData[i])) {
+ aResults.unshift([aData[i]]);
+ }
+ else if(YAHOO.lang.isArray(aData[i])) {
+ aResults.unshift(aData[i]);
+ }
+ }
+ }
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ YAHOO.log("Results returned for query \"" + sQuery +
+ "\": " + YAHOO.lang.dump(aResults), "info", this.toString());
+ oCallbackFn(sQuery, aResults, oParent);
+};
+
+YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/autocomplete/autocomplete-min.js b/lib/yui/autocomplete/autocomplete-min.js
index 91bba0312c..d877c981f5 100755
--- a/lib/yui/autocomplete/autocomplete-min.js
+++ b/lib/yui/autocomplete/autocomplete-min.js
@@ -1,183 +1,191 @@
/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 0.12.2
+version: 2.3.0
*/
-
-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
+
+YAHOO.widget.AutoComplete=function(elInput,elContainer,oDataSource,oConfigs){if(elInput&&elContainer&&oDataSource){if(oDataSource instanceof YAHOO.widget.DataSource){this.dataSource=oDataSource;}
+else{return;}
+if(YAHOO.util.Dom.inDocument(elInput)){if(YAHOO.lang.isString(elInput)){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;}
+YAHOO.util.Dom.addClass(this._oTextbox,"yui-ac-input");}
+else{return;}
+if(YAHOO.util.Dom.inDocument(elContainer)){if(YAHOO.lang.isString(elContainer)){this._oContainer=document.getElementById(elContainer);}
+else{this._oContainer=elContainer;}
+if(this._oContainer.style.display=="none"){}
+var elParent=this._oContainer.parentNode;var elTag=elParent.tagName.toLowerCase();while(elParent&&(elParent!="document")){if(elTag=="div"){YAHOO.util.Dom.addClass(elParent,"yui-ac");break;}
+else{elParent=elParent.parentNode;elTag=elParent.tagName.toLowerCase();}}
+if(elTag!="div"){}}
+else{return;}
+if(oConfigs&&(oConfigs.constructor==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.2;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(oTextbox,oContainer,sQuery,aResults){return true;};YAHOO.widget.AutoComplete.prototype.sendQuery=function(sQuery){this._sendQuery(sQuery);};YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery=function(sQuery){return sQuery;};YAHOO.widget.AutoComplete.prototype.destroy=function(){var instanceName=this.toString();var elInput=this._oTextbox;var elContainer=this._oContainer;this.textboxFocusEvent.unsubscribe();this.textboxKeyEvent.unsubscribe();this.dataRequestEvent.unsubscribe();this.dataReturnEvent.unsubscribe();this.dataErrorEvent.unsubscribe();this.containerExpandEvent.unsubscribe();this.typeAheadEvent.unsubscribe();this.itemMouseOverEvent.unsubscribe();this.itemMouseOutEvent.unsubscribe();this.itemArrowToEvent.unsubscribe();this.itemArrowFromEvent.unsubscribe();this.itemSelectEvent.unsubscribe();this.unmatchedItemSelectEvent.unsubscribe();this.selectionEnforceEvent.unsubscribe();this.containerCollapseEvent.unsubscribe();this.textboxBlurEvent.unsubscribe();YAHOO.util.Event.purgeElement(elInput,true);YAHOO.util.Event.purgeElement(elContainer,true);elContainer.innerHTML="";for(var key in this){if(this.hasOwnProperty(key)){this[key]=null;}}};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(!YAHOO.lang.isNumber(minQueryLength)){this.minQueryLength=1;}
+var maxResultsDisplayed=this.maxResultsDisplayed;if(!YAHOO.lang.isNumber(maxResultsDisplayed)||(maxResultsDisplayed<1)){this.maxResultsDisplayed=10;}
+var queryDelay=this.queryDelay;if(!YAHOO.lang.isNumber(queryDelay)||(queryDelay<0)){this.queryDelay=0.2;}
+var delimChar=this.delimChar;if(YAHOO.lang.isString(delimChar)){this.delimChar=[delimChar];}
+else if(!YAHOO.lang.isArray(delimChar)){this.delimChar=null;}
+var animSpeed=this.animSpeed;if((this.animHoriz||this.animVert)&&YAHOO.util.Anim){if(!YAHOO.lang.isNumber(animSpeed)||(animSpeed<0)){this.animSpeed=0.3;}
+if(!this._oAnim){this._oAnim=new YAHOO.util.Anim(this._oContainer._oContent,{},this.animSpeed);}
+else{this._oAnim.duration=this.animSpeed;}}
+if(this.forceSelection&&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(){YAHOO.util.Dom.addClass(this._oContainer,"yui-ac-container");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;oldi--){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<=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;sQuery=this.doBeforeSendQuery(sQuery);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;}
+var ok=oSelf.doBeforeExpandContainer(oSelf._oTextbox,oSelf._oContainer,sQuery,aResults);oSelf._toggleContainer(ok);if(oSelf.autoHighlight){var oFirstItem=aItems[0];oSelf._toggleHighlight(oFirstItem,"to");oSelf.itemArrowToEvent.fire(oSelf,oFirstItem);oSelf._typeAhead(oFirstItem,sQuery);}
+else{oSelf._oCurItem=null;}}
+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=null;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=oItem;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._oCurItem){this._selectItem(this._oCurItem);}
+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._oCurItem){if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
+oSelf._selectItem(oSelf._oCurItem);}
+else{oSelf._toggleContainer(false);}
+break;case 13:if(oSelf._oCurItem){if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
+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)){YAHOO.util.Event.stopEvent(v);}
+break;case 13:if(oSelf._nKeyCode!=nKeyCode){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._bItemSelected=false;YAHOO.util.Dom.removeClass(oSelf._oCurItem,oSelf.highlightClassName);oSelf._oCurItem=null;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;if(!oSelf._bItemSelected){oSelf.textboxFocusEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(v,oSelf){if(!oSelf._bOverContainer||(oSelf._nKeyCode==9)){if(!oSelf._bItemSelected){var oMatch=oSelf._textMatchesOption();if(!oSelf._bContainerOpen||(oSelf._bContainerOpen&&(oMatch===null))){if(oSelf.forceSelection){oSelf._clearSelection();}
+else{oSelf.unmatchedItemSelectEvent.fire(oSelf,oSelf._sCurQuery);}}
+else{oSelf._selectItem(oMatch);}}
+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(!YAHOO.lang.isNumber(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(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
+if(!YAHOO.lang.isArray(aSchema)||!YAHOO.lang.isString(sScriptURI)){return;}
+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(YAHOO.lang.isNumber(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,jsonObjParsed;var isNotMac=(navigator.userAgent.toLowerCase().indexOf('khtml')==-1);if(oResponse.parseJSON&&isNotMac){jsonObjParsed=oResponse.parseJSON();if(!jsonObjParsed){bError=true;}
+else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}
+catch(e){bError=true;break;}}}
+else if(window.JSON&&isNotMac){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(!YAHOO.lang.isArray(jsonList)){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(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
+if(!YAHOO.lang.isFunction(oFunction)){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(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
+if(!YAHOO.lang.isArray(aData)){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 i;var aData=this.data;var aResults=[];var bMatchFound=false;var bMatchContains=this.queryMatchContains;if(sQuery){if(!this.queryMatchCase){sQuery=sQuery.toLowerCase();}
+for(i=aData.length-1;i>=0;i--){var aDataset=[];if(YAHOO.lang.isString(aData[i])){aDataset[0]=aData[i];}
+else if(YAHOO.lang.isArray(aData[i])){aDataset=aData[i];}
+if(YAHOO.lang.isString(aDataset[0])){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);}}}}
+else{for(i=aData.length-1;i>=0;i--){if(YAHOO.lang.isString(aData[i])){aResults.unshift([aData[i]]);}
+else if(YAHOO.lang.isArray(aData[i])){aResults.unshift(aData[i]);}}}
+this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);};YAHOO.register("autocomplete",YAHOO.widget.AutoComplete,{version:"2.3.0",build:"442"});
\ No newline at end of file
diff --git a/lib/yui/autocomplete/autocomplete.js b/lib/yui/autocomplete/autocomplete.js
index a39a98780b..72a6772b59 100755
--- a/lib/yui/autocomplete/autocomplete.js
+++ b/lib/yui/autocomplete/autocomplete.js
@@ -1,3065 +1,3190 @@
/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 0.12.2
+version: 2.3.0
*/
- /**
- * The AutoComplete control provides the front-end logic for text-entry suggestion and
- * completion functionality.
- *
- * @module autocomplete
- * @requires yahoo, dom, event, datasource
- * @optional animation, connection, json
- * @namespace YAHOO.widget
- * @title AutoComplete Widget
- */
-
-/****************************************************************************/
-/****************************************************************************/
-/****************************************************************************/
-
-/**
- * The AutoComplete class provides the customizable functionality of a plug-and-play DHTML
- * auto completion widget. Some key features:
- *
- * Navigate with up/down arrow keys and/or mouse to pick a selection
- * The drop down container can "roll down" or "fly out" via configurable
- * animation
- * UI look-and-feel customizable through CSS, including container
- * attributes, borders, position, fonts, etc
- *
- *
- * @class AutoComplete
- * @constructor
- * @param elInput {HTMLElement} DOM element reference of an input field.
- * @param elInput {String} String ID of an input field.
- * @param elContainer {HTMLElement} DOM element reference of an existing DIV.
- * @param elContainer {String} String ID of an existing DIV.
- * @param oDataSource {Object} Instance of YAHOO.widget.DataSource for query/results.
- * @param oConfigs {Object} (optional) Object literal of configuration params.
- */
-YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
- if(elInput && elContainer && oDataSource) {
- // Validate DataSource
- if (oDataSource && (oDataSource instanceof YAHOO.widget.DataSource)) {
- this.dataSource = oDataSource;
- }
- else {
- return;
- }
-
- // Validate input element
- 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;
- }
-
- // Validate container element
- 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;
- }
-
- // Set any config params passed in to override defaults
- if (typeof oConfigs == "object") {
- for(var sConfig in oConfigs) {
- if (sConfig) {
- this[sConfig] = oConfigs[sConfig];
- }
- }
- }
-
- // Initialization sequence
- this._initContainer();
- this._initProps();
- this._initList();
- this._initContainerHelpers();
-
- // Set up events
- var oSelf = this;
- var oTextbox = this._oTextbox;
- // Events are actually for the content module within the container
- var oContent = this._oContainer._oContent;
-
- // Dom events
- 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);
-
- // Custom events
- 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);
-
- // Finish up
- oTextbox.setAttribute("autocomplete","off");
- YAHOO.widget.AutoComplete._nIndex++;
- }
- // Required arguments were not found
- else {
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * The DataSource object that encapsulates the data used for auto completion.
- * This object should be an inherited object from YAHOO.widget.DataSource.
- *
- * @property dataSource
- * @type Object
- */
-YAHOO.widget.AutoComplete.prototype.dataSource = null;
-
-/**
- * Number of characters that must be entered before querying for results. A negative value
- * effectively turns off the widget. A value of 0 allows queries of null or empty string
- * values.
- *
- * @property minQueryLength
- * @type Number
- * @default 1
- */
-YAHOO.widget.AutoComplete.prototype.minQueryLength = 1;
-
-/**
- * Maximum number of results to display in results container.
- *
- * @property maxResultsDisplayed
- * @type Number
- * @default 10
- */
-YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed = 10;
-
-/**
- * Number of seconds to delay before submitting a query request. If a query
- * request is received before a previous one has completed its delay, the
- * previous request is cancelled and the new request is set to the delay.
- *
- * @property queryDelay
- * @type Number
- * @default 0.5
- */
-YAHOO.widget.AutoComplete.prototype.queryDelay = 0.5;
-
-/**
- * Class name of a highlighted item within results container.
- *
- * @property highlighClassName
- * @type String
- * @default "yui-ac-highlight"
- */
-YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight";
-
-/**
- * Class name of a pre-highlighted item within results container.
- *
- * @property prehighlightClassName
- * @type String
- */
-YAHOO.widget.AutoComplete.prototype.prehighlightClassName = null;
-
-/**
- * Query delimiter. A single character separator for multiple delimited
- * selections. Multiple delimiter characteres may be defined as an array of
- * strings. A null value or empty string indicates that query results cannot
- * be delimited. This feature is not recommended if you need forceSelection to
- * be true.
- *
- * @property delimChar
- * @type String | String[]
- */
-YAHOO.widget.AutoComplete.prototype.delimChar = null;
-
-/**
- * Whether or not the first item in results container should be automatically highlighted
- * on expand.
- *
- * @property autoHighlight
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.autoHighlight = true;
-
-/**
- * Whether or not the input field should be automatically updated
- * with the first query result as the user types, auto-selecting the substring
- * that the user has not typed.
- *
- * @property typeAhead
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.typeAhead = false;
-
-/**
- * Whether or not to animate the expansion/collapse of the results container in the
- * horizontal direction.
- *
- * @property animHoriz
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.animHoriz = false;
-
-/**
- * Whether or not to animate the expansion/collapse of the results container in the
- * vertical direction.
- *
- * @property animVert
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.animVert = true;
-
-/**
- * Speed of container expand/collapse animation, in seconds..
- *
- * @property animSpeed
- * @type Number
- * @default 0.3
- */
-YAHOO.widget.AutoComplete.prototype.animSpeed = 0.3;
-
-/**
- * Whether or not to force the user's selection to match one of the query
- * results. Enabling this feature essentially transforms the input field into a
- * <select> field. This feature is not recommended with delimiter character(s)
- * defined.
- *
- * @property forceSelection
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.forceSelection = false;
-
-/**
- * Whether or not to allow browsers to cache user-typed input in the input
- * field. Disabling this feature will prevent the widget from setting the
- * autocomplete="off" on the input field. When autocomplete="off"
- * and users click the back button after form submission, user-typed input can
- * be prefilled by the browser from its cache. This caching of user input may
- * not be desired for sensitive data, such as credit card numbers, in which
- * case, implementers should consider setting allowBrowserAutocomplete to false.
- *
- * @property allowBrowserAutocomplete
- * @type Boolean
- * @default true
- */
-YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true;
-
-/**
- * Whether or not the results container should always be displayed.
- * Enabling this feature displays the container when the widget is instantiated
- * and prevents the toggling of the container to a collapsed state.
- *
- * @property alwaysShowContainer
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.alwaysShowContainer = false;
-
-/**
- * Whether or not to use an iFrame to layer over Windows form elements in
- * IE. Set to true only when the results container will be on top of a
- * <select> field in IE and thus exposed to the IE z-index bug (i.e.,
- * 5.5 < IE < 7).
- *
- * @property useIFrame
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.useIFrame = false;
-
-/**
- * Whether or not the results container should have a shadow.
- *
- * @property useShadow
- * @type Boolean
- * @default false
- */
-YAHOO.widget.AutoComplete.prototype.useShadow = false;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Public accessor to the unique name of the AutoComplete instance.
- *
- * @method toString
- * @return {String} Unique name of the AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.toString = function() {
- return "AutoComplete " + this._sName;
-};
-
- /**
- * Returns true if container is in an expanded state, false otherwise.
- *
- * @method isContainerOpen
- * @return {Boolean} Returns true if container is in an expanded state, false otherwise.
- */
-YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() {
- return this._bContainerOpen;
-};
-
-/**
- * Public accessor to the internal array of DOM <li> elements that
- * display query results within the results container.
- *
- * @method getListItems
- * @return {HTMLElement[]} Array of <li> elements within the results container.
- */
-YAHOO.widget.AutoComplete.prototype.getListItems = function() {
- return this._aListItems;
-};
-
-/**
- * Public accessor to the data held in an <li> element of the
- * results container.
- *
- * @method getListItemData
- * @return {Object | Array} Object or array of result data or null
- */
-YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
- if(oListItem._oResultData) {
- return oListItem._oResultData;
- }
- else {
- return false;
- }
-};
-
-/**
- * Sets HTML markup for the results container header. This markup will be
- * inserted within a <div> tag with a class of "ac_hd".
- *
- * @method setHeader
- * @param sHeader {String} HTML markup for results container header.
- */
-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";
- }
-};
-
-/**
- * Sets HTML markup for the results container footer. This markup will be
- * inserted within a <div> tag with a class of "ac_ft".
- *
- * @method setFooter
- * @param sFooter {String} HTML markup for results container footer.
- */
-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";
- }
-};
-
-/**
- * Sets HTML markup for the results container body. This markup will be
- * inserted within a <div> tag with a class of "ac_bd".
- *
- * @method setBody
- * @param sHeader {String} HTML markup for results container body.
- */
-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;
-};
-
-/**
- * Overridable method that converts a result item object into HTML markup
- * for display. Return data values are accessible via the oResultItem object,
- * and the key return value will always be oResultItem[0]. Markup will be
- * displayed within <li> element tags in the container.
- *
- * @method formatResult
- * @param oResultItem {Object} Result item representing one query result. Data is held in an array.
- * @param sQuery {String} The current query string.
- * @return {String} HTML markup of formatted result data.
- */
-YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery) {
- var sResult = oResultItem[0];
- if(sResult) {
- return sResult;
- }
- else {
- return "";
- }
-};
-
-/**
- * Overridable method called before container expands allows implementers to access data
- * and DOM elements.
- *
- * @method doBeforeExpandContainer
- * @return {Boolean} Return true to continue expanding container, false to cancel the expand.
- */
-YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oResultItem, sQuery) {
- return true;
-};
-
-/**
- * Makes query request to the DataSource.
- *
- * @method sendQuery
- * @param sQuery {String} Query string.
- */
-YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) {
- this._sendQuery(sQuery);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Fired when the input field receives focus.
- *
- * @event textboxFocusEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null;
-
-/**
- * Fired when the input field receives key input.
- *
- * @event textboxKeyEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param nKeycode {Number} The keycode number.
- */
-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.
- */
-YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null;
-
-/**
- * Fired when the AutoComplete instance receives query results from the data
- * source.
- *
- * @event dataReturnEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param sQuery {String} The query string.
- * @param aResults {Array} Results array.
- */
-YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
-
-/**
- * Fired when the AutoComplete instance does not receive query results from the
- * DataSource due to an error.
- *
- * @event dataErrorEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param sQuery {String} The query string.
- */
-YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
-
-/**
- * Fired when the results container is expanded.
- *
- * @event containerExpandEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
-
-/**
- * Fired when the input field has been prefilled by the type-ahead
- * feature.
- *
- * @event typeAheadEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param sQuery {String} The query string.
- * @param sPrefill {String} The prefill string.
- */
-YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null;
-
-/**
- * Fired when result item has been moused over.
- *
- * @event itemMouseOverEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item moused to.
- */
-YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
-
-/**
- * Fired when result item has been moused out.
- *
- * @event itemMouseOutEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item moused from.
- */
-YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
-
-/**
- * Fired when result item has been arrowed to.
- *
- * @event itemArrowToEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item arrowed to.
- */
-YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null;
-
-/**
- * Fired when result item has been arrowed away from.
- *
- * @event itemArrowFromEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The <li> element item arrowed from.
- */
-YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent = null;
-
-/**
- * Fired when an item is selected via mouse click, ENTER key, or TAB key.
- *
- * @event itemSelectEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param elItem {HTMLElement} The selected <li> element item.
- * @param oData {Object} The data returned for the item, either as an object,
- * or mapped from the schema into an array.
- */
-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.
- *
- * @event unmatchedItemSelectEvent
- * @param oSelf {Object} The AutoComplete instance.
- * @param sQuery {String} The user-typed query string.
- */
-YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
-
-/**
- * Fired if forceSelection is enabled and the user's input has been cleared
- * because it did not match one of the returned query results.
- *
- * @event selectionEnforceEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
-
-/**
- * Fired when the results container is collapsed.
- *
- * @event containerCollapseEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null;
-
-/**
- * Fired when the input field loses focus.
- *
- * @event textboxBlurEvent
- * @param oSelf {Object} The AutoComplete instance.
- */
-YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private member variables
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Internal class variable to index multiple AutoComplete instances.
- *
- * @property _nIndex
- * @type Number
- * @default 0
- * @private
- */
-YAHOO.widget.AutoComplete._nIndex = 0;
-
-/**
- * Name of AutoComplete instance.
- *
- * @property _sName
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sName = null;
-
-/**
- * Text input field DOM element.
- *
- * @property _oTextbox
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oTextbox = null;
-
-/**
- * Whether or not the input field is currently in focus. If query results come back
- * but the user has already moved on, do not proceed with auto complete behavior.
- *
- * @property _bFocused
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bFocused = true;
-
-/**
- * Animation instance for container expand/collapse.
- *
- * @property _oAnim
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oAnim = null;
-
-/**
- * Container DOM element.
- *
- * @property _oContainer
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oContainer = null;
-
-/**
- * Whether or not the results container is currently open.
- *
- * @property _bContainerOpen
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;
-
-/**
- * Whether or not the mouse is currently over the results
- * container. This is necessary in order to prevent clicks on container items
- * from being text input field blur events.
- *
- * @property _bOverContainer
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bOverContainer = false;
-
-/**
- * Array of <li> elements references that contain query results within the
- * results container.
- *
- * @property _aListItems
- * @type Array
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._aListItems = null;
-
-/**
- * Number of <li> elements currently displayed in results container.
- *
- * @property _nDisplayedItems
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0;
-
-/**
- * Internal count of <li> elements displayed and hidden in results container.
- *
- * @property _maxResultsDisplayed
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0;
-
-/**
- * Current query string
- *
- * @property _sCurQuery
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sCurQuery = null;
-
-/**
- * Past queries this session (for saving delimited queries).
- *
- * @property _sSavedQuery
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sSavedQuery = null;
-
-/**
- * Pointer to the currently highlighted <li> element in the container.
- *
- * @property _oCurItem
- * @type HTMLElement
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._oCurItem = null;
-
-/**
- * Whether or not an item has been selected since the container was populated
- * with results. Reset to false by _populateList, and set to true when item is
- * selected.
- *
- * @property _bItemSelected
- * @type Boolean
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._bItemSelected = false;
-
-/**
- * Key code of the last key pressed in textbox.
- *
- * @property _nKeyCode
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nKeyCode = null;
-
-/**
- * Delay timeout ID.
- *
- * @property _nDelayID
- * @type Number
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._nDelayID = -1;
-
-/**
- * Src to iFrame used when useIFrame = true. Supports implementations over SSL
- * as well.
- *
- * @property _iFrameSrc
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;";
-
-/**
- * For users typing via certain IMEs, queries must be triggered by intervals,
- * since key events yet supported across all browsers for all IMEs.
- *
- * @property _queryInterval
- * @type Object
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._queryInterval = null;
-
-/**
- * Internal tracker to last known textbox value, used to determine whether or not
- * to trigger a query via interval for certain IME users.
- *
- * @event _sLastTextboxValue
- * @type String
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Updates and validates latest public config properties.
- *
- * @method __initProps
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initProps = function() {
- // Correct any invalid values
- 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) {
- }
-};
-
-/**
- * Initializes the results container helpers if they are enabled and do
- * not exist
- *
- * @method _initContainerHelpers
- * @private
- */
-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);
- }
-};
-
-/**
- * Initializes the results container once at object creation
- *
- * @method _initContainer
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._initContainer = function() {
- if(!this._oContainer._oContent) {
- // The oContent div helps size the iframe and shadow properly
- 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 {
- }
-};
-
-/**
- * Clears out contents of container body and creates up to
- * YAHOO.widget.AutoComplete#maxResultsDisplayed <li> elements in an
- * <ul> element.
- *
- * @method _initList
- * @private
- */
-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) || // alt,pause/break,caps lock
- (nKeyCode == 27) || // esc
- (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end
- (nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up
- (nKeyCode == 40) || // down
- (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert
- return true;
- }
- return false;
-};
-
-/**
- * Makes query request to the DataSource.
- *
- * @method _sendQuery
- * @param sQuery {String} Query string.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) {
- // Widget has been effectively turned off
- if(this.minQueryLength == -1) {
- this._toggleContainer(false);
- return;
- }
- // Delimiter has been enabled
- var aDelimChar = (this.delimChar) ? this.delimChar : null;
- if(aDelimChar) {
- // Loop through all possible delimiters and find the latest one
- // A " " may be a false positive if they are defined as delimiters AND
- // are used to separate delimited queries
- var nDelimIndex = -1;
- for(var i = aDelimChar.length-1; i >= 0; i--) {
- var nNewIndex = sQuery.lastIndexOf(aDelimChar[i]);
- if(nNewIndex > nDelimIndex) {
- nDelimIndex = nNewIndex;
- }
- }
- // If we think the last delimiter is a space (" "), make sure it is NOT
- // a false positive by also checking the char directly before it
- if(aDelimChar[i] == " ") {
- for (var j = aDelimChar.length-1; j >= 0; j--) {
- if(sQuery[nDelimIndex - 1] == aDelimChar[j]) {
- nDelimIndex--;
- break;
- }
- }
- }
- // A delimiter has been found so extract the latest query
- if (nDelimIndex > -1) {
- var nQueryStart = nDelimIndex + 1;
- // Trim any white space from the beginning...
- while(sQuery.charAt(nQueryStart) == " ") {
- nQueryStart += 1;
- }
- // ...and save the rest of the string for later
- this._sSavedQuery = sQuery.substring(0,nQueryStart);
- // Here is the query itself
- sQuery = sQuery.substr(nQueryStart);
- }
- else if(sQuery.indexOf(this._sSavedQuery) < 0){
- this._sSavedQuery = null;
- }
- }
-
- // Don't search queries that are too short
- if (sQuery && (sQuery.length < this.minQueryLength) || (!sQuery && this.minQueryLength > 0)) {
- if (this._nDelayID != -1) {
- clearTimeout(this._nDelayID);
- }
- this._toggleContainer(false);
- return;
- }
-
- sQuery = encodeURIComponent(sQuery);
- this._nDelayID = -1; // Reset timeout ID because request has been made
- this.dataRequestEvent.fire(this, sQuery);
- this.dataSource.getResults(this._populateList, sQuery, this);
-};
-
-/**
- * Populates the array of <li> elements in the container with query
- * results. This method is passed to YAHOO.widget.DataSource#getResults as a
- * callback function so results from the DataSource instance are returned to the
- * AutoComplete instance.
- *
- * @method _populateList
- * @param sQuery {String} The query string.
- * @param aResults {Array} An array of query result objects from the DataSource.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-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;
-
- // Fill items with data
- 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;
-
- }
-
- // Empty out remaining items if any
- 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) {
- // Go to the first item
- var oFirstItem = aItems[0];
- oSelf._toggleHighlight(oFirstItem,"to");
- oSelf.itemArrowToEvent.fire(oSelf, oFirstItem);
- oSelf._typeAhead(oFirstItem,sQuery);
- }
- else {
- oSelf._oCurItem = null;
- }
-
- // Expand the container
- var ok = oSelf.doBeforeExpandContainer(oSelf._oTextbox, oSelf._oContainer, sQuery, aResults);
- oSelf._toggleContainer(ok);
- }
- else {
- oSelf._toggleContainer(false);
- }
- oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults);
-};
-
-/**
- * When forceSelection is true and the user attempts
- * leave the text input box without selecting an item from the query results,
- * the user selection is cleared.
- *
- * @method _clearSelection
- * @private
- */
-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;
-
- // Fire custom event
- this.selectionEnforceEvent.fire(this);
-};
-
-/**
- * Whether or not user-typed value in the text input box matches any of the
- * query results.
- *
- * @method _textMatchesOption
- * @return {Boolean} True if user-input text matches a result, false otherwise.
- * @private
- */
-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);
-};
-
-/**
- * Updates in the text input box with the first query result as the user types,
- * selecting the substring that the user has not typed.
- *
- * @method _typeAhead
- * @param oItem {HTMLElement} The <li> element item whose data populates the input field.
- * @param sQuery {String} Query string.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
- // Don't update if turned off
- if (!this.typeAhead || (this._nKeyCode == 8)) {
- return;
- }
-
- var oTextbox = this._oTextbox;
- var sValue = this._oTextbox.value; // any saved queries plus what user has typed
-
- // Don't update with type-ahead if text selection is not supported
- if(!oTextbox.setSelectionRange && !oTextbox.createTextRange) {
- return;
- }
-
- // Select the portion of text that the user has not typed
- 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);
-};
-
-/**
- * Selects text in the input field.
- *
- * @method _selectText
- * @param oTextbox {HTMLElement} Text input box element in which to select text.
- * @param nStart {Number} Starting index of text string to select.
- * @param nEnd {Number} Ending index of text selection.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEnd) {
- if (oTextbox.setSelectionRange) { // For Mozilla
- oTextbox.setSelectionRange(nStart,nEnd);
- }
- else if (oTextbox.createTextRange) { // For IE
- var oTextRange = oTextbox.createTextRange();
- oTextRange.moveStart("character", nStart);
- oTextRange.moveEnd("character", nEnd-oTextbox.value.length);
- oTextRange.select();
- }
- else {
- oTextbox.select();
- }
-};
-
-/**
- * Syncs results container with its helpers.
- *
- * @method _toggleContainerHelpers
- * @param bShow {Boolean} True if container is expanded, false if collapsed
- * @private
- */
-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;
- }
- }
-};
-
-/**
- * Animates expansion or collapse of the container.
- *
- * @method _toggleContainer
- * @param bShow {Boolean} True if container should be expanded, false if container should be collapsed
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
- var oContainer = this._oContainer;
-
- // Implementer has container always open so don't mess with it
- if(this.alwaysShowContainer && this._bContainerOpen) {
- return;
- }
-
- // Clear contents of container
- 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;
- }
-
- // Container is already closed
- if (!bShow && !this._bContainerOpen) {
- oContainer._oContent.style.display = "none";
- return;
- }
-
- // If animation is enabled...
- var oAnim = this._oAnim;
- if (oAnim && oAnim.getEl() && (this.animHoriz || this.animVert)) {
- // If helpers need to be collapsed, do it right away...
- // but if helpers need to be expanded, wait until after the container expands
- if(!bShow) {
- this._toggleContainerHelpers(bShow);
- }
-
- if(oAnim.isAnimated()) {
- oAnim.stop();
- }
-
- // Clone container to grab current size offscreen
- var oClone = oContainer._oContent.cloneNode(true);
- oContainer.appendChild(oClone);
- oClone.style.top = "-9000px";
- oClone.style.display = "block";
-
- // Current size of the container is the EXPANDED size
- var wExp = oClone.offsetWidth;
- var hExp = oClone.offsetHeight;
-
- // Calculate COLLAPSED sizes based on horiz and vert anim
- var wColl = (this.animHoriz) ? 0 : wExp;
- var hColl = (this.animVert) ? 0 : hExp;
-
- // Set animation sizes
- oAnim.attributes = (bShow) ?
- {width: { to: wExp }, height: { to: hExp }} :
- {width: { to: wColl}, height: { to: hColl }};
-
- // If opening anew, set to a collapsed size...
- if(bShow && !this._bContainerOpen) {
- oContainer._oContent.style.width = wColl+"px";
- oContainer._oContent.style.height = hColl+"px";
- }
- // Else, set it to its last known size.
- else {
- oContainer._oContent.style.width = wExp+"px";
- oContainer._oContent.style.height = hExp+"px";
- }
-
- oContainer.removeChild(oClone);
- oClone = null;
-
- var oSelf = this;
- var onAnimComplete = function() {
- // Finish the collapse
- oAnim.onComplete.unsubscribeAll();
-
- if(bShow) {
- oSelf.containerExpandEvent.fire(oSelf);
- }
- else {
- oContainer._oContent.style.display = "none";
- oSelf.containerCollapseEvent.fire(oSelf);
- }
- oSelf._toggleContainerHelpers(bShow);
- };
-
- // Display container and animate it
- oContainer._oContent.style.display = "block";
- oAnim.onComplete.subscribe(onAnimComplete);
- oAnim.animate();
- this._bContainerOpen = bShow;
- }
- // Else don't animate, just show or hide
- 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;
- }
-
-};
-
-/**
- * Toggles the highlight on or off for an item in the container, and also cleans
- * up highlighting of any previous item.
- *
- * @method _toggleHighlight
- * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
- * @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._toggleHighlight = function(oNewItem, sType) {
- var sHighlight = this.highlightClassName;
- if(this._oCurItem) {
- // Remove highlight from old item
- YAHOO.util.Dom.removeClass(this._oCurItem, sHighlight);
- }
-
- if((sType == "to") && sHighlight) {
- // Apply highlight to new item
- YAHOO.util.Dom.addClass(oNewItem, sHighlight);
- this._oCurItem = oNewItem;
- }
-};
-
-/**
- * Toggles the pre-highlight on or off for an item in the container.
- *
- * @method _togglePrehighlight
- * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
- * @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function(oNewItem, sType) {
- if(oNewItem == this._oCurItem) {
- return;
- }
-
- var sPrehighlight = this.prehighlightClassName;
- if((sType == "mouseover") && sPrehighlight) {
- // Apply prehighlight to new item
- YAHOO.util.Dom.addClass(oNewItem, sPrehighlight);
- }
- else {
- // Remove prehighlight from old item
- YAHOO.util.Dom.removeClass(oNewItem, sPrehighlight);
- }
-};
-
-/**
- * Updates the text input box value with selected query result. If a delimiter
- * has been defined, then the value gets appended with the delimiter.
- *
- * @method _updateValue
- * @param oItem {HTMLElement} The <li> element item with which to update the value.
- * @private
- */
-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();
-
- // First clear text field
- oTextbox.value = "";
- // Grab data to put into text field
- if(sDelimChar) {
- if(sSavedQuery) {
- oTextbox.value = sSavedQuery;
- }
- oTextbox.value += sResultKey + sDelimChar;
- if(sDelimChar != " ") {
- oTextbox.value += " ";
- }
- }
- else { oTextbox.value = sResultKey; }
-
- // scroll to bottom of textarea if necessary
- if(oTextbox.type == "textarea") {
- oTextbox.scrollTop = oTextbox.scrollHeight;
- }
-
- // move cursor to end
- var end = oTextbox.value.length;
- this._selectText(oTextbox,end,end);
-
- this._oCurItem = oItem;
-};
-
-/**
- * Selects a result item from the container
- *
- * @method _selectItem
- * @param oItem {HTMLElement} The selected <li> element item.
- * @private
- */
-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);
-};
-
-/**
- * For values updated by type-ahead, the right arrow key jumps to the end
- * of the textbox, otherwise the container is closed.
- *
- * @method _jumpSelection
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._jumpSelection = function() {
- if(!this.typeAhead) {
- return;
- }
- else {
- this._toggleContainer(false);
- }
-};
-
-/**
- * Triggered by up and down arrow keys, changes the current highlighted
- * <li> element item. Scrolls container if necessary.
- *
- * @method _moveSelection
- * @param nKeyCode {Number} Code of key pressed.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
- if(this._bContainerOpen) {
- // Determine current item's id number
- var oCurItem = this._oCurItem;
- var nCurItemIndex = -1;
-
- if (oCurItem) {
- nCurItemIndex = oCurItem._nItemIndex;
- }
-
- var nNewItemIndex = (nKeyCode == 40) ?
- (nCurItemIndex + 1) : (nCurItemIndex - 1);
-
- // Out of bounds
- if (nNewItemIndex < -2 || nNewItemIndex >= this._nDisplayedItems) {
- return;
- }
-
- if (oCurItem) {
- // Unhighlight current item
- this._toggleHighlight(oCurItem, "from");
- this.itemArrowFromEvent.fire(this, oCurItem);
- }
- if (nNewItemIndex == -1) {
- // Go back to query (remove type-ahead string)
- 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) {
- // Close container
- this._toggleContainer(false);
- return;
- }
-
- var oNewItem = this._aListItems[nNewItemIndex];
-
- // Scroll the container if necessary
- 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 < this._nDisplayedItems)) {
- // User is keying down
- if(nKeyCode == 40) {
- // Bottom of selected item is below scroll area...
- if((oNewItem.offsetTop+oNewItem.offsetHeight) > (oContent.scrollTop + oContent.offsetHeight)) {
- // Set bottom of scroll area to bottom of selected item
- oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
- }
- // Bottom of selected item is above scroll area...
- else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) {
- // Set top of selected item to top of scroll area
- oContent.scrollTop = oNewItem.offsetTop;
-
- }
- }
- // User is keying up
- else {
- // Top of selected item is above scroll area
- if(oNewItem.offsetTop < oContent.scrollTop) {
- // Set top of scroll area to top of selected item
- this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
- }
- // Top of selected item is below scroll area
- else if(oNewItem.offsetTop > (oContent.scrollTop + oContent.offsetHeight)) {
- // Set bottom of selected item to bottom of scroll area
- 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);
- }
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles <li> element mouseover events in the container.
- *
- * @method _onItemMouseover
- * @param v {HTMLEvent} The mouseover event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-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);
-};
-
-/**
- * Handles <li> element mouseout events in the container.
- *
- * @method _onItemMouseout
- * @param v {HTMLEvent} The mouseout event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-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);
-};
-
-/**
- * Handles <li> element click events in the container.
- *
- * @method _onItemMouseclick
- * @param v {HTMLEvent} The click event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onItemMouseclick = function(v,oSelf) {
- // In case item has not been moused over
- oSelf._toggleHighlight(this,"to");
- oSelf._selectItem(this);
-};
-
-/**
- * Handles container mouseover events.
- *
- * @method _onContainerMouseover
- * @param v {HTMLEvent} The mouseover event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) {
- oSelf._bOverContainer = true;
-};
-
-/**
- * Handles container mouseout events.
- *
- * @method _onContainerMouseout
- * @param v {HTMLEvent} The mouseout event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onContainerMouseout = function(v,oSelf) {
- oSelf._bOverContainer = false;
- // If container is still active
- if(oSelf._oCurItem) {
- oSelf._toggleHighlight(oSelf._oCurItem,"to");
- }
-};
-
-/**
- * Handles container scroll events.
- *
- * @method _onContainerScroll
- * @param v {HTMLEvent} The scroll event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) {
- oSelf._oTextbox.focus();
-};
-
-/**
- * Handles container resize events.
- *
- * @method _onContainerResize
- * @param v {HTMLEvent} The resize event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onContainerResize = function(v,oSelf) {
- oSelf._toggleContainerHelpers(oSelf._bContainerOpen);
-};
-
-/**
- * Handles textbox keydown events of functional keys, mainly for UI behavior.
- *
- * @method _onTextboxKeyDown
- * @param v {HTMLEvent} The keydown event.
- * @param oSelf {object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) {
- var nKeyCode = v.keyCode;
-
- switch (nKeyCode) {
- case 9: // tab
- if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
- if(oSelf._bContainerOpen) {
- YAHOO.util.Event.stopEvent(v);
- }
- }
- // select an item or clear out
- if(oSelf._oCurItem) {
- oSelf._selectItem(oSelf._oCurItem);
- }
- else {
- oSelf._toggleContainer(false);
- }
- break;
- case 13: // enter
- 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: // esc
- oSelf._toggleContainer(false);
- return;
- case 39: // right
- oSelf._jumpSelection();
- break;
- case 38: // up
- YAHOO.util.Event.stopEvent(v);
- oSelf._moveSelection(nKeyCode);
- break;
- case 40: // down
- YAHOO.util.Event.stopEvent(v);
- oSelf._moveSelection(nKeyCode);
- break;
- default:
- break;
- }
-};
-
-/**
- * Handles textbox keypress events.
- * @method _onTextboxKeyPress
- * @param v {HTMLEvent} The keypress event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) {
- var nKeyCode = v.keyCode;
-
- //Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337)
- var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1);
- if(isMac) {
- switch (nKeyCode) {
- case 9: // tab
- if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
- if(oSelf._bContainerOpen) {
- YAHOO.util.Event.stopEvent(v);
- }
- }
- break;
- case 13: // enter
- if(oSelf._nKeyCode != nKeyCode) {
- if(oSelf._bContainerOpen) {
- YAHOO.util.Event.stopEvent(v);
- }
- }
- break;
- case 38: // up
- case 40: // down
- YAHOO.util.Event.stopEvent(v);
- break;
- default:
- break;
- }
- }
-
- //TODO: (?) limit only to non-IE, non-Mac-FF for Korean IME support (bug 811948)
- // Korean IME detected
- else if(nKeyCode == 229) {
- oSelf._queryInterval = setInterval(function() { oSelf._onIMEDetected(oSelf); },500);
- }
-};
-
-/**
- * Handles textbox keyup events that trigger queries.
- *
- * @method _onTextboxKeyUp
- * @param v {HTMLEvent} The keyup event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
- // Check to see if any of the public properties have been updated
- oSelf._initProps();
-
- var nKeyCode = v.keyCode;
- oSelf._nKeyCode = nKeyCode;
- var sText = this.value; //string in textbox
-
- // Filter out chars that don't trigger queries
- if (oSelf._isIgnoreKey(nKeyCode) || (sText.toLowerCase() == oSelf._sCurQuery)) {
- return;
- }
- else {
- oSelf.textboxKeyEvent.fire(oSelf, nKeyCode);
- }
-
- // Set timeout on the request
- 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 {
- // No delay so send request immediately
- oSelf._sendQuery(sText);
- }
-};
-
-/**
- * Handles text input box receiving focus.
- *
- * @method _onTextboxFocus
- * @param v {HTMLEvent} The focus event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
- oSelf._oTextbox.setAttribute("autocomplete","off");
- oSelf._bFocused = true;
- oSelf.textboxFocusEvent.fire(oSelf);
-};
-
-/**
- * Handles text input box losing focus.
- *
- * @method _onTextboxBlur
- * @param v {HTMLEvent} The focus event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
- // Don't treat as a blur if it was a selection via mouse click
- if(!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
- // Current query needs to be validated
- 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);
- }
-};
-
-/**
- * Handles form submission event.
- *
- * @method _onFormSubmit
- * @param v {HTMLEvent} The submit event.
- * @param oSelf {Object} The AutoComplete instance.
- * @private
- */
-YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
- if(oSelf.allowBrowserAutocomplete) {
- oSelf._oTextbox.setAttribute("autocomplete","on");
- }
- else {
- 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 AutoComplete control provides the front-end logic for text-entry suggestion and
+ * completion functionality.
+ *
+ * @module autocomplete
+ * @requires yahoo, dom, event, datasource
+ * @optional animation, connection
+ * @namespace YAHOO.widget
+ * @title AutoComplete Widget
+ */
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The AutoComplete class provides the customizable functionality of a plug-and-play DHTML
+ * auto completion widget. Some key features:
+ *
+ * Navigate with up/down arrow keys and/or mouse to pick a selection
+ * The drop down container can "roll down" or "fly out" via configurable
+ * animation
+ * UI look-and-feel customizable through CSS, including container
+ * attributes, borders, position, fonts, etc
+ *
+ *
+ * @class AutoComplete
+ * @constructor
+ * @param elInput {HTMLElement} DOM element reference of an input field.
+ * @param elInput {String} String ID of an input field.
+ * @param elContainer {HTMLElement} DOM element reference of an existing DIV.
+ * @param elContainer {String} String ID of an existing DIV.
+ * @param oDataSource {YAHOO.widget.DataSource} DataSource instance.
+ * @param oConfigs {Object} (optional) Object literal of configuration params.
+ */
+YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) {
+ if(elInput && elContainer && oDataSource) {
+ // Validate DataSource
+ if(oDataSource instanceof YAHOO.widget.DataSource) {
+ this.dataSource = oDataSource;
+ }
+ else {
+ return;
+ }
+
+ // Validate input element
+ if(YAHOO.util.Dom.inDocument(elInput)) {
+ if(YAHOO.lang.isString(elInput)) {
+ 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;
+ }
+ YAHOO.util.Dom.addClass(this._oTextbox, "yui-ac-input");
+ }
+ else {
+ return;
+ }
+
+ // Validate container element
+ if(YAHOO.util.Dom.inDocument(elContainer)) {
+ if(YAHOO.lang.isString(elContainer)) {
+ this._oContainer = document.getElementById(elContainer);
+ }
+ else {
+ this._oContainer = elContainer;
+ }
+ if(this._oContainer.style.display == "none") {
+ }
+
+ // For skinning
+ var elParent = this._oContainer.parentNode;
+ var elTag = elParent.tagName.toLowerCase();
+ while(elParent && (elParent != "document")) {
+ if(elTag == "div") {
+ YAHOO.util.Dom.addClass(elParent, "yui-ac");
+ break;
+ }
+ else {
+ elParent = elParent.parentNode;
+ elTag = elParent.tagName.toLowerCase();
+ }
+ }
+ if(elTag != "div") {
+ }
+ }
+ else {
+ return;
+ }
+
+ // Set any config params passed in to override defaults
+ if(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ if(sConfig) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+ }
+
+ // Initialization sequence
+ this._initContainer();
+ this._initProps();
+ this._initList();
+ this._initContainerHelpers();
+
+ // Set up events
+ var oSelf = this;
+ var oTextbox = this._oTextbox;
+ // Events are actually for the content module within the container
+ var oContent = this._oContainer._oContent;
+
+ // Dom events
+ 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);
+
+ // Custom events
+ 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);
+
+ // Finish up
+ oTextbox.setAttribute("autocomplete","off");
+ YAHOO.widget.AutoComplete._nIndex++;
+ }
+ // Required arguments were not found
+ else {
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * The DataSource object that encapsulates the data used for auto completion.
+ * This object should be an inherited object from YAHOO.widget.DataSource.
+ *
+ * @property dataSource
+ * @type YAHOO.widget.DataSource
+ */
+YAHOO.widget.AutoComplete.prototype.dataSource = null;
+
+/**
+ * Number of characters that must be entered before querying for results. A negative value
+ * effectively turns off the widget. A value of 0 allows queries of null or empty string
+ * values.
+ *
+ * @property minQueryLength
+ * @type Number
+ * @default 1
+ */
+YAHOO.widget.AutoComplete.prototype.minQueryLength = 1;
+
+/**
+ * Maximum number of results to display in results container.
+ *
+ * @property maxResultsDisplayed
+ * @type Number
+ * @default 10
+ */
+YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed = 10;
+
+/**
+ * Number of seconds to delay before submitting a query request. If a query
+ * request is received before a previous one has completed its delay, the
+ * previous request is cancelled and the new request is set to the delay.
+ * Implementers should take care when setting this value very low (i.e., less
+ * than 0.2) with low latency DataSources and the typeAhead feature enabled, as
+ * fast typers may see unexpected behavior.
+ *
+ * @property queryDelay
+ * @type Number
+ * @default 0.2
+ */
+YAHOO.widget.AutoComplete.prototype.queryDelay = 0.2;
+
+/**
+ * Class name of a highlighted item within results container.
+ *
+ * @property highlightClassName
+ * @type String
+ * @default "yui-ac-highlight"
+ */
+YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight";
+
+/**
+ * Class name of a pre-highlighted item within results container.
+ *
+ * @property prehighlightClassName
+ * @type String
+ */
+YAHOO.widget.AutoComplete.prototype.prehighlightClassName = null;
+
+/**
+ * Query delimiter. A single character separator for multiple delimited
+ * selections. Multiple delimiter characteres may be defined as an array of
+ * strings. A null value or empty string indicates that query results cannot
+ * be delimited. This feature is not recommended if you need forceSelection to
+ * be true.
+ *
+ * @property delimChar
+ * @type String | String[]
+ */
+YAHOO.widget.AutoComplete.prototype.delimChar = null;
+
+/**
+ * Whether or not the first item in results container should be automatically highlighted
+ * on expand.
+ *
+ * @property autoHighlight
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.AutoComplete.prototype.autoHighlight = true;
+
+/**
+ * Whether or not the input field should be automatically updated
+ * with the first query result as the user types, auto-selecting the substring
+ * that the user has not typed.
+ *
+ * @property typeAhead
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.typeAhead = false;
+
+/**
+ * Whether or not to animate the expansion/collapse of the results container in the
+ * horizontal direction.
+ *
+ * @property animHoriz
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.animHoriz = false;
+
+/**
+ * Whether or not to animate the expansion/collapse of the results container in the
+ * vertical direction.
+ *
+ * @property animVert
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.AutoComplete.prototype.animVert = true;
+
+/**
+ * Speed of container expand/collapse animation, in seconds..
+ *
+ * @property animSpeed
+ * @type Number
+ * @default 0.3
+ */
+YAHOO.widget.AutoComplete.prototype.animSpeed = 0.3;
+
+/**
+ * Whether or not to force the user's selection to match one of the query
+ * results. Enabling this feature essentially transforms the input field into a
+ * <select> field. This feature is not recommended with delimiter character(s)
+ * defined.
+ *
+ * @property forceSelection
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.forceSelection = false;
+
+/**
+ * Whether or not to allow browsers to cache user-typed input in the input
+ * field. Disabling this feature will prevent the widget from setting the
+ * autocomplete="off" on the input field. When autocomplete="off"
+ * and users click the back button after form submission, user-typed input can
+ * be prefilled by the browser from its cache. This caching of user input may
+ * not be desired for sensitive data, such as credit card numbers, in which
+ * case, implementers should consider setting allowBrowserAutocomplete to false.
+ *
+ * @property allowBrowserAutocomplete
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true;
+
+/**
+ * Whether or not the results container should always be displayed.
+ * Enabling this feature displays the container when the widget is instantiated
+ * and prevents the toggling of the container to a collapsed state.
+ *
+ * @property alwaysShowContainer
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.alwaysShowContainer = false;
+
+/**
+ * Whether or not to use an iFrame to layer over Windows form elements in
+ * IE. Set to true only when the results container will be on top of a
+ * <select> field in IE and thus exposed to the IE z-index bug (i.e.,
+ * 5.5 < IE < 7).
+ *
+ * @property useIFrame
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.useIFrame = false;
+
+/**
+ * Whether or not the results container should have a shadow.
+ *
+ * @property useShadow
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.AutoComplete.prototype.useShadow = false;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the AutoComplete instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.toString = function() {
+ return "AutoComplete " + this._sName;
+};
+
+ /**
+ * Returns true if container is in an expanded state, false otherwise.
+ *
+ * @method isContainerOpen
+ * @return {Boolean} Returns true if container is in an expanded state, false otherwise.
+ */
+YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() {
+ return this._bContainerOpen;
+};
+
+/**
+ * Public accessor to the internal array of DOM <li> elements that
+ * display query results within the results container.
+ *
+ * @method getListItems
+ * @return {HTMLElement[]} Array of <li> elements within the results container.
+ */
+YAHOO.widget.AutoComplete.prototype.getListItems = function() {
+ return this._aListItems;
+};
+
+/**
+ * Public accessor to the data held in an <li> element of the
+ * results container.
+ *
+ * @method getListItemData
+ * @return {Object | Object[]} Object or array of result data or null
+ */
+YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
+ if(oListItem._oResultData) {
+ return oListItem._oResultData;
+ }
+ else {
+ return false;
+ }
+};
+
+/**
+ * Sets HTML markup for the results container header. This markup will be
+ * inserted within a <div> tag with a class of "yui-ac-hd".
+ *
+ * @method setHeader
+ * @param sHeader {String} HTML markup for results container header.
+ */
+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";
+ }
+};
+
+/**
+ * Sets HTML markup for the results container footer. This markup will be
+ * inserted within a <div> tag with a class of "yui-ac-ft".
+ *
+ * @method setFooter
+ * @param sFooter {String} HTML markup for results container footer.
+ */
+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";
+ }
+};
+
+/**
+ * Sets HTML markup for the results container body. This markup will be
+ * inserted within a <div> tag with a class of "yui-ac-bd".
+ *
+ * @method setBody
+ * @param sBody {String} HTML markup for results container body.
+ */
+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;
+};
+
+/**
+ * Overridable method that converts a result item object into HTML markup
+ * for display. Return data values are accessible via the oResultItem object,
+ * and the key return value will always be oResultItem[0]. Markup will be
+ * displayed within <li> element tags in the container.
+ *
+ * @method formatResult
+ * @param oResultItem {Object} Result item representing one query result. Data is held in an array.
+ * @param sQuery {String} The current query string.
+ * @return {String} HTML markup of formatted result data.
+ */
+YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery) {
+ var sResult = oResultItem[0];
+ if(sResult) {
+ return sResult;
+ }
+ else {
+ return "";
+ }
+};
+
+/**
+ * Overridable method called before container expands allows implementers to access data
+ * and DOM elements.
+ *
+ * @method doBeforeExpandContainer
+ * @param oTextbox {HTMLElement} The text input box.
+ * @param oContainer {HTMLElement} The container element.
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} An array of query results.
+ * @return {Boolean} Return true to continue expanding container, false to cancel the expand.
+ */
+YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {
+ return true;
+};
+
+/**
+ * Makes query request to the DataSource.
+ *
+ * @method sendQuery
+ * @param sQuery {String} Query string.
+ */
+YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) {
+ this._sendQuery(sQuery);
+};
+
+/**
+ * Overridable method gives implementers access to the query before it gets sent.
+ *
+ * @method doBeforeSendQuery
+ * @param sQuery {String} Query string.
+ * @return {String} Query string.
+ */
+YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery = function(sQuery) {
+ return sQuery;
+};
+
+/**
+ * Nulls out the entire AutoComplete instance and related objects, removes attached
+ * event listeners, and clears out DOM elements inside the container. After
+ * calling this method, the instance reference should be expliclitly nulled by
+ * implementer, as in myDataTable = null. Use with caution!
+ *
+ * @method destroy
+ */
+YAHOO.widget.AutoComplete.prototype.destroy = function() {
+ var instanceName = this.toString();
+ var elInput = this._oTextbox;
+ var elContainer = this._oContainer;
+
+ // Unhook custom events
+ this.textboxFocusEvent.unsubscribe();
+ this.textboxKeyEvent.unsubscribe();
+ this.dataRequestEvent.unsubscribe();
+ this.dataReturnEvent.unsubscribe();
+ this.dataErrorEvent.unsubscribe();
+ this.containerExpandEvent.unsubscribe();
+ this.typeAheadEvent.unsubscribe();
+ this.itemMouseOverEvent.unsubscribe();
+ this.itemMouseOutEvent.unsubscribe();
+ this.itemArrowToEvent.unsubscribe();
+ this.itemArrowFromEvent.unsubscribe();
+ this.itemSelectEvent.unsubscribe();
+ this.unmatchedItemSelectEvent.unsubscribe();
+ this.selectionEnforceEvent.unsubscribe();
+ this.containerCollapseEvent.unsubscribe();
+ this.textboxBlurEvent.unsubscribe();
+
+ // Unhook DOM events
+ YAHOO.util.Event.purgeElement(elInput, true);
+ YAHOO.util.Event.purgeElement(elContainer, true);
+
+ // Remove DOM elements
+ elContainer.innerHTML = "";
+
+ // Null out objects
+ for(var key in this) {
+ if(this.hasOwnProperty(key)) {
+ this[key] = null;
+ }
+ }
+
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public events
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Fired when the input field receives focus.
+ *
+ * @event textboxFocusEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null;
+
+/**
+ * Fired when the input field receives key input.
+ *
+ * @event textboxKeyEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param nKeycode {Number} The keycode number.
+ */
+YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null;
+
+/**
+ * Fired when the AutoComplete instance makes a query to the DataSource.
+ *
+ * @event dataRequestEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The query string.
+ */
+YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null;
+
+/**
+ * Fired when the AutoComplete instance receives query results from the data
+ * source.
+ *
+ * @event dataReturnEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} Results array.
+ */
+YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
+
+/**
+ * Fired when the AutoComplete instance does not receive query results from the
+ * DataSource due to an error.
+ *
+ * @event dataErrorEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The query string.
+ */
+YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
+
+/**
+ * Fired when the results container is expanded.
+ *
+ * @event containerExpandEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
+
+/**
+ * Fired when the input field has been prefilled by the type-ahead
+ * feature.
+ *
+ * @event typeAheadEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The query string.
+ * @param sPrefill {String} The prefill string.
+ */
+YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null;
+
+/**
+ * Fired when result item has been moused over.
+ *
+ * @event itemMouseOverEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The <li> element item moused to.
+ */
+YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
+
+/**
+ * Fired when result item has been moused out.
+ *
+ * @event itemMouseOutEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The <li> element item moused from.
+ */
+YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
+
+/**
+ * Fired when result item has been arrowed to.
+ *
+ * @event itemArrowToEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The <li> element item arrowed to.
+ */
+YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null;
+
+/**
+ * Fired when result item has been arrowed away from.
+ *
+ * @event itemArrowFromEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The <li> element item arrowed from.
+ */
+YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent = null;
+
+/**
+ * Fired when an item is selected via mouse click, ENTER key, or TAB key.
+ *
+ * @event itemSelectEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param elItem {HTMLElement} The selected <li> element item.
+ * @param oData {Object} The data returned for the item, either as an object,
+ * or mapped from the schema into an array.
+ */
+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.
+ *
+ * @event unmatchedItemSelectEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @param sQuery {String} The user-typed query string.
+ */
+YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
+
+/**
+ * Fired if forceSelection is enabled and the user's input has been cleared
+ * because it did not match one of the returned query results.
+ *
+ * @event selectionEnforceEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
+
+/**
+ * Fired when the results container is collapsed.
+ *
+ * @event containerCollapseEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null;
+
+/**
+ * Fired when the input field loses focus.
+ *
+ * @event textboxBlurEvent
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ */
+YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Internal class variable to index multiple AutoComplete instances.
+ *
+ * @property _nIndex
+ * @type Number
+ * @default 0
+ * @private
+ */
+YAHOO.widget.AutoComplete._nIndex = 0;
+
+/**
+ * Name of AutoComplete instance.
+ *
+ * @property _sName
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sName = null;
+
+/**
+ * Text input field DOM element.
+ *
+ * @property _oTextbox
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oTextbox = null;
+
+/**
+ * Whether or not the input field is currently in focus. If query results come back
+ * but the user has already moved on, do not proceed with auto complete behavior.
+ *
+ * @property _bFocused
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bFocused = true;
+
+/**
+ * Animation instance for container expand/collapse.
+ *
+ * @property _oAnim
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oAnim = null;
+
+/**
+ * Container DOM element.
+ *
+ * @property _oContainer
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oContainer = null;
+
+/**
+ * Whether or not the results container is currently open.
+ *
+ * @property _bContainerOpen
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;
+
+/**
+ * Whether or not the mouse is currently over the results
+ * container. This is necessary in order to prevent clicks on container items
+ * from being text input field blur events.
+ *
+ * @property _bOverContainer
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bOverContainer = false;
+
+/**
+ * Array of <li> elements references that contain query results within the
+ * results container.
+ *
+ * @property _aListItems
+ * @type HTMLElement[]
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._aListItems = null;
+
+/**
+ * Number of <li> elements currently displayed in results container.
+ *
+ * @property _nDisplayedItems
+ * @type Number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0;
+
+/**
+ * Internal count of <li> elements displayed and hidden in results container.
+ *
+ * @property _maxResultsDisplayed
+ * @type Number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0;
+
+/**
+ * Current query string
+ *
+ * @property _sCurQuery
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sCurQuery = null;
+
+/**
+ * Past queries this session (for saving delimited queries).
+ *
+ * @property _sSavedQuery
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sSavedQuery = null;
+
+/**
+ * Pointer to the currently highlighted <li> element in the container.
+ *
+ * @property _oCurItem
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oCurItem = null;
+
+/**
+ * Whether or not an item has been selected since the container was populated
+ * with results. Reset to false by _populateList, and set to true when item is
+ * selected.
+ *
+ * @property _bItemSelected
+ * @type Boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bItemSelected = false;
+
+/**
+ * Key code of the last key pressed in textbox.
+ *
+ * @property _nKeyCode
+ * @type Number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nKeyCode = null;
+
+/**
+ * Delay timeout ID.
+ *
+ * @property _nDelayID
+ * @type Number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nDelayID = -1;
+
+/**
+ * Src to iFrame used when useIFrame = true. Supports implementations over SSL
+ * as well.
+ *
+ * @property _iFrameSrc
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;";
+
+/**
+ * For users typing via certain IMEs, queries must be triggered by intervals,
+ * since key events yet supported across all browsers for all IMEs.
+ *
+ * @property _queryInterval
+ * @type Object
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._queryInterval = null;
+
+/**
+ * Internal tracker to last known textbox value, used to determine whether or not
+ * to trigger a query via interval for certain IME users.
+ *
+ * @event _sLastTextboxValue
+ * @type String
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Updates and validates latest public config properties.
+ *
+ * @method __initProps
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initProps = function() {
+ // Correct any invalid values
+ var minQueryLength = this.minQueryLength;
+ if(!YAHOO.lang.isNumber(minQueryLength)) {
+ this.minQueryLength = 1;
+ }
+ var maxResultsDisplayed = this.maxResultsDisplayed;
+ if(!YAHOO.lang.isNumber(maxResultsDisplayed) || (maxResultsDisplayed < 1)) {
+ this.maxResultsDisplayed = 10;
+ }
+ var queryDelay = this.queryDelay;
+ if(!YAHOO.lang.isNumber(queryDelay) || (queryDelay < 0)) {
+ this.queryDelay = 0.2;
+ }
+ var delimChar = this.delimChar;
+ if(YAHOO.lang.isString(delimChar)) {
+ this.delimChar = [delimChar];
+ }
+ else if(!YAHOO.lang.isArray(delimChar)) {
+ this.delimChar = null;
+ }
+ var animSpeed = this.animSpeed;
+ if((this.animHoriz || this.animVert) && YAHOO.util.Anim) {
+ if(!YAHOO.lang.isNumber(animSpeed) || (animSpeed < 0)) {
+ this.animSpeed = 0.3;
+ }
+ if(!this._oAnim ) {
+ this._oAnim = new YAHOO.util.Anim(this._oContainer._oContent, {}, this.animSpeed);
+ }
+ else {
+ this._oAnim.duration = this.animSpeed;
+ }
+ }
+ if(this.forceSelection && delimChar) {
+ }
+};
+
+/**
+ * Initializes the results container helpers if they are enabled and do
+ * not exist
+ *
+ * @method _initContainerHelpers
+ * @private
+ */
+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);
+ }
+};
+
+/**
+ * Initializes the results container once at object creation
+ *
+ * @method _initContainer
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initContainer = function() {
+ YAHOO.util.Dom.addClass(this._oContainer, "yui-ac-container");
+
+ if(!this._oContainer._oContent) {
+ // The oContent div helps size the iframe and shadow properly
+ 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 {
+ }
+};
+
+/**
+ * Clears out contents of container body and creates up to
+ * YAHOO.widget.AutoComplete#maxResultsDisplayed <li> elements in an
+ * <ul> element.
+ *
+ * @method _initList
+ * @private
+ */
+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; oldi--) {
+ 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) || // alt,pause/break,caps lock
+ (nKeyCode == 27) || // esc
+ (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end
+ /*(nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up
+ (nKeyCode == 40) || // down*/
+ (nKeyCode >= 36 && nKeyCode <= 40) || // home,left,up, right, down
+ (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert
+ return true;
+ }
+ return false;
+};
+
+/**
+ * Makes query request to the DataSource.
+ *
+ * @method _sendQuery
+ * @param sQuery {String} Query string.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) {
+ // Widget has been effectively turned off
+ if(this.minQueryLength == -1) {
+ this._toggleContainer(false);
+ return;
+ }
+ // Delimiter has been enabled
+ var aDelimChar = (this.delimChar) ? this.delimChar : null;
+ if(aDelimChar) {
+ // Loop through all possible delimiters and find the latest one
+ // A " " may be a false positive if they are defined as delimiters AND
+ // are used to separate delimited queries
+ var nDelimIndex = -1;
+ for(var i = aDelimChar.length-1; i >= 0; i--) {
+ var nNewIndex = sQuery.lastIndexOf(aDelimChar[i]);
+ if(nNewIndex > nDelimIndex) {
+ nDelimIndex = nNewIndex;
+ }
+ }
+ // If we think the last delimiter is a space (" "), make sure it is NOT
+ // a false positive by also checking the char directly before it
+ if(aDelimChar[i] == " ") {
+ for (var j = aDelimChar.length-1; j >= 0; j--) {
+ if(sQuery[nDelimIndex - 1] == aDelimChar[j]) {
+ nDelimIndex--;
+ break;
+ }
+ }
+ }
+ // A delimiter has been found so extract the latest query
+ if(nDelimIndex > -1) {
+ var nQueryStart = nDelimIndex + 1;
+ // Trim any white space from the beginning...
+ while(sQuery.charAt(nQueryStart) == " ") {
+ nQueryStart += 1;
+ }
+ // ...and save the rest of the string for later
+ this._sSavedQuery = sQuery.substring(0,nQueryStart);
+ // Here is the query itself
+ sQuery = sQuery.substr(nQueryStart);
+ }
+ else if(sQuery.indexOf(this._sSavedQuery) < 0){
+ this._sSavedQuery = null;
+ }
+ }
+
+ // Don't search queries that are too short
+ if((sQuery && (sQuery.length < this.minQueryLength)) || (!sQuery && this.minQueryLength > 0)) {
+ if(this._nDelayID != -1) {
+ clearTimeout(this._nDelayID);
+ }
+ this._toggleContainer(false);
+ return;
+ }
+
+ sQuery = encodeURIComponent(sQuery);
+ this._nDelayID = -1; // Reset timeout ID because request has been made
+ sQuery = this.doBeforeSendQuery(sQuery);
+ this.dataRequestEvent.fire(this, sQuery);
+ this.dataSource.getResults(this._populateList, sQuery, this);
+};
+
+/**
+ * Populates the array of <li> elements in the container with query
+ * results. This method is passed to YAHOO.widget.DataSource#getResults as a
+ * callback function so results from the DataSource instance are returned to the
+ * AutoComplete instance.
+ *
+ * @method _populateList
+ * @param sQuery {String} The query string.
+ * @param aResults {Object[]} An array of query result objects from the DataSource.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+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;
+
+ // Fill items with data
+ 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;
+
+ }
+
+ // Empty out remaining items if any
+ 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;
+ }
+
+ // Expand the container
+ var ok = oSelf.doBeforeExpandContainer(oSelf._oTextbox, oSelf._oContainer, sQuery, aResults);
+ oSelf._toggleContainer(ok);
+
+ if(oSelf.autoHighlight) {
+ // Go to the first item
+ var oFirstItem = aItems[0];
+ oSelf._toggleHighlight(oFirstItem,"to");
+ oSelf.itemArrowToEvent.fire(oSelf, oFirstItem);
+ oSelf._typeAhead(oFirstItem,sQuery);
+ }
+ else {
+ oSelf._oCurItem = null;
+ }
+ }
+ else {
+ oSelf._toggleContainer(false);
+ }
+ oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults);
+
+};
+
+/**
+ * When forceSelection is true and the user attempts
+ * leave the text input box without selecting an item from the query results,
+ * the user selection is cleared.
+ *
+ * @method _clearSelection
+ * @private
+ */
+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;
+
+ // Fire custom event
+ this.selectionEnforceEvent.fire(this);
+};
+
+/**
+ * Whether or not user-typed value in the text input box matches any of the
+ * query results.
+ *
+ * @method _textMatchesOption
+ * @return {HTMLElement} Matching list item element if user-input text matches
+ * a result, null otherwise.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._textMatchesOption = function() {
+ var foundMatch = null;
+
+ 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 = oItem;
+ break;
+ }
+ }
+ return(foundMatch);
+};
+
+/**
+ * Updates in the text input box with the first query result as the user types,
+ * selecting the substring that the user has not typed.
+ *
+ * @method _typeAhead
+ * @param oItem {HTMLElement} The <li> element item whose data populates the input field.
+ * @param sQuery {String} Query string.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
+ // Don't update if turned off
+ if(!this.typeAhead || (this._nKeyCode == 8)) {
+ return;
+ }
+
+ var oTextbox = this._oTextbox;
+ var sValue = this._oTextbox.value; // any saved queries plus what user has typed
+
+ // Don't update with type-ahead if text selection is not supported
+ if(!oTextbox.setSelectionRange && !oTextbox.createTextRange) {
+ return;
+ }
+
+ // Select the portion of text that the user has not typed
+ 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);
+};
+
+/**
+ * Selects text in the input field.
+ *
+ * @method _selectText
+ * @param oTextbox {HTMLElement} Text input box element in which to select text.
+ * @param nStart {Number} Starting index of text string to select.
+ * @param nEnd {Number} Ending index of text selection.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEnd) {
+ if(oTextbox.setSelectionRange) { // For Mozilla
+ oTextbox.setSelectionRange(nStart,nEnd);
+ }
+ else if(oTextbox.createTextRange) { // For IE
+ var oTextRange = oTextbox.createTextRange();
+ oTextRange.moveStart("character", nStart);
+ oTextRange.moveEnd("character", nEnd-oTextbox.value.length);
+ oTextRange.select();
+ }
+ else {
+ oTextbox.select();
+ }
+};
+
+/**
+ * Syncs results container with its helpers.
+ *
+ * @method _toggleContainerHelpers
+ * @param bShow {Boolean} True if container is expanded, false if collapsed
+ * @private
+ */
+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;
+ }
+ }
+};
+
+/**
+ * Animates expansion or collapse of the container.
+ *
+ * @method _toggleContainer
+ * @param bShow {Boolean} True if container should be expanded, false if container should be collapsed
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
+ var oContainer = this._oContainer;
+
+ // Implementer has container always open so don't mess with it
+ if(this.alwaysShowContainer && this._bContainerOpen) {
+ return;
+ }
+
+ // Clear contents of container
+ 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;
+ }
+
+ // Container is already closed
+ if(!bShow && !this._bContainerOpen) {
+ oContainer._oContent.style.display = "none";
+ return;
+ }
+
+ // If animation is enabled...
+ var oAnim = this._oAnim;
+ if(oAnim && oAnim.getEl() && (this.animHoriz || this.animVert)) {
+ // If helpers need to be collapsed, do it right away...
+ // but if helpers need to be expanded, wait until after the container expands
+ if(!bShow) {
+ this._toggleContainerHelpers(bShow);
+ }
+
+ if(oAnim.isAnimated()) {
+ oAnim.stop();
+ }
+
+ // Clone container to grab current size offscreen
+ var oClone = oContainer._oContent.cloneNode(true);
+ oContainer.appendChild(oClone);
+ oClone.style.top = "-9000px";
+ oClone.style.display = "block";
+
+ // Current size of the container is the EXPANDED size
+ var wExp = oClone.offsetWidth;
+ var hExp = oClone.offsetHeight;
+
+ // Calculate COLLAPSED sizes based on horiz and vert anim
+ var wColl = (this.animHoriz) ? 0 : wExp;
+ var hColl = (this.animVert) ? 0 : hExp;
+
+ // Set animation sizes
+ oAnim.attributes = (bShow) ?
+ {width: { to: wExp }, height: { to: hExp }} :
+ {width: { to: wColl}, height: { to: hColl }};
+
+ // If opening anew, set to a collapsed size...
+ if(bShow && !this._bContainerOpen) {
+ oContainer._oContent.style.width = wColl+"px";
+ oContainer._oContent.style.height = hColl+"px";
+ }
+ // Else, set it to its last known size.
+ else {
+ oContainer._oContent.style.width = wExp+"px";
+ oContainer._oContent.style.height = hExp+"px";
+ }
+
+ oContainer.removeChild(oClone);
+ oClone = null;
+
+ var oSelf = this;
+ var onAnimComplete = function() {
+ // Finish the collapse
+ oAnim.onComplete.unsubscribeAll();
+
+ if(bShow) {
+ oSelf.containerExpandEvent.fire(oSelf);
+ }
+ else {
+ oContainer._oContent.style.display = "none";
+ oSelf.containerCollapseEvent.fire(oSelf);
+ }
+ oSelf._toggleContainerHelpers(bShow);
+ };
+
+ // Display container and animate it
+ oContainer._oContent.style.display = "block";
+ oAnim.onComplete.subscribe(onAnimComplete);
+ oAnim.animate();
+ this._bContainerOpen = bShow;
+ }
+ // Else don't animate, just show or hide
+ 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;
+ }
+
+};
+
+/**
+ * Toggles the highlight on or off for an item in the container, and also cleans
+ * up highlighting of any previous item.
+ *
+ * @method _toggleHighlight
+ * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
+ * @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleHighlight = function(oNewItem, sType) {
+ var sHighlight = this.highlightClassName;
+ if(this._oCurItem) {
+ // Remove highlight from old item
+ YAHOO.util.Dom.removeClass(this._oCurItem, sHighlight);
+ }
+
+ if((sType == "to") && sHighlight) {
+ // Apply highlight to new item
+ YAHOO.util.Dom.addClass(oNewItem, sHighlight);
+ this._oCurItem = oNewItem;
+ }
+};
+
+/**
+ * Toggles the pre-highlight on or off for an item in the container.
+ *
+ * @method _togglePrehighlight
+ * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior.
+ * @param sType {String} Type "mouseover" will toggle highlight on, and "mouseout" will toggle highlight off.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function(oNewItem, sType) {
+ if(oNewItem == this._oCurItem) {
+ return;
+ }
+
+ var sPrehighlight = this.prehighlightClassName;
+ if((sType == "mouseover") && sPrehighlight) {
+ // Apply prehighlight to new item
+ YAHOO.util.Dom.addClass(oNewItem, sPrehighlight);
+ }
+ else {
+ // Remove prehighlight from old item
+ YAHOO.util.Dom.removeClass(oNewItem, sPrehighlight);
+ }
+};
+
+/**
+ * Updates the text input box value with selected query result. If a delimiter
+ * has been defined, then the value gets appended with the delimiter.
+ *
+ * @method _updateValue
+ * @param oItem {HTMLElement} The <li> element item with which to update the value.
+ * @private
+ */
+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();
+
+ // First clear text field
+ oTextbox.value = "";
+ // Grab data to put into text field
+ if(sDelimChar) {
+ if(sSavedQuery) {
+ oTextbox.value = sSavedQuery;
+ }
+ oTextbox.value += sResultKey + sDelimChar;
+ if(sDelimChar != " ") {
+ oTextbox.value += " ";
+ }
+ }
+ else { oTextbox.value = sResultKey; }
+
+ // scroll to bottom of textarea if necessary
+ if(oTextbox.type == "textarea") {
+ oTextbox.scrollTop = oTextbox.scrollHeight;
+ }
+
+ // move cursor to end
+ var end = oTextbox.value.length;
+ this._selectText(oTextbox,end,end);
+
+ this._oCurItem = oItem;
+};
+
+/**
+ * Selects a result item from the container
+ *
+ * @method _selectItem
+ * @param oItem {HTMLElement} The selected <li> element item.
+ * @private
+ */
+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);
+};
+
+/**
+ * If an item is highlighted in the container, the right arrow key jumps to the
+ * end of the textbox and selects the highlighted item, otherwise the container
+ * is closed.
+ *
+ * @method _jumpSelection
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._jumpSelection = function() {
+ if(this._oCurItem) {
+ this._selectItem(this._oCurItem);
+ }
+ else {
+ this._toggleContainer(false);
+ }
+};
+
+/**
+ * Triggered by up and down arrow keys, changes the current highlighted
+ * <li> element item. Scrolls container if necessary.
+ *
+ * @method _moveSelection
+ * @param nKeyCode {Number} Code of key pressed.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
+ if(this._bContainerOpen) {
+ // Determine current item's id number
+ var oCurItem = this._oCurItem;
+ var nCurItemIndex = -1;
+
+ if(oCurItem) {
+ nCurItemIndex = oCurItem._nItemIndex;
+ }
+
+ var nNewItemIndex = (nKeyCode == 40) ?
+ (nCurItemIndex + 1) : (nCurItemIndex - 1);
+
+ // Out of bounds
+ if(nNewItemIndex < -2 || nNewItemIndex >= this._nDisplayedItems) {
+ return;
+ }
+
+ if(oCurItem) {
+ // Unhighlight current item
+ this._toggleHighlight(oCurItem, "from");
+ this.itemArrowFromEvent.fire(this, oCurItem);
+ }
+ if(nNewItemIndex == -1) {
+ // Go back to query (remove type-ahead string)
+ 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) {
+ // Close container
+ this._toggleContainer(false);
+ return;
+ }
+
+ var oNewItem = this._aListItems[nNewItemIndex];
+
+ // Scroll the container if necessary
+ 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 < this._nDisplayedItems)) {
+ // User is keying down
+ if(nKeyCode == 40) {
+ // Bottom of selected item is below scroll area...
+ if((oNewItem.offsetTop+oNewItem.offsetHeight) > (oContent.scrollTop + oContent.offsetHeight)) {
+ // Set bottom of scroll area to bottom of selected item
+ oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight;
+ }
+ // Bottom of selected item is above scroll area...
+ else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) {
+ // Set top of selected item to top of scroll area
+ oContent.scrollTop = oNewItem.offsetTop;
+
+ }
+ }
+ // User is keying up
+ else {
+ // Top of selected item is above scroll area
+ if(oNewItem.offsetTop < oContent.scrollTop) {
+ // Set top of scroll area to top of selected item
+ this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
+ }
+ // Top of selected item is below scroll area
+ else if(oNewItem.offsetTop > (oContent.scrollTop + oContent.offsetHeight)) {
+ // Set bottom of selected item to bottom of scroll area
+ 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);
+ }
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Private event handlers
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Handles <li> element mouseover events in the container.
+ *
+ * @method _onItemMouseover
+ * @param v {HTMLEvent} The mouseover event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+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);
+};
+
+/**
+ * Handles <li> element mouseout events in the container.
+ *
+ * @method _onItemMouseout
+ * @param v {HTMLEvent} The mouseout event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+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);
+};
+
+/**
+ * Handles <li> element click events in the container.
+ *
+ * @method _onItemMouseclick
+ * @param v {HTMLEvent} The click event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onItemMouseclick = function(v,oSelf) {
+ // In case item has not been moused over
+ oSelf._toggleHighlight(this,"to");
+ oSelf._selectItem(this);
+};
+
+/**
+ * Handles container mouseover events.
+ *
+ * @method _onContainerMouseover
+ * @param v {HTMLEvent} The mouseover event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) {
+ oSelf._bOverContainer = true;
+};
+
+/**
+ * Handles container mouseout events.
+ *
+ * @method _onContainerMouseout
+ * @param v {HTMLEvent} The mouseout event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerMouseout = function(v,oSelf) {
+ oSelf._bOverContainer = false;
+ // If container is still active
+ if(oSelf._oCurItem) {
+ oSelf._toggleHighlight(oSelf._oCurItem,"to");
+ }
+};
+
+/**
+ * Handles container scroll events.
+ *
+ * @method _onContainerScroll
+ * @param v {HTMLEvent} The scroll event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) {
+ oSelf._oTextbox.focus();
+};
+
+/**
+ * Handles container resize events.
+ *
+ * @method _onContainerResize
+ * @param v {HTMLEvent} The resize event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerResize = function(v,oSelf) {
+ oSelf._toggleContainerHelpers(oSelf._bContainerOpen);
+};
+
+
+/**
+ * Handles textbox keydown events of functional keys, mainly for UI behavior.
+ *
+ * @method _onTextboxKeyDown
+ * @param v {HTMLEvent} The keydown event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) {
+ var nKeyCode = v.keyCode;
+
+ switch (nKeyCode) {
+ case 9: // tab
+ // select an item or clear out
+ if(oSelf._oCurItem) {
+ if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._toggleContainer(false);
+ }
+ break;
+ case 13: // enter
+ if(oSelf._oCurItem) {
+ if(oSelf._nKeyCode != nKeyCode) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._toggleContainer(false);
+ }
+ break;
+ case 27: // esc
+ oSelf._toggleContainer(false);
+ return;
+ case 39: // right
+ oSelf._jumpSelection();
+ break;
+ case 38: // up
+ YAHOO.util.Event.stopEvent(v);
+ oSelf._moveSelection(nKeyCode);
+ break;
+ case 40: // down
+ YAHOO.util.Event.stopEvent(v);
+ oSelf._moveSelection(nKeyCode);
+ break;
+ default:
+ break;
+ }
+};
+
+/**
+ * Handles textbox keypress events.
+ * @method _onTextboxKeyPress
+ * @param v {HTMLEvent} The keypress event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) {
+ var nKeyCode = v.keyCode;
+
+ //Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337)
+ var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1);
+ if(isMac) {
+ switch (nKeyCode) {
+ case 9: // tab
+ if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ break;
+ case 13: // enter
+ if(oSelf._nKeyCode != nKeyCode) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ break;
+ case 38: // up
+ case 40: // down
+ YAHOO.util.Event.stopEvent(v);
+ break;
+ default:
+ break;
+ }
+ }
+
+ //TODO: (?) limit only to non-IE, non-Mac-FF for Korean IME support (bug 811948)
+ // Korean IME detected
+ else if(nKeyCode == 229) {
+ oSelf._queryInterval = setInterval(function() { oSelf._onIMEDetected(oSelf); },500);
+ }
+};
+
+/**
+ * Handles textbox keyup events that trigger queries.
+ *
+ * @method _onTextboxKeyUp
+ * @param v {HTMLEvent} The keyup event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
+ // Check to see if any of the public properties have been updated
+ oSelf._initProps();
+
+ var nKeyCode = v.keyCode;
+ oSelf._nKeyCode = nKeyCode;
+ var sText = this.value; //string in textbox
+
+ // Filter out chars that don't trigger queries
+ if(oSelf._isIgnoreKey(nKeyCode) || (sText.toLowerCase() == oSelf._sCurQuery)) {
+ return;
+ }
+ else {
+ oSelf._bItemSelected = false;
+ YAHOO.util.Dom.removeClass(oSelf._oCurItem, oSelf.highlightClassName);
+ oSelf._oCurItem = null;
+
+ oSelf.textboxKeyEvent.fire(oSelf, nKeyCode);
+ }
+
+ // Set timeout on the request
+ 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 {
+ // No delay so send request immediately
+ oSelf._sendQuery(sText);
+ }
+};
+
+/**
+ * Handles text input box receiving focus.
+ *
+ * @method _onTextboxFocus
+ * @param v {HTMLEvent} The focus event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
+ oSelf._oTextbox.setAttribute("autocomplete","off");
+ oSelf._bFocused = true;
+ if(!oSelf._bItemSelected) {
+ oSelf.textboxFocusEvent.fire(oSelf);
+ }
+};
+
+/**
+ * Handles text input box losing focus.
+ *
+ * @method _onTextboxBlur
+ * @param v {HTMLEvent} The focus event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
+ // Don't treat as a blur if it was a selection via mouse click
+ if(!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
+ // Current query needs to be validated
+ if(!oSelf._bItemSelected) {
+ var oMatch = oSelf._textMatchesOption();
+ if(!oSelf._bContainerOpen || (oSelf._bContainerOpen && (oMatch === null))) {
+ if(oSelf.forceSelection) {
+ oSelf._clearSelection();
+ }
+ else {
+ oSelf.unmatchedItemSelectEvent.fire(oSelf, oSelf._sCurQuery);
+ }
+ }
+ else {
+ oSelf._selectItem(oMatch);
+ }
+ }
+
+ if(oSelf._bContainerOpen) {
+ oSelf._toggleContainer(false);
+ }
+ oSelf._cancelIntervalDetection(oSelf);
+ oSelf._bFocused = false;
+ oSelf.textboxBlurEvent.fire(oSelf);
+ }
+};
+
+/**
+ * Handles form submission event.
+ *
+ * @method _onFormSubmit
+ * @param v {HTMLEvent} The submit event.
+ * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
+ if(oSelf.allowBrowserAutocomplete) {
+ oSelf._oTextbox.setAttribute("autocomplete","on");
+ }
+ else {
+ 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 fine-tune the matching algorithm used against JS Array types of
+ * DataSource and DataSource caches. If queryMatchContains is true, then the JS
+ * Array or cache returns results that "contain" the query string. By default,
+ * queryMatchContains is set to false, so that only results that "start with"
+ * the query string are returned.
+ *
+ * @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 case-sensitivity in the matching algorithm used against JS Array
+ * types of DataSources and DataSource caches. If queryMatchCase is true, only
+ * case-sensitive matches will return.
+ *
+ * @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(!YAHOO.lang.isNumber(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(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!YAHOO.lang.isArray(aSchema) || !YAHOO.lang.isString(sScriptURI)) {
+ return;
+ }
+
+ 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(YAHOO.lang.isNumber(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, jsonObjParsed;
+ // Check for JSON lib but divert KHTML clients
+ var isNotMac = (navigator.userAgent.toLowerCase().indexOf('khtml')== -1);
+ if(oResponse.parseJSON && isNotMac) {
+ // Use the new JSON utility if available
+ jsonObjParsed = oResponse.parseJSON();
+ if(!jsonObjParsed) {
+ bError = true;
+ }
+ else {
+ try {
+ // eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("jsonObjParsed." + aSchema[0]);
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+ }
+ else if(window.JSON && isNotMac) {
+ // Use older JSON lib if available
+ 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(!YAHOO.lang.isArray(jsonList)) {
+ 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(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!YAHOO.lang.isFunction(oFunction)) {
+ 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(oConfigs && (oConfigs.constructor == Object)) {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!YAHOO.lang.isArray(aData)) {
+ 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 i;
+ 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(i = aData.length-1; i >= 0; i--) {
+ var aDataset = [];
+
+ if(YAHOO.lang.isString(aData[i])) {
+ aDataset[0] = aData[i];
+ }
+ else if(YAHOO.lang.isArray(aData[i])) {
+ aDataset = aData[i];
+ }
+
+ if(YAHOO.lang.isString(aDataset[0])) {
+ 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);
+ }
+ }
+ }
+ }
+ else {
+ for(i = aData.length-1; i >= 0; i--) {
+ if(YAHOO.lang.isString(aData[i])) {
+ aResults.unshift([aData[i]]);
+ }
+ else if(YAHOO.lang.isArray(aData[i])) {
+ aResults.unshift(aData[i]);
+ }
+ }
+ }
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ oCallbackFn(sQuery, aResults, oParent);
+};
+
+YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/base/README b/lib/yui/base/README
new file mode 100755
index 0000000000..287f22ea11
--- /dev/null
+++ b/lib/yui/base/README
@@ -0,0 +1,5 @@
+YUI Library - Base - Release Notes
+
+Version 2.3.0
+
+ * Initial release.
\ No newline at end of file
diff --git a/lib/yui/base/base-min.css b/lib/yui/base/base-min.css
new file mode 100755
index 0000000000..a4dcc816f6
--- /dev/null
+++ b/lib/yui/base/base-min.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+h1{font-size:138.5%;}h2{font-size:123.1%;}h3{font-size:108%;}h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:bold;}abbr,acronym{border-bottom:1px dotted #000;cursor:help;}em{font-style:italic;}blockquote,ul,ol,dl{margin:1em;}ol,ul,dl{margin-left:2em;}ol li{list-style: decimal outside;}ul li{list-style: disc outside;}dl dd{margin-left:1em;}th,td {border:1px solid #000;padding:.5em;}th {font-weight:bold;text-align:center;}caption {margin-bottom:.5em;text-align:center;}p,fieldset,table {margin-bottom:1em;}
\ No newline at end of file
diff --git a/lib/yui/base/base.css b/lib/yui/base/base.css
new file mode 100755
index 0000000000..85dcca7dd2
--- /dev/null
+++ b/lib/yui/base/base.css
@@ -0,0 +1,76 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+/* base.css, part of YUI's CSS Foundation */
+h1 {
+ /*18px via YUI Fonts CSS foundation*/
+ font-size:138.5%;
+}
+h2 {
+ /*16px via YUI Fonts CSS foundation*/
+ font-size:123.1%;
+}
+h3 {
+ /*14px via YUI Fonts CSS foundation*/
+ font-size:108%;
+}
+h1,h2,h3 {
+ /* top & bottom margin based on font size */
+ margin:1em 0;
+}
+h1,h2,h3,h4,h5,h6,strong {
+ /*bringing boldness back to headers and the strong element*/
+ font-weight:bold;
+}
+abbr,acronym {
+ /*indicating to users that more info is available */
+ border-bottom:1px dotted #000;
+ cursor:help;
+}
+em {
+ /*bringing italics back to the em element*/
+ font-style:italic;
+}
+blockquote,ul,ol,dl {
+ /*giving blockquotes and lists room to breath*/
+ margin:1em;
+}
+ol,ul,dl {
+ /*bringing lists on to the page with breathing room */
+ margin-left:2em;
+}
+ol li {
+ /*giving OL's LIs generated numbers*/
+ list-style: decimal outside;
+}
+ul li {
+ /*giving UL's LIs generated disc markers*/
+ list-style: disc outside;
+}
+dl dd {
+ /*giving UL's LIs generated numbers*/
+ margin-left:1em;
+}
+th,td {
+ /*borders and padding to make the table readable*/
+ border:1px solid #000;
+ padding:.5em;
+}
+th {
+ /*distinguishing table headers from data cells*/
+ font-weight:bold;
+ text-align:center;
+}
+caption {
+ /*coordinated marking to match cell's padding*/
+ margin-bottom:.5em;
+ /*centered so it doesn't blend in to other content*/
+ text-align:center;
+}
+p,fieldset,table {
+ /*so things don't run into each other*/
+ margin-bottom:1em;
+}
\ No newline at end of file
diff --git a/lib/yui/button/README b/lib/yui/button/README
new file mode 100755
index 0000000000..a0bcb58831
--- /dev/null
+++ b/lib/yui/button/README
@@ -0,0 +1,272 @@
+*** Version 2.3.0 ***
+
+Added the following features:
+-----------------------------
+
++ Added a "focusmenu" configuration attribute that controls whether or not a
+ Button instance's menu will automatically be focused when made visible.
+
++ Added a "lazyloadmenu" configuration attribute that controls the value of
+ the "lazyload" configuration property of a Button's menu.
+
++ Added "menuclassname" configuration attribute that defines a CSS class name
+ to be applied to the root HTML element of a button's menu.
+
+
+Fixed the following bugs:
+-------------------------
+
++ Setting the "label" attribute of a Button of type "link" to a string with
+ a "www." prefix will no longer result in the value of the "href" property
+ being used for the "label" in IE.
+
++ Disabling a Button when its menu is visible will now result in the menu
+ being hidden.
+
++ Hidden field(s) created by a Button instance are now removed if the
+ submission of its parent form is cancelled.
+
++ If a Button instance is preceeded by another enabled HTML submit button
+ ( or ), it will no longer
+ create a hidden field representing its name and value when its parent form
+ is submitted.
+
++ If an HTML form contains a mix of YUI Buttons of type "submit" and standard
+ HTML submit buttons ( or )
+ its "submit" event will no longer fire twice when it is submitted by the user
+ pressing the enter key while focus inside another HTML form control.
+
++ If all Button instances in a form are disabled, the form will no longer be
+ submitted when the user presses the enter key while focused inside another
+ HTML form control.
+
++ The first enabled Button instance in a form now correctly adds its name and
+ value to the form's data set when the form is submitted by the user pressing
+ the enter key while focused inside another form control.
+
++ Fixed typo in the source file for the ButtonGroup class that was causing the
+ private variable "m_oButtons" to be declared as a global.
+
++ Switched to use of the CSS display type "-moz-inline-box" from
+ "-moz-inline-stack" for Gecko-based browsers so that the entire area of a
+ Button instance is clickable when it is rendered inside another inline
+ element.
+
++ Added "yui-button" and "yui-[button type]-button" prefix to CSS classes to
+ sandbox Button styles.
+
+
+Changes:
+--------
+
++ Default value of "type" configuration attribute now "push" (was "button").
+
++ Type "menubutton" now "menu."
+
++ Type "splitbuton" now "split."
+
++ Added "addStateCSSClasses" method.
+
++ Added "removeStateCSSClasses" method.
+
++ Renamed protected property "_hiddenField" to "_hiddenFields."
+
++ Removed protected "submit" event handler named "_onFormSubmit."
+
++ Renamed public method "createHiddenField" to "createHiddenFields."
+
++ Added new "removeHiddenFields" method.
+
++ Renamed static method "YAHOO.widget.Button.onFormKeyDown"
+ to "YAHOO.widget.Button.onFormKeyPress."
+
++ Renamed "TAG_NAME" constant (YAHOO.widget.Button.prototype.TAG_NAME and
+ YAHOO.widget.ButtonGroup.prototype.TAG_NAME) to
+ "NODE_NAME" (YAHOO.widget.Button.prototype.NODE_NAME and
+ YAHOO.widget.ButtonGroup.prototype.NODE_NAME).
+
++ The "selectedMenuItem" configuration attribute now correctly gets/sets the
+ index of the selected MenuItem instance of the button's menu, rather than a
+ MenuItem instance.
+
++ The "container" configuration attribute is now writeonce
+
++ The "menu" configuration attribute is now writeonce
+
++ The root element of each button's menu now will have two CSS classes
+ appended to it:
+ - The CSS class name specified by the "menuclassname" configuration
+ attribute (by default is "yui-button-menu")
+ - A type-specific class name (either "yui-split-button-menu"
+ or "yui-menu-button-menu")
+
++ "menu" configuration attribute now supports creation or use of
+ YAHOO.widget.Overlay in addition to previously supported
+ YAHOO.widget.Menu:
+
+ - To create a menu from existing markup using YAHOO.widget.Overlay, pass the
+ id or node reference of the HTML element to be used to create the Overlay
+ as the value of the "menu" configuration attribute.
+
+ - YAHOO.widget.Overlay instances passed as a value for the "menu"
+ configuration attribute need to be fully rendered.
+
+ - To create a menu from existing markup using YAHOO.widget.Menu, pass the
+ id or node reference of the HTML element to be used to create the menu
+ as the value of the "menu" configuration attribute and give the
+ HTML element the same class name as specified by
+ YAHOO.widget.Menu.prototype.CSS_CLASS_NAME.
+
+ - YAHOO.widget.Overlay instances used as a menu are by default not rendered
+ until they are are made visible for the first time. This behavior
+ can be changed so that they are rendered immediately by setting the value
+ of the "lazyloadmenu" configuration attribute to "false."
+
++ If you pass an element id for the value of the "menu" configuration
+ attribute, that node is now accessed immediately via the "get" method of the
+ Dom utility (YAHOO.util.Dom) as opposed to the "onContentReady" method of the
+ Event utility (YAHOO.util.Event).
+
++ Modified code to support a more generic markup format. Now any number of
+ HTML elements can exist between a Button's root HTML element and its button
+ node (be it an or element):
+
+ ... ...
+
++ A Button can now be initialized using any of the following six HTML patterns:
+
+ - TEXT/HTML
+ - TEXT/HTML
+ -
+ - ... TEXT/HTML ...
+ - ... TEXT/HTML ...
+ - ... ...
+
++ The id of a Button instance can now match that of its source element.
+
++ CSS changes:
+
+ 1) All Buttons have a "yui-" prefix as opposed to "yui":
+
+ 2.2.2 | 2.3
+ -------------------------
+ .yuibutton | .yui-button
+
+
+ 2) Each Button type has its own class name with a "yui-" prefix and
+ "-button" suffix IN ADDITION TO the default "yui-button" class name:
+
+ 2.2.2 | 2.3
+ ------------------------------------------
+ .yuibutton.splitbutton | .yui-split-button
+ .yuibutton.menubutton | .yui-menu-button
+
+ * Allows for the definition of generic styles that apply to all buttons,
+ while providing a means for uniquely styling buttons of a specific type.
+
+
+ 3) For states that are common to all Buttons, two classes are applied: a
+ generic class name (i.e. yui-button-[state]) and a type-specific state class
+ name (yui-[type]-button-[state]):
+
+ 2.2.2 | 2.3
+ -------------------------------------------
+ .yuibutton.focus | .yui-button-focus
+ .yuibutton.radio.focus | .yui-radio-button-focus
+
+ * States common to all Button types are:
+ + focus
+ + hover
+ + active
+ + disabled
+
+ ** Allows for the definition of generic styles that apply to all states of
+ all buttons, while providing a means for uniquely styling states for
+ buttons of a specific type.
+
+
+ 4) Buttons of type "radio" and "checkbox" have two classes applied to
+ represent their "checked" state: a generic class name
+ (i.e. yui-button-checked) and a type-specific class
+ name (yui-[type]-button-checked):
+
+ 2.2.2 | 2.3
+ -------------------------------------------
+ .yuibutton.checked | .yui-button-checked
+ .yuibutton.radio.checked | .yui-radio-button-checked
+ .yuibutton.checkbox.checked | .yui-checkbox-button-checked
+
+ ** This allows for the definition of a universal style for all Buttons that
+ have a "checked" state or the ability to define a type-specific style for
+ the "checked" state.
+
+
+ 5) States that are specific to a particular type only get a type-specific
+ state class name. Currently this only applies to the "splitbutton" type:
+
+ 2.2.2 | 2.3
+ -------------------------------------------
+ .yuibutton.activeoption | .yui-split-button-activeoption
+
+
+ 6) The "ie6" class name is removed.
+
+
+*** Version 2.2.2 ***
+
++ No changes
+
+
+*** Version 2.2.1 ***
+
+Added the following features:
+-----------------------------
+
++ Added "getHiddenField" method to YAHOO.widget.Button.
+
+
+Fixed the following bugs:
+-------------------------
+
++ Removed built-in use of the Event utility's "onAvailable" method from the
+ constructor of Button and ButtonGroup as it was preventing the addition of
+ event listeners on instances created from existing markup. Going forward
+ Button and ButtonGroup instances created from existing markup can only be
+ instantiated once their source HTML element is available in the DOM. The
+ Button examples illustrate how this can be accomplished.
+
++ Modified code so that disabled Button instances no longer fire DOM events.
+
++ Pressing the enter key while focused on a form field whose parent form
+ contains a Button instance of type "submit" will now automatically submit
+ the form using the first Button instance of type "submit".
+
++ Clicking a Button instance of type="submit" will now cause the Button's
+ parent form's "submit" event to fire.
+
++ Modified Button CSS so that the filter used to apply alpha transparency to
+ a Button's background PNG is only used by IE 6. The previous code was
+ enabling IE's Alpha image loader for IE 7 in Quirks mode.
+
++ Fixed documentation error for "getForm" method.
+
+
+Changes:
+--------
+
++ Made the "submitForm" method of YAHOO.widget.Button public (was
+ previously protected).
+
++ Removed "init" event and corresponding "oninit" configuration attribute
+ from YAHOO.widget.Button and YAHOO.widget.ButtonGroup.
+
++ Added the CSS class "ie6" to button.css. This classname is append to root
+ DOM element of Button instances created with IE 6. By default this class
+ is used to apply a filter that gives alpha transparency to a Button's
+ background PNG.
+
+
+
+*** Version 2.2.0 ***
+
+* Button Control introduced
diff --git a/lib/yui/button/assets/background.png b/lib/yui/button/assets/background.png
new file mode 100755
index 0000000000..32a72e491a
Binary files /dev/null and b/lib/yui/button/assets/background.png differ
diff --git a/lib/yui/button/assets/button-core.css b/lib/yui/button/assets/button-core.css
new file mode 100755
index 0000000000..5aa3015efe
--- /dev/null
+++ b/lib/yui/button/assets/button-core.css
@@ -0,0 +1,6 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
diff --git a/lib/yui/button/assets/button.css b/lib/yui/button/assets/button.css
new file mode 100755
index 0000000000..fcdcfa24ed
--- /dev/null
+++ b/lib/yui/button/assets/button.css
@@ -0,0 +1,215 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-button {
+
+ display:-moz-inline-box; /* Gecko */
+ display:inline-block; /* IE, Opera and Safari */
+ border-width:1px 0;
+ border-style:solid;
+ border-color:#999;
+ background:#ecece3 url(background.png) left center;
+ margin:auto .25em;
+
+}
+
+.yui-button.ie6 {
+
+ /* Give the transparent background image to IE 6 */
+ background-image:none;
+ filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../build/button/assets/background.png', sizingMethod = 'scale');
+
+}
+
+.yui-button .first-child {
+
+ display:block;
+ *display:inline-block; /* IE */
+ border-width:0 1px;
+ border-style:solid;
+ border-color:#999;
+ margin:0 -1px;
+ *position:relative;
+ *left:-1px;
+
+}
+
+.yui-button button,
+.yui-button a {
+
+ display:block;
+ *display:inline-block; /* IE */
+ padding:.25em .5em;
+ border:1px solid #ccc;
+
+}
+
+.yui-button button {
+
+ *overflow:visible; /* Remove superfluous padding for IE */
+ font-size:100%; /* Makes form controls resizable in IE */
+ background-color:transparent;
+ cursor:pointer;
+ cursor:hand;
+
+}
+
+.yui-button a {
+
+ text-decoration:none;
+ color:#000;
+
+}
+
+.yui-split-button button,
+.yui-menu-button button {
+
+ padding-right:20px;
+ background-position:right center;
+ background-repeat:no-repeat;
+
+}
+
+.yui-menu-button button {
+
+ background-image:url(menuarrow.gif);
+
+}
+
+.yui-split-button button {
+
+ background-image:url(splitarrow.gif);
+
+}
+
+
+/* Focus state */
+
+.yui-button-focus {
+
+ border-color:#5e5c95;
+
+}
+
+.yui-button-focus .first-child {
+
+ border-color:#5e5c95;
+
+}
+
+.yui-button-focus button,
+.yui-button-focus a {
+
+ border-color:#cec1fc;
+
+}
+
+
+/* Hover state */
+
+.yui-button-hover {
+
+ border-color:#406fac;
+ background-color:#98d5fc;
+
+}
+
+.yui-button-hover .first-child {
+
+ border-color:#406fac;
+
+}
+
+.yui-button-hover button,
+.yui-button-hover a {
+
+ border-color:#7099ce;
+
+}
+
+
+/* Active state */
+
+.yui-button-active {
+
+ border-color:#7a8180;
+ background-color:#333;
+
+}
+
+.yui-button-active .first-child {
+
+ border-color:#7a8180;
+
+}
+
+.yui-button-active button,
+.yui-button-active a {
+
+ border-color:#98a09f;
+
+}
+
+.yui-split-button-activeoption button {
+
+ background-color:transparent;
+ background-image:url(splitarrow_active.gif);
+
+}
+
+
+
+/* Checked state */
+
+.yui-radio-button-checked,
+.yui-checkbox-button-checked {
+
+ border-color:#7a8180;
+ background-color:#333;
+
+}
+
+.yui-radio-button-checked .first-child,
+.yui-checkbox-button-checked .first-child {
+
+ border-color:#7a8180;
+
+}
+
+.yui-radio-button-checked button,
+.yui-checkbox-button-checked button {
+
+ border-color:#98a09f;
+
+}
+
+
+
+/* Disabled state */
+
+.yui-button-disabled {
+
+ border-color:#cbcdc5;
+ background:#ecece3;
+
+ filter:none;
+
+}
+
+.yui-button-disabled .first-child {
+
+ border-color:#cbcdc5;
+
+}
+
+.yui-button-disabled button,
+.yui-button-disabled a {
+
+ border-color:transparent;
+ color:#b9b9b9;
+ cursor:default;
+
+}
\ No newline at end of file
diff --git a/lib/yui/button/assets/menuarrow.gif b/lib/yui/button/assets/menuarrow.gif
new file mode 100755
index 0000000000..ffa2ba9d25
Binary files /dev/null and b/lib/yui/button/assets/menuarrow.gif differ
diff --git a/lib/yui/button/assets/skins/sam/button-skin.css b/lib/yui/button/assets/skins/sam/button-skin.css
new file mode 100755
index 0000000000..e8f8011a81
--- /dev/null
+++ b/lib/yui/button/assets/skins/sam/button-skin.css
@@ -0,0 +1,245 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-skin-sam .yui-button {
+
+ display: -moz-inline-box; /* Gecko */
+ display: inline-block; /* IE, Opera and Safari */
+ border-width: 1px 0;
+ border-style: solid;
+ border-color: #808080;
+ background: url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;
+ margin: auto .25em;
+
+}
+
+.yui-skin-sam .yui-button .first-child {
+
+ display: block;
+ *display: inline-block; /* IE */
+ border-width: 0 1px;
+ border-style: solid;
+ border-color: #808080;
+ margin: 0 -1px;
+ *position: relative;
+ *left: -1px;
+
+}
+
+.yui-skin-sam .yui-button button,
+.yui-skin-sam .yui-button a {
+
+ display: block;
+ *display: inline-block; /* IE */
+ padding: 0 10px;
+ border: none;
+ font-size: 93%; /* 12px */
+ line-height: 2; /* ~24px */
+ *line-height: 1.7; /* For IE */
+ min-height: 2em; /* For Gecko */
+ *min-height: auto; /* For IE */
+ color: #000;
+
+}
+
+.yui-skin-sam .yui-button button {
+
+ *overflow: visible; /* Remove superfluous padding for IE */
+ background-color: transparent;
+ cursor: pointer;
+ cursor: hand;
+
+}
+
+.yui-skin-sam .yui-button a {
+
+ text-decoration: none;
+
+}
+
+
+.yui-skin-sam .yui-split-button button,
+.yui-skin-sam .yui-menu-button button {
+
+ padding-right: 20px;
+ background-position: right center;
+ background-repeat: no-repeat;
+
+}
+
+.yui-skin-sam .yui-menu-button button {
+
+ background-image: url(menu-button-arrow.png);
+
+}
+
+.yui-skin-sam .yui-split-button button {
+
+ background-image: url(split-button-arrow.png);
+
+}
+
+
+/* Focus state */
+
+
+.yui-skin-sam .yui-button-focus {
+
+ border-color: #7D98B8;
+ background-position: 0 -1300px;
+
+}
+
+.yui-skin-sam .yui-button-focus .first-child {
+
+ border-color: #7D98B8;
+
+}
+
+.yui-skin-sam .yui-button-focus button,
+.yui-skin-sam .yui-button-focus a {
+
+ color: #000;
+
+}
+
+.yui-skin-sam .yui-split-button-focus button {
+
+ background-image: url(split-button-arrow-focus.png);
+
+}
+
+
+/* Hover state */
+
+.yui-skin-sam .yui-button-hover {
+
+ border-color: #7D98B8;
+ background-position: 0 -1300px;
+
+}
+
+.yui-skin-sam .yui-button-hover .first-child {
+
+ border-color: #7D98B8;
+
+}
+
+.yui-skin-sam .yui-button-hover button,
+.yui-skin-sam .yui-button-hover a {
+
+ color: #000;
+
+}
+
+.yui-skin-sam .yui-split-button-hover button {
+
+ background-image: url(split-button-arrow-hover.png);
+
+}
+
+
+/* Active state */
+
+.yui-skin-sam .yui-button-active {
+
+ border-color: #7D98B8;
+ background-position: 0 -1700px;
+
+}
+
+.yui-skin-sam .yui-button-active .first-child {
+
+ border-color: #7D98B8;
+
+}
+
+.yui-skin-sam .yui-button-active button,
+.yui-skin-sam .yui-button-active a {
+
+ color: #000;
+
+}
+
+.yui-skin-sam .yui-split-button-activeoption {
+
+ border-color: #808080;
+ background-position: 0 0;
+
+}
+
+.yui-skin-sam .yui-split-button-activeoption .first-child {
+
+ border-color: #808080;
+
+}
+
+.yui-skin-sam .yui-split-button-activeoption button {
+
+ background-image: url(split-button-arrow-active.png);
+
+}
+
+
+/* Checked state */
+
+.yui-skin-sam .yui-radio-button-checked,
+.yui-skin-sam .yui-checkbox-button-checked {
+
+ border-color: #304369;
+ background-position: 0 -1400px;
+
+}
+
+.yui-skin-sam .yui-radio-button-checked .first-child,
+.yui-skin-sam .yui-checkbox-button-checked .first-child {
+
+ border-color: #304369;
+
+}
+
+.yui-skin-sam .yui-radio-button-checked button,
+.yui-skin-sam .yui-checkbox-button-checked button {
+
+ color: #fff;
+
+}
+
+
+/* Disabled state */
+
+.yui-skin-sam .yui-button-disabled {
+
+ border-color: #ccc;
+ background-position: 0 -1500px;
+
+}
+
+.yui-skin-sam .yui-button-disabled .first-child {
+
+ border-color: #ccc;
+
+}
+
+.yui-skin-sam .yui-button-disabled button,
+.yui-skin-sam .yui-button-disabled a {
+
+ color: #A6A6A6;
+ cursor: default;
+
+}
+
+.yui-skin-sam .yui-menu-button-disabled button {
+
+ background-image: url(menu-button-arrow-disabled.png);
+
+}
+
+.yui-skin-sam .yui-split-button-disabled button {
+
+ background-image: url(split-button-arrow-disabled.png);
+
+}
\ No newline at end of file
diff --git a/lib/yui/button/assets/skins/sam/button.css b/lib/yui/button/assets/skins/sam/button.css
new file mode 100755
index 0000000000..0de5e6e01e
--- /dev/null
+++ b/lib/yui/button/assets/skins/sam/button.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-skin-sam .yui-button{display:-moz-inline-box;display:inline-block;border-width:1px 0;border-style:solid;border-color:#808080;background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;margin:auto .25em;}.yui-skin-sam .yui-button .first-child{display:block;*display:inline-block;border-width:0 1px;border-style:solid;border-color:#808080;margin:0 -1px;*position:relative;*left:-1px;}.yui-skin-sam .yui-button button,.yui-skin-sam .yui-button a{display:block;*display:inline-block;padding:0 10px;border:none;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-button button{*overflow:visible;background-color:transparent;cursor:pointer;cursor:hand;}.yui-skin-sam .yui-button a{text-decoration:none;}.yui-skin-sam .yui-split-button button,.yui-skin-sam .yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}.yui-skin-sam .yui-menu-button button{background-image:url(menu-button-arrow.png);}.yui-skin-sam .yui-split-button button{background-image:url(split-button-arrow.png);}.yui-skin-sam .yui-button-focus{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-focus .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-focus button,.yui-skin-sam .yui-button-focus a{color:#000;}.yui-skin-sam .yui-split-button-focus button{background-image:url(split-button-arrow-focus.png);}.yui-skin-sam .yui-button-hover{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-hover .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-hover button,.yui-skin-sam .yui-button-hover a{color:#000;}.yui-skin-sam .yui-split-button-hover button{background-image:url(split-button-arrow-hover.png);}.yui-skin-sam .yui-button-active{border-color:#7D98B8;background-position:0 -1700px;}.yui-skin-sam .yui-button-active .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-active button,.yui-skin-sam .yui-button-active a{color:#000;}.yui-skin-sam .yui-split-button-activeoption{border-color:#808080;background-position:0 0;}.yui-skin-sam .yui-split-button-activeoption .first-child{border-color:#808080;}.yui-skin-sam .yui-split-button-activeoption button{background-image:url(split-button-arrow-active.png);}.yui-skin-sam .yui-radio-button-checked,.yui-skin-sam .yui-checkbox-button-checked{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-radio-button-checked .first-child,.yui-skin-sam .yui-checkbox-button-checked .first-child{border-color:#304369;}.yui-skin-sam .yui-radio-button-checked button,.yui-skin-sam .yui-checkbox-button-checked button{color:#fff;}.yui-skin-sam .yui-button-disabled{border-color:#ccc;background-position:0 -1500px;}.yui-skin-sam .yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-button-disabled button,.yui-skin-sam .yui-button-disabled a{color:#A6A6A6;cursor:default;}.yui-skin-sam .yui-menu-button-disabled button{background-image:url(menu-button-arrow-disabled.png);}.yui-skin-sam .yui-split-button-disabled button{background-image:url(split-button-arrow-disabled.png);}
diff --git a/lib/yui/button/assets/skins/sam/menu-button-arrow-disabled.png b/lib/yui/button/assets/skins/sam/menu-button-arrow-disabled.png
new file mode 100755
index 0000000000..8cef2abb31
Binary files /dev/null and b/lib/yui/button/assets/skins/sam/menu-button-arrow-disabled.png differ
diff --git a/lib/yui/button/assets/skins/sam/menu-button-arrow.png b/lib/yui/button/assets/skins/sam/menu-button-arrow.png
new file mode 100755
index 0000000000..f03dfee4e4
Binary files /dev/null and b/lib/yui/button/assets/skins/sam/menu-button-arrow.png differ
diff --git a/lib/yui/button/assets/skins/sam/split-button-arrow-active.png b/lib/yui/button/assets/skins/sam/split-button-arrow-active.png
new file mode 100755
index 0000000000..fa58c5030e
Binary files /dev/null and b/lib/yui/button/assets/skins/sam/split-button-arrow-active.png differ
diff --git a/lib/yui/button/assets/skins/sam/split-button-arrow-disabled.png b/lib/yui/button/assets/skins/sam/split-button-arrow-disabled.png
new file mode 100755
index 0000000000..0a6a82c640
Binary files /dev/null and b/lib/yui/button/assets/skins/sam/split-button-arrow-disabled.png differ
diff --git a/lib/yui/button/assets/skins/sam/split-button-arrow-focus.png b/lib/yui/button/assets/skins/sam/split-button-arrow-focus.png
new file mode 100755
index 0000000000..167d71eb72
Binary files /dev/null and b/lib/yui/button/assets/skins/sam/split-button-arrow-focus.png differ
diff --git a/lib/yui/button/assets/skins/sam/split-button-arrow-hover.png b/lib/yui/button/assets/skins/sam/split-button-arrow-hover.png
new file mode 100755
index 0000000000..167d71eb72
Binary files /dev/null and b/lib/yui/button/assets/skins/sam/split-button-arrow-hover.png differ
diff --git a/lib/yui/button/assets/skins/sam/split-button-arrow.png b/lib/yui/button/assets/skins/sam/split-button-arrow.png
new file mode 100755
index 0000000000..b33a93ff2d
Binary files /dev/null and b/lib/yui/button/assets/skins/sam/split-button-arrow.png differ
diff --git a/lib/yui/button/assets/splitarrow.gif b/lib/yui/button/assets/splitarrow.gif
new file mode 100755
index 0000000000..6d1ce65940
Binary files /dev/null and b/lib/yui/button/assets/splitarrow.gif differ
diff --git a/lib/yui/button/assets/splitarrow_active.gif b/lib/yui/button/assets/splitarrow_active.gif
new file mode 100755
index 0000000000..25c0884e06
Binary files /dev/null and b/lib/yui/button/assets/splitarrow_active.gif differ
diff --git a/lib/yui/button/button-beta-debug.js b/lib/yui/button/button-beta-debug.js
new file mode 100755
index 0000000000..c9dfa28cb7
--- /dev/null
+++ b/lib/yui/button/button-beta-debug.js
@@ -0,0 +1,4554 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+/**
+* @module button
+* @description The Button Control enables the creation of rich, graphical
+* buttons that function like traditional HTML form buttons. Unlike
+* tradition HTML form buttons, buttons created with the Button Control can have
+* a label that is different from its value. With the inclusion of the optional
+* Menu Control , the Button Control can also be
+* used to create menu buttons and split buttons, controls that are not
+* available natively in HTML. The Button Control can also be thought of as a
+* way to create more visually engaging implementations of the browser's
+* default radio-button and check-box controls.
+* The Button Control supports the following types:
+*
+* push
+* Basic push button that can execute a user-specified command when
+* pressed.
+* link
+* Navigates to a specified url when pressed.
+* submit
+* Submits the parent form when pressed.
+* reset
+* Resets the parent form when pressed.
+* checkbox
+* Maintains a "checked" state that can be toggled on and off.
+* radio
+* Maintains a "checked" state that can be toggled on and off. Use with
+* the ButtonGroup class to create a set of controls that are mutually
+* exclusive; checking one button in the set will uncheck all others in
+* the group.
+* menu
+* When pressed will show/hide a menu.
+* split
+* Can execute a user-specified command or display a menu when pressed.
+*
+* @title Button
+* @namespace YAHOO.widget
+* @requires yahoo, dom, element, event
+* @optional container, menu
+* @beta
+*/
+
+
+(function () {
+
+
+ /**
+ * The Button class creates a rich, graphical button.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to
+ * be used to create the button.
+ * @param {HTMLInputElement |
+ * HTMLButtonElement |HTMLElement } p_oElement Object reference for the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to be
+ * used to create the button.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a set
+ * of configuration attributes used to create the button.
+ * @namespace YAHOO.widget
+ * @class Button
+ * @constructor
+ * @extends YAHOO.util.Element
+ */
+
+
+
+ // Shorthard for utilities
+
+ var Dom = YAHOO.util.Dom,
+ Event = YAHOO.util.Event,
+ Lang = YAHOO.lang,
+ Overlay = YAHOO.widget.Overlay,
+ Menu = YAHOO.widget.Menu,
+
+
+ // Private member variables
+
+ m_oButtons = {}, // Collection of all Button instances
+ m_oOverlayManager = null, // YAHOO.widget.OverlayManager instance
+ m_oSubmitTrigger = null, // The button that submitted the form
+ m_oFocusedButton = null; // The button that has focus
+
+
+
+ // Private methods
+
+
+
+ /**
+ * @method createInputElement
+ * @description Creates an <input>
element of the
+ * specified type.
+ * @private
+ * @param {String} p_sType String specifying the type of
+ * <input>
element to create.
+ * @param {String} p_sName String specifying the name of
+ * <input>
element to create.
+ * @param {String} p_sValue String specifying the value of
+ * <input>
element to create.
+ * @param {String} p_bChecked Boolean specifying if the
+ * <input>
element is to be checked.
+ * @return {HTMLInputElement }
+ */
+ function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) {
+
+ var oInput,
+ sInput;
+
+ if (Lang.isString(p_sType) && Lang.isString(p_sName)) {
+
+ if (YAHOO.env.ua.ie) {
+
+ /*
+ For IE it is necessary to create the element with the
+ "type," "name," "value," and "checked" properties set all
+ at once.
+ */
+
+ sInput = " ";
+
+ oInput = document.createElement(sInput);
+
+ }
+ else {
+
+ oInput = document.createElement("input");
+ oInput.name = p_sName;
+ oInput.type = p_sType;
+
+ if (p_bChecked) {
+
+ oInput.checked = true;
+
+ }
+
+ }
+
+ oInput.value = p_sValue;
+
+ return oInput;
+
+ }
+
+ }
+
+
+ /**
+ * @method setAttributesFromSrcElement
+ * @description Gets the values for all the attributes of the source element
+ * (either <input>
or <a>
) that
+ * map to Button configuration attributes and sets them into a collection
+ * that is passed to the Button constructor.
+ * @private
+ * @param {HTMLInputElement |HTMLAnchorElement } p_oElement Object reference to the HTML
+ * element (either <input>
or <span>
+ *
) used to create the button.
+ * @param {Object} p_oAttributes Object reference for the collection of
+ * configuration attributes used to create the button.
+ */
+ function setAttributesFromSrcElement(p_oElement, p_oAttributes) {
+
+ var sSrcElementNodeName = p_oElement.nodeName.toUpperCase(),
+ me = this,
+ oAttribute,
+ oRootNode,
+ sText;
+
+
+ /**
+ * @method setAttributeFromDOMAttribute
+ * @description Gets the value of the specified DOM attribute and sets it
+ * into the collection of configuration attributes used to configure
+ * the button.
+ * @private
+ * @param {String} p_sAttribute String representing the name of the
+ * attribute to retrieve from the DOM element.
+ */
+ function setAttributeFromDOMAttribute(p_sAttribute) {
+
+ if ( !(p_sAttribute in p_oAttributes) ) {
+
+ /*
+ Need to use "getAttributeNode" instead of "getAttribute"
+ because using "getAttribute," IE will return the innerText
+ of a <button>
for the value attribute
+ rather than the value of the "value" attribute.
+ */
+
+ oAttribute = p_oElement.getAttributeNode(p_sAttribute);
+
+
+ if (oAttribute && ("value" in oAttribute)) {
+
+ me.logger.log("Setting attribute \"" + p_sAttribute +
+ "\" using source element's attribute value of \"" +
+ oAttribute.value + "\"");
+
+ p_oAttributes[p_sAttribute] = oAttribute.value;
+
+ }
+
+ }
+
+ }
+
+
+ /**
+ * @method setFormElementProperties
+ * @description Gets the value of the attributes from the form element
+ * and sets them into the collection of configuration attributes used to
+ * configure the button.
+ * @private
+ */
+ function setFormElementProperties() {
+
+ setAttributeFromDOMAttribute("type");
+
+ if (p_oAttributes.type == "button") {
+
+ p_oAttributes.type = "push";
+
+ }
+
+ if ( !("disabled" in p_oAttributes) ) {
+
+ p_oAttributes.disabled = p_oElement.disabled;
+
+ }
+
+ setAttributeFromDOMAttribute("name");
+ setAttributeFromDOMAttribute("value");
+ setAttributeFromDOMAttribute("title");
+
+ }
+
+
+ switch (sSrcElementNodeName) {
+
+ case "A":
+
+ p_oAttributes.type = "link";
+
+ setAttributeFromDOMAttribute("href");
+ setAttributeFromDOMAttribute("target");
+
+ break;
+
+ case "INPUT":
+
+ setFormElementProperties();
+
+ if ( !("checked" in p_oAttributes) ) {
+
+ p_oAttributes.checked = p_oElement.checked;
+
+ }
+
+ break;
+
+ case "BUTTON":
+
+ setFormElementProperties();
+
+ oRootNode = p_oElement.parentNode.parentNode;
+
+ if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-checked")) {
+
+ p_oAttributes.checked = true;
+
+ }
+
+ if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-disabled")) {
+
+ p_oAttributes.disabled = true;
+
+ }
+
+ p_oElement.removeAttribute("value");
+
+ p_oElement.setAttribute("type", "button");
+
+ break;
+
+ }
+
+ p_oElement.removeAttribute("id");
+ p_oElement.removeAttribute("name");
+
+ if ( !("tabindex" in p_oAttributes) ) {
+
+ p_oAttributes.tabindex = p_oElement.tabIndex;
+
+ }
+
+ if ( !("label" in p_oAttributes) ) {
+
+ // Set the "label" property
+
+ sText = sSrcElementNodeName == "INPUT" ?
+ p_oElement.value : p_oElement.innerHTML;
+
+
+ if (sText && sText.length > 0) {
+
+ p_oAttributes.label = sText;
+
+ }
+
+ }
+
+ }
+
+
+ /**
+ * @method initConfig
+ * @description Initializes the set of configuration attributes that are
+ * used to instantiate the button.
+ * @private
+ * @param {Object} Object representing the button's set of
+ * configuration attributes.
+ */
+ function initConfig(p_oConfig) {
+
+ var oAttributes = p_oConfig.attributes,
+ oSrcElement = oAttributes.srcelement,
+ sSrcElementNodeName = oSrcElement.nodeName.toUpperCase(),
+ me = this;
+
+
+ if (sSrcElementNodeName == this.NODE_NAME) {
+
+ p_oConfig.element = oSrcElement;
+ p_oConfig.id = oSrcElement.id;
+
+ Dom.getElementsBy(function (p_oElement) {
+
+ switch (p_oElement.nodeName.toUpperCase()) {
+
+ case "BUTTON":
+ case "A":
+ case "INPUT":
+
+ setAttributesFromSrcElement.call(me, p_oElement,
+ oAttributes);
+
+ break;
+
+ }
+
+ }, "*", oSrcElement);
+
+ }
+ else {
+
+ switch (sSrcElementNodeName) {
+
+ case "BUTTON":
+ case "A":
+ case "INPUT":
+
+ setAttributesFromSrcElement.call(this, oSrcElement,
+ oAttributes);
+
+ break;
+
+ }
+
+ }
+
+ }
+
+
+
+ // Constructor
+
+ YAHOO.widget.Button = function (p_oElement, p_oAttributes) {
+
+ var fnSuperClass = YAHOO.widget.Button.superclass.constructor,
+ oConfig,
+ oElement;
+
+ if (arguments.length == 1 && !Lang.isString(p_oElement) &&
+ !p_oElement.nodeName) {
+
+ if (!p_oElement.id) {
+
+ p_oElement.id = Dom.generateId();
+
+ YAHOO.log("No value specified for the button's \"id\" " +
+ "attribute. Setting button id to \"" + p_oElement.id +
+ "\".", "warn");
+
+ }
+
+ this.logger = new YAHOO.widget.LogWriter("Button " + p_oElement.id);
+
+ this.logger.log("No source HTML element. Building the button " +
+ "using the set of configuration attributes.");
+
+ fnSuperClass.call(this,
+ (this.createButtonElement(p_oElement.type)),
+ p_oElement);
+
+ }
+ else {
+
+ oConfig = { element: null, attributes: (p_oAttributes || {}) };
+
+
+ if (Lang.isString(p_oElement)) {
+
+ oElement = Dom.get(p_oElement);
+
+ if (oElement) {
+
+ if (!oConfig.attributes.id) {
+
+ oConfig.attributes.id = p_oElement;
+
+ }
+
+ this.logger = new YAHOO.widget.LogWriter(
+ "Button " + oConfig.attributes.id);
+
+ this.logger.log("Building the button using an existing " +
+ "HTML element as a source element.");
+
+
+ oConfig.attributes.srcelement = oElement;
+
+ initConfig.call(this, oConfig);
+
+
+ if (!oConfig.element) {
+
+ this.logger.log("Source element could not be used " +
+ "as is. Creating a new HTML element for " +
+ "the button.");
+
+ oConfig.element =
+ this.createButtonElement(oConfig.attributes.type);
+
+ }
+
+ fnSuperClass.call(this, oConfig.element,
+ oConfig.attributes);
+
+ }
+
+ }
+ else if (p_oElement.nodeName) {
+
+ if (!oConfig.attributes.id) {
+
+ if (p_oElement.id) {
+
+ oConfig.attributes.id = p_oElement.id;
+
+ }
+ else {
+
+ oConfig.attributes.id = Dom.generateId();
+
+ YAHOO.log("No value specified for the button's " +
+ "\"id\" attribute. Setting button id to \"" +
+ oConfig.attributes.id + "\".", "warn");
+
+ }
+
+ }
+
+
+ this.logger = new YAHOO.widget.LogWriter(
+ "Button " + oConfig.attributes.id);
+
+ this.logger.log("Building the button using an existing HTML " +
+ "element as a source element.");
+
+
+ oConfig.attributes.srcelement = p_oElement;
+
+ initConfig.call(this, oConfig);
+
+
+ if (!oConfig.element) {
+
+ this.logger.log("Source element could not be used as is." +
+ " Creating a new HTML element for the button.");
+
+ oConfig.element =
+ this.createButtonElement(oConfig.attributes.type);
+
+ }
+
+ fnSuperClass.call(this, oConfig.element, oConfig.attributes);
+
+ }
+
+ }
+
+ };
+
+
+
+ YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, {
+
+
+ // Protected properties
+
+
+ /**
+ * @property _button
+ * @description Object reference to the button's internal
+ * <a>
or <button>
element.
+ * @default null
+ * @protected
+ * @type HTMLAnchorElement |HTMLButtonElement
+ */
+ _button: null,
+
+
+ /**
+ * @property _menu
+ * @description Object reference to the button's menu.
+ * @default null
+ * @protected
+ * @type {YAHOO.widget.Overlay |
+ * YAHOO.widget.Menu }
+ */
+ _menu: null,
+
+
+ /**
+ * @property _hiddenFields
+ * @description Object reference to the <input>
+ * element, or array of HTML form elements used to represent the button
+ * when its parent form is submitted.
+ * @default null
+ * @protected
+ * @type HTMLInputElement |Array
+ */
+ _hiddenFields: null,
+
+
+ /**
+ * @property _onclickAttributeValue
+ * @description Object reference to the button's current value for the
+ * "onclick" configuration attribute.
+ * @default null
+ * @protected
+ * @type Object
+ */
+ _onclickAttributeValue: null,
+
+
+ /**
+ * @property _activationKeyPressed
+ * @description Boolean indicating if the key(s) that toggle the button's
+ * "active" state have been pressed.
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _activationKeyPressed: false,
+
+
+ /**
+ * @property _activationButtonPressed
+ * @description Boolean indicating if the mouse button that toggles
+ * the button's "active" state has been pressed.
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _activationButtonPressed: false,
+
+
+ /**
+ * @property _hasKeyEventHandlers
+ * @description Boolean indicating if the button's "blur", "keydown" and
+ * "keyup" event handlers are assigned
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _hasKeyEventHandlers: false,
+
+
+ /**
+ * @property _hasMouseEventHandlers
+ * @description Boolean indicating if the button's "mouseout,"
+ * "mousedown," and "mouseup" event handlers are assigned
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _hasMouseEventHandlers: false,
+
+
+
+ // Constants
+
+
+ /**
+ * @property NODE_NAME
+ * @description The name of the node to be used for the button's
+ * root element.
+ * @default "SPAN"
+ * @final
+ * @type String
+ */
+ NODE_NAME: "SPAN",
+
+
+ /**
+ * @property CHECK_ACTIVATION_KEYS
+ * @description Array of numbers representing keys that (when pressed)
+ * toggle the button's "checked" attribute.
+ * @default [32]
+ * @final
+ * @type Array
+ */
+ CHECK_ACTIVATION_KEYS: [32],
+
+
+ /**
+ * @property ACTIVATION_KEYS
+ * @description Array of numbers representing keys that (when presed)
+ * toggle the button's "active" state.
+ * @default [13, 32]
+ * @final
+ * @type Array
+ */
+ ACTIVATION_KEYS: [13, 32],
+
+
+ /**
+ * @property OPTION_AREA_WIDTH
+ * @description Width (in pixels) of the area of a split button that
+ * when pressed will display a menu.
+ * @default 20
+ * @final
+ * @type Number
+ */
+ OPTION_AREA_WIDTH: 20,
+
+
+ /**
+ * @property CSS_CLASS_NAME
+ * @description String representing the CSS class(es) to be applied to
+ * the button's root element.
+ * @default "yui-button"
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yui-button",
+
+
+ /**
+ * @property RADIO_DEFAULT_TITLE
+ * @description String representing the default title applied to buttons
+ * of type "radio."
+ * @default "Unchecked. Click to check."
+ * @final
+ * @type String
+ */
+ RADIO_DEFAULT_TITLE: "Unchecked. Click to check.",
+
+
+ /**
+ * @property RADIO_CHECKED_TITLE
+ * @description String representing the title applied to buttons of
+ * type "radio" when checked.
+ * @default "Checked. Click to uncheck."
+ * @final
+ * @type String
+ */
+ RADIO_CHECKED_TITLE: "Checked. Click to uncheck.",
+
+
+ /**
+ * @property CHECKBOX_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "checkbox."
+ * @default "Unchecked. Click to check."
+ * @final
+ * @type String
+ */
+ CHECKBOX_DEFAULT_TITLE: "Unchecked. Click to check.",
+
+
+ /**
+ * @property CHECKBOX_CHECKED_TITLE
+ * @description String representing the title applied to buttons of type
+ * "checkbox" when checked.
+ * @default "Checked. Click to uncheck."
+ * @final
+ * @type String
+ */
+ CHECKBOX_CHECKED_TITLE: "Checked. Click to uncheck.",
+
+
+ /**
+ * @property MENUBUTTON_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "menu."
+ * @default "Menu collapsed. Click to expand."
+ * @final
+ * @type String
+ */
+ MENUBUTTON_DEFAULT_TITLE: "Menu collapsed. Click to expand.",
+
+
+ /**
+ * @property MENUBUTTON_MENU_VISIBLE_TITLE
+ * @description String representing the title applied to buttons of type
+ * "menu" when the button's menu is visible.
+ * @default "Menu expanded. Click or press Esc to collapse."
+ * @final
+ * @type String
+ */
+ MENUBUTTON_MENU_VISIBLE_TITLE:
+ "Menu expanded. Click or press Esc to collapse.",
+
+
+ /**
+ * @property SPLITBUTTON_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "split."
+ * @default "Menu collapsed. Click inside option region or press
+ * Ctrl + Shift + M to show the menu."
+ * @final
+ * @type String
+ */
+ SPLITBUTTON_DEFAULT_TITLE: ("Menu collapsed. Click inside option " +
+ "region or press Ctrl + Shift + M to show the menu."),
+
+
+ /**
+ * @property SPLITBUTTON_OPTION_VISIBLE_TITLE
+ * @description String representing the title applied to buttons of type
+ * "split" when the button's menu is visible.
+ * @default "Menu expanded. Press Esc or Ctrl + Shift + M to hide
+ * the menu."
+ * @final
+ * @type String
+ */
+ SPLITBUTTON_OPTION_VISIBLE_TITLE:
+ "Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.",
+
+
+ /**
+ * @property SUBMIT_TITLE
+ * @description String representing the title applied to buttons of
+ * type "submit."
+ * @default "Click to submit form."
+ * @final
+ * @type String
+ */
+ SUBMIT_TITLE: "Click to submit form.",
+
+
+
+ // Protected attribute setter methods
+
+
+ /**
+ * @method _setType
+ * @description Sets the value of the button's "type" attribute.
+ * @protected
+ * @param {String} p_sType String indicating the value for the button's
+ * "type" attribute.
+ */
+ _setType: function (p_sType) {
+
+ if (p_sType == "split") {
+
+ this.on("option", this._onOption);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setLabel
+ * @description Sets the value of the button's "label" attribute.
+ * @protected
+ * @param {String} p_sLabel String indicating the value for the button's
+ * "label" attribute.
+ */
+ _setLabel: function (p_sLabel) {
+
+ this._button.innerHTML = p_sLabel;
+
+ },
+
+
+ /**
+ * @method _setTabIndex
+ * @description Sets the value of the button's "tabindex" attribute.
+ * @protected
+ * @param {Number} p_nTabIndex Number indicating the value for the
+ * button's "tabindex" attribute.
+ */
+ _setTabIndex: function (p_nTabIndex) {
+
+ this._button.tabIndex = p_nTabIndex;
+
+ },
+
+
+ /**
+ * @method _setTitle
+ * @description Sets the value of the button's "title" attribute.
+ * @protected
+ * @param {String} p_nTabIndex Number indicating the value for
+ * the button's "title" attribute.
+ */
+ _setTitle: function (p_sTitle) {
+
+ var sTitle = p_sTitle;
+
+ if (this.get("type") != "link") {
+
+ if (!sTitle) {
+
+ switch (this.get("type")) {
+
+ case "radio":
+
+ sTitle = this.RADIO_DEFAULT_TITLE;
+
+ break;
+
+ case "checkbox":
+
+ sTitle = this.CHECKBOX_DEFAULT_TITLE;
+
+ break;
+
+ case "menu":
+
+ sTitle = this.MENUBUTTON_DEFAULT_TITLE;
+
+ break;
+
+ case "split":
+
+ sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
+
+ break;
+
+ case "submit":
+
+ sTitle = this.SUBMIT_TITLE;
+
+ break;
+
+ }
+
+ }
+
+ this._button.title = sTitle;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setDisabled
+ * @description Sets the value of the button's "disabled" attribute.
+ * @protected
+ * @param {Boolean} p_bDisabled Boolean indicating the value for
+ * the button's "disabled" attribute.
+ */
+ _setDisabled: function (p_bDisabled) {
+
+ if (this.get("type") != "link") {
+
+ if (p_bDisabled) {
+
+ if (this._menu) {
+
+ this._menu.hide();
+
+ }
+
+ if (this.hasFocus()) {
+
+ this.blur();
+
+ }
+
+ this._button.setAttribute("disabled", "disabled");
+
+ this.addStateCSSClasses("disabled");
+
+ }
+ else {
+
+ this._button.removeAttribute("disabled");
+
+ this.removeStateCSSClasses("disabled");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _setHref
+ * @description Sets the value of the button's "href" attribute.
+ * @protected
+ * @param {String} p_sHref String indicating the value for the button's
+ * "href" attribute.
+ */
+ _setHref: function (p_sHref) {
+
+ if (this.get("type") == "link") {
+
+ this._button.href = p_sHref;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setTarget
+ * @description Sets the value of the button's "target" attribute.
+ * @protected
+ * @param {String} p_sTarget String indicating the value for the button's
+ * "target" attribute.
+ */
+ _setTarget: function (p_sTarget) {
+
+ if (this.get("type") == "link") {
+
+ this._button.setAttribute("target", p_sTarget);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setChecked
+ * @description Sets the value of the button's "target" attribute.
+ * @protected
+ * @param {Boolean} p_bChecked Boolean indicating the value for
+ * the button's "checked" attribute.
+ */
+ _setChecked: function (p_bChecked) {
+
+ var sType = this.get("type"),
+ sTitle;
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ if (p_bChecked) {
+
+ this.addStateCSSClasses("checked");
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_CHECKED_TITLE :
+ this.CHECKBOX_CHECKED_TITLE;
+
+ }
+ else {
+
+ this.removeStateCSSClasses("checked");
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_DEFAULT_TITLE :
+ this.CHECKBOX_DEFAULT_TITLE;
+
+ }
+
+ this.set("title", sTitle);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setMenu
+ * @description Sets the value of the button's "menu" attribute.
+ * @protected
+ * @param {Object} p_oMenu Object indicating the value for the button's
+ * "menu" attribute.
+ */
+ _setMenu: function (p_oMenu) {
+
+ var bLazyLoad = this.get("lazyloadmenu"),
+ oButtonElement = this.get("element"),
+
+ /*
+ Boolean indicating if the value of p_oMenu is an instance
+ of YAHOO.widget.Menu or YAHOO.widget.Overlay.
+ */
+
+ bInstance = false,
+
+
+ oMenu,
+ oMenuElement,
+ oSrcElement,
+ aItems,
+ nItems,
+ oItem,
+ i;
+
+
+ if (!Overlay) {
+
+ this.logger.log("YAHOO.widget.Overlay dependency not met.",
+ "error");
+
+ return false;
+
+ }
+
+
+ if (!Menu) {
+
+ this.logger.log("YAHOO.widget.Menu dependency not met.",
+ "error");
+
+ return false;
+
+ }
+
+
+ function onAppendTo() {
+
+ oMenu.render(oButtonElement.parentNode);
+
+ this.removeListener("appendTo", onAppendTo);
+
+ }
+
+
+ function initMenu() {
+
+ if (oMenu) {
+
+ Dom.addClass(oMenu.element, this.get("menuclassname"));
+ Dom.addClass(oMenu.element,
+ "yui-" + this.get("type") + "-button-menu");
+
+ oMenu.showEvent.subscribe(this._onMenuShow, null, this);
+ oMenu.hideEvent.subscribe(this._onMenuHide, null, this);
+ oMenu.renderEvent.subscribe(this._onMenuRender, null, this);
+
+
+ if (oMenu instanceof Menu) {
+
+ oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,
+ this, true);
+
+ oMenu.clickEvent.subscribe(this._onMenuClick,
+ this, true);
+
+ oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,
+ this, true);
+
+ oSrcElement = oMenu.srcElement;
+
+ if (oSrcElement &&
+ oSrcElement.nodeName.toUpperCase() == "SELECT") {
+
+ oSrcElement.style.display = "none";
+ oSrcElement.parentNode.removeChild(oSrcElement);
+
+ }
+
+ }
+ else if (oMenu instanceof Overlay) {
+
+ if (!m_oOverlayManager) {
+
+ m_oOverlayManager =
+ new YAHOO.widget.OverlayManager();
+
+ }
+
+ m_oOverlayManager.register(oMenu);
+
+ }
+
+
+ this._menu = oMenu;
+
+
+ if (!bInstance) {
+
+ if (bLazyLoad && !(oMenu instanceof Menu)) {
+
+ /*
+ Mimic Menu's "lazyload" functionality by adding
+ a "beforeshow" event listener that renders the
+ Overlay instance before it is made visible by
+ the button.
+ */
+
+ oMenu.beforeShowEvent.subscribe(
+ this._onOverlayBeforeShow, null, this);
+
+ }
+ else if (!bLazyLoad) {
+
+ if (Dom.inDocument(oButtonElement)) {
+
+ oMenu.render(oButtonElement.parentNode);
+
+ }
+ else {
+
+ this.on("appendTo", onAppendTo);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+
+ if (p_oMenu && (p_oMenu instanceof Menu)) {
+
+ oMenu = p_oMenu;
+ aItems = oMenu.getItems();
+ nItems = aItems.length;
+ bInstance = true;
+
+
+ if (nItems > 0) {
+
+ i = nItems - 1;
+
+ do {
+
+ oItem = aItems[i];
+
+ if (oItem) {
+
+ oItem.cfg.subscribeToConfigEvent("selected",
+ this._onMenuItemSelected,
+ oItem,
+ this);
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ initMenu.call(this);
+
+ }
+ else if (p_oMenu && (p_oMenu instanceof Overlay)) {
+
+ oMenu = p_oMenu;
+ bInstance = true;
+
+ oMenu.cfg.setProperty("visible", false);
+ oMenu.cfg.setProperty("context", [oButtonElement, "tl", "bl"]);
+
+ initMenu.call(this);
+
+ }
+ else if (Lang.isArray(p_oMenu)) {
+
+ this.on("appendTo", function () {
+
+ oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad,
+ itemdata: p_oMenu });
+
+ initMenu.call(this);
+
+ });
+
+ }
+ else if (Lang.isString(p_oMenu)) {
+
+ oMenuElement = Dom.get(p_oMenu);
+
+ if (oMenuElement) {
+
+ if (Dom.hasClass(oMenuElement,
+ Menu.prototype.CSS_CLASS_NAME) ||
+ oMenuElement.nodeName == "SELECT") {
+
+ oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
+
+ initMenu.call(this);
+
+ }
+ else {
+
+ oMenu = new Overlay(p_oMenu, { visible: false,
+ context: [oButtonElement, "tl", "bl"] });
+
+ initMenu.call(this);
+
+ }
+
+ }
+
+ }
+ else if (p_oMenu && p_oMenu.nodeName) {
+
+ if (Dom.hasClass(p_oMenu, Menu.prototype.CSS_CLASS_NAME) ||
+ p_oMenu.nodeName == "SELECT") {
+
+ oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
+
+ initMenu.call(this);
+
+ }
+ else {
+
+ if (!p_oMenu.id) {
+
+ Dom.generateId(p_oMenu);
+
+ }
+
+ oMenu = new Overlay(p_oMenu, { visible: false,
+ context: [oButtonElement, "tl", "bl"] });
+
+ initMenu.call(this);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _setOnClick
+ * @description Sets the value of the button's "onclick" attribute.
+ * @protected
+ * @param {Object} p_oObject Object indicating the value for the button's
+ * "onclick" attribute.
+ */
+ _setOnClick: function (p_oObject) {
+
+ /*
+ Remove any existing listeners if a "click" event handler
+ has already been specified.
+ */
+
+ if (this._onclickAttributeValue &&
+ (this._onclickAttributeValue != p_oObject)) {
+
+ this.removeListener("click", this._onclickAttributeValue.fn);
+
+ this._onclickAttributeValue = null;
+
+ }
+
+
+ if (!this._onclickAttributeValue &&
+ Lang.isObject(p_oObject) &&
+ Lang.isFunction(p_oObject.fn)) {
+
+ this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope);
+
+ this._onclickAttributeValue = p_oObject;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setSelectedMenuItem
+ * @description Sets the value of the button's
+ * "selectedMenuItem" attribute.
+ * @protected
+ * @param {Number} p_nIndex Number representing the index of the item
+ * in the button's menu that is currently selected.
+ */
+ _setSelectedMenuItem: function (p_nIndex) {
+
+ var oMenu = this._menu,
+ oMenuItem;
+
+
+ if (oMenu && oMenu instanceof Menu) {
+
+ oMenuItem = oMenu.getItem(p_nIndex);
+
+
+ if (oMenuItem && !oMenuItem.cfg.getProperty("selected")) {
+
+ oMenuItem.cfg.setProperty("selected", true);
+
+ }
+
+ }
+
+ },
+
+
+ // Protected methods
+
+
+
+ /**
+ * @method _isActivationKey
+ * @description Determines if the specified keycode is one that toggles
+ * the button's "active" state.
+ * @protected
+ * @param {Number} p_nKeyCode Number representing the keycode to
+ * be evaluated.
+ * @return {Boolean}
+ */
+ _isActivationKey: function (p_nKeyCode) {
+
+ var sType = this.get("type"),
+ aKeyCodes = (sType == "checkbox" || sType == "radio") ?
+ this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS,
+
+ nKeyCodes = aKeyCodes.length,
+ i;
+
+ if (nKeyCodes > 0) {
+
+ i = nKeyCodes - 1;
+
+ do {
+
+ if (p_nKeyCode == aKeyCodes[i]) {
+
+ return true;
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ },
+
+
+ /**
+ * @method _isSplitButtonOptionKey
+ * @description Determines if the specified keycode is one that toggles
+ * the display of the split button's menu.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ * @return {Boolean}
+ */
+ _isSplitButtonOptionKey: function (p_oEvent) {
+
+ return (p_oEvent.ctrlKey && p_oEvent.shiftKey &&
+ Event.getCharCode(p_oEvent) == 77);
+
+ },
+
+
+ /**
+ * @method _addListenersToForm
+ * @description Adds event handlers to the button's form.
+ * @protected
+ */
+ _addListenersToForm: function () {
+
+ var oForm = this.getForm(),
+ oSrcElement,
+ aListeners,
+ nListeners,
+ i,
+ bHasKeyPressListener;
+
+
+ if (oForm) {
+
+ Event.on(oForm, "reset", this._onFormReset, null, this);
+ Event.on(oForm, "submit", this.createHiddenFields, null, this);
+
+ oSrcElement = this.get("srcelement");
+
+
+ if (this.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit"))
+ {
+
+ aListeners = Event.getListeners(oForm, "keypress");
+ bHasKeyPressListener = false;
+
+ if (aListeners) {
+
+ nListeners = aListeners.length;
+
+ if (nListeners > 0) {
+
+ i = nListeners - 1;
+
+ do {
+
+ if (aListeners[i].fn ==
+ YAHOO.widget.Button.onFormKeyPress)
+ {
+
+ bHasKeyPressListener = true;
+ break;
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ }
+
+
+ if (!bHasKeyPressListener) {
+
+ Event.on(oForm, "keypress",
+ YAHOO.widget.Button.onFormKeyPress);
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ _originalMaxHeight: -1,
+
+
+ /**
+ * @method _showMenu
+ * @description Shows the button's menu.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event) that triggered
+ * the display of the menu.
+ */
+ _showMenu: function (p_oEvent) {
+
+ YAHOO.widget.MenuManager.hideVisible();
+
+ if (m_oOverlayManager) {
+
+ m_oOverlayManager.hideAll();
+
+ }
+
+
+ var oMenu = this._menu,
+ nViewportHeight = Dom.getViewportHeight(),
+ nMenuHeight,
+ nScrollTop,
+ nY;
+
+
+ if (oMenu && (oMenu instanceof Menu)) {
+
+ oMenu.cfg.applyConfig({ context: [this.get("id"), "tl", "bl"],
+ constraintoviewport: false,
+ clicktohide: false,
+ visible: true });
+
+ oMenu.cfg.fireQueue();
+
+ oMenu.align("tl", "bl");
+
+ /*
+ Stop the propagation of the event so that the MenuManager
+ doesn't blur the menu after it gets focus.
+ */
+
+ if (p_oEvent.type == "mousedown") {
+
+ Event.stopPropagation(p_oEvent);
+
+ }
+
+
+ if (this.get("focusmenu")) {
+
+ this._menu.focus();
+
+ }
+
+ nMenuHeight = oMenu.element.offsetHeight;
+
+
+ if ((oMenu.cfg.getProperty("y") + nMenuHeight) >
+ nViewportHeight) {
+
+ this.logger.log("Current menu position will place a " +
+ "portion, or the entire menu outside the boundary of " +
+ "the viewport. Repositioning the menu to stay " +
+ "inside the viewport.");
+
+ oMenu.align("bl", "tl");
+
+ nY = oMenu.cfg.getProperty("y");
+
+ nScrollTop = Dom.getDocumentScrollTop();
+
+
+ if (nScrollTop >= nY) {
+
+ if (this._originalMaxHeight == -1) {
+
+ this._originalMaxHeight =
+ oMenu.cfg.getProperty("maxheight");
+
+ }
+
+ oMenu.cfg.setProperty("maxheight",
+ (nMenuHeight - ((nScrollTop - nY) + 20)));
+
+ oMenu.align("bl", "tl");
+
+ }
+
+ }
+
+ }
+ else if (oMenu && (oMenu instanceof Overlay)) {
+
+ oMenu.show();
+ oMenu.align("tl", "bl");
+
+ nMenuHeight = oMenu.element.offsetHeight;
+
+
+ if ((oMenu.cfg.getProperty("y") + nMenuHeight) >
+ nViewportHeight) {
+
+ this.logger.log("Current menu position will place a " +
+ "portion, or the entire menu outside the boundary of " +
+ "the viewport. Repositioning the menu to stay inside" +
+ " the viewport.");
+
+ oMenu.align("bl", "tl");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _hideMenu
+ * @description Hides the button's menu.
+ * @protected
+ */
+ _hideMenu: function () {
+
+ var oMenu = this._menu;
+
+ if (oMenu) {
+
+ oMenu.hide();
+
+ }
+
+ },
+
+
+
+
+ // Protected event handlers
+
+
+ /**
+ * @method _onMouseOver
+ * @description "mouseover" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseOver: function (p_oEvent) {
+
+ if (!this._hasMouseEventHandlers) {
+
+ this.on("mouseout", this._onMouseOut);
+ this.on("mousedown", this._onMouseDown);
+ this.on("mouseup", this._onMouseUp);
+
+ this._hasMouseEventHandlers = true;
+
+ }
+
+ this.addStateCSSClasses("hover");
+
+ if (this._activationButtonPressed) {
+
+ this.addStateCSSClasses("active");
+
+ }
+
+
+ if (this._bOptionPressed) {
+
+ this.addStateCSSClasses("activeoption");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMouseOut
+ * @description "mouseout" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseOut: function (p_oEvent) {
+
+ this.removeStateCSSClasses("hover");
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ if (this._activationButtonPressed || this._bOptionPressed) {
+
+ Event.on(document, "mouseup", this._onDocumentMouseUp,
+ null, this);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onDocumentMouseUp
+ * @description "mouseup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentMouseUp: function (p_oEvent) {
+
+ this._activationButtonPressed = false;
+ this._bOptionPressed = false;
+
+ var sType = this.get("type");
+
+ if (sType == "menu" || sType == "split") {
+
+ this.removeStateCSSClasses(
+ (sType == "menu" ? "active" : "activeoption"));
+
+ this._hideMenu();
+
+ }
+
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+
+ },
+
+
+ /**
+ * @method _onMouseDown
+ * @description "mousedown" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseDown: function (p_oEvent) {
+
+ var sType,
+ oElement,
+ nX,
+ me;
+
+
+ function onMouseUp() {
+
+ this._hideMenu();
+ this.removeListener("mouseup", onMouseUp);
+
+ }
+
+
+ if ((p_oEvent.which || p_oEvent.button) == 1) {
+
+
+ if (!this.hasFocus()) {
+
+ this.focus();
+
+ }
+
+
+ sType = this.get("type");
+
+
+ if (sType == "split") {
+
+ oElement = this.get("element");
+ nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
+
+ if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
+
+ this.fireEvent("option", p_oEvent);
+
+ }
+ else {
+
+ this.addStateCSSClasses("active");
+
+ this._activationButtonPressed = true;
+
+ }
+
+ }
+ else if (sType == "menu") {
+
+ if (this.isActive()) {
+
+ this._hideMenu();
+
+ this._activationButtonPressed = false;
+
+ }
+ else {
+
+ this._showMenu(p_oEvent);
+
+ this._activationButtonPressed = true;
+
+ }
+
+ }
+ else {
+
+ this.addStateCSSClasses("active");
+
+ this._activationButtonPressed = true;
+
+ }
+
+
+
+ if (sType == "split" || sType == "menu") {
+
+ me = this;
+
+ this._hideMenuTimerId = window.setTimeout(function () {
+
+ me.on("mouseup", onMouseUp);
+
+ }, 250);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMouseUp
+ * @description "mouseup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseUp: function (p_oEvent) {
+
+ var sType = this.get("type");
+
+
+ if (this._hideMenuTimerId) {
+
+ window.clearTimeout(this._hideMenuTimerId);
+
+ }
+
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.set("checked", !(this.get("checked")));
+
+ }
+
+
+ this._activationButtonPressed = false;
+
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onFocus
+ * @description "focus" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onFocus: function (p_oEvent) {
+
+ var oElement;
+
+ this.addStateCSSClasses("focus");
+
+ if (this._activationKeyPressed) {
+
+ this.addStateCSSClasses("active");
+
+ }
+
+ m_oFocusedButton = this;
+
+
+ if (!this._hasKeyEventHandlers) {
+
+ oElement = this._button;
+
+ Event.on(oElement, "blur", this._onBlur, null, this);
+ Event.on(oElement, "keydown", this._onKeyDown, null, this);
+ Event.on(oElement, "keyup", this._onKeyUp, null, this);
+
+ this._hasKeyEventHandlers = true;
+
+ }
+
+
+ this.fireEvent("focus", p_oEvent);
+
+ },
+
+
+ /**
+ * @method _onBlur
+ * @description "blur" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onBlur: function (p_oEvent) {
+
+ this.removeStateCSSClasses("focus");
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ if (this._activationKeyPressed) {
+
+ Event.on(document, "keyup", this._onDocumentKeyUp, null, this);
+
+ }
+
+
+ m_oFocusedButton = null;
+
+ this.fireEvent("blur", p_oEvent);
+
+ },
+
+
+ /**
+ * @method _onDocumentKeyUp
+ * @description "keyup" event handler for the document.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentKeyUp: function (p_oEvent) {
+
+ if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ this._activationKeyPressed = false;
+
+ Event.removeListener(document, "keyup", this._onDocumentKeyUp);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onKeyDown
+ * @description "keydown" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyDown: function (p_oEvent) {
+
+ var oMenu = this._menu;
+
+
+ if (this.get("type") == "split" &&
+ this._isSplitButtonOptionKey(p_oEvent)) {
+
+ this.fireEvent("option", p_oEvent);
+
+ }
+ else if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ if (this.get("type") == "menu") {
+
+ this._showMenu(p_oEvent);
+
+ }
+ else {
+
+ this._activationKeyPressed = true;
+
+ this.addStateCSSClasses("active");
+
+ }
+
+ }
+
+
+ if (oMenu && oMenu.cfg.getProperty("visible") &&
+ Event.getCharCode(p_oEvent) == 27) {
+
+ oMenu.hide();
+ this.focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method _onKeyUp
+ * @description "keyup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyUp: function (p_oEvent) {
+
+ var sType;
+
+ if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ sType = this.get("type");
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.set("checked", !(this.get("checked")));
+
+ }
+
+ this._activationKeyPressed = false;
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onClick
+ * @description "click" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onClick: function (p_oEvent) {
+
+ var sType = this.get("type"),
+ sTitle,
+ oForm,
+ oSrcElement,
+ oElement,
+ nX;
+
+
+ switch (sType) {
+
+ case "radio":
+ case "checkbox":
+
+ if (this.get("checked")) {
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_CHECKED_TITLE :
+ this.CHECKBOX_CHECKED_TITLE;
+
+ }
+ else {
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_DEFAULT_TITLE :
+ this.CHECKBOX_DEFAULT_TITLE;
+
+ }
+
+ this.set("title", sTitle);
+
+ break;
+
+ case "submit":
+
+ this.submitForm();
+
+ break;
+
+ case "reset":
+
+ oForm = this.getForm();
+
+ if (oForm) {
+
+ oForm.reset();
+
+ }
+
+ break;
+
+ case "menu":
+
+ sTitle = this._menu.cfg.getProperty("visible") ?
+ this.MENUBUTTON_MENU_VISIBLE_TITLE :
+ this.MENUBUTTON_DEFAULT_TITLE;
+
+ this.set("title", sTitle);
+
+ break;
+
+ case "split":
+
+ oElement = this.get("element");
+ nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
+
+ if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
+
+ return false;
+
+ }
+ else {
+
+ this._hideMenu();
+
+ oSrcElement = this.get("srcelement");
+
+ if (oSrcElement && oSrcElement.type == "submit") {
+
+ this.submitForm();
+
+ }
+
+ }
+
+ sTitle = this._menu.cfg.getProperty("visible") ?
+ this.SPLITBUTTON_OPTION_VISIBLE_TITLE :
+ this.SPLITBUTTON_DEFAULT_TITLE;
+
+ this.set("title", sTitle);
+
+ break;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onAppendTo
+ * @description "appendTo" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onAppendTo: function (p_oEvent) {
+
+ /*
+ It is necessary to call "getForm" using "setTimeout" to make
+ sure that the button's "form" property returns a node
+ reference. Sometimes, if you try to get the reference
+ immediately after appending the field, it is null.
+ */
+
+ var me = this;
+
+ window.setTimeout(function () {
+
+ me._addListenersToForm();
+
+ }, 0);
+
+ },
+
+
+ /**
+ * @method _onFormReset
+ * @description "reset" event handler for the button's form.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event
+ * object passed back by the event utility (YAHOO.util.Event).
+ */
+ _onFormReset: function (p_oEvent) {
+
+ var sType = this.get("type"),
+ oMenu = this._menu;
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.resetValue("checked");
+
+ }
+
+
+ if (oMenu && (oMenu instanceof Menu)) {
+
+ this.resetValue("selectedMenuItem");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onDocumentMouseDown
+ * @description "mousedown" event handler for the document.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentMouseDown: function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ oButtonElement = this.get("element"),
+ oMenuElement = this._menu.element;
+
+ if (oTarget != oButtonElement &&
+ !Dom.isAncestor(oButtonElement, oTarget) &&
+ oTarget != oMenuElement &&
+ !Dom.isAncestor(oMenuElement, oTarget)) {
+
+ this._hideMenu();
+
+ Event.removeListener(document, "mousedown",
+ this._onDocumentMouseDown);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onOption
+ * @description "option" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onOption: function (p_oEvent) {
+
+ if (this.hasClass("yui-split-button-activeoption")) {
+
+ this._hideMenu();
+
+ this._bOptionPressed = false;
+
+ }
+ else {
+
+ this._showMenu(p_oEvent);
+
+ this._bOptionPressed = true;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onOverlayBeforeShow
+ * @description "beforeshow" event handler for the
+ * YAHOO.widget.Overlay instance
+ * serving as the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onOverlayBeforeShow: function (p_sType) {
+
+ var oMenu = this._menu;
+
+ oMenu.render(this.get("element").parentNode);
+
+ oMenu.beforeShowEvent.unsubscribe(this._onOverlayBeforeShow);
+
+ },
+
+
+ /**
+ * @method _onMenuShow
+ * @description "show" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onMenuShow: function (p_sType) {
+
+ Event.on(document, "mousedown", this._onDocumentMouseDown,
+ null, this);
+
+ var sTitle,
+ sState;
+
+ if (this.get("type") == "split") {
+
+ sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE;
+ sState = "activeoption";
+
+ }
+ else {
+
+ sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE;
+ sState = "active";
+
+ }
+
+ this.addStateCSSClasses(sState);
+ this.set("title", sTitle);
+
+ },
+
+
+ /**
+ * @method _onMenuHide
+ * @description "hide" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onMenuHide: function (p_sType) {
+
+ var oMenu = this._menu,
+ sTitle,
+ sState;
+
+ if (oMenu && (oMenu instanceof Menu) &&
+ this._originalMaxHeight != -1) {
+
+ this._menu.cfg.setProperty("maxheight",
+ this._originalMaxHeight);
+
+ }
+
+
+ if (this.get("type") == "split") {
+
+ sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
+ sState = "activeoption";
+
+ }
+ else {
+
+ sTitle = this.MENUBUTTON_DEFAULT_TITLE;
+ sState = "active";
+ }
+
+
+ this.removeStateCSSClasses(sState);
+ this.set("title", sTitle);
+
+
+ if (this.get("type") == "split") {
+
+ this._bOptionPressed = false;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuKeyDown
+ * @description "keydown" event handler for the button's 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.
+ */
+ _onMenuKeyDown: function (p_sType, p_aArgs) {
+
+ var oEvent = p_aArgs[0];
+
+ if (Event.getCharCode(oEvent) == 27) {
+
+ this.focus();
+
+ if (this.get("type") == "split") {
+
+ this._bOptionPressed = false;
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuRender
+ * @description "render" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the
+ * event thatwas fired.
+ */
+ _onMenuRender: function (p_sType) {
+
+ var oButtonElement = this.get("element"),
+ oButtonParent = oButtonElement.parentNode,
+ oMenuElement = this._menu.element;
+
+
+ if (oButtonParent != oMenuElement.parentNode) {
+
+ oButtonParent.appendChild(oMenuElement);
+
+ }
+
+ this.set("selectedMenuItem", this.get("selectedMenuItem"));
+
+ },
+
+
+ /**
+ * @method _onMenuItemSelected
+ * @description "selectedchange" event handler for each item in the
+ * button's 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 {Number} p_nItem Number representing the index of the menu
+ * item that subscribed to the event.
+ */
+ _onMenuItemSelected: function (p_sType, p_aArgs, p_nItem) {
+
+ var bSelected = p_aArgs[0];
+
+ if (bSelected) {
+
+ this.set("selectedMenuItem", p_nItem);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuItemAdded
+ * @description "itemadded" event handler for the button's 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.MenuItem } p_oItem Object representing the menu
+ * item that subscribed to the event.
+ */
+ _onMenuItemAdded: function (p_sType, p_aArgs, p_oItem) {
+
+ var oItem = p_aArgs[0];
+
+ oItem.cfg.subscribeToConfigEvent("selected",
+ this._onMenuItemSelected,
+ oItem.index,
+ this);
+
+ },
+
+
+ /**
+ * @method _onMenuClick
+ * @description "click" event handler for the button's 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.
+ */
+ _onMenuClick: function (p_sType, p_aArgs) {
+
+ var oItem = p_aArgs[1],
+ oSrcElement;
+
+ if (oItem) {
+
+ oSrcElement = this.get("srcelement");
+
+ if (oSrcElement && oSrcElement.type == "submit") {
+
+ this.submitForm();
+
+ }
+
+ this._hideMenu();
+
+ }
+
+ },
+
+
+
+ // Public methods
+
+
+ /**
+ * @method createButtonElement
+ * @description Creates the button's HTML elements.
+ * @param {String} p_sType String indicating the type of element
+ * to create.
+ * @return {HTMLElement }
+ */
+ createButtonElement: function (p_sType) {
+
+ var sNodeName = this.NODE_NAME,
+ oElement = document.createElement(sNodeName);
+
+ oElement.innerHTML = "<" + sNodeName + " class=\"first-child\">" +
+ (p_sType == "link" ? " " :
+ " ") + "" + sNodeName + ">";
+
+ return oElement;
+
+ },
+
+
+ /**
+ * @method addStateCSSClasses
+ * @description Appends state-specific CSS classes to the button's root
+ * DOM element.
+ */
+ addStateCSSClasses: function (p_sState) {
+
+ var sType = this.get("type");
+
+ if (Lang.isString(p_sState)) {
+
+ if (p_sState != "activeoption") {
+
+ this.addClass(this.CSS_CLASS_NAME + ("-" + p_sState));
+
+ }
+
+ this.addClass("yui-" + sType + ("-button-" + p_sState));
+
+ }
+
+ },
+
+
+ /**
+ * @method removeStateCSSClasses
+ * @description Removes state-specific CSS classes to the button's root
+ * DOM element.
+ */
+ removeStateCSSClasses: function (p_sState) {
+
+ var sType = this.get("type");
+
+ if (Lang.isString(p_sState)) {
+
+ this.removeClass(this.CSS_CLASS_NAME + ("-" + p_sState));
+ this.removeClass("yui-" + sType + ("-button-" + p_sState));
+
+ }
+
+ },
+
+
+ /**
+ * @method createHiddenFields
+ * @description Creates the button's hidden form field and appends it
+ * to its parent form.
+ * @return {HTMLInputElement |Array}
+ */
+ createHiddenFields: function () {
+
+ this.removeHiddenFields();
+
+ var oForm = this.getForm(),
+ oButtonField,
+ sType,
+ bCheckable,
+ oMenu,
+ oMenuItem,
+ sName,
+ oValue,
+ oMenuField;
+
+
+ if (oForm && !this.get("disabled")) {
+
+ sType = this.get("type");
+ bCheckable = (sType == "checkbox" || sType == "radio");
+
+
+ if (bCheckable || (m_oSubmitTrigger == this)) {
+
+ this.logger.log("Creating hidden field.");
+
+ oButtonField = createInputElement(
+ (bCheckable ? sType : "hidden"),
+ this.get("name"),
+ this.get("value"),
+ this.get("checked"));
+
+
+ if (oButtonField) {
+
+ if (bCheckable) {
+
+ oButtonField.style.display = "none";
+
+ }
+
+ oForm.appendChild(oButtonField);
+
+ }
+
+ }
+
+
+ oMenu = this._menu;
+
+
+ if (oMenu && (oMenu instanceof Menu)) {
+
+ this.logger.log("Creating hidden field for menu.");
+
+ oMenuField = oMenu.srcElement;
+ oMenuItem = oMenu.getItem(this.get("selectedMenuItem"));
+
+ if (oMenuField &&
+ oMenuField.nodeName.toUpperCase() == "SELECT") {
+
+ oForm.appendChild(oMenuField);
+ oMenuField.selectedIndex = oMenuItem.index;
+
+ }
+ else {
+
+ oValue = (oMenuItem.value === null ||
+ oMenuItem.value === "") ?
+ oMenuItem.cfg.getProperty("text") :
+ oMenuItem.value;
+
+ sName = this.get("name");
+
+ if (oValue && sName) {
+
+ oMenuField = createInputElement("hidden",
+ (sName + "_options"),
+ oValue);
+
+ oForm.appendChild(oMenuField);
+
+ }
+
+ }
+
+ }
+
+
+ if (oButtonField && oMenuField) {
+
+ this._hiddenFields = [oButtonField, oMenuField];
+
+ }
+ else if (!oButtonField && oMenuField) {
+
+ this._hiddenFields = oMenuField;
+
+ }
+ else if (oButtonField && !oMenuField) {
+
+ this._hiddenFields = oButtonField;
+
+ }
+
+
+ return this._hiddenFields;
+
+ }
+
+ },
+
+
+ /**
+ * @method removeHiddenFields
+ * @description Removes the button's hidden form field(s) from its
+ * parent form.
+ */
+ removeHiddenFields: function () {
+
+ var oField = this._hiddenFields,
+ nFields,
+ i;
+
+ function removeChild(p_oElement) {
+
+ if (Dom.inDocument(p_oElement)) {
+
+ p_oElement.parentNode.removeChild(p_oElement);
+
+ }
+
+ }
+
+
+ if (oField) {
+
+ if (Lang.isArray(oField)) {
+
+ nFields = oField.length;
+
+ if (nFields > 0) {
+
+ i = nFields - 1;
+
+ do {
+
+ removeChild(oField[i]);
+
+ }
+ while (i--);
+
+ }
+
+ }
+ else {
+
+ removeChild(oField);
+
+ }
+
+ this._hiddenFields = null;
+
+ }
+
+ },
+
+
+ /**
+ * @method submitForm
+ * @description Submits the form to which the button belongs. Returns
+ * true if the form was submitted successfully, false if the submission
+ * was cancelled.
+ * @protected
+ * @return {Boolean}
+ */
+ submitForm: function () {
+
+ var oForm = this.getForm(),
+
+ oSrcElement = this.get("srcelement"),
+
+ /*
+ Boolean indicating if the event fired successfully
+ (was not cancelled by any handlers)
+ */
+
+ bSubmitForm = false,
+
+ oEvent;
+
+
+ if (oForm) {
+
+ if (this.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit"))
+ {
+
+ m_oSubmitTrigger = this;
+
+ }
+
+
+ if (YAHOO.env.ua.ie) {
+
+ bSubmitForm = oForm.fireEvent("onsubmit");
+
+ }
+ else { // Gecko, Opera, and Safari
+
+ oEvent = document.createEvent("HTMLEvents");
+ oEvent.initEvent("submit", true, true);
+
+ bSubmitForm = oForm.dispatchEvent(oEvent);
+
+ }
+
+
+ /*
+ In IE and Safari, dispatching a "submit" event to a form
+ WILL cause the form's "submit" event to fire, but WILL NOT
+ submit the form. Therefore, we need to call the "submit"
+ method as well.
+ */
+
+ if ((YAHOO.env.ua.ie || YAHOO.env.ua.webkit) && bSubmitForm) {
+
+ oForm.submit();
+
+ }
+
+ }
+
+ return bSubmitForm;
+
+ },
+
+
+ /**
+ * @method init
+ * @description The Button class's initialization method.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to
+ * be used to create the button.
+ * @param {HTMLInputElement |HTMLButtonElement |
+ * HTMLElement } p_oElement Object reference for the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to be
+ * used to create the button.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a
+ * set of configuration attributes used to create the button.
+ */
+ init: function (p_oElement, p_oAttributes) {
+
+ var sNodeName = p_oAttributes.type == "link" ? "A" : "BUTTON",
+ oSrcElement = p_oAttributes.srcelement,
+ oButton = p_oElement.getElementsByTagName(sNodeName)[0],
+ oInput;
+
+
+ if (!oButton) {
+
+ oInput = p_oElement.getElementsByTagName("INPUT")[0];
+
+
+ if (oInput) {
+
+ oButton = document.createElement("BUTTON");
+ oButton.setAttribute("type", "button");
+
+ oInput.parentNode.replaceChild(oButton, oInput);
+
+ }
+
+ }
+
+ this._button = oButton;
+
+
+ YAHOO.widget.Button.superclass.init.call(this, p_oElement,
+ p_oAttributes);
+
+
+ m_oButtons[this.get("id")] = this;
+
+
+ this.addClass(this.CSS_CLASS_NAME);
+
+ this.addClass("yui-" + this.get("type") + "-button");
+
+ Event.on(this._button, "focus", this._onFocus, null, this);
+ this.on("mouseover", this._onMouseOver);
+ this.on("click", this._onClick);
+ this.on("appendTo", this._onAppendTo);
+
+
+ var oContainer = this.get("container"),
+ oElement = this.get("element"),
+ bElInDoc = Dom.inDocument(oElement),
+ oParentNode;
+
+
+ if (oContainer) {
+
+ if (oSrcElement && oSrcElement != oElement) {
+
+ oParentNode = oSrcElement.parentNode;
+
+ if (oParentNode) {
+
+ oParentNode.removeChild(oSrcElement);
+
+ }
+
+ }
+
+ if (Lang.isString(oContainer)) {
+
+ Event.onContentReady(oContainer, function () {
+
+ this.appendTo(oContainer);
+
+ }, null, this);
+
+ }
+ else {
+
+ this.appendTo(oContainer);
+
+ }
+
+ }
+ else if (!bElInDoc && oSrcElement && oSrcElement != oElement) {
+
+ oParentNode = oSrcElement.parentNode;
+
+ if (oParentNode) {
+
+ this.fireEvent("beforeAppendTo", {
+ type: "beforeAppendTo",
+ target: oParentNode
+ });
+
+ oParentNode.replaceChild(oElement, oSrcElement);
+
+ this.fireEvent("appendTo", {
+ type: "appendTo",
+ target: oParentNode
+ });
+
+ }
+
+ }
+ else if (this.get("type") != "link" && bElInDoc && oSrcElement &&
+ oSrcElement == oElement) {
+
+ this._addListenersToForm();
+
+ }
+
+ this.logger.log("Initialization completed.");
+
+ },
+
+
+ /**
+ * @method initAttributes
+ * @description Initializes all of the configuration attributes used to
+ * create the button.
+ * @param {Object} p_oAttributes Object literal specifying a set of
+ * configuration attributes used to create the button.
+ */
+ initAttributes: function (p_oAttributes) {
+
+ var oAttributes = p_oAttributes || {};
+
+ YAHOO.widget.Button.superclass.initAttributes.call(this,
+ oAttributes);
+
+
+ /**
+ * @config type
+ * @description String specifying the button's type. Possible
+ * values are: "push," "link," "submit," "reset," "checkbox,"
+ * "radio," "menu," and "split."
+ * @default "push"
+ * @type String
+ */
+ this.setAttributeConfig("type", {
+
+ value: (oAttributes.type || "push"),
+ validator: Lang.isString,
+ writeOnce: true,
+ method: this._setType
+
+ });
+
+
+ /**
+ * @config label
+ * @description String specifying the button's text label
+ * or innerHTML.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("label", {
+
+ value: oAttributes.label,
+ validator: Lang.isString,
+ method: this._setLabel
+
+ });
+
+
+ /**
+ * @config value
+ * @description Object specifying the value for the button.
+ * @default null
+ * @type Object
+ */
+ this.setAttributeConfig("value", {
+
+ value: oAttributes.value
+
+ });
+
+
+ /**
+ * @config name
+ * @description String specifying the name for the button.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("name", {
+
+ value: oAttributes.name,
+ validator: Lang.isString
+
+ });
+
+
+ /**
+ * @config tabindex
+ * @description Number specifying the tabindex for the button.
+ * @default null
+ * @type Number
+ */
+ this.setAttributeConfig("tabindex", {
+
+ value: oAttributes.tabindex,
+ validator: Lang.isNumber,
+ method: this._setTabIndex
+
+ });
+
+
+ /**
+ * @config title
+ * @description String specifying the title for the button.
+ * @default null
+ * @type String
+ */
+ this.configureAttribute("title", {
+
+ value: oAttributes.title,
+ validator: Lang.isString,
+ method: this._setTitle
+
+ });
+
+
+ /**
+ * @config disabled
+ * @description Boolean indicating if the button should be disabled.
+ * (Disabled buttons are dimmed and will not respond to user input
+ * or fire events. Does not apply to button's of type "link.")
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("disabled", {
+
+ value: (oAttributes.disabled || false),
+ validator: Lang.isBoolean,
+ method: this._setDisabled
+
+ });
+
+
+ /**
+ * @config href
+ * @description String specifying the href for the button. Applies
+ * only to buttons of type "link."
+ * @type String
+ */
+ this.setAttributeConfig("href", {
+
+ value: oAttributes.href,
+ validator: Lang.isString,
+ method: this._setHref
+
+ });
+
+
+ /**
+ * @config target
+ * @description String specifying the target for the button.
+ * Applies only to buttons of type "link."
+ * @type String
+ */
+ this.setAttributeConfig("target", {
+
+ value: oAttributes.target,
+ validator: Lang.isString,
+ method: this._setTarget
+
+ });
+
+
+ /**
+ * @config checked
+ * @description Boolean indicating if the button is checked.
+ * Applies only to buttons of type "radio" and "checkbox."
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("checked", {
+
+ value: (oAttributes.checked || false),
+ validator: Lang.isBoolean,
+ method: this._setChecked
+
+ });
+
+
+ /**
+ * @config container
+ * @description HTML element reference or string specifying the id
+ * attribute of the HTML element that the button's markup should be
+ * rendered into.
+ * @type HTMLElement |String
+ * @default null
+ */
+ this.setAttributeConfig("container", {
+
+ value: oAttributes.container,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config srcelement
+ * @description Object reference to the HTML element (either
+ * <input>
or <span>
)
+ * used to create the button.
+ * @type HTMLElement |String
+ * @default null
+ */
+ this.setAttributeConfig("srcelement", {
+
+ value: oAttributes.srcelement,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config menu
+ * @description Object specifying the menu for the button.
+ * The value can be one of the following:
+ *
+ * Object specifying a
+ * YAHOO.widget.Menu instance.
+ * Object specifying a
+ * YAHOO.widget.Overlay instance.
+ * String specifying the id attribute of the <div>
+ *
element used to create the menu. By default the menu
+ * will be created as an instance of
+ * YAHOO.widget.Overlay .
+ * If the
+ * default CSS class name for YAHOO.widget.Menu is applied to
+ * the <div>
element, it will be created as an
+ * instance of YAHOO.widget.Menu
+ * . String specifying the id attribute of the
+ * <select>
element used to create the menu.
+ * Object specifying the <div>
element
+ * used to create the menu.
+ * Object specifying the <select>
element
+ * used to create the menu.
+ * Array of object literals, each representing a set of
+ * YAHOO.widget.MenuItem
+ * configuration attributes.
+ * Array of strings representing the text labels for each menu
+ * item in the menu.
+ *
+ * @type YAHOO.widget.Menu |YAHOO.widget.Overlay |HTMLElement |String|Array
+ * @default null
+ */
+ this.setAttributeConfig("menu", {
+
+ value: null,
+ method: this._setMenu,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config lazyloadmenu
+ * @description Boolean indicating the value to set for the
+ * "lazyload"
+ * configuration property of the button's menu. Setting
+ * "lazyloadmenu" to true
will defer rendering of
+ * the button's menu until the first time it is made visible.
+ * If "lazyloadmenu" is set to false
, the button's
+ * menu will be rendered immediately if the button is in the
+ * document, or in response to the button's "appendTo" event if
+ * the button is not yet in the document. In either case, the
+ * menu is rendered into the button's parent HTML element.
+ * This attribute does not apply if a
+ * YAHOO.widget.Menu or
+ * YAHOO.widget.Overlay
+ * instance is passed as the value of the button's "menu"
+ * configuration attribute.
+ * YAHOO.widget.Menu or
+ * YAHOO.widget.Overlay instances should be rendered before
+ * being set as the value for the "menu" configuration
+ * attribute.
+ * @default true
+ * @type Boolean
+ */
+ this.setAttributeConfig("lazyloadmenu", {
+
+ value: (oAttributes.lazyloadmenu === false ? false : true),
+ validator: Lang.isBoolean,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config menuclassname
+ * @description String representing the CSS class name to be
+ * applied to the root element of the button's menu.
+ * @type String
+ * @default "yui-button-menu"
+ */
+ this.setAttributeConfig("menuclassname", {
+
+ value: (oAttributes.menuclassname || "yui-button-menu"),
+ validator: Lang.isString,
+ method: this._setMenuClassName,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config selectedMenuItem
+ * @description Number representing the index of the item in the
+ * button's menu that is currently selected.
+ * @type Number
+ * @default null
+ */
+ this.setAttributeConfig("selectedMenuItem", {
+
+ value: 0,
+ validator: Lang.isNumber,
+ method: this._setSelectedMenuItem
+
+ });
+
+
+ /**
+ * @config onclick
+ * @description Object literal representing the code to be executed
+ * when the button is clicked. Format: {
+ * fn: Function, // The handler to call
+ * when the event fires. obj: Object,
+ * // An object to pass back to the handler.
+ * scope: Object // The object to use
+ * for the scope of the handler. }
+ * @type Object
+ * @default null
+ */
+ this.setAttributeConfig("onclick", {
+
+ value: oAttributes.onclick,
+ method: this._setOnClick
+
+ });
+
+
+ /**
+ * @config focusmenu
+ * @description Boolean indicating whether or not the button's menu
+ * should be focused when it is made visible.
+ * @type Boolean
+ * @default true
+ */
+ this.setAttributeConfig("focusmenu", {
+
+ value: (oAttributes.focusmenu === false ? false : true),
+ validator: Lang.isBoolean
+
+ });
+
+ },
+
+
+ /**
+ * @method focus
+ * @description Causes the button to receive the focus and fires the
+ * button's "focus" event.
+ */
+ focus: function () {
+
+ if (!this.get("disabled")) {
+
+ this._button.focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method blur
+ * @description Causes the button to lose focus and fires the button's
+ * "blur" event.
+ */
+ blur: function () {
+
+ if (!this.get("disabled")) {
+
+ this._button.blur();
+
+ }
+
+ },
+
+
+ /**
+ * @method hasFocus
+ * @description Returns a boolean indicating whether or not the button
+ * has focus.
+ * @return {Boolean}
+ */
+ hasFocus: function () {
+
+ return (m_oFocusedButton == this);
+
+ },
+
+
+ /**
+ * @method isActive
+ * @description Returns a boolean indicating whether or not the button
+ * is active.
+ * @return {Boolean}
+ */
+ isActive: function () {
+
+ return this.hasClass(this.CSS_CLASS_NAME + "-active");
+
+ },
+
+
+ /**
+ * @method getMenu
+ * @description Returns a reference to the button's menu.
+ * @return {
+ * YAHOO.widget.Overlay |YAHOO.widget.Menu }
+ */
+ getMenu: function () {
+
+ return this._menu;
+
+ },
+
+
+ /**
+ * @method getForm
+ * @description Returns a reference to the button's parent form.
+ * @return {HTMLFormElement }
+ */
+ getForm: function () {
+
+ return this._button.form;
+
+ },
+
+
+ /**
+ * @method getHiddenFields
+ * @description Returns an <input>
element or
+ * array of form elements used to represent the button when its parent
+ * form is submitted.
+ * @return {HTMLInputElement |Array}
+ */
+ getHiddenFields: function () {
+
+ return this._hiddenFields;
+
+ },
+
+
+ /**
+ * @method destroy
+ * @description Removes the button's element from its parent element and
+ * removes all event handlers.
+ */
+ destroy: function () {
+
+ this.logger.log("Destroying ...");
+
+ var oElement = this.get("element"),
+ oParentNode = oElement.parentNode,
+ oMenu = this._menu;
+
+ if (oMenu) {
+
+ this.logger.log("Destroying menu.");
+
+ oMenu.destroy();
+
+ }
+
+ this.logger.log("Removing DOM event handlers.");
+
+ Event.purgeElement(oElement);
+ Event.purgeElement(this._button);
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+ Event.removeListener(document, "keyup", this._onDocumentKeyUp);
+ Event.removeListener(document, "mousedown",
+ this._onDocumentMouseDown);
+
+
+ var oForm = this.getForm();
+
+ if (oForm) {
+
+ Event.removeListener(oForm, "reset", this._onFormReset);
+ Event.removeListener(oForm, "submit", this.createHiddenFields);
+
+ }
+
+
+ oParentNode.removeChild(oElement);
+
+ this.logger.log("Removing from document.");
+
+ delete m_oButtons[this.get("id")];
+
+ this.logger.log("Destroyed.");
+
+ },
+
+
+ fireEvent: function (p_sType , p_aArgs) {
+
+ // Disabled buttons should not respond to DOM events
+
+ if (this.DOM_EVENTS[p_sType] && this.get("disabled")) {
+
+ return;
+
+ }
+
+ YAHOO.widget.Button.superclass.fireEvent.call(this, p_sType,
+ p_aArgs);
+
+ },
+
+
+ /**
+ * @method toString
+ * @description Returns a string representing the button.
+ * @return {String}
+ */
+ toString: function () {
+
+ return ("Button " + this.get("id"));
+
+ }
+
+ });
+
+
+ /**
+ * @method YAHOO.widget.Button.onFormKeyPress
+ * @description "keypress" event handler for the button's form.
+ * @param {Event} p_oEvent Object representing the DOM event object passed
+ * back by the event utility (YAHOO.util.Event).
+ */
+ YAHOO.widget.Button.onFormKeyPress = function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ nCharCode = Event.getCharCode(p_oEvent),
+ sNodeName = oTarget.nodeName && oTarget.nodeName.toUpperCase(),
+ sType = oTarget.type,
+
+ /*
+ Boolean indicating if the form contains any enabled or
+ disabled YUI submit buttons
+ */
+
+ bFormContainsYUIButtons = false,
+
+ oButton,
+
+ oYUISubmitButton, // The form's first, enabled YUI submit button
+
+ /*
+ The form's first, enabled HTML submit button that precedes any
+ YUI submit button
+ */
+
+ oPrecedingSubmitButton,
+
+
+ /*
+ The form's first, enabled HTML submit button that follows a
+ YUI button
+ */
+
+ oFollowingSubmitButton;
+
+
+ function isSubmitButton(p_oElement) {
+
+ var sId,
+ oSrcElement;
+
+ switch (p_oElement.nodeName.toUpperCase()) {
+
+ case "INPUT":
+ case "BUTTON":
+
+ if (p_oElement.type == "submit" && !p_oElement.disabled) {
+
+ if (!bFormContainsYUIButtons &&
+ !oPrecedingSubmitButton) {
+
+ oPrecedingSubmitButton = p_oElement;
+
+ }
+
+ if (oYUISubmitButton && !oFollowingSubmitButton) {
+
+ oFollowingSubmitButton = p_oElement;
+
+ }
+
+ }
+
+ break;
+
+
+ default:
+
+ sId = p_oElement.id;
+
+ if (sId) {
+
+ oButton = m_oButtons[sId];
+
+ if (oButton) {
+
+ bFormContainsYUIButtons = true;
+
+ if (!oButton.get("disabled")) {
+
+ oSrcElement = oButton.get("srcelement");
+
+ if (!oYUISubmitButton &&
+ (oButton.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit")))
+ {
+
+ oYUISubmitButton = oButton;
+
+ }
+
+ }
+
+ }
+
+ }
+
+ break;
+
+ }
+
+ }
+
+
+ if (nCharCode == 13 && ((sNodeName == "INPUT" && (sType == "text" ||
+ sType == "password" || sType == "checkbox" || sType == "radio" ||
+ sType == "file") ) || sNodeName == "SELECT"))
+ {
+
+ Dom.getElementsBy(isSubmitButton, "*", this);
+
+
+ if (oPrecedingSubmitButton) {
+
+ /*
+ Need to set focus to the first enabled submit button
+ to make sure that IE includes its name and value
+ in the form's data set.
+ */
+
+ oPrecedingSubmitButton.focus();
+
+ }
+ else if (!oPrecedingSubmitButton && oYUISubmitButton) {
+
+ if (oFollowingSubmitButton) {
+
+ /*
+ Need to call "preventDefault" to ensure that
+ the name and value of the regular submit button
+ following the YUI button doesn't get added to the
+ form's data set when it is submitted.
+ */
+
+ Event.preventDefault(p_oEvent);
+
+ }
+
+ oYUISubmitButton.submitForm();
+
+ }
+
+ }
+
+ };
+
+
+ /**
+ * @method addHiddenFieldsToForm
+ * @description Searches the specified form and adds hidden fields for
+ * instances of YAHOO.widget.Button that are of type "radio," "checkbox,"
+ * "menu," and "split."
+ * @param {HTMLFormElement } p_oForm Object reference
+ * for the form to search.
+ */
+ YAHOO.widget.Button.addHiddenFieldsToForm = function (p_oForm) {
+
+ var aButtons = Dom.getElementsByClassName(
+ YAHOO.widget.Button.prototype.CSS_CLASS_NAME,
+ "*",
+ p_oForm),
+
+ nButtons = aButtons.length,
+ oButton,
+ sId,
+ i;
+
+ if (nButtons > 0) {
+
+ YAHOO.log("Form contains " + nButtons + " YUI buttons.");
+
+ for (i = 0; i < nButtons; i++) {
+
+ sId = aButtons[i].id;
+
+ if (sId) {
+
+ oButton = m_oButtons[sId];
+
+ if (oButton) {
+
+ oButton.createHiddenFields();
+
+ }
+
+ }
+
+ }
+
+ }
+
+ };
+
+
+
+ // Events
+
+
+ /**
+ * @event focus
+ * @description Fires when the menu item receives focus. Passes back a
+ * single object representing the original DOM event object passed back by
+ * the event utility (YAHOO.util.Event) when the event was fired. See
+ * Element.addListener
+ * for more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+
+ /**
+ * @event blur
+ * @description Fires when the menu item loses the input focus. Passes back
+ * a single object representing the original DOM event object passed back by
+ * the event utility (YAHOO.util.Event) when the event was fired. See
+ * Element.addListener for
+ * more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+
+ /**
+ * @event option
+ * @description Fires when the user invokes the button's option. Passes
+ * back a single object representing the original DOM event (either
+ * "mousedown" or "keydown") that caused the "option" event to fire. See
+ * Element.addListener
+ * for more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+})();
+(function () {
+
+ // Shorthard for utilities
+
+ var Dom = YAHOO.util.Dom,
+ Event = YAHOO.util.Event,
+ Lang = YAHOO.lang,
+ Button = YAHOO.widget.Button,
+
+ // Private collection of radio buttons
+
+ m_oButtons = {};
+
+
+
+ /**
+ * The ButtonGroup class creates a set of buttons that are mutually
+ * exclusive; checking one button in the set will uncheck all others in the
+ * button group.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <div>
element of the button group.
+ * @param {HTMLDivElement } p_oElement Object
+ * specifying the <div>
element of the button group.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a set
+ * of configuration attributes used to create the button group.
+ * @namespace YAHOO.widget
+ * @class ButtonGroup
+ * @constructor
+ * @extends YAHOO.util.Element
+ */
+ YAHOO.widget.ButtonGroup = function (p_oElement, p_oAttributes) {
+
+ var fnSuperClass = YAHOO.widget.ButtonGroup.superclass.constructor,
+ sNodeName,
+ oElement,
+ sId;
+
+ if (arguments.length == 1 && !Lang.isString(p_oElement) &&
+ !p_oElement.nodeName) {
+
+ if (!p_oElement.id) {
+
+ sId = Dom.generateId();
+
+ p_oElement.id = sId;
+
+ YAHOO.log("No value specified for the button group's \"id\"" +
+ " attribute. Setting button group id to \"" + sId + "\".",
+ "warn");
+
+ }
+
+ this.logger = new YAHOO.widget.LogWriter("ButtonGroup " + sId);
+
+ this.logger.log("No source HTML element. Building the button " +
+ "group using the set of configuration attributes.");
+
+ fnSuperClass.call(this, (this._createGroupElement()), p_oElement);
+
+ }
+ else if (Lang.isString(p_oElement)) {
+
+ oElement = Dom.get(p_oElement);
+
+ if (oElement) {
+
+ if (oElement.nodeName.toUpperCase() == this.NODE_NAME) {
+
+ this.logger =
+ new YAHOO.widget.LogWriter("ButtonGroup " + p_oElement);
+
+ fnSuperClass.call(this, oElement, p_oAttributes);
+
+ }
+
+ }
+
+ }
+ else {
+
+ sNodeName = p_oElement.nodeName;
+
+ if (sNodeName && sNodeName == this.NODE_NAME) {
+
+ if (!p_oElement.id) {
+
+ p_oElement.id = Dom.generateId();
+
+ YAHOO.log("No value specified for the button group's" +
+ " \"id\" attribute. Setting button group id " +
+ "to \"" + p_oElement.id + "\".", "warn");
+
+ }
+
+ this.logger =
+ new YAHOO.widget.LogWriter("ButtonGroup " + p_oElement.id);
+
+ fnSuperClass.call(this, p_oElement, p_oAttributes);
+
+ }
+
+ }
+
+ };
+
+
+ YAHOO.extend(YAHOO.widget.ButtonGroup, YAHOO.util.Element, {
+
+
+ // Protected properties
+
+
+ /**
+ * @property _buttons
+ * @description Array of buttons in the button group.
+ * @default null
+ * @protected
+ * @type Array
+ */
+ _buttons: null,
+
+
+
+ // Constants
+
+
+ /**
+ * @property NODE_NAME
+ * @description The name of the tag to be used for the button
+ * group's element.
+ * @default "DIV"
+ * @final
+ * @type String
+ */
+ NODE_NAME: "DIV",
+
+
+ /**
+ * @property CSS_CLASS_NAME
+ * @description String representing the CSS class(es) to be applied
+ * to the button group's element.
+ * @default "yui-buttongroup"
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yui-buttongroup",
+
+
+
+ // Protected methods
+
+
+ /**
+ * @method _createGroupElement
+ * @description Creates the button group's element.
+ * @protected
+ * @return {HTMLDivElement }
+ */
+ _createGroupElement: function () {
+
+ var oElement = document.createElement(this.NODE_NAME);
+
+ return oElement;
+
+ },
+
+
+
+ // Protected attribute setter methods
+
+
+ /**
+ * @method _setDisabled
+ * @description Sets the value of the button groups's
+ * "disabled" attribute.
+ * @protected
+ * @param {Boolean} p_bDisabled Boolean indicating the value for
+ * the button group's "disabled" attribute.
+ */
+ _setDisabled: function (p_bDisabled) {
+
+ var nButtons = this.getCount(),
+ i;
+
+ if (nButtons > 0) {
+
+ i = nButtons - 1;
+
+ do {
+
+ this._buttons[i].set("disabled", p_bDisabled);
+
+ }
+ while (i--);
+
+ }
+
+ },
+
+
+
+ // Protected event handlers
+
+
+ /**
+ * @method _onKeyDown
+ * @description "keydown" event handler for the button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyDown: function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ nCharCode = Event.getCharCode(p_oEvent),
+ sId = oTarget.parentNode.parentNode.id,
+ oButton = m_oButtons[sId],
+ nIndex = -1;
+
+
+ if (nCharCode == 37 || nCharCode == 38) {
+
+ nIndex = (oButton.index === 0) ?
+ (this._buttons.length - 1) : (oButton.index - 1);
+
+ }
+ else if (nCharCode == 39 || nCharCode == 40) {
+
+ nIndex = (oButton.index === (this._buttons.length - 1)) ?
+ 0 : (oButton.index + 1);
+
+ }
+
+
+ if (nIndex > -1) {
+
+ this.check(nIndex);
+ this.getButton(nIndex).focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method _onAppendTo
+ * @description "appendTo" event handler for the button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the event that was fired.
+ */
+ _onAppendTo: function (p_oEvent) {
+
+ var aButtons = this._buttons,
+ nButtons = aButtons.length,
+ i;
+
+ for (i = 0; i < nButtons; i++) {
+
+ aButtons[i].appendTo(this.get("element"));
+
+ }
+
+ },
+
+
+ /**
+ * @method _onButtonCheckedChange
+ * @description "checkedChange" event handler for each button in the
+ * button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the event that was fired.
+ * @param {YAHOO.widget.Button }
+ * p_oButton Object representing the button that fired the event.
+ */
+ _onButtonCheckedChange: function (p_oEvent, p_oButton) {
+
+ var bChecked = p_oEvent.newValue,
+ oCheckedButton = this.get("checkedButton");
+
+ if (bChecked && oCheckedButton != p_oButton) {
+
+ if (oCheckedButton) {
+
+ oCheckedButton.set("checked", false, true);
+
+ }
+
+ this.set("checkedButton", p_oButton);
+ this.set("value", p_oButton.get("value"));
+
+ }
+ else if (oCheckedButton && !oCheckedButton.set("checked")) {
+
+ oCheckedButton.set("checked", true, true);
+
+ }
+
+ },
+
+
+
+ // Public methods
+
+
+ /**
+ * @method init
+ * @description The ButtonGroup class's initialization method.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <div>
element of the button group.
+ * @param {HTMLDivElement } p_oElement Object
+ * specifying the <div>
element of the button group.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a
+ * set of configuration attributes used to create the button group.
+ */
+ init: function (p_oElement, p_oAttributes) {
+
+ this._buttons = [];
+
+ YAHOO.widget.ButtonGroup.superclass.init.call(this, p_oElement,
+ p_oAttributes);
+
+ this.addClass(this.CSS_CLASS_NAME);
+
+ this.logger.log("Searching for child nodes with the class name " +
+ "\"yui-radio-button\" to add to the button group.");
+
+ var aButtons = this.getElementsByClassName("yui-radio-button");
+
+
+ if (aButtons.length > 0) {
+
+ this.logger.log("Found " + aButtons.length +
+ " child nodes with the class name \"yui-radio-button.\"" +
+ " Attempting to add to button group.");
+
+ this.addButtons(aButtons);
+
+ }
+
+
+ this.logger.log("Searching for child nodes with the type of " +
+ " \"radio\" to add to the button group.");
+
+ function isRadioButton(p_oElement) {
+
+ return (p_oElement.type == "radio");
+
+ }
+
+ aButtons =
+ Dom.getElementsBy(isRadioButton, "input", this.get("element"));
+
+
+ if (aButtons.length > 0) {
+
+ this.logger.log("Found " + aButtons.length + " child nodes" +
+ " with the type of \"radio.\" Attempting to add to" +
+ " button group.");
+
+ this.addButtons(aButtons);
+
+ }
+
+ this.on("keydown", this._onKeyDown);
+ this.on("appendTo", this._onAppendTo);
+
+
+ var oContainer = this.get("container");
+
+ if (oContainer) {
+
+ if (Lang.isString(oContainer)) {
+
+ Event.onContentReady(oContainer, function () {
+
+ this.appendTo(oContainer);
+
+ }, null, this);
+
+ }
+ else {
+
+ this.appendTo(oContainer);
+
+ }
+
+ }
+
+
+ this.logger.log("Initialization completed.");
+
+ },
+
+
+ /**
+ * @method initAttributes
+ * @description Initializes all of the configuration attributes used to
+ * create the button group.
+ * @param {Object} p_oAttributes Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ */
+ initAttributes: function (p_oAttributes) {
+
+ var oAttributes = p_oAttributes || {};
+
+ YAHOO.widget.ButtonGroup.superclass.initAttributes.call(
+ this, oAttributes);
+
+
+ /**
+ * @config name
+ * @description String specifying the name for the button group.
+ * This name will be applied to each button in the button group.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("name", {
+
+ value: oAttributes.name,
+ validator: Lang.isString
+
+ });
+
+
+ /**
+ * @config disabled
+ * @description Boolean indicating if the button group should be
+ * disabled. Disabling the button group will disable each button
+ * in the button group. Disabled buttons are dimmed and will not
+ * respond to user input or fire events.
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("disabled", {
+
+ value: (oAttributes.disabled || false),
+ validator: Lang.isBoolean,
+ method: this._setDisabled
+
+ });
+
+
+ /**
+ * @config value
+ * @description Object specifying the value for the button group.
+ * @default null
+ * @type Object
+ */
+ this.setAttributeConfig("value", {
+
+ value: oAttributes.value
+
+ });
+
+
+ /**
+ * @config container
+ * @description HTML element reference or string specifying the id
+ * attribute of the HTML element that the button group's markup
+ * should be rendered into.
+ * @type HTMLElement |String
+ * @default null
+ */
+ this.setAttributeConfig("container", {
+
+ value: oAttributes.container,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config checkedButton
+ * @description Reference for the button in the button group that
+ * is checked.
+ * @type {YAHOO.widget.Button }
+ * @default null
+ */
+ this.setAttributeConfig("checkedButton", {
+
+ value: null
+
+ });
+
+ },
+
+
+ /**
+ * @method addButton
+ * @description Adds the button to the button group.
+ * @param {YAHOO.widget.Button }
+ * p_oButton Object reference for the
+ * YAHOO.widget.Button instance to be added to the button group.
+ * @param {String} p_oButton String specifying the id attribute of the
+ * <input>
or <span>
element
+ * to be used to create the button to be added to the button group.
+ * @param {HTMLInputElement |HTMLElement } p_oButton Object reference for the
+ * <input>
or <span>
element
+ * to be used to create the button to be added to the button group.
+ * @param {Object} p_oButton Object literal specifying a set of
+ * YAHOO.widget.Button
+ * configuration attributes used to configure the button to be added to
+ * the button group.
+ * @return {YAHOO.widget.Button }
+ */
+ addButton: function (p_oButton) {
+
+ var oButton,
+ oButtonElement,
+ oGroupElement,
+ nIndex,
+ sButtonName,
+ sGroupName;
+
+
+ if (p_oButton instanceof Button &&
+ p_oButton.get("type") == "radio") {
+
+ oButton = p_oButton;
+
+ }
+ else if (!Lang.isString(p_oButton) && !p_oButton.nodeName) {
+
+ p_oButton.type = "radio";
+
+ oButton = new Button(p_oButton);
+
+ }
+ else {
+
+ oButton = new Button(p_oButton, { type: "radio" });
+
+ }
+
+
+ if (oButton) {
+
+ nIndex = this._buttons.length;
+ sButtonName = oButton.get("name");
+ sGroupName = this.get("name");
+
+ oButton.index = nIndex;
+
+ this._buttons[nIndex] = oButton;
+ m_oButtons[oButton.get("id")] = oButton;
+
+
+ if (sButtonName != sGroupName) {
+
+ oButton.set("name", sGroupName);
+
+ }
+
+
+ if (this.get("disabled")) {
+
+ oButton.set("disabled", true);
+
+ }
+
+
+ if (oButton.get("checked")) {
+
+ this.set("checkedButton", oButton);
+
+ }
+
+
+ oButtonElement = oButton.get("element");
+ oGroupElement = this.get("element");
+
+ if (oButtonElement.parentNode != oGroupElement) {
+
+ oGroupElement.appendChild(oButtonElement);
+
+ }
+
+
+ oButton.on("checkedChange",
+ this._onButtonCheckedChange, oButton, this);
+
+ this.logger.log("Button " + oButton.get("id") + " added.");
+
+ return oButton;
+
+ }
+
+ },
+
+
+ /**
+ * @method addButtons
+ * @description Adds the array of buttons to the button group.
+ * @param {Array} p_aButtons Array of
+ * YAHOO.widget.Button instances to be added
+ * to the button group.
+ * @param {Array} p_aButtons Array of strings specifying the id
+ * attribute of the <input>
or <span>
+ *
elements to be used to create the buttons to be added to the
+ * button group.
+ * @param {Array} p_aButtons Array of object references for the
+ * <input>
or <span>
elements
+ * to be used to create the buttons to be added to the button group.
+ * @param {Array} p_aButtons Array of object literals, each containing
+ * a set of YAHOO.widget.Button
+ * configuration attributes used to configure each button to be added
+ * to the button group.
+ * @return {Array}
+ */
+ addButtons: function (p_aButtons) {
+
+ var nButtons,
+ oButton,
+ aButtons,
+ i;
+
+ if (Lang.isArray(p_aButtons)) {
+
+ nButtons = p_aButtons.length;
+ aButtons = [];
+
+ if (nButtons > 0) {
+
+ for (i = 0; i < nButtons; i++) {
+
+ oButton = this.addButton(p_aButtons[i]);
+
+ if (oButton) {
+
+ aButtons[aButtons.length] = oButton;
+
+ }
+
+ }
+
+ if (aButtons.length > 0) {
+
+ this.logger.log(aButtons.length + " buttons added.");
+
+ return aButtons;
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method removeButton
+ * @description Removes the button at the specified index from the
+ * button group.
+ * @param {Number} p_nIndex Number specifying the index of the button
+ * to be removed from the button group.
+ */
+ removeButton: function (p_nIndex) {
+
+ var oButton = this.getButton(p_nIndex),
+ nButtons,
+ i;
+
+ if (oButton) {
+
+ this.logger.log("Removing button " + oButton.get("id") + ".");
+
+ this._buttons.splice(p_nIndex, 1);
+ delete m_oButtons[oButton.get("id")];
+
+ oButton.removeListener("checkedChange",
+ this._onButtonCheckedChange);
+
+ oButton.destroy();
+
+
+ nButtons = this._buttons.length;
+
+ if (nButtons > 0) {
+
+ i = this._buttons.length - 1;
+
+ do {
+
+ this._buttons[i].index = i;
+
+ }
+ while (i--);
+
+ }
+
+ this.logger.log("Button " + oButton.get("id") + " removed.");
+
+ }
+
+ },
+
+
+ /**
+ * @method getButton
+ * @description Returns the button at the specified index.
+ * @param {Number} p_nIndex The index of the button to retrieve from the
+ * button group.
+ * @return {YAHOO.widget.Button }
+ */
+ getButton: function (p_nIndex) {
+
+ if (Lang.isNumber(p_nIndex)) {
+
+ return this._buttons[p_nIndex];
+
+ }
+
+ },
+
+
+ /**
+ * @method getButtons
+ * @description Returns an array of the buttons in the button group.
+ * @return {Array}
+ */
+ getButtons: function () {
+
+ return this._buttons;
+
+ },
+
+
+ /**
+ * @method getCount
+ * @description Returns the number of buttons in the button group.
+ * @return {Number}
+ */
+ getCount: function () {
+
+ return this._buttons.length;
+
+ },
+
+
+ /**
+ * @method focus
+ * @description Sets focus to the button at the specified index.
+ * @param {Number} p_nIndex Number indicating the index of the button
+ * to focus.
+ */
+ focus: function (p_nIndex) {
+
+ var oButton,
+ nButtons,
+ i;
+
+ if (Lang.isNumber(p_nIndex)) {
+
+ oButton = this._buttons[p_nIndex];
+
+ if (oButton) {
+
+ oButton.focus();
+
+ }
+
+ }
+ else {
+
+ nButtons = this.getCount();
+
+ for (i = 0; i < nButtons; i++) {
+
+ oButton = this._buttons[i];
+
+ if (!oButton.get("disabled")) {
+
+ oButton.focus();
+ break;
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method check
+ * @description Checks the button at the specified index.
+ * @param {Number} p_nIndex Number indicating the index of the button
+ * to check.
+ */
+ check: function (p_nIndex) {
+
+ var oButton = this.getButton(p_nIndex);
+
+ if (oButton) {
+
+ oButton.set("checked", true);
+
+ }
+
+ },
+
+
+ /**
+ * @method destroy
+ * @description Removes the button group's element from its parent
+ * element and removes all event handlers.
+ */
+ destroy: function () {
+
+ this.logger.log("Destroying...");
+
+ var nButtons = this._buttons.length,
+ oElement = this.get("element"),
+ oParentNode = oElement.parentNode,
+ i;
+
+ if (nButtons > 0) {
+
+ i = this._buttons.length - 1;
+
+ do {
+
+ this._buttons[i].destroy();
+
+ }
+ while (i--);
+
+ }
+
+ this.logger.log("Removing DOM event handlers.");
+
+ Event.purgeElement(oElement);
+
+ this.logger.log("Removing from document.");
+
+ oParentNode.removeChild(oElement);
+
+ },
+
+
+ /**
+ * @method toString
+ * @description Returns a string representing the button group.
+ * @return {String}
+ */
+ toString: function () {
+
+ return ("ButtonGroup " + this.get("id"));
+
+ }
+
+ });
+
+})();
+YAHOO.register("button", YAHOO.widget.Button, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/button/button-beta-min.js b/lib/yui/button/button-beta-min.js
new file mode 100755
index 0000000000..be19b02b34
--- /dev/null
+++ b/lib/yui/button/button-beta-min.js
@@ -0,0 +1,162 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+
+(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,Overlay=YAHOO.widget.Overlay,Menu=YAHOO.widget.Menu,m_oButtons={},m_oOverlayManager=null,m_oSubmitTrigger=null,m_oFocusedButton=null;function createInputElement(p_sType,p_sName,p_sValue,p_bChecked){var oInput,sInput;if(Lang.isString(p_sType)&&Lang.isString(p_sName)){if(YAHOO.env.ua.ie){sInput=" ";oInput=document.createElement(sInput);}
+else{oInput=document.createElement("input");oInput.name=p_sName;oInput.type=p_sType;if(p_bChecked){oInput.checked=true;}}
+oInput.value=p_sValue;return oInput;}}
+function setAttributesFromSrcElement(p_oElement,p_oAttributes){var sSrcElementNodeName=p_oElement.nodeName.toUpperCase(),me=this,oAttribute,oRootNode,sText;function setAttributeFromDOMAttribute(p_sAttribute){if(!(p_sAttribute in p_oAttributes)){oAttribute=p_oElement.getAttributeNode(p_sAttribute);if(oAttribute&&("value"in oAttribute)){p_oAttributes[p_sAttribute]=oAttribute.value;}}}
+function setFormElementProperties(){setAttributeFromDOMAttribute("type");if(p_oAttributes.type=="button"){p_oAttributes.type="push";}
+if(!("disabled"in p_oAttributes)){p_oAttributes.disabled=p_oElement.disabled;}
+setAttributeFromDOMAttribute("name");setAttributeFromDOMAttribute("value");setAttributeFromDOMAttribute("title");}
+switch(sSrcElementNodeName){case"A":p_oAttributes.type="link";setAttributeFromDOMAttribute("href");setAttributeFromDOMAttribute("target");break;case"INPUT":setFormElementProperties();if(!("checked"in p_oAttributes)){p_oAttributes.checked=p_oElement.checked;}
+break;case"BUTTON":setFormElementProperties();oRootNode=p_oElement.parentNode.parentNode;if(Dom.hasClass(oRootNode,this.CSS_CLASS_NAME+"-checked")){p_oAttributes.checked=true;}
+if(Dom.hasClass(oRootNode,this.CSS_CLASS_NAME+"-disabled")){p_oAttributes.disabled=true;}
+p_oElement.removeAttribute("value");p_oElement.setAttribute("type","button");break;}
+p_oElement.removeAttribute("id");p_oElement.removeAttribute("name");if(!("tabindex"in p_oAttributes)){p_oAttributes.tabindex=p_oElement.tabIndex;}
+if(!("label"in p_oAttributes)){sText=sSrcElementNodeName=="INPUT"?p_oElement.value:p_oElement.innerHTML;if(sText&&sText.length>0){p_oAttributes.label=sText;}}}
+function initConfig(p_oConfig){var oAttributes=p_oConfig.attributes,oSrcElement=oAttributes.srcelement,sSrcElementNodeName=oSrcElement.nodeName.toUpperCase(),me=this;if(sSrcElementNodeName==this.NODE_NAME){p_oConfig.element=oSrcElement;p_oConfig.id=oSrcElement.id;Dom.getElementsBy(function(p_oElement){switch(p_oElement.nodeName.toUpperCase()){case"BUTTON":case"A":case"INPUT":setAttributesFromSrcElement.call(me,p_oElement,oAttributes);break;}},"*",oSrcElement);}
+else{switch(sSrcElementNodeName){case"BUTTON":case"A":case"INPUT":setAttributesFromSrcElement.call(this,oSrcElement,oAttributes);break;}}}
+YAHOO.widget.Button=function(p_oElement,p_oAttributes){var fnSuperClass=YAHOO.widget.Button.superclass.constructor,oConfig,oElement;if(arguments.length==1&&!Lang.isString(p_oElement)&&!p_oElement.nodeName){if(!p_oElement.id){p_oElement.id=Dom.generateId();}
+fnSuperClass.call(this,(this.createButtonElement(p_oElement.type)),p_oElement);}
+else{oConfig={element:null,attributes:(p_oAttributes||{})};if(Lang.isString(p_oElement)){oElement=Dom.get(p_oElement);if(oElement){if(!oConfig.attributes.id){oConfig.attributes.id=p_oElement;}
+oConfig.attributes.srcelement=oElement;initConfig.call(this,oConfig);if(!oConfig.element){oConfig.element=this.createButtonElement(oConfig.attributes.type);}
+fnSuperClass.call(this,oConfig.element,oConfig.attributes);}}
+else if(p_oElement.nodeName){if(!oConfig.attributes.id){if(p_oElement.id){oConfig.attributes.id=p_oElement.id;}
+else{oConfig.attributes.id=Dom.generateId();}}
+oConfig.attributes.srcelement=p_oElement;initConfig.call(this,oConfig);if(!oConfig.element){oConfig.element=this.createButtonElement(oConfig.attributes.type);}
+fnSuperClass.call(this,oConfig.element,oConfig.attributes);}}};YAHOO.extend(YAHOO.widget.Button,YAHOO.util.Element,{_button:null,_menu:null,_hiddenFields:null,_onclickAttributeValue:null,_activationKeyPressed:false,_activationButtonPressed:false,_hasKeyEventHandlers:false,_hasMouseEventHandlers:false,NODE_NAME:"SPAN",CHECK_ACTIVATION_KEYS:[32],ACTIVATION_KEYS:[13,32],OPTION_AREA_WIDTH:20,CSS_CLASS_NAME:"yui-button",RADIO_DEFAULT_TITLE:"Unchecked. Click to check.",RADIO_CHECKED_TITLE:"Checked. Click to uncheck.",CHECKBOX_DEFAULT_TITLE:"Unchecked. Click to check.",CHECKBOX_CHECKED_TITLE:"Checked. Click to uncheck.",MENUBUTTON_DEFAULT_TITLE:"Menu collapsed. Click to expand.",MENUBUTTON_MENU_VISIBLE_TITLE:"Menu expanded. Click or press Esc to collapse.",SPLITBUTTON_DEFAULT_TITLE:("Menu collapsed. Click inside option "+"region or press Ctrl + Shift + M to show the menu."),SPLITBUTTON_OPTION_VISIBLE_TITLE:"Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.",SUBMIT_TITLE:"Click to submit form.",_setType:function(p_sType){if(p_sType=="split"){this.on("option",this._onOption);}},_setLabel:function(p_sLabel){this._button.innerHTML=p_sLabel;},_setTabIndex:function(p_nTabIndex){this._button.tabIndex=p_nTabIndex;},_setTitle:function(p_sTitle){var sTitle=p_sTitle;if(this.get("type")!="link"){if(!sTitle){switch(this.get("type")){case"radio":sTitle=this.RADIO_DEFAULT_TITLE;break;case"checkbox":sTitle=this.CHECKBOX_DEFAULT_TITLE;break;case"menu":sTitle=this.MENUBUTTON_DEFAULT_TITLE;break;case"split":sTitle=this.SPLITBUTTON_DEFAULT_TITLE;break;case"submit":sTitle=this.SUBMIT_TITLE;break;}}
+this._button.title=sTitle;}},_setDisabled:function(p_bDisabled){if(this.get("type")!="link"){if(p_bDisabled){if(this._menu){this._menu.hide();}
+if(this.hasFocus()){this.blur();}
+this._button.setAttribute("disabled","disabled");this.addStateCSSClasses("disabled");}
+else{this._button.removeAttribute("disabled");this.removeStateCSSClasses("disabled");}}},_setHref:function(p_sHref){if(this.get("type")=="link"){this._button.href=p_sHref;}},_setTarget:function(p_sTarget){if(this.get("type")=="link"){this._button.setAttribute("target",p_sTarget);}},_setChecked:function(p_bChecked){var sType=this.get("type"),sTitle;if(sType=="checkbox"||sType=="radio"){if(p_bChecked){this.addStateCSSClasses("checked");sTitle=(sType=="radio")?this.RADIO_CHECKED_TITLE:this.CHECKBOX_CHECKED_TITLE;}
+else{this.removeStateCSSClasses("checked");sTitle=(sType=="radio")?this.RADIO_DEFAULT_TITLE:this.CHECKBOX_DEFAULT_TITLE;}
+this.set("title",sTitle);}},_setMenu:function(p_oMenu){var bLazyLoad=this.get("lazyloadmenu"),oButtonElement=this.get("element"),bInstance=false,oMenu,oMenuElement,oSrcElement,aItems,nItems,oItem,i;if(!Overlay){return false;}
+if(!Menu){return false;}
+function onAppendTo(){oMenu.render(oButtonElement.parentNode);this.removeListener("appendTo",onAppendTo);}
+function initMenu(){if(oMenu){Dom.addClass(oMenu.element,this.get("menuclassname"));Dom.addClass(oMenu.element,"yui-"+this.get("type")+"-button-menu");oMenu.showEvent.subscribe(this._onMenuShow,null,this);oMenu.hideEvent.subscribe(this._onMenuHide,null,this);oMenu.renderEvent.subscribe(this._onMenuRender,null,this);if(oMenu instanceof Menu){oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,this,true);oMenu.clickEvent.subscribe(this._onMenuClick,this,true);oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,this,true);oSrcElement=oMenu.srcElement;if(oSrcElement&&oSrcElement.nodeName.toUpperCase()=="SELECT"){oSrcElement.style.display="none";oSrcElement.parentNode.removeChild(oSrcElement);}}
+else if(oMenu instanceof Overlay){if(!m_oOverlayManager){m_oOverlayManager=new YAHOO.widget.OverlayManager();}
+m_oOverlayManager.register(oMenu);}
+this._menu=oMenu;if(!bInstance){if(bLazyLoad&&!(oMenu instanceof Menu)){oMenu.beforeShowEvent.subscribe(this._onOverlayBeforeShow,null,this);}
+else if(!bLazyLoad){if(Dom.inDocument(oButtonElement)){oMenu.render(oButtonElement.parentNode);}
+else{this.on("appendTo",onAppendTo);}}}}}
+if(p_oMenu&&(p_oMenu instanceof Menu)){oMenu=p_oMenu;aItems=oMenu.getItems();nItems=aItems.length;bInstance=true;if(nItems>0){i=nItems-1;do{oItem=aItems[i];if(oItem){oItem.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,oItem,this);}}
+while(i--);}
+initMenu.call(this);}
+else if(p_oMenu&&(p_oMenu instanceof Overlay)){oMenu=p_oMenu;bInstance=true;oMenu.cfg.setProperty("visible",false);oMenu.cfg.setProperty("context",[oButtonElement,"tl","bl"]);initMenu.call(this);}
+else if(Lang.isArray(p_oMenu)){this.on("appendTo",function(){oMenu=new Menu(Dom.generateId(),{lazyload:bLazyLoad,itemdata:p_oMenu});initMenu.call(this);});}
+else if(Lang.isString(p_oMenu)){oMenuElement=Dom.get(p_oMenu);if(oMenuElement){if(Dom.hasClass(oMenuElement,Menu.prototype.CSS_CLASS_NAME)||oMenuElement.nodeName=="SELECT"){oMenu=new Menu(p_oMenu,{lazyload:bLazyLoad});initMenu.call(this);}
+else{oMenu=new Overlay(p_oMenu,{visible:false,context:[oButtonElement,"tl","bl"]});initMenu.call(this);}}}
+else if(p_oMenu&&p_oMenu.nodeName){if(Dom.hasClass(p_oMenu,Menu.prototype.CSS_CLASS_NAME)||p_oMenu.nodeName=="SELECT"){oMenu=new Menu(p_oMenu,{lazyload:bLazyLoad});initMenu.call(this);}
+else{if(!p_oMenu.id){Dom.generateId(p_oMenu);}
+oMenu=new Overlay(p_oMenu,{visible:false,context:[oButtonElement,"tl","bl"]});initMenu.call(this);}}},_setOnClick:function(p_oObject){if(this._onclickAttributeValue&&(this._onclickAttributeValue!=p_oObject)){this.removeListener("click",this._onclickAttributeValue.fn);this._onclickAttributeValue=null;}
+if(!this._onclickAttributeValue&&Lang.isObject(p_oObject)&&Lang.isFunction(p_oObject.fn)){this.on("click",p_oObject.fn,p_oObject.obj,p_oObject.scope);this._onclickAttributeValue=p_oObject;}},_setSelectedMenuItem:function(p_nIndex){var oMenu=this._menu,oMenuItem;if(oMenu&&oMenu instanceof Menu){oMenuItem=oMenu.getItem(p_nIndex);if(oMenuItem&&!oMenuItem.cfg.getProperty("selected")){oMenuItem.cfg.setProperty("selected",true);}}},_isActivationKey:function(p_nKeyCode){var sType=this.get("type"),aKeyCodes=(sType=="checkbox"||sType=="radio")?this.CHECK_ACTIVATION_KEYS:this.ACTIVATION_KEYS,nKeyCodes=aKeyCodes.length,i;if(nKeyCodes>0){i=nKeyCodes-1;do{if(p_nKeyCode==aKeyCodes[i]){return true;}}
+while(i--);}},_isSplitButtonOptionKey:function(p_oEvent){return(p_oEvent.ctrlKey&&p_oEvent.shiftKey&&Event.getCharCode(p_oEvent)==77);},_addListenersToForm:function(){var oForm=this.getForm(),oSrcElement,aListeners,nListeners,i,bHasKeyPressListener;if(oForm){Event.on(oForm,"reset",this._onFormReset,null,this);Event.on(oForm,"submit",this.createHiddenFields,null,this);oSrcElement=this.get("srcelement");if(this.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit"))
+{aListeners=Event.getListeners(oForm,"keypress");bHasKeyPressListener=false;if(aListeners){nListeners=aListeners.length;if(nListeners>0){i=nListeners-1;do{if(aListeners[i].fn==YAHOO.widget.Button.onFormKeyPress)
+{bHasKeyPressListener=true;break;}}
+while(i--);}}
+if(!bHasKeyPressListener){Event.on(oForm,"keypress",YAHOO.widget.Button.onFormKeyPress);}}}},_originalMaxHeight:-1,_showMenu:function(p_oEvent){YAHOO.widget.MenuManager.hideVisible();if(m_oOverlayManager){m_oOverlayManager.hideAll();}
+var oMenu=this._menu,nViewportHeight=Dom.getViewportHeight(),nMenuHeight,nScrollTop,nY;if(oMenu&&(oMenu instanceof Menu)){oMenu.cfg.applyConfig({context:[this.get("id"),"tl","bl"],constraintoviewport:false,clicktohide:false,visible:true});oMenu.cfg.fireQueue();oMenu.align("tl","bl");if(p_oEvent.type=="mousedown"){Event.stopPropagation(p_oEvent);}
+if(this.get("focusmenu")){this._menu.focus();}
+nMenuHeight=oMenu.element.offsetHeight;if((oMenu.cfg.getProperty("y")+nMenuHeight)>nViewportHeight){oMenu.align("bl","tl");nY=oMenu.cfg.getProperty("y");nScrollTop=Dom.getDocumentScrollTop();if(nScrollTop>=nY){if(this._originalMaxHeight==-1){this._originalMaxHeight=oMenu.cfg.getProperty("maxheight");}
+oMenu.cfg.setProperty("maxheight",(nMenuHeight-((nScrollTop-nY)+20)));oMenu.align("bl","tl");}}}
+else if(oMenu&&(oMenu instanceof Overlay)){oMenu.show();oMenu.align("tl","bl");nMenuHeight=oMenu.element.offsetHeight;if((oMenu.cfg.getProperty("y")+nMenuHeight)>nViewportHeight){oMenu.align("bl","tl");}}},_hideMenu:function(){var oMenu=this._menu;if(oMenu){oMenu.hide();}},_onMouseOver:function(p_oEvent){if(!this._hasMouseEventHandlers){this.on("mouseout",this._onMouseOut);this.on("mousedown",this._onMouseDown);this.on("mouseup",this._onMouseUp);this._hasMouseEventHandlers=true;}
+this.addStateCSSClasses("hover");if(this._activationButtonPressed){this.addStateCSSClasses("active");}
+if(this._bOptionPressed){this.addStateCSSClasses("activeoption");}},_onMouseOut:function(p_oEvent){this.removeStateCSSClasses("hover");if(this.get("type")!="menu"){this.removeStateCSSClasses("active");}
+if(this._activationButtonPressed||this._bOptionPressed){Event.on(document,"mouseup",this._onDocumentMouseUp,null,this);}},_onDocumentMouseUp:function(p_oEvent){this._activationButtonPressed=false;this._bOptionPressed=false;var sType=this.get("type");if(sType=="menu"||sType=="split"){this.removeStateCSSClasses((sType=="menu"?"active":"activeoption"));this._hideMenu();}
+Event.removeListener(document,"mouseup",this._onDocumentMouseUp);},_onMouseDown:function(p_oEvent){var sType,oElement,nX,me;function onMouseUp(){this._hideMenu();this.removeListener("mouseup",onMouseUp);}
+if((p_oEvent.which||p_oEvent.button)==1){if(!this.hasFocus()){this.focus();}
+sType=this.get("type");if(sType=="split"){oElement=this.get("element");nX=Event.getPageX(p_oEvent)-Dom.getX(oElement);if((oElement.offsetWidth-this.OPTION_AREA_WIDTH)"+
+(p_sType=="link"?" ":" ")+""+sNodeName+">";return oElement;},addStateCSSClasses:function(p_sState){var sType=this.get("type");if(Lang.isString(p_sState)){if(p_sState!="activeoption"){this.addClass(this.CSS_CLASS_NAME+("-"+p_sState));}
+this.addClass("yui-"+sType+("-button-"+p_sState));}},removeStateCSSClasses:function(p_sState){var sType=this.get("type");if(Lang.isString(p_sState)){this.removeClass(this.CSS_CLASS_NAME+("-"+p_sState));this.removeClass("yui-"+sType+("-button-"+p_sState));}},createHiddenFields:function(){this.removeHiddenFields();var oForm=this.getForm(),oButtonField,sType,bCheckable,oMenu,oMenuItem,sName,oValue,oMenuField;if(oForm&&!this.get("disabled")){sType=this.get("type");bCheckable=(sType=="checkbox"||sType=="radio");if(bCheckable||(m_oSubmitTrigger==this)){oButtonField=createInputElement((bCheckable?sType:"hidden"),this.get("name"),this.get("value"),this.get("checked"));if(oButtonField){if(bCheckable){oButtonField.style.display="none";}
+oForm.appendChild(oButtonField);}}
+oMenu=this._menu;if(oMenu&&(oMenu instanceof Menu)){oMenuField=oMenu.srcElement;oMenuItem=oMenu.getItem(this.get("selectedMenuItem"));if(oMenuField&&oMenuField.nodeName.toUpperCase()=="SELECT"){oForm.appendChild(oMenuField);oMenuField.selectedIndex=oMenuItem.index;}
+else{oValue=(oMenuItem.value===null||oMenuItem.value==="")?oMenuItem.cfg.getProperty("text"):oMenuItem.value;sName=this.get("name");if(oValue&&sName){oMenuField=createInputElement("hidden",(sName+"_options"),oValue);oForm.appendChild(oMenuField);}}}
+if(oButtonField&&oMenuField){this._hiddenFields=[oButtonField,oMenuField];}
+else if(!oButtonField&&oMenuField){this._hiddenFields=oMenuField;}
+else if(oButtonField&&!oMenuField){this._hiddenFields=oButtonField;}
+return this._hiddenFields;}},removeHiddenFields:function(){var oField=this._hiddenFields,nFields,i;function removeChild(p_oElement){if(Dom.inDocument(p_oElement)){p_oElement.parentNode.removeChild(p_oElement);}}
+if(oField){if(Lang.isArray(oField)){nFields=oField.length;if(nFields>0){i=nFields-1;do{removeChild(oField[i]);}
+while(i--);}}
+else{removeChild(oField);}
+this._hiddenFields=null;}},submitForm:function(){var oForm=this.getForm(),oSrcElement=this.get("srcelement"),bSubmitForm=false,oEvent;if(oForm){if(this.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit"))
+{m_oSubmitTrigger=this;}
+if(YAHOO.env.ua.ie){bSubmitForm=oForm.fireEvent("onsubmit");}
+else{oEvent=document.createEvent("HTMLEvents");oEvent.initEvent("submit",true,true);bSubmitForm=oForm.dispatchEvent(oEvent);}
+if((YAHOO.env.ua.ie||YAHOO.env.ua.webkit)&&bSubmitForm){oForm.submit();}}
+return bSubmitForm;},init:function(p_oElement,p_oAttributes){var sNodeName=p_oAttributes.type=="link"?"A":"BUTTON",oSrcElement=p_oAttributes.srcelement,oButton=p_oElement.getElementsByTagName(sNodeName)[0],oInput;if(!oButton){oInput=p_oElement.getElementsByTagName("INPUT")[0];if(oInput){oButton=document.createElement("BUTTON");oButton.setAttribute("type","button");oInput.parentNode.replaceChild(oButton,oInput);}}
+this._button=oButton;YAHOO.widget.Button.superclass.init.call(this,p_oElement,p_oAttributes);m_oButtons[this.get("id")]=this;this.addClass(this.CSS_CLASS_NAME);this.addClass("yui-"+this.get("type")+"-button");Event.on(this._button,"focus",this._onFocus,null,this);this.on("mouseover",this._onMouseOver);this.on("click",this._onClick);this.on("appendTo",this._onAppendTo);var oContainer=this.get("container"),oElement=this.get("element"),bElInDoc=Dom.inDocument(oElement),oParentNode;if(oContainer){if(oSrcElement&&oSrcElement!=oElement){oParentNode=oSrcElement.parentNode;if(oParentNode){oParentNode.removeChild(oSrcElement);}}
+if(Lang.isString(oContainer)){Event.onContentReady(oContainer,function(){this.appendTo(oContainer);},null,this);}
+else{this.appendTo(oContainer);}}
+else if(!bElInDoc&&oSrcElement&&oSrcElement!=oElement){oParentNode=oSrcElement.parentNode;if(oParentNode){this.fireEvent("beforeAppendTo",{type:"beforeAppendTo",target:oParentNode});oParentNode.replaceChild(oElement,oSrcElement);this.fireEvent("appendTo",{type:"appendTo",target:oParentNode});}}
+else if(this.get("type")!="link"&&bElInDoc&&oSrcElement&&oSrcElement==oElement){this._addListenersToForm();}},initAttributes:function(p_oAttributes){var oAttributes=p_oAttributes||{};YAHOO.widget.Button.superclass.initAttributes.call(this,oAttributes);this.setAttributeConfig("type",{value:(oAttributes.type||"push"),validator:Lang.isString,writeOnce:true,method:this._setType});this.setAttributeConfig("label",{value:oAttributes.label,validator:Lang.isString,method:this._setLabel});this.setAttributeConfig("value",{value:oAttributes.value});this.setAttributeConfig("name",{value:oAttributes.name,validator:Lang.isString});this.setAttributeConfig("tabindex",{value:oAttributes.tabindex,validator:Lang.isNumber,method:this._setTabIndex});this.configureAttribute("title",{value:oAttributes.title,validator:Lang.isString,method:this._setTitle});this.setAttributeConfig("disabled",{value:(oAttributes.disabled||false),validator:Lang.isBoolean,method:this._setDisabled});this.setAttributeConfig("href",{value:oAttributes.href,validator:Lang.isString,method:this._setHref});this.setAttributeConfig("target",{value:oAttributes.target,validator:Lang.isString,method:this._setTarget});this.setAttributeConfig("checked",{value:(oAttributes.checked||false),validator:Lang.isBoolean,method:this._setChecked});this.setAttributeConfig("container",{value:oAttributes.container,writeOnce:true});this.setAttributeConfig("srcelement",{value:oAttributes.srcelement,writeOnce:true});this.setAttributeConfig("menu",{value:null,method:this._setMenu,writeOnce:true});this.setAttributeConfig("lazyloadmenu",{value:(oAttributes.lazyloadmenu===false?false:true),validator:Lang.isBoolean,writeOnce:true});this.setAttributeConfig("menuclassname",{value:(oAttributes.menuclassname||"yui-button-menu"),validator:Lang.isString,method:this._setMenuClassName,writeOnce:true});this.setAttributeConfig("selectedMenuItem",{value:0,validator:Lang.isNumber,method:this._setSelectedMenuItem});this.setAttributeConfig("onclick",{value:oAttributes.onclick,method:this._setOnClick});this.setAttributeConfig("focusmenu",{value:(oAttributes.focusmenu===false?false:true),validator:Lang.isBoolean});},focus:function(){if(!this.get("disabled")){this._button.focus();}},blur:function(){if(!this.get("disabled")){this._button.blur();}},hasFocus:function(){return(m_oFocusedButton==this);},isActive:function(){return this.hasClass(this.CSS_CLASS_NAME+"-active");},getMenu:function(){return this._menu;},getForm:function(){return this._button.form;},getHiddenFields:function(){return this._hiddenFields;},destroy:function(){var oElement=this.get("element"),oParentNode=oElement.parentNode,oMenu=this._menu;if(oMenu){oMenu.destroy();}
+Event.purgeElement(oElement);Event.purgeElement(this._button);Event.removeListener(document,"mouseup",this._onDocumentMouseUp);Event.removeListener(document,"keyup",this._onDocumentKeyUp);Event.removeListener(document,"mousedown",this._onDocumentMouseDown);var oForm=this.getForm();if(oForm){Event.removeListener(oForm,"reset",this._onFormReset);Event.removeListener(oForm,"submit",this.createHiddenFields);}
+oParentNode.removeChild(oElement);delete m_oButtons[this.get("id")];},fireEvent:function(p_sType,p_aArgs){if(this.DOM_EVENTS[p_sType]&&this.get("disabled")){return;}
+YAHOO.widget.Button.superclass.fireEvent.call(this,p_sType,p_aArgs);},toString:function(){return("Button "+this.get("id"));}});YAHOO.widget.Button.onFormKeyPress=function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),nCharCode=Event.getCharCode(p_oEvent),sNodeName=oTarget.nodeName&&oTarget.nodeName.toUpperCase(),sType=oTarget.type,bFormContainsYUIButtons=false,oButton,oYUISubmitButton,oPrecedingSubmitButton,oFollowingSubmitButton;function isSubmitButton(p_oElement){var sId,oSrcElement;switch(p_oElement.nodeName.toUpperCase()){case"INPUT":case"BUTTON":if(p_oElement.type=="submit"&&!p_oElement.disabled){if(!bFormContainsYUIButtons&&!oPrecedingSubmitButton){oPrecedingSubmitButton=p_oElement;}
+if(oYUISubmitButton&&!oFollowingSubmitButton){oFollowingSubmitButton=p_oElement;}}
+break;default:sId=p_oElement.id;if(sId){oButton=m_oButtons[sId];if(oButton){bFormContainsYUIButtons=true;if(!oButton.get("disabled")){oSrcElement=oButton.get("srcelement");if(!oYUISubmitButton&&(oButton.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit")))
+{oYUISubmitButton=oButton;}}}}
+break;}}
+if(nCharCode==13&&((sNodeName=="INPUT"&&(sType=="text"||sType=="password"||sType=="checkbox"||sType=="radio"||sType=="file"))||sNodeName=="SELECT"))
+{Dom.getElementsBy(isSubmitButton,"*",this);if(oPrecedingSubmitButton){oPrecedingSubmitButton.focus();}
+else if(!oPrecedingSubmitButton&&oYUISubmitButton){if(oFollowingSubmitButton){Event.preventDefault(p_oEvent);}
+oYUISubmitButton.submitForm();}}};YAHOO.widget.Button.addHiddenFieldsToForm=function(p_oForm){var aButtons=Dom.getElementsByClassName(YAHOO.widget.Button.prototype.CSS_CLASS_NAME,"*",p_oForm),nButtons=aButtons.length,oButton,sId,i;if(nButtons>0){for(i=0;i0){i=nButtons-1;do{this._buttons[i].set("disabled",p_bDisabled);}
+while(i--);}},_onKeyDown:function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),nCharCode=Event.getCharCode(p_oEvent),sId=oTarget.parentNode.parentNode.id,oButton=m_oButtons[sId],nIndex=-1;if(nCharCode==37||nCharCode==38){nIndex=(oButton.index===0)?(this._buttons.length-1):(oButton.index-1);}
+else if(nCharCode==39||nCharCode==40){nIndex=(oButton.index===(this._buttons.length-1))?0:(oButton.index+1);}
+if(nIndex>-1){this.check(nIndex);this.getButton(nIndex).focus();}},_onAppendTo:function(p_oEvent){var aButtons=this._buttons,nButtons=aButtons.length,i;for(i=0;i0){this.addButtons(aButtons);}
+function isRadioButton(p_oElement){return(p_oElement.type=="radio");}
+aButtons=Dom.getElementsBy(isRadioButton,"input",this.get("element"));if(aButtons.length>0){this.addButtons(aButtons);}
+this.on("keydown",this._onKeyDown);this.on("appendTo",this._onAppendTo);var oContainer=this.get("container");if(oContainer){if(Lang.isString(oContainer)){Event.onContentReady(oContainer,function(){this.appendTo(oContainer);},null,this);}
+else{this.appendTo(oContainer);}}},initAttributes:function(p_oAttributes){var oAttributes=p_oAttributes||{};YAHOO.widget.ButtonGroup.superclass.initAttributes.call(this,oAttributes);this.setAttributeConfig("name",{value:oAttributes.name,validator:Lang.isString});this.setAttributeConfig("disabled",{value:(oAttributes.disabled||false),validator:Lang.isBoolean,method:this._setDisabled});this.setAttributeConfig("value",{value:oAttributes.value});this.setAttributeConfig("container",{value:oAttributes.container,writeOnce:true});this.setAttributeConfig("checkedButton",{value:null});},addButton:function(p_oButton){var oButton,oButtonElement,oGroupElement,nIndex,sButtonName,sGroupName;if(p_oButton instanceof Button&&p_oButton.get("type")=="radio"){oButton=p_oButton;}
+else if(!Lang.isString(p_oButton)&&!p_oButton.nodeName){p_oButton.type="radio";oButton=new Button(p_oButton);}
+else{oButton=new Button(p_oButton,{type:"radio"});}
+if(oButton){nIndex=this._buttons.length;sButtonName=oButton.get("name");sGroupName=this.get("name");oButton.index=nIndex;this._buttons[nIndex]=oButton;m_oButtons[oButton.get("id")]=oButton;if(sButtonName!=sGroupName){oButton.set("name",sGroupName);}
+if(this.get("disabled")){oButton.set("disabled",true);}
+if(oButton.get("checked")){this.set("checkedButton",oButton);}
+oButtonElement=oButton.get("element");oGroupElement=this.get("element");if(oButtonElement.parentNode!=oGroupElement){oGroupElement.appendChild(oButtonElement);}
+oButton.on("checkedChange",this._onButtonCheckedChange,oButton,this);return oButton;}},addButtons:function(p_aButtons){var nButtons,oButton,aButtons,i;if(Lang.isArray(p_aButtons)){nButtons=p_aButtons.length;aButtons=[];if(nButtons>0){for(i=0;i0){return aButtons;}}}},removeButton:function(p_nIndex){var oButton=this.getButton(p_nIndex),nButtons,i;if(oButton){this._buttons.splice(p_nIndex,1);delete m_oButtons[oButton.get("id")];oButton.removeListener("checkedChange",this._onButtonCheckedChange);oButton.destroy();nButtons=this._buttons.length;if(nButtons>0){i=this._buttons.length-1;do{this._buttons[i].index=i;}
+while(i--);}}},getButton:function(p_nIndex){if(Lang.isNumber(p_nIndex)){return this._buttons[p_nIndex];}},getButtons:function(){return this._buttons;},getCount:function(){return this._buttons.length;},focus:function(p_nIndex){var oButton,nButtons,i;if(Lang.isNumber(p_nIndex)){oButton=this._buttons[p_nIndex];if(oButton){oButton.focus();}}
+else{nButtons=this.getCount();for(i=0;i0){i=this._buttons.length-1;do{this._buttons[i].destroy();}
+while(i--);}
+Event.purgeElement(oElement);oParentNode.removeChild(oElement);},toString:function(){return("ButtonGroup "+this.get("id"));}});})();YAHOO.register("button",YAHOO.widget.Button,{version:"2.3.0",build:"442"});
\ No newline at end of file
diff --git a/lib/yui/button/button-beta.js b/lib/yui/button/button-beta.js
new file mode 100755
index 0000000000..83195b829f
--- /dev/null
+++ b/lib/yui/button/button-beta.js
@@ -0,0 +1,4477 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+/**
+* @module button
+* @description The Button Control enables the creation of rich, graphical
+* buttons that function like traditional HTML form buttons. Unlike
+* tradition HTML form buttons, buttons created with the Button Control can have
+* a label that is different from its value. With the inclusion of the optional
+* Menu Control , the Button Control can also be
+* used to create menu buttons and split buttons, controls that are not
+* available natively in HTML. The Button Control can also be thought of as a
+* way to create more visually engaging implementations of the browser's
+* default radio-button and check-box controls.
+* The Button Control supports the following types:
+*
+* push
+* Basic push button that can execute a user-specified command when
+* pressed.
+* link
+* Navigates to a specified url when pressed.
+* submit
+* Submits the parent form when pressed.
+* reset
+* Resets the parent form when pressed.
+* checkbox
+* Maintains a "checked" state that can be toggled on and off.
+* radio
+* Maintains a "checked" state that can be toggled on and off. Use with
+* the ButtonGroup class to create a set of controls that are mutually
+* exclusive; checking one button in the set will uncheck all others in
+* the group.
+* menu
+* When pressed will show/hide a menu.
+* split
+* Can execute a user-specified command or display a menu when pressed.
+*
+* @title Button
+* @namespace YAHOO.widget
+* @requires yahoo, dom, element, event
+* @optional container, menu
+* @beta
+*/
+
+
+(function () {
+
+
+ /**
+ * The Button class creates a rich, graphical button.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to
+ * be used to create the button.
+ * @param {HTMLInputElement |
+ * HTMLButtonElement |HTMLElement } p_oElement Object reference for the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to be
+ * used to create the button.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a set
+ * of configuration attributes used to create the button.
+ * @namespace YAHOO.widget
+ * @class Button
+ * @constructor
+ * @extends YAHOO.util.Element
+ */
+
+
+
+ // Shorthard for utilities
+
+ var Dom = YAHOO.util.Dom,
+ Event = YAHOO.util.Event,
+ Lang = YAHOO.lang,
+ Overlay = YAHOO.widget.Overlay,
+ Menu = YAHOO.widget.Menu,
+
+
+ // Private member variables
+
+ m_oButtons = {}, // Collection of all Button instances
+ m_oOverlayManager = null, // YAHOO.widget.OverlayManager instance
+ m_oSubmitTrigger = null, // The button that submitted the form
+ m_oFocusedButton = null; // The button that has focus
+
+
+
+ // Private methods
+
+
+
+ /**
+ * @method createInputElement
+ * @description Creates an <input>
element of the
+ * specified type.
+ * @private
+ * @param {String} p_sType String specifying the type of
+ * <input>
element to create.
+ * @param {String} p_sName String specifying the name of
+ * <input>
element to create.
+ * @param {String} p_sValue String specifying the value of
+ * <input>
element to create.
+ * @param {String} p_bChecked Boolean specifying if the
+ * <input>
element is to be checked.
+ * @return {HTMLInputElement }
+ */
+ function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) {
+
+ var oInput,
+ sInput;
+
+ if (Lang.isString(p_sType) && Lang.isString(p_sName)) {
+
+ if (YAHOO.env.ua.ie) {
+
+ /*
+ For IE it is necessary to create the element with the
+ "type," "name," "value," and "checked" properties set all
+ at once.
+ */
+
+ sInput = " ";
+
+ oInput = document.createElement(sInput);
+
+ }
+ else {
+
+ oInput = document.createElement("input");
+ oInput.name = p_sName;
+ oInput.type = p_sType;
+
+ if (p_bChecked) {
+
+ oInput.checked = true;
+
+ }
+
+ }
+
+ oInput.value = p_sValue;
+
+ return oInput;
+
+ }
+
+ }
+
+
+ /**
+ * @method setAttributesFromSrcElement
+ * @description Gets the values for all the attributes of the source element
+ * (either <input>
or <a>
) that
+ * map to Button configuration attributes and sets them into a collection
+ * that is passed to the Button constructor.
+ * @private
+ * @param {HTMLInputElement |HTMLAnchorElement } p_oElement Object reference to the HTML
+ * element (either <input>
or <span>
+ *
) used to create the button.
+ * @param {Object} p_oAttributes Object reference for the collection of
+ * configuration attributes used to create the button.
+ */
+ function setAttributesFromSrcElement(p_oElement, p_oAttributes) {
+
+ var sSrcElementNodeName = p_oElement.nodeName.toUpperCase(),
+ me = this,
+ oAttribute,
+ oRootNode,
+ sText;
+
+
+ /**
+ * @method setAttributeFromDOMAttribute
+ * @description Gets the value of the specified DOM attribute and sets it
+ * into the collection of configuration attributes used to configure
+ * the button.
+ * @private
+ * @param {String} p_sAttribute String representing the name of the
+ * attribute to retrieve from the DOM element.
+ */
+ function setAttributeFromDOMAttribute(p_sAttribute) {
+
+ if ( !(p_sAttribute in p_oAttributes) ) {
+
+ /*
+ Need to use "getAttributeNode" instead of "getAttribute"
+ because using "getAttribute," IE will return the innerText
+ of a <button>
for the value attribute
+ rather than the value of the "value" attribute.
+ */
+
+ oAttribute = p_oElement.getAttributeNode(p_sAttribute);
+
+
+ if (oAttribute && ("value" in oAttribute)) {
+
+
+ p_oAttributes[p_sAttribute] = oAttribute.value;
+
+ }
+
+ }
+
+ }
+
+
+ /**
+ * @method setFormElementProperties
+ * @description Gets the value of the attributes from the form element
+ * and sets them into the collection of configuration attributes used to
+ * configure the button.
+ * @private
+ */
+ function setFormElementProperties() {
+
+ setAttributeFromDOMAttribute("type");
+
+ if (p_oAttributes.type == "button") {
+
+ p_oAttributes.type = "push";
+
+ }
+
+ if ( !("disabled" in p_oAttributes) ) {
+
+ p_oAttributes.disabled = p_oElement.disabled;
+
+ }
+
+ setAttributeFromDOMAttribute("name");
+ setAttributeFromDOMAttribute("value");
+ setAttributeFromDOMAttribute("title");
+
+ }
+
+
+ switch (sSrcElementNodeName) {
+
+ case "A":
+
+ p_oAttributes.type = "link";
+
+ setAttributeFromDOMAttribute("href");
+ setAttributeFromDOMAttribute("target");
+
+ break;
+
+ case "INPUT":
+
+ setFormElementProperties();
+
+ if ( !("checked" in p_oAttributes) ) {
+
+ p_oAttributes.checked = p_oElement.checked;
+
+ }
+
+ break;
+
+ case "BUTTON":
+
+ setFormElementProperties();
+
+ oRootNode = p_oElement.parentNode.parentNode;
+
+ if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-checked")) {
+
+ p_oAttributes.checked = true;
+
+ }
+
+ if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-disabled")) {
+
+ p_oAttributes.disabled = true;
+
+ }
+
+ p_oElement.removeAttribute("value");
+
+ p_oElement.setAttribute("type", "button");
+
+ break;
+
+ }
+
+ p_oElement.removeAttribute("id");
+ p_oElement.removeAttribute("name");
+
+ if ( !("tabindex" in p_oAttributes) ) {
+
+ p_oAttributes.tabindex = p_oElement.tabIndex;
+
+ }
+
+ if ( !("label" in p_oAttributes) ) {
+
+ // Set the "label" property
+
+ sText = sSrcElementNodeName == "INPUT" ?
+ p_oElement.value : p_oElement.innerHTML;
+
+
+ if (sText && sText.length > 0) {
+
+ p_oAttributes.label = sText;
+
+ }
+
+ }
+
+ }
+
+
+ /**
+ * @method initConfig
+ * @description Initializes the set of configuration attributes that are
+ * used to instantiate the button.
+ * @private
+ * @param {Object} Object representing the button's set of
+ * configuration attributes.
+ */
+ function initConfig(p_oConfig) {
+
+ var oAttributes = p_oConfig.attributes,
+ oSrcElement = oAttributes.srcelement,
+ sSrcElementNodeName = oSrcElement.nodeName.toUpperCase(),
+ me = this;
+
+
+ if (sSrcElementNodeName == this.NODE_NAME) {
+
+ p_oConfig.element = oSrcElement;
+ p_oConfig.id = oSrcElement.id;
+
+ Dom.getElementsBy(function (p_oElement) {
+
+ switch (p_oElement.nodeName.toUpperCase()) {
+
+ case "BUTTON":
+ case "A":
+ case "INPUT":
+
+ setAttributesFromSrcElement.call(me, p_oElement,
+ oAttributes);
+
+ break;
+
+ }
+
+ }, "*", oSrcElement);
+
+ }
+ else {
+
+ switch (sSrcElementNodeName) {
+
+ case "BUTTON":
+ case "A":
+ case "INPUT":
+
+ setAttributesFromSrcElement.call(this, oSrcElement,
+ oAttributes);
+
+ break;
+
+ }
+
+ }
+
+ }
+
+
+
+ // Constructor
+
+ YAHOO.widget.Button = function (p_oElement, p_oAttributes) {
+
+ var fnSuperClass = YAHOO.widget.Button.superclass.constructor,
+ oConfig,
+ oElement;
+
+ if (arguments.length == 1 && !Lang.isString(p_oElement) &&
+ !p_oElement.nodeName) {
+
+ if (!p_oElement.id) {
+
+ p_oElement.id = Dom.generateId();
+
+
+ }
+
+
+
+ fnSuperClass.call(this,
+ (this.createButtonElement(p_oElement.type)),
+ p_oElement);
+
+ }
+ else {
+
+ oConfig = { element: null, attributes: (p_oAttributes || {}) };
+
+
+ if (Lang.isString(p_oElement)) {
+
+ oElement = Dom.get(p_oElement);
+
+ if (oElement) {
+
+ if (!oConfig.attributes.id) {
+
+ oConfig.attributes.id = p_oElement;
+
+ }
+
+
+
+
+ oConfig.attributes.srcelement = oElement;
+
+ initConfig.call(this, oConfig);
+
+
+ if (!oConfig.element) {
+
+
+ oConfig.element =
+ this.createButtonElement(oConfig.attributes.type);
+
+ }
+
+ fnSuperClass.call(this, oConfig.element,
+ oConfig.attributes);
+
+ }
+
+ }
+ else if (p_oElement.nodeName) {
+
+ if (!oConfig.attributes.id) {
+
+ if (p_oElement.id) {
+
+ oConfig.attributes.id = p_oElement.id;
+
+ }
+ else {
+
+ oConfig.attributes.id = Dom.generateId();
+
+
+ }
+
+ }
+
+
+
+
+
+ oConfig.attributes.srcelement = p_oElement;
+
+ initConfig.call(this, oConfig);
+
+
+ if (!oConfig.element) {
+
+
+ oConfig.element =
+ this.createButtonElement(oConfig.attributes.type);
+
+ }
+
+ fnSuperClass.call(this, oConfig.element, oConfig.attributes);
+
+ }
+
+ }
+
+ };
+
+
+
+ YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, {
+
+
+ // Protected properties
+
+
+ /**
+ * @property _button
+ * @description Object reference to the button's internal
+ * <a>
or <button>
element.
+ * @default null
+ * @protected
+ * @type HTMLAnchorElement |HTMLButtonElement
+ */
+ _button: null,
+
+
+ /**
+ * @property _menu
+ * @description Object reference to the button's menu.
+ * @default null
+ * @protected
+ * @type {YAHOO.widget.Overlay |
+ * YAHOO.widget.Menu }
+ */
+ _menu: null,
+
+
+ /**
+ * @property _hiddenFields
+ * @description Object reference to the <input>
+ * element, or array of HTML form elements used to represent the button
+ * when its parent form is submitted.
+ * @default null
+ * @protected
+ * @type HTMLInputElement |Array
+ */
+ _hiddenFields: null,
+
+
+ /**
+ * @property _onclickAttributeValue
+ * @description Object reference to the button's current value for the
+ * "onclick" configuration attribute.
+ * @default null
+ * @protected
+ * @type Object
+ */
+ _onclickAttributeValue: null,
+
+
+ /**
+ * @property _activationKeyPressed
+ * @description Boolean indicating if the key(s) that toggle the button's
+ * "active" state have been pressed.
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _activationKeyPressed: false,
+
+
+ /**
+ * @property _activationButtonPressed
+ * @description Boolean indicating if the mouse button that toggles
+ * the button's "active" state has been pressed.
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _activationButtonPressed: false,
+
+
+ /**
+ * @property _hasKeyEventHandlers
+ * @description Boolean indicating if the button's "blur", "keydown" and
+ * "keyup" event handlers are assigned
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _hasKeyEventHandlers: false,
+
+
+ /**
+ * @property _hasMouseEventHandlers
+ * @description Boolean indicating if the button's "mouseout,"
+ * "mousedown," and "mouseup" event handlers are assigned
+ * @default false
+ * @protected
+ * @type Boolean
+ */
+ _hasMouseEventHandlers: false,
+
+
+
+ // Constants
+
+
+ /**
+ * @property NODE_NAME
+ * @description The name of the node to be used for the button's
+ * root element.
+ * @default "SPAN"
+ * @final
+ * @type String
+ */
+ NODE_NAME: "SPAN",
+
+
+ /**
+ * @property CHECK_ACTIVATION_KEYS
+ * @description Array of numbers representing keys that (when pressed)
+ * toggle the button's "checked" attribute.
+ * @default [32]
+ * @final
+ * @type Array
+ */
+ CHECK_ACTIVATION_KEYS: [32],
+
+
+ /**
+ * @property ACTIVATION_KEYS
+ * @description Array of numbers representing keys that (when presed)
+ * toggle the button's "active" state.
+ * @default [13, 32]
+ * @final
+ * @type Array
+ */
+ ACTIVATION_KEYS: [13, 32],
+
+
+ /**
+ * @property OPTION_AREA_WIDTH
+ * @description Width (in pixels) of the area of a split button that
+ * when pressed will display a menu.
+ * @default 20
+ * @final
+ * @type Number
+ */
+ OPTION_AREA_WIDTH: 20,
+
+
+ /**
+ * @property CSS_CLASS_NAME
+ * @description String representing the CSS class(es) to be applied to
+ * the button's root element.
+ * @default "yui-button"
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yui-button",
+
+
+ /**
+ * @property RADIO_DEFAULT_TITLE
+ * @description String representing the default title applied to buttons
+ * of type "radio."
+ * @default "Unchecked. Click to check."
+ * @final
+ * @type String
+ */
+ RADIO_DEFAULT_TITLE: "Unchecked. Click to check.",
+
+
+ /**
+ * @property RADIO_CHECKED_TITLE
+ * @description String representing the title applied to buttons of
+ * type "radio" when checked.
+ * @default "Checked. Click to uncheck."
+ * @final
+ * @type String
+ */
+ RADIO_CHECKED_TITLE: "Checked. Click to uncheck.",
+
+
+ /**
+ * @property CHECKBOX_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "checkbox."
+ * @default "Unchecked. Click to check."
+ * @final
+ * @type String
+ */
+ CHECKBOX_DEFAULT_TITLE: "Unchecked. Click to check.",
+
+
+ /**
+ * @property CHECKBOX_CHECKED_TITLE
+ * @description String representing the title applied to buttons of type
+ * "checkbox" when checked.
+ * @default "Checked. Click to uncheck."
+ * @final
+ * @type String
+ */
+ CHECKBOX_CHECKED_TITLE: "Checked. Click to uncheck.",
+
+
+ /**
+ * @property MENUBUTTON_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "menu."
+ * @default "Menu collapsed. Click to expand."
+ * @final
+ * @type String
+ */
+ MENUBUTTON_DEFAULT_TITLE: "Menu collapsed. Click to expand.",
+
+
+ /**
+ * @property MENUBUTTON_MENU_VISIBLE_TITLE
+ * @description String representing the title applied to buttons of type
+ * "menu" when the button's menu is visible.
+ * @default "Menu expanded. Click or press Esc to collapse."
+ * @final
+ * @type String
+ */
+ MENUBUTTON_MENU_VISIBLE_TITLE:
+ "Menu expanded. Click or press Esc to collapse.",
+
+
+ /**
+ * @property SPLITBUTTON_DEFAULT_TITLE
+ * @description String representing the default title applied to
+ * buttons of type "split."
+ * @default "Menu collapsed. Click inside option region or press
+ * Ctrl + Shift + M to show the menu."
+ * @final
+ * @type String
+ */
+ SPLITBUTTON_DEFAULT_TITLE: ("Menu collapsed. Click inside option " +
+ "region or press Ctrl + Shift + M to show the menu."),
+
+
+ /**
+ * @property SPLITBUTTON_OPTION_VISIBLE_TITLE
+ * @description String representing the title applied to buttons of type
+ * "split" when the button's menu is visible.
+ * @default "Menu expanded. Press Esc or Ctrl + Shift + M to hide
+ * the menu."
+ * @final
+ * @type String
+ */
+ SPLITBUTTON_OPTION_VISIBLE_TITLE:
+ "Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.",
+
+
+ /**
+ * @property SUBMIT_TITLE
+ * @description String representing the title applied to buttons of
+ * type "submit."
+ * @default "Click to submit form."
+ * @final
+ * @type String
+ */
+ SUBMIT_TITLE: "Click to submit form.",
+
+
+
+ // Protected attribute setter methods
+
+
+ /**
+ * @method _setType
+ * @description Sets the value of the button's "type" attribute.
+ * @protected
+ * @param {String} p_sType String indicating the value for the button's
+ * "type" attribute.
+ */
+ _setType: function (p_sType) {
+
+ if (p_sType == "split") {
+
+ this.on("option", this._onOption);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setLabel
+ * @description Sets the value of the button's "label" attribute.
+ * @protected
+ * @param {String} p_sLabel String indicating the value for the button's
+ * "label" attribute.
+ */
+ _setLabel: function (p_sLabel) {
+
+ this._button.innerHTML = p_sLabel;
+
+ },
+
+
+ /**
+ * @method _setTabIndex
+ * @description Sets the value of the button's "tabindex" attribute.
+ * @protected
+ * @param {Number} p_nTabIndex Number indicating the value for the
+ * button's "tabindex" attribute.
+ */
+ _setTabIndex: function (p_nTabIndex) {
+
+ this._button.tabIndex = p_nTabIndex;
+
+ },
+
+
+ /**
+ * @method _setTitle
+ * @description Sets the value of the button's "title" attribute.
+ * @protected
+ * @param {String} p_nTabIndex Number indicating the value for
+ * the button's "title" attribute.
+ */
+ _setTitle: function (p_sTitle) {
+
+ var sTitle = p_sTitle;
+
+ if (this.get("type") != "link") {
+
+ if (!sTitle) {
+
+ switch (this.get("type")) {
+
+ case "radio":
+
+ sTitle = this.RADIO_DEFAULT_TITLE;
+
+ break;
+
+ case "checkbox":
+
+ sTitle = this.CHECKBOX_DEFAULT_TITLE;
+
+ break;
+
+ case "menu":
+
+ sTitle = this.MENUBUTTON_DEFAULT_TITLE;
+
+ break;
+
+ case "split":
+
+ sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
+
+ break;
+
+ case "submit":
+
+ sTitle = this.SUBMIT_TITLE;
+
+ break;
+
+ }
+
+ }
+
+ this._button.title = sTitle;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setDisabled
+ * @description Sets the value of the button's "disabled" attribute.
+ * @protected
+ * @param {Boolean} p_bDisabled Boolean indicating the value for
+ * the button's "disabled" attribute.
+ */
+ _setDisabled: function (p_bDisabled) {
+
+ if (this.get("type") != "link") {
+
+ if (p_bDisabled) {
+
+ if (this._menu) {
+
+ this._menu.hide();
+
+ }
+
+ if (this.hasFocus()) {
+
+ this.blur();
+
+ }
+
+ this._button.setAttribute("disabled", "disabled");
+
+ this.addStateCSSClasses("disabled");
+
+ }
+ else {
+
+ this._button.removeAttribute("disabled");
+
+ this.removeStateCSSClasses("disabled");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _setHref
+ * @description Sets the value of the button's "href" attribute.
+ * @protected
+ * @param {String} p_sHref String indicating the value for the button's
+ * "href" attribute.
+ */
+ _setHref: function (p_sHref) {
+
+ if (this.get("type") == "link") {
+
+ this._button.href = p_sHref;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setTarget
+ * @description Sets the value of the button's "target" attribute.
+ * @protected
+ * @param {String} p_sTarget String indicating the value for the button's
+ * "target" attribute.
+ */
+ _setTarget: function (p_sTarget) {
+
+ if (this.get("type") == "link") {
+
+ this._button.setAttribute("target", p_sTarget);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setChecked
+ * @description Sets the value of the button's "target" attribute.
+ * @protected
+ * @param {Boolean} p_bChecked Boolean indicating the value for
+ * the button's "checked" attribute.
+ */
+ _setChecked: function (p_bChecked) {
+
+ var sType = this.get("type"),
+ sTitle;
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ if (p_bChecked) {
+
+ this.addStateCSSClasses("checked");
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_CHECKED_TITLE :
+ this.CHECKBOX_CHECKED_TITLE;
+
+ }
+ else {
+
+ this.removeStateCSSClasses("checked");
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_DEFAULT_TITLE :
+ this.CHECKBOX_DEFAULT_TITLE;
+
+ }
+
+ this.set("title", sTitle);
+
+ }
+
+ },
+
+
+ /**
+ * @method _setMenu
+ * @description Sets the value of the button's "menu" attribute.
+ * @protected
+ * @param {Object} p_oMenu Object indicating the value for the button's
+ * "menu" attribute.
+ */
+ _setMenu: function (p_oMenu) {
+
+ var bLazyLoad = this.get("lazyloadmenu"),
+ oButtonElement = this.get("element"),
+
+ /*
+ Boolean indicating if the value of p_oMenu is an instance
+ of YAHOO.widget.Menu or YAHOO.widget.Overlay.
+ */
+
+ bInstance = false,
+
+
+ oMenu,
+ oMenuElement,
+ oSrcElement,
+ aItems,
+ nItems,
+ oItem,
+ i;
+
+
+ if (!Overlay) {
+
+
+ return false;
+
+ }
+
+
+ if (!Menu) {
+
+
+ return false;
+
+ }
+
+
+ function onAppendTo() {
+
+ oMenu.render(oButtonElement.parentNode);
+
+ this.removeListener("appendTo", onAppendTo);
+
+ }
+
+
+ function initMenu() {
+
+ if (oMenu) {
+
+ Dom.addClass(oMenu.element, this.get("menuclassname"));
+ Dom.addClass(oMenu.element,
+ "yui-" + this.get("type") + "-button-menu");
+
+ oMenu.showEvent.subscribe(this._onMenuShow, null, this);
+ oMenu.hideEvent.subscribe(this._onMenuHide, null, this);
+ oMenu.renderEvent.subscribe(this._onMenuRender, null, this);
+
+
+ if (oMenu instanceof Menu) {
+
+ oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,
+ this, true);
+
+ oMenu.clickEvent.subscribe(this._onMenuClick,
+ this, true);
+
+ oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,
+ this, true);
+
+ oSrcElement = oMenu.srcElement;
+
+ if (oSrcElement &&
+ oSrcElement.nodeName.toUpperCase() == "SELECT") {
+
+ oSrcElement.style.display = "none";
+ oSrcElement.parentNode.removeChild(oSrcElement);
+
+ }
+
+ }
+ else if (oMenu instanceof Overlay) {
+
+ if (!m_oOverlayManager) {
+
+ m_oOverlayManager =
+ new YAHOO.widget.OverlayManager();
+
+ }
+
+ m_oOverlayManager.register(oMenu);
+
+ }
+
+
+ this._menu = oMenu;
+
+
+ if (!bInstance) {
+
+ if (bLazyLoad && !(oMenu instanceof Menu)) {
+
+ /*
+ Mimic Menu's "lazyload" functionality by adding
+ a "beforeshow" event listener that renders the
+ Overlay instance before it is made visible by
+ the button.
+ */
+
+ oMenu.beforeShowEvent.subscribe(
+ this._onOverlayBeforeShow, null, this);
+
+ }
+ else if (!bLazyLoad) {
+
+ if (Dom.inDocument(oButtonElement)) {
+
+ oMenu.render(oButtonElement.parentNode);
+
+ }
+ else {
+
+ this.on("appendTo", onAppendTo);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+
+ if (p_oMenu && (p_oMenu instanceof Menu)) {
+
+ oMenu = p_oMenu;
+ aItems = oMenu.getItems();
+ nItems = aItems.length;
+ bInstance = true;
+
+
+ if (nItems > 0) {
+
+ i = nItems - 1;
+
+ do {
+
+ oItem = aItems[i];
+
+ if (oItem) {
+
+ oItem.cfg.subscribeToConfigEvent("selected",
+ this._onMenuItemSelected,
+ oItem,
+ this);
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ initMenu.call(this);
+
+ }
+ else if (p_oMenu && (p_oMenu instanceof Overlay)) {
+
+ oMenu = p_oMenu;
+ bInstance = true;
+
+ oMenu.cfg.setProperty("visible", false);
+ oMenu.cfg.setProperty("context", [oButtonElement, "tl", "bl"]);
+
+ initMenu.call(this);
+
+ }
+ else if (Lang.isArray(p_oMenu)) {
+
+ this.on("appendTo", function () {
+
+ oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad,
+ itemdata: p_oMenu });
+
+ initMenu.call(this);
+
+ });
+
+ }
+ else if (Lang.isString(p_oMenu)) {
+
+ oMenuElement = Dom.get(p_oMenu);
+
+ if (oMenuElement) {
+
+ if (Dom.hasClass(oMenuElement,
+ Menu.prototype.CSS_CLASS_NAME) ||
+ oMenuElement.nodeName == "SELECT") {
+
+ oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
+
+ initMenu.call(this);
+
+ }
+ else {
+
+ oMenu = new Overlay(p_oMenu, { visible: false,
+ context: [oButtonElement, "tl", "bl"] });
+
+ initMenu.call(this);
+
+ }
+
+ }
+
+ }
+ else if (p_oMenu && p_oMenu.nodeName) {
+
+ if (Dom.hasClass(p_oMenu, Menu.prototype.CSS_CLASS_NAME) ||
+ p_oMenu.nodeName == "SELECT") {
+
+ oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });
+
+ initMenu.call(this);
+
+ }
+ else {
+
+ if (!p_oMenu.id) {
+
+ Dom.generateId(p_oMenu);
+
+ }
+
+ oMenu = new Overlay(p_oMenu, { visible: false,
+ context: [oButtonElement, "tl", "bl"] });
+
+ initMenu.call(this);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _setOnClick
+ * @description Sets the value of the button's "onclick" attribute.
+ * @protected
+ * @param {Object} p_oObject Object indicating the value for the button's
+ * "onclick" attribute.
+ */
+ _setOnClick: function (p_oObject) {
+
+ /*
+ Remove any existing listeners if a "click" event handler
+ has already been specified.
+ */
+
+ if (this._onclickAttributeValue &&
+ (this._onclickAttributeValue != p_oObject)) {
+
+ this.removeListener("click", this._onclickAttributeValue.fn);
+
+ this._onclickAttributeValue = null;
+
+ }
+
+
+ if (!this._onclickAttributeValue &&
+ Lang.isObject(p_oObject) &&
+ Lang.isFunction(p_oObject.fn)) {
+
+ this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope);
+
+ this._onclickAttributeValue = p_oObject;
+
+ }
+
+ },
+
+
+ /**
+ * @method _setSelectedMenuItem
+ * @description Sets the value of the button's
+ * "selectedMenuItem" attribute.
+ * @protected
+ * @param {Number} p_nIndex Number representing the index of the item
+ * in the button's menu that is currently selected.
+ */
+ _setSelectedMenuItem: function (p_nIndex) {
+
+ var oMenu = this._menu,
+ oMenuItem;
+
+
+ if (oMenu && oMenu instanceof Menu) {
+
+ oMenuItem = oMenu.getItem(p_nIndex);
+
+
+ if (oMenuItem && !oMenuItem.cfg.getProperty("selected")) {
+
+ oMenuItem.cfg.setProperty("selected", true);
+
+ }
+
+ }
+
+ },
+
+
+ // Protected methods
+
+
+
+ /**
+ * @method _isActivationKey
+ * @description Determines if the specified keycode is one that toggles
+ * the button's "active" state.
+ * @protected
+ * @param {Number} p_nKeyCode Number representing the keycode to
+ * be evaluated.
+ * @return {Boolean}
+ */
+ _isActivationKey: function (p_nKeyCode) {
+
+ var sType = this.get("type"),
+ aKeyCodes = (sType == "checkbox" || sType == "radio") ?
+ this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS,
+
+ nKeyCodes = aKeyCodes.length,
+ i;
+
+ if (nKeyCodes > 0) {
+
+ i = nKeyCodes - 1;
+
+ do {
+
+ if (p_nKeyCode == aKeyCodes[i]) {
+
+ return true;
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ },
+
+
+ /**
+ * @method _isSplitButtonOptionKey
+ * @description Determines if the specified keycode is one that toggles
+ * the display of the split button's menu.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ * @return {Boolean}
+ */
+ _isSplitButtonOptionKey: function (p_oEvent) {
+
+ return (p_oEvent.ctrlKey && p_oEvent.shiftKey &&
+ Event.getCharCode(p_oEvent) == 77);
+
+ },
+
+
+ /**
+ * @method _addListenersToForm
+ * @description Adds event handlers to the button's form.
+ * @protected
+ */
+ _addListenersToForm: function () {
+
+ var oForm = this.getForm(),
+ oSrcElement,
+ aListeners,
+ nListeners,
+ i,
+ bHasKeyPressListener;
+
+
+ if (oForm) {
+
+ Event.on(oForm, "reset", this._onFormReset, null, this);
+ Event.on(oForm, "submit", this.createHiddenFields, null, this);
+
+ oSrcElement = this.get("srcelement");
+
+
+ if (this.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit"))
+ {
+
+ aListeners = Event.getListeners(oForm, "keypress");
+ bHasKeyPressListener = false;
+
+ if (aListeners) {
+
+ nListeners = aListeners.length;
+
+ if (nListeners > 0) {
+
+ i = nListeners - 1;
+
+ do {
+
+ if (aListeners[i].fn ==
+ YAHOO.widget.Button.onFormKeyPress)
+ {
+
+ bHasKeyPressListener = true;
+ break;
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ }
+
+
+ if (!bHasKeyPressListener) {
+
+ Event.on(oForm, "keypress",
+ YAHOO.widget.Button.onFormKeyPress);
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ _originalMaxHeight: -1,
+
+
+ /**
+ * @method _showMenu
+ * @description Shows the button's menu.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event) that triggered
+ * the display of the menu.
+ */
+ _showMenu: function (p_oEvent) {
+
+ YAHOO.widget.MenuManager.hideVisible();
+
+ if (m_oOverlayManager) {
+
+ m_oOverlayManager.hideAll();
+
+ }
+
+
+ var oMenu = this._menu,
+ nViewportHeight = Dom.getViewportHeight(),
+ nMenuHeight,
+ nScrollTop,
+ nY;
+
+
+ if (oMenu && (oMenu instanceof Menu)) {
+
+ oMenu.cfg.applyConfig({ context: [this.get("id"), "tl", "bl"],
+ constraintoviewport: false,
+ clicktohide: false,
+ visible: true });
+
+ oMenu.cfg.fireQueue();
+
+ oMenu.align("tl", "bl");
+
+ /*
+ Stop the propagation of the event so that the MenuManager
+ doesn't blur the menu after it gets focus.
+ */
+
+ if (p_oEvent.type == "mousedown") {
+
+ Event.stopPropagation(p_oEvent);
+
+ }
+
+
+ if (this.get("focusmenu")) {
+
+ this._menu.focus();
+
+ }
+
+ nMenuHeight = oMenu.element.offsetHeight;
+
+
+ if ((oMenu.cfg.getProperty("y") + nMenuHeight) >
+ nViewportHeight) {
+
+
+ oMenu.align("bl", "tl");
+
+ nY = oMenu.cfg.getProperty("y");
+
+ nScrollTop = Dom.getDocumentScrollTop();
+
+
+ if (nScrollTop >= nY) {
+
+ if (this._originalMaxHeight == -1) {
+
+ this._originalMaxHeight =
+ oMenu.cfg.getProperty("maxheight");
+
+ }
+
+ oMenu.cfg.setProperty("maxheight",
+ (nMenuHeight - ((nScrollTop - nY) + 20)));
+
+ oMenu.align("bl", "tl");
+
+ }
+
+ }
+
+ }
+ else if (oMenu && (oMenu instanceof Overlay)) {
+
+ oMenu.show();
+ oMenu.align("tl", "bl");
+
+ nMenuHeight = oMenu.element.offsetHeight;
+
+
+ if ((oMenu.cfg.getProperty("y") + nMenuHeight) >
+ nViewportHeight) {
+
+
+ oMenu.align("bl", "tl");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _hideMenu
+ * @description Hides the button's menu.
+ * @protected
+ */
+ _hideMenu: function () {
+
+ var oMenu = this._menu;
+
+ if (oMenu) {
+
+ oMenu.hide();
+
+ }
+
+ },
+
+
+
+
+ // Protected event handlers
+
+
+ /**
+ * @method _onMouseOver
+ * @description "mouseover" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseOver: function (p_oEvent) {
+
+ if (!this._hasMouseEventHandlers) {
+
+ this.on("mouseout", this._onMouseOut);
+ this.on("mousedown", this._onMouseDown);
+ this.on("mouseup", this._onMouseUp);
+
+ this._hasMouseEventHandlers = true;
+
+ }
+
+ this.addStateCSSClasses("hover");
+
+ if (this._activationButtonPressed) {
+
+ this.addStateCSSClasses("active");
+
+ }
+
+
+ if (this._bOptionPressed) {
+
+ this.addStateCSSClasses("activeoption");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMouseOut
+ * @description "mouseout" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseOut: function (p_oEvent) {
+
+ this.removeStateCSSClasses("hover");
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ if (this._activationButtonPressed || this._bOptionPressed) {
+
+ Event.on(document, "mouseup", this._onDocumentMouseUp,
+ null, this);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onDocumentMouseUp
+ * @description "mouseup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentMouseUp: function (p_oEvent) {
+
+ this._activationButtonPressed = false;
+ this._bOptionPressed = false;
+
+ var sType = this.get("type");
+
+ if (sType == "menu" || sType == "split") {
+
+ this.removeStateCSSClasses(
+ (sType == "menu" ? "active" : "activeoption"));
+
+ this._hideMenu();
+
+ }
+
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+
+ },
+
+
+ /**
+ * @method _onMouseDown
+ * @description "mousedown" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseDown: function (p_oEvent) {
+
+ var sType,
+ oElement,
+ nX,
+ me;
+
+
+ function onMouseUp() {
+
+ this._hideMenu();
+ this.removeListener("mouseup", onMouseUp);
+
+ }
+
+
+ if ((p_oEvent.which || p_oEvent.button) == 1) {
+
+
+ if (!this.hasFocus()) {
+
+ this.focus();
+
+ }
+
+
+ sType = this.get("type");
+
+
+ if (sType == "split") {
+
+ oElement = this.get("element");
+ nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
+
+ if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
+
+ this.fireEvent("option", p_oEvent);
+
+ }
+ else {
+
+ this.addStateCSSClasses("active");
+
+ this._activationButtonPressed = true;
+
+ }
+
+ }
+ else if (sType == "menu") {
+
+ if (this.isActive()) {
+
+ this._hideMenu();
+
+ this._activationButtonPressed = false;
+
+ }
+ else {
+
+ this._showMenu(p_oEvent);
+
+ this._activationButtonPressed = true;
+
+ }
+
+ }
+ else {
+
+ this.addStateCSSClasses("active");
+
+ this._activationButtonPressed = true;
+
+ }
+
+
+
+ if (sType == "split" || sType == "menu") {
+
+ me = this;
+
+ this._hideMenuTimerId = window.setTimeout(function () {
+
+ me.on("mouseup", onMouseUp);
+
+ }, 250);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMouseUp
+ * @description "mouseup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onMouseUp: function (p_oEvent) {
+
+ var sType = this.get("type");
+
+
+ if (this._hideMenuTimerId) {
+
+ window.clearTimeout(this._hideMenuTimerId);
+
+ }
+
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.set("checked", !(this.get("checked")));
+
+ }
+
+
+ this._activationButtonPressed = false;
+
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onFocus
+ * @description "focus" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onFocus: function (p_oEvent) {
+
+ var oElement;
+
+ this.addStateCSSClasses("focus");
+
+ if (this._activationKeyPressed) {
+
+ this.addStateCSSClasses("active");
+
+ }
+
+ m_oFocusedButton = this;
+
+
+ if (!this._hasKeyEventHandlers) {
+
+ oElement = this._button;
+
+ Event.on(oElement, "blur", this._onBlur, null, this);
+ Event.on(oElement, "keydown", this._onKeyDown, null, this);
+ Event.on(oElement, "keyup", this._onKeyUp, null, this);
+
+ this._hasKeyEventHandlers = true;
+
+ }
+
+
+ this.fireEvent("focus", p_oEvent);
+
+ },
+
+
+ /**
+ * @method _onBlur
+ * @description "blur" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onBlur: function (p_oEvent) {
+
+ this.removeStateCSSClasses("focus");
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ if (this._activationKeyPressed) {
+
+ Event.on(document, "keyup", this._onDocumentKeyUp, null, this);
+
+ }
+
+
+ m_oFocusedButton = null;
+
+ this.fireEvent("blur", p_oEvent);
+
+ },
+
+
+ /**
+ * @method _onDocumentKeyUp
+ * @description "keyup" event handler for the document.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentKeyUp: function (p_oEvent) {
+
+ if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ this._activationKeyPressed = false;
+
+ Event.removeListener(document, "keyup", this._onDocumentKeyUp);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onKeyDown
+ * @description "keydown" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyDown: function (p_oEvent) {
+
+ var oMenu = this._menu;
+
+
+ if (this.get("type") == "split" &&
+ this._isSplitButtonOptionKey(p_oEvent)) {
+
+ this.fireEvent("option", p_oEvent);
+
+ }
+ else if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ if (this.get("type") == "menu") {
+
+ this._showMenu(p_oEvent);
+
+ }
+ else {
+
+ this._activationKeyPressed = true;
+
+ this.addStateCSSClasses("active");
+
+ }
+
+ }
+
+
+ if (oMenu && oMenu.cfg.getProperty("visible") &&
+ Event.getCharCode(p_oEvent) == 27) {
+
+ oMenu.hide();
+ this.focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method _onKeyUp
+ * @description "keyup" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyUp: function (p_oEvent) {
+
+ var sType;
+
+ if (this._isActivationKey(Event.getCharCode(p_oEvent))) {
+
+ sType = this.get("type");
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.set("checked", !(this.get("checked")));
+
+ }
+
+ this._activationKeyPressed = false;
+
+ if (this.get("type") != "menu") {
+
+ this.removeStateCSSClasses("active");
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onClick
+ * @description "click" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onClick: function (p_oEvent) {
+
+ var sType = this.get("type"),
+ sTitle,
+ oForm,
+ oSrcElement,
+ oElement,
+ nX;
+
+
+ switch (sType) {
+
+ case "radio":
+ case "checkbox":
+
+ if (this.get("checked")) {
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_CHECKED_TITLE :
+ this.CHECKBOX_CHECKED_TITLE;
+
+ }
+ else {
+
+ sTitle = (sType == "radio") ?
+ this.RADIO_DEFAULT_TITLE :
+ this.CHECKBOX_DEFAULT_TITLE;
+
+ }
+
+ this.set("title", sTitle);
+
+ break;
+
+ case "submit":
+
+ this.submitForm();
+
+ break;
+
+ case "reset":
+
+ oForm = this.getForm();
+
+ if (oForm) {
+
+ oForm.reset();
+
+ }
+
+ break;
+
+ case "menu":
+
+ sTitle = this._menu.cfg.getProperty("visible") ?
+ this.MENUBUTTON_MENU_VISIBLE_TITLE :
+ this.MENUBUTTON_DEFAULT_TITLE;
+
+ this.set("title", sTitle);
+
+ break;
+
+ case "split":
+
+ oElement = this.get("element");
+ nX = Event.getPageX(p_oEvent) - Dom.getX(oElement);
+
+ if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) {
+
+ return false;
+
+ }
+ else {
+
+ this._hideMenu();
+
+ oSrcElement = this.get("srcelement");
+
+ if (oSrcElement && oSrcElement.type == "submit") {
+
+ this.submitForm();
+
+ }
+
+ }
+
+ sTitle = this._menu.cfg.getProperty("visible") ?
+ this.SPLITBUTTON_OPTION_VISIBLE_TITLE :
+ this.SPLITBUTTON_DEFAULT_TITLE;
+
+ this.set("title", sTitle);
+
+ break;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onAppendTo
+ * @description "appendTo" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onAppendTo: function (p_oEvent) {
+
+ /*
+ It is necessary to call "getForm" using "setTimeout" to make
+ sure that the button's "form" property returns a node
+ reference. Sometimes, if you try to get the reference
+ immediately after appending the field, it is null.
+ */
+
+ var me = this;
+
+ window.setTimeout(function () {
+
+ me._addListenersToForm();
+
+ }, 0);
+
+ },
+
+
+ /**
+ * @method _onFormReset
+ * @description "reset" event handler for the button's form.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event
+ * object passed back by the event utility (YAHOO.util.Event).
+ */
+ _onFormReset: function (p_oEvent) {
+
+ var sType = this.get("type"),
+ oMenu = this._menu;
+
+ if (sType == "checkbox" || sType == "radio") {
+
+ this.resetValue("checked");
+
+ }
+
+
+ if (oMenu && (oMenu instanceof Menu)) {
+
+ this.resetValue("selectedMenuItem");
+
+ }
+
+ },
+
+
+ /**
+ * @method _onDocumentMouseDown
+ * @description "mousedown" event handler for the document.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onDocumentMouseDown: function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ oButtonElement = this.get("element"),
+ oMenuElement = this._menu.element;
+
+ if (oTarget != oButtonElement &&
+ !Dom.isAncestor(oButtonElement, oTarget) &&
+ oTarget != oMenuElement &&
+ !Dom.isAncestor(oMenuElement, oTarget)) {
+
+ this._hideMenu();
+
+ Event.removeListener(document, "mousedown",
+ this._onDocumentMouseDown);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onOption
+ * @description "option" event handler for the button.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onOption: function (p_oEvent) {
+
+ if (this.hasClass("yui-split-button-activeoption")) {
+
+ this._hideMenu();
+
+ this._bOptionPressed = false;
+
+ }
+ else {
+
+ this._showMenu(p_oEvent);
+
+ this._bOptionPressed = true;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onOverlayBeforeShow
+ * @description "beforeshow" event handler for the
+ * YAHOO.widget.Overlay instance
+ * serving as the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onOverlayBeforeShow: function (p_sType) {
+
+ var oMenu = this._menu;
+
+ oMenu.render(this.get("element").parentNode);
+
+ oMenu.beforeShowEvent.unsubscribe(this._onOverlayBeforeShow);
+
+ },
+
+
+ /**
+ * @method _onMenuShow
+ * @description "show" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onMenuShow: function (p_sType) {
+
+ Event.on(document, "mousedown", this._onDocumentMouseDown,
+ null, this);
+
+ var sTitle,
+ sState;
+
+ if (this.get("type") == "split") {
+
+ sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE;
+ sState = "activeoption";
+
+ }
+ else {
+
+ sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE;
+ sState = "active";
+
+ }
+
+ this.addStateCSSClasses(sState);
+ this.set("title", sTitle);
+
+ },
+
+
+ /**
+ * @method _onMenuHide
+ * @description "hide" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the event
+ * that was fired.
+ */
+ _onMenuHide: function (p_sType) {
+
+ var oMenu = this._menu,
+ sTitle,
+ sState;
+
+ if (oMenu && (oMenu instanceof Menu) &&
+ this._originalMaxHeight != -1) {
+
+ this._menu.cfg.setProperty("maxheight",
+ this._originalMaxHeight);
+
+ }
+
+
+ if (this.get("type") == "split") {
+
+ sTitle = this.SPLITBUTTON_DEFAULT_TITLE;
+ sState = "activeoption";
+
+ }
+ else {
+
+ sTitle = this.MENUBUTTON_DEFAULT_TITLE;
+ sState = "active";
+ }
+
+
+ this.removeStateCSSClasses(sState);
+ this.set("title", sTitle);
+
+
+ if (this.get("type") == "split") {
+
+ this._bOptionPressed = false;
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuKeyDown
+ * @description "keydown" event handler for the button's 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.
+ */
+ _onMenuKeyDown: function (p_sType, p_aArgs) {
+
+ var oEvent = p_aArgs[0];
+
+ if (Event.getCharCode(oEvent) == 27) {
+
+ this.focus();
+
+ if (this.get("type") == "split") {
+
+ this._bOptionPressed = false;
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuRender
+ * @description "render" event handler for the button's menu.
+ * @private
+ * @param {String} p_sType String representing the name of the
+ * event thatwas fired.
+ */
+ _onMenuRender: function (p_sType) {
+
+ var oButtonElement = this.get("element"),
+ oButtonParent = oButtonElement.parentNode,
+ oMenuElement = this._menu.element;
+
+
+ if (oButtonParent != oMenuElement.parentNode) {
+
+ oButtonParent.appendChild(oMenuElement);
+
+ }
+
+ this.set("selectedMenuItem", this.get("selectedMenuItem"));
+
+ },
+
+
+ /**
+ * @method _onMenuItemSelected
+ * @description "selectedchange" event handler for each item in the
+ * button's 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 {Number} p_nItem Number representing the index of the menu
+ * item that subscribed to the event.
+ */
+ _onMenuItemSelected: function (p_sType, p_aArgs, p_nItem) {
+
+ var bSelected = p_aArgs[0];
+
+ if (bSelected) {
+
+ this.set("selectedMenuItem", p_nItem);
+
+ }
+
+ },
+
+
+ /**
+ * @method _onMenuItemAdded
+ * @description "itemadded" event handler for the button's 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.MenuItem } p_oItem Object representing the menu
+ * item that subscribed to the event.
+ */
+ _onMenuItemAdded: function (p_sType, p_aArgs, p_oItem) {
+
+ var oItem = p_aArgs[0];
+
+ oItem.cfg.subscribeToConfigEvent("selected",
+ this._onMenuItemSelected,
+ oItem.index,
+ this);
+
+ },
+
+
+ /**
+ * @method _onMenuClick
+ * @description "click" event handler for the button's 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.
+ */
+ _onMenuClick: function (p_sType, p_aArgs) {
+
+ var oItem = p_aArgs[1],
+ oSrcElement;
+
+ if (oItem) {
+
+ oSrcElement = this.get("srcelement");
+
+ if (oSrcElement && oSrcElement.type == "submit") {
+
+ this.submitForm();
+
+ }
+
+ this._hideMenu();
+
+ }
+
+ },
+
+
+
+ // Public methods
+
+
+ /**
+ * @method createButtonElement
+ * @description Creates the button's HTML elements.
+ * @param {String} p_sType String indicating the type of element
+ * to create.
+ * @return {HTMLElement }
+ */
+ createButtonElement: function (p_sType) {
+
+ var sNodeName = this.NODE_NAME,
+ oElement = document.createElement(sNodeName);
+
+ oElement.innerHTML = "<" + sNodeName + " class=\"first-child\">" +
+ (p_sType == "link" ? " " :
+ " ") + "" + sNodeName + ">";
+
+ return oElement;
+
+ },
+
+
+ /**
+ * @method addStateCSSClasses
+ * @description Appends state-specific CSS classes to the button's root
+ * DOM element.
+ */
+ addStateCSSClasses: function (p_sState) {
+
+ var sType = this.get("type");
+
+ if (Lang.isString(p_sState)) {
+
+ if (p_sState != "activeoption") {
+
+ this.addClass(this.CSS_CLASS_NAME + ("-" + p_sState));
+
+ }
+
+ this.addClass("yui-" + sType + ("-button-" + p_sState));
+
+ }
+
+ },
+
+
+ /**
+ * @method removeStateCSSClasses
+ * @description Removes state-specific CSS classes to the button's root
+ * DOM element.
+ */
+ removeStateCSSClasses: function (p_sState) {
+
+ var sType = this.get("type");
+
+ if (Lang.isString(p_sState)) {
+
+ this.removeClass(this.CSS_CLASS_NAME + ("-" + p_sState));
+ this.removeClass("yui-" + sType + ("-button-" + p_sState));
+
+ }
+
+ },
+
+
+ /**
+ * @method createHiddenFields
+ * @description Creates the button's hidden form field and appends it
+ * to its parent form.
+ * @return {HTMLInputElement |Array}
+ */
+ createHiddenFields: function () {
+
+ this.removeHiddenFields();
+
+ var oForm = this.getForm(),
+ oButtonField,
+ sType,
+ bCheckable,
+ oMenu,
+ oMenuItem,
+ sName,
+ oValue,
+ oMenuField;
+
+
+ if (oForm && !this.get("disabled")) {
+
+ sType = this.get("type");
+ bCheckable = (sType == "checkbox" || sType == "radio");
+
+
+ if (bCheckable || (m_oSubmitTrigger == this)) {
+
+
+ oButtonField = createInputElement(
+ (bCheckable ? sType : "hidden"),
+ this.get("name"),
+ this.get("value"),
+ this.get("checked"));
+
+
+ if (oButtonField) {
+
+ if (bCheckable) {
+
+ oButtonField.style.display = "none";
+
+ }
+
+ oForm.appendChild(oButtonField);
+
+ }
+
+ }
+
+
+ oMenu = this._menu;
+
+
+ if (oMenu && (oMenu instanceof Menu)) {
+
+
+ oMenuField = oMenu.srcElement;
+ oMenuItem = oMenu.getItem(this.get("selectedMenuItem"));
+
+ if (oMenuField &&
+ oMenuField.nodeName.toUpperCase() == "SELECT") {
+
+ oForm.appendChild(oMenuField);
+ oMenuField.selectedIndex = oMenuItem.index;
+
+ }
+ else {
+
+ oValue = (oMenuItem.value === null ||
+ oMenuItem.value === "") ?
+ oMenuItem.cfg.getProperty("text") :
+ oMenuItem.value;
+
+ sName = this.get("name");
+
+ if (oValue && sName) {
+
+ oMenuField = createInputElement("hidden",
+ (sName + "_options"),
+ oValue);
+
+ oForm.appendChild(oMenuField);
+
+ }
+
+ }
+
+ }
+
+
+ if (oButtonField && oMenuField) {
+
+ this._hiddenFields = [oButtonField, oMenuField];
+
+ }
+ else if (!oButtonField && oMenuField) {
+
+ this._hiddenFields = oMenuField;
+
+ }
+ else if (oButtonField && !oMenuField) {
+
+ this._hiddenFields = oButtonField;
+
+ }
+
+
+ return this._hiddenFields;
+
+ }
+
+ },
+
+
+ /**
+ * @method removeHiddenFields
+ * @description Removes the button's hidden form field(s) from its
+ * parent form.
+ */
+ removeHiddenFields: function () {
+
+ var oField = this._hiddenFields,
+ nFields,
+ i;
+
+ function removeChild(p_oElement) {
+
+ if (Dom.inDocument(p_oElement)) {
+
+ p_oElement.parentNode.removeChild(p_oElement);
+
+ }
+
+ }
+
+
+ if (oField) {
+
+ if (Lang.isArray(oField)) {
+
+ nFields = oField.length;
+
+ if (nFields > 0) {
+
+ i = nFields - 1;
+
+ do {
+
+ removeChild(oField[i]);
+
+ }
+ while (i--);
+
+ }
+
+ }
+ else {
+
+ removeChild(oField);
+
+ }
+
+ this._hiddenFields = null;
+
+ }
+
+ },
+
+
+ /**
+ * @method submitForm
+ * @description Submits the form to which the button belongs. Returns
+ * true if the form was submitted successfully, false if the submission
+ * was cancelled.
+ * @protected
+ * @return {Boolean}
+ */
+ submitForm: function () {
+
+ var oForm = this.getForm(),
+
+ oSrcElement = this.get("srcelement"),
+
+ /*
+ Boolean indicating if the event fired successfully
+ (was not cancelled by any handlers)
+ */
+
+ bSubmitForm = false,
+
+ oEvent;
+
+
+ if (oForm) {
+
+ if (this.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit"))
+ {
+
+ m_oSubmitTrigger = this;
+
+ }
+
+
+ if (YAHOO.env.ua.ie) {
+
+ bSubmitForm = oForm.fireEvent("onsubmit");
+
+ }
+ else { // Gecko, Opera, and Safari
+
+ oEvent = document.createEvent("HTMLEvents");
+ oEvent.initEvent("submit", true, true);
+
+ bSubmitForm = oForm.dispatchEvent(oEvent);
+
+ }
+
+
+ /*
+ In IE and Safari, dispatching a "submit" event to a form
+ WILL cause the form's "submit" event to fire, but WILL NOT
+ submit the form. Therefore, we need to call the "submit"
+ method as well.
+ */
+
+ if ((YAHOO.env.ua.ie || YAHOO.env.ua.webkit) && bSubmitForm) {
+
+ oForm.submit();
+
+ }
+
+ }
+
+ return bSubmitForm;
+
+ },
+
+
+ /**
+ * @method init
+ * @description The Button class's initialization method.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to
+ * be used to create the button.
+ * @param {HTMLInputElement |HTMLButtonElement |
+ * HTMLElement } p_oElement Object reference for the
+ * <input>
, <button>
,
+ * <a>
, or <span>
element to be
+ * used to create the button.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a
+ * set of configuration attributes used to create the button.
+ */
+ init: function (p_oElement, p_oAttributes) {
+
+ var sNodeName = p_oAttributes.type == "link" ? "A" : "BUTTON",
+ oSrcElement = p_oAttributes.srcelement,
+ oButton = p_oElement.getElementsByTagName(sNodeName)[0],
+ oInput;
+
+
+ if (!oButton) {
+
+ oInput = p_oElement.getElementsByTagName("INPUT")[0];
+
+
+ if (oInput) {
+
+ oButton = document.createElement("BUTTON");
+ oButton.setAttribute("type", "button");
+
+ oInput.parentNode.replaceChild(oButton, oInput);
+
+ }
+
+ }
+
+ this._button = oButton;
+
+
+ YAHOO.widget.Button.superclass.init.call(this, p_oElement,
+ p_oAttributes);
+
+
+ m_oButtons[this.get("id")] = this;
+
+
+ this.addClass(this.CSS_CLASS_NAME);
+
+ this.addClass("yui-" + this.get("type") + "-button");
+
+ Event.on(this._button, "focus", this._onFocus, null, this);
+ this.on("mouseover", this._onMouseOver);
+ this.on("click", this._onClick);
+ this.on("appendTo", this._onAppendTo);
+
+
+ var oContainer = this.get("container"),
+ oElement = this.get("element"),
+ bElInDoc = Dom.inDocument(oElement),
+ oParentNode;
+
+
+ if (oContainer) {
+
+ if (oSrcElement && oSrcElement != oElement) {
+
+ oParentNode = oSrcElement.parentNode;
+
+ if (oParentNode) {
+
+ oParentNode.removeChild(oSrcElement);
+
+ }
+
+ }
+
+ if (Lang.isString(oContainer)) {
+
+ Event.onContentReady(oContainer, function () {
+
+ this.appendTo(oContainer);
+
+ }, null, this);
+
+ }
+ else {
+
+ this.appendTo(oContainer);
+
+ }
+
+ }
+ else if (!bElInDoc && oSrcElement && oSrcElement != oElement) {
+
+ oParentNode = oSrcElement.parentNode;
+
+ if (oParentNode) {
+
+ this.fireEvent("beforeAppendTo", {
+ type: "beforeAppendTo",
+ target: oParentNode
+ });
+
+ oParentNode.replaceChild(oElement, oSrcElement);
+
+ this.fireEvent("appendTo", {
+ type: "appendTo",
+ target: oParentNode
+ });
+
+ }
+
+ }
+ else if (this.get("type") != "link" && bElInDoc && oSrcElement &&
+ oSrcElement == oElement) {
+
+ this._addListenersToForm();
+
+ }
+
+
+ },
+
+
+ /**
+ * @method initAttributes
+ * @description Initializes all of the configuration attributes used to
+ * create the button.
+ * @param {Object} p_oAttributes Object literal specifying a set of
+ * configuration attributes used to create the button.
+ */
+ initAttributes: function (p_oAttributes) {
+
+ var oAttributes = p_oAttributes || {};
+
+ YAHOO.widget.Button.superclass.initAttributes.call(this,
+ oAttributes);
+
+
+ /**
+ * @config type
+ * @description String specifying the button's type. Possible
+ * values are: "push," "link," "submit," "reset," "checkbox,"
+ * "radio," "menu," and "split."
+ * @default "push"
+ * @type String
+ */
+ this.setAttributeConfig("type", {
+
+ value: (oAttributes.type || "push"),
+ validator: Lang.isString,
+ writeOnce: true,
+ method: this._setType
+
+ });
+
+
+ /**
+ * @config label
+ * @description String specifying the button's text label
+ * or innerHTML.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("label", {
+
+ value: oAttributes.label,
+ validator: Lang.isString,
+ method: this._setLabel
+
+ });
+
+
+ /**
+ * @config value
+ * @description Object specifying the value for the button.
+ * @default null
+ * @type Object
+ */
+ this.setAttributeConfig("value", {
+
+ value: oAttributes.value
+
+ });
+
+
+ /**
+ * @config name
+ * @description String specifying the name for the button.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("name", {
+
+ value: oAttributes.name,
+ validator: Lang.isString
+
+ });
+
+
+ /**
+ * @config tabindex
+ * @description Number specifying the tabindex for the button.
+ * @default null
+ * @type Number
+ */
+ this.setAttributeConfig("tabindex", {
+
+ value: oAttributes.tabindex,
+ validator: Lang.isNumber,
+ method: this._setTabIndex
+
+ });
+
+
+ /**
+ * @config title
+ * @description String specifying the title for the button.
+ * @default null
+ * @type String
+ */
+ this.configureAttribute("title", {
+
+ value: oAttributes.title,
+ validator: Lang.isString,
+ method: this._setTitle
+
+ });
+
+
+ /**
+ * @config disabled
+ * @description Boolean indicating if the button should be disabled.
+ * (Disabled buttons are dimmed and will not respond to user input
+ * or fire events. Does not apply to button's of type "link.")
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("disabled", {
+
+ value: (oAttributes.disabled || false),
+ validator: Lang.isBoolean,
+ method: this._setDisabled
+
+ });
+
+
+ /**
+ * @config href
+ * @description String specifying the href for the button. Applies
+ * only to buttons of type "link."
+ * @type String
+ */
+ this.setAttributeConfig("href", {
+
+ value: oAttributes.href,
+ validator: Lang.isString,
+ method: this._setHref
+
+ });
+
+
+ /**
+ * @config target
+ * @description String specifying the target for the button.
+ * Applies only to buttons of type "link."
+ * @type String
+ */
+ this.setAttributeConfig("target", {
+
+ value: oAttributes.target,
+ validator: Lang.isString,
+ method: this._setTarget
+
+ });
+
+
+ /**
+ * @config checked
+ * @description Boolean indicating if the button is checked.
+ * Applies only to buttons of type "radio" and "checkbox."
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("checked", {
+
+ value: (oAttributes.checked || false),
+ validator: Lang.isBoolean,
+ method: this._setChecked
+
+ });
+
+
+ /**
+ * @config container
+ * @description HTML element reference or string specifying the id
+ * attribute of the HTML element that the button's markup should be
+ * rendered into.
+ * @type HTMLElement |String
+ * @default null
+ */
+ this.setAttributeConfig("container", {
+
+ value: oAttributes.container,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config srcelement
+ * @description Object reference to the HTML element (either
+ * <input>
or <span>
)
+ * used to create the button.
+ * @type HTMLElement |String
+ * @default null
+ */
+ this.setAttributeConfig("srcelement", {
+
+ value: oAttributes.srcelement,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config menu
+ * @description Object specifying the menu for the button.
+ * The value can be one of the following:
+ *
+ * Object specifying a
+ * YAHOO.widget.Menu instance.
+ * Object specifying a
+ * YAHOO.widget.Overlay instance.
+ * String specifying the id attribute of the <div>
+ *
element used to create the menu. By default the menu
+ * will be created as an instance of
+ * YAHOO.widget.Overlay .
+ * If the
+ * default CSS class name for YAHOO.widget.Menu is applied to
+ * the <div>
element, it will be created as an
+ * instance of YAHOO.widget.Menu
+ * . String specifying the id attribute of the
+ * <select>
element used to create the menu.
+ * Object specifying the <div>
element
+ * used to create the menu.
+ * Object specifying the <select>
element
+ * used to create the menu.
+ * Array of object literals, each representing a set of
+ * YAHOO.widget.MenuItem
+ * configuration attributes.
+ * Array of strings representing the text labels for each menu
+ * item in the menu.
+ *
+ * @type YAHOO.widget.Menu |YAHOO.widget.Overlay |HTMLElement |String|Array
+ * @default null
+ */
+ this.setAttributeConfig("menu", {
+
+ value: null,
+ method: this._setMenu,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config lazyloadmenu
+ * @description Boolean indicating the value to set for the
+ * "lazyload"
+ * configuration property of the button's menu. Setting
+ * "lazyloadmenu" to true
will defer rendering of
+ * the button's menu until the first time it is made visible.
+ * If "lazyloadmenu" is set to false
, the button's
+ * menu will be rendered immediately if the button is in the
+ * document, or in response to the button's "appendTo" event if
+ * the button is not yet in the document. In either case, the
+ * menu is rendered into the button's parent HTML element.
+ * This attribute does not apply if a
+ * YAHOO.widget.Menu or
+ * YAHOO.widget.Overlay
+ * instance is passed as the value of the button's "menu"
+ * configuration attribute.
+ * YAHOO.widget.Menu or
+ * YAHOO.widget.Overlay instances should be rendered before
+ * being set as the value for the "menu" configuration
+ * attribute.
+ * @default true
+ * @type Boolean
+ */
+ this.setAttributeConfig("lazyloadmenu", {
+
+ value: (oAttributes.lazyloadmenu === false ? false : true),
+ validator: Lang.isBoolean,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config menuclassname
+ * @description String representing the CSS class name to be
+ * applied to the root element of the button's menu.
+ * @type String
+ * @default "yui-button-menu"
+ */
+ this.setAttributeConfig("menuclassname", {
+
+ value: (oAttributes.menuclassname || "yui-button-menu"),
+ validator: Lang.isString,
+ method: this._setMenuClassName,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config selectedMenuItem
+ * @description Number representing the index of the item in the
+ * button's menu that is currently selected.
+ * @type Number
+ * @default null
+ */
+ this.setAttributeConfig("selectedMenuItem", {
+
+ value: 0,
+ validator: Lang.isNumber,
+ method: this._setSelectedMenuItem
+
+ });
+
+
+ /**
+ * @config onclick
+ * @description Object literal representing the code to be executed
+ * when the button is clicked. Format: {
+ * fn: Function, // The handler to call
+ * when the event fires. obj: Object,
+ * // An object to pass back to the handler.
+ * scope: Object // The object to use
+ * for the scope of the handler. }
+ * @type Object
+ * @default null
+ */
+ this.setAttributeConfig("onclick", {
+
+ value: oAttributes.onclick,
+ method: this._setOnClick
+
+ });
+
+
+ /**
+ * @config focusmenu
+ * @description Boolean indicating whether or not the button's menu
+ * should be focused when it is made visible.
+ * @type Boolean
+ * @default true
+ */
+ this.setAttributeConfig("focusmenu", {
+
+ value: (oAttributes.focusmenu === false ? false : true),
+ validator: Lang.isBoolean
+
+ });
+
+ },
+
+
+ /**
+ * @method focus
+ * @description Causes the button to receive the focus and fires the
+ * button's "focus" event.
+ */
+ focus: function () {
+
+ if (!this.get("disabled")) {
+
+ this._button.focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method blur
+ * @description Causes the button to lose focus and fires the button's
+ * "blur" event.
+ */
+ blur: function () {
+
+ if (!this.get("disabled")) {
+
+ this._button.blur();
+
+ }
+
+ },
+
+
+ /**
+ * @method hasFocus
+ * @description Returns a boolean indicating whether or not the button
+ * has focus.
+ * @return {Boolean}
+ */
+ hasFocus: function () {
+
+ return (m_oFocusedButton == this);
+
+ },
+
+
+ /**
+ * @method isActive
+ * @description Returns a boolean indicating whether or not the button
+ * is active.
+ * @return {Boolean}
+ */
+ isActive: function () {
+
+ return this.hasClass(this.CSS_CLASS_NAME + "-active");
+
+ },
+
+
+ /**
+ * @method getMenu
+ * @description Returns a reference to the button's menu.
+ * @return {
+ * YAHOO.widget.Overlay |YAHOO.widget.Menu }
+ */
+ getMenu: function () {
+
+ return this._menu;
+
+ },
+
+
+ /**
+ * @method getForm
+ * @description Returns a reference to the button's parent form.
+ * @return {HTMLFormElement }
+ */
+ getForm: function () {
+
+ return this._button.form;
+
+ },
+
+
+ /**
+ * @method getHiddenFields
+ * @description Returns an <input>
element or
+ * array of form elements used to represent the button when its parent
+ * form is submitted.
+ * @return {HTMLInputElement |Array}
+ */
+ getHiddenFields: function () {
+
+ return this._hiddenFields;
+
+ },
+
+
+ /**
+ * @method destroy
+ * @description Removes the button's element from its parent element and
+ * removes all event handlers.
+ */
+ destroy: function () {
+
+
+ var oElement = this.get("element"),
+ oParentNode = oElement.parentNode,
+ oMenu = this._menu;
+
+ if (oMenu) {
+
+
+ oMenu.destroy();
+
+ }
+
+
+ Event.purgeElement(oElement);
+ Event.purgeElement(this._button);
+ Event.removeListener(document, "mouseup", this._onDocumentMouseUp);
+ Event.removeListener(document, "keyup", this._onDocumentKeyUp);
+ Event.removeListener(document, "mousedown",
+ this._onDocumentMouseDown);
+
+
+ var oForm = this.getForm();
+
+ if (oForm) {
+
+ Event.removeListener(oForm, "reset", this._onFormReset);
+ Event.removeListener(oForm, "submit", this.createHiddenFields);
+
+ }
+
+
+ oParentNode.removeChild(oElement);
+
+
+ delete m_oButtons[this.get("id")];
+
+
+ },
+
+
+ fireEvent: function (p_sType , p_aArgs) {
+
+ // Disabled buttons should not respond to DOM events
+
+ if (this.DOM_EVENTS[p_sType] && this.get("disabled")) {
+
+ return;
+
+ }
+
+ YAHOO.widget.Button.superclass.fireEvent.call(this, p_sType,
+ p_aArgs);
+
+ },
+
+
+ /**
+ * @method toString
+ * @description Returns a string representing the button.
+ * @return {String}
+ */
+ toString: function () {
+
+ return ("Button " + this.get("id"));
+
+ }
+
+ });
+
+
+ /**
+ * @method YAHOO.widget.Button.onFormKeyPress
+ * @description "keypress" event handler for the button's form.
+ * @param {Event} p_oEvent Object representing the DOM event object passed
+ * back by the event utility (YAHOO.util.Event).
+ */
+ YAHOO.widget.Button.onFormKeyPress = function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ nCharCode = Event.getCharCode(p_oEvent),
+ sNodeName = oTarget.nodeName && oTarget.nodeName.toUpperCase(),
+ sType = oTarget.type,
+
+ /*
+ Boolean indicating if the form contains any enabled or
+ disabled YUI submit buttons
+ */
+
+ bFormContainsYUIButtons = false,
+
+ oButton,
+
+ oYUISubmitButton, // The form's first, enabled YUI submit button
+
+ /*
+ The form's first, enabled HTML submit button that precedes any
+ YUI submit button
+ */
+
+ oPrecedingSubmitButton,
+
+
+ /*
+ The form's first, enabled HTML submit button that follows a
+ YUI button
+ */
+
+ oFollowingSubmitButton;
+
+
+ function isSubmitButton(p_oElement) {
+
+ var sId,
+ oSrcElement;
+
+ switch (p_oElement.nodeName.toUpperCase()) {
+
+ case "INPUT":
+ case "BUTTON":
+
+ if (p_oElement.type == "submit" && !p_oElement.disabled) {
+
+ if (!bFormContainsYUIButtons &&
+ !oPrecedingSubmitButton) {
+
+ oPrecedingSubmitButton = p_oElement;
+
+ }
+
+ if (oYUISubmitButton && !oFollowingSubmitButton) {
+
+ oFollowingSubmitButton = p_oElement;
+
+ }
+
+ }
+
+ break;
+
+
+ default:
+
+ sId = p_oElement.id;
+
+ if (sId) {
+
+ oButton = m_oButtons[sId];
+
+ if (oButton) {
+
+ bFormContainsYUIButtons = true;
+
+ if (!oButton.get("disabled")) {
+
+ oSrcElement = oButton.get("srcelement");
+
+ if (!oYUISubmitButton &&
+ (oButton.get("type") == "submit" ||
+ (oSrcElement && oSrcElement.type == "submit")))
+ {
+
+ oYUISubmitButton = oButton;
+
+ }
+
+ }
+
+ }
+
+ }
+
+ break;
+
+ }
+
+ }
+
+
+ if (nCharCode == 13 && ((sNodeName == "INPUT" && (sType == "text" ||
+ sType == "password" || sType == "checkbox" || sType == "radio" ||
+ sType == "file") ) || sNodeName == "SELECT"))
+ {
+
+ Dom.getElementsBy(isSubmitButton, "*", this);
+
+
+ if (oPrecedingSubmitButton) {
+
+ /*
+ Need to set focus to the first enabled submit button
+ to make sure that IE includes its name and value
+ in the form's data set.
+ */
+
+ oPrecedingSubmitButton.focus();
+
+ }
+ else if (!oPrecedingSubmitButton && oYUISubmitButton) {
+
+ if (oFollowingSubmitButton) {
+
+ /*
+ Need to call "preventDefault" to ensure that
+ the name and value of the regular submit button
+ following the YUI button doesn't get added to the
+ form's data set when it is submitted.
+ */
+
+ Event.preventDefault(p_oEvent);
+
+ }
+
+ oYUISubmitButton.submitForm();
+
+ }
+
+ }
+
+ };
+
+
+ /**
+ * @method addHiddenFieldsToForm
+ * @description Searches the specified form and adds hidden fields for
+ * instances of YAHOO.widget.Button that are of type "radio," "checkbox,"
+ * "menu," and "split."
+ * @param {HTMLFormElement } p_oForm Object reference
+ * for the form to search.
+ */
+ YAHOO.widget.Button.addHiddenFieldsToForm = function (p_oForm) {
+
+ var aButtons = Dom.getElementsByClassName(
+ YAHOO.widget.Button.prototype.CSS_CLASS_NAME,
+ "*",
+ p_oForm),
+
+ nButtons = aButtons.length,
+ oButton,
+ sId,
+ i;
+
+ if (nButtons > 0) {
+
+
+ for (i = 0; i < nButtons; i++) {
+
+ sId = aButtons[i].id;
+
+ if (sId) {
+
+ oButton = m_oButtons[sId];
+
+ if (oButton) {
+
+ oButton.createHiddenFields();
+
+ }
+
+ }
+
+ }
+
+ }
+
+ };
+
+
+
+ // Events
+
+
+ /**
+ * @event focus
+ * @description Fires when the menu item receives focus. Passes back a
+ * single object representing the original DOM event object passed back by
+ * the event utility (YAHOO.util.Event) when the event was fired. See
+ * Element.addListener
+ * for more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+
+ /**
+ * @event blur
+ * @description Fires when the menu item loses the input focus. Passes back
+ * a single object representing the original DOM event object passed back by
+ * the event utility (YAHOO.util.Event) when the event was fired. See
+ * Element.addListener for
+ * more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+
+ /**
+ * @event option
+ * @description Fires when the user invokes the button's option. Passes
+ * back a single object representing the original DOM event (either
+ * "mousedown" or "keydown") that caused the "option" event to fire. See
+ * Element.addListener
+ * for more information on listening for this event.
+ * @type YAHOO.util.CustomEvent
+ */
+
+})();
+(function () {
+
+ // Shorthard for utilities
+
+ var Dom = YAHOO.util.Dom,
+ Event = YAHOO.util.Event,
+ Lang = YAHOO.lang,
+ Button = YAHOO.widget.Button,
+
+ // Private collection of radio buttons
+
+ m_oButtons = {};
+
+
+
+ /**
+ * The ButtonGroup class creates a set of buttons that are mutually
+ * exclusive; checking one button in the set will uncheck all others in the
+ * button group.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <div>
element of the button group.
+ * @param {HTMLDivElement } p_oElement Object
+ * specifying the <div>
element of the button group.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a set
+ * of configuration attributes used to create the button group.
+ * @namespace YAHOO.widget
+ * @class ButtonGroup
+ * @constructor
+ * @extends YAHOO.util.Element
+ */
+ YAHOO.widget.ButtonGroup = function (p_oElement, p_oAttributes) {
+
+ var fnSuperClass = YAHOO.widget.ButtonGroup.superclass.constructor,
+ sNodeName,
+ oElement,
+ sId;
+
+ if (arguments.length == 1 && !Lang.isString(p_oElement) &&
+ !p_oElement.nodeName) {
+
+ if (!p_oElement.id) {
+
+ sId = Dom.generateId();
+
+ p_oElement.id = sId;
+
+
+ }
+
+
+
+ fnSuperClass.call(this, (this._createGroupElement()), p_oElement);
+
+ }
+ else if (Lang.isString(p_oElement)) {
+
+ oElement = Dom.get(p_oElement);
+
+ if (oElement) {
+
+ if (oElement.nodeName.toUpperCase() == this.NODE_NAME) {
+
+
+ fnSuperClass.call(this, oElement, p_oAttributes);
+
+ }
+
+ }
+
+ }
+ else {
+
+ sNodeName = p_oElement.nodeName;
+
+ if (sNodeName && sNodeName == this.NODE_NAME) {
+
+ if (!p_oElement.id) {
+
+ p_oElement.id = Dom.generateId();
+
+
+ }
+
+
+ fnSuperClass.call(this, p_oElement, p_oAttributes);
+
+ }
+
+ }
+
+ };
+
+
+ YAHOO.extend(YAHOO.widget.ButtonGroup, YAHOO.util.Element, {
+
+
+ // Protected properties
+
+
+ /**
+ * @property _buttons
+ * @description Array of buttons in the button group.
+ * @default null
+ * @protected
+ * @type Array
+ */
+ _buttons: null,
+
+
+
+ // Constants
+
+
+ /**
+ * @property NODE_NAME
+ * @description The name of the tag to be used for the button
+ * group's element.
+ * @default "DIV"
+ * @final
+ * @type String
+ */
+ NODE_NAME: "DIV",
+
+
+ /**
+ * @property CSS_CLASS_NAME
+ * @description String representing the CSS class(es) to be applied
+ * to the button group's element.
+ * @default "yui-buttongroup"
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yui-buttongroup",
+
+
+
+ // Protected methods
+
+
+ /**
+ * @method _createGroupElement
+ * @description Creates the button group's element.
+ * @protected
+ * @return {HTMLDivElement }
+ */
+ _createGroupElement: function () {
+
+ var oElement = document.createElement(this.NODE_NAME);
+
+ return oElement;
+
+ },
+
+
+
+ // Protected attribute setter methods
+
+
+ /**
+ * @method _setDisabled
+ * @description Sets the value of the button groups's
+ * "disabled" attribute.
+ * @protected
+ * @param {Boolean} p_bDisabled Boolean indicating the value for
+ * the button group's "disabled" attribute.
+ */
+ _setDisabled: function (p_bDisabled) {
+
+ var nButtons = this.getCount(),
+ i;
+
+ if (nButtons > 0) {
+
+ i = nButtons - 1;
+
+ do {
+
+ this._buttons[i].set("disabled", p_bDisabled);
+
+ }
+ while (i--);
+
+ }
+
+ },
+
+
+
+ // Protected event handlers
+
+
+ /**
+ * @method _onKeyDown
+ * @description "keydown" event handler for the button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the DOM event object
+ * passed back by the event utility (YAHOO.util.Event).
+ */
+ _onKeyDown: function (p_oEvent) {
+
+ var oTarget = Event.getTarget(p_oEvent),
+ nCharCode = Event.getCharCode(p_oEvent),
+ sId = oTarget.parentNode.parentNode.id,
+ oButton = m_oButtons[sId],
+ nIndex = -1;
+
+
+ if (nCharCode == 37 || nCharCode == 38) {
+
+ nIndex = (oButton.index === 0) ?
+ (this._buttons.length - 1) : (oButton.index - 1);
+
+ }
+ else if (nCharCode == 39 || nCharCode == 40) {
+
+ nIndex = (oButton.index === (this._buttons.length - 1)) ?
+ 0 : (oButton.index + 1);
+
+ }
+
+
+ if (nIndex > -1) {
+
+ this.check(nIndex);
+ this.getButton(nIndex).focus();
+
+ }
+
+ },
+
+
+ /**
+ * @method _onAppendTo
+ * @description "appendTo" event handler for the button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the event that was fired.
+ */
+ _onAppendTo: function (p_oEvent) {
+
+ var aButtons = this._buttons,
+ nButtons = aButtons.length,
+ i;
+
+ for (i = 0; i < nButtons; i++) {
+
+ aButtons[i].appendTo(this.get("element"));
+
+ }
+
+ },
+
+
+ /**
+ * @method _onButtonCheckedChange
+ * @description "checkedChange" event handler for each button in the
+ * button group.
+ * @protected
+ * @param {Event} p_oEvent Object representing the event that was fired.
+ * @param {YAHOO.widget.Button }
+ * p_oButton Object representing the button that fired the event.
+ */
+ _onButtonCheckedChange: function (p_oEvent, p_oButton) {
+
+ var bChecked = p_oEvent.newValue,
+ oCheckedButton = this.get("checkedButton");
+
+ if (bChecked && oCheckedButton != p_oButton) {
+
+ if (oCheckedButton) {
+
+ oCheckedButton.set("checked", false, true);
+
+ }
+
+ this.set("checkedButton", p_oButton);
+ this.set("value", p_oButton.get("value"));
+
+ }
+ else if (oCheckedButton && !oCheckedButton.set("checked")) {
+
+ oCheckedButton.set("checked", true, true);
+
+ }
+
+ },
+
+
+
+ // Public methods
+
+
+ /**
+ * @method init
+ * @description The ButtonGroup class's initialization method.
+ * @param {String} p_oElement String specifying the id attribute of the
+ * <div>
element of the button group.
+ * @param {HTMLDivElement } p_oElement Object
+ * specifying the <div>
element of the button group.
+ * @param {Object} p_oElement Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ * @param {Object} p_oAttributes Optional. Object literal specifying a
+ * set of configuration attributes used to create the button group.
+ */
+ init: function (p_oElement, p_oAttributes) {
+
+ this._buttons = [];
+
+ YAHOO.widget.ButtonGroup.superclass.init.call(this, p_oElement,
+ p_oAttributes);
+
+ this.addClass(this.CSS_CLASS_NAME);
+
+
+ var aButtons = this.getElementsByClassName("yui-radio-button");
+
+
+ if (aButtons.length > 0) {
+
+
+ this.addButtons(aButtons);
+
+ }
+
+
+
+ function isRadioButton(p_oElement) {
+
+ return (p_oElement.type == "radio");
+
+ }
+
+ aButtons =
+ Dom.getElementsBy(isRadioButton, "input", this.get("element"));
+
+
+ if (aButtons.length > 0) {
+
+
+ this.addButtons(aButtons);
+
+ }
+
+ this.on("keydown", this._onKeyDown);
+ this.on("appendTo", this._onAppendTo);
+
+
+ var oContainer = this.get("container");
+
+ if (oContainer) {
+
+ if (Lang.isString(oContainer)) {
+
+ Event.onContentReady(oContainer, function () {
+
+ this.appendTo(oContainer);
+
+ }, null, this);
+
+ }
+ else {
+
+ this.appendTo(oContainer);
+
+ }
+
+ }
+
+
+
+ },
+
+
+ /**
+ * @method initAttributes
+ * @description Initializes all of the configuration attributes used to
+ * create the button group.
+ * @param {Object} p_oAttributes Object literal specifying a set of
+ * configuration attributes used to create the button group.
+ */
+ initAttributes: function (p_oAttributes) {
+
+ var oAttributes = p_oAttributes || {};
+
+ YAHOO.widget.ButtonGroup.superclass.initAttributes.call(
+ this, oAttributes);
+
+
+ /**
+ * @config name
+ * @description String specifying the name for the button group.
+ * This name will be applied to each button in the button group.
+ * @default null
+ * @type String
+ */
+ this.setAttributeConfig("name", {
+
+ value: oAttributes.name,
+ validator: Lang.isString
+
+ });
+
+
+ /**
+ * @config disabled
+ * @description Boolean indicating if the button group should be
+ * disabled. Disabling the button group will disable each button
+ * in the button group. Disabled buttons are dimmed and will not
+ * respond to user input or fire events.
+ * @default false
+ * @type Boolean
+ */
+ this.setAttributeConfig("disabled", {
+
+ value: (oAttributes.disabled || false),
+ validator: Lang.isBoolean,
+ method: this._setDisabled
+
+ });
+
+
+ /**
+ * @config value
+ * @description Object specifying the value for the button group.
+ * @default null
+ * @type Object
+ */
+ this.setAttributeConfig("value", {
+
+ value: oAttributes.value
+
+ });
+
+
+ /**
+ * @config container
+ * @description HTML element reference or string specifying the id
+ * attribute of the HTML element that the button group's markup
+ * should be rendered into.
+ * @type HTMLElement |String
+ * @default null
+ */
+ this.setAttributeConfig("container", {
+
+ value: oAttributes.container,
+ writeOnce: true
+
+ });
+
+
+ /**
+ * @config checkedButton
+ * @description Reference for the button in the button group that
+ * is checked.
+ * @type {YAHOO.widget.Button }
+ * @default null
+ */
+ this.setAttributeConfig("checkedButton", {
+
+ value: null
+
+ });
+
+ },
+
+
+ /**
+ * @method addButton
+ * @description Adds the button to the button group.
+ * @param {YAHOO.widget.Button }
+ * p_oButton Object reference for the
+ * YAHOO.widget.Button instance to be added to the button group.
+ * @param {String} p_oButton String specifying the id attribute of the
+ * <input>
or <span>
element
+ * to be used to create the button to be added to the button group.
+ * @param {HTMLInputElement |HTMLElement } p_oButton Object reference for the
+ * <input>
or <span>
element
+ * to be used to create the button to be added to the button group.
+ * @param {Object} p_oButton Object literal specifying a set of
+ * YAHOO.widget.Button
+ * configuration attributes used to configure the button to be added to
+ * the button group.
+ * @return {YAHOO.widget.Button }
+ */
+ addButton: function (p_oButton) {
+
+ var oButton,
+ oButtonElement,
+ oGroupElement,
+ nIndex,
+ sButtonName,
+ sGroupName;
+
+
+ if (p_oButton instanceof Button &&
+ p_oButton.get("type") == "radio") {
+
+ oButton = p_oButton;
+
+ }
+ else if (!Lang.isString(p_oButton) && !p_oButton.nodeName) {
+
+ p_oButton.type = "radio";
+
+ oButton = new Button(p_oButton);
+
+ }
+ else {
+
+ oButton = new Button(p_oButton, { type: "radio" });
+
+ }
+
+
+ if (oButton) {
+
+ nIndex = this._buttons.length;
+ sButtonName = oButton.get("name");
+ sGroupName = this.get("name");
+
+ oButton.index = nIndex;
+
+ this._buttons[nIndex] = oButton;
+ m_oButtons[oButton.get("id")] = oButton;
+
+
+ if (sButtonName != sGroupName) {
+
+ oButton.set("name", sGroupName);
+
+ }
+
+
+ if (this.get("disabled")) {
+
+ oButton.set("disabled", true);
+
+ }
+
+
+ if (oButton.get("checked")) {
+
+ this.set("checkedButton", oButton);
+
+ }
+
+
+ oButtonElement = oButton.get("element");
+ oGroupElement = this.get("element");
+
+ if (oButtonElement.parentNode != oGroupElement) {
+
+ oGroupElement.appendChild(oButtonElement);
+
+ }
+
+
+ oButton.on("checkedChange",
+ this._onButtonCheckedChange, oButton, this);
+
+
+ return oButton;
+
+ }
+
+ },
+
+
+ /**
+ * @method addButtons
+ * @description Adds the array of buttons to the button group.
+ * @param {Array} p_aButtons Array of
+ * YAHOO.widget.Button instances to be added
+ * to the button group.
+ * @param {Array} p_aButtons Array of strings specifying the id
+ * attribute of the <input>
or <span>
+ *
elements to be used to create the buttons to be added to the
+ * button group.
+ * @param {Array} p_aButtons Array of object references for the
+ * <input>
or <span>
elements
+ * to be used to create the buttons to be added to the button group.
+ * @param {Array} p_aButtons Array of object literals, each containing
+ * a set of YAHOO.widget.Button
+ * configuration attributes used to configure each button to be added
+ * to the button group.
+ * @return {Array}
+ */
+ addButtons: function (p_aButtons) {
+
+ var nButtons,
+ oButton,
+ aButtons,
+ i;
+
+ if (Lang.isArray(p_aButtons)) {
+
+ nButtons = p_aButtons.length;
+ aButtons = [];
+
+ if (nButtons > 0) {
+
+ for (i = 0; i < nButtons; i++) {
+
+ oButton = this.addButton(p_aButtons[i]);
+
+ if (oButton) {
+
+ aButtons[aButtons.length] = oButton;
+
+ }
+
+ }
+
+ if (aButtons.length > 0) {
+
+
+ return aButtons;
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method removeButton
+ * @description Removes the button at the specified index from the
+ * button group.
+ * @param {Number} p_nIndex Number specifying the index of the button
+ * to be removed from the button group.
+ */
+ removeButton: function (p_nIndex) {
+
+ var oButton = this.getButton(p_nIndex),
+ nButtons,
+ i;
+
+ if (oButton) {
+
+
+ this._buttons.splice(p_nIndex, 1);
+ delete m_oButtons[oButton.get("id")];
+
+ oButton.removeListener("checkedChange",
+ this._onButtonCheckedChange);
+
+ oButton.destroy();
+
+
+ nButtons = this._buttons.length;
+
+ if (nButtons > 0) {
+
+ i = this._buttons.length - 1;
+
+ do {
+
+ this._buttons[i].index = i;
+
+ }
+ while (i--);
+
+ }
+
+
+ }
+
+ },
+
+
+ /**
+ * @method getButton
+ * @description Returns the button at the specified index.
+ * @param {Number} p_nIndex The index of the button to retrieve from the
+ * button group.
+ * @return {YAHOO.widget.Button }
+ */
+ getButton: function (p_nIndex) {
+
+ if (Lang.isNumber(p_nIndex)) {
+
+ return this._buttons[p_nIndex];
+
+ }
+
+ },
+
+
+ /**
+ * @method getButtons
+ * @description Returns an array of the buttons in the button group.
+ * @return {Array}
+ */
+ getButtons: function () {
+
+ return this._buttons;
+
+ },
+
+
+ /**
+ * @method getCount
+ * @description Returns the number of buttons in the button group.
+ * @return {Number}
+ */
+ getCount: function () {
+
+ return this._buttons.length;
+
+ },
+
+
+ /**
+ * @method focus
+ * @description Sets focus to the button at the specified index.
+ * @param {Number} p_nIndex Number indicating the index of the button
+ * to focus.
+ */
+ focus: function (p_nIndex) {
+
+ var oButton,
+ nButtons,
+ i;
+
+ if (Lang.isNumber(p_nIndex)) {
+
+ oButton = this._buttons[p_nIndex];
+
+ if (oButton) {
+
+ oButton.focus();
+
+ }
+
+ }
+ else {
+
+ nButtons = this.getCount();
+
+ for (i = 0; i < nButtons; i++) {
+
+ oButton = this._buttons[i];
+
+ if (!oButton.get("disabled")) {
+
+ oButton.focus();
+ break;
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * @method check
+ * @description Checks the button at the specified index.
+ * @param {Number} p_nIndex Number indicating the index of the button
+ * to check.
+ */
+ check: function (p_nIndex) {
+
+ var oButton = this.getButton(p_nIndex);
+
+ if (oButton) {
+
+ oButton.set("checked", true);
+
+ }
+
+ },
+
+
+ /**
+ * @method destroy
+ * @description Removes the button group's element from its parent
+ * element and removes all event handlers.
+ */
+ destroy: function () {
+
+
+ var nButtons = this._buttons.length,
+ oElement = this.get("element"),
+ oParentNode = oElement.parentNode,
+ i;
+
+ if (nButtons > 0) {
+
+ i = this._buttons.length - 1;
+
+ do {
+
+ this._buttons[i].destroy();
+
+ }
+ while (i--);
+
+ }
+
+
+ Event.purgeElement(oElement);
+
+
+ oParentNode.removeChild(oElement);
+
+ },
+
+
+ /**
+ * @method toString
+ * @description Returns a string representing the button group.
+ * @return {String}
+ */
+ toString: function () {
+
+ return ("ButtonGroup " + this.get("id"));
+
+ }
+
+ });
+
+})();
+YAHOO.register("button", YAHOO.widget.Button, {version: "2.3.0", build: "442"});
diff --git a/lib/yui/calendar/README b/lib/yui/calendar/README
index d4fc65d143..3c04748c14 100755
--- a/lib/yui/calendar/README
+++ b/lib/yui/calendar/README
@@ -1,5 +1,38 @@
Calendar Release Notes
+*** version 2.3.0 ***
+
+ - Added checks to select, selectCell, deselect and deselectCell methods to ensure the Calendar/Calendar group was not set to an invalid state by programmatically selecting unselectable dates or cells.
+ - Added new locale configuration properties for the Month/Year label used in the Calendar header (MY_LABEL_MONTH_POSITION, MY_LABEL_YEAR_POSITION, MY_LABEL_YEAR_SUFFIX, MY_LABEL_MONTH_SUFFIX). Japan is an example locale, where customization of the Month/Year label is required.
+ - Changed "first", "last" class names to "first-of-type", "last-of-type", to avoid collision with YUI Grids' use of the "first" class name.
+ - Added public isDateOOB method, to check if a given date is outside of the minimum/maximum configuration dates of the Calendar.
+ - Deprecated YAHOO.widget.Calendar.browser, refactored to use YAHOO.env.ua instead.
+ - Removed overflow:hidden from default Calendar/CalendarGroup container for non-IE6 browsers to fix clipping issue with IE7 when CalendarGroup was inside a box with a specific width. overflow:hidden is still required for IE6 with an iframe shim.
+ - Added Opera container width calculation fix to CalendarGroup.show method, to fix incorrect wrapping when using a CalendarGroup which is initially rendered hidden (display:none). Previously this fix was only applied on render.
+
+*** version 2.2.2 ***
+
+ - Fixed problem with selected dates being shared across instances, when more than one Calendar/CalendarGroup was on the page
+
+*** version 2.2.1 ***
+
+ - Fixed problem with selectCell adding duplicate selected date entries for dates which were already selected
+ - Fixed problem with CalendarGroup iframe shim not covering the CalendarGroup title area
+ - Removed javascript:void(null) from close button and cell links which was interrupting form submission and firing onbeforeunload in IE
+ - Fixed problem with CalendarGroup getSelectedDates returning invalid results, when used in conjunction with the "selected" Config property (either passed in the constructor config argument or set seperately after construction)
+ - Refactored Calendar and CalendarGroup to improve performance, especially when working with a large number of instances in IE6
+
+*** version 2.2.0 ***
+
+ - Image customization can now be done through CSS. Images for Close, Left and Right Arrows are now pulled in using CSS defined in calendar.css and by default use relative paths to the images in the same directory as calendar.css.
+ - Deprecated Calendar.IMG_ROOT and NAV_ARROW_LEFT, NAV_ARROW_RIGHT configuration properties. Customizations based on older releases which set these properties will still function as expected.
+ - Deprecated CalendarGroup.CSS_2UPCLOSE. Calendar's Style.CSS_CLOSE property now represents the new default CSS class (calclose) for the close button. CSS_2UPCLOSE is still applied along with CSS_CLOSE to the new markup for the close button to support existing customizations of the CSS_2UPCLOSE CSS class (close-icon)
+ - Fixed problem with Safari setting Calendar pages to incorrect dates if the pages spanned a year boundary in CalendarGroups with 3 or more pages, due to a bug in Safari's implementation of Date setMonth
+ - Fixed problem with CalendarGroup setMonth rendering Calendar pages with incorrect dates in all browsers if current pages spanned year boundary
+ - Fixed incorrect CalendarGroup logging statement in calendar-debug.js
+ - Fixed domEventMap support for Safari versions prior to 2.0.2, caused by hasOwnProperty not being supported
+ - Removed unused private property : _pageDate from Calendar class
+
*** version 0.12.2 ***
- Corrected documentation for clearTime function to reflect the change from midnight to noon
diff --git a/lib/yui/calendar/assets/calendar-core.css b/lib/yui/calendar/assets/calendar-core.css
new file mode 100755
index 0000000000..d25fd0427f
--- /dev/null
+++ b/lib/yui/calendar/assets/calendar-core.css
@@ -0,0 +1,88 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+/**
+ * CORE
+ *
+ * This is the set of CSS rules required by Calendar to drive core functionality and structure.
+ * Changes to these rules may result in the Calendar not functioning or rendering correctly.
+ *
+ * They should not be modified for skinning.
+ **/
+
+/* CALENDAR BOUNDING BOX */
+.yui-calcontainer {
+ position:relative;
+ float:left;
+ _overflow:hidden; /* IE6 only, to clip iframe shim */
+}
+
+/* IFRAME SHIM */
+.yui-calcontainer iframe {
+ position:absolute;
+ border:none;
+ margin:0;padding:0;
+ z-index:0;
+ width:100%;
+ height:100%;
+ left:0px;
+ top:0px;
+}
+
+/* IFRAME SHIM IE6 only */
+.yui-calcontainer iframe.fixedsize {
+ width:50em;
+ height:50em;
+ top:-1px;
+ left:-1px;
+}
+
+/* BOUNDING BOX FOR EACH CALENDAR GROUP PAGE */
+.yui-calcontainer.multi .groupcal {
+ z-index:1;
+ float:left;
+ position:relative;
+}
+
+/* TITLE BAR */
+.yui-calcontainer .title {
+ position:relative;
+ z-index:1;
+}
+
+/* CLOSE ICON CONTAINER */
+.yui-calcontainer .close-icon {
+ position:absolute;
+ z-index:1;
+}
+
+/* CALENDAR TABLE */
+.yui-calendar {
+ position:relative;
+}
+
+/* NAVBAR LEFT ARROW CONTAINER */
+.yui-calendar .calnavleft {
+ position:absolute;
+ z-index:1;
+}
+
+/* NAVBAR RIGHT ARROW CONTAINER */
+.yui-calendar .calnavright {
+ position:absolute;
+ z-index:1;
+}
+
+/* NAVBAR TEXT CONTAINER */
+.yui-calendar .calheader {
+ position:relative;
+ width:100%;
+ text-align:center;
+}
+
+/* Specific changes for calendar running under fonts/reset */
+.yui-calendar .calbody a:hover {background:inherit;}
+p#clear {clear:left; padding-top:10px;}
\ No newline at end of file
diff --git a/lib/yui/calendar/assets/calendar.css b/lib/yui/calendar/assets/calendar.css
index b97a705362..377b93191d 100755
--- a/lib/yui/calendar/assets/calendar.css
+++ b/lib/yui/calendar/assets/calendar.css
@@ -1,28 +1,35 @@
/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-Version 0.12
+version: 2.3.0
*/
-
.yui-calcontainer {
position:relative;
padding:5px;
background-color:#F7F9FB;
border:1px solid #7B9EBD;
float:left;
- overflow:hidden;
+ _overflow:hidden; /* IE6 only, to clip iframe shim */
}
.yui-calcontainer iframe {
position:absolute;
border:none;
margin:0;padding:0;
- left:-1px;
- top:-1px;
z-index:0;
+ width:100%;
+ height:100%;
+ left:0px;
+ top:0px;
+}
+
+/* IE6 only */
+.yui-calcontainer iframe.fixedsize {
width:50em;
height:50em;
+ top:-1px;
+ left:-1px;
}
.yui-calcontainer.multi {
@@ -57,6 +64,13 @@ Version 0.12
z-index:1;
}
+.yui-calcontainer .calclose {
+ background: url("calx.gif") no-repeat;
+ width:17px;
+ height:13px;
+ cursor:pointer;
+}
+
/* Calendar element styles */
.yui-calendar {
@@ -73,7 +87,6 @@ Version 0.12
.yui-calendar .calnavleft {
position:absolute;
- background-repeat:no-repeat;
cursor:pointer;
top:2px;
bottom:0;
@@ -81,18 +94,19 @@ Version 0.12
height:12px;
left:2px;
z-index:1;
+ background: url("callt.gif") no-repeat;
}
.yui-calendar .calnavright {
position:absolute;
- background-repeat:no-repeat;
cursor:pointer;
top:2px;
bottom:0;
width:9px;
- height:12px;
+ height:12px;
right:2px;
z-index:1;
+ background: url("calrt.gif") no-repeat;
}
.yui-calendar td.calcell {
@@ -186,6 +200,6 @@ Version 0.12
border-right-width:2px;
}
-/*Specific changes for calendar running under fonts/reset */
-.yui-calendar a:hover {background:inherit;}
+/* Specific changes for calendar running under fonts/reset */
+.yui-calendar .calbody a:hover {background:inherit;}
p#clear {clear:left; padding-top:10px;}
diff --git a/lib/yui/calendar/assets/skins/sam/calendar-skin.css b/lib/yui/calendar/assets/skins/sam/calendar-skin.css
new file mode 100755
index 0000000000..66a6df4b11
--- /dev/null
+++ b/lib/yui/calendar/assets/skins/sam/calendar-skin.css
@@ -0,0 +1,231 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+/**
+ * SAM
+ *
+ * Skin colors used:
+ *
+ * - Control Border : 808080
+ * - Control Chrome : f2f2f2
+ * - Cell Borders : cccccc
+ * - Normal Cell BG : ffffff
+ * - Date Links : 0066cc
+ * - Selected Cells BG : b3d4ff
+ * - Cell Hover BG : 426fd9
+ * - Disabled BG : cccccc
+ * - Disabled Text Color : a6a6a6
+ **/
+
+/* CALENDAR BOUNDING BOX */
+.yui-skin-sam .yui-calcontainer {
+ background-color:#f2f2f2;
+ border:1px solid #808080;
+ padding:10px;
+}
+
+/* CALENDARGROUP BOUNDING BOX */
+.yui-skin-sam .yui-calcontainer.multi {
+ padding:0 5px 0 5px;
+}
+
+/* BOUNDING BOX FOR EACH CALENDAR GROUP PAGE */
+.yui-skin-sam .yui-calcontainer.multi .groupcal {
+ background-color:transparent;
+ border:none;
+ padding:10px 5px 10px 5px;
+ margin:0;
+}
+
+/* TITLE BAR */
+.yui-skin-sam .yui-calcontainer .title {
+ background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;
+ border-bottom:1px solid #cccccc;
+ font:100% sans-serif;
+ color:#000;
+ font-weight:bold;
+ height:auto;
+ padding:.4em;
+ margin:0 -10px 10px -10px;
+ top:0;
+ left:0;
+ text-align:left;
+}
+
+.yui-skin-sam .yui-calcontainer.multi .title {
+ margin:0 -5px 0 -5px;
+}
+
+.yui-skin-sam .yui-calcontainer.withtitle {
+ padding-top:0;
+}
+
+/* CLOSE BUTTON */
+.yui-skin-sam .yui-calcontainer .calclose {
+ background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -300px;
+ width:25px;
+ height:15px;
+ top:.4em;
+ right:.4em;
+ cursor:pointer;
+}
+
+/* CALENDAR TABLE */
+.yui-skin-sam .yui-calendar {
+ border-spacing:0;
+ border-collapse:collapse;
+ font:100% sans-serif;
+ text-align:center;
+}
+
+/* NAVBAR BOUNDING BOX */
+.yui-skin-sam .yui-calendar .calhead {
+ background:transparent;
+ border:none;
+ vertical-align:middle;
+}
+
+/* NAVBAR TEXT CONTAINER */
+.yui-skin-sam .yui-calendar .calheader {
+ background:transparent;
+ font-weight:bold;
+ padding:0 0 .6em 0;
+ text-align:center;
+}
+
+.yui-skin-sam .yui-calendar .calheader img {
+ border:none;
+}
+
+/* NAVBAR LEFT ARROW */
+.yui-skin-sam .yui-calendar .calnavleft {
+ background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -450px;
+ width:25px;
+ height:15px;
+ top:0;
+ bottom:0;
+ left:-10px;
+ margin-left:.4em;
+ cursor:pointer;
+}
+
+/* NAVBAR RIGHT ARROW */
+.yui-skin-sam .yui-calendar .calnavright {
+ background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -500px;
+ width:25px;
+ height:15px;
+ top:0;
+ bottom:0;
+ right:-10px;
+ margin-right:.4em;
+ cursor:pointer;
+}
+
+/* WEEKDAY HEADER ROW */
+.yui-skin-sam .yui-calendar .calweekdayrow {
+ height:2em;
+}
+
+/* WEEKDAY (Su, Mo, Tu...) HEADER CELLS */
+.yui-skin-sam .yui-calendar .calweekdaycell {
+ color:#000;
+ font-weight:bold;
+ text-align:center;
+ width:2em;
+}
+
+/* CALENDAR FOOTER. NOT IMPLEMENTED BY DEFAULT */
+.yui-skin-sam .yui-calendar .calfoot {
+ background-color:#f2f2f2;
+}
+
+/* WEEK NUMBERS (ROW HEADERS/FOOTERS) */
+.yui-skin-sam .yui-calendar .calrowhead, .yui-skin-sam .yui-calendar .calrowfoot {
+ color:#a6a6a6;
+ font-size:85%;
+ font-style:normal;
+ font-weight:normal;
+}
+
+.yui-skin-sam .yui-calendar .calrowhead {
+ text-align:right;
+ padding-right:2px;
+}
+
+.yui-skin-sam .yui-calendar .calrowfoot {
+ text-align:left;
+ padding-left:2px;
+}
+
+/* NORMAL CELLS */
+.yui-skin-sam .yui-calendar td.calcell {
+ border:1px solid #cccccc;
+ background:#fff;
+ padding:1px;
+ height:1.6em;
+ line-height:1.6em; /* set line height equal to cell height to center vertically */
+ text-align:center;
+ white-space:nowrap;
+}
+
+/* LINK INSIDE NORMAL CELLS */
+.yui-skin-sam .yui-calendar td.calcell a {
+ color:#0066cc;
+ display:block;
+ height:100%;
+ text-decoration:none;
+}
+
+/* TODAY'S DATE */
+.yui-skin-sam .yui-calendar td.calcell.today {
+ background-color:#000;
+}
+
+.yui-skin-sam .yui-calendar td.calcell.today a {
+ background-color:#fff;
+}
+
+/* OOM DATES */
+.yui-skin-sam .yui-calendar td.calcell.oom {
+ background-color:#cccccc;
+ color:#a6a6a6;
+ cursor:default;
+}
+
+/* SELECTED DATE */
+.yui-skin-sam .yui-calendar td.calcell.selected {
+ background-color:#fff;
+ color:#000;
+}
+
+.yui-skin-sam .yui-calendar td.calcell.selected a {
+ background-color:#b3d4ff;
+ color:#000;
+}
+
+/* HOVER DATE */
+.yui-skin-sam .yui-calendar td.calcell.calcellhover {
+ background-color:#426fd9;
+ color:#fff;
+ cursor:pointer;
+}
+
+.yui-skin-sam .yui-calendar td.calcell.calcellhover a {
+ background-color:#426fd9;
+ color:#fff;
+}
+
+/* DEFAULT OOB DATES */
+.yui-skin-sam .yui-calendar td.calcell.previous {
+ color:#e0e0e0;
+}
+
+/* CUSTOM RENDERERS */
+.yui-skin-sam .yui-calendar td.calcell.restricted { text-decoration:line-through; }
+.yui-skin-sam .yui-calendar td.calcell.highlight1 { background-color:#ccff99; }
+.yui-skin-sam .yui-calendar td.calcell.highlight2 { background-color:#99ccff; }
+.yui-skin-sam .yui-calendar td.calcell.highlight3 { background-color:#ffcccc; }
+.yui-skin-sam .yui-calendar td.calcell.highlight4 { background-color:#ccff99; }
\ No newline at end of file
diff --git a/lib/yui/calendar/assets/skins/sam/calendar.css b/lib/yui/calendar/assets/skins/sam/calendar.css
new file mode 100755
index 0000000000..2b6d11a196
--- /dev/null
+++ b/lib/yui/calendar/assets/skins/sam/calendar.css
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.3.0
+*/
+.yui-calcontainer{position:relative;float:left;_overflow:hidden;}.yui-calcontainer iframe{position:absolute;border:none;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0px;top:0px;}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px;}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative;}.yui-calcontainer .title{position:relative;z-index:1;}.yui-calcontainer .close-icon{position:absolute;z-index:1;}.yui-calendar{position:relative;}.yui-calendar .calnavleft{position:absolute;z-index:1;}.yui-calendar .calnavright{position:absolute;z-index:1;}.yui-calendar .calheader{position:relative;width:100%;text-align:center;}.yui-calendar .calbody a:hover{background:inherit;}p#clear{clear:left;padding-top:10px;}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px;}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px;}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:none;padding:10px 5px 10px 5px;margin:0;}.yui-skin-sam .yui-calcontainer .title{background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;border-bottom:1px solid #cccccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left;}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px;}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0;}.yui-skin-sam .yui-calcontainer .calclose{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:none;vertical-align:middle;}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center;}.yui-skin-sam .yui-calendar .calheader img{border:none;}.yui-skin-sam .yui-calendar .calnavleft{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calnavright{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em;}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em;}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2;}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding-right:2px;}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding-left:2px;}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #cccccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap;}.yui-skin-sam .yui-calendar td.calcell a{color:#0066cc;display:block;height:100%;text-decoration:none;}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000;}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff;}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#cccccc;color:#a6a6a6;cursor:default;}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer;}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff;}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0;}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through;}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#ccff99;}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#99ccff;}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#ffcccc;}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#ccff99;}
diff --git a/lib/yui/calendar/calendar-debug.js b/lib/yui/calendar/calendar-debug.js
index 622feef52e..47a54b3d7d 100755
--- a/lib/yui/calendar/calendar-debug.js
+++ b/lib/yui/calendar/calendar-debug.js
@@ -1,487 +1,701 @@
/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Copyright (c) 2007, 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;i 0) {
+
+ i = nSubscribers - 1;
+
+ do {
+
+ subsc = evt.subscribers[i];
+
+ if (subsc && subsc.obj == obj && subsc.fn == fn) {
+
+ return true;
+
+ }
+
+ }
+ while (i--);
+
+ }
+
+ return false;
+
+ };
+
+ YAHOO.lang.augmentProto(Config, YAHOO.util.EventProvider);
+
+}());
/**
* YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility
@@ -676,7 +890,6 @@ YAHOO.widget.DateMath = {
* @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) {
@@ -757,7 +970,7 @@ YAHOO.widget.DateMath = {
};
/**
-* 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.
+* 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 or multi-month interface. Calendars are generated entirely via script and can be navigated without any page refreshes.
* @module calendar
* @title Calendar
* @namespace YAHOO.widget
@@ -774,7 +987,6 @@ YAHOO.widget.DateMath = {
*
*
*
-* Note that the table can be replaced with any kind of element.
*
* @namespace YAHOO.widget
* @class Calendar
@@ -791,9 +1003,10 @@ YAHOO.widget.Calendar = function(id, containerId, config) {
* The path to be used for images loaded for the Calendar
* @property YAHOO.widget.Calendar.IMG_ROOT
* @static
+* @deprecated You can now customize images by overriding the calclose, calnavleft and calnavright default CSS classes for the close icon, left arrow and right arrow respectively
* @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/");
+YAHOO.widget.Calendar.IMG_ROOT = null;
/**
* Type constant used for renderers to represent an individual date (M/D/Y)
@@ -858,6 +1071,153 @@ YAHOO.widget.Calendar.DISPLAY_DAYS = 42;
*/
YAHOO.widget.Calendar.STOP_RENDER = "S";
+/**
+* Constant used to represent short date field string formats (e.g. Tu or Feb)
+* @property YAHOO.widget.Calendar.SHORT
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.SHORT = "short";
+
+/**
+* Constant used to represent long date field string formats (e.g. Monday or February)
+* @property YAHOO.widget.Calendar.LONG
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.LONG = "long";
+
+/**
+* Constant used to represent medium date field string formats (e.g. Mon)
+* @property YAHOO.widget.Calendar.MEDIUM
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.MEDIUM = "medium";
+
+/**
+* Constant used to represent single character date field string formats (e.g. M, T, W)
+* @property YAHOO.widget.Calendar.ONE_CHAR
+* @static
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar.ONE_CHAR = "1char";
+
+/**
+* The set of default Config property keys and values for the Calendar
+* @property YAHOO.widget.Calendar._DEFAULT_CONFIG
+* @final
+* @static
+* @private
+* @type Object
+*/
+YAHOO.widget.Calendar._DEFAULT_CONFIG = {
+ // Default values for pagedate and selected are not class level constants - they are set during instance creation
+ PAGEDATE : {key:"pagedate", value:null},
+ SELECTED : {key:"selected", value:null},
+ TITLE : {key:"title", value:""},
+ CLOSE : {key:"close", value:false},
+ IFRAME : {key:"iframe", value:(YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) ? true : false},
+ MINDATE : {key:"mindate", value:null},
+ MAXDATE : {key:"maxdate", value:null},
+ MULTI_SELECT : {key:"multi_select", value:false},
+ START_WEEKDAY : {key:"start_weekday", value:0},
+ SHOW_WEEKDAYS : {key:"show_weekdays", value:true},
+ SHOW_WEEK_HEADER : {key:"show_week_header", value:false},
+ SHOW_WEEK_FOOTER : {key:"show_week_footer", value:false},
+ HIDE_BLANK_WEEKS : {key:"hide_blank_weeks", value:false},
+ NAV_ARROW_LEFT: {key:"nav_arrow_left", value:null} ,
+ NAV_ARROW_RIGHT : {key:"nav_arrow_right", value:null} ,
+ MONTHS_SHORT : {key:"months_short", value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]},
+ MONTHS_LONG: {key:"months_long", value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]},
+ WEEKDAYS_1CHAR: {key:"weekdays_1char", value:["S", "M", "T", "W", "T", "F", "S"]},
+ WEEKDAYS_SHORT: {key:"weekdays_short", value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]},
+ WEEKDAYS_MEDIUM: {key:"weekdays_medium", value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]},
+ WEEKDAYS_LONG: {key:"weekdays_long", value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]},
+ LOCALE_MONTHS:{key:"locale_months", value:"long"},
+ LOCALE_WEEKDAYS:{key:"locale_weekdays", value:"short"},
+ DATE_DELIMITER:{key:"date_delimiter", value:","},
+ DATE_FIELD_DELIMITER:{key:"date_field_delimiter", value:"/"},
+ DATE_RANGE_DELIMITER:{key:"date_range_delimiter", value:"-"},
+ MY_MONTH_POSITION:{key:"my_month_position", value:1},
+ MY_YEAR_POSITION:{key:"my_year_position", value:2},
+ MD_MONTH_POSITION:{key:"md_month_position", value:1},
+ MD_DAY_POSITION:{key:"md_day_position", value:2},
+ MDY_MONTH_POSITION:{key:"mdy_month_position", value:1},
+ MDY_DAY_POSITION:{key:"mdy_day_position", value:2},
+ MDY_YEAR_POSITION:{key:"mdy_year_position", value:3},
+ MY_LABEL_MONTH_POSITION:{key:"my_label_month_position", value:1},
+ MY_LABEL_YEAR_POSITION:{key:"my_label_year_position", value:2},
+ MY_LABEL_MONTH_SUFFIX:{key:"my_label_month_suffix", value:" "},
+ MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix", value:""}
+};
+
+/**
+* The set of Custom Event types supported by the Calendar
+* @property YAHOO.widget.Calendar._EVENT_TYPES
+* @final
+* @static
+* @private
+* @type Object
+*/
+YAHOO.widget.Calendar._EVENT_TYPES = {
+ BEFORE_SELECT : "beforeSelect",
+ SELECT : "select",
+ BEFORE_DESELECT : "beforeDeselect",
+ DESELECT : "deselect",
+ CHANGE_PAGE : "changePage",
+ BEFORE_RENDER : "beforeRender",
+ RENDER : "render",
+ RESET : "reset",
+ CLEAR : "clear"
+};
+
+/**
+* The set of default style constants for the Calendar
+* @property YAHOO.widget.Calendar._STYLES
+* @final
+* @static
+* @private
+* @type Object
+*/
+YAHOO.widget.Calendar._STYLES = {
+ CSS_ROW_HEADER: "calrowhead",
+ CSS_ROW_FOOTER: "calrowfoot",
+ CSS_CELL : "calcell",
+ CSS_CELL_SELECTOR : "selector",
+ CSS_CELL_SELECTED : "selected",
+ CSS_CELL_SELECTABLE : "selectable",
+ CSS_CELL_RESTRICTED : "restricted",
+ CSS_CELL_TODAY : "today",
+ CSS_CELL_OOM : "oom",
+ CSS_CELL_OOB : "previous",
+ CSS_HEADER : "calheader",
+ CSS_HEADER_TEXT : "calhead",
+ CSS_BODY : "calbody",
+ CSS_WEEKDAY_CELL : "calweekdaycell",
+ CSS_WEEKDAY_ROW : "calweekdayrow",
+ CSS_FOOTER : "calfoot",
+ CSS_CALENDAR : "yui-calendar",
+ CSS_SINGLE : "single",
+ CSS_CONTAINER : "yui-calcontainer",
+ CSS_NAV_LEFT : "calnavleft",
+ CSS_NAV_RIGHT : "calnavright",
+ CSS_CLOSE : "calclose",
+ CSS_CELL_TOP : "calcelltop",
+ CSS_CELL_LEFT : "calcellleft",
+ CSS_CELL_RIGHT : "calcellright",
+ CSS_CELL_BOTTOM : "calcellbottom",
+ CSS_CELL_HOVER : "calcellhover",
+ CSS_CELL_HIGHLIGHT1 : "highlight1",
+ CSS_CELL_HIGHLIGHT2 : "highlight2",
+ CSS_CELL_HIGHLIGHT3 : "highlight3",
+ CSS_CELL_HIGHLIGHT4 : "highlight4"
+};
+
YAHOO.widget.Calendar.prototype = {
/**
@@ -933,14 +1293,6 @@ YAHOO.widget.Calendar.prototype = {
*/
_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
@@ -967,17 +1319,14 @@ YAHOO.widget.Calendar.prototype = {
* @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.logger = new YAHOO.widget.LogWriter("Calendar " + 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");
- }
+ if (! this.oDomContainer) { this.logger.log("No valid container present.", "error"); }
/**
* The Config object used to hold the configuration variables for the Calendar
@@ -1004,7 +1353,7 @@ YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) {
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 = [];
@@ -1020,30 +1369,41 @@ YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) {
};
/**
-* Renders the built-in IFRAME shim for the IE6 and below
+* Default Config listener for the iframe property. If the iframe config property is set to true,
+* renders the built-in IFRAME shim if the container is relatively or absolutely positioned.
+*
* @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.parent) {
+ if (YAHOO.util.Dom.inDocument(this.oDomContainer)) {
+ if (useIframe) {
+ var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position");
+
+ if (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");
+
+ if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) {
+ YAHOO.util.Dom.addClass(this.iframe, "fixedsize");
+ }
- 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);
+ this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild);
+ }
}
- }
- } else {
- if (this.iframe) {
- if (this.iframe.parentNode) {
- this.iframe.parentNode.removeChild(this.iframe);
+ } else {
+ if (this.iframe) {
+ if (this.iframe.parentNode) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+ this.iframe = null;
}
- this.iframe = null;
}
}
}
@@ -1055,7 +1415,7 @@ YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) {
*/
YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) {
var title = args[0];
- var close = this.cfg.getProperty("close");
+ var close = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.CLOSE.key);
var titleDiv;
@@ -1084,24 +1444,31 @@ YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) {
*/
YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) {
var close = args[0];
- var title = this.cfg.getProperty("title");
+ var title = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.TITLE.key);
+
+ var DEPR_CLOSE_PATH = "us/my/bn/x_d.gif";
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.href = "#";
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);
+ YAHOO.util.Event.addListener(linkClose, "click", function(e, cal) {cal.hide(); YAHOO.util.Event.preventDefault(e); }, this);
+
+ if (YAHOO.widget.Calendar.IMG_ROOT !== null) {
+ var imgClose = document.createElement("img");
+ imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + DEPR_CLOSE_PATH;
+ imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;
+ linkClose.appendChild(imgClose);
+ } else {
+ linkClose.innerHTML = ' ';
+ }
+
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);
@@ -1118,61 +1485,63 @@ YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) {
*/
YAHOO.widget.Calendar.prototype.initEvents = function() {
+ var defEvents = YAHOO.widget.Calendar._EVENT_TYPES;
+
/**
* Fired before a selection is made
* @event beforeSelectEvent
*/
- this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect");
+ this.beforeSelectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SELECT);
/**
* 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");
+ this.selectEvent = new YAHOO.util.CustomEvent(defEvents.SELECT);
/**
* Fired before a selection is made
* @event beforeDeselectEvent
*/
- this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect");
+ this.beforeDeselectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_DESELECT);
/**
* 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");
+ this.deselectEvent = new YAHOO.util.CustomEvent(defEvents.DESELECT);
/**
* Fired when the Calendar page is changed
* @event changePageEvent
*/
- this.changePageEvent = new YAHOO.util.CustomEvent("changePage");
+ this.changePageEvent = new YAHOO.util.CustomEvent(defEvents.CHANGE_PAGE);
/**
* Fired before the Calendar is rendered
* @event beforeRenderEvent
*/
- this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER);
/**
* Fired when the Calendar is rendered
* @event renderEvent
*/
- this.renderEvent = new YAHOO.util.CustomEvent("render");
+ this.renderEvent = new YAHOO.util.CustomEvent(defEvents.RENDER);
/**
* Fired when the Calendar is reset
* @event resetEvent
*/
- this.resetEvent = new YAHOO.util.CustomEvent("reset");
+ this.resetEvent = new YAHOO.util.CustomEvent(defEvents.RESET);
/**
* Fired when the Calendar is cleared
* @event clearEvent
*/
- this.clearEvent = new YAHOO.util.CustomEvent("clear");
+ this.clearEvent = new YAHOO.util.CustomEvent(defEvents.CLEAR);
this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true);
this.selectEvent.subscribe(this.onSelect, this, true);
@@ -1184,7 +1553,6 @@ YAHOO.widget.Calendar.prototype.initEvents = function() {
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.
@@ -1193,17 +1561,30 @@ YAHOO.widget.Calendar.prototype.initEvents = function() {
* @param {Calendar} cal A reference to the calendar passed by the Event utility
*/
YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) {
+ var cell,index,d,date;
+
var target = YAHOO.util.Event.getTarget(e);
+ var tagName = target.tagName.toLowerCase();
+ var defSelector = false;
- var cell,index,d,date;
+ while (tagName != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
+
+ if (!defSelector && tagName == "a" && YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTOR)) {
+ defSelector = true;
+ }
- while (target.tagName.toLowerCase() != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
target = target.parentNode;
- if (target.tagName.toLowerCase() == "html") {
+ tagName = target.tagName.toLowerCase();
+ if (tagName == "html") {
return;
}
}
-
+
+ if (defSelector) {
+ // Stop link href navigation for default renderer
+ YAHOO.util.Event.preventDefault(e);
+ }
+
cell = target;
if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) {
@@ -1214,22 +1595,21 @@ YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) {
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) {
@@ -1294,13 +1674,15 @@ YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) {
YAHOO.widget.Calendar.prototype.setupConfig = function() {
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+
/**
* 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 } );
+ this.cfg.addProperty(defCfg.PAGEDATE.key, { value:new Date(), handler:this.configPageDate } );
/**
* The date or range of dates representing the current Calendar selection
@@ -1308,7 +1690,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type String
* @default []
*/
- this.cfg.addProperty("selected", { value:[], handler:this.configSelected } );
+ this.cfg.addProperty(defCfg.SELECTED.key, { value:[], handler:this.configSelected } );
/**
* The title to display above the Calendar's month header
@@ -1316,7 +1698,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type String
* @default ""
*/
- this.cfg.addProperty("title", { value:"", handler:this.configTitle } );
+ this.cfg.addProperty(defCfg.TITLE.key, { value:defCfg.TITLE.value, handler:this.configTitle } );
/**
* Whether or not a close button should be displayed for this Calendar
@@ -1324,15 +1706,18 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Boolean
* @default false
*/
- this.cfg.addProperty("close", { value:false, handler:this.configClose } );
+ this.cfg.addProperty(defCfg.CLOSE.key, { value:defCfg.CLOSE.value, 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.
+ * This property is enabled by default for IE6 and below. It is disabled by default for other browsers for performance reasons, but can be
+ * enabled if required.
+ *
* @config iframe
* @type Boolean
- * @default true
+ * @default true for IE6 and below, false for all other browsers
*/
- this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } );
+ this.cfg.addProperty(defCfg.IFRAME.key, { value:defCfg.IFRAME.value, handler:this.configIframe, validator:this.cfg.checkBoolean } );
/**
* The minimum selectable date in the current Calendar (mm/dd/yyyy)
@@ -1340,7 +1725,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type String
* @default null
*/
- this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } );
+ this.cfg.addProperty(defCfg.MINDATE.key, { value:defCfg.MINDATE.value, handler:this.configMinDate } );
/**
* The maximum selectable date in the current Calendar (mm/dd/yyyy)
@@ -1348,7 +1733,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type String
* @default null
*/
- this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } );
+ this.cfg.addProperty(defCfg.MAXDATE.key, { value:defCfg.MAXDATE.value, handler:this.configMaxDate } );
// Options properties
@@ -1359,7 +1744,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Boolean
* @default false
*/
- this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+ this.cfg.addProperty(defCfg.MULTI_SELECT.key, { value:defCfg.MULTI_SELECT.value, handler:this.configOptions, validator:this.cfg.checkBoolean } );
/**
* The weekday the week begins on. Default is 0 (Sunday).
@@ -1367,7 +1752,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type number
* @default 0
*/
- this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.configOptions, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty(defCfg.START_WEEKDAY.key, { value:defCfg.START_WEEKDAY.value, handler:this.configOptions, validator:this.cfg.checkNumber } );
/**
* True if the Calendar should show weekday labels. True by default.
@@ -1375,7 +1760,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Boolean
* @default true
*/
- this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+ this.cfg.addProperty(defCfg.SHOW_WEEKDAYS.key, { value:defCfg.SHOW_WEEKDAYS.value, handler:this.configOptions, validator:this.cfg.checkBoolean } );
/**
* True if the Calendar should show week row headers. False by default.
@@ -1383,7 +1768,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Boolean
* @default false
*/
- this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+ this.cfg.addProperty(defCfg.SHOW_WEEK_HEADER.key, { value:defCfg.SHOW_WEEK_HEADER.value, handler:this.configOptions, validator:this.cfg.checkBoolean } );
/**
* True if the Calendar should show week row footers. False by default.
@@ -1391,7 +1776,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Boolean
* @default false
*/
- this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
+ this.cfg.addProperty(defCfg.SHOW_WEEK_FOOTER.key,{ value:defCfg.SHOW_WEEK_FOOTER.value, 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.
@@ -1399,23 +1784,25 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Boolean
* @default false
*/
- this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } );
-
+ this.cfg.addProperty(defCfg.HIDE_BLANK_WEEKS.key, { value:defCfg.HIDE_BLANK_WEEKS.value, 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"
+ * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft"
+ * @default null
*/
- this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.configOptions } );
+ this.cfg.addProperty(defCfg.NAV_ARROW_LEFT.key, { value:defCfg.NAV_ARROW_LEFT.value, handler:this.configOptions } );
/**
- * The image that should be used for the left navigation arrow.
+ * The image that should be used for the right navigation arrow.
* @config NAV_ARROW_RIGHT
* @type String
- * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif"
+ * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright"
+ * @default null
*/
- this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.configOptions } );
+ this.cfg.addProperty(defCfg.NAV_ARROW_RIGHT.key, { value:defCfg.NAV_ARROW_RIGHT.value, handler:this.configOptions } );
// Locale properties
@@ -1425,7 +1812,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @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 } );
+ this.cfg.addProperty(defCfg.MONTHS_SHORT.key, { value:defCfg.MONTHS_SHORT.value, handler:this.configLocale } );
/**
* The long month labels for the current locale.
@@ -1433,7 +1820,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @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 } );
+ this.cfg.addProperty(defCfg.MONTHS_LONG.key, { value:defCfg.MONTHS_LONG.value, handler:this.configLocale } );
/**
* The 1-character weekday labels for the current locale.
@@ -1441,7 +1828,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @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 } );
+ this.cfg.addProperty(defCfg.WEEKDAYS_1CHAR.key, { value:defCfg.WEEKDAYS_1CHAR.value, handler:this.configLocale } );
/**
* The short weekday labels for the current locale.
@@ -1449,7 +1836,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @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 } );
+ this.cfg.addProperty(defCfg.WEEKDAYS_SHORT.key, { value:defCfg.WEEKDAYS_SHORT.value, handler:this.configLocale } );
/**
* The medium weekday labels for the current locale.
@@ -1457,7 +1844,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @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 } );
+ this.cfg.addProperty(defCfg.WEEKDAYS_MEDIUM.key, { value:defCfg.WEEKDAYS_MEDIUM.value, handler:this.configLocale } );
/**
* The long weekday labels for the current locale.
@@ -1465,7 +1852,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @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 } );
+ this.cfg.addProperty(defCfg.WEEKDAYS_LONG.key, { value:defCfg.WEEKDAYS_LONG.value, handler:this.configLocale } );
/**
* Refreshes the locale values used to build the Calendar.
@@ -1473,17 +1860,17 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @private
*/
var refreshLocale = function() {
- this.cfg.refireEvent("LOCALE_MONTHS");
- this.cfg.refireEvent("LOCALE_WEEKDAYS");
+ this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key);
+ this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key);
};
- 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.subscribeToConfigEvent(defCfg.START_WEEKDAY.key, refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent(defCfg.MONTHS_SHORT.key, refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent(defCfg.MONTHS_LONG.key, refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_1CHAR.key, refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_SHORT.key, refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_MEDIUM.key, refreshLocale, this, true);
+ this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_LONG.key, refreshLocale, this, true);
/**
* The setting that determines which length of month labels should be used. Possible values are "short" and "long".
@@ -1491,7 +1878,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type String
* @default "long"
*/
- this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } );
+ this.cfg.addProperty(defCfg.LOCALE_MONTHS.key, { value:defCfg.LOCALE_MONTHS.value, handler:this.configLocaleValues } );
/**
* The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long".
@@ -1499,7 +1886,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type String
* @default "short"
*/
- this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } );
+ this.cfg.addProperty(defCfg.LOCALE_WEEKDAYS.key, { value:defCfg.LOCALE_WEEKDAYS.value, handler:this.configLocaleValues } );
/**
* The value used to delimit individual dates in a date string passed to various Calendar functions.
@@ -1507,7 +1894,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type String
* @default ","
*/
- this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } );
+ this.cfg.addProperty(defCfg.DATE_DELIMITER.key, { value:defCfg.DATE_DELIMITER.value, handler:this.configLocale } );
/**
* The value used to delimit date fields in a date string passed to various Calendar functions.
@@ -1515,7 +1902,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type String
* @default "/"
*/
- this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } );
+ this.cfg.addProperty(defCfg.DATE_FIELD_DELIMITER.key, { value:defCfg.DATE_FIELD_DELIMITER.value, handler:this.configLocale } );
/**
* The value used to delimit date ranges in a date string passed to various Calendar functions.
@@ -1523,7 +1910,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type String
* @default "-"
*/
- this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } );
+ this.cfg.addProperty(defCfg.DATE_RANGE_DELIMITER.key, { value:defCfg.DATE_RANGE_DELIMITER.value, handler:this.configLocale } );
/**
* The position of the month in a month/year date string
@@ -1531,7 +1918,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Number
* @default 1
*/
- this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty(defCfg.MY_MONTH_POSITION.key, { value:defCfg.MY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } );
/**
* The position of the year in a month/year date string
@@ -1539,7 +1926,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Number
* @default 2
*/
- this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty(defCfg.MY_YEAR_POSITION.key, { value:defCfg.MY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } );
/**
* The position of the month in a month/day date string
@@ -1547,7 +1934,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Number
* @default 1
*/
- this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty(defCfg.MD_MONTH_POSITION.key, { value:defCfg.MD_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } );
/**
* The position of the day in a month/year date string
@@ -1555,7 +1942,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Number
* @default 2
*/
- this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty(defCfg.MD_DAY_POSITION.key, { value:defCfg.MD_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } );
/**
* The position of the month in a month/day/year date string
@@ -1563,7 +1950,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Number
* @default 1
*/
- this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty(defCfg.MDY_MONTH_POSITION.key, { value:defCfg.MDY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } );
/**
* The position of the day in a month/day/year date string
@@ -1571,7 +1958,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Number
* @default 2
*/
- this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty(defCfg.MDY_DAY_POSITION.key, { value:defCfg.MDY_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } );
/**
* The position of the year in a month/day/year date string
@@ -1579,7 +1966,39 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @type Number
* @default 3
*/
- this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty(defCfg.MDY_YEAR_POSITION.key, { value:defCfg.MDY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the month in the month year label string used as the Calendar header
+ * @config MY_LABEL_MONTH_POSITION
+ * @type Number
+ * @default 1
+ */
+ this.cfg.addProperty(defCfg.MY_LABEL_MONTH_POSITION.key, { value:defCfg.MY_LABEL_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The position of the year in the month year label string used as the Calendar header
+ * @config MY_LABEL_YEAR_POSITION
+ * @type Number
+ * @default 2
+ */
+ this.cfg.addProperty(defCfg.MY_LABEL_YEAR_POSITION.key, { value:defCfg.MY_LABEL_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } );
+
+ /**
+ * The suffix used after the month when rendering the Calendar header
+ * @config MY_LABEL_MONTH_SUFFIX
+ * @type String
+ * @default " "
+ */
+ this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key, { value:defCfg.MY_LABEL_MONTH_SUFFIX.value, handler:this.configLocale } );
+
+ /**
+ * The suffix used after the year when rendering the Calendar header
+ * @config MY_LABEL_YEAR_SUFFIX
+ * @type String
+ * @default ""
+ */
+ this.cfg.addProperty(defCfg.MY_LABEL_YEAR_SUFFIX.key, { value:defCfg.MY_LABEL_YEAR_SUFFIX.value, handler:this.configLocale } );
};
/**
@@ -1587,34 +2006,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() {
* @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");
- }
+ this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key, this._parsePageDate(args[0]), true);
};
/**
@@ -1623,9 +2015,9 @@ YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) {
*/
YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) {
var val = args[0];
- if (typeof val == 'string') {
+ if (YAHOO.lang.isString(val)) {
val = this._parseDate(val);
- this.cfg.setProperty("mindate", new Date(val[0],(val[1]-1),val[2]));
+ this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MINDATE.key, new Date(val[0],(val[1]-1),val[2]));
}
};
@@ -1635,9 +2027,9 @@ YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) {
*/
YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) {
var val = args[0];
- if (typeof val == 'string') {
+ if (YAHOO.lang.isString(val)) {
val = this._parseDate(val);
- this.cfg.setProperty("maxdate", new Date(val[0],(val[1]-1),val[2]));
+ this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MAXDATE.key, new Date(val[0],(val[1]-1),val[2]));
}
};
@@ -1647,14 +2039,15 @@ YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) {
*/
YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) {
var selected = args[0];
+ var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key;
if (selected) {
- if (typeof selected == 'string') {
- this.cfg.setProperty("selected", this._parseDates(selected), true);
+ if (YAHOO.lang.isString(selected)) {
+ this.cfg.setProperty(cfgSelected, this._parseDates(selected), true);
}
}
if (! this._selectedDates) {
- this._selectedDates = this.cfg.getProperty("selected");
+ this._selectedDates = this.cfg.getProperty(cfgSelected);
}
};
@@ -1663,9 +2056,7 @@ YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) {
* @method configOptions
*/
YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) {
- type = type.toUpperCase();
- var val = args[0];
- this.Options[type] = val;
+ this.Options[type.toUpperCase()] = args[0];
};
/**
@@ -1673,13 +2064,11 @@ YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) {
* @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");
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+ this.Locale[type.toUpperCase()] = args[0];
+ this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key);
+ this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key);
};
/**
@@ -1687,37 +2076,39 @@ YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) {
* @method configLocaleValues
*/
YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) {
- type = type.toUpperCase();
+ var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG;
+
+ type = type.toLowerCase();
var val = args[0];
switch (type) {
- case "LOCALE_MONTHS":
+ case defCfg.LOCALE_MONTHS.key:
switch (val) {
- case "short":
- this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_SHORT").concat();
+ case YAHOO.widget.Calendar.SHORT:
+ this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_SHORT.key).concat();
break;
- case "long":
- this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_LONG").concat();
+ case YAHOO.widget.Calendar.LONG:
+ this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_LONG.key).concat();
break;
}
break;
- case "LOCALE_WEEKDAYS":
+ case defCfg.LOCALE_WEEKDAYS.key:
switch (val) {
- case "1char":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_1CHAR").concat();
+ case YAHOO.widget.Calendar.ONE_CHAR:
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_1CHAR.key).concat();
break;
- case "short":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_SHORT").concat();
+ case YAHOO.widget.Calendar.SHORT:
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_SHORT.key).concat();
break;
- case "medium":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_MEDIUM").concat();
+ case YAHOO.widget.Calendar.MEDIUM:
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_MEDIUM.key).concat();
break;
- case "long":
- this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_LONG").concat();
+ case YAHOO.widget.Calendar.LONG:
+ this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_LONG.key).concat();
break;
}
- var START_WEEKDAY = this.cfg.getProperty("START_WEEKDAY");
+ var START_WEEKDAY = this.cfg.getProperty(defCfg.START_WEEKDAY.key);
if (START_WEEKDAY > 0) {
for (var w=0;w