3 * Copyright(c) 2006, Jack Slocum.
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name yui-ext nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 YAHOO.namespace('ext', 'ext.util', 'ext.grid');
30 YAHOO.ext.Strict = (document.compatMode == 'CSS1Compat');
31 YAHOO.ext.SSL_SECURE_URL = 'javascript:false';
33 window.undefined = undefined;
37 Function.prototype.createCallback = function(){
42 return method.apply(window, args);
47 Function.prototype.createDelegate = function(obj, args, appendArgs){
50 var callArgs = args || arguments;
51 if(appendArgs === true){
52 callArgs = Array.prototype.slice.call(arguments, 0);
53 callArgs = callArgs.concat(args);
54 }else if(typeof appendArgs == 'number'){
55 callArgs = Array.prototype.slice.call(arguments, 0);
56 var applyArgs = [appendArgs, 0].concat(args);
57 Array.prototype.splice.apply(callArgs, applyArgs);
59 return method.apply(obj || window, callArgs);
64 Function.prototype.defer = function(millis, obj, args, appendArgs){
65 return setTimeout(this.createDelegate(obj, args, appendArgs), millis);
68 Function.prototype.createSequence = function(fcn, scope){
69 if(typeof fcn != 'function'){
74 var retval = method.apply(this || window, arguments);
75 fcn.apply(scope || this || window, arguments);
81 YAHOO.util.Event.on(window, 'unload', function(){
82 delete Function.prototype.createSequence;
83 delete Function.prototype.defer;
84 delete Function.prototype.createDelegate;
85 delete Function.prototype.createCallback;
86 delete Function.prototype.createInterceptor;
90 Function.prototype.createInterceptor = function(fcn, scope){
91 if(typeof fcn != 'function'){
98 if(fcn.apply(scope || this || window, arguments) === false){
101 return method.apply(this || window, arguments);;
106 YAHOO.ext.util.Browser = new function(){
107 var ua = navigator.userAgent.toLowerCase();
109 this.isOpera = (ua.indexOf('opera') > -1);
111 this.isSafari = (ua.indexOf('webkit') > -1);
113 this.isIE = (window.ActiveXObject);
115 this.isIE7 = (ua.indexOf('msie 7') > -1);
117 this.isGecko = !this.isSafari && (ua.indexOf('gecko') > -1);
119 if(ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1){
121 this.isWindows = true;
122 }else if(ua.indexOf("macintosh") != -1){
126 if(this.isIE && !this.isIE7){
128 document.execCommand("BackgroundImageCache", false, true);
133 YAHOO.print = function(arg1, arg2, etc){
134 if(!YAHOO.ext._console){
135 var cs = YAHOO.ext.DomHelper.insertBefore(document.body.firstChild,
136 {tag: 'div',style:'width:250px;height:350px;overflow:auto;border:3px solid #c3daf9;' +
137 'background:white;position:absolute;right:5px;top:5px;' +
138 'font:normal 8pt arial,verdana,helvetica;z-index:50000;padding:5px;'}, true);
139 new YAHOO.ext.Resizable(cs, {
145 draggable:(YAHOO.util.DD ? true : false)
147 cs.on('dblclick', cs.hide);
148 YAHOO.ext._console = cs;
151 for(var i = 0, len = arguments.length; i < len; i++) {
152 msg += arguments[i] + '<hr noshade style="color:#eeeeee;" size="1">';
154 YAHOO.ext._console.dom.innerHTML = msg + YAHOO.ext._console.dom.innerHTML;
155 YAHOO.ext._console.dom.scrollTop = 0;
156 YAHOO.ext._console.show();
159 YAHOO.printf = function(format, arg1, arg2, etc){
160 var args = Array.prototype.slice.call(arguments, 1);
161 YAHOO.print(format.replace(
162 /\{\{[^{}]*\}\}|\{(\d+)(,\s*([\w.]+))?\}/g,
163 function(m, a1, a2, a3) {
164 if (m.chatAt == '{') {
165 return m.slice(1, -1);
172 return rpl ? rpl : '';
177 YAHOO.util.CustomEvent.prototype.fireDirect = function(){
178 var len=this.subscribers.length;
179 for (var i=0; i<len; ++i) {
180 var s = this.subscribers[i];
182 var scope = (s.override) ? s.obj : this.scope;
183 if(s.fn.apply(scope, arguments) === false){
191 YAHOO.extendX = function(subclass, superclass, overrides){
192 YAHOO.extend(subclass, superclass);
193 subclass.override = function(o){
194 YAHOO.override(subclass, o);
196 if(!subclass.prototype.override){
197 subclass.prototype.override = function(o){
198 for(var method in o){
199 this[method] = o[method];
204 subclass.override(overrides);
208 YAHOO.override = function(origclass, overrides){
210 var p = origclass.prototype;
211 for(var method in overrides){
212 p[method] = overrides[method];
218 YAHOO.ext.util.DelayedTask = function(fn, scope, args){
219 var timeoutId = null;
222 this.delay = function(delay, newFn, newScope, newArgs){
224 clearTimeout(timeoutId);
227 scope = newScope || scope;
228 args = newArgs || args;
229 timeoutId = setTimeout(fn.createDelegate(scope, args), delay);
233 this.cancel = function(){
235 clearTimeout(timeoutId);
242 YAHOO.ext.KeyMap = function(el, config, eventName){
244 this.eventName = eventName || 'keydown';
246 if(config instanceof Array){
247 for(var i = 0, len = config.length; i < len; i++){
248 this.addBinding(config[i]);
251 this.addBinding(config);
253 this.keyDownDelegate = YAHOO.ext.EventManager.wrap(this.handleKeyDown, this, true);
257 YAHOO.ext.KeyMap.prototype = {
259 addBinding : function(config){
260 var keyCode = config.key,
261 shift = config.shift,
265 scope = config.scope;
266 if(typeof keyCode == 'string'){
268 var keyString = keyCode.toUpperCase();
269 for(var j = 0, len = keyString.length; j < len; j++){
270 ks.push(keyString.charCodeAt(j));
274 var keyArray = keyCode instanceof Array;
275 var handler = function(e){
276 if((!shift || e.shiftKey) && (!ctrl || e.ctrlKey) && (!alt || e.altKey)){
279 for(var i = 0, len = keyCode.length; i < len; i++){
281 fn.call(scope || window, k, e);
287 fn.call(scope || window, k, e);
292 this.bindings.push(handler);
295 handleKeyDown : function(e){
297 var b = this.bindings;
298 for(var i = 0, len = b.length; i < len; i++){
305 isEnabled : function(){
312 this.el.on(this.eventName, this.keyDownDelegate);
320 this.el.removeListener(this.eventName, this.keyDownDelegate);
321 this.enabled = false;
327 YAHOO.ext.util.Observable = function(){};
328 YAHOO.ext.util.Observable.prototype = {
330 fireEvent : function(){
331 var ce = this.events[arguments[0].toLowerCase()];
332 if(typeof ce == 'object'){
333 return ce.fireDirect.apply(ce, Array.prototype.slice.call(arguments, 1));
339 addListener : function(eventName, fn, scope, override){
340 eventName = eventName.toLowerCase();
341 var ce = this.events[eventName];
344 throw 'You are trying to listen for an event that does not exist: "' + eventName + '".';
346 if(typeof ce == 'boolean'){
347 ce = new YAHOO.util.CustomEvent(eventName);
348 this.events[eventName] = ce;
350 ce.subscribe(fn, scope, override);
354 delayedListener : function(eventName, fn, scope, delay){
355 var newFn = function(){
356 setTimeout(fn.createDelegate(scope, arguments), delay || 1);
358 this.addListener(eventName, newFn);
363 bufferedListener : function(eventName, fn, scope, millis){
364 var task = new YAHOO.ext.util.DelayedTask();
365 var newFn = function(){
366 task.delay(millis || 250, fn, scope, Array.prototype.slice.call(arguments, 0));
368 this.addListener(eventName, newFn);
373 removeListener : function(eventName, fn, scope){
374 var ce = this.events[eventName.toLowerCase()];
375 if(typeof ce == 'object'){
376 ce.unsubscribe(fn, scope);
381 purgeListeners : function(){
382 for(var evt in this.events){
383 if(typeof this.events[evt] == 'object'){
384 this.events[evt].unsubscribeAll();
390 YAHOO.ext.util.Observable.prototype.on = YAHOO.ext.util.Observable.prototype.addListener;
393 YAHOO.ext.util.Config = {
395 apply : function(obj, config, defaults){
397 this.apply(obj, defaults);
400 for(var prop in config){
401 obj[prop] = config[prop];
409 String.escape = function(string) {
410 return string.replace(/('|\\)/g, "\\$1");
414 String.leftPad = function (val, size, ch) {
415 var result = new String(val);
419 while (result.length < size) {
420 result = ch + result;
426 if(YAHOO.util.Connect){
427 YAHOO.util.Connect.setHeader = function(o){
428 for(var prop in this._http_header){
430 if(typeof this._http_header[prop] != 'function'){
431 o.conn.setRequestHeader(prop, this._http_header[prop]);
434 delete this._http_header;
435 this._http_header = {};
436 this._has_http_headers = false;
440 if(YAHOO.util.DragDrop){
442 YAHOO.util.DragDrop.prototype.defaultPadding = {left:0, right:0, top:0, bottom:0};
445 YAHOO.util.DragDrop.prototype.constrainTo = function(constrainTo, pad, inContent){
446 if(typeof pad == 'number'){
447 pad = {left: pad, right:pad, top:pad, bottom:pad};
449 pad = pad || this.defaultPadding;
450 var b = getEl(this.getEl()).getBox();
451 var ce = getEl(constrainTo);
452 var c = ce.dom == document.body ? { x: 0, y: 0,
453 width: YAHOO.util.Dom.getViewportWidth(),
454 height: YAHOO.util.Dom.getViewportHeight()} : ce.getBox(inContent || false);
455 var topSpace = b.y - c.y;
456 var leftSpace = b.x - c.x;
458 this.resetConstraints();
459 this.setXConstraint(leftSpace - (pad.left||0),
460 c.width - leftSpace - b.width - (pad.right||0)
462 this.setYConstraint(topSpace - (pad.top||0),
463 c.height - topSpace - b.height - (pad.bottom||0)
468 YAHOO.ext.util.MixedCollection = function(allowFunctions){
473 'clear' : new YAHOO.util.CustomEvent('clear'),
475 'add' : new YAHOO.util.CustomEvent('add'),
477 'replace' : new YAHOO.util.CustomEvent('replace'),
479 'remove' : new YAHOO.util.CustomEvent('remove')
481 this.allowFunctions = allowFunctions === true;
484 YAHOO.extendX(YAHOO.ext.util.MixedCollection, YAHOO.ext.util.Observable, {
485 allowFunctions : false,
488 add : function(key, o){
489 if(arguments.length == 1){
491 key = this.getKey(o);
494 if(typeof key != 'undefined' && key != null){
498 this.fireEvent('add', this.items.length-1, o, key);
503 getKey : function(o){
508 replace : function(key, o){
509 if(arguments.length == 1){
511 key = this.getKey(o);
513 if(typeof this.items[key] == 'undefined'){
514 return this.add(key, o);
516 var old = this.items[key];
517 if(typeof key == 'number'){
520 var index = this.indexOfKey(key);
521 this.items[index] = o;
524 this.fireEvent('replace', key, old, o);
529 addAll : function(objs){
530 if(arguments.length > 1 || objs instanceof Array){
531 var args = arguments.length > 1 ? arguments : objs;
532 for(var i = 0, len = args.length; i < len; i++){
536 for(var key in objs){
537 if(this.allowFunctions || typeof objs[key] != 'function'){
538 this.add(objs[key], key);
545 each : function(fn, scope){
546 for(var i = 0, len = this.items.length; i < len; i++){
547 fn.call(scope || window, this.items[i]);
552 eachKey : function(fn, scope){
553 for(var i = 0, len = this.keys.length; i < len; i++){
554 fn.call(scope || window, this.keys[i], this.items[i]);
559 find : function(fn, scope){
560 for(var i = 0, len = this.items.length; i < len; i++){
561 if(fn.call(scope || window, this.items[i])){
562 return this.items[i];
569 insert : function(index, key, o){
570 if(arguments.length == 2){
572 key = this.getKey(o);
574 if(index >= this.items.length){
575 return this.add(o, key);
577 this.items.splice(index, 0, o);
578 if(typeof key != 'undefined' && key != null){
580 this.keys.splice(index, 0, key);
582 this.fireEvent('add', index, o, key);
587 remove : function(o){
588 var index = this.indexOf(o);
589 this.items.splice(index, 1);
590 if(typeof this.keys[index] != 'undefined'){
591 var key = this.keys[index];
592 this.keys.splice(index, 1);
593 delete this.items[key];
595 this.fireEvent('remove', o);
600 removeAt : function(index){
601 this.items.splice(index, 1);
602 var key = this.keys[index];
603 if(typeof key != 'undefined'){
604 this.keys.splice(index, 1);
605 delete this.items[key];
607 this.fireEvent('remove', o, key);
611 removeKey : function(key){
612 var o = this.items[key];
613 var index = this.indexOf(o);
614 this.items.splice(index, 1);
615 this.keys.splice(index, 1);
616 delete this.items[key];
617 this.fireEvent('remove', o, key);
621 getCount : function(){
622 return this.items.length;
626 indexOf : function(o){
627 if(!this.items.indexOf){
628 for(var i = 0, len = this.items.length; i < len; i++){
629 if(this.items[i] == o) return i;
633 return this.items.indexOf(o);
638 indexOfKey : function(key){
639 if(!this.keys.indexOf){
640 for(var i = 0, len = this.keys.length; i < len; i++){
641 if(this.keys[i] == key) return i;
645 return this.keys.indexOf(key);
650 item : function(key){
651 return this.items[key];
655 contains : function(o){
656 return this.indexOf(o) != -1;
660 containsKey : function(key){
661 return typeof this.items[key] != 'undefined';
668 this.fireEvent('clear');
673 return this.items[0];
678 return this.items[this.items.length];
682 YAHOO.ext.util.MixedCollection.prototype.get = YAHOO.ext.util.MixedCollection.prototype.item;
684 YAHOO.ext.util.JSON = new function(){
685 var useHasOwn = {}.hasOwnProperty ? true : false;
690 var pad = function(n) {
691 return n < 10 ? '0' + n : n;
704 var encodeString = function(s){
705 if (/["\\\x00-\x1f]/.test(s)) {
706 return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
713 Math.floor(c / 16).toString(16) +
714 (c % 16).toString(16);
717 return '"' + s + '"';
720 var encodeArray = function(o){
721 var a = ['['], b, i, l = o.length, v;
722 for (i = 0; i < l; i += 1) {
733 a.push(v === null ? "null" : YAHOO.ext.util.JSON.encode(v));
741 var encodeDate = function(o){
742 return '"' + o.getFullYear() + '-' +
743 pad(o.getMonth() + 1) + '-' +
744 pad(o.getDate()) + 'T' +
745 pad(o.getHours()) + ':' +
746 pad(o.getMinutes()) + ':' +
747 pad(o.getSeconds()) + '"';
751 this.encode = function(o){
752 if(typeof o == 'undefined' || o === null){
754 }else if(o instanceof Array){
755 return encodeArray(o);
756 }else if(o instanceof Date){
757 return encodeDate(o);
758 }else if(typeof o == 'string'){
759 return encodeString(o);
760 }else if(typeof o == 'number'){
761 return isFinite(o) ? String(o) : "null";
762 }else if(typeof o == 'boolean'){
765 var a = ['{'], b, i, v;
767 if(!useHasOwn || o.hasOwnProperty(i)) {
778 a.push(this.encode(i), ':',
779 v === null ? "null" : this.encode(v));
790 this.decode = function(json){
794 return eval('(' + json + ')');
802 YAHOO.ext.util.CSS = new function(){
805 var toCamel = function(property) {
806 var convert = function(prop) {
807 var test = /(-[a-z])/i.exec(prop);
808 return prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase());
810 while(property.indexOf('-') > -1) {
811 property = convert(property);
817 this.getRules = function(refreshCache){
818 if(rules == null || refreshCache){
820 var ds = document.styleSheets;
821 for(var i =0, len = ds.length; i < len; i++){
824 var ssRules = ss.cssRules || ss.rules;
825 for(var j = ssRules.length-1; j >= 0; --j){
826 rules[ssRules[j].selectorText] = ssRules[j];
835 this.getRule = function(selector, refreshCache){
836 var rs = this.getRules(refreshCache);
837 if(!(selector instanceof Array)){
840 for(var i = 0; i < selector.length; i++){
842 return rs[selector[i]];
850 this.updateRule = function(selector, property, value){
851 if(!(selector instanceof Array)){
852 var rule = this.getRule(selector);
854 rule.style[toCamel(property)] = value;
858 for(var i = 0; i < selector.length; i++){
859 if(this.updateRule(selector[i], property, value)){
868 this.apply = function(el, selector){
869 if(!(selector instanceof Array)){
870 var rule = this.getRule(selector);
874 if(typeof s[key] != 'function'){
875 if(s[key] && String(s[key]).indexOf(':') < 0 && s[key] != 'false'){
876 try{el.style[key] = s[key];}catch(e){}
883 for(var i = 0; i < selector.length; i++){
884 if(this.apply(el, selector[i])){
892 this.applyFirst = function(el, id, selector){
894 '#' + id + ' ' + selector,
897 return this.apply(el, selectors);
900 this.revert = function(el, selector){
901 if(!(selector instanceof Array)){
902 var rule = this.getRule(selector);
904 for(key in rule.style){
905 if(rule.style[key] && String(rule.style[key]).indexOf(':') < 0 && rule.style[key] != 'false'){
906 try{el.style[key] = '';}catch(e){}
912 for(var i = 0; i < selector.length; i++){
913 if(this.revert(el, selector[i])){
921 this.revertFirst = function(el, id, selector){
923 '#' + id + ' ' + selector,
926 return this.revert(el, selectors);
929 YAHOO.ext.util.Bench = function(){
933 YAHOO.ext.util.Bench.prototype = {
934 start : function(key){
936 this.timers[key] = {};
937 this.timers[key].startTime = new Date().getTime();
940 stop : function(key){
941 key = key || this.lastKey;
942 this.timers[key].endTime = new Date().getTime();
945 getElapsed : function(key){
946 key = key || this.lastKey;
947 return this.timers[key].endTime - this.timers[key].startTime;
950 toString : function(html){
952 for(var key in this.timers){
953 if(typeof this.timers[key] != 'function'){
954 results += key + ":\t" + (this.getElapsed(key) / 1000) + " seconds\n";
958 results = results.replace("\n", '<br>');
964 alert(this.toString());
968 YAHOO.ext.DomHelper = new function(){
971 var tempTableEl = null;
974 var emptyTags = /^(?:base|basefont|br|frame|hr|img|input|isindex|link|meta|nextid|range|spacer|wbr|audioscope|area|param|keygen|col|limittext|spot|tab|over|right|left|choose|atop|of)$/i;
976 this.applyStyles = function(el, styles){
978 var D = YAHOO.util.Dom;
979 if (typeof styles == "string"){
980 var re = /\s?([a-z\-]*)\:([^;]*);?/gi;
982 while ((matches = re.exec(styles)) != null){
983 D.setStyle(el, matches[1], matches[2]);
985 }else if (typeof styles == "object"){
986 for (var style in styles){
987 D.setStyle(el, style, styles[style]);
989 }else if (typeof styles == "function"){
990 YAHOO.ext.DomHelper.applyStyles(el, styles.call());
997 var createHtml = function(o){
1001 if(attr == 'tag' || attr == 'children' || attr == 'html' || typeof o[attr] == 'function') continue;
1002 if(attr == 'style'){
1004 if(typeof s == 'function'){
1007 if(typeof s == 'string'){
1008 b += ' style="' + s + '"';
1009 }else if(typeof s == 'object'){
1012 if(typeof s[key] != 'function'){
1013 b += key + ':' + s[key] + ';';
1020 b += ' class="' + o['cls'] + '"';
1021 }else if(attr == 'htmlFor'){
1022 b += ' for="' + o['htmlFor'] + '"';
1024 b += ' ' + attr + '="' + o[attr] + '"';
1028 if(emptyTags.test(o.tag)){
1033 for(var i = 0, len = o.children.length; i < len; i++) {
1034 b += createHtml(o.children[i], b);
1040 b += '</' + o.tag + '>';
1047 var createDom = function(o, parentNode){
1048 var el = d.createElement(o.tag);
1049 var useSet = el.setAttribute ? true : false;
1051 if(attr == 'tag' || attr == 'children' || attr == 'html' || attr == 'style' || typeof o[attr] == 'function') continue;
1053 el.className = o['cls'];
1055 if(useSet) el.setAttribute(attr, o[attr]);
1056 else el[attr] = o[attr];
1059 YAHOO.ext.DomHelper.applyStyles(el, o.style);
1061 for(var i = 0, len = o.children.length; i < len; i++) {
1062 createDom(o.children[i], el);
1066 el.innerHTML = o.html;
1069 parentNode.appendChild(el);
1075 var insertIntoTable = function(tag, where, el, html){
1077 tempTableEl = document.createElement('div');
1080 if(tag == 'table' || tag == 'tbody'){
1081 tempTableEl.innerHTML = '<table><tbody>'+html+'</tbody></table>';
1082 node = tempTableEl.firstChild.firstChild.firstChild;
1084 tempTableEl.innerHTML = '<table><tbody><tr>'+html+'</tr></tbody></table>';
1085 node = tempTableEl.firstChild.firstChild.firstChild.firstChild;
1087 if(where == 'beforebegin'){
1088 el.parentNode.insertBefore(node, el);
1090 }else if(where == 'afterbegin'){
1091 el.insertBefore(node, el.firstChild);
1093 }else if(where == 'beforeend'){
1094 el.appendChild(node);
1096 }else if(where == 'afterend'){
1097 el.parentNode.insertBefore(node, el.nextSibling);
1103 this.insertHtml = function(where, el, html){
1104 where = where.toLowerCase();
1105 if(el.insertAdjacentHTML){
1106 var tag = el.tagName.toLowerCase();
1107 if(tag == 'table' || tag == 'tbody' || tag == 'tr'){
1108 return insertIntoTable(tag, where, el, html);
1112 el.insertAdjacentHTML(where, html);
1113 return el.previousSibling;
1115 el.insertAdjacentHTML(where, html);
1116 return el.firstChild;
1118 el.insertAdjacentHTML(where, html);
1119 return el.lastChild;
1121 el.insertAdjacentHTML(where, html);
1122 return el.nextSibling;
1124 throw 'Illegal insertion point -> "' + where + '"';
1126 var range = el.ownerDocument.createRange();
1130 range.setStartBefore(el);
1131 frag = range.createContextualFragment(html);
1132 el.parentNode.insertBefore(frag, el);
1133 return el.previousSibling;
1136 range.setStartBefore(el.firstChild);
1138 range.selectNodeContents(el);
1139 range.collapse(true);
1141 frag = range.createContextualFragment(html);
1142 el.insertBefore(frag, el.firstChild);
1143 return el.firstChild;
1146 range.setStartAfter(el.lastChild);
1148 range.selectNodeContents(el);
1149 range.collapse(false);
1151 frag = range.createContextualFragment(html);
1152 el.appendChild(frag);
1153 return el.lastChild;
1155 range.setStartAfter(el);
1156 frag = range.createContextualFragment(html);
1157 el.parentNode.insertBefore(frag, el.nextSibling);
1158 return el.nextSibling;
1160 throw 'Illegal insertion point -> "' + where + '"';
1164 this.insertBefore = function(el, o, returnElement){
1165 el = YAHOO.util.Dom.get(el);
1168 newNode = createDom(o, null);
1169 el.parentNode.insertBefore(newNode, el);
1171 var html = createHtml(o);
1172 newNode = this.insertHtml('beforeBegin', el, html);
1174 return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode;
1178 this.insertAfter = function(el, o, returnElement){
1179 el = YAHOO.util.Dom.get(el);
1182 newNode = createDom(o, null);
1183 el.parentNode.insertBefore(newNode, el.nextSibling);
1185 var html = createHtml(o);
1186 newNode = this.insertHtml('afterEnd', el, html);
1188 return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode;
1192 this.append = function(el, o, returnElement){
1193 el = YAHOO.util.Dom.get(el);
1196 newNode = createDom(o, null);
1197 el.appendChild(newNode);
1199 var html = createHtml(o);
1200 newNode = this.insertHtml('beforeEnd', el, html);
1202 return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode;
1206 this.overwrite = function(el, o, returnElement){
1207 el = YAHOO.util.Dom.get(el);
1208 el.innerHTML = createHtml(o);
1209 return returnElement ? YAHOO.ext.Element.get(el.firstChild, true) : el.firstChild;
1213 this.createTemplate = function(o){
1214 var html = createHtml(o);
1215 return new YAHOO.ext.DomHelper.Template(html);
1220 YAHOO.ext.DomHelper.Template = function(html){
1224 YAHOO.ext.DomHelper.Template.prototype = {
1226 applyTemplate : function(values){
1228 return this.compiled(values);
1231 var fn = function(match, index){
1232 if(typeof values[index] != 'undefined'){
1233 return values[index];
1238 return this.html.replace(this.re, fn);
1245 compile : function(){
1246 var html = this.html;
1249 body.push("this.compiled = function(values){ return [");
1251 var lastMatchEnd = 0;
1252 while ((result = re.exec(html)) != null){
1253 body.push("'", html.substring(lastMatchEnd, result.index), "', ");
1254 body.push("values['", html.substring(result.index+1,re.lastIndex-1), "'], ");
1255 lastMatchEnd = re.lastIndex;
1257 body.push("'", html.substr(lastMatchEnd), "'].join('');};");
1258 eval(body.join(''));
1262 insertBefore: function(el, values, returnElement){
1263 el = YAHOO.util.Dom.get(el);
1264 var newNode = YAHOO.ext.DomHelper.insertHtml('beforeBegin', el, this.applyTemplate(values));
1265 return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode;
1269 insertAfter : function(el, values, returnElement){
1270 el = YAHOO.util.Dom.get(el);
1271 var newNode = YAHOO.ext.DomHelper.insertHtml('afterEnd', el, this.applyTemplate(values));
1272 return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode;
1276 append : function(el, values, returnElement){
1277 el = YAHOO.util.Dom.get(el);
1278 var newNode = YAHOO.ext.DomHelper.insertHtml('beforeEnd', el, this.applyTemplate(values));
1279 return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode;
1283 overwrite : function(el, values, returnElement){
1284 el = YAHOO.util.Dom.get(el);
1286 var newNode = YAHOO.ext.DomHelper.insertHtml('beforeEnd', el, this.applyTemplate(values));
1287 return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode;
1291 YAHOO.ext.Template = YAHOO.ext.DomHelper.Template;
1293 YAHOO.ext.Element = function(element, forceNew){
1294 var dom = YAHOO.util.Dom.get(element);
1298 if(!forceNew && YAHOO.ext.Element.cache[dom.id]){
1299 return YAHOO.ext.Element.cache[dom.id];
1305 this.id = this.dom.id;
1307 this.visibilityMode = YAHOO.ext.Element.VISIBILITY;
1311 this.originalDisplay = YAHOO.util.Dom.getStyle(this.dom, 'display') || '';
1312 if(this.autoDisplayMode){
1313 if(this.originalDisplay == 'none'){
1314 this.setVisibilityMode(YAHOO.ext.Element.DISPLAY);
1317 if(this.originalDisplay == 'none'){
1318 this.originalDisplay = '';
1322 this.defaultUnit = 'px';
1325 YAHOO.ext.Element.prototype = {
1327 setVisibilityMode : function(visMode){
1328 this.visibilityMode = visMode;
1333 enableDisplayMode : function(display){
1334 this.setVisibilityMode(YAHOO.ext.Element.DISPLAY);
1335 if(typeof display != 'undefined') this.originalDisplay = display;
1340 animate : function(args, duration, onComplete, easing, animType){
1341 this.anim(args, duration, onComplete, easing, animType);
1346 anim : function(args, duration, onComplete, easing, animType){
1347 animType = animType || YAHOO.util.Anim;
1348 var anim = new animType(this.dom, args, duration || .35,
1349 easing || YAHOO.util.Easing.easeBoth);
1351 if(!(onComplete instanceof Array)){
1352 anim.onComplete.subscribe(onComplete, this, true);
1354 for(var i = 0; i < onComplete.length; i++){
1355 var fn = onComplete[i];
1356 if(fn) anim.onComplete.subscribe(fn, this, true);
1364 scrollIntoView : function(container){
1365 var c = getEl(container || document.body, true);
1366 var cp = c.getStyle('position');
1367 var restorePos = false;
1368 if(cp != 'relative' && cp != 'absolute'){
1369 c.setStyle('position', 'relative');
1373 var childTop = parseInt(el.offsetTop, 10);
1374 var childBottom = childTop + el.offsetHeight;
1375 var containerTop = parseInt(c.scrollTop, 10);
1376 var containerBottom = containerTop + c.clientHeight;
1377 if(childTop < containerTop){
1378 c.scrollTop = childTop;
1379 }else if(childBottom > containerBottom){
1380 c.scrollTop = childBottom-c.clientHeight;
1383 c.setStyle('position', cp);
1389 autoHeight : function(animate, duration, onComplete, easing){
1390 var oldHeight = this.getHeight();
1393 setTimeout(function(){
1394 var height = parseInt(this.dom.scrollHeight, 10);
1396 this.setHeight(height);
1398 if(typeof onComplete == 'function'){
1402 this.setHeight(oldHeight);
1403 this.setHeight(height, animate, duration, function(){
1405 if(typeof onComplete == 'function') onComplete();
1406 }.createDelegate(this), easing);
1408 }.createDelegate(this), 0);
1413 isVisible : function(deep) {
1414 var vis = YAHOO.util.Dom.getStyle(this.dom, 'visibility') != 'hidden'
1415 && YAHOO.util.Dom.getStyle(this.dom, 'display') != 'none';
1419 var p = this.dom.parentNode;
1420 while(p && p.tagName.toLowerCase() != 'body'){
1421 if(YAHOO.util.Dom.getStyle(p, 'visibility') == 'hidden' || YAHOO.util.Dom.getStyle(p, 'display') == 'none'){
1430 select : function(selector, unique){
1431 return YAHOO.ext.Element.select('#' + this.dom.id + ' ' + selector, unique);
1435 initDD : function(group, config, overrides){
1436 var dd = new YAHOO.util.DD(YAHOO.util.Dom.generateId(this.dom), group, config);
1437 return YAHOO.ext.util.Config.apply(dd, overrides);
1441 initDDProxy : function(group, config, overrides){
1442 var dd = new YAHOO.util.DDProxy(YAHOO.util.Dom.generateId(this.dom), group, config);
1443 return YAHOO.ext.util.Config.apply(dd, overrides);
1447 initDDTarget : function(group, config, overrides){
1448 var dd = new YAHOO.util.DDTarget(YAHOO.util.Dom.generateId(this.dom), group, config);
1449 return YAHOO.ext.util.Config.apply(dd, overrides);
1453 setVisible : function(visible, animate, duration, onComplete, easing){
1455 if(!animate || !YAHOO.util.Anim){
1456 if(this.visibilityMode == YAHOO.ext.Element.DISPLAY){
1457 this.setDisplayed(visible);
1459 YAHOO.util.Dom.setStyle(this.dom, 'visibility', visible ? 'visible' : 'hidden');
1463 this.setOpacity(visible?0:1);
1464 YAHOO.util.Dom.setStyle(this.dom, 'visibility', 'visible');
1465 if(this.visibilityMode == YAHOO.ext.Element.DISPLAY){
1466 this.setDisplayed(true);
1468 var args = {opacity: { from: (visible?0:1), to: (visible?1:0) }};
1469 var anim = new YAHOO.util.Anim(this.dom, args, duration || .35,
1470 easing || (visible ? YAHOO.util.Easing.easeIn : YAHOO.util.Easing.easeOut));
1471 anim.onComplete.subscribe((function(){
1472 if(this.visibilityMode == YAHOO.ext.Element.DISPLAY){
1473 this.setDisplayed(visible);
1475 YAHOO.util.Dom.setStyle(this.dom, 'visibility', visible ? 'visible' : 'hidden');
1477 }).createDelegate(this));
1479 anim.onComplete.subscribe(onComplete);
1487 isDisplayed : function() {
1488 return YAHOO.util.Dom.getStyle(this.dom, 'display') != 'none';
1492 toggle : function(animate, duration, onComplete, easing){
1493 this.setVisible(!this.isVisible(), animate, duration, onComplete, easing);
1498 setDisplayed : function(value) {
1499 if(typeof value == 'boolean'){
1500 value = value ? this.originalDisplay : 'none';
1502 YAHOO.util.Dom.setStyle(this.dom, 'display', value);
1507 focus : function() {
1523 addClass : function(className){
1524 if(className instanceof Array){
1525 for(var i = 0, len = className.length; i < len; i++) {
1526 this.addClass(className[i]);
1529 if(!this.hasClass(className)){
1530 this.dom.className = this.dom.className + ' ' + className;
1537 radioClass : function(className){
1538 var siblings = this.dom.parentNode.childNodes;
1539 for(var i = 0; i < siblings.length; i++) {
1540 var s = siblings[i];
1541 if(s.nodeType == 1){
1542 YAHOO.util.Dom.removeClass(s, className);
1545 this.addClass(className);
1549 removeClass : function(className){
1550 if(className instanceof Array){
1551 for(var i = 0, len = className.length; i < len; i++) {
1552 this.removeClass(className[i]);
1555 var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
1556 var c = this.dom.className;
1558 this.dom.className = c.replace(re, ' ');
1565 toggleClass : function(className){
1566 if(this.hasClass(className)){
1567 this.removeClass(className);
1569 this.addClass(className);
1575 hasClass : function(className){
1576 var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
1577 return re.test(this.dom.className);
1581 replaceClass : function(oldClassName, newClassName){
1582 this.removeClass(oldClassName);
1583 this.addClass(newClassName);
1588 getStyle : function(name){
1589 return YAHOO.util.Dom.getStyle(this.dom, name);
1593 setStyle : function(name, value){
1594 if(typeof name == 'string'){
1595 YAHOO.util.Dom.setStyle(this.dom, name, value);
1597 var D = YAHOO.util.Dom;
1598 for(var style in name){
1599 if(typeof name[style] != 'function'){
1600 D.setStyle(this.dom, style, name[style]);
1608 applyStyles : function(style){
1609 YAHOO.ext.DomHelper.applyStyles(this.dom, style);
1614 return YAHOO.util.Dom.getX(this.dom);
1619 return YAHOO.util.Dom.getY(this.dom);
1624 return YAHOO.util.Dom.getXY(this.dom);
1628 setX : function(x, animate, duration, onComplete, easing){
1629 if(!animate || !YAHOO.util.Anim){
1630 YAHOO.util.Dom.setX(this.dom, x);
1632 this.setXY([x, this.getY()], animate, duration, onComplete, easing);
1638 setY : function(y, animate, duration, onComplete, easing){
1639 if(!animate || !YAHOO.util.Anim){
1640 YAHOO.util.Dom.setY(this.dom, y);
1642 this.setXY([this.getX(), y], animate, duration, onComplete, easing);
1648 setLeft : function(left){
1649 YAHOO.util.Dom.setStyle(this.dom, 'left', this.addUnits(left));
1654 setTop : function(top){
1655 YAHOO.util.Dom.setStyle(this.dom, 'top', this.addUnits(top));
1660 setRight : function(right){
1661 YAHOO.util.Dom.setStyle(this.dom, 'right', this.addUnits(right));
1666 setBottom : function(bottom){
1667 YAHOO.util.Dom.setStyle(this.dom, 'bottom', this.addUnits(bottom));
1672 setXY : function(pos, animate, duration, onComplete, easing){
1673 if(!animate || !YAHOO.util.Anim){
1674 YAHOO.util.Dom.setXY(this.dom, pos);
1676 this.anim({points: {to: pos}}, duration, onComplete, easing, YAHOO.util.Motion);
1682 setLocation : function(x, y, animate, duration, onComplete, easing){
1683 this.setXY([x, y], animate, duration, onComplete, easing);
1688 moveTo : function(x, y, animate, duration, onComplete, easing){
1691 this.setXY([x, y], animate, duration, onComplete, easing);
1696 getRegion : function(){
1697 return YAHOO.util.Dom.getRegion(this.dom);
1701 getHeight : function(contentHeight){
1702 var h = this.dom.offsetHeight;
1703 return contentHeight !== true ? h : h-this.getBorderWidth('tb')-this.getPadding('tb');
1707 getWidth : function(contentWidth){
1708 var w = this.dom.offsetWidth;
1709 return contentWidth !== true ? w : w-this.getBorderWidth('lr')-this.getPadding('lr');
1713 getSize : function(contentSize){
1714 return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
1718 adjustWidth : function(width){
1719 if(typeof width == 'number'){
1720 if(this.autoBoxAdjust && !this.isBorderBox()){
1721 width -= (this.getBorderWidth('lr') + this.getPadding('lr'));
1731 adjustHeight : function(height){
1732 if(typeof height == 'number'){
1733 if(this.autoBoxAdjust && !this.isBorderBox()){
1734 height -= (this.getBorderWidth('tb') + this.getPadding('tb'));
1744 setWidth : function(width, animate, duration, onComplete, easing){
1745 width = this.adjustWidth(width);
1746 if(!animate || !YAHOO.util.Anim){
1747 YAHOO.util.Dom.setStyle(this.dom, 'width', this.addUnits(width));
1749 this.anim({width: {to: width}}, duration, onComplete,
1750 easing || (width > this.getWidth() ? YAHOO.util.Easing.easeOut : YAHOO.util.Easing.easeIn));
1756 setHeight : function(height, animate, duration, onComplete, easing){
1757 height = this.adjustHeight(height);
1758 if(!animate || !YAHOO.util.Anim){
1759 YAHOO.util.Dom.setStyle(this.dom, 'height', this.addUnits(height));
1761 this.anim({height: {to: height}}, duration, onComplete,
1762 easing || (height > this.getHeight() ? YAHOO.util.Easing.easeOut : YAHOO.util.Easing.easeIn));
1768 setSize : function(width, height, animate, duration, onComplete, easing){
1769 if(!animate || !YAHOO.util.Anim){
1770 this.setWidth(width);
1771 this.setHeight(height);
1773 width = this.adjustWidth(width); height = this.adjustHeight(height);
1774 this.anim({width: {to: width}, height: {to: height}}, duration, onComplete, easing);
1780 setBounds : function(x, y, width, height, animate, duration, onComplete, easing){
1781 if(!animate || !YAHOO.util.Anim){
1782 this.setWidth(width);
1783 this.setHeight(height);
1784 this.setLocation(x, y);
1786 width = this.adjustWidth(width); height = this.adjustHeight(height);
1787 this.anim({points: {to: [x, y]}, width: {to: width}, height: {to: height}}, duration, onComplete, easing, YAHOO.util.Motion);
1793 setRegion : function(region, animate, duration, onComplete, easing){
1794 this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, animate, duration, onComplete, easing);
1799 addListener : function(eventName, handler, scope, override){
1800 YAHOO.util.Event.addListener(this.dom, eventName, handler, scope || this, true);
1804 bufferedListener : function(eventName, fn, scope, millis){
1805 var task = new YAHOO.ext.util.DelayedTask();
1806 scope = scope || this;
1807 var newFn = function(){
1808 task.delay(millis || 250, fn, scope, Array.prototype.slice.call(arguments, 0));
1810 this.addListener(eventName, newFn);
1816 addHandler : function(eventName, stopPropagation, handler, scope, override){
1817 var fn = YAHOO.ext.Element.createStopHandler(stopPropagation, handler, scope || this, true);
1818 YAHOO.util.Event.addListener(this.dom, eventName, fn);
1823 on : function(eventName, handler, scope, override){
1824 YAHOO.util.Event.addListener(this.dom, eventName, handler, scope || this, true);
1829 addManagedListener : function(eventName, fn, scope, override){
1830 return YAHOO.ext.EventManager.on(this.dom, eventName, fn, scope || this, true);
1834 mon : function(eventName, fn, scope, override){
1835 return YAHOO.ext.EventManager.on(this.dom, eventName, fn, scope || this, true);
1838 removeListener : function(eventName, handler, scope){
1839 YAHOO.util.Event.removeListener(this.dom, eventName, handler);
1844 removeAllListeners : function(){
1845 YAHOO.util.Event.purgeElement(this.dom);
1851 setOpacity : function(opacity, animate, duration, onComplete, easing){
1852 if(!animate || !YAHOO.util.Anim){
1853 YAHOO.util.Dom.setStyle(this.dom, 'opacity', opacity);
1855 this.anim({opacity: {to: opacity}}, duration, onComplete, easing);
1861 getLeft : function(local){
1865 return parseInt(this.getStyle('left'), 10) || 0;
1870 getRight : function(local){
1872 return this.getX() + this.getWidth();
1874 return (this.getLeft(true) + this.getWidth()) || 0;
1879 getTop : function(local) {
1883 return parseInt(this.getStyle('top'), 10) || 0;
1888 getBottom : function(local){
1890 return this.getY() + this.getHeight();
1892 return (this.getTop(true) + this.getHeight()) || 0;
1897 setAbsolutePositioned : function(zIndex){
1898 this.setStyle('position', 'absolute');
1900 this.setStyle('z-index', zIndex);
1906 setRelativePositioned : function(zIndex){
1907 this.setStyle('position', 'relative');
1909 this.setStyle('z-index', zIndex);
1915 clearPositioning : function(){
1916 this.setStyle('position', '');
1917 this.setStyle('left', '');
1918 this.setStyle('right', '');
1919 this.setStyle('top', '');
1920 this.setStyle('bottom', '');
1925 getPositioning : function(){
1927 'position' : this.getStyle('position'),
1928 'left' : this.getStyle('left'),
1929 'right' : this.getStyle('right'),
1930 'top' : this.getStyle('top'),
1931 'bottom' : this.getStyle('bottom')
1936 getBorderWidth : function(side){
1937 return this.addStyles(side, YAHOO.ext.Element.borders);
1941 getPadding : function(side){
1942 return this.addStyles(side, YAHOO.ext.Element.paddings);
1946 setPositioning : function(positionCfg){
1947 if(positionCfg.position)this.setStyle('position', positionCfg.position);
1948 if(positionCfg.left)this.setLeft(positionCfg.left);
1949 if(positionCfg.right)this.setRight(positionCfg.right);
1950 if(positionCfg.top)this.setTop(positionCfg.top);
1951 if(positionCfg.bottom)this.setBottom(positionCfg.bottom);
1957 setLeftTop : function(left, top){
1958 this.dom.style.left = this.addUnits(left);
1959 this.dom.style.top = this.addUnits(top);
1964 move : function(direction, distance, animate, duration, onComplete, easing){
1965 var xy = this.getXY();
1966 direction = direction.toLowerCase();
1970 this.moveTo(xy[0]-distance, xy[1], animate, duration, onComplete, easing);
1974 this.moveTo(xy[0]+distance, xy[1], animate, duration, onComplete, easing);
1979 this.moveTo(xy[0], xy[1]-distance, animate, duration, onComplete, easing);
1984 this.moveTo(xy[0], xy[1]+distance, animate, duration, onComplete, easing);
1992 if(!this.isClipped){
1993 this.isClipped = true;
1994 this.originalClip = {
1995 'o': this.getStyle('overflow'),
1996 'x': this.getStyle('overflow-x'),
1997 'y': this.getStyle('overflow-y')
1999 this.setStyle('overflow', 'hidden');
2000 this.setStyle('overflow-x', 'hidden');
2001 this.setStyle('overflow-y', 'hidden');
2007 unclip : function(){
2009 this.isClipped = false;
2010 var o = this.originalClip;
2011 if(o.o){this.setStyle('overflow', o.o);}
2012 if(o.x){this.setStyle('overflow-x', o.x);}
2013 if(o.y){this.setStyle('overflow-y', o.y);}
2019 alignTo : function(element, position, offsets, animate, duration, onComplete, easing){
2020 var otherEl = getEl(element);
2024 offsets = offsets || [0, 0];
2025 var r = otherEl.getRegion();
2026 position = position.toLowerCase();
2029 this.moveTo(r.left + offsets[0], r.bottom + offsets[1],
2030 animate, duration, onComplete, easing);
2033 this.moveTo(r.right + offsets[0], r.bottom + offsets[1],
2034 animate, duration, onComplete, easing);
2037 this.moveTo(r.left + offsets[0], r.top + offsets[1],
2038 animate, duration, onComplete, easing);
2041 this.moveTo(r.right + offsets[0], r.top + offsets[1],
2042 animate, duration, onComplete, easing);
2049 clearOpacity : function(){
2050 if (window.ActiveXObject) {
2051 this.dom.style.filter = '';
2053 this.dom.style.opacity = '';
2054 this.dom.style['-moz-opacity'] = '';
2055 this.dom.style['-khtml-opacity'] = '';
2061 hide : function(animate, duration, onComplete, easing){
2062 this.setVisible(false, animate, duration, onComplete, easing);
2067 show : function(animate, duration, onComplete, easing){
2068 this.setVisible(true, animate, duration, onComplete, easing);
2073 addUnits : function(size){
2074 if(size === '' || size == 'auto' || typeof size == 'undefined'){
2077 if(typeof size == 'number' || !YAHOO.ext.Element.unitPattern.test(size)){
2078 return size + this.defaultUnit;
2084 beginMeasure : function(){
2086 if(el.offsetWidth || el.offsetHeight){
2091 while((!el.offsetWidth && !el.offsetHeight) && p && p.tagName && p.tagName.toLowerCase() != 'body'){
2092 if(YAHOO.util.Dom.getStyle(p, 'display') == 'none'){
2093 changed.push({el: p, visibility: YAHOO.util.Dom.getStyle(p, 'visibility')});
2094 p.style.visibility = 'hidden';
2095 p.style.display = 'block';
2099 this._measureChanged = changed;
2105 endMeasure : function(){
2106 var changed = this._measureChanged;
2108 for(var i = 0, len = changed.length; i < len; i++) {
2110 r.el.style.visibility = r.visibility;
2111 r.el.style.display = 'none';
2113 this._measureChanged = null;
2119 update : function(html, loadScripts, callback){
2120 if(typeof html == 'undefined'){
2123 if(loadScripts !== true){
2124 this.dom.innerHTML = html;
2125 if(typeof callback == 'function'){
2130 var id = YAHOO.util.Dom.generateId();
2133 html += '<span id="' + id + '"></span>';
2135 YAHOO.util.Event.onAvailable(id, function(){
2136 var hd = document.getElementsByTagName("head")[0];
2137 var re = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img;
2138 var srcRe = /\ssrc=([\'\"])(.*?)\1/i;
2140 while(match = re.exec(html)){
2141 var srcMatch = match[0].match(srcRe);
2142 if(srcMatch && srcMatch[2]){
2143 var s = document.createElement("script");
2144 s.src = srcMatch[2];
2146 }else if(match[1] && match[1].length > 0){
2150 var el = document.getElementById(id);
2151 if(el){el.parentNode.removeChild(el);}
2152 if(typeof callback == 'function'){
2156 dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img, '');
2162 var um = this.getUpdateManager();
2163 um.update.apply(um, arguments);
2168 getUpdateManager : function(){
2169 if(!this.updateManager){
2170 this.updateManager = new YAHOO.ext.UpdateManager(this);
2172 return this.updateManager;
2176 unselectable : function(){
2177 this.dom.unselectable = 'on';
2178 this.swallowEvent('selectstart', true);
2179 this.applyStyles('-moz-user-select:none;-khtml-user-select:none;');
2184 getCenterXY : function(offsetScroll){
2185 var centerX = Math.round((YAHOO.util.Dom.getViewportWidth()-this.getWidth())/2);
2186 var centerY = Math.round((YAHOO.util.Dom.getViewportHeight()-this.getHeight())/2);
2188 return [centerX, centerY];
2190 var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft || 0;
2191 var scrollY = document.documentElement.scrollTop || document.body.scrollTop || 0;
2192 return[centerX + scrollX, centerY + scrollY];
2197 center : function(centerIn) {
2199 this.setXY(this.getCenterXY(true));
2201 var box = YAHOO.ext.Element.get(centerIn).getBox();
2202 this.setXY([box.x + (box.width / 2) - (this.getWidth() / 2),
2203 box.y + (box.height / 2) - (this.getHeight() / 2)]);
2209 getChildrenByTagName : function(tagName){
2210 var children = this.dom.getElementsByTagName(tagName);
2211 var len = children.length;
2212 var ce = new Array(len);
2213 for(var i = 0; i < len; ++i){
2214 ce[i] = YAHOO.ext.Element.get(children[i], true);
2220 getChildrenByClassName : function(className, tagName){
2221 var children = YAHOO.util.Dom.getElementsByClassName(className, tagName, this.dom);
2222 var len = children.length;
2223 var ce = new Array(len);
2224 for(var i = 0; i < len; ++i){
2225 ce[i] = YAHOO.ext.Element.get(children[i], true);
2231 isBorderBox : function(){
2232 if(typeof this.bbox == 'undefined'){
2234 var b = YAHOO.ext.util.Browser;
2235 var strict = YAHOO.ext.Strict;
2236 this.bbox = ((b.isIE && !strict && el.style.boxSizing != 'content-box') ||
2237 (b.isGecko && YAHOO.util.Dom.getStyle(el, "-moz-box-sizing") == 'border-box') ||
2238 (!b.isSafari && YAHOO.util.Dom.getStyle(el, "box-sizing") == 'border-box'));
2244 getBox : function(contentBox, local){
2249 var left = parseInt(YAHOO.util.Dom.getStyle('left'), 10) || 0;
2250 var top = parseInt(YAHOO.util.Dom.getStyle('top'), 10) || 0;
2254 var w = el.offsetWidth;
2255 var h = el.offsetHeight;
2257 return {x: xy[0], y: xy[1], width: w, height: h};
2259 var l = this.getBorderWidth('l')+this.getPadding('l');
2260 var r = this.getBorderWidth('r')+this.getPadding('r');
2261 var t = this.getBorderWidth('t')+this.getPadding('t');
2262 var b = this.getBorderWidth('b')+this.getPadding('b');
2263 return {x: xy[0]+l, y: xy[1]+t, width: w-(l+r), height: h-(t+b)};
2268 setBox : function(box, adjust, animate, duration, onComplete, easing){
2269 var w = box.width, h = box.height;
2270 if((adjust && !this.autoBoxAdjust) && !this.isBorderBox()){
2271 w -= (this.getBorderWidth('lr') + this.getPadding('lr'));
2272 h -= (this.getBorderWidth('tb') + this.getPadding('tb'));
2274 this.setBounds(box.x, box.y, w, h, animate, duration, onComplete, easing);
2279 repaint : function(){
2281 YAHOO.util.Dom.addClass(dom, 'yui-ext-repaint');
2282 setTimeout(function(){
2283 YAHOO.util.Dom.removeClass(dom, 'yui-ext-repaint');
2289 getMargins : function(side){
2292 top: parseInt(this.getStyle('margin-top'), 10) || 0,
2293 left: parseInt(this.getStyle('margin-left'), 10) || 0,
2294 bottom: parseInt(this.getStyle('margin-bottom'), 10) || 0,
2295 right: parseInt(this.getStyle('margin-right'), 10) || 0
2298 return this.addStyles(side, YAHOO.ext.Element.margins);
2302 addStyles : function(sides, styles){
2304 for(var i = 0, len = sides.length; i < len; i++){
2305 var w = parseInt(this.getStyle(styles[sides.charAt(i)]), 10);
2306 if(!isNaN(w)) val += w;
2312 createProxy : function(config, renderTo, matchBox){
2314 renderTo = YAHOO.util.Dom.get(renderTo);
2316 renderTo = document.body;
2318 config = typeof config == 'object' ?
2319 config : {tag : 'div', cls: config};
2320 var proxy = YAHOO.ext.DomHelper.append(renderTo, config, true);
2322 proxy.setBox(this.getBox());
2328 createShim : function(){
2332 cls: 'yiframe-shim',
2333 style: 'position:absolute;visibility:hidden;left:0;top:0;overflow:hidden;',
2334 src: YAHOO.ext.SSL_SECURE_URL
2336 var shim = YAHOO.ext.DomHelper.append(this.dom.parentNode, config, true);
2337 shim.setBox(this.getBox());
2342 remove : function(){
2343 this.dom.parentNode.removeChild(this.dom);
2344 delete YAHOO.ext.Element.cache[this.dom.id];
2348 addClassOnOver : function(className){
2349 this.on('mouseover', function(){
2350 this.addClass(className);
2352 this.on('mouseout', function(){
2353 this.removeClass(className);
2359 swallowEvent : function(eventName, preventDefault){
2360 var fn = function(e){
2361 e.stopPropagation();
2366 this.mon(eventName, fn);
2371 fitToParent : function(monitorResize){
2372 var p = getEl(this.dom.parentNode, true);
2374 var box = p.getBox(true, true);
2376 this.setSize(box.width, box.height);
2377 if(monitorResize === true){
2378 YAHOO.ext.EventManager.onWindowResize(this.fitToParent, this, true);
2384 getNextSibling : function(){
2385 var n = this.dom.nextSibling;
2386 while(n && n.nodeType != 1){
2393 getPrevSibling : function(){
2394 var n = this.dom.previousSibling;
2395 while(n && n.nodeType != 1){
2396 n = n.previousSibling;
2403 appendChild: function(el){
2410 createChild: function(config, insertBefore){
2413 c = YAHOO.ext.DomHelper.insertBefore(insertBefore, config, true);
2415 c = YAHOO.ext.DomHelper.append(this.dom, config, true);
2421 appendTo: function(el){
2422 var node = getEl(el).dom;
2423 node.appendChild(this.dom);
2428 insertBefore: function(el){
2429 var node = getEl(el).dom;
2430 node.parentNode.insertBefore(this.dom, node);
2435 insertAfter: function(el){
2436 var node = getEl(el).dom;
2437 node.parentNode.insertBefore(this.dom, node.nextSibling);
2442 wrap: function(config){
2444 config = {tag: 'div'};
2446 var newEl = YAHOO.ext.DomHelper.insertBefore(this.dom, config, true);
2447 newEl.dom.appendChild(this.dom);
2452 replace: function(el){
2454 this.insertBefore(el);
2460 insertHtml : function(where, html){
2461 YAHOO.ext.DomHelper.insertHtml(where, this.dom, html);
2468 var useSet = el.setAttribute ? true : false;
2470 if(attr == 'style' || typeof o[attr] == 'function') continue;
2472 el.className = o['cls'];
2474 if(useSet) el.setAttribute(attr, o[attr]);
2475 else el[attr] = o[attr];
2478 YAHOO.ext.DomHelper.applyStyles(el, o.style);
2483 addKeyListener : function(key, fn, scope){
2485 if(typeof key != 'object' || key instanceof Array){
2501 var map = new YAHOO.ext.KeyMap(this, config);
2506 addKeyMap : function(config){
2507 return new YAHOO.ext.KeyMap(this, config);
2512 YAHOO.ext.Element.prototype.autoBoxAdjust = true;
2514 YAHOO.ext.Element.prototype.autoDisplayMode = true;
2516 YAHOO.ext.Element.unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i;
2518 YAHOO.ext.Element.VISIBILITY = 1;
2520 YAHOO.ext.Element.DISPLAY = 2;
2522 YAHOO.ext.Element.blockElements = /^(?:address|blockquote|center|dir|div|dl|fieldset|form|h\d|hr|isindex|menu|ol|ul|p|pre|table|dd|dt|li|tbody|tr|td|thead|tfoot|iframe)$/i;
2523 YAHOO.ext.Element.borders = {l: 'border-left-width', r: 'border-right-width', t: 'border-top-width', b: 'border-bottom-width'};
2524 YAHOO.ext.Element.paddings = {l: 'padding-left', r: 'padding-right', t: 'padding-top', b: 'padding-bottom'};
2525 YAHOO.ext.Element.margins = {l: 'margin-left', r: 'margin-right', t: 'margin-top', b: 'margin-bottom'};
2528 YAHOO.ext.Element.createStopHandler = function(stopPropagation, handler, scope, override){
2531 if(stopPropagation){
2532 YAHOO.util.Event.stopEvent(e);
2534 YAHOO.util.Event.preventDefault(e);
2537 handler.call(override && scope ? scope : window, e, scope);
2542 YAHOO.ext.Element.cache = {};
2545 YAHOO.ext.Element.get = function(el, autoGenerateId){
2546 if(!el){ return null; }
2547 autoGenerateId = true;
2548 if(el instanceof YAHOO.ext.Element){
2549 el.dom = YAHOO.util.Dom.get(el.id);
2550 YAHOO.ext.Element.cache[el.id] = el;
2552 }else if(el.isComposite){
2554 }else if(el instanceof Array){
2555 return YAHOO.ext.Element.select(el);
2556 }else if(el === document){
2558 if(!YAHOO.ext.Element.cache['__ydocument']){
2559 var docEl = function(){};
2560 docEl.prototype = YAHOO.ext.Element.prototype;
2561 var o = new docEl();
2563 YAHOO.ext.Element.cache['__ydocument'] = o;
2565 return YAHOO.ext.Element.cache['__ydocument'];
2568 if(typeof el != 'string'){
2569 if(!el.id && !autoGenerateId){ return null; }
2570 YAHOO.util.Dom.generateId(el, 'elgen-');
2573 var element = YAHOO.ext.Element.cache[key];
2575 element = new YAHOO.ext.Element(key);
2576 if(!element.dom) return null;
2577 YAHOO.ext.Element.cache[key] = element;
2579 element.dom = YAHOO.util.Dom.get(key);
2585 var getEl = YAHOO.ext.Element.get;
2588 YAHOO.util.Event.addListener(window, 'unload', function(){
2589 YAHOO.ext.Element.cache = null;
2594 YAHOO.ext.CompositeElement = function(els){
2596 this.addElements(els);
2598 YAHOO.ext.CompositeElement.prototype = {
2600 addElements : function(els){
2601 if(!els) return this;
2602 var yels = this.elements;
2603 var index = yels.length-1;
2604 for(var i = 0, len = els.length; i < len; i++) {
2605 yels[++index] = getEl(els[i], true);
2609 invoke : function(fn, args){
2610 var els = this.elements;
2611 for(var i = 0, len = els.length; i < len; i++) {
2612 YAHOO.ext.Element.prototype[fn].apply(els[i], args);
2617 add : function(els){
2618 if(typeof els == 'string'){
2619 this.addElements(YAHOO.ext.Element.selectorFunction(string));
2620 }else if(els instanceof Array){
2621 this.addElements(els);
2623 this.addElements([els]);
2628 each : function(fn, scope){
2629 var els = this.elements;
2630 for(var i = 0, len = els.length; i < len; i++){
2631 fn.call(scope || els[i], els[i], this, i);
2637 YAHOO.ext.CompositeElementLite = function(els){
2638 YAHOO.ext.CompositeElementLite.superclass.constructor.call(this, els);
2639 this.el = YAHOO.ext.Element.get(this.elements[0], true);
2641 YAHOO.extendX(YAHOO.ext.CompositeElementLite, YAHOO.ext.CompositeElement, {
2642 addElements : function(els){
2644 this.elements = this.elements.concat(els);
2648 invoke : function(fn, args){
2649 var els = this.elements;
2651 for(var i = 0, len = els.length; i < len; i++) {
2653 YAHOO.ext.Element.prototype[fn].apply(el, args);
2658 YAHOO.ext.CompositeElement.createCall = function(proto, fnName){
2660 proto[fnName] = function(){
2661 return this.invoke(fnName, arguments);
2665 for(var fnName in YAHOO.ext.Element.prototype){
2666 if(typeof YAHOO.ext.Element.prototype[fnName] == 'function'){
2667 YAHOO.ext.CompositeElement.createCall(YAHOO.ext.CompositeElement.prototype, fnName);
2670 if(typeof cssQuery == 'function'){
2671 YAHOO.ext.Element.selectorFunction = cssQuery;
2672 }else if(typeof document.getElementsBySelector == 'function'){
2673 YAHOO.ext.Element.selectorFunction = document.getElementsBySelector.createDelegate(document);
2676 YAHOO.ext.Element.select = function(selector, unique){
2678 if(typeof selector == 'string'){
2679 els = YAHOO.ext.Element.selectorFunction(selector);
2680 }else if(selector instanceof Array){
2683 throw 'Invalid selector';
2685 if(unique === true){
2686 return new YAHOO.ext.CompositeElement(els);
2688 return new YAHOO.ext.CompositeElementLite(els);
2692 var getEls = YAHOO.ext.Element.select;
2693 YAHOO.namespace('ext.state');
2695 YAHOO.ext.state.Provider = function(){
2696 YAHOO.ext.state.Provider.superclass.constructor.call(this);
2699 'statechange': new YAHOO.util.CustomEvent('statechange')
2703 YAHOO.extendX(YAHOO.ext.state.Provider, YAHOO.ext.util.Observable, {
2705 get : function(name, defaultValue){
2706 return typeof this.state[name] == 'undefined' ?
2707 defaultValue : this.state[name];
2711 clear : function(name){
2712 delete this.state[name];
2713 this.fireEvent('statechange', this, name, null);
2717 set : function(name, value){
2718 this.state[name] = value;
2719 this.fireEvent('statechange', this, name, value);
2723 decodeValue : function(cookie){
2724 var re = /^(a|n|d|b|s|o)\:(.*)$/;
2725 var matches = re.exec(unescape(cookie));
2726 if(!matches || !matches[1]) return;
2727 var type = matches[1];
2731 return parseFloat(v);
2733 return new Date(Date.parse(v));
2738 var values = v.split('^');
2739 for(var i = 0, len = values.length; i < len; i++){
2740 all.push(this.decodeValue(values[i]))
2745 var values = v.split('^');
2746 for(var i = 0, len = values.length; i < len; i++){
2747 var kv = values[i].split('=');
2748 all[kv[0]] = this.decodeValue(kv[1]);
2757 encodeValue : function(v){
2759 if(typeof v == 'number'){
2761 }else if(typeof v == 'boolean'){
2762 enc = 'b:' + (v ? '1' : '0');
2763 }else if(v instanceof Date){
2764 enc = 'd:' + v.toGMTString();
2765 }else if(v instanceof Array){
2767 for(var i = 0, len = v.length; i < len; i++){
2768 flat += this.encodeValue(v[i]);
2769 if(i != len-1) flat += '^';
2772 }else if(typeof v == 'object'){
2775 if(typeof v[key] != 'function'){
2776 flat += key + '=' + this.encodeValue(v[key]) + '^';
2779 enc = 'o:' + flat.substring(0, flat.length-1);
2788 YAHOO.ext.state.Manager = new function(){
2789 var provider = new YAHOO.ext.state.Provider();
2793 setProvider : function(stateProvider){
2794 provider = stateProvider;
2798 get : function(key, defaultValue){
2799 return provider.get(key, defaultValue);
2803 set : function(key, value){
2804 provider.set(key, value);
2808 clear : function(key){
2809 provider.clear(key);
2813 getProvider : function(){
2820 YAHOO.ext.state.CookieProvider = function(config){
2821 YAHOO.ext.state.CookieProvider.superclass.constructor.call(this);
2823 this.expires = new Date(new Date().getTime()+(1000*60*60*24*7));
2825 this.secure = false;
2826 YAHOO.ext.util.Config.apply(this, config);
2827 this.state = this.readCookies();
2830 YAHOO.extendX(YAHOO.ext.state.CookieProvider, YAHOO.ext.state.Provider, {
2831 set : function(name, value){
2832 if(typeof value == 'undefined' || value === null){
2836 this.setCookie(name, value);
2837 YAHOO.ext.state.CookieProvider.superclass.set.call(this, name, value);
2840 clear : function(name){
2841 this.clearCookie(name);
2842 YAHOO.ext.state.CookieProvider.superclass.clear.call(this, name);
2845 readCookies : function(){
2847 var c = document.cookie + ';';
2848 var re = /\s?(.*?)=(.*?);/g;
2850 while((matches = re.exec(c)) != null){
2851 var name = matches[1];
2852 var value = matches[2];
2853 if(name && name.substring(0,3) == 'ys-'){
2854 cookies[name.substr(3)] = this.decodeValue(value);
2860 setCookie : function(name, value){
2861 document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
2862 ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
2863 ((this.path == null) ? "" : ("; path=" + this.path)) +
2864 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
2865 ((this.secure == true) ? "; secure" : "");
2868 clearCookie : function(name){
2869 document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
2870 ((this.path == null) ? "" : ("; path=" + this.path)) +
2871 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
2872 ((this.secure == true) ? "; secure" : "");
2878 YAHOO.ext.EventManager = new function(){
2881 var docReadyState = false;
2882 this.ieDeferSrc = false;
2886 var fireDocReady = function(){
2888 docReadyState = true;
2890 clearInterval(docReadyProcId);
2893 docReadyEvent.fire();
2898 var initDocReady = function(){
2899 docReadyEvent = new YAHOO.util.CustomEvent('documentready');
2900 if(document.addEventListener) {
2901 YAHOO.util.Event.on(document, "DOMContentLoaded", fireDocReady);
2902 }else if(YAHOO.ext.util.Browser.isIE){
2904 document.write('<s'+'cript id="ie-deferred-loader" defer="defer" src="' +
2905 (YAHOO.ext.EventManager.ieDeferSrc || YAHOO.ext.SSL_SECURE_URL) + '"></s'+'cript>');
2906 YAHOO.util.Event.on('ie-deferred-loader', 'readystatechange', function(){
2907 if(this.readyState == 'complete'){
2911 }else if(YAHOO.ext.util.Browser.isSafari){
2912 docReadyProcId = setInterval(function(){
2913 var rs = document.readyState;
2914 if(rs == 'loaded' || rs == 'complete') {
2920 YAHOO.util.Event.on(window, 'load', fireDocReady);
2923 this.wrap = function(fn, scope, override){
2924 var wrappedFn = function(e){
2925 YAHOO.ext.EventObject.setEvent(e);
2926 fn.call(override ? scope || window : window, YAHOO.ext.EventObject, scope);
2932 this.addListener = function(element, eventName, fn, scope, override){
2933 var wrappedFn = this.wrap(fn, scope, override);
2934 YAHOO.util.Event.addListener(element, eventName, wrappedFn);
2939 this.removeListener = function(element, eventName, wrappedFn){
2940 return YAHOO.util.Event.removeListener(element, eventName, wrappedFn);
2944 this.on = this.addListener;
2947 this.onDocumentReady = function(fn, scope, override){
2949 fn.call(override? scope || window : window, scope);
2955 docReadyEvent.subscribe(fn, scope, override);
2959 this.onWindowResize = function(fn, scope, override){
2961 resizeEvent = new YAHOO.util.CustomEvent('windowresize');
2962 resizeTask = new YAHOO.ext.util.DelayedTask(function(){
2963 resizeEvent.fireDirect(YAHOO.util.Dom.getViewportWidth(), YAHOO.util.Dom.getViewportHeight());
2965 YAHOO.util.Event.on(window, 'resize', function(){
2966 resizeTask.delay(50);
2969 resizeEvent.subscribe(fn, scope, override);
2973 this.removeResizeListener = function(fn, scope){
2975 resizeEvent.unsubscribe(fn, scope);
2981 YAHOO.ext.EventObject = new function(){
2983 this.browserEvent = null;
2987 this.shiftKey = false;
2989 this.ctrlKey = false;
2991 this.altKey = false;
3025 this.setEvent = function(e){
3029 this.browserEvent = e;
3031 this.button = e.button;
3032 this.shiftKey = e.shiftKey;
3033 this.ctrlKey = e.ctrlKey;
3034 this.altKey = e.altKey;
3037 this.shiftKey = false;
3038 this.ctrlKey = false;
3039 this.altKey = false;
3045 this.stopEvent = function(){
3046 if(this.browserEvent){
3047 YAHOO.util.Event.stopEvent(this.browserEvent);
3052 this.preventDefault = function(){
3053 if(this.browserEvent){
3054 YAHOO.util.Event.preventDefault(this.browserEvent);
3059 this.isNavKeyPress = function(){
3060 return (this.browserEvent.keyCode && this.browserEvent.keyCode >= 33 && this.browserEvent.keyCode <= 40);
3064 this.stopPropagation = function(){
3065 if(this.browserEvent){
3066 YAHOO.util.Event.stopPropagation(this.browserEvent);
3071 this.getCharCode = function(){
3072 if(this.browserEvent){
3073 return YAHOO.util.Event.getCharCode(this.browserEvent);
3079 this.getKey = function(){
3080 if(this.browserEvent){
3081 return this.browserEvent.keyCode || this.browserEvent.charCode;
3087 this.getPageX = function(){
3088 if(this.browserEvent){
3089 return YAHOO.util.Event.getPageX(this.browserEvent);
3095 this.getPageY = function(){
3096 if(this.browserEvent){
3097 return YAHOO.util.Event.getPageY(this.browserEvent);
3103 this.getTime = function(){
3104 if(this.browserEvent){
3105 return YAHOO.util.Event.getTime(this.browserEvent);
3111 this.getXY = function(){
3112 if(this.browserEvent){
3113 return YAHOO.util.Event.getXY(this.browserEvent);
3119 this.getTarget = function(){
3120 if(this.browserEvent){
3121 return YAHOO.util.Event.getTarget(this.browserEvent);
3127 this.findTarget = function(className, tagName){
3128 if(tagName) tagName = tagName.toLowerCase();
3129 if(this.browserEvent){
3130 function isMatch(el){
3134 if(className && !YAHOO.util.Dom.hasClass(el, className)){
3137 if(tagName && el.tagName.toLowerCase() != tagName){
3143 var t = this.getTarget();
3144 if(!t || isMatch(t)){
3147 var p = t.parentNode;
3148 var b = document.body;
3159 this.getRelatedTarget = function(){
3160 if(this.browserEvent){
3161 return YAHOO.util.Event.getRelatedTarget(this.browserEvent);
3167 this.getWheelDelta = function(){
3168 var e = this.browserEvent;
3171 delta = e.wheelDelta/120;
3173 if(window.opera) delta = -delta;
3175 delta = -e.detail/3;
3181 this.hasModifier = function(){
3182 return this.ctrlKey || this.altKey || this.shiftKey;
3188 YAHOO.ext.UpdateManager = function(el, forceNew){
3189 el = YAHOO.ext.Element.get(el);
3190 if(!forceNew && el.updateManager){
3191 return el.updateManager;
3196 this.defaultUrl = null;
3197 this.beforeUpdate = new YAHOO.util.CustomEvent('UpdateManager.beforeUpdate');
3198 this.onUpdate = new YAHOO.util.CustomEvent('UpdateManager.onUpdate');
3199 this.onFailure = new YAHOO.util.CustomEvent('UpdateManager.onFailure');
3203 'beforeupdate': this.beforeUpdate,
3205 'update': this.onUpdate,
3207 'failure': this.onFailure
3211 this.sslBlankUrl = YAHOO.ext.UpdateManager.defaults.sslBlankUrl;
3213 this.disableCaching = YAHOO.ext.UpdateManager.defaults.disableCaching;
3215 this.indicatorText = YAHOO.ext.UpdateManager.defaults.indicatorText;
3217 this.showLoadIndicator = YAHOO.ext.UpdateManager.defaults.showLoadIndicator;
3219 this.timeout = YAHOO.ext.UpdateManager.defaults.timeout;
3222 this.loadScripts = YAHOO.ext.UpdateManager.defaults.loadScripts;
3225 this.transaction = null;
3228 this.autoRefreshProcId = null;
3230 this.refreshDelegate = this.refresh.createDelegate(this);
3232 this.updateDelegate = this.update.createDelegate(this);
3234 this.formUpdateDelegate = this.formUpdate.createDelegate(this);
3236 this.successDelegate = this.processSuccess.createDelegate(this);
3238 this.failureDelegate = this.processFailure.createDelegate(this);
3241 this.renderer = new YAHOO.ext.UpdateManager.BasicRenderer();
3244 YAHOO.ext.UpdateManager.prototype = {
3245 fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent,
3246 on : YAHOO.ext.util.Observable.prototype.on,
3247 addListener : YAHOO.ext.util.Observable.prototype.addListener,
3248 delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener,
3249 removeListener : YAHOO.ext.util.Observable.prototype.removeListener,
3250 purgeListeners : YAHOO.ext.util.Observable.prototype.purgeListeners,
3251 bufferedListener : YAHOO.ext.util.Observable.prototype.bufferedListener,
3258 update : function(url, params, callback, discardUrl){
3259 if(this.beforeUpdate.fireDirect(this.el, url, params) !== false){
3260 if(typeof url == 'object'){
3263 params = params || cfg.params;
3264 callback = callback || cfg.callback;
3265 discardUrl = discardUrl || cfg.discardUrl;
3266 if(callback && cfg.scope){
3267 callback = callback.createDelegate(cfg.scope);
3269 if(typeof cfg.nocache != 'undefined'){this.disableCaching = cfg.nocache};
3270 if(typeof cfg.text != 'undefined'){this.indicatorText = '<div class="loading-indicator">'+cfg.text+'</div>'};
3271 if(typeof cfg.scripts != 'undefined'){this.loadScripts = cfg.scripts};
3272 if(typeof cfg.timeout != 'undefined'){this.timeout = cfg.timeout};
3276 this.defaultUrl = url;
3278 if(typeof url == 'function'){
3281 if(typeof params == 'function'){
3284 if(params && typeof params != 'string'){
3286 for(var key in params){
3287 if(typeof params[key] != 'function'){
3288 buf.push(encodeURIComponent(key), '=', encodeURIComponent(params[key]), '&');
3291 delete buf[buf.length-1];
3292 params = buf.join('');
3295 success: this.successDelegate,
3296 failure: this.failureDelegate,
3297 timeout: (this.timeout*1000),
3298 argument: {'url': url, 'form': null, 'callback': callback, 'params': params}
3300 var method = params ? 'POST' : 'GET';
3301 if(method == 'GET'){
3302 url = this.prepareUrl(url);
3304 this.transaction = YAHOO.util.Connect.asyncRequest(method, url, callback, params);
3309 formUpdate : function(form, url, reset, callback){
3310 if(this.beforeUpdate.fireDirect(this.el, form, url) !== false){
3312 formEl = YAHOO.util.Dom.get(form);
3313 if(typeof url == 'function'){
3316 if(typeof params == 'function'){
3319 url = url || formEl.action;
3321 success: this.successDelegate,
3322 failure: this.failureDelegate,
3323 timeout: (this.timeout*1000),
3324 argument: {'url': url, 'form': form, 'callback': callback, 'reset': reset}
3326 var isUpload = false;
3327 var enctype = formEl.getAttribute('enctype');
3328 if(enctype && enctype.toLowerCase() == 'multipart/form-data'){
3331 YAHOO.util.Connect.setForm(form, isUpload, this.sslBlankUrl);
3332 this.transaction = YAHOO.util.Connect.asyncRequest('POST', url, callback);
3337 refresh : function(callback){
3338 if(this.defaultUrl == null){
3341 this.update(this.defaultUrl, null, callback, true);
3345 startAutoRefresh : function(interval, url, params, callback, refreshNow){
3347 this.update(url || this.defaultUrl, params, callback, true);
3349 if(this.autoRefreshProcId){
3350 clearInterval(this.autoRefreshProcId);
3352 this.autoRefreshProcId = setInterval(this.update.createDelegate(this, [url || this.defaultUrl, params, callback, true]), interval*1000);
3356 stopAutoRefresh : function(){
3357 if(this.autoRefreshProcId){
3358 clearInterval(this.autoRefreshProcId);
3363 showLoading : function(){
3364 if(this.showLoadIndicator){
3365 this.el.update(this.indicatorText);
3370 prepareUrl : function(url){
3371 if(this.disableCaching){
3372 var append = '_dc=' + (new Date().getTime());
3373 if(url.indexOf('?') !== -1){
3374 url += '&' + append;
3376 url += '?' + append;
3383 processSuccess : function(response){
3384 this.transaction = null;
3385 if(response.argument.form && response.argument.reset){
3387 response.argument.form.reset();
3390 if(this.loadScripts){
3391 this.renderer.render(this.el, response, this,
3392 this.updateComplete.createDelegate(this, [response]));
3394 this.renderer.render(this.el, response, this);
3395 this.updateComplete(response);
3399 updateComplete : function(response){
3400 this.fireEvent('update', this.el, response);
3401 if(typeof response.argument.callback == 'function'){
3402 response.argument.callback(this.el, true);
3407 processFailure : function(response){
3408 this.transaction = null;
3409 this.onFailure.fireDirect(this.el, response);
3410 if(typeof response.argument.callback == 'function'){
3411 response.argument.callback(this.el, false);
3416 setRenderer : function(renderer){
3417 this.renderer = renderer;
3420 getRenderer : function(){
3421 return this.renderer;
3425 setDefaultUrl : function(defaultUrl){
3426 this.defaultUrl = defaultUrl;
3431 if(this.transaction){
3432 YAHOO.util.Connect.abort(this.transaction);
3437 isUpdating : function(){
3438 if(this.transaction){
3439 return YAHOO.util.Connect.isCallInProgress(this.transaction);
3446 YAHOO.ext.UpdateManager.defaults = {
3451 loadScripts : false,
3454 sslBlankUrl : (YAHOO.ext.SSL_SECURE_URL || 'javascript:false'),
3456 disableCaching : false,
3458 showLoadIndicator : true,
3460 indicatorText : '<div class="loading-indicator">Loading...</div>'
3464 YAHOO.ext.UpdateManager.updateElement = function(el, url, params, options){
3465 var um = getEl(el, true).getUpdateManager();
3466 YAHOO.ext.util.Config.apply(um, options);
3467 um.update(url, params, options.callback);
3470 YAHOO.ext.UpdateManager.update = YAHOO.ext.UpdateManager.updateElement;
3472 YAHOO.ext.UpdateManager.BasicRenderer = function(){};
3474 YAHOO.ext.UpdateManager.BasicRenderer.prototype = {
3476 render : function(el, response, updateManager, callback){
3477 el.update(response.responseText, updateManager.loadScripts, callback);
3483 Date.parseFunctions = {count:0};
3485 Date.parseRegexes = [];
3487 Date.formatFunctions = {count:0};
3490 Date.prototype.dateFormat = function(format) {
3491 if (Date.formatFunctions[format] == null) {
3492 Date.createNewFormat(format);
3494 var func = Date.formatFunctions[format];
3495 return this[func]();
3499 Date.prototype.format = Date.prototype.dateFormat;
3502 Date.createNewFormat = function(format) {
3503 var funcName = "format" + Date.formatFunctions.count++;
3504 Date.formatFunctions[format] = funcName;
3505 var code = "Date.prototype." + funcName + " = function(){return ";
3506 var special = false;
3508 for (var i = 0; i < format.length; ++i) {
3509 ch = format.charAt(i);
3510 if (!special && ch == "\\") {
3515 code += "'" + String.escape(ch) + "' + ";
3518 code += Date.getFormatCode(ch);
3521 eval(code.substring(0, code.length - 3) + ";}");
3525 Date.getFormatCode = function(character) {
3526 switch (character) {
3528 return "String.leftPad(this.getDate(), 2, '0') + ";
3530 return "Date.dayNames[this.getDay()].substring(0, 3) + ";
3532 return "this.getDate() + ";
3534 return "Date.dayNames[this.getDay()] + ";
3536 return "this.getSuffix() + ";
3538 return "this.getDay() + ";
3540 return "this.getDayOfYear() + ";
3542 return "this.getWeekOfYear() + ";
3544 return "Date.monthNames[this.getMonth()] + ";
3546 return "String.leftPad(this.getMonth() + 1, 2, '0') + ";
3548 return "Date.monthNames[this.getMonth()].substring(0, 3) + ";
3550 return "(this.getMonth() + 1) + ";
3552 return "this.getDaysInMonth() + ";
3554 return "(this.isLeapYear() ? 1 : 0) + ";
3556 return "this.getFullYear() + ";
3558 return "('' + this.getFullYear()).substring(2, 4) + ";
3560 return "(this.getHours() < 12 ? 'am' : 'pm') + ";
3562 return "(this.getHours() < 12 ? 'AM' : 'PM') + ";
3564 return "((this.getHours() %12) ? this.getHours() % 12 : 12) + ";
3566 return "this.getHours() + ";
3568 return "String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";
3570 return "String.leftPad(this.getHours(), 2, '0') + ";
3572 return "String.leftPad(this.getMinutes(), 2, '0') + ";
3574 return "String.leftPad(this.getSeconds(), 2, '0') + ";
3576 return "this.getGMTOffset() + ";
3578 return "this.getTimezone() + ";
3580 return "(this.getTimezoneOffset() * -60) + ";
3582 return "'" + String.escape(character) + "' + ";
3587 Date.parseDate = function(input, format) {
3588 if (Date.parseFunctions[format] == null) {
3589 Date.createParser(format);
3591 var func = Date.parseFunctions[format];
3592 return Date[func](input);
3596 Date.createParser = function(format) {
3597 var funcName = "parse" + Date.parseFunctions.count++;
3598 var regexNum = Date.parseRegexes.length;
3599 var currentGroup = 1;
3600 Date.parseFunctions[format] = funcName;
3602 var code = "Date." + funcName + " = function(input){\n"
3603 + "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1;\n"
3604 + "var d = new Date();\n"
3605 + "y = d.getFullYear();\n"
3606 + "m = d.getMonth();\n"
3607 + "d = d.getDate();\n"
3608 + "var results = input.match(Date.parseRegexes[" + regexNum + "]);\n"
3609 + "if (results && results.length > 0) {"
3612 var special = false;
3614 for (var i = 0; i < format.length; ++i) {
3615 ch = format.charAt(i);
3616 if (!special && ch == "\\") {
3621 regex += String.escape(ch);
3624 obj = Date.formatCodeToRegex(ch, currentGroup);
3625 currentGroup += obj.g;
3627 if (obj.g && obj.c) {
3633 code += "if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"
3634 + "{return new Date(y, m, d, h, i, s);}\n"
3635 + "else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"
3636 + "{return new Date(y, m, d, h, i);}\n"
3637 + "else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n"
3638 + "{return new Date(y, m, d, h);}\n"
3639 + "else if (y > 0 && m >= 0 && d > 0)\n"
3640 + "{return new Date(y, m, d);}\n"
3641 + "else if (y > 0 && m >= 0)\n"
3642 + "{return new Date(y, m);}\n"
3643 + "else if (y > 0)\n"
3644 + "{return new Date(y);}\n"
3647 Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$");
3652 Date.formatCodeToRegex = function(character, currentGroup) {
3653 switch (character) {
3657 s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};
3661 c:"d = parseInt(results[" + currentGroup + "], 10);\n",
3666 s:"(?:" + Date.dayNames.join("|") + ")"};
3670 s:"(?:st|nd|rd|th)"};
3685 c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "].substring(0, 3)], 10);\n",
3686 s:"(" + Date.monthNames.join("|") + ")"};
3689 c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "]], 10);\n",
3690 s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};
3694 c:"m = parseInt(results[" + currentGroup + "], 10) - 1;\n",
3706 c:"y = parseInt(results[" + currentGroup + "], 10);\n",
3710 c:"var ty = parseInt(results[" + currentGroup + "], 10);\n"
3711 + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
3715 c:"if (results[" + currentGroup + "] == 'am') {\n"
3716 + "if (h == 12) { h = 0; }\n"
3717 + "} else { if (h < 12) { h += 12; }}",
3721 c:"if (results[" + currentGroup + "] == 'AM') {\n"
3722 + "if (h == 12) { h = 0; }\n"
3723 + "} else { if (h < 12) { h += 12; }}",
3730 c:"h = parseInt(results[" + currentGroup + "], 10);\n",
3734 c:"i = parseInt(results[" + currentGroup + "], 10);\n",
3738 c:"s = parseInt(results[" + currentGroup + "], 10);\n",
3755 s:String.escape(character)};
3759 Date.prototype.getTimezone = function() {
3760 return this.toString().replace(
3761 /^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace(
3762 /^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3");
3765 Date.prototype.getGMTOffset = function() {
3766 return (this.getTimezoneOffset() > 0 ? "-" : "+")
3767 + String.leftPad(Math.floor(this.getTimezoneOffset() / 60), 2, "0")
3768 + String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
3771 Date.prototype.getDayOfYear = function() {
3773 Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
3774 for (var i = 0; i < this.getMonth(); ++i) {
3775 num += Date.daysInMonth[i];
3777 return num + this.getDate() - 1;
3780 Date.prototype.getWeekOfYear = function() {
3782 var now = this.getDayOfYear() + (4 - this.getDay());
3784 var jan1 = new Date(this.getFullYear(), 0, 1);
3785 var then = (7 - jan1.getDay() + 4);
3786 return String.leftPad(((now - then) / 7) + 1, 2, "0");
3789 Date.prototype.isLeapYear = function() {
3790 var year = this.getFullYear();
3791 return ((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
3794 Date.prototype.getFirstDayOfMonth = function() {
3795 var day = (this.getDay() - (this.getDate() - 1)) % 7;
3796 return (day < 0) ? (day + 7) : day;
3799 Date.prototype.getLastDayOfMonth = function() {
3800 var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
3801 return (day < 0) ? (day + 7) : day;
3804 Date.prototype.getDaysInMonth = function() {
3805 Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
3806 return Date.daysInMonth[this.getMonth()];
3810 Date.prototype.getSuffix = function() {
3811 switch (this.getDate()) {
3828 Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
3859 Date.monthNumbers = {
3873 YAHOO.ext.TabPanel = function(container, config){
3875 this.el = getEl(container, true);
3877 this.tabPosition = 'top';
3878 this.currentTabWidth = 0;
3880 this.minTabWidth = 40;
3882 this.maxTabWidth = 250;
3884 this.preferredTabWidth = 175;
3886 this.resizeTabs = false;
3888 this.monitorResize = true;
3891 if(typeof config == 'boolean'){
3892 this.tabPosition = config ? 'bottom' : 'top';
3894 YAHOO.ext.util.Config.apply(this, config);
3897 if(this.tabPosition == 'bottom'){
3898 this.bodyEl = getEl(this.createBody(this.el.dom));
3899 this.el.addClass('ytabs-bottom');
3901 this.stripWrap = getEl(this.createStrip(this.el.dom), true);
3902 this.stripEl = getEl(this.createStripList(this.stripWrap.dom), true);
3903 this.stripBody = getEl(this.stripWrap.dom.firstChild.firstChild, true);
3904 if(YAHOO.ext.util.Browser.isIE){
3905 YAHOO.util.Dom.setStyle(this.stripWrap.dom.firstChild, 'overflow-x', 'hidden');
3907 if(this.tabPosition != 'bottom'){
3909 this.bodyEl = getEl(this.createBody(this.el.dom));
3910 this.el.addClass('ytabs-top');
3914 this.bodyEl.setStyle('position', 'relative');
3917 if(!this.items.indexOf){
3918 this.items.indexOf = function(o){
3919 for(var i = 0, len = this.length; i < len; i++){
3920 if(this[i] == o) return i;
3926 this.onTabChange = new YAHOO.util.CustomEvent('TabItem.onTabChange');
3927 this.activateDelegate = this.activate.createDelegate(this);
3931 'tabchange': this.onTabChange,
3933 'beforetabchange' : new YAHOO.util.CustomEvent('beforechange')
3936 YAHOO.ext.EventManager.onWindowResize(this.onResize, this, true);
3937 this.cpad = this.el.getPadding('lr');
3938 this.hiddenCount = 0;
3941 YAHOO.ext.TabPanel.prototype = {
3942 fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent,
3943 on : YAHOO.ext.util.Observable.prototype.on,
3944 addListener : YAHOO.ext.util.Observable.prototype.addListener,
3945 delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener,
3946 removeListener : YAHOO.ext.util.Observable.prototype.removeListener,
3947 purgeListeners : YAHOO.ext.util.Observable.prototype.purgeListeners,
3949 addTab : function(id, text, content, closable){
3950 var item = new YAHOO.ext.TabPanelItem(this, id, text, closable);
3951 this.addTabItem(item);
3953 item.setContent(content);
3959 getTab : function(id){
3960 return this.items[id];
3964 hideTab : function(id){
3965 var t = this.items[id];
3969 this.autoSizeTabs();
3974 unhideTab : function(id){
3975 var t = this.items[id];
3979 this.autoSizeTabs();
3984 addTabItem : function(item){
3985 this.items[item.id] = item;
3986 this.items.push(item);
3987 if(this.resizeTabs){
3988 item.setWidth(this.currentTabWidth || this.preferredTabWidth)
3989 this.autoSizeTabs();
3996 removeTab : function(id){
3997 var items = this.items;
3998 var tab = items[id];
4000 var index = items.indexOf(tab);
4001 if(this.active == tab && items.length > 1){
4002 var newTab = this.getNextAvailable(index);
4003 if(newTab)newTab.activate();
4005 this.stripEl.dom.removeChild(tab.pnode.dom);
4006 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){
4007 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
4009 items.splice(index, 1);
4010 delete this.items[tab.id];
4011 tab.fireEvent('close', tab);
4012 tab.purgeListeners();
4013 this.autoSizeTabs();
4016 getNextAvailable : function(start){
4017 var items = this.items;
4021 while(index < items.length){
4022 var item = items[++index];
4023 if(item && !item.isHidden()){
4030 var item = items[--index];
4031 if(item && !item.isHidden()){
4039 disableTab : function(id){
4040 var tab = this.items[id];
4041 if(tab && this.active != tab){
4047 enableTab : function(id){
4048 var tab = this.items[id];
4053 activate : function(id){
4054 var tab = this.items[id];
4055 if(tab == this.active){
4059 this.fireEvent('beforetabchange', this, e, tab);
4060 if(e.cancel !== true && !tab.disabled){
4064 this.active = this.items[id];
4066 this.onTabChange.fireDirect(this, this.active);
4072 getActiveTab : function(){
4077 syncHeight : function(targetHeight){
4078 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth('tb')-this.el.getPadding('tb');
4079 var bm = this.bodyEl.getMargins();
4080 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
4081 this.bodyEl.setHeight(newHeight);
4085 onResize : function(){
4086 if(this.monitorResize){
4087 this.autoSizeTabs();
4092 beginUpdate : function(){
4093 this.updating = true;
4097 endUpdate : function(){
4098 this.updating = false;
4099 this.autoSizeTabs();
4103 autoSizeTabs : function(){
4104 var count = this.items.length;
4105 var vcount = count - this.hiddenCount;
4106 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) return;
4107 var w = Math.max(this.el.getWidth() - this.cpad, 10);
4108 var availWidth = Math.floor(w / vcount);
4109 var b = this.stripBody;
4110 if(b.getWidth() > w){
4111 var tabs = this.items;
4112 this.setTabWidth(Math.max(availWidth, this.minTabWidth));
4113 if(availWidth < this.minTabWidth){
4117 if(this.currentTabWidth < this.preferredTabWidth){
4118 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth));
4124 getCount : function(){
4125 return this.items.length;
4129 setTabWidth : function(width){
4130 this.currentTabWidth = width;
4131 for(var i = 0, len = this.items.length; i < len; i++) {
4132 if(!this.items[i].isHidden())this.items[i].setWidth(width);
4137 destroy : function(removeEl){
4138 YAHOO.ext.EventManager.removeResizeListener(this.onResize, this);
4139 for(var i = 0, len = this.items.length; i < len; i++){
4140 this.items[i].purgeListeners();
4142 if(removeEl === true){
4150 YAHOO.ext.TabPanelItem = function(tabPanel, id, text, closable){
4152 this.tabPanel = tabPanel;
4156 this.disabled = false;
4160 this.loaded = false;
4161 this.closable = closable;
4164 this.bodyEl = getEl(tabPanel.createItemBody(tabPanel.bodyEl.dom, id));
4165 this.bodyEl.setVisibilityMode(YAHOO.ext.Element.VISIBILITY);
4166 this.bodyEl.setStyle('display', 'block');
4167 this.bodyEl.setStyle('zoom', '1');
4170 var els = tabPanel.createStripElements(tabPanel.stripEl.dom, text, closable);
4172 this.el = getEl(els.el, true);
4173 this.inner = getEl(els.inner, true);
4174 this.textEl = getEl(this.el.dom.firstChild.firstChild.firstChild, true);
4175 this.pnode = getEl(els.el.parentNode, true);
4176 this.el.mon('click', this.onTabClick, this, true);
4179 var c = getEl(els.close, true);
4180 c.dom.title = this.closeText;
4181 c.addClassOnOver('close-over');
4182 c.mon('click', this.closeClick, this, true);
4186 this.onActivate = new YAHOO.util.CustomEvent('TabItem.onActivate');
4187 this.onDeactivate = new YAHOO.util.CustomEvent('TabItem.onDeactivate');
4191 'activate': this.onActivate,
4193 'beforeclose': new YAHOO.util.CustomEvent('beforeclose'),
4195 'close': new YAHOO.util.CustomEvent('close'),
4197 'deactivate' : this.onDeactivate
4199 this.hidden = false;
4202 YAHOO.ext.TabPanelItem.prototype = {
4203 fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent,
4204 on : YAHOO.ext.util.Observable.prototype.on,
4205 addListener : YAHOO.ext.util.Observable.prototype.addListener,
4206 delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener,
4207 removeListener : YAHOO.ext.util.Observable.prototype.removeListener,
4208 purgeListeners : function(){
4209 YAHOO.ext.util.Observable.prototype.purgeListeners.call(this);
4210 this.el.removeAllListeners();
4214 this.pnode.addClass('on');
4216 if(YAHOO.ext.util.Browser.isOpera){
4217 this.tabPanel.stripWrap.repaint();
4219 this.onActivate.fireDirect(this.tabPanel, this);
4223 isActive : function(){
4224 return this.tabPanel.getActiveTab() == this;
4229 this.pnode.removeClass('on');
4231 this.onDeactivate.fireDirect(this.tabPanel, this);
4234 hideAction : function(){
4235 this.bodyEl.setStyle('position', 'absolute');
4236 this.bodyEl.setLeft('-20000px');
4237 this.bodyEl.setTop('-20000px');
4241 showAction : function(){
4242 this.bodyEl.setStyle('position', 'relative');
4243 this.bodyEl.setTop('');
4244 this.bodyEl.setLeft('');
4246 this.tabPanel.el.repaint.defer(1);
4250 setTooltip : function(text){
4251 this.textEl.dom.title = text;
4254 onTabClick : function(e){
4256 this.tabPanel.activate(this.id);
4259 getWidth : function(){
4260 return this.inner.getWidth();
4263 setWidth : function(width){
4264 var iwidth = width - this.pnode.getPadding("lr");
4265 this.inner.setWidth(iwidth);
4266 this.textEl.setWidth(iwidth-this.inner.getPadding('lr'));
4267 this.pnode.setWidth(width);
4270 setHidden : function(hidden){
4271 this.hidden = hidden;
4272 this.pnode.setStyle('display', hidden ? 'none' : '');
4276 isHidden : function(){
4281 getText : function(){
4285 autoSize : function(){
4286 this.el.beginMeasure();
4287 this.textEl.setWidth(1);
4288 this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding('lr'));
4289 this.el.endMeasure();
4293 setText : function(text){
4295 this.textEl.update(text);
4296 this.textEl.dom.title = text;
4297 if(!this.tabPanel.resizeTabs){
4302 activate : function(){
4303 this.tabPanel.activate(this.id);
4307 disable : function(){
4308 if(this.tabPanel.active != this){
4309 this.disabled = true;
4310 this.pnode.addClass('disabled');
4315 enable : function(){
4316 this.disabled = false;
4317 this.pnode.removeClass('disabled');
4321 setContent : function(content, loadScripts){
4322 this.bodyEl.update(content, loadScripts);
4326 getUpdateManager : function(){
4327 return this.bodyEl.getUpdateManager();
4331 setUrl : function(url, params, loadOnce){
4332 if(this.refreshDelegate){
4333 this.onActivate.unsubscribe(this.refreshDelegate);
4335 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
4336 this.onActivate.subscribe(this.refreshDelegate);
4337 return this.bodyEl.getUpdateManager();
4341 _handleRefresh : function(url, params, loadOnce){
4342 if(!loadOnce || !this.loaded){
4343 var updater = this.bodyEl.getUpdateManager();
4344 updater.update(url, params, this._setLoaded.createDelegate(this));
4349 refresh : function(){
4350 if(this.refreshDelegate){
4351 this.loaded = false;
4352 this.refreshDelegate();
4357 _setLoaded : function(){
4362 closeClick : function(e){
4364 this.fireEvent('beforeclose', this, e);
4365 if(e.cancel !== true){
4366 this.tabPanel.removeTab(this.id);
4370 closeText : 'Close this tab'
4374 YAHOO.ext.TabPanel.prototype.createStrip = function(container){
4375 var strip = document.createElement('div');
4376 strip.className = 'ytab-wrap';
4377 container.appendChild(strip);
4381 YAHOO.ext.TabPanel.prototype.createStripList = function(strip){
4383 strip.innerHTML = '<div class="ytab-strip-wrap"><table class="ytab-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr></tr></tbody></table></div>';
4384 return strip.firstChild.firstChild.firstChild.firstChild;
4387 YAHOO.ext.TabPanel.prototype.createBody = function(container){
4388 var body = document.createElement('div');
4389 YAHOO.util.Dom.generateId(body, 'tab-body');
4390 YAHOO.util.Dom.addClass(body, 'yui-ext-tabbody');
4391 container.appendChild(body);
4395 YAHOO.ext.TabPanel.prototype.createItemBody = function(bodyEl, id){
4396 var body = YAHOO.util.Dom.get(id);
4398 body = document.createElement('div');
4401 YAHOO.util.Dom.addClass(body, 'yui-ext-tabitembody');
4402 bodyEl.insertBefore(body, bodyEl.firstChild);
4406 YAHOO.ext.TabPanel.prototype.createStripElements = function(stripEl, text, closable){
4407 var td = document.createElement('td');
4408 stripEl.appendChild(td);
4410 td.className = "ytab-closable";
4412 this.closeTpl = new YAHOO.ext.Template(
4413 '<a href="#" class="ytab-right"><span class="ytab-left"><em class="ytab-inner">' +
4414 '<span unselectable="on" title="{text}" class="ytab-text">{text}</span>' +
4415 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
4418 var el = this.closeTpl.overwrite(td, {'text': text});
4419 var close = el.getElementsByTagName('div')[0];
4420 var inner = el.getElementsByTagName('em')[0];
4421 return {'el': el, 'close': close, 'inner': inner};
4424 this.tabTpl = new YAHOO.ext.Template(
4425 '<a href="#" class="ytab-right"><span class="ytab-left"><em class="ytab-inner">' +
4426 '<span unselectable="on" title="{text}" class="ytab-text">{text}</span></em></span></a>'
4429 var el = this.tabTpl.overwrite(td, {'text': text});
4430 var inner = el.getElementsByTagName('em')[0];
4431 return {'el': el, 'inner': inner};
4436 YAHOO.ext.Actor = function(element, animator, selfCapture){
4437 this.el = YAHOO.ext.Element.get(element, true);
4438 YAHOO.ext.Actor.superclass.constructor.call(this, element, true);
4439 this.onCapture = new YAHOO.util.CustomEvent('Actor.onCapture');
4442 animator.addActor(this);
4445 this.capturing = selfCapture;
4446 this.playlist = selfCapture ? new YAHOO.ext.Animator.AnimSequence() : null;
4449 YAHOO.extendX(YAHOO.ext.Actor, YAHOO.ext.Element);
4452 YAHOO.ext.Actor.prototype.capture = function(action){
4453 if(this.playlist != null){
4454 this.playlist.add(action);
4456 this.onCapture.fireDirect(this, action);
4461 YAHOO.ext.Actor.overrideAnimation = function(method, animParam, onParam){
4463 if(!this.capturing){
4464 return method.apply(this, arguments);
4466 var args = Array.prototype.slice.call(arguments, 0);
4467 if(args[animParam] === true){
4468 return this.capture(new YAHOO.ext.Actor.AsyncAction(this, method, args, onParam));
4470 return this.capture(new YAHOO.ext.Actor.Action(this, method, args));
4476 YAHOO.ext.Actor.overrideBasic = function(method){
4478 if(!this.capturing){
4479 return method.apply(this, arguments);
4481 var args = Array.prototype.slice.call(arguments, 0);
4482 return this.capture(new YAHOO.ext.Actor.Action(this, method, args));
4488 YAHOO.ext.Actor.prototype.setVisibilityMode = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setVisibilityMode);
4490 YAHOO.ext.Actor.prototype.enableDisplayMode = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.enableDisplayMode);
4492 YAHOO.ext.Actor.prototype.focus = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.focus);
4494 YAHOO.ext.Actor.prototype.addClass = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.addClass);
4496 YAHOO.ext.Actor.prototype.removeClass = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.removeClass);
4498 YAHOO.ext.Actor.prototype.replaceClass = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.replaceClass);
4500 YAHOO.ext.Actor.prototype.setStyle = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setStyle);
4502 YAHOO.ext.Actor.prototype.setLeft = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setLeft);
4504 YAHOO.ext.Actor.prototype.setTop = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setTop);
4506 YAHOO.ext.Actor.prototype.setAbsolutePositioned = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setAbsolutePositioned);
4508 YAHOO.ext.Actor.prototype.setRelativePositioned = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setRelativePositioned);
4510 YAHOO.ext.Actor.prototype.clearPositioning = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.clearPositioning);
4512 YAHOO.ext.Actor.prototype.setPositioning = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setPositioning);
4514 YAHOO.ext.Actor.prototype.clip = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.clip);
4516 YAHOO.ext.Actor.prototype.unclip = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.unclip);
4518 YAHOO.ext.Actor.prototype.clearOpacity = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.clearOpacity);
4520 YAHOO.ext.Actor.prototype.update = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.update);
4522 YAHOO.ext.Actor.prototype.remove = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.remove);
4523 YAHOO.ext.Actor.prototype.fitToParent = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.fitToParent);
4524 YAHOO.ext.Actor.prototype.appendChild = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.appendChild);
4525 YAHOO.ext.Actor.prototype.createChild = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.createChild);
4526 YAHOO.ext.Actor.prototype.appendTo = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.appendTo);
4527 YAHOO.ext.Actor.prototype.insertBefore = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.insertBefore);
4528 YAHOO.ext.Actor.prototype.insertAfter = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.insertAfter);
4529 YAHOO.ext.Actor.prototype.wrap = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.wrap);
4530 YAHOO.ext.Actor.prototype.replace = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.replace);
4531 YAHOO.ext.Actor.prototype.insertHtml = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.insertHtml);
4532 YAHOO.ext.Actor.prototype.set = YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.set);
4535 YAHOO.ext.Actor.prototype.load = function(){
4536 if(!this.capturing){
4537 return YAHOO.ext.Actor.superclass.load.apply(this, arguments);
4539 var args = Array.prototype.slice.call(arguments, 0);
4540 return this.capture(new YAHOO.ext.Actor.AsyncAction(this, YAHOO.ext.Actor.superclass.load,
4545 YAHOO.ext.Actor.prototype.animate = function(args, duration, onComplete, easing, animType){
4546 if(!this.capturing){
4547 return YAHOO.ext.Actor.superclass.animate.apply(this, arguments);
4549 return this.capture(new YAHOO.ext.Actor.AsyncAction(this, YAHOO.ext.Actor.superclass.animate,
4550 [args, duration, onComplete, easing, animType], 2));
4554 YAHOO.ext.Actor.prototype.setVisible = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setVisible, 1, 3);
4556 YAHOO.ext.Actor.prototype.toggle = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.toggle, 0, 2);
4558 YAHOO.ext.Actor.prototype.setXY = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setXY, 1, 3);
4560 YAHOO.ext.Actor.prototype.setLocation = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setLocation, 2, 4);
4562 YAHOO.ext.Actor.prototype.setWidth = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setWidth, 1, 3);
4564 YAHOO.ext.Actor.prototype.setHeight = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setHeight, 1, 3);
4566 YAHOO.ext.Actor.prototype.setSize = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setSize, 2, 4);
4568 YAHOO.ext.Actor.prototype.setBounds = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setBounds, 4, 6);
4570 YAHOO.ext.Actor.prototype.setOpacity = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setOpacity, 1, 3);
4572 YAHOO.ext.Actor.prototype.moveTo = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.moveTo, 2, 4);
4574 YAHOO.ext.Actor.prototype.move = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.move, 2, 4);
4576 YAHOO.ext.Actor.prototype.alignTo = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.alignTo, 3, 5);
4578 YAHOO.ext.Actor.prototype.hide = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.hide, 0, 2);
4580 YAHOO.ext.Actor.prototype.show = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.show, 0, 2);
4583 YAHOO.ext.Actor.prototype.setBox = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setBox, 2, 4);
4586 YAHOO.ext.Actor.prototype.autoHeight = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.autoHeight, 0, 2);
4588 YAHOO.ext.Actor.prototype.setX = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setX, 1, 3);
4590 YAHOO.ext.Actor.prototype.setY = YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setY, 1, 3);
4593 YAHOO.ext.Actor.prototype.startCapture = function(){
4594 this.capturing = true;
4595 this.playlist = new YAHOO.ext.Animator.AnimSequence();
4599 YAHOO.ext.Actor.prototype.stopCapture = function(){
4600 this.capturing = false;
4604 YAHOO.ext.Actor.prototype.clear = function(){
4605 this.playlist = new YAHOO.ext.Animator.AnimSequence();
4609 YAHOO.ext.Actor.prototype.play = function(oncomplete){
4610 this.capturing = false;
4612 this.playlist.play(oncomplete);
4617 YAHOO.ext.Actor.prototype.addCall = function(fcn, args, scope){
4618 if(!this.capturing){
4619 fcn.apply(scope || this, args || []);
4621 this.capture(new YAHOO.ext.Actor.Action(scope, fcn, args || []));
4626 YAHOO.ext.Actor.prototype.addAsyncCall = function(fcn, callbackIndex, args, scope){
4627 if(!this.capturing){
4628 fcn.apply(scope || this, args || []);
4630 this.capture(new YAHOO.ext.Actor.AsyncAction(scope, fcn, args || [], callbackIndex));
4635 YAHOO.ext.Actor.prototype.pause = function(seconds){
4636 this.capture(new YAHOO.ext.Actor.PauseAction(seconds));
4640 YAHOO.ext.Actor.prototype.shake = function(){
4641 this.move('left', 20, true, .05);
4642 this.move('right', 40, true, .05);
4643 this.move('left', 40, true, .05);
4644 this.move('right', 20, true, .05);
4648 YAHOO.ext.Actor.prototype.bounce = function(){
4649 this.move('up', 20, true, .05);
4650 this.move('down', 40, true, .05);
4651 this.move('up', 40, true, .05);
4652 this.move('down', 20, true, .05);
4656 YAHOO.ext.Actor.prototype.blindShow = function(anchor, newSize, duration, easing){
4657 var size = newSize || this.getSize();
4659 this.setVisible(true);
4660 anchor = anchor.toLowerCase();
4665 this.setHeight(newSize, true, duration || .5, null, easing || YAHOO.util.Easing.easeOut);
4670 this.setWidth(newSize, true, duration || .5, null, easing || YAHOO.util.Easing.easeOut);
4678 YAHOO.ext.Actor.prototype.blindHide = function(anchor, duration, easing){
4679 var size = this.getSize();
4681 anchor = anchor.toLowerCase();
4685 this.setSize(size.width, 1, true, duration || .5, null, easing || YAHOO.util.Easing.easeIn);
4686 this.setVisible(false);
4690 this.setSize(1, size.height, true, duration || .5, null, easing || YAHOO.util.Easing.easeIn);
4691 this.setVisible(false);
4695 this.animate({width: {to: 1}, points: {by: [this.getWidth(), 0]}},
4696 duration || .5, null, YAHOO.util.Easing.easeIn, YAHOO.util.Motion);
4697 this.setVisible(false);
4701 this.animate({height: {to: 1}, points: {by: [0, this.getHeight()]}},
4702 duration || .5, null, YAHOO.util.Easing.easeIn, YAHOO.util.Motion);
4703 this.setVisible(false);
4710 YAHOO.ext.Actor.prototype.slideShow = function(anchor, newSize, duration, easing, clearPositioning){
4711 var size = newSize || this.getSize();
4713 var firstChild = this.dom.firstChild;
4714 if(!firstChild || (firstChild.nodeName && "#TEXT" == firstChild.nodeName.toUpperCase())) {
4715 this.blindShow(anchor, newSize, duration, easing);
4718 var child = YAHOO.ext.Element.get(firstChild, true);
4719 var pos = child.getPositioning();
4720 this.addCall(child.setAbsolutePositioned, null, child);
4721 this.setVisible(true);
4722 anchor = anchor.toLowerCase();
4726 this.addCall(child.setStyle, ['right', ''], child);
4727 this.addCall(child.setStyle, ['top', ''], child);
4728 this.addCall(child.setStyle, ['left', '0px'], child);
4729 this.addCall(child.setStyle, ['bottom', '0px'], child);
4731 this.setHeight(newSize, true, duration || .5, null, easing || YAHOO.util.Easing.easeOut);
4735 this.addCall(child.setStyle, ['left', ''], child);
4736 this.addCall(child.setStyle, ['bottom', ''], child);
4737 this.addCall(child.setStyle, ['right', '0px'], child);
4738 this.addCall(child.setStyle, ['top', '0px'], child);
4740 this.setWidth(newSize, true, duration || .5, null, easing || YAHOO.util.Easing.easeOut);
4744 this.addCall(child.setStyle, ['left', '0px'], child);
4745 this.addCall(child.setStyle, ['top', '0px'], child);
4746 this.addCall(child.setStyle, ['right', ''], child);
4747 this.addCall(child.setStyle, ['bottom', ''], child);
4749 this.setWidth(newSize, true, duration || .5, null, easing || YAHOO.util.Easing.easeOut);
4753 this.addCall(child.setStyle, ['right', ''], child);
4754 this.addCall(child.setStyle, ['top', '0px'], child);
4755 this.addCall(child.setStyle, ['left', '0px'], child);
4756 this.addCall(child.setStyle, ['bottom', ''], child);
4758 this.setHeight(newSize, true, duration || .5, null, easing || YAHOO.util.Easing.easeOut);
4761 if(clearPositioning !== false){
4762 this.addCall(child.setPositioning, [pos], child);
4769 YAHOO.ext.Actor.prototype.slideHide = function(anchor, duration, easing){
4770 var size = this.getSize();
4772 var firstChild = this.dom.firstChild;
4773 if(!firstChild || (firstChild.nodeName && "#TEXT" == firstChild.nodeName.toUpperCase())) {
4774 this.blindHide(anchor, duration, easing);
4777 var child = YAHOO.ext.Element.get(firstChild, true);
4778 var pos = child.getPositioning();
4779 this.addCall(child.setAbsolutePositioned, null, child);
4780 anchor = anchor.toLowerCase();
4784 this.addCall(child.setStyle, ['right', ''], child);
4785 this.addCall(child.setStyle, ['top', ''], child);
4786 this.addCall(child.setStyle, ['left', '0px'], child);
4787 this.addCall(child.setStyle, ['bottom', '0px'], child);
4788 this.setSize(size.width, 1, true, duration || .5, null, easing || YAHOO.util.Easing.easeIn);
4789 this.setVisible(false);
4793 this.addCall(child.setStyle, ['left', ''], child);
4794 this.addCall(child.setStyle, ['bottom', ''], child);
4795 this.addCall(child.setStyle, ['right', '0px'], child);
4796 this.addCall(child.setStyle, ['top', '0px'], child);
4797 this.setSize(1, size.height, true, duration || .5, null, easing || YAHOO.util.Easing.easeIn);
4798 this.setVisible(false);
4802 this.addCall(child.setStyle, ['right', ''], child);
4803 this.addCall(child.setStyle, ['bottom', ''], child);
4804 this.addCall(child.setStyle, ['left', '0px'], child);
4805 this.addCall(child.setStyle, ['top', '0px'], child);
4806 this.setSize(1, size.height, true, duration || .5, null, easing || YAHOO.util.Easing.easeIn);
4807 this.setVisible(false);
4811 this.addCall(child.setStyle, ['right', ''], child);
4812 this.addCall(child.setStyle, ['top', '0px'], child);
4813 this.addCall(child.setStyle, ['left', '0px'], child);
4814 this.addCall(child.setStyle, ['bottom', ''], child);
4815 this.setSize(size.width, 1, true, duration || .5, null, easing || YAHOO.util.Easing.easeIn);
4816 this.setVisible(false);
4819 this.addCall(child.setPositioning, [pos], child);
4824 YAHOO.ext.Actor.prototype.squish = function(duration){
4825 var size = this.getSize();
4827 this.setSize(1, 1, true, duration || .5);
4828 this.setVisible(false);
4833 YAHOO.ext.Actor.prototype.appear = function(duration){
4834 this.setVisible(true, true, duration);
4838 YAHOO.ext.Actor.prototype.fade = function(duration){
4839 this.setVisible(false, true, duration);
4843 YAHOO.ext.Actor.prototype.switchOff = function(duration){
4845 this.setVisible(false, true, .1);
4846 this.clearOpacity();
4847 this.setVisible(true);
4848 this.animate({height: {to: 1}, points: {by: [0, this.getHeight()/2]}},
4849 duration || .5, null, YAHOO.util.Easing.easeOut, YAHOO.util.Motion);
4850 this.setVisible(false);
4854 YAHOO.ext.Actor.prototype.highlight = function(color, fromColor, duration, attribute){
4855 attribute = attribute || 'background-color';
4856 var original = this.getStyle(attribute);
4857 fromColor = fromColor || ((original && original != '' && original != 'transparent') ? original : '#FFFFFF');
4859 cfg[attribute] = {to: color, from: fromColor};
4860 this.setVisible(true);
4861 this.animate(cfg, duration || .5, null, YAHOO.util.Easing.bounceOut, YAHOO.util.ColorAnim);
4862 this.setStyle(attribute, original);
4866 YAHOO.ext.Actor.prototype.pulsate = function(count, duration){
4868 for(var i = 0; i < count; i++){
4869 this.toggle(true, duration || .25);
4870 this.toggle(true, duration || .25);
4875 YAHOO.ext.Actor.prototype.dropOut = function(duration){
4876 this.animate({opacity: {to: 0}, points: {by: [0, this.getHeight()]}},
4877 duration || .5, null, YAHOO.util.Easing.easeIn, YAHOO.util.Motion);
4878 this.setVisible(false);
4882 YAHOO.ext.Actor.prototype.moveOut = function(anchor, duration, easing){
4884 var vw = Y.Dom.getViewportWidth();
4885 var vh = Y.Dom.getViewportHeight();
4886 var cpoints = this.getCenterXY()
4887 var centerX = cpoints[0];
4888 var centerY = cpoints[1];
4889 var anchor = anchor.toLowerCase();
4894 p = [centerX, -this.getHeight()];
4898 p = [-this.getWidth(), centerY];
4902 p = [vw+this.getWidth(), centerY];
4906 p = [centerX, vh+this.getHeight()];
4910 p = [-this.getWidth(), -this.getHeight()];
4914 p = [-this.getWidth(), vh+this.getHeight()];
4917 case 'bottom-right':
4918 p = [vw+this.getWidth(), vh+this.getHeight()];
4922 p = [vw+this.getWidth(), -this.getHeight()];
4925 this.moveTo(p[0], p[1], true, duration || .35, null, easing || Y.Easing.easeIn);
4926 this.setVisible(false);
4930 YAHOO.ext.Actor.prototype.moveIn = function(anchor, to, duration, easing){
4931 to = to || this.getCenterXY();
4932 this.moveOut(anchor, .01);
4933 this.setVisible(true);
4934 this.setXY(to, true, duration || .35, null, easing || YAHOO.util.Easing.easeOut);
4937 YAHOO.ext.Actor.prototype.frame = function(color, count, duration){
4938 color = color || "red";
4940 duration = duration || .5;
4941 var frameFn = function(callback){
4942 var box = this.getBox();
4943 var animFn = function(){
4944 var proxy = this.createProxy({
4948 position:"absolute",
4949 zIndex:this.getStyle("zIndex"),
4950 border:"0px solid " + color
4953 var scale = proxy.isBorderBox() ? 2 : 1;
4955 top:{from:box.y, to:box.y - 20},
4956 left:{from:box.x, to:box.x - 20},
4957 borderWidth:{from:0, to:10},
4958 opacity:{from:1, to:0},
4959 height:{from:box.height, to:(box.height + (20*scale))},
4960 width:{from:box.width, to:(box.width + (20*scale))}
4961 }, duration, function(){
4965 animFn.defer((duration/2)*1000, this);
4967 if(typeof callback == 'function'){
4974 this.addAsyncCall(frameFn, 0, null, this);
4977 YAHOO.ext.Actor.Action = function(actor, method, args){
4979 this.method = method;
4983 YAHOO.ext.Actor.Action.prototype = {
4984 play : function(onComplete){
4985 this.method.apply(this.actor || window, this.args);
4991 YAHOO.ext.Actor.AsyncAction = function(actor, method, args, onIndex){
4992 YAHOO.ext.Actor.AsyncAction.superclass.constructor.call(this, actor, method, args);
4993 this.onIndex = onIndex;
4994 this.originalCallback = this.args[onIndex];
4996 YAHOO.extendX(YAHOO.ext.Actor.AsyncAction, YAHOO.ext.Actor.Action);
4998 YAHOO.ext.Actor.AsyncAction.prototype.play = function(onComplete){
4999 var callbackArg = this.originalCallback ?
5000 this.originalCallback.createSequence(onComplete) : onComplete;
5001 this.args[this.onIndex] = callbackArg;
5002 this.method.apply(this.actor, this.args);
5006 YAHOO.ext.Actor.PauseAction = function(seconds){
5007 this.seconds = seconds;
5009 YAHOO.ext.Actor.PauseAction.prototype = {
5010 play : function(onComplete){
5011 setTimeout(onComplete, this.seconds * 1000);
5015 YAHOO.ext.Animator = function(){
5017 this.playlist = new YAHOO.ext.Animator.AnimSequence();
5018 this.captureDelegate = this.capture.createDelegate(this);
5019 this.playDelegate = this.play.createDelegate(this);
5020 this.syncing = false;
5021 this.stopping = false;
5022 this.playing = false;
5023 for(var i = 0; i < arguments.length; i++){
5024 this.addActor(arguments[i]);
5028 YAHOO.ext.Animator.prototype = {
5030 capture : function(actor, action){
5032 if(!this.syncMap[actor.id]){
5033 this.syncMap[actor.id] = new YAHOO.ext.Animator.AnimSequence();
5035 this.syncMap[actor.id].add(action);
5037 this.playlist.add(action);
5042 addActor : function(actor){
5043 actor.onCapture.subscribe(this.captureDelegate);
5044 this.actors.push(actor);
5049 startCapture : function(clearPlaylist){
5050 for(var i = 0; i < this.actors.length; i++){
5051 var a = this.actors[i];
5052 if(!this.isCapturing(a)){
5053 a.onCapture.subscribe(this.captureDelegate);
5058 this.playlist = new YAHOO.ext.Animator.AnimSequence();
5063 isCapturing : function(actor){
5064 var subscribers = actor.onCapture.subscribers;
5066 for(var i = 0; i < subscribers.length; i++){
5067 if(subscribers[i] && subscribers[i].contains(this.captureDelegate)){
5076 stopCapture : function(){
5077 for(var i = 0; i < this.actors.length; i++){
5078 var a = this.actors[i];
5079 a.onCapture.unsubscribe(this.captureDelegate);
5080 a.capturing = false;
5085 beginSync : function(){
5086 this.syncing = true;
5091 endSync : function(){
5092 this.syncing = false;
5093 var composite = new YAHOO.ext.Animator.CompositeSequence();
5094 for(key in this.syncMap){
5095 if(typeof this.syncMap[key] != 'function'){
5096 composite.add(this.syncMap[key]);
5099 this.playlist.add(composite);
5100 this.syncMap = null;
5104 play : function(oncomplete){
5105 if(this.playing) return;
5107 this.playlist.play(oncomplete);
5112 this.playlist.stop();
5116 isPlaying : function(){
5117 return this.playlist.isPlaying();
5121 this.playlist = new YAHOO.ext.Animator.AnimSequence();
5125 addCall : function(fcn, args, scope){
5126 this.playlist.add(new YAHOO.ext.Actor.Action(scope, fcn, args || []));
5130 addAsyncCall : function(fcn, callbackIndex, args, scope){
5131 this.playlist.add(new YAHOO.ext.Actor.AsyncAction(scope, fcn, args || [], callbackIndex));
5135 pause : function(seconds){
5136 this.playlist.add(new YAHOO.ext.Actor.PauseAction(seconds));
5141 YAHOO.ext.Animator.select = function(selector){
5143 if(typeof selector == 'string'){
5144 els = YAHOO.ext.Element.selectorFunction(selector);
5145 }else if(selector instanceof Array){
5148 throw 'Invalid selector';
5150 return new YAHOO.ext.AnimatorComposite(els);
5152 var getActors = YAHOO.ext.Animator.select;
5155 YAHOO.ext.AnimatorComposite = function(els){
5156 this.animator = new YAHOO.ext.Animator();
5157 this.addElements(els);
5158 this.syncAnims = true;
5160 YAHOO.ext.AnimatorComposite.prototype = {
5163 addElements : function(els){
5164 if(!els) return this;
5165 var anim = this.animator;
5166 for(var i = 0, len = els.length; i < len; i++) {
5167 anim.addActor(new YAHOO.ext.Actor(els[i]));
5169 anim.startCapture();
5173 sequence : function(){
5174 this.syncAnims = false;
5179 this.syncAnims = true;
5182 invoke : function(fn, args){
5183 var els = this.animator.actors;
5184 if(this.syncAnims) this.animator.beginSync();
5185 for(var i = 0, len = els.length; i < len; i++) {
5186 YAHOO.ext.Actor.prototype[fn].apply(els[i], args);
5188 if(this.syncAnims) this.animator.endSync();
5192 play : function(callback){
5193 this.animator.play(callback);
5197 reset : function(callback){
5198 this.animator.startCapture(true);
5202 pause : function(seconds){
5203 this.animator.pause(seconds);
5207 getAnimator : function(){
5208 return this.animator;
5211 each : function(fn, scope){
5212 var els = this.animator.actors;
5213 if(this.syncAnims) this.animator.beginSync();
5214 for(var i = 0, len = els.length; i < len; i++){
5215 fn.call(scope || els[i], els[i], this, i);
5217 if(this.syncAnims) this.animator.endSync();
5221 addCall : function(fcn, args, scope){
5222 this.animator.addCall(fcn, args, scope);
5226 addAsyncCall : function(fcn, callbackIndex, args, scope){
5227 this.animator.addAsyncCall(fcn, callbackIndex, args, scope);
5231 for(var fnName in YAHOO.ext.Actor.prototype){
5232 if(typeof YAHOO.ext.Actor.prototype[fnName] == 'function'){
5233 YAHOO.ext.CompositeElement.createCall(YAHOO.ext.AnimatorComposite.prototype, fnName);
5238 YAHOO.ext.Animator.AnimSequence = function(){
5240 this.nextDelegate = this.next.createDelegate(this);
5241 this.playDelegate = this.play.createDelegate(this);
5242 this.oncomplete = null;
5243 this.playing = false;
5244 this.stopping = false;
5245 this.actionIndex = -1;
5248 YAHOO.ext.Animator.AnimSequence.prototype = {
5250 add : function(action){
5251 this.actions.push(action);
5256 this.playing = false;
5257 if(this.oncomplete){
5258 this.oncomplete(this, false);
5262 var nextAction = this.actions[++this.actionIndex];
5264 nextAction.play(this.nextDelegate);
5266 this.playing = false;
5267 if(this.oncomplete){
5268 this.oncomplete(this, true);
5273 play : function(oncomplete){
5274 if(this.playing) return;
5275 this.oncomplete = oncomplete;
5276 this.stopping = false;
5277 this.playing = true;
5278 this.actionIndex = -1;
5283 this.stopping = true;
5286 isPlaying : function(){
5287 return this.playing;
5294 addCall : function(fcn, args, scope){
5295 this.actions.push(new YAHOO.ext.Actor.Action(scope, fcn, args || []));
5298 addAsyncCall : function(fcn, callbackIndex, args, scope){
5299 this.actions.push(new YAHOO.ext.Actor.AsyncAction(scope, fcn, args || [], callbackIndex));
5302 pause : function(seconds){
5303 this.actions.push(new YAHOO.ext.Actor.PauseAction(seconds));
5308 YAHOO.ext.Animator.CompositeSequence = function(){
5309 this.sequences = [];
5311 this.trackDelegate = this.trackCompletion.createDelegate(this);
5314 YAHOO.ext.Animator.CompositeSequence.prototype = {
5315 add : function(sequence){
5316 this.sequences.push(sequence);
5319 play : function(onComplete){
5321 if(this.sequences.length < 1){
5322 if(onComplete)onComplete();
5325 this.onComplete = onComplete;
5326 for(var i = 0; i < this.sequences.length; i++){
5327 this.sequences[i].play(this.trackDelegate);
5331 trackCompletion : function(){
5333 if(this.completed >= this.sequences.length && this.onComplete){
5339 for(var i = 0; i < this.sequences.length; i++){
5340 this.sequences[i].stop();
5344 isPlaying : function(){
5345 for(var i = 0; i < this.sequences.length; i++){
5346 if(this.sequences[i].isPlaying()){
5357 YAHOO.ext.Toolbar = function(container, buttons){
5358 this.el = getEl(container, true);
5359 var div = document.createElement('div');
5360 div.className = 'ytoolbar';
5361 var tb = document.createElement('table');
5365 div.appendChild(tb);
5366 var tbody = document.createElement('tbody');
5367 tb.appendChild(tbody);
5368 var tr = document.createElement('tr');
5369 tbody.appendChild(tr);
5370 this.el.dom.appendChild(div);
5373 this.add.apply(this, buttons);
5377 YAHOO.ext.Toolbar.prototype = {
5380 for(var i = 0; i < arguments.length; i++){
5381 var el = arguments[i];
5382 var td = document.createElement('td');
5383 this.tr.appendChild(td);
5384 if(el instanceof YAHOO.ext.ToolbarButton){
5386 }else if(el instanceof Array){
5388 }else if(typeof el == 'string'){
5389 var span = document.createElement('span');
5390 if(el == 'separator'){
5391 span.className = 'ytb-sep';
5393 span.innerHTML = el;
5394 span.className = 'ytb-text';
5396 td.appendChild(span);
5397 }else if(typeof el == 'object' && el.nodeType){
5399 }else if(typeof el == 'object'){
5411 addSeparator : function(){
5412 var td = document.createElement('td');
5413 this.tr.appendChild(td);
5414 var span = document.createElement('span');
5415 span.className = 'ytb-sep';
5416 td.appendChild(span);
5420 addButton : function(config){
5421 if(config instanceof Array){
5423 for(var i = 0, len = config.length; i < len; i++) {
5424 buttons.push(this.addButton(config[i]));
5429 if(!(config instanceof YAHOO.ext.ToolbarButton)){
5430 b = new YAHOO.ext.ToolbarButton(config);
5437 addText : function(text){
5438 var td = document.createElement('td');
5439 this.tr.appendChild(td);
5440 var span = document.createElement('span');
5441 span.className = 'ytb-text';
5442 span.innerHTML = text;
5443 td.appendChild(span);
5448 insertButton : function(index, config){
5449 if(config instanceof Array){
5451 for(var i = 0, len = config.length; i < len; i++) {
5452 buttons.push(this.insertButton(index + i, config[i]));
5456 var b = new YAHOO.ext.ToolbarButton(config);
5457 var td = document.createElement('td');
5458 var nextSibling = this.tr.childNodes[index];
5460 this.tr.insertBefore(td, nextSibling);
5462 this.tr.appendChild(td);
5469 YAHOO.ext.ToolbarButton = function(config){
5470 YAHOO.ext.util.Config.apply(this, config);
5473 YAHOO.ext.ToolbarButton.prototype = {
5475 init : function(appendTo){
5476 var element = document.createElement('span');
5477 element.className = 'ytb-button';
5479 element.id = this.id;
5481 this.setDisabled(this.disabled === true);
5482 var inner = document.createElement('span');
5483 inner.className = 'ytb-button-inner ' + this.className;
5484 inner.unselectable = 'on';
5486 element.setAttribute('title', this.tooltip);
5489 YAHOO.ext.DomHelper.applyStyles(inner, this.style);
5491 element.appendChild(inner);
5492 appendTo.appendChild(element);
5493 this.el = getEl(element, true);
5494 this.el.unselectable();
5495 inner.innerHTML = (this.text ? this.text : ' ');
5497 this.el.mon('click', this.onClick, this, true);
5498 this.el.mon('mouseover', this.onMouseOver, this, true);
5499 this.el.mon('mouseout', this.onMouseOut, this, true);
5503 setHandler : function(click, scope){
5509 setText : function(text){
5510 this.inner.innerHTML = text;
5514 setTooltip : function(text){
5515 this.el.dom.title = text;
5520 this.el.dom.parentNode.style.display = '';
5525 this.el.dom.parentNode.style.display = 'none';
5529 disable : function(){
5530 this.disabled = true;
5532 this.el.addClass('ytb-button-disabled');
5537 enable : function(){
5538 this.disabled = false;
5540 this.el.removeClass('ytb-button-disabled');
5545 isDisabled : function(){
5546 return this.disabled === true;
5549 setDisabled : function(disabled){
5558 onClick : function(){
5559 if(!this.disabled && this.click){
5560 this.click.call(this.scope || window, this);
5565 onMouseOver : function(){
5567 this.el.addClass('ytb-button-over');
5569 this.mouseover.call(this.scope || window, this);
5575 onMouseOut : function(){
5576 this.el.removeClass('ytb-button-over');
5579 this.mouseout.call(this.scope || window, this);
5585 YAHOO.ext.Resizable = function(el, config){
5586 this.el = getEl(el);
5588 if(config && config.wrap){
5589 config.resizeChild = this.el;
5590 this.el = this.el.wrap(typeof config.wrap == 'object' ? config.wrap : null);
5591 this.el.id = this.el.dom.id = config.resizeChild.id + '-rzwrap';
5592 this.el.setStyle('overflow', 'hidden');
5593 this.el.setPositioning(config.resizeChild.getPositioning());
5594 config.resizeChild.clearPositioning();
5595 if(!config.width || !config.height){
5596 var csize = config.resizeChild.getSize();
5599 this.el.setSize(csize.width, csize.height);
5601 if(config.pinned && !config.adjustments){
5602 config.adjustments = 'auto';
5606 this.proxy = this.el.createProxy({tag: 'div', cls: 'yresizable-proxy', id: this.el.id + '-rzproxy'})
5607 this.proxy.unselectable();
5610 this.overlay = this.el.createProxy({tag: 'div', cls: 'yresizable-overlay', html: ' '});
5611 this.overlay.unselectable();
5612 this.overlay.enableDisplayMode('block');
5613 this.overlay.mon('mousemove', this.onMouseMove, this, true);
5614 this.overlay.mon('mouseup', this.onMouseUp, this, true);
5616 YAHOO.ext.util.Config.apply(this, config, {
5618 resizeChild : false,
5620 adjustments : [0, 0],
5640 multiDirectional : false,
5642 disableTrackOver : false,
5644 easing : YAHOO.util.Easing ? YAHOO.util.Easing.easeOutStrong : null,
5648 heightIncrement : 0,
5656 preserveRatio : false,
5668 this.disableTrackOver = true;
5669 this.el.addClass('yresizable-pinned');
5672 var position = this.el.getStyle('position');
5673 if(position != 'absolute' && position != 'fixed'){
5674 this.el.setStyle('position', 'relative');
5677 this.handles = 's,e,se';
5678 if(this.multiDirectional){
5679 this.handles += ',n,w';
5682 if(this.handles == 'all'){
5683 this.handles = 'n s e w ne nw se sw';
5685 var hs = this.handles.split(/\s*?[,;]\s*?| /);
5686 var ps = YAHOO.ext.Resizable.positions;
5687 for(var i = 0, len = hs.length; i < len; i++){
5688 if(hs[i] && ps[hs[i]]){
5689 var pos = ps[hs[i]];
5690 this[pos] = new YAHOO.ext.Resizable.Handle(this, pos, this.disableTrackOver, this.transparent);
5694 this.corner = this.southeast;
5696 this.activeHandle = null;
5698 if(this.resizeChild){
5699 if(typeof this.resizeChild == 'boolean'){
5700 this.resizeChild = YAHOO.ext.Element.get(this.el.dom.firstChild, true);
5702 this.resizeChild = YAHOO.ext.Element.get(this.resizeChild, true);
5706 if(this.adjustments == 'auto'){
5707 var rc = this.resizeChild;
5708 var hw = this.west, he = this.east, hn = this.north, hs = this.south;
5709 if(rc && (hw || hn)){
5710 rc.setRelativePositioned();
5711 rc.setLeft(hw ? hw.el.getWidth() : 0);
5712 rc.setTop(hn ? hn.el.getHeight() : 0);
5714 this.adjustments = [
5715 (he ? -he.el.getWidth() : 0) + (hw ? -hw.el.getWidth() : 0),
5716 (hn ? -hn.el.getHeight() : 0) + (hs ? -hs.el.getHeight() : 0) -1
5721 this.dd = this.dynamic ?
5722 this.el.initDD(null) : this.el.initDDProxy(null, {dragElId: this.proxy.id});
5723 this.dd.setHandleElId(this.resizeChild ? this.resizeChild.id : this.el.id);
5729 'beforeresize' : new YAHOO.util.CustomEvent(),
5731 'resize' : new YAHOO.util.CustomEvent()
5734 if(this.width !== null && this.height !== null){
5735 this.resizeTo(this.width, this.height);
5737 this.updateChildSize();
5741 YAHOO.extendX(YAHOO.ext.Resizable, YAHOO.ext.util.Observable, {
5743 resizeTo : function(width, height){
5744 this.el.setSize(width, height);
5745 this.updateChildSize();
5746 this.fireEvent('resize', this, width, height, null);
5749 startSizing : function(e){
5750 this.fireEvent('beforeresize', this, e);
5752 this.resizing = true;
5753 this.startBox = this.el.getBox();
5754 this.startPoint = e.getXY();
5755 this.offsets = [(this.startBox.x + this.startBox.width) - this.startPoint[0],
5756 (this.startBox.y + this.startBox.height) - this.startPoint[1]];
5757 this.proxy.setBox(this.startBox);
5759 this.overlay.setSize(YAHOO.util.Dom.getDocumentWidth(), YAHOO.util.Dom.getDocumentHeight());
5760 this.overlay.show();
5768 onMouseDown : function(handle, e){
5771 this.activeHandle = handle;
5772 this.overlay.setStyle('cursor', handle.el.getStyle('cursor'));
5773 this.startSizing(e);
5777 onMouseUp : function(e){
5778 var size = this.resizeElement();
5779 this.resizing = false;
5781 this.overlay.hide();
5782 this.fireEvent('resize', this, size.width, size.height, e);
5785 updateChildSize : function(){
5786 if(this.resizeChild){
5788 var child = this.resizeChild;
5789 var adj = this.adjustments;
5790 if(el.dom.offsetWidth){
5791 var b = el.getSize(true);
5792 child.setSize(b.width+adj[0], b.height+adj[1]);
5798 if(YAHOO.ext.util.Browser.isIE){
5799 setTimeout(function(){
5800 if(el.dom.offsetWidth){
5801 var b = el.getSize(true);
5802 child.setSize(b.width+adj[0], b.height+adj[1]);
5809 snap : function(value, inc, min){
5810 if(!inc || !value) return value;
5811 var newValue = value;
5812 var m = value % inc;
5815 newValue = value + (inc-m);
5817 newValue = value - m;
5820 return Math.max(min, newValue);
5823 resizeElement : function(){
5824 var box = this.proxy.getBox();
5828 this.el.setBox(box, false, this.animate, this.duration, null, this.easing);
5832 this.updateChildSize();
5837 constrain : function(v, diff, m, mx){
5840 }else if(v - diff > mx){
5846 onMouseMove : function(e){
5851 var curSize = this.curSize || this.startBox;
5852 var x = this.startBox.x, y = this.startBox.y;
5854 var w = curSize.width, h = curSize.height;
5856 var mw = this.minWidth, mh = this.minHeight;
5857 var mxw = this.maxWidth, mxh = this.maxHeight;
5858 var wi = this.widthIncrement;
5859 var hi = this.heightIncrement;
5861 var eventXY = e.getXY();
5862 var diffX = -(this.startPoint[0] - Math.max(this.minX, eventXY[0]));
5863 var diffY = -(this.startPoint[1] - Math.max(this.minY, eventXY[1]));
5865 var pos = this.activeHandle.position;
5870 w = Math.min(Math.max(mw, w), mxw);
5874 h = Math.min(Math.max(mh, h), mxh);
5879 w = Math.min(Math.max(mw, w), mxw);
5880 h = Math.min(Math.max(mh, h), mxh);
5883 diffY = this.constrain(h, diffY, mh, mxh);
5888 diffX = this.constrain(w, diffX, mw, mxw);
5894 w = Math.min(Math.max(mw, w), mxw);
5895 diffY = this.constrain(h, diffY, mh, mxh);
5900 diffX = this.constrain(w, diffX, mw, mxw);
5901 diffY = this.constrain(h, diffY, mh, mxh);
5908 diffX = this.constrain(w, diffX, mw, mxw);
5910 h = Math.min(Math.max(mh, h), mxh);
5916 var sw = this.snap(w, wi, mw);
5917 var sh = this.snap(h, hi, mh);
5918 if(sw != w || sh != h){
5941 if(this.preserveRatio){
5946 h = Math.min(Math.max(mh, h), mxh);
5951 w = Math.min(Math.max(mw, w), mxw);
5956 w = Math.min(Math.max(mw, w), mxw);
5962 w = Math.min(Math.max(mw, w), mxw);
5968 h = Math.min(Math.max(mh, h), mxh);
5976 h = Math.min(Math.max(mh, h), mxh);
5986 h = Math.min(Math.max(mh, h), mxh);
5994 this.proxy.setBounds(x, y, w, h);
5996 this.resizeElement();
6002 handleOver : function(){
6004 this.el.addClass('yresizable-over');
6008 handleOut : function(){
6010 this.el.removeClass('yresizable-over');
6020 getResizeChild : function(){
6021 return this.resizeChild;
6026 YAHOO.ext.Resizable.positions = {
6027 n: 'north', s: 'south', e: 'east', w: 'west', se: 'southeast', sw: 'southwest', nw: 'northwest', ne: 'northeast'
6031 YAHOO.ext.Resizable.Handle = function(rz, pos, disableTrackOver, transparent){
6034 var tpl = YAHOO.ext.DomHelper.createTemplate(
6035 {tag: 'div', cls: 'yresizable-handle yresizable-handle-{0}', html: ' '}
6038 YAHOO.ext.Resizable.Handle.prototype.tpl = tpl;
6040 this.position = pos;
6042 this.el = this.tpl.append(rz.el.dom, [this.position], true);
6043 this.el.unselectable();
6045 this.el.setOpacity(0);
6047 this.el.mon('mousedown', this.onMouseDown, this, true);
6048 if(!disableTrackOver){
6049 this.el.mon('mouseover', this.onMouseOver, this, true);
6050 this.el.mon('mouseout', this.onMouseOut, this, true);
6054 YAHOO.ext.Resizable.Handle.prototype = {
6055 afterResize : function(rz){
6059 onMouseDown : function(e){
6060 this.rz.onMouseDown(this, e);
6063 onMouseOver : function(e){
6064 this.rz.handleOver(this, e);
6067 onMouseOut : function(e){
6068 this.rz.handleOut(this, e);
6075 if(YAHOO.util.DragDropMgr){
6076 YAHOO.util.DragDropMgr.clickTimeThresh = 350;
6079 YAHOO.ext.SplitBar = function(dragElement, resizingElement, orientation, placement){
6082 this.el = YAHOO.ext.Element.get(dragElement, true);
6083 this.el.dom.unselectable = 'on';
6085 this.resizingEl = YAHOO.ext.Element.get(resizingElement, true);
6088 this.orientation = orientation || YAHOO.ext.SplitBar.HORIZONTAL;
6094 this.maxSize = 2000;
6096 this.onMoved = new YAHOO.util.CustomEvent("SplitBarMoved", this);
6099 this.animate = false;
6102 this.useShim = false;
6108 this.proxy = YAHOO.ext.SplitBar.createProxy(this.orientation);
6111 this.dd = new YAHOO.util.DDProxy(this.el.dom.id, "SplitBars", {dragElId : this.proxy.id});
6114 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
6117 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
6120 this.dragSpecs = {};
6123 this.adapter = new YAHOO.ext.SplitBar.BasicLayoutAdapter();
6124 this.adapter.init(this);
6126 if(this.orientation == YAHOO.ext.SplitBar.HORIZONTAL){
6128 this.placement = placement || (this.el.getX() > this.resizingEl.getX() ? YAHOO.ext.SplitBar.LEFT : YAHOO.ext.SplitBar.RIGHT);
6129 this.el.setStyle('cursor', 'e-resize');
6132 this.placement = placement || (this.el.getY() > this.resizingEl.getY() ? YAHOO.ext.SplitBar.TOP : YAHOO.ext.SplitBar.BOTTOM);
6133 this.el.setStyle('cursor', 'n-resize');
6138 'resize' : this.onMoved,
6140 'moved' : this.onMoved,
6142 'beforeresize' : new YAHOO.util.CustomEvent('beforeresize')
6146 YAHOO.extendX(YAHOO.ext.SplitBar, YAHOO.ext.util.Observable, {
6147 onStartProxyDrag : function(x, y){
6148 this.fireEvent('beforeresize', this);
6151 this.shim = YAHOO.ext.SplitBar.createShim();
6153 this.shim.setVisible(true);
6155 YAHOO.util.Dom.setStyle(this.proxy, 'display', 'block');
6156 var size = this.adapter.getElementSize(this);
6157 this.activeMinSize = this.getMinimumSize();;
6158 this.activeMaxSize = this.getMaximumSize();;
6159 var c1 = size - this.activeMinSize;
6160 var c2 = Math.max(this.activeMaxSize - size, 0);
6161 if(this.orientation == YAHOO.ext.SplitBar.HORIZONTAL){
6162 this.dd.resetConstraints();
6163 this.dd.setXConstraint(
6164 this.placement == YAHOO.ext.SplitBar.LEFT ? c1 : c2,
6165 this.placement == YAHOO.ext.SplitBar.LEFT ? c2 : c1
6167 this.dd.setYConstraint(0, 0);
6169 this.dd.resetConstraints();
6170 this.dd.setXConstraint(0, 0);
6171 this.dd.setYConstraint(
6172 this.placement == YAHOO.ext.SplitBar.TOP ? c1 : c2,
6173 this.placement == YAHOO.ext.SplitBar.TOP ? c2 : c1
6176 this.dragSpecs.startSize = size;
6177 this.dragSpecs.startPoint = [x, y];
6179 YAHOO.util.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
6183 onEndProxyDrag : function(e){
6184 YAHOO.util.Dom.setStyle(this.proxy, 'display', 'none');
6185 var endPoint = YAHOO.util.Event.getXY(e);
6187 this.shim.setVisible(false);
6190 if(this.orientation == YAHOO.ext.SplitBar.HORIZONTAL){
6191 newSize = this.dragSpecs.startSize +
6192 (this.placement == YAHOO.ext.SplitBar.LEFT ?
6193 endPoint[0] - this.dragSpecs.startPoint[0] :
6194 this.dragSpecs.startPoint[0] - endPoint[0]
6197 newSize = this.dragSpecs.startSize +
6198 (this.placement == YAHOO.ext.SplitBar.TOP ?
6199 endPoint[1] - this.dragSpecs.startPoint[1] :
6200 this.dragSpecs.startPoint[1] - endPoint[1]
6203 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
6204 if(newSize != this.dragSpecs.startSize){
6205 this.adapter.setElementSize(this, newSize);
6206 this.onMoved.fireDirect(this, newSize);
6211 getAdapter : function(){
6212 return this.adapter;
6216 setAdapter : function(adapter){
6217 this.adapter = adapter;
6218 this.adapter.init(this);
6222 getMinimumSize : function(){
6223 return this.minSize;
6227 setMinimumSize : function(minSize){
6228 this.minSize = minSize;
6232 getMaximumSize : function(){
6233 return this.maxSize;
6237 setMaximumSize : function(maxSize){
6238 this.maxSize = maxSize;
6242 setCurrentSize : function(size){
6243 var oldAnimate = this.animate;
6244 this.animate = false;
6245 this.adapter.setElementSize(this, size);
6246 this.animate = oldAnimate;
6250 destroy : function(removeEl){
6255 this.proxy.parentNode.removeChild(this.proxy);
6263 YAHOO.ext.SplitBar.createShim = function(){
6264 var shim = document.createElement('div');
6265 shim.unselectable = 'on';
6266 YAHOO.util.Dom.generateId(shim, 'split-shim');
6267 YAHOO.util.Dom.setStyle(shim, 'width', '100%');
6268 YAHOO.util.Dom.setStyle(shim, 'height', '100%');
6269 YAHOO.util.Dom.setStyle(shim, 'position', 'absolute');
6270 YAHOO.util.Dom.setStyle(shim, 'background', 'white');
6271 YAHOO.util.Dom.setStyle(shim, 'z-index', 11000);
6272 window.document.body.appendChild(shim);
6273 var shimEl = YAHOO.ext.Element.get(shim);
6274 shimEl.setOpacity(.01);
6275 shimEl.setXY([0, 0]);
6280 YAHOO.ext.SplitBar.createProxy = function(orientation){
6281 var proxy = document.createElement('div');
6282 proxy.unselectable = 'on';
6283 YAHOO.util.Dom.generateId(proxy, 'split-proxy');
6284 YAHOO.util.Dom.setStyle(proxy, 'position', 'absolute');
6285 YAHOO.util.Dom.setStyle(proxy, 'visibility', 'hidden');
6286 YAHOO.util.Dom.setStyle(proxy, 'z-index', 11001);
6287 YAHOO.util.Dom.setStyle(proxy, 'background-color', "#aaa");
6288 if(orientation == YAHOO.ext.SplitBar.HORIZONTAL){
6289 YAHOO.util.Dom.setStyle(proxy, 'cursor', 'e-resize');
6291 YAHOO.util.Dom.setStyle(proxy, 'cursor', 'n-resize');
6294 YAHOO.util.Dom.setStyle(proxy, 'line-height', '0px');
6295 YAHOO.util.Dom.setStyle(proxy, 'font-size', '0px');
6296 window.document.body.appendChild(proxy);
6301 YAHOO.ext.SplitBar.BasicLayoutAdapter = function(){
6304 YAHOO.ext.SplitBar.BasicLayoutAdapter.prototype = {
6310 getElementSize : function(s){
6311 if(s.orientation == YAHOO.ext.SplitBar.HORIZONTAL){
6312 return s.resizingEl.getWidth();
6314 return s.resizingEl.getHeight();
6319 setElementSize : function(s, newSize, onComplete){
6320 if(s.orientation == YAHOO.ext.SplitBar.HORIZONTAL){
6321 if(!YAHOO.util.Anim || !s.animate){
6322 s.resizingEl.setWidth(newSize);
6324 onComplete(s, newSize);
6327 s.resizingEl.setWidth(newSize, true, .1, onComplete, YAHOO.util.Easing.easeOut);
6331 if(!YAHOO.util.Anim || !s.animate){
6332 s.resizingEl.setHeight(newSize);
6334 onComplete(s, newSize);
6337 s.resizingEl.setHeight(newSize, true, .1, onComplete, YAHOO.util.Easing.easeOut);
6344 YAHOO.ext.SplitBar.AbsoluteLayoutAdapter = function(container){
6345 this.basic = new YAHOO.ext.SplitBar.BasicLayoutAdapter();
6346 this.container = getEl(container);
6349 YAHOO.ext.SplitBar.AbsoluteLayoutAdapter.prototype = {
6355 getElementSize : function(s){
6356 return this.basic.getElementSize(s);
6359 setElementSize : function(s, newSize, onComplete){
6360 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
6363 moveSplitter : function(s){
6364 var yes = YAHOO.ext.SplitBar;
6365 switch(s.placement){
6367 s.el.setX(s.resizingEl.getRight());
6370 s.el.setStyle('right', (this.container.getWidth() - s.resizingEl.getLeft()) + 'px');
6373 s.el.setY(s.resizingEl.getBottom());
6376 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
6383 YAHOO.ext.SplitBar.VERTICAL = 1;
6386 YAHOO.ext.SplitBar.HORIZONTAL = 2;
6389 YAHOO.ext.SplitBar.LEFT = 1;
6392 YAHOO.ext.SplitBar.RIGHT = 2;
6395 YAHOO.ext.SplitBar.TOP = 3;
6398 YAHOO.ext.SplitBar.BOTTOM = 4;
6401 YAHOO.ext.grid.Grid = function(container, config, colModel, selectionModel){
6403 this.container = YAHOO.ext.Element.get(container);
6404 this.container.update('');
6405 this.container.setStyle('overflow', 'hidden');
6406 this.id = this.container.id;
6409 this.fieldId = null;
6410 var dataModel = config;
6411 this.dataModel = dataModel;
6412 this.colModel = colModel;
6413 this.selModel = selectionModel;
6414 this.activeEditor = null;
6415 this.editingCell = null;
6418 this.minColumnWidth = 25;
6421 this.autoSizeColumns = false;
6424 this.autoSizeHeaders = false;
6427 this.monitorWindowResize = true;
6430 this.maxRowsToMeasure = 0;
6433 this.trackMouseOver = false;
6436 this.enableDragDrop = false;
6439 this.stripeRows = true;
6441 this.autoHeight = false;
6444 this.autoWidth = false;
6450 this.allowTextSelectionPattern = /INPUT|TEXTAREA|SELECT/i;
6452 if(typeof config == 'object' && !config.getRowCount){
6453 YAHOO.ext.util.Config.apply(this, config);
6457 this.setValueDelegate = this.setCellValue.createDelegate(this);
6484 'celldblclick' : true,
6488 'rowdblclick' : true,
6490 'headerclick' : true,
6492 'rowcontextmenu' : true,
6494 'headercontextmenu' : true,
6496 'beforeedit' : true,
6500 'bodyscroll' : true,
6502 'columnresize' : true,
6518 YAHOO.ext.grid.Grid.prototype = {
6520 render : function(){
6521 if((!this.container.dom.offsetHeight || this.container.dom.offsetHeight < 20)
6522 || this.container.getStyle('height') == 'auto'){
6523 this.autoHeight = true;
6525 if((!this.container.dom.offsetWidth || this.container.dom.offsetWidth < 20)){
6526 this.autoWidth = true;
6529 if(this.dataModel.isPaged()){
6530 this.view = new YAHOO.ext.grid.PagedGridView();
6532 this.view = new YAHOO.ext.grid.GridView();
6535 this.view.init(this);
6536 this.el = getEl(this.view.render(), true);
6537 var c = this.container;
6538 c.mon("click", this.onClick, this, true);
6539 c.mon("dblclick", this.onDblClick, this, true);
6540 c.mon("contextmenu", this.onContextMenu, this, true);
6541 c.mon("selectstart", this.cancelTextSelection, this, true);
6542 c.mon("mousedown", this.cancelTextSelection, this, true);
6543 c.mon("mousedown", this.onMouseDown, this, true);
6544 c.mon("mouseup", this.onMouseUp, this, true);
6545 if(this.trackMouseOver){
6546 this.el.mon("mouseover", this.onMouseOver, this, true);
6547 this.el.mon("mouseout", this.onMouseOut, this, true);
6549 c.mon("keypress", this.onKeyPress, this, true);
6550 c.mon("keydown", this.onKeyDown, this, true);
6556 this.rows = this.el.dom.rows;
6557 if(!this.disableSelection){
6559 this.selModel = new YAHOO.ext.grid.DefaultSelectionModel(this);
6561 this.selModel.init(this);
6562 this.selModel.onSelectionChange.subscribe(this.updateField, this, true);
6564 this.selModel = new YAHOO.ext.grid.DisableSelectionModel(this);
6565 this.selModel.init(this);
6568 if(this.enableDragDrop){
6569 this.dd = new YAHOO.ext.grid.GridDD(this, this.container.dom);
6574 reset : function(config){
6575 this.destroy(false, true);
6576 YAHOO.ext.util.Config.apply(this, config);
6581 destroy : function(removeEl, keepListeners){
6582 var c = this.container;
6583 c.removeAllListeners();
6584 this.view.destroy();
6585 YAHOO.ext.EventManager.removeResizeListener(this.view.onWindowResize, this.view);
6587 this.colModel.purgeListeners();
6589 this.purgeListeners();
6592 if(removeEl === true){
6598 setDataModel : function(dm, rerender){
6599 this.view.unplugDataModel(this.dataModel);
6600 this.dataModel = dm;
6601 this.view.plugDataModel(dm);
6603 dm.fireEvent('datachanged');
6607 onMouseDown : function(e){
6608 this.fireEvent('mousedown', e);
6611 onMouseUp : function(e){
6612 this.fireEvent('mouseup', e);
6615 onMouseOver : function(e){
6616 this.fireEvent('mouseover', e);
6619 onMouseOut : function(e){
6620 this.fireEvent('mouseout', e);
6623 onKeyPress : function(e){
6624 this.fireEvent('keypress', e);
6627 onKeyDown : function(e){
6628 this.fireEvent('keydown', e);
6631 fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent,
6632 on : YAHOO.ext.util.Observable.prototype.on,
6633 addListener : YAHOO.ext.util.Observable.prototype.addListener,
6634 delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener,
6635 removeListener : YAHOO.ext.util.Observable.prototype.removeListener,
6636 purgeListeners : YAHOO.ext.util.Observable.prototype.purgeListeners,
6637 bufferedListener : YAHOO.ext.util.Observable.prototype.bufferedListener,
6639 onClick : function(e){
6640 this.fireEvent('click', e);
6641 var target = e.getTarget();
6642 var row = this.getRowFromChild(target);
6643 var cell = this.getCellFromChild(target);
6644 var header = this.getHeaderFromChild(target);
6646 this.fireEvent('rowclick', this, row.rowIndex, e);
6649 this.fireEvent('cellclick', this, row.rowIndex, cell.columnIndex, e);
6652 this.fireEvent('headerclick', this, header.columnIndex, e);
6656 onContextMenu : function(e){
6657 var target = e.getTarget();
6658 var row = this.getRowFromChild(target);
6659 var header = this.getHeaderFromChild(target);
6661 this.fireEvent('rowcontextmenu', this, row.rowIndex, e);
6664 this.fireEvent('headercontextmenu', this, header.columnIndex, e);
6669 onDblClick : function(e){
6670 this.fireEvent('dblclick', e);
6671 var target = e.getTarget();
6672 var row = this.getRowFromChild(target);
6673 var cell = this.getCellFromChild(target);
6675 this.fireEvent('rowdblclick', this, row.rowIndex, e);
6678 this.fireEvent('celldblclick', this, row.rowIndex, cell.columnIndex, e);
6683 startEditing : function(rowIndex, colIndex){
6684 var row = this.rows[rowIndex];
6685 var cell = row.childNodes[colIndex];
6687 setTimeout(this.doEdit.createDelegate(this, [row, cell]), 10);
6691 stopEditing : function(){
6692 if(this.activeEditor){
6693 this.activeEditor.stopEditing();
6698 doEdit : function(row, cell){
6699 if(!row || !cell) return;
6700 var cm = this.colModel;
6701 var dm = this.dataModel;
6702 var colIndex = cell.columnIndex;
6703 var rowIndex = row.rowIndex;
6704 if(cm.isCellEditable(colIndex, rowIndex)){
6705 var ed = cm.getCellEditor(colIndex, rowIndex);
6707 if(this.activeEditor){
6708 this.activeEditor.stopEditing();
6710 this.fireEvent('beforeedit', this, rowIndex, colIndex);
6711 this.activeEditor = ed;
6712 this.editingCell = cell;
6713 this.view.ensureVisible(row, true);
6717 ed.init(this, this.el.dom.parentNode, this.setValueDelegate);
6718 var value = dm.getValueAt(rowIndex, cm.getDataIndex(colIndex));
6720 setTimeout(ed.startEditing.createDelegate(ed, [value, row, cell]), 1);
6725 setCellValue : function(value, rowIndex, colIndex){
6726 this.dataModel.setValueAt(value, rowIndex, this.colModel.getDataIndex(colIndex));
6727 this.fireEvent('afteredit', this, rowIndex, colIndex);
6731 cancelTextSelection : function(e){
6732 var target = e.getTarget();
6733 if(target && target != this.el.dom.parentNode && !this.allowTextSelectionPattern.test(target.tagName)){
6739 autoSize : function(){
6740 this.view.updateWrapHeight();
6741 this.view.adjustForScroll();
6745 scrollTo : function(row){
6746 if(typeof row == 'number'){
6747 row = this.rows[row];
6749 this.view.ensureVisible(row, true);
6753 getEditingCell : function(){
6754 return this.editingCell;
6758 bindToField : function(fieldId){
6759 this.fieldId = fieldId;
6764 updateField : function(){
6766 var field = YAHOO.util.Dom.get(this.fieldId);
6767 field.value = this.getSelectedRowIds().join(',');
6772 readField : function(){
6774 var field = YAHOO.util.Dom.get(this.fieldId);
6775 var values = field.value.split(',');
6776 var rows = this.getRowsById(values);
6777 this.selModel.selectRows(rows, false);
6782 getRow : function(index){
6783 return this.rows[index];
6787 getRowsById : function(id){
6788 var dm = this.dataModel;
6789 if(!(id instanceof Array)){
6790 for(var i = 0; i < this.rows.length; i++){
6791 if(dm.getRowId(i) == id){
6792 return this.rows[i];
6799 for(var i = 0; i < id.length; i++){
6801 if(i != id.length-1) re += "|";
6803 var regex = new RegExp(re + ")$");
6804 for(var i = 0; i < this.rows.length; i++){
6805 if(regex.test(dm.getRowId(i))){
6806 found.push(this.rows[i]);
6813 getRowAfter : function(row){
6814 return this.getSibling('next', row);
6818 getRowBefore : function(row){
6819 return this.getSibling('previous', row);
6823 getCellAfter : function(cell, includeHidden){
6824 var next = this.getSibling('next', cell);
6825 if(next && !includeHidden && this.colModel.isHidden(next.columnIndex)){
6826 return this.getCellAfter(next);
6832 getCellBefore : function(cell, includeHidden){
6833 var prev = this.getSibling('previous', cell);
6834 if(prev && !includeHidden && this.colModel.isHidden(prev.columnIndex)){
6835 return this.getCellBefore(prev);
6841 getLastCell : function(row, includeHidden){
6842 var cell = this.getElement('previous', row.lastChild);
6843 if(cell && !includeHidden && this.colModel.isHidden(cell.columnIndex)){
6844 return this.getCellBefore(cell);
6850 getFirstCell : function(row, includeHidden){
6851 var cell = this.getElement('next', row.firstChild);
6852 if(cell && !includeHidden && this.colModel.isHidden(cell.columnIndex)){
6853 return this.getCellAfter(cell);
6859 getSibling : function(type, node){
6860 if(!node) return null;
6863 while(n && n.nodeType != 1){
6870 getElement : function(direction, node){
6871 if(!node || node.nodeType == 1) return node;
6872 else return this.getSibling(direction, node);
6876 getElementFromChild : function(childEl, parentClass){
6877 if(!childEl || (YAHOO.util.Dom.hasClass(childEl, parentClass))){
6880 var p = childEl.parentNode;
6881 var b = document.body;
6883 if(YAHOO.util.Dom.hasClass(p, parentClass)){
6892 getRowFromChild : function(childEl){
6893 return this.getElementFromChild(childEl, 'ygrid-row');
6897 getCellFromChild : function(childEl){
6898 return this.getElementFromChild(childEl, 'ygrid-col');
6903 getHeaderFromChild : function(childEl){
6904 return this.getElementFromChild(childEl, 'ygrid-hd');
6908 getSelectedRows : function(){
6909 return this.selModel.getSelectedRows();
6913 getSelectedRow : function(){
6914 if(this.selModel.hasSelection()){
6915 return this.selModel.getSelectedRows()[0];
6921 getSelectedRowIndexes : function(){
6923 var rows = this.selModel.getSelectedRows();
6924 for(var i = 0; i < rows.length; i++) {
6925 a[i] = rows[i].rowIndex;
6931 getSelectedRowIndex : function(){
6932 if(this.selModel.hasSelection()){
6933 return this.selModel.getSelectedRows()[0].rowIndex;
6939 getSelectedRowId : function(){
6940 if(this.selModel.hasSelection()){
6941 return this.selModel.getSelectedRowIds()[0];
6947 getSelectedRowIds : function(){
6948 return this.selModel.getSelectedRowIds();
6952 clearSelections : function(){
6953 this.selModel.clearSelections();
6958 selectAll : function(){
6959 this.selModel.selectAll();
6964 getSelectionCount : function(){
6965 return this.selModel.getCount();
6969 hasSelection : function(){
6970 return this.selModel.hasSelection();
6974 getSelectionModel : function(){
6976 this.selModel = new DefaultSelectionModel();
6978 return this.selModel;
6982 getDataModel : function(){
6983 return this.dataModel;
6987 getColumnModel : function(){
6988 return this.colModel;
6992 getView : function(){
6996 getDragDropText : function(){
6997 return this.ddText.replace('%0', this.selModel.getCount());
7001 YAHOO.ext.grid.Grid.prototype.ddText = "%0 selected row(s)";
7004 if(YAHOO.util.DDProxy){
7006 YAHOO.ext.grid.GridDD = function(grid, bwrap){
7008 var ddproxy = document.createElement('div');
7009 ddproxy.id = grid.container.id + '-ddproxy';
7010 ddproxy.className = 'ygrid-drag-proxy';
7011 document.body.insertBefore(ddproxy, document.body.firstChild);
7012 YAHOO.util.Dom.setStyle(ddproxy, 'opacity', .80);
7013 var ddicon = document.createElement('span');
7014 ddicon.className = 'ygrid-drop-icon ygrid-drop-nodrop';
7015 ddproxy.appendChild(ddicon);
7016 var ddtext = document.createElement('span');
7017 ddtext.className = 'ygrid-drag-text';
7018 ddtext.innerHTML = " ";
7019 ddproxy.appendChild(ddtext);
7021 this.ddproxy = ddproxy;
7022 this.ddtext = ddtext;
7023 this.ddicon = ddicon;
7024 YAHOO.util.Event.on(bwrap, 'click', this.handleClick, this, true);
7025 YAHOO.ext.grid.GridDD.superclass.constructor.call(this, bwrap.id, 'GridDD',
7026 {dragElId : ddproxy.id, resizeFrame: false});
7028 this.unlockDelegate = grid.selModel.unlock.createDelegate(grid.selModel);
7030 YAHOO.extendX(YAHOO.ext.grid.GridDD, YAHOO.util.DDProxy);
7032 YAHOO.ext.grid.GridDD.prototype.handleMouseDown = function(e){
7033 var row = this.grid.getRowFromChild(YAHOO.util.Event.getTarget(e));
7035 if(this.grid.selModel.isSelected(row)){
7036 YAHOO.ext.grid.GridDD.superclass.handleMouseDown.call(this, e);
7038 this.grid.selModel.unlock();
7039 YAHOO.ext.EventObject.setEvent(e);
7040 this.grid.selModel.rowClick(this.grid, row.rowIndex, YAHOO.ext.EventObject);
7041 YAHOO.ext.grid.GridDD.superclass.handleMouseDown.call(this, e);
7042 this.grid.selModel.lock();
7046 YAHOO.ext.grid.GridDD.prototype.handleClick = function(e){
7047 if(this.grid.selModel.isLocked()){
7048 setTimeout(this.unlockDelegate, 1);
7049 YAHOO.util.Event.stopEvent(e);
7054 YAHOO.ext.grid.GridDD.prototype.setDropStatus = function(dropStatus){
7055 if(dropStatus === true){
7056 YAHOO.util.Dom.replaceClass(this.ddicon, 'ygrid-drop-nodrop', 'ygrid-drop-ok');
7058 YAHOO.util.Dom.replaceClass(this.ddicon, 'ygrid-drop-ok', 'ygrid-drop-nodrop');
7062 YAHOO.ext.grid.GridDD.prototype.startDrag = function(e){
7063 this.ddtext.innerHTML = this.grid.getDragDropText();
7064 this.setDropStatus(false);
7065 this.grid.selModel.lock();
7066 this.grid.fireEvent('startdrag', this.grid, this, e);
7069 YAHOO.ext.grid.GridDD.prototype.endDrag = function(e){
7070 YAHOO.util.Dom.setStyle(this.ddproxy, 'visibility', 'hidden');
7071 this.grid.fireEvent('enddrag', this.grid, this, e);
7074 YAHOO.ext.grid.GridDD.prototype.autoOffset = function(iPageX, iPageY) {
7075 this.setDelta(-12, -20);
7078 YAHOO.ext.grid.GridDD.prototype.onDragEnter = function(e, id) {
7079 this.setDropStatus(true);
7080 this.grid.fireEvent('dragenter', this.grid, this, id, e);
7083 YAHOO.ext.grid.GridDD.prototype.onDragDrop = function(e, id) {
7084 this.grid.fireEvent('dragdrop', this.grid, this, id, e);
7087 YAHOO.ext.grid.GridDD.prototype.onDragOver = function(e, id) {
7088 this.grid.fireEvent('dragover', this.grid, this, id, e);
7091 YAHOO.ext.grid.GridDD.prototype.onDragOut = function(e, id) {
7092 this.setDropStatus(false);
7093 this.grid.fireEvent('dragout', this.grid, this, id, e);
7097 YAHOO.ext.grid.GridView = function(){
7099 this.lastFocusedRow = null;
7100 this.onScroll = new YAHOO.util.CustomEvent('onscroll');
7101 this.adjustScrollTask = new YAHOO.ext.util.DelayedTask(this._adjustForScroll, this);
7102 this.ensureVisibleTask = new YAHOO.ext.util.DelayedTask();
7105 YAHOO.ext.grid.GridView.prototype = {
7106 init: function(grid){
7110 fireScroll: function(scrollLeft, scrollTop){
7111 this.onScroll.fireDirect(this.grid, scrollLeft, scrollTop);
7115 getColumnRenderers : function(){
7117 var cm = this.grid.colModel;
7118 var colCount = cm.getColumnCount();
7119 for(var i = 0; i < colCount; i++){
7120 renderers.push(cm.getRenderer(i));
7125 buildIndexMap : function(){
7128 var cm = this.grid.colModel;
7129 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7130 var di = cm.getDataIndex(i);
7134 return {'colToData': colToData, 'dataToCol': dataToCol};
7137 getDataIndexes : function(){
7139 this.indexMap = this.buildIndexMap();
7141 return this.indexMap.colToData;
7144 getColumnIndexByDataIndex : function(dataIndex){
7146 this.indexMap = this.buildIndexMap();
7148 return this.indexMap.dataToCol[dataIndex];
7151 updateHeaders : function(){
7152 var colModel = this.grid.colModel;
7153 var hcells = this.headers;
7154 var colCount = colModel.getColumnCount();
7155 for(var i = 0; i < colCount; i++){
7156 hcells[i].textNode.innerHTML = colModel.getColumnHeader(i);
7160 adjustForScroll : function(disableDelay){
7162 this.adjustScrollTask.delay(50);
7164 this._adjustForScroll();
7169 getCellAtPoint : function(x, y){
7170 var colIndex = null;
7171 var rowIndex = null;
7174 var xy = YAHOO.util.Dom.getXY(this.wrap);
7175 x = (x - xy[0]) + this.wrap.scrollLeft;
7176 y = (y - xy[1]) + this.wrap.scrollTop;
7178 var colModel = this.grid.colModel;
7180 var colCount = colModel.getColumnCount();
7181 for(var i = 0; i < colCount; i++){
7182 if(colModel.isHidden(i)) continue;
7183 var width = colModel.getColumnWidth(i);
7184 if(x >= pos && x < pos+width){
7190 if(colIndex != null){
7191 rowIndex = (y == 0 ? 0 : Math.floor(y / this.getRowHeight()));
7192 if(rowIndex >= this.grid.dataModel.getRowCount()){
7195 return [colIndex, rowIndex];
7201 _adjustForScroll : function(){
7202 this.forceScrollUpdate();
7203 if(this.scrollbarMode == YAHOO.ext.grid.GridView.SCROLLBARS_OVERLAP){
7205 if(this.wrap.clientWidth && this.wrap.clientWidth !== 0){
7206 adjustment = this.wrap.offsetWidth - this.wrap.clientWidth;
7208 this.hwrap.setWidth(this.wrap.offsetWidth-adjustment);
7210 this.hwrap.setWidth(this.wrap.offsetWidth);
7212 this.bwrap.setWidth(Math.max(this.grid.colModel.getTotalWidth(), this.wrap.clientWidth));
7216 focusRow : function(row){
7217 if(typeof row == 'number'){
7218 row = this.getBodyTable().childNodes[row];
7221 var left = this.wrap.scrollLeft;
7223 row.childNodes.item(0).hideFocus = true;
7224 row.childNodes.item(0).focus();
7226 this.ensureVisible(row);
7227 this.wrap.scrollLeft = left;
7228 this.handleScroll();
7229 this.lastFocusedRow = row;
7233 ensureVisible : function(row, disableDelay){
7235 this.ensureVisibleTask.delay(50, this._ensureVisible, this, [row]);
7237 this._ensureVisible(row);
7242 _ensureVisible : function(row){
7243 if(typeof row == 'number'){
7244 row = this.getBodyTable().childNodes[row];
7247 var left = this.wrap.scrollLeft;
7248 var rowTop = parseInt(row.offsetTop, 10);
7249 var rowBottom = rowTop + row.offsetHeight;
7250 var clientTop = parseInt(this.wrap.scrollTop, 10);
7251 var clientBottom = clientTop + this.wrap.clientHeight;
7252 if(rowTop < clientTop){
7253 this.wrap.scrollTop = rowTop;
7254 }else if(rowBottom > clientBottom){
7255 this.wrap.scrollTop = rowBottom-this.wrap.clientHeight;
7257 this.wrap.scrollLeft = left;
7258 this.handleScroll();
7261 updateColumns : function(){
7262 this.grid.stopEditing();
7263 var colModel = this.grid.colModel;
7264 var hcols = this.headers;
7265 var colCount = colModel.getColumnCount();
7267 var totalWidth = colModel.getTotalWidth();
7268 for(var i = 0; i < colCount; i++){
7269 if(colModel.isHidden(i)) continue;
7270 var width = colModel.getColumnWidth(i);
7271 hcols[i].style.width = width + 'px';
7272 hcols[i].style.left = pos + 'px';
7273 hcols[i].split.style.left = (pos+width-3) + 'px';
7274 this.setCSSWidth(i, width, pos);
7277 this.lastWidth = totalWidth;
7278 if(this.grid.autoWidth){
7279 this.grid.container.setWidth(totalWidth+this.grid.container.getBorderWidth('lr'));
7280 this.grid.autoSize();
7282 this.bwrap.setWidth(Math.max(totalWidth, this.wrap.clientWidth));
7283 if(!YAHOO.ext.util.Browser.isIE){
7284 this.wrap.scrollLeft = this.hwrap.dom.scrollLeft;
7287 this.forceScrollUpdate();
7288 if(this.grid.autoHeight){
7290 this.updateWrapHeight();
7294 setCSSWidth : function(colIndex, width, pos){
7295 var selector = ["#" + this.grid.id + " .ygrid-col-" + colIndex, ".ygrid-col-" + colIndex];
7296 YAHOO.ext.util.CSS.updateRule(selector, 'width', width + 'px');
7297 if(typeof pos == 'number'){
7298 YAHOO.ext.util.CSS.updateRule(selector, 'left', pos + 'px');
7303 setCSSStyle : function(colIndex, name, value){
7304 var selector = ["#" + this.grid.id + " .ygrid-col-" + colIndex, ".ygrid-col-" + colIndex];
7305 YAHOO.ext.util.CSS.updateRule(selector, name, value);
7308 handleHiddenChange : function(colModel, colIndex, hidden){
7310 this.hideColumn(colIndex);
7312 this.unhideColumn(colIndex);
7314 this.updateColumns();
7317 hideColumn : function(colIndex){
7318 var selector = ["#" + this.grid.id + " .ygrid-col-" + colIndex, ".ygrid-col-" + colIndex];
7319 YAHOO.ext.util.CSS.updateRule(selector, 'position', 'absolute');
7320 YAHOO.ext.util.CSS.updateRule(selector, 'visibility', 'hidden');
7322 this.headers[colIndex].style.display = 'none';
7323 this.headers[colIndex].split.style.display = 'none';
7326 unhideColumn : function(colIndex){
7327 var selector = ["#" + this.grid.id + " .ygrid-col-" + colIndex, ".ygrid-col-" + colIndex];
7328 YAHOO.ext.util.CSS.updateRule(selector, 'position', '');
7329 YAHOO.ext.util.CSS.updateRule(selector, 'visibility', 'visible');
7331 this.headers[colIndex].style.display = '';
7332 this.headers[colIndex].split.style.display = '';
7335 getBodyTable : function(){
7336 return this.bwrap.dom;
7339 updateRowIndexes : function(firstRow, lastRow){
7340 var stripeRows = this.grid.stripeRows;
7341 var bt = this.getBodyTable();
7342 var nodes = bt.childNodes;
7343 firstRow = firstRow || 0;
7344 lastRow = lastRow || nodes.length-1;
7345 var re = /^(?:ygrid-row ygrid-row-alt|ygrid-row)/;
7346 for(var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
7347 var node = nodes[rowIndex];
7348 if(stripeRows && (rowIndex+1) % 2 == 0){
7349 node.className = node.className.replace(re, 'ygrid-row ygrid-row-alt');
7351 node.className = node.className.replace(re, 'ygrid-row');
7353 node.rowIndex = rowIndex;
7354 nodes[rowIndex].style.top = (rowIndex * this.rowHeight) + 'px';
7358 insertRows : function(dataModel, firstRow, lastRow){
7359 this.updateBodyHeight();
7360 this.adjustForScroll(true);
7361 var renderers = this.getColumnRenderers();
7362 var dindexes = this.getDataIndexes();
7363 var colCount = this.grid.colModel.getColumnCount();
7364 var beforeRow = null;
7365 var bt = this.getBodyTable();
7366 if(firstRow < bt.childNodes.length){
7367 beforeRow = bt.childNodes[firstRow];
7369 for(var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
7370 var row = document.createElement('span');
7371 row.className = 'ygrid-row';
7372 row.style.top = (rowIndex * this.rowHeight) + 'px';
7373 this.renderRow(dataModel, row, rowIndex, colCount, renderers, dindexes);
7375 bt.insertBefore(row, beforeRow);
7377 bt.appendChild(row);
7380 this.updateRowIndexes(firstRow);
7381 this.adjustForScroll(true);
7384 renderRow : function(dataModel, row, rowIndex, colCount, renderers, dindexes){
7385 for(var colIndex = 0; colIndex < colCount; colIndex++){
7386 var td = document.createElement('span');
7387 td.className = 'ygrid-col ygrid-col-' + colIndex + (colIndex == colCount-1 ? ' ygrid-col-last' : '');
7388 td.columnIndex = colIndex;
7390 var span = document.createElement('span');
7391 span.className = 'ygrid-cell-text';
7392 td.appendChild(span);
7393 var val = renderers[colIndex](dataModel.getValueAt(rowIndex, dindexes[colIndex]), rowIndex, colIndex, td);
7394 if(typeof val == 'undefined' || val === '') val = ' ';
7395 span.innerHTML = val;
7396 row.appendChild(td);
7400 deleteRows : function(dataModel, firstRow, lastRow){
7401 this.updateBodyHeight();
7403 this.grid.selModel.deselectRange(firstRow, lastRow);
7404 var bt = this.getBodyTable();
7406 for(var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
7407 rows.push(bt.childNodes[rowIndex]);
7409 for(var i = 0; i < rows.length; i++){
7410 bt.removeChild(rows[i]);
7414 this.updateRowIndexes(firstRow);
7415 this.adjustForScroll();
7418 updateRows : function(dataModel, firstRow, lastRow){
7419 var bt = this.getBodyTable();
7420 var dindexes = this.getDataIndexes();
7421 var renderers = this.getColumnRenderers();
7422 var colCount = this.grid.colModel.getColumnCount();
7423 for(var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
7424 var row = bt.rows[rowIndex];
7425 var cells = row.childNodes;
7426 for(var colIndex = 0; colIndex < colCount; colIndex++){
7427 var td = cells[colIndex];
7428 var val = renderers[colIndex](dataModel.getValueAt(rowIndex, dindexes[colIndex]), rowIndex, colIndex, td);
7429 if(typeof val == 'undefined' || val === '') val = ' ';
7430 td.firstChild.innerHTML = val;
7435 handleSort : function(dataModel, sortColumnIndex, sortDir, noRefresh){
7436 this.grid.selModel.syncSelectionsToIds();
7438 this.updateRows(dataModel, 0, dataModel.getRowCount()-1);
7440 this.updateHeaderSortState();
7441 if(this.lastFocusedRow){
7442 this.focusRow(this.lastFocusedRow);
7446 syncScroll : function(){
7447 this.hwrap.dom.scrollLeft = this.wrap.scrollLeft;
7450 handleScroll : function(){
7452 this.fireScroll(this.wrap.scrollLeft, this.wrap.scrollTop);
7453 this.grid.fireEvent('bodyscroll', this.wrap.scrollLeft, this.wrap.scrollTop);
7456 getRowHeight : function(){
7457 if(!this.rowHeight){
7458 var rule = YAHOO.ext.util.CSS.getRule(["#" + this.grid.id + " .ygrid-row", ".ygrid-row"]);
7459 if(rule && rule.style.height){
7460 this.rowHeight = parseInt(rule.style.height, 10);
7462 this.rowHeight = 21;
7465 return this.rowHeight;
7468 renderRows : function(dataModel){
7469 this.grid.stopEditing();
7470 if(this.grid.selModel){
7471 this.grid.selModel.clearSelections();
7473 var bt = this.getBodyTable();
7475 this.rowHeight = this.getRowHeight();
7476 this.insertRows(dataModel, 0, dataModel.getRowCount()-1);
7479 updateCell : function(dataModel, rowIndex, dataIndex){
7480 var colIndex = this.getColumnIndexByDataIndex(dataIndex);
7481 if(typeof colIndex == 'undefined'){
7484 var bt = this.getBodyTable();
7485 var row = bt.childNodes[rowIndex];
7486 var cell = row.childNodes[colIndex];
7487 var renderer = this.grid.colModel.getRenderer(colIndex);
7488 var val = renderer(dataModel.getValueAt(rowIndex, dataIndex), rowIndex, colIndex, cell);
7489 if(typeof val == 'undefined' || val === '') val = ' ';
7490 cell.firstChild.innerHTML = val;
7493 calcColumnWidth : function(colIndex, maxRowsToMeasure){
7495 var bt = this.getBodyTable();
7496 var rows = bt.childNodes;
7497 var stopIndex = Math.min(maxRowsToMeasure || rows.length, rows.length);
7498 if(this.grid.autoSizeHeaders){
7499 var h = this.headers[colIndex];
7500 var curWidth = h.style.width;
7501 h.style.width = this.grid.minColumnWidth+'px';
7502 maxWidth = Math.max(maxWidth, h.scrollWidth);
7503 h.style.width = curWidth;
7505 for(var i = 0; i < stopIndex; i++){
7506 var cell = rows[i].childNodes[colIndex].firstChild;
7507 maxWidth = Math.max(maxWidth, cell.scrollWidth);
7509 return maxWidth + 5;
7513 autoSizeColumn : function(colIndex, forceMinSize){
7515 this.setCSSWidth(colIndex, this.grid.minColumnWidth);
7517 var newWidth = this.calcColumnWidth(colIndex);
7518 this.grid.colModel.setColumnWidth(colIndex,
7519 Math.max(this.grid.minColumnWidth, newWidth));
7520 this.grid.fireEvent('columnresize', colIndex, newWidth);
7524 autoSizeColumns : function(){
7525 var colModel = this.grid.colModel;
7526 var colCount = colModel.getColumnCount();
7527 var wrap = this.wrap;
7528 for(var i = 0; i < colCount; i++){
7529 this.setCSSWidth(i, this.grid.minColumnWidth);
7530 colModel.setColumnWidth(i, this.calcColumnWidth(i, this.grid.maxRowsToMeasure), true);
7532 if(colModel.getTotalWidth() < wrap.clientWidth){
7533 var diff = Math.floor((wrap.clientWidth - colModel.getTotalWidth()) / colCount);
7534 for(var i = 0; i < colCount; i++){
7535 colModel.setColumnWidth(i, colModel.getColumnWidth(i) + diff, true);
7538 this.updateColumns();
7542 fitColumns : function(){
7543 var cm = this.grid.colModel;
7544 var colCount = cm.getColumnCount();
7548 for (i = 0; i < colCount; i++){
7549 if(!cm.isHidden(i) && !cm.isFixed(i)){
7550 w = cm.getColumnWidth(i);
7556 var frac = (this.wrap.clientWidth - cm.getTotalWidth())/width;
7557 while (cols.length){
7560 cm.setColumnWidth(i, Math.floor(w + w*frac), true);
7562 this.updateColumns();
7565 onWindowResize : function(){
7566 if(this.grid.monitorWindowResize){
7567 this.adjustForScroll();
7568 this.updateWrapHeight();
7569 this.adjustForScroll();
7573 updateWrapHeight : function(){
7574 this.grid.container.beginMeasure();
7576 var box = this.grid.container.getSize(true);
7577 this.wrapEl.setHeight(box.height-this.footerHeight-parseInt(this.wrap.offsetTop, 10));
7578 this.pwrap.setSize(box.width, box.height);
7579 this.grid.container.endMeasure();
7582 forceScrollUpdate : function(){
7583 var wrap = this.wrapEl;
7584 wrap.setWidth(wrap.getWidth(true));
7585 setTimeout(function(){
7590 updateHeaderSortState : function(){
7591 var state = this.grid.dataModel.getSortState();
7592 if(!state || typeof state.column == 'undefined') return;
7593 var sortColumn = this.getColumnIndexByDataIndex(state.column);
7594 var sortDir = state.direction;
7595 for(var i = 0, len = this.headers.length; i < len; i++){
7596 var h = this.headers[i];
7597 if(i != sortColumn){
7598 h.sortDesc.style.display = 'none';
7599 h.sortAsc.style.display = 'none';
7601 h.sortDesc.style.display = sortDir == 'DESC' ? 'block' : 'none';
7602 h.sortAsc.style.display = sortDir == 'ASC' ? 'block' : 'none';
7607 unplugDataModel : function(dm){
7608 dm.removeListener('cellupdated', this.updateCell, this);
7609 dm.removeListener('datachanged', this.renderRows, this);
7610 dm.removeListener('rowsdeleted', this.deleteRows, this);
7611 dm.removeListener('rowsinserted', this.insertRows, this);
7612 dm.removeListener('rowsupdated', this.updateRows, this);
7613 dm.removeListener('rowssorted', this.handleSort, this);
7616 plugDataModel : function(dm){
7617 dm.on('cellupdated', this.updateCell, this, true);
7618 dm.on('datachanged', this.renderRows, this, true);
7619 dm.on('rowsdeleted', this.deleteRows, this, true);
7620 dm.on('rowsinserted', this.insertRows, this, true);
7621 dm.on('rowsupdated', this.updateRows, this, true);
7622 dm.on('rowssorted', this.handleSort, this, true);
7625 destroy : function(){
7626 this.unplugDataModel(this.grid.dataModel);
7627 var sp = this.splitters;
7630 if(sp[i] && typeof sp[i] != 'function'){
7631 sp[i].destroy(true);
7637 render : function(){
7638 var grid = this.grid;
7639 var container = grid.container.dom;
7640 var dataModel = grid.dataModel;
7641 this.plugDataModel(dataModel);
7643 var colModel = grid.colModel;
7644 colModel.onWidthChange.subscribe(this.updateColumns, this, true);
7645 colModel.onHeaderChange.subscribe(this.updateHeaders, this, true);
7646 colModel.onHiddenChange.subscribe(this.handleHiddenChange, this, true);
7648 if(grid.monitorWindowResize === true){
7649 YAHOO.ext.EventManager.onWindowResize(this.onWindowResize, this, true);
7651 var autoSizeDelegate = this.autoSizeColumn.createDelegate(this);
7653 var colCount = colModel.getColumnCount();
7655 var dh = YAHOO.ext.DomHelper;
7656 this.pwrap = dh.append(container,
7657 {tag: 'div', cls: 'ygrid-positioner',
7658 style: 'position:relative;width:100%;height:100%;left:0;top:0;overflow:hidden;'}, true);
7659 var pos = this.pwrap.dom;
7662 var wrap = dh.append(pos, {tag: 'div', cls: 'ygrid-wrap'});
7664 this.wrapEl = getEl(wrap, true);
7665 YAHOO.ext.EventManager.on(wrap, 'scroll', this.handleScroll, this, true);
7667 var hwrap = dh.append(pos, {tag: 'div', cls: 'ygrid-wrap-headers'});
7668 this.hwrap = getEl(hwrap, true);
7670 var bwrap = dh.append(wrap, {tag: 'div', cls: 'ygrid-wrap-body', id: container.id + '-body'});
7671 this.bwrap = getEl(bwrap, true);
7672 this.bwrap.setWidth(colModel.getTotalWidth());
7673 bwrap.rows = bwrap.childNodes;
7675 this.footerHeight = 0;
7676 var foot = this.appendFooter(this.pwrap.dom);
7678 this.footer = getEl(foot, true);
7679 this.footerHeight = this.footer.getHeight();
7681 this.updateWrapHeight();
7683 var hrow = dh.append(hwrap, {tag: 'span', cls: 'ygrid-hrow'});
7686 if(!YAHOO.ext.util.Browser.isGecko){
7688 var iframe = document.createElement('iframe');
7689 iframe.className = 'ygrid-hrow-frame';
7690 iframe.frameBorder = 0;
7691 iframe.src = YAHOO.ext.SSL_SECURE_URL;
7692 hwrap.appendChild(iframe);
7694 this.headerCtrl = new YAHOO.ext.grid.HeaderController(this.grid);
7697 this.splitters = [];
7699 var htemplate = dh.createTemplate({
7700 tag: 'span', cls: 'ygrid-hd ygrid-header-{0}', children: [{
7702 cls: 'ygrid-hd-body',
7703 html: '<table border="0" cellpadding="0" cellspacing="0" title="{2}">' +
7704 '<tbody><tr><td><span>{1}</span></td>' +
7705 '<td><span class="sort-desc"></span><span class="sort-asc"></span></td>' +
7706 '</tr></tbody></table>'
7709 htemplate.compile();
7710 for(var i = 0; i < colCount; i++){
7711 var hd = htemplate.append(hrow, [i, colModel.getColumnHeader(i), colModel.getColumnTooltip(i) || '']);
7712 var spans = hd.getElementsByTagName('span');
7713 hd.textNode = spans[1];
7714 hd.sortDesc = spans[2];
7715 hd.sortAsc = spans[3];
7717 this.headers.push(hd);
7718 if(colModel.isSortable(i)){
7719 this.headerCtrl.register(hd);
7721 var split = dh.append(hrow, {tag: 'span', cls: 'ygrid-hd-split'});
7724 if(colModel.isResizable(i) && !colModel.isFixed(i)){
7725 YAHOO.util.Event.on(split, 'dblclick', autoSizeDelegate.createCallback(i+0, true));
7726 var sb = new YAHOO.ext.SplitBar(split, hd, null, YAHOO.ext.SplitBar.LEFT);
7728 sb.minSize = grid.minColumnWidth;
7729 sb.onMoved.subscribe(this.onColumnSplitterMoved, this, true);
7730 YAHOO.util.Dom.addClass(sb.proxy, 'ygrid-column-sizer');
7731 YAHOO.util.Dom.setStyle(sb.proxy, 'background-color', '');
7732 sb.dd._resizeProxy = function(){
7733 var el = this.getDragEl();
7734 YAHOO.util.Dom.setStyle(el, 'height', (hwrap.clientHeight+wrap.clientHeight-2) +'px');
7736 this.splitters[i] = sb;
7738 split.style.cursor = 'default';
7741 if(grid.autoSizeColumns){
7742 this.renderRows(dataModel);
7743 this.autoSizeColumns();
7745 this.updateColumns();
7746 this.renderRows(dataModel);
7749 for(var i = 0; i < colCount; i++){
7750 if(colModel.isHidden(i)){
7754 this.updateHeaderSortState();
7758 onColumnSplitterMoved : function(splitter, newSize){
7759 this.grid.colModel.setColumnWidth(splitter.columnIndex, newSize);
7760 this.grid.fireEvent('columnresize', splitter.columnIndex, newSize);
7763 appendFooter : function(parentEl){
7767 autoHeight : function(){
7768 if(this.grid.autoHeight){
7769 var h = this.getBodyHeight();
7770 var c = this.grid.container;
7771 var total = h + (parseInt(this.wrap.offsetTop, 10)||0) +
7772 this.footerHeight + c.getBorderWidth('tb') + c.getPadding('tb')
7773 + (this.wrap.offsetHeight - this.wrap.clientHeight);
7779 getBodyHeight : function(){
7780 return this.grid.dataModel.getRowCount() * this.getRowHeight();;
7783 updateBodyHeight : function(){
7784 this.getBodyTable().style.height = this.getBodyHeight() + 'px';
7785 if(this.grid.autoHeight){
7787 this.updateWrapHeight();
7791 YAHOO.ext.grid.GridView.SCROLLBARS_UNDER = 0;
7792 YAHOO.ext.grid.GridView.SCROLLBARS_OVERLAP = 1;
7793 YAHOO.ext.grid.GridView.prototype.scrollbarMode = YAHOO.ext.grid.GridView.SCROLLBARS_UNDER;
7795 YAHOO.ext.grid.GridView.prototype.fitColumnsToContainer = YAHOO.ext.grid.GridView.prototype.fitColumns;
7797 YAHOO.ext.grid.HeaderController = function(grid){
7802 YAHOO.ext.grid.HeaderController.prototype = {
7803 register : function(header){
7804 this.headers.push(header);
7805 YAHOO.ext.EventManager.on(header, 'selectstart', this.cancelTextSelection, this, true);
7806 YAHOO.ext.EventManager.on(header, 'mousedown', this.cancelTextSelection, this, true);
7807 YAHOO.ext.EventManager.on(header, 'mouseover', this.headerOver, this, true);
7808 YAHOO.ext.EventManager.on(header, 'mouseout', this.headerOut, this, true);
7809 YAHOO.ext.EventManager.on(header, 'click', this.headerClick, this, true);
7812 headerClick : function(e){
7813 var grid = this.grid, cm = grid.colModel, dm = grid.dataModel;
7815 var header = grid.getHeaderFromChild(e.getTarget());
7816 var state = dm.getSortState();
7817 var direction = header.sortDir || 'ASC';
7818 if(typeof state.column != 'undefined' &&
7819 grid.getView().getColumnIndexByDataIndex(state.column) == header.columnIndex){
7820 direction = (state.direction == 'ASC' ? 'DESC' : 'ASC');
7822 header.sortDir = direction;
7823 dm.sort(cm, cm.getDataIndex(header.columnIndex), direction);
7826 headerOver : function(e){
7827 var header = this.grid.getHeaderFromChild(e.getTarget());
7828 YAHOO.util.Dom.addClass(header, 'ygrid-hd-over');
7832 headerOut : function(e){
7833 var header = this.grid.getHeaderFromChild(e.getTarget());
7834 YAHOO.util.Dom.removeClass(header, 'ygrid-hd-over');
7838 cancelTextSelection : function(e){
7843 YAHOO.ext.grid.PagedGridView = function(){
7844 YAHOO.ext.grid.PagedGridView.superclass.constructor.call(this);
7848 YAHOO.extendX(YAHOO.ext.grid.PagedGridView, YAHOO.ext.grid.GridView, {
7849 appendFooter : function(parentEl){
7850 var fwrap = document.createElement('div');
7851 fwrap.className = 'ygrid-wrap-footer';
7852 var fbody = document.createElement('span');
7853 fbody.className = 'ygrid-footer';
7854 fwrap.appendChild(fbody);
7855 parentEl.appendChild(fwrap);
7856 this.createPagingToolbar(fbody);
7860 createPagingToolbar : function(container){
7861 var tb = new YAHOO.ext.Toolbar(container);
7862 this.pageToolbar = tb;
7863 this.first = tb.addButton({
7864 tooltip: this.firstText,
7865 className: 'ygrid-page-first',
7867 click: this.onClick.createDelegate(this, ['first'])
7869 this.prev = tb.addButton({
7870 tooltip: this.prevText,
7871 className: 'ygrid-page-prev',
7873 click: this.onClick.createDelegate(this, ['prev'])
7876 tb.add(this.beforePageText);
7877 var pageBox = document.createElement('input');
7878 pageBox.type = 'text';
7880 pageBox.value = '1';
7881 pageBox.className = 'ygrid-page-number';
7883 this.field = getEl(pageBox, true);
7884 this.field.mon('keydown', this.onEnter, this, true);
7885 this.field.on('focus', function(){pageBox.select();});
7886 this.afterTextEl = tb.addText(this.afterPageText.replace('%0', '1'));
7887 this.field.setHeight(18);
7889 this.next = tb.addButton({
7890 tooltip: this.nextText,
7891 className: 'ygrid-page-next',
7893 click: this.onClick.createDelegate(this, ['next'])
7895 this.last = tb.addButton({
7896 tooltip: this.lastText,
7897 className: 'ygrid-page-last',
7899 click: this.onClick.createDelegate(this, ['last'])
7902 this.loading = tb.addButton({
7903 tooltip: this.refreshText,
7904 className: 'ygrid-loading',
7906 click: this.onClick.createDelegate(this, ['refresh'])
7908 this.onPageLoaded(1, this.grid.dataModel.getTotalPages());
7912 getPageToolbar : function(){
7913 return this.pageToolbar;
7916 onPageLoaded : function(pageNum, totalPages){
7917 this.cursor = pageNum;
7918 this.lastPage = totalPages;
7919 this.afterTextEl.innerHTML = this.afterPageText.replace('%0', totalPages);
7920 this.field.dom.value = pageNum;
7921 this.first.setDisabled(pageNum == 1);
7922 this.prev.setDisabled(pageNum == 1);
7923 this.next.setDisabled(pageNum == totalPages);
7924 this.last.setDisabled(pageNum == totalPages);
7925 this.loading.enable();
7928 onLoadError : function(){
7929 this.loading.enable();
7932 onEnter : function(e){
7933 if(e.browserEvent.keyCode == e.RETURN){
7934 var v = this.field.dom.value;
7936 this.field.dom.value = this.cursor;
7939 var pageNum = parseInt(v, 10);
7941 this.field.dom.value = this.cursor;
7944 pageNum = Math.min(Math.max(1, pageNum), this.lastPage);
7945 this.grid.dataModel.loadPage(pageNum);
7950 beforeLoad : function(){
7951 this.grid.stopEditing();
7953 this.loading.disable();
7957 onClick : function(which){
7960 this.grid.dataModel.loadPage(1);
7963 this.grid.dataModel.loadPage(this.cursor -1);
7966 this.grid.dataModel.loadPage(this.cursor + 1);
7969 this.grid.dataModel.loadPage(this.lastPage);
7972 this.grid.dataModel.loadPage(this.cursor);
7977 unplugDataModel : function(dm){
7978 dm.removeListener('beforeload', this.beforeLoad, this);
7979 dm.removeListener('load', this.onPageLoaded, this);
7980 dm.removeListener('loadexception', this.onLoadError, this);
7981 YAHOO.ext.grid.PagedGridView.superclass.unplugDataModel.call(this, dm);
7984 plugDataModel : function(dm){
7985 dm.on('beforeload', this.beforeLoad, this, true);
7986 dm.on('load', this.onPageLoaded, this, true);
7987 dm.on('loadexception', this.onLoadError, this);
7988 YAHOO.ext.grid.PagedGridView.superclass.plugDataModel.call(this, dm);
7992 beforePageText : "Page",
7994 afterPageText : "of %0",
7996 firstText : "First Page",
7998 prevText : "Previous Page",
8000 nextText : "Next Page",
8002 lastText : "Last Page",
8004 refreshText : "Refresh"
8008 YAHOO.ext.grid.EditorGrid = function(container, dataModel, colModel){
8009 YAHOO.ext.grid.EditorGrid.superclass.constructor.call(this, container, dataModel,
8010 colModel, new YAHOO.ext.grid.EditorSelectionModel());
8011 this.container.addClass('yeditgrid');
8013 YAHOO.extendX(YAHOO.ext.grid.EditorGrid, YAHOO.ext.grid.Grid);
8015 YAHOO.ext.grid.AbstractColumnModel = function(){
8017 this.onWidthChange = new YAHOO.util.CustomEvent('widthChanged');
8018 this.onHeaderChange = new YAHOO.util.CustomEvent('headerChanged');
8019 this.onHiddenChange = new YAHOO.util.CustomEvent('hiddenChanged');
8023 'widthchange': this.onWidthChange,
8025 'headerchange': this.onHeaderChange,
8027 'hiddenchange': this.onHiddenChange
8031 YAHOO.ext.grid.AbstractColumnModel.prototype = {
8032 fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent,
8033 on : YAHOO.ext.util.Observable.prototype.on,
8034 addListener : YAHOO.ext.util.Observable.prototype.addListener,
8035 delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener,
8036 removeListener : YAHOO.ext.util.Observable.prototype.removeListener,
8037 purgeListeners : YAHOO.ext.util.Observable.prototype.purgeListeners,
8038 bufferedListener : YAHOO.ext.util.Observable.prototype.bufferedListener,
8040 fireWidthChange : function(colIndex, newWidth){
8041 this.onWidthChange.fireDirect(this, colIndex, newWidth);
8044 fireHeaderChange : function(colIndex, newHeader){
8045 this.onHeaderChange.fireDirect(this, colIndex, newHeader);
8048 fireHiddenChange : function(colIndex, hidden){
8049 this.onHiddenChange.fireDirect(this, colIndex, hidden);
8053 getColumnCount : function(){
8058 isSortable : function(col){
8063 isHidden : function(col){
8068 getSortType : function(col){
8069 return YAHOO.ext.grid.DefaultColumnModel.sortTypes.none;
8073 getRenderer : function(col){
8074 return YAHOO.ext.grid.DefaultColumnModel.defaultRenderer;
8078 getColumnWidth : function(col){
8083 getTotalWidth : function(){
8088 getColumnHeader : function(col){
8094 YAHOO.ext.grid.DefaultColumnModel = function(config){
8095 YAHOO.ext.grid.DefaultColumnModel.superclass.constructor.call(this);
8097 this.config = config;
8100 this.defaultWidth = 100;
8102 this.defaultSortable = false;
8104 YAHOO.extendX(YAHOO.ext.grid.DefaultColumnModel, YAHOO.ext.grid.AbstractColumnModel, {
8107 getColumnCount : function(){
8108 return this.config.length;
8112 isSortable : function(col){
8113 if(typeof this.config[col].sortable == 'undefined'){
8114 return this.defaultSortable;
8116 return this.config[col].sortable;
8120 getSortType : function(col){
8124 for(var i = 0, len = this.config.length; i < len; i++){
8125 map[this.getDataIndex(i)] = i;
8129 col = this.dataMap[col];
8130 if(!this.config[col].sortType){
8131 return YAHOO.ext.grid.DefaultColumnModel.sortTypes.none;
8133 return this.config[col].sortType;
8137 setSortType : function(col, fn){
8138 this.config[col].sortType = fn;
8143 getRenderer : function(col){
8144 if(!this.config[col].renderer){
8145 return YAHOO.ext.grid.DefaultColumnModel.defaultRenderer;
8147 return this.config[col].renderer;
8151 setRenderer : function(col, fn){
8152 this.config[col].renderer = fn;
8156 getColumnWidth : function(col){
8157 return this.config[col].width || this.defaultWidth;
8161 setColumnWidth : function(col, width, suppressEvent){
8162 this.config[col].width = width;
8163 this.totalWidth = null;
8165 this.onWidthChange.fireDirect(this, col, width);
8170 getTotalWidth : function(includeHidden){
8171 if(!this.totalWidth){
8172 this.totalWidth = 0;
8173 for(var i = 0; i < this.config.length; i++){
8174 if(includeHidden || !this.isHidden(i)){
8175 this.totalWidth += this.getColumnWidth(i);
8179 return this.totalWidth;
8183 getColumnHeader : function(col){
8184 return this.config[col].header;
8188 setColumnHeader : function(col, header){
8189 this.config[col].header = header;
8190 this.onHeaderChange.fireDirect(this, col, header);
8194 getColumnTooltip : function(col){
8195 return this.config[col].tooltip;
8198 setColumnTooltip : function(col, header){
8199 this.config[col].tooltip = tooltip;
8203 getDataIndex : function(col){
8204 if(typeof this.config[col].dataIndex != 'number'){
8207 return this.config[col].dataIndex;
8211 setDataIndex : function(col, dataIndex){
8212 this.config[col].dataIndex = dataIndex;
8215 isCellEditable : function(colIndex, rowIndex){
8216 return this.config[colIndex].editable || (typeof this.config[colIndex].editable == 'undefined' && this.config[colIndex].editor);
8220 getCellEditor : function(colIndex, rowIndex){
8221 return this.config[colIndex].editor;
8225 setEditable : function(col, editable){
8226 this.config[col].editable = editable;
8231 isHidden : function(colIndex){
8232 return this.config[colIndex].hidden;
8237 isFixed : function(colIndex){
8238 return this.config[colIndex].fixed;
8242 isResizable : function(colIndex){
8243 return this.config[colIndex].resizable !== false;
8246 setHidden : function(colIndex, hidden){
8247 this.config[colIndex].hidden = hidden;
8248 this.totalWidth = null;
8249 this.fireHiddenChange(colIndex, hidden);
8253 setEditor : function(col, editor){
8254 this.config[col].editor = editor;
8259 YAHOO.ext.grid.DefaultColumnModel.sortTypes = {
8260 none : function(s) {
8264 asUCString : function(s) {
8265 return String(s).toUpperCase();
8268 asDate : function(s) {
8269 if(s instanceof Date){
8272 return Date.parse(String(s));
8275 asFloat : function(s) {
8276 var val = parseFloat(String(s).replace(/,/g, ''));
8277 if(isNaN(val)) val = 0;
8281 asInt : function(s) {
8282 var val = parseInt(String(s).replace(/,/g, ''));
8283 if(isNaN(val)) val = 0;
8288 YAHOO.ext.grid.DefaultColumnModel.defaultRenderer = function(value){
8289 if(typeof value == 'string' && value.length < 1){
8295 YAHOO.ext.grid.AbstractDataModel = function(){
8297 this.onCellUpdated = new YAHOO.util.CustomEvent('onCellUpdated');
8299 this.onTableDataChanged = new YAHOO.util.CustomEvent('onTableDataChanged');
8301 this.onRowsDeleted = new YAHOO.util.CustomEvent('onRowsDeleted');
8303 this.onRowsInserted = new YAHOO.util.CustomEvent('onRowsInserted');
8305 this.onRowsUpdated = new YAHOO.util.CustomEvent('onRowsUpdated');
8307 this.onRowsSorted = new YAHOO.util.CustomEvent('onRowsSorted');
8311 'cellupdated' : this.onCellUpdated,
8313 'datachanged' : this.onTableDataChanged,
8315 'rowsdeleted' : this.onRowsDeleted,
8317 'rowsinserted' : this.onRowsInserted,
8319 'rowsupdated' : this.onRowsUpdated,
8321 'rowssorted' : this.onRowsSorted
8325 YAHOO.ext.grid.AbstractDataModel.prototype = {
8327 fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent,
8328 on : YAHOO.ext.util.Observable.prototype.on,
8329 addListener : YAHOO.ext.util.Observable.prototype.addListener,
8330 delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener,
8331 removeListener : YAHOO.ext.util.Observable.prototype.removeListener,
8332 purgeListeners : YAHOO.ext.util.Observable.prototype.purgeListeners,
8333 bufferedListener : YAHOO.ext.util.Observable.prototype.bufferedListener,
8336 fireCellUpdated : function(row, col){
8337 this.onCellUpdated.fireDirect(this, row, col);
8341 fireTableDataChanged : function(){
8342 this.onTableDataChanged.fireDirect(this);
8346 fireRowsDeleted : function(firstRow, lastRow){
8347 this.onRowsDeleted.fireDirect(this, firstRow, lastRow);
8351 fireRowsInserted : function(firstRow, lastRow){
8352 this.onRowsInserted.fireDirect(this, firstRow, lastRow);
8356 fireRowsUpdated : function(firstRow, lastRow){
8357 this.onRowsUpdated.fireDirect(this, firstRow, lastRow);
8361 fireRowsSorted : function(sortColumnIndex, sortDir, noRefresh){
8362 this.onRowsSorted.fireDirect(this, sortColumnIndex, sortDir, noRefresh);
8366 sort : function(sortInfo, columnIndex, direction, suppressEvent){
8371 getSortState : function(){
8372 return {column: this.sortColumn, direction: this.sortDir};
8376 getRowCount : function(){
8381 getTotalRowCount : function(){
8382 return this.getRowCount();
8387 getRowId : function(rowIndex){
8392 getValueAt : function(rowIndex, colIndex){
8397 setValueAt : function(value, rowIndex, colIndex){
8401 isPaged : function(){
8407 YAHOO.ext.grid.DefaultDataModel = function(data){
8408 YAHOO.ext.grid.DefaultDataModel.superclass.constructor.call(this);
8412 YAHOO.extendX(YAHOO.ext.grid.DefaultDataModel, YAHOO.ext.grid.AbstractDataModel, {
8414 getRowCount : function(){
8415 return this.data.length;
8419 getRowId : function(rowIndex){
8420 return this.data[rowIndex][0];
8424 getRow : function(rowIndex){
8425 return this.data[rowIndex];
8429 getRows : function(indexes){
8430 var data = this.data;
8432 for(var i = 0; i < indexes.length; i++){
8433 r.push(data[indexes[i]]);
8439 getValueAt : function(rowIndex, colIndex){
8440 return this.data[rowIndex][colIndex];
8444 setValueAt: function(value, rowIndex, colIndex){
8445 this.data[rowIndex][colIndex] = value;
8446 this.fireCellUpdated(rowIndex, colIndex);
8450 removeRows: function(startIndex, endIndex){
8451 endIndex = endIndex || startIndex;
8452 this.data.splice(startIndex, endIndex-startIndex+1);
8453 this.fireRowsDeleted(startIndex, endIndex);
8457 removeRow: function(index){
8458 this.data.splice(index, 1);
8459 this.fireRowsDeleted(index, index);
8463 removeAll: function(){
8464 var count = this.getRowCount();
8466 this.removeRows(0, count-1);
8471 query: function(spec, returnUnmatched){
8474 for(var i = 0; i < d.length; i++){
8477 for(var col in spec){
8479 if(!isMatch) continue;
8480 var filter = spec[col];
8481 switch(typeof filter){
8485 if(row[col] != filter){
8490 if(!filter(row[col], row)){
8495 if(filter instanceof RegExp){
8496 if(String(row[col]).search(filter) === -1){
8504 if(isMatch && !returnUnmatched){
8506 }else if(!isMatch && returnUnmatched){
8514 filter: function(query){
8515 var matches = this.query(query, true);
8516 var data = this.data;
8519 for(var i = 0; i < matches.length; i++){
8520 data[matches[i]]._deleted = true;
8522 for(var i = 0; i < data.length; i++){
8523 while(data[i] && data[i]._deleted === true){
8527 return matches.length;
8531 addRow: function(cellValues){
8532 this.data.push(cellValues);
8533 var newIndex = this.data.length-1;
8534 this.fireRowsInserted(newIndex, newIndex);
8540 addRows: function(rowData){
8541 this.data = this.data.concat(rowData);
8542 var firstIndex = this.data.length-rowData.length;
8543 this.fireRowsInserted(firstIndex, firstIndex+rowData.length-1);
8548 insertRow: function(index, cellValues){
8549 this.data.splice(index, 0, cellValues);
8550 this.fireRowsInserted(index, index);
8556 insertRows: function(index, rowData){
8558 var args = rowData.concat();
8559 args.splice(0, 0, index, 0);
8560 this.data.splice.apply(this.data, args);
8561 this.fireRowsInserted(index, index+rowData.length-1);
8566 applySort: function(suppressEvent){
8567 if(typeof this.sortColumn != 'undefined'){
8568 this.sort(this.sortInfo, this.sortColumn, this.sortDir, suppressEvent);
8573 setDefaultSort: function(sortInfo, columnIndex, direction){
8574 this.sortInfo = sortInfo;
8575 this.sortColumn = columnIndex;
8576 this.sortDir = direction;
8579 sort: function(sortInfo, columnIndex, direction, suppressEvent){
8581 this.sortInfo = sortInfo;
8582 this.sortColumn = columnIndex;
8583 this.sortDir = direction;
8585 var dsc = (direction && direction.toUpperCase() == 'DESC');
8586 var sortType = null;
8587 if(sortInfo != null){
8588 if(typeof sortInfo == 'function'){
8589 sortType = sortInfo;
8590 }else if(typeof sortInfo == 'object'){
8591 sortType = sortInfo.getSortType(columnIndex);;
8594 var fn = function(cells, cells2){
8595 var v1 = sortType ? sortType(cells[columnIndex], cells) : cells[columnIndex];
8596 var v2 = sortType ? sortType(cells2[columnIndex], cells2) : cells2[columnIndex];
8598 return dsc ? +1 : -1;
8600 return dsc ? -1 : +1;
8605 this.fireRowsSorted(columnIndex, direction);
8610 each: function(fn, scope){
8612 for(var i = 0, len = d.length; i < len; i++){
8613 if(fn.call(scope || window, d[i], i) === false) break;
8619 if(YAHOO.ext.grid.DefaultColumnModel){
8620 YAHOO.ext.grid.DefaultDataModel.sortTypes = YAHOO.ext.grid.DefaultColumnModel.sortTypes;
8623 YAHOO.ext.grid.LoadableDataModel = function(dataType){
8624 YAHOO.ext.grid.LoadableDataModel.superclass.constructor.call(this, []);
8627 this.onLoad = new YAHOO.util.CustomEvent('load');
8629 this.onLoadException = new YAHOO.util.CustomEvent('loadException');
8631 this.events['load'] = this.onLoad;
8633 this.events['beforeload'] = new YAHOO.util.CustomEvent('beforeload');
8635 this.events['loadexception'] = this.onLoadException;
8638 this.dataType = dataType;
8640 this.preprocessors = [];
8642 this.postprocessors = [];
8646 this.loadedPage = 1;
8648 this.remoteSort = false;
8652 this.pageUrl = null;
8654 this.baseParams = {};
8656 this.paramMap = {'page':'page', 'pageSize':'pageSize', 'sortColumn':'sortColumn', 'sortDir':'sortDir'};
8659 YAHOO.extendX(YAHOO.ext.grid.LoadableDataModel, YAHOO.ext.grid.DefaultDataModel, {
8662 setLoadedPage: function(pageNum, userCallback){
8663 this.loadedPage = pageNum;
8664 if(typeof userCallback == 'function'){
8670 isPaged: function(){
8671 return this.pageSize > 0;
8675 getTotalRowCount: function(){
8676 return this.totalCount || this.getRowCount();
8680 getPageSize: function(){
8681 return this.pageSize;
8685 getTotalPages: function(){
8686 if(this.getPageSize() == 0 || this.getTotalRowCount() == 0){
8689 return Math.ceil(this.getTotalRowCount()/this.getPageSize());
8693 initPaging: function(url, pageSize, baseParams){
8695 this.pageSize = pageSize;
8696 this.remoteSort = true;
8697 if(baseParams) this.baseParams = baseParams;
8701 createParams: function(pageNum, sortColumn, sortDir){
8702 var params = {}, map = this.paramMap;
8703 for(var key in this.baseParams){
8704 if(typeof this.baseParams[key] != 'function'){
8705 params[key] = this.baseParams[key];
8708 params[map['page']] = pageNum;
8709 params[map['pageSize']] = this.getPageSize();
8710 params[map['sortColumn']] = (typeof sortColumn == 'undefined' ? '' : sortColumn);
8711 params[map['sortDir']] = sortDir || '';
8716 loadPage: function(pageNum, callback, keepExisting){
8717 var sort = this.getSortState();
8718 var params = this.createParams(pageNum, sort.column, sort.direction);
8719 this.load(this.pageUrl, params, this.setLoadedPage.createDelegate(this, [pageNum, callback]),
8720 keepExisting ? (pageNum-1) * this.pageSize : null);
8724 applySort: function(suppressEvent){
8725 if(!this.remoteSort){
8726 YAHOO.ext.grid.LoadableDataModel.superclass.applySort.apply(this, arguments);
8727 }else if(!suppressEvent){
8728 var sort = this.getSortState();
8730 this.fireRowsSorted(sort.column, sort.direction, true);
8736 resetPaging: function(){
8737 this.loadedPage = 1;
8741 sort: function(sortInfo, columnIndex, direction, suppressEvent){
8742 if(!this.remoteSort){
8743 YAHOO.ext.grid.LoadableDataModel.superclass.sort.apply(this, arguments);
8745 this.sortInfo = sortInfo;
8746 this.sortColumn = columnIndex;
8747 this.sortDir = direction;
8748 var params = this.createParams(this.loadedPage, columnIndex, direction);
8749 this.load(this.pageUrl, params, this.fireRowsSorted.createDelegate(this, [columnIndex, direction, true]));
8754 load: function(url, params, callback, insertIndex){
8755 this.fireEvent('beforeload', this);
8756 if(params && typeof params != 'string'){
8758 for(var key in params){
8759 if(typeof params[key] != 'function'){
8760 buf.push(encodeURIComponent(key), '=', encodeURIComponent(params[key]), '&');
8763 delete buf[buf.length-1];
8764 params = buf.join('');
8767 success: this.processResponse,
8768 failure: this.processException,
8770 argument: {callback: callback, insertIndex: insertIndex}
8772 var method = params ? 'POST' : 'GET';
8773 this.transId = YAHOO.util.Connect.asyncRequest(method, url, cb, params);
8777 processResponse: function(response){
8778 var cb = response.argument.callback;
8779 var keepExisting = (typeof response.argument.insertIndex == 'number');
8780 var insertIndex = response.argument.insertIndex;
8781 switch(this.dataType){
8782 case YAHOO.ext.grid.LoadableDataModel.XML:
8783 this.loadData(response.responseXML, cb, keepExisting, insertIndex);
8785 case YAHOO.ext.grid.LoadableDataModel.JSON:
8786 var rtext = response.responseText;
8789 while(rtext.substring(0,1) == " ") {
8790 rtext = rtext.substring(1, rtext.length);
8793 if(rtext.indexOf("{") < 0) {
8794 throw "Invalid JSON response";
8798 if(rtext.indexOf("{}") === 0) {
8799 this.loadData({}, response.argument.callback);
8805 var jsonObjRaw = eval("(" + rtext + ")");
8807 throw "Error evaling JSON response";
8809 this.loadData(jsonObjRaw, cb, keepExisting, insertIndex);
8811 this.fireLoadException(e, response);
8812 if(typeof cb == 'function'){
8817 case YAHOO.ext.grid.LoadableDataModel.TEXT:
8818 this.loadData(response.responseText, cb, keepExisting, insertIndex);
8824 processException: function(response){
8825 this.fireLoadException(null, response);
8826 if(typeof response.argument.callback == 'function'){
8827 response.argument.callback(this, false);
8831 fireLoadException: function(e, responseObj){
8832 this.onLoadException.fireDirect(this, e, responseObj);
8835 fireLoadEvent: function(){
8836 this.fireEvent('load', this.loadedPage, this.getTotalPages());
8840 addPreprocessor: function(columnIndex, fn){
8841 this.preprocessors[columnIndex] = fn;
8845 getPreprocessor: function(columnIndex){
8846 return this.preprocessors[columnIndex];
8850 removePreprocessor: function(columnIndex){
8851 this.preprocessors[columnIndex] = null;
8855 addPostprocessor: function(columnIndex, fn){
8856 this.postprocessors[columnIndex] = fn;
8860 getPostprocessor: function(columnIndex){
8861 return this.postprocessors[columnIndex];
8865 removePostprocessor: function(columnIndex){
8866 this.postprocessors[columnIndex] = null;
8869 loadData: function(data, callback, keepExisting, insertIndex){
8874 YAHOO.ext.grid.LoadableDataModel.XML = 'xml';
8875 YAHOO.ext.grid.LoadableDataModel.JSON = 'json';
8876 YAHOO.ext.grid.LoadableDataModel.TEXT = 'text';
8884 YAHOO.ext.grid.XMLDataModel = function(schema, xml){
8885 YAHOO.ext.grid.XMLDataModel.superclass.constructor.call(this, YAHOO.ext.grid.LoadableDataModel.XML);
8887 this.schema = schema;
8894 YAHOO.extendX(YAHOO.ext.grid.XMLDataModel, YAHOO.ext.grid.LoadableDataModel, {
8896 getDocument: function(){
8901 loadData: function(doc, callback, keepExisting, insertIndex){
8904 var idField = this.schema.id;
8905 var fields = this.schema.fields;
8906 if(this.schema.totalTag){
8907 this.totalCount = null;
8908 var totalNode = doc.getElementsByTagName(this.schema.totalTag);
8909 if(totalNode && totalNode.item(0) && totalNode.item(0).firstChild) {
8910 var v = parseInt(totalNode.item(0).firstChild.nodeValue, 10);
8912 this.totalCount = v;
8917 var nodes = doc.getElementsByTagName(this.schema.tagName);
8918 if(nodes && nodes.length > 0) {
8919 for(var i = 0; i < nodes.length; i++) {
8920 var node = nodes.item(i);
8922 colData.node = node;
8923 colData.id = this.getNamedValue(node, idField, String(++this.idSeed));
8924 for(var j = 0; j < fields.length; j++) {
8925 var val = this.getNamedValue(node, fields[j], "");
8926 if(this.preprocessors[j]){
8927 val = this.preprocessors[j](val);
8931 rowData.push(colData);
8934 if(keepExisting !== true){
8935 YAHOO.ext.grid.XMLDataModel.superclass.removeAll.call(this);
8937 if(typeof insertIndex != 'number'){
8938 insertIndex = this.getRowCount();
8940 YAHOO.ext.grid.XMLDataModel.superclass.insertRows.call(this, insertIndex, rowData);
8941 if(typeof callback == 'function'){
8942 callback(this, true);
8944 this.fireLoadEvent();
8948 addRow: function(id, cellValues){
8949 var node = this.createNode(this.xml, id, cellValues);
8950 cellValues.id = id || ++this.idSeed;
8951 cellValues.node = node;
8952 return YAHOO.ext.grid.XMLDataModel.superclass.addRow.call(this, cellValues);
8956 insertRow: function(index, id, cellValues){
8957 var node = this.createNode(this.xml, id, cellValues);
8958 cellValues.id = id || ++this.idSeed;
8959 cellValues.node = node;
8960 return YAHOO.ext.grid.XMLDataModel.superclass.insertRow.call(this, index, cellValues);
8964 removeRow: function(index){
8965 var node = this.data[index].node;
8966 node.parentNode.removeChild(node);
8967 YAHOO.ext.grid.XMLDataModel.superclass.removeRow.call(this, index, index);
8970 getNode: function(rowIndex){
8971 return this.data[rowIndex].node;
8975 createNode: function(xmlDoc, id, colData){
8976 var template = this.data[0].node;
8977 var newNode = template.cloneNode(true);
8978 var fields = this.schema.fields;
8979 for(var i = 0, len = fields.length; i < len; i++){
8980 var nodeValue = colData[i];
8981 if(this.postprocessors[i]){
8982 nodeValue = this.postprocessors[i](nodeValue);
8984 this.setNamedValue(newNode, fields[i], nodeValue);
8987 this.setNamedValue(newNode, this.schema.idField, id);
8989 template.parentNode.appendChild(newNode);
8994 getNamedValue: function(node, name, defaultValue){
8996 return defaultValue;
8998 var nodeValue = defaultValue;
8999 var attrNode = node.attributes.getNamedItem(name);
9001 nodeValue = attrNode.value;
9003 var childNode = node.getElementsByTagName(name);
9004 if(childNode && childNode.item(0) && childNode.item(0).firstChild) {
9005 nodeValue = childNode.item(0).firstChild.nodeValue;
9008 var index = name.indexOf(':');
9010 return this.getNamedValue(node, name.substr(index+1), defaultValue);
9018 setNamedValue: function(node, name, value){
9022 var attrNode = node.attributes.getNamedItem(name);
9024 attrNode.value = value;
9027 var childNode = node.getElementsByTagName(name);
9028 if(childNode && childNode.item(0) && childNode.item(0).firstChild) {
9029 childNode.item(0).firstChild.nodeValue = value;
9032 var index = name.indexOf(':');
9034 this.setNamedValue(node, name.substr(index+1), value);
9040 setValueAt: function(value, rowIndex, colIndex){
9041 var node = this.data[rowIndex].node;
9043 var nodeValue = value;
9044 if(this.postprocessors[colIndex]){
9045 nodeValue = this.postprocessors[colIndex](value);
9047 this.setNamedValue(node, this.schema.fields[colIndex], nodeValue);
9049 YAHOO.ext.grid.XMLDataModel.superclass.setValueAt.call(this, value, rowIndex, colIndex);
9053 getRowId: function(rowIndex){
9054 return this.data[rowIndex].id;
9057 addRows : function(rowData){
9058 for(var j = 0, len = rowData.length; j < len; j++){
9059 var cellValues = rowData[j];
9060 var id = ++this.idSeed;
9061 var node = this.createNode(this.xml, id, cellValues);
9062 cellValues.node=node;
9063 cellValues.id = cellValues.id || id;
9064 YAHOO.ext.grid.XMLDataModel.superclass.addRow.call(this,cellValues);
9068 insertRows : function(index, rowData){
9070 rowData = rowData.slice(0).reverse();
9071 for(var j = 0, len = rowData.length; j < len; j++){
9072 var cellValues = rowData[j];
9073 var id = ++this.idSeed;
9074 var node = this.createNode(this.xml, id, cellValues);
9075 cellValues.id = cellValues.id || id;
9076 cellValues.node = node;
9077 YAHOO.ext.grid.XMLDataModel.superclass.insertRow.call(this, index, cellValues);
9082 YAHOO.ext.grid.XMLQueryDataModel = function(){
9083 YAHOO.ext.grid.XMLQueryDataModel.superclass.constructor.apply(this, arguments);
9085 YAHOO.extendX(YAHOO.ext.grid.XMLQueryDataModel, YAHOO.ext.grid.XMLDataModel, {
9086 getNamedValue: function(node, name, defaultValue){
9088 return defaultValue;
9090 var nodeValue = defaultValue;
9091 var childNode = cssQuery(name, node);
9092 if(childNode && childNode[0]) {
9093 nodeValue = childNode[0].firstChild.nodeValue;
9100 YAHOO.ext.grid.JSONDataModel = function(schema){
9101 YAHOO.ext.grid.JSONDataModel.superclass.constructor.call(this, YAHOO.ext.grid.LoadableDataModel.JSON);
9103 this.schema = schema;
9105 YAHOO.extendX(YAHOO.ext.grid.JSONDataModel, YAHOO.ext.grid.LoadableDataModel, {
9107 loadData : function(data, callback, keepExisting){
9108 var idField = this.schema.id;
9109 var fields = this.schema.fields;
9111 if(this.schema.totalProperty){
9112 var v = parseInt(eval('data.' + this.schema.totalProperty), 10);
9114 this.totalCount = v;
9118 var root = eval('data.' + this.schema.root);
9119 for(var i = 0; i < root.length; i++){
9122 colData.node = node;
9123 colData.id = (typeof node[idField] != 'undefined' && node[idField] !== '' ? node[idField] : String(i));
9124 for(var j = 0; j < fields.length; j++) {
9125 var val = node[fields[j]];
9126 if(typeof val == 'undefined'){
9129 if(this.preprocessors[j]){
9130 val = this.preprocessors[j](val);
9134 rowData.push(colData);
9136 if(keepExisting !== true){
9139 this.addRows(rowData);
9140 if(typeof callback == 'function'){
9141 callback(this, true);
9143 this.fireLoadEvent();
9145 this.fireLoadException(e, null);
9146 if(typeof callback == 'function'){
9147 callback(this, false);
9153 getRowId : function(rowIndex){
9154 return this.data[rowIndex].id;
9158 YAHOO.ext.grid.DefaultSelectionModel = function(){
9159 this.selectedRows = [];
9160 this.selectedRowIds = [];
9161 this.lastSelectedRow = null;
9163 this.onRowSelect = new YAHOO.util.CustomEvent('SelectionTable.rowSelected');
9164 this.onSelectionChange = new YAHOO.util.CustomEvent('SelectionTable.selectionChanged');
9168 'selectionchange' : this.onSelectionChange,
9170 'rowselect' : this.onRowSelect
9173 this.locked = false;
9176 YAHOO.ext.grid.DefaultSelectionModel.prototype = {
9178 init : function(grid){
9189 unlock : function(){
9190 this.locked = false;
9194 isLocked : function(){
9199 initEvents : function(){
9200 if(this.grid.trackMouseOver){
9201 this.grid.addListener("mouseover", this.handleOver, this, true);
9202 this.grid.addListener("mouseout", this.handleOut, this, true);
9204 this.grid.addListener("rowclick", this.rowClick, this, true);
9205 this.grid.addListener("keydown", this.keyDown, this, true);
9208 fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent,
9209 on : YAHOO.ext.util.Observable.prototype.on,
9210 addListener : YAHOO.ext.util.Observable.prototype.addListener,
9211 delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener,
9212 removeListener : YAHOO.ext.util.Observable.prototype.removeListener,
9213 purgeListeners : YAHOO.ext.util.Observable.prototype.purgeListeners,
9214 bufferedListener : YAHOO.ext.util.Observable.prototype.bufferedListener,
9217 syncSelectionsToIds : function(){
9218 if(this.getCount() > 0){
9219 var ids = this.selectedRowIds.concat();
9220 this.clearSelections();
9221 this.selectRowsById(ids, true);
9226 selectRowsById : function(id, keepExisting){
9227 var rows = this.grid.getRowsById(id);
9228 if (!(rows instanceof Array)){
9229 this.selectRow(rows, keepExisting);
9232 this.selectRows(rows, keepExisting);
9236 getCount : function(){
9237 return this.selectedRows.length;
9241 selectFirstRow : function(){
9242 for(var j = 0; j < this.grid.rows.length; j++){
9243 if(this.isSelectable(this.grid.rows[j])){
9244 this.focusRow(this.grid.rows[j]);
9245 this.setRowState(this.grid.rows[j], true);
9252 selectNext : function(keepExisting){
9253 if(this.lastSelectedRow){
9254 for(var j = (this.lastSelectedRow.rowIndex+1); j < this.grid.rows.length; j++){
9255 var row = this.grid.rows[j];
9256 if(this.isSelectable(row)){
9258 this.setRowState(row, true, keepExisting);
9266 selectPrevious : function(keepExisting){
9267 if(this.lastSelectedRow){
9268 for(var j = (this.lastSelectedRow.rowIndex-1); j >= 0; j--){
9269 var row = this.grid.rows[j];
9270 if(this.isSelectable(row)){
9272 this.setRowState(row, true, keepExisting);
9280 getSelectedRows : function(){
9281 return this.selectedRows;
9285 getSelectedRowIds : function(){
9286 return this.selectedRowIds;
9290 clearSelections : function(){
9291 if(this.isLocked()) return;
9292 var oldSelections = this.selectedRows.concat();
9293 for(var j = 0; j < oldSelections.length; j++){
9294 this.setRowState(oldSelections[j], false);
9296 this.selectedRows = [];
9297 this.selectedRowIds = [];
9302 selectAll : function(){
9303 if(this.isLocked()) return;
9304 this.selectedRows = [];
9305 this.selectedRowIds = [];
9306 for(var j = 0, len = this.grid.rows.length; j < len; j++){
9307 this.setRowState(this.grid.rows[j], true, true);
9312 hasSelection : function(){
9313 return this.selectedRows.length > 0;
9317 isSelected : function(row){
9318 return row && (row.selected === true || row.getAttribute('selected') == 'true');
9322 isSelectable : function(row){
9323 return row && row.getAttribute('selectable') != 'false';
9327 rowClick : function(grid, rowIndex, e){
9328 if(this.isLocked()) return;
9329 var row = grid.getRow(rowIndex);
9330 if(this.isSelectable(row)){
9331 if(e.shiftKey && this.lastSelectedRow){
9332 var lastIndex = this.lastSelectedRow.rowIndex;
9333 this.selectRange(this.lastSelectedRow, row, e.ctrlKey);
9334 this.lastSelectedRow = this.grid.el.dom.rows[lastIndex];
9337 var rowState = e.ctrlKey ? !this.isSelected(row) : true;
9338 this.setRowState(row, rowState, e.hasModifier());
9344 focusRow : function(row){
9345 this.grid.view.focusRow(row);
9349 selectRow : function(row, keepExisting){
9350 this.setRowState(this.getRow(row), true, keepExisting);
9354 selectRows : function(rows, keepExisting){
9356 this.clearSelections();
9358 for(var i = 0; i < rows.length; i++){
9359 this.selectRow(rows[i], true);
9364 deselectRow : function(row){
9365 this.setRowState(this.getRow(row), false);
9369 getRow : function(row){
9370 if(typeof row == 'number'){
9371 row = this.grid.rows[row];
9377 selectRange : function(startRow, endRow, keepExisting){
9378 startRow = this.getRow(startRow);
9379 endRow = this.getRow(endRow);
9380 this.setRangeState(startRow, endRow, true, keepExisting);
9384 deselectRange : function(startRow, endRow){
9385 startRow = this.getRow(startRow);
9386 endRow = this.getRow(endRow);
9387 this.setRangeState(startRow, endRow, false, true);
9391 setRowStateFromChild : function(childEl, selected, keepExisting){
9392 var row = this.grid.getRowFromChild(childEl);
9393 this.setRowState(row, selected, keepExisting);
9397 setRangeState : function(startRow, endRow, selected, keepExisting){
9398 if(this.isLocked()) return;
9400 this.clearSelections();
9402 var curRow = startRow;
9403 while(curRow.rowIndex != endRow.rowIndex){
9404 this.setRowState(curRow, selected, true);
9405 curRow = (startRow.rowIndex < endRow.rowIndex ?
9406 this.grid.getRowAfter(curRow) : this.grid.getRowBefore(curRow))
9408 this.setRowState(endRow, selected, true);
9412 setRowState : function(row, selected, keepExisting){
9413 if(this.isLocked()) return;
9414 if(this.isSelectable(row)){
9417 this.clearSelections();
9419 this.setRowClass(row, 'selected');
9420 row.selected = true;
9421 this.selectedRows.push(row);
9422 this.selectedRowIds.push(this.grid.dataModel.getRowId(row.rowIndex));
9423 this.lastSelectedRow = row;
9425 this.setRowClass(row, '');
9426 row.selected = false;
9427 this._removeSelected(row);
9429 this.fireEvent('rowselect', this, row, selected);
9430 this.fireEvent('selectionchange', this, this.selectedRows, this.selectedRowIds);
9435 handleOver : function(e){
9436 var row = this.grid.getRowFromChild(e.getTarget());
9437 if(this.isSelectable(row) && !this.isSelected(row)){
9438 this.setRowClass(row, 'over');
9443 handleOut : function(e){
9444 var row = this.grid.getRowFromChild(e.getTarget());
9445 if(this.isSelectable(row) && !this.isSelected(row)){
9446 this.setRowClass(row, '');
9451 keyDown : function(e){
9452 if(e.browserEvent.keyCode == e.DOWN){
9453 this.selectNext(e.shiftKey);
9455 }else if(e.browserEvent.keyCode == e.UP){
9456 this.selectPrevious(e.shiftKey);
9462 setRowClass : function(row, cssClass){
9463 if(this.isSelectable(row)){
9464 if(cssClass == 'selected'){
9465 YAHOO.util.Dom.removeClass(row, 'ygrid-row-over');
9466 YAHOO.util.Dom.addClass(row, 'ygrid-row-selected');
9467 }else if(cssClass == 'over'){
9468 YAHOO.util.Dom.removeClass(row, 'ygrid-row-selected');
9469 YAHOO.util.Dom.addClass(row, 'ygrid-row-over');
9470 }else if(cssClass == ''){
9471 YAHOO.util.Dom.removeClass(row, 'ygrid-row-selected');
9472 YAHOO.util.Dom.removeClass(row, 'ygrid-row-over');
9478 _removeSelected : function(row){
9479 var sr = this.selectedRows;
9480 for (var i = 0; i < sr.length; i++) {
9482 this.selectedRows.splice(i, 1);
9483 this.selectedRowIds.splice(i, 1);
9491 YAHOO.ext.grid.SingleSelectionModel = function(){
9492 YAHOO.ext.grid.SingleSelectionModel.superclass.constructor.call(this);
9495 YAHOO.extendX(YAHOO.ext.grid.SingleSelectionModel, YAHOO.ext.grid.DefaultSelectionModel);
9498 YAHOO.ext.grid.SingleSelectionModel.prototype.setRowState = function(row, selected){
9499 YAHOO.ext.grid.SingleSelectionModel.superclass.setRowState.call(this, row, selected, false);
9502 YAHOO.ext.grid.DisableSelectionModel = function(){
9503 YAHOO.ext.grid.DisableSelectionModel.superclass.constructor.call(this);
9506 YAHOO.extendX(YAHOO.ext.grid.DisableSelectionModel, YAHOO.ext.grid.DefaultSelectionModel);
9508 YAHOO.ext.grid.DisableSelectionModel.prototype.initEvents = function(){
9512 YAHOO.ext.grid.EditorSelectionModel = function(){
9513 YAHOO.ext.grid.EditorSelectionModel.superclass.constructor.call(this);
9515 this.clicksToActivateCell = 1;
9516 this.events['cellactivate'] = new YAHOO.util.CustomEvent('cellactivate');
9519 YAHOO.extendX(YAHOO.ext.grid.EditorSelectionModel, YAHOO.ext.grid.DefaultSelectionModel);
9521 YAHOO.ext.grid.EditorSelectionModel.prototype.disableArrowNavigation = false;
9522 YAHOO.ext.grid.EditorSelectionModel.prototype.controlForArrowNavigation = false;
9525 YAHOO.ext.grid.EditorSelectionModel.prototype.initEvents = function(){
9526 this.grid.addListener("cellclick", this.onCellClick, this, true);
9527 this.grid.addListener("celldblclick", this.onCellDblClick, this, true);
9528 this.grid.addListener("keydown", this.keyDown, this, true);
9531 YAHOO.ext.grid.EditorSelectionModel.prototype.onCellClick = function(grid, rowIndex, colIndex){
9532 if(this.clicksToActivateCell == 1){
9533 var row = this.grid.getRow(rowIndex);
9534 var cell = row.childNodes[colIndex];
9536 this.activate(row, cell);
9541 YAHOO.ext.grid.EditorSelectionModel.prototype.activate = function(row, cell){
9542 this.fireEvent('cellactivate', this, row, cell);
9543 this.grid.doEdit(row, cell);
9546 YAHOO.ext.grid.EditorSelectionModel.prototype.onCellDblClick = function(grid, rowIndex, colIndex){
9547 if(this.clicksToActivateCell == 2){
9548 var row = this.grid.getRow(rowIndex);
9549 var cell = row.childNodes[colIndex];
9551 this.activate(row, cell);
9557 YAHOO.ext.grid.EditorSelectionModel.prototype.setRowState = function(row, selected){
9558 YAHOO.ext.grid.EditorSelectionModel.superclass.setRowState.call(this, row, false, false);
9561 YAHOO.ext.grid.EditorSelectionModel.prototype.focusRow = function(row, selected){
9564 YAHOO.ext.grid.EditorSelectionModel.prototype.getEditorCellAfter = function(cell, spanRows){
9566 var next = g.getCellAfter(cell);
9567 while(next && !g.colModel.isCellEditable(next.columnIndex)){
9568 next = g.getCellAfter(next);
9570 if(!next && spanRows){
9571 var row = g.getRowAfter(g.getRowFromChild(cell));
9573 next = g.getFirstCell(row);
9574 if(!g.colModel.isCellEditable(next.columnIndex)){
9575 next = this.getEditorCellAfter(next);
9582 YAHOO.ext.grid.EditorSelectionModel.prototype.getEditorCellBefore = function(cell, spanRows){
9584 var prev = g.getCellBefore(cell);
9585 while(prev && !g.colModel.isCellEditable(prev.columnIndex)){
9586 prev = g.getCellBefore(prev);
9588 if(!prev && spanRows){
9589 var row = g.getRowBefore(g.getRowFromChild(cell));
9591 prev = g.getLastCell(row);
9592 if(!g.colModel.isCellEditable(prev.columnIndex)){
9593 prev = this.getEditorCellBefore(prev);
9600 YAHOO.ext.grid.EditorSelectionModel.prototype.allowArrowNav = function(e){
9601 return (!this.disableArrowNavigation && (!this.controlForArrowNavigation || e.ctrlKey));
9604 YAHOO.ext.grid.EditorSelectionModel.prototype.keyDown = function(e){
9605 var g = this.grid, cm = g.colModel, cell = g.getEditingCell();
9608 switch(e.browserEvent.keyCode){
9611 newCell = this.getEditorCellBefore(cell, true);
9613 newCell = this.getEditorCellAfter(cell, true);
9618 if(this.allowArrowNav(e)){
9619 var next = g.getRowAfter(g.getRowFromChild(cell));
9621 newCell = next.childNodes[cell.columnIndex];
9626 if(this.allowArrowNav(e)){
9627 var prev = g.getRowBefore(g.getRowFromChild(cell));
9629 newCell = prev.childNodes[cell.columnIndex];
9635 var prev = g.getRowBefore(g.getRowFromChild(cell));
9637 newCell = prev.childNodes[cell.columnIndex];
9640 var next = g.getRowAfter(g.getRowFromChild(cell));
9642 newCell = next.childNodes[cell.columnIndex];
9647 if(this.allowArrowNav(e)){
9648 newCell = this.getEditorCellAfter(cell);
9652 if(this.allowArrowNav(e)){
9653 newCell = this.getEditorCellBefore(cell);
9658 this.activate(g.getRowFromChild(newCell), newCell);
9664 YAHOO.ext.grid.EditorAndSelectionModel = function(){
9665 YAHOO.ext.grid.EditorAndSelectionModel.superclass.constructor.call(this);
9666 this.events['cellactivate'] = new YAHOO.util.CustomEvent('cellactivate');
9669 YAHOO.extendX(YAHOO.ext.grid.EditorAndSelectionModel, YAHOO.ext.grid.DefaultSelectionModel);
9671 YAHOO.ext.grid.EditorAndSelectionModel.prototype.initEvents = function(){
9672 YAHOO.ext.grid.EditorAndSelectionModel.superclass.initEvents.call(this);
9673 this.grid.addListener("celldblclick", this.onCellDblClick, this, true);
9676 YAHOO.ext.grid.EditorAndSelectionModel.prototype.onCellDblClick = function(grid, rowIndex, colIndex){
9677 var row = this.grid.getRow(rowIndex);
9678 var cell = row.childNodes[colIndex];
9680 this.fireEvent('cellactivate', this, row, cell);
9681 this.grid.doEdit(row, cell);
9685 YAHOO.ext.grid.CellEditor = function(element){
9686 this.colIndex = null;
9687 this.rowIndex = null;
9689 this.editing = false;
9690 this.originalValue = null;
9691 this.element = getEl(element, true);
9692 this.element.addClass('ygrid-editor');
9693 this.element.dom.tabIndex = 1;
9694 this.initialized = false;
9695 this.callback = null;
9698 YAHOO.ext.grid.CellEditor.prototype = {
9699 init : function(grid, bodyElement, callback){
9703 if(this.initialized) return;
9704 this.initialized = true;
9705 this.callback = callback;
9707 bodyElement.appendChild(this.element.dom);
9711 initEvents : function(){
9712 var stopOnEnter = function(e){
9713 if(e.browserEvent.keyCode == e.RETURN){
9714 this.stopEditing(true);
9715 }else if(e.browserEvent.keyCode == e.ESC){
9716 this.setValue(this.originalValue);
9717 this.stopEditing(true);
9720 this.element.mon('keydown', stopOnEnter, this, true);
9721 this.element.on('blur', this.stopEditing, this, true);
9724 startEditing : function(value, row, cell){
9725 this.originalValue = value;
9726 this.rowIndex = row.rowIndex;
9727 this.colIndex = cell.columnIndex;
9729 this.setValue(value);
9730 var cellbox = getEl(cell, true).getBox();
9731 this.fitToCell(cellbox);
9732 this.editing = true;
9736 stopEditing : function(focusCell){
9738 this.editing = false;
9739 var newValue = this.getValue();
9742 if(this.originalValue != newValue){
9743 this.callback(newValue, this.rowIndex, this.colIndex);
9748 setValue : function(value){
9749 this.element.dom.value = value;
9752 getValue : function(){
9753 return this.element.dom.value;
9756 fitToCell : function(box){
9757 this.element.setBox(box, true);
9761 this.element.show();
9762 this.element.focus();
9767 this.element.dom.blur();
9769 this.element.hide();
9773 YAHOO.ext.grid.CheckboxEditor = function(){
9774 var div = document.createElement('span');
9775 div.className = 'ygrid-editor ygrid-checkbox-editor';
9776 var cb = document.createElement('input');
9777 cb.type = 'checkbox';
9778 cb.setAttribute('autocomplete', 'off');
9779 div.appendChild(cb);
9780 document.body.appendChild(div);
9781 YAHOO.ext.grid.CheckboxEditor.superclass.constructor.call(this, div);
9784 this.cb = getEl(cb, true);
9787 YAHOO.extendX(YAHOO.ext.grid.CheckboxEditor, YAHOO.ext.grid.CellEditor);
9789 YAHOO.ext.grid.CheckboxEditor.prototype.fitToCell = function(box){
9790 this.element.setBox(box, true);
9793 YAHOO.ext.grid.CheckboxEditor.prototype.setValue = function(value){
9794 this.cb.dom.checked = (value === true || value === 'true' || value === 1 || value === '1');
9797 YAHOO.ext.grid.CheckboxEditor.prototype.getValue = function(){
9798 return this.cb.dom.checked;
9801 YAHOO.ext.grid.CheckboxEditor.prototype.show = function(){
9802 this.element.show();
9806 YAHOO.ext.grid.CheckboxEditor.prototype.initEvents = function(){
9807 var stopOnEnter = function(e){
9808 if(e.browserEvent.keyCode == e.RETURN){
9809 this.stopEditing(true);
9810 }else if(e.browserEvent.keyCode == e.ESC){
9811 this.setValue(this.originalValue);
9812 this.stopEditing(true);
9815 this.cb.mon('keydown', stopOnEnter, this, true);
9816 this.cb.on('blur', this.stopEditing, this, true);
9819 YAHOO.ext.grid.CheckboxEditor.prototype.hide = function(){
9823 this.element.hide();
9826 YAHOO.ext.grid.DateEditor = function(config){
9827 var div = document.createElement('span');
9828 div.className = 'ygrid-editor ygrid-editor-container';
9830 var element = document.createElement('input');
9831 element.type = 'text';
9832 element.tabIndex = 1;
9833 element.setAttribute('autocomplete', 'off');
9834 div.appendChild(element);
9836 var pick = document.createElement('span');
9837 pick.className = 'pick-button';
9838 div.appendChild(pick);
9840 document.body.appendChild(div);
9842 this.div = getEl(div, true);
9843 this.element = getEl(element, true);
9844 this.pick = getEl(pick, true);
9846 this.colIndex = null;
9847 this.rowIndex = null;
9849 this.editing = false;
9850 this.originalValue = null;
9851 this.initialized = false;
9852 this.callback = null;
9855 this.mouseDownHandler = YAHOO.ext.EventManager.wrap(this.handleMouseDown, this, true);
9857 YAHOO.ext.util.Config.apply(this, config);
9858 if(typeof this.minValue == 'string') this.minValue = this.parseDate(this.minValue);
9859 if(typeof this.maxValue == 'string') this.maxValue = this.parseDate(this.maxValue);
9860 this.ddMatch = /ddnone/;
9861 if(this.disabledDates){
9862 var dd = this.disabledDates;
9864 for(var i = 0; i < dd.length; i++){
9866 if(i != dd.length-1) re += "|";
9868 this.ddMatch = new RegExp(re + ")");
9872 YAHOO.ext.grid.DateEditor.prototype = {
9873 init : function(grid, bodyElement, callback){
9874 if(this.initialized) return;
9876 this.initialized = true;
9877 this.callback = callback;
9879 bodyElement.appendChild(this.div.dom);
9883 initEvents : function(){
9884 var stopOnEnter = function(e){
9885 if(e.browserEvent.keyCode == e.RETURN){
9886 this.stopEditing(true);
9887 }else if(e.browserEvent.keyCode == e.ESC){
9888 this.setValue(this.originalValue);
9889 this.stopEditing(true);
9892 this.element.mon('keydown', stopOnEnter, this, true);
9893 var vtask = new YAHOO.ext.util.DelayedTask(this.validate, this);
9894 this.element.mon('keyup', vtask.delay.createDelegate(vtask, [this.validationDelay]));
9895 this.pick.on('click', this.showCalendar, this, true);
9898 startEditing : function(value, row, cell){
9899 this.originalValue = value;
9900 this.rowIndex = row.rowIndex;
9901 this.colIndex = cell.columnIndex;
9903 this.setValue(value);
9905 var cellbox = getEl(cell, true).getBox();
9906 this.div.setBox(cellbox, true);
9907 this.element.setWidth(cellbox.width-this.pick.getWidth());
9908 this.editing = true;
9909 YAHOO.util.Event.on(document, "mousedown", this.mouseDownHandler);
9913 stopEditing : function(focusCell){
9915 YAHOO.util.Event.removeListener(document, "mousedown", this.mouseDownHandler);
9916 this.editing = false;
9917 var newValue = this.getValue();
9920 if(this.originalValue != newValue){
9921 this.callback(newValue, this.rowIndex, this.colIndex);
9926 setValue : function(value){
9927 this.element.dom.value = this.formatDate(value);
9931 getValue : function(){
9932 if(!this.validate()){
9933 return this.originalValue;
9935 var value = this.element.dom.value;
9936 if(value.length < 1){
9939 return this.parseDate(value);
9946 this.element.focus();
9952 this.element.dom.blur();
9957 validate : function(){
9958 var dom = this.element.dom;
9959 var value = dom.value;
9960 if(value.length < 1){
9961 if(this.allowBlank){
9963 this.element.removeClass('ygrid-editor-invalid');
9966 dom.title = this.blankText;
9967 this.element.addClass('ygrid-editor-invalid');
9971 value = this.parseDate(value);
9973 dom.title = this.invalidText.replace('%0', dom.value).replace('%1', this.format);
9974 this.element.addClass('ygrid-editor-invalid');
9977 var time = value.getTime();
9978 if(this.minValue && time < this.minValue.getTime()){
9979 dom.title = this.minText.replace('%0', this.formatDate(this.minValue));
9980 this.element.addClass('ygrid-editor-invalid');
9983 if(this.maxValue && time > this.maxValue.getTime()){
9984 dom.title = this.maxText.replace('%0', this.formatDate(this.maxValue));
9985 this.element.addClass('ygrid-editor-invalid');
9988 if(this.disabledDays){
9989 var day = value.getDay();
9990 for(var i = 0; i < this.disabledDays.length; i++) {
9991 if(day === this.disabledDays[i]){
9992 dom.title = this.disabledDaysText;
9993 this.element.addClass('ygrid-editor-invalid');
9998 var fvalue = this.formatDate(value);
9999 if(this.ddMatch.test(fvalue)){
10000 dom.title = this.disabledDatesText.replace('%0', fvalue);
10001 this.element.addClass('ygrid-editor-invalid');
10004 var msg = this.validator(value);
10007 this.element.addClass('ygrid-editor-invalid');
10011 this.element.removeClass('ygrid-editor-invalid');
10015 handleMouseDown : function(e){
10016 var t = e.getTarget();
10017 var dom = this.div.dom;
10018 if(t != dom && !YAHOO.util.Dom.isAncestor(dom, t)){
10019 this.stopEditing();
10023 showCalendar : function(value){
10024 if(this.cal == null){
10025 this.cal = new YAHOO.ext.DatePicker(this.div.dom.parentNode.parentNode);
10027 this.cal.minDate = this.minValue;
10028 this.cal.maxDate = this.maxValue;
10029 this.cal.disabledDatesRE = this.ddMatch;
10030 this.cal.disabledDatesText = this.disabledDatesText;
10031 this.cal.disabledDays = this.disabledDays;
10032 this.cal.disabledDaysText = this.disabledDaysText;
10033 this.cal.format = this.format;
10035 this.cal.minText = this.minText.replace('%0', this.formatDate(this.minValue));
10038 this.cal.maxText = this.maxText.replace('%0', this.formatDate(this.maxValue));
10040 var r = this.div.getRegion();
10041 this.cal.show(r.left, r.bottom, this.getValue(), this.setValue.createDelegate(this));
10044 parseDate : function(value){
10045 if(!value || value instanceof Date) return value;
10046 return Date.parseDate(value, this.format);
10049 formatDate : function(date){
10050 if(!date || !(date instanceof Date)) return date;
10051 return date.format(this.format);
10055 YAHOO.ext.grid.DateEditor.prototype.format = 'm/d/y';
10056 YAHOO.ext.grid.DateEditor.prototype.disabledDays = null;
10057 YAHOO.ext.grid.DateEditor.prototype.disabledDaysText = '';
10058 YAHOO.ext.grid.DateEditor.prototype.disabledDates = null;
10059 YAHOO.ext.grid.DateEditor.prototype.disabledDatesText = '';
10060 YAHOO.ext.grid.DateEditor.prototype.allowBlank = true;
10061 YAHOO.ext.grid.DateEditor.prototype.minValue = null;
10062 YAHOO.ext.grid.DateEditor.prototype.maxValue = null;
10063 YAHOO.ext.grid.DateEditor.prototype.minText = 'The date in this field must be after %0';
10064 YAHOO.ext.grid.DateEditor.prototype.maxText = 'The date in this field must be before %0';
10065 YAHOO.ext.grid.DateEditor.prototype.blankText = 'This field cannot be blank';
10066 YAHOO.ext.grid.DateEditor.prototype.invalidText = '%0 is not a valid date - it must be in the format %1';
10067 YAHOO.ext.grid.DateEditor.prototype.validationDelay = 200;
10068 YAHOO.ext.grid.DateEditor.prototype.validator = function(){return true;};
10070 YAHOO.ext.grid.NumberEditor = function(config){
10071 var element = document.createElement('input');
10072 element.type = 'text';
10073 element.className = 'ygrid-editor ygrid-num-editor';
10074 element.setAttribute('autocomplete', 'off');
10075 document.body.appendChild(element);
10076 YAHOO.ext.grid.NumberEditor.superclass.constructor.call(this, element);
10077 YAHOO.ext.util.Config.apply(this, config);
10079 YAHOO.extendX(YAHOO.ext.grid.NumberEditor, YAHOO.ext.grid.CellEditor);
10081 YAHOO.ext.grid.NumberEditor.prototype.initEvents = function(){
10082 var stopOnEnter = function(e){
10083 if(e.browserEvent.keyCode == e.RETURN){
10084 this.stopEditing(true);
10085 }else if(e.browserEvent.keyCode == e.ESC){
10086 this.setValue(this.originalValue);
10087 this.stopEditing(true);
10091 var allowed = "0123456789";
10092 if(this.allowDecimals){
10093 allowed += this.decimalSeparator;
10095 if(this.allowNegative){
10098 var keyPress = function(e){
10099 var c = e.getCharCode();
10100 if(c != e.BACKSPACE && allowed.indexOf(String.fromCharCode(c)) === -1){
10104 this.element.mon('keydown', stopOnEnter, this, true);
10105 var vtask = new YAHOO.ext.util.DelayedTask(this.validate, this);
10106 this.element.mon('keyup', vtask.delay.createDelegate(vtask, [this.validationDelay]));
10107 this.element.mon('keypress', keyPress, this, true);
10108 this.element.on('blur', this.stopEditing, this, true);
10111 YAHOO.ext.grid.NumberEditor.prototype.validate = function(){
10112 var dom = this.element.dom;
10113 var value = dom.value;
10114 if(value.length < 1){
10115 if(this.allowBlank){
10117 this.element.removeClass('ygrid-editor-invalid');
10120 dom.title = this.blankText;
10121 this.element.addClass('ygrid-editor-invalid');
10125 if(value.search(/\d+/) === -1){
10126 dom.title = this.nanText.replace('%0', value);
10127 this.element.addClass('ygrid-editor-invalid');
10130 var num = this.parseValue(value);
10131 if(num < this.minValue){
10132 dom.title = this.minText.replace('%0', this.minValue);
10133 this.element.addClass('ygrid-editor-invalid');
10136 if(num > this.maxValue){
10137 dom.title = this.maxText.replace('%0', this.maxValue);
10138 this.element.addClass('ygrid-editor-invalid');
10141 var msg = this.validator(value);
10144 this.element.addClass('ygrid-editor-invalid');
10148 this.element.removeClass('ygrid-editor-invalid');
10152 YAHOO.ext.grid.NumberEditor.prototype.show = function(){
10153 this.element.dom.title = '';
10154 YAHOO.ext.grid.NumberEditor.superclass.show.call(this);
10155 if(this.selectOnFocus){
10157 this.element.dom.select();
10160 this.validate(this.element.dom.value);
10163 YAHOO.ext.grid.NumberEditor.prototype.getValue = function(){
10164 if(!this.validate()){
10165 return this.originalValue;
10167 var value = this.element.dom.value;
10168 if(value.length < 1){
10171 return this.fixPrecision(this.parseValue(value));
10175 YAHOO.ext.grid.NumberEditor.prototype.parseValue = function(value){
10176 return parseFloat(new String(value).replace(this.decimalSeparator, '.'));
10179 YAHOO.ext.grid.NumberEditor.prototype.fixPrecision = function(value){
10180 if(!this.allowDecimals || this.decimalPrecision == -1 || isNaN(value) || value == 0 || !value){
10189 var scale = Math.pow(10, this.decimalPrecision+1);
10190 var fixed = this.decimalPrecisionFcn(value * scale);
10191 fixed = this.decimalPrecisionFcn(fixed/10);
10192 return fixed / (scale/10);
10195 YAHOO.ext.grid.NumberEditor.prototype.allowBlank = true;
10196 YAHOO.ext.grid.NumberEditor.prototype.allowDecimals = true;
10197 YAHOO.ext.grid.NumberEditor.prototype.decimalSeparator = '.';
10198 YAHOO.ext.grid.NumberEditor.prototype.decimalPrecision = 2;
10199 YAHOO.ext.grid.NumberEditor.prototype.decimalPrecisionFcn = Math.floor;
10200 YAHOO.ext.grid.NumberEditor.prototype.allowNegative = true;
10201 YAHOO.ext.grid.NumberEditor.prototype.selectOnFocus = true;
10202 YAHOO.ext.grid.NumberEditor.prototype.minValue = Number.NEGATIVE_INFINITY;
10203 YAHOO.ext.grid.NumberEditor.prototype.maxValue = Number.MAX_VALUE;
10204 YAHOO.ext.grid.NumberEditor.prototype.minText = 'The minimum value for this field is %0';
10205 YAHOO.ext.grid.NumberEditor.prototype.maxText = 'The maximum value for this field is %0';
10206 YAHOO.ext.grid.NumberEditor.prototype.blankText = 'This field cannot be blank';
10207 YAHOO.ext.grid.NumberEditor.prototype.nanText = '%0 is not a valid number';
10208 YAHOO.ext.grid.NumberEditor.prototype.validationDelay = 100;
10209 YAHOO.ext.grid.NumberEditor.prototype.validator = function(){return true;};
10210 YAHOO.ext.DatePicker = function(id, parentElement){
10212 this.selectedDate = new Date();
10213 this.visibleDate = new Date();
10214 this.element = null;
10215 this.shadow = null;
10216 this.callback = null;
10217 this.buildControl(parentElement || document.body);
10218 this.mouseDownHandler = YAHOO.ext.EventManager.wrap(this.handleMouseDown, this, true);
10219 this.keyDownHandler = YAHOO.ext.EventManager.wrap(this.handleKeyDown, this, true);
10220 this.wheelHandler = YAHOO.ext.EventManager.wrap(this.handleMouseWheel, this, true);
10223 YAHOO.ext.DatePicker.prototype = {
10224 show : function(x, y, value, callback){
10226 this.selectedDate = value;
10227 this.visibleDate = value;
10228 this.callback = callback;
10230 this.element.show();
10231 this.element.setXY(this.constrainToViewport ? this.constrainXY(x, y) : [x, y]);
10232 this.shadow.show();
10233 this.shadow.setRegion(this.element.getRegion());
10234 this.element.dom.tabIndex = 1;
10235 this.element.focus();
10236 YAHOO.util.Event.on(document, "mousedown", this.mouseDownHandler);
10237 YAHOO.util.Event.on(document, "keydown", this.keyDownHandler);
10238 YAHOO.util.Event.on(document, "mousewheel", this.wheelHandler);
10239 YAHOO.util.Event.on(document, "DOMMouseScroll", this.wheelHandler);
10242 constrainXY : function(x, y){
10243 var w = YAHOO.util.Dom.getViewportWidth();
10244 var h = YAHOO.util.Dom.getViewportHeight();
10245 var size = this.element.getSize();
10247 Math.min(w-size.width, x),
10248 Math.min(h-size.height, y)
10253 this.shadow.hide();
10254 this.element.hide();
10255 YAHOO.util.Event.removeListener(document, "mousedown", this.mouseDownHandler);
10256 YAHOO.util.Event.removeListener(document, "keydown", this.keyDownHandler);
10257 YAHOO.util.Event.removeListener(document, "mousewheel", this.wheelHandler);
10258 YAHOO.util.Event.removeListener(document, "DOMMouseScroll", this.wheelHandler);
10261 setSelectedDate : function(date){
10262 this.selectedDate = date;
10265 getSelectedDate : function(){
10266 return this.selectedDate;
10269 showPrevMonth : function(){
10270 this.visibleDate = this.getPrevMonth(this.visibleDate);
10274 showNextMonth : function(){
10275 this.visibleDate = this.getNextMonth(this.visibleDate);
10279 showPrevYear : function(){
10280 var d = this.visibleDate;
10281 this.visibleDate = new Date(d.getFullYear()-1, d.getMonth(), d.getDate());
10285 showNextYear : function(){
10286 var d = this.visibleDate;
10287 this.visibleDate = new Date(d.getFullYear()+1, d.getMonth(), d.getDate());
10291 handleMouseDown : function(e){
10292 var target = e.getTarget();
10293 if(target != this.element.dom && !YAHOO.util.Dom.isAncestor(this.element.dom, target)){
10298 handleKeyDown : function(e){
10299 switch(e.browserEvent.keyCode){
10301 this.showPrevMonth();
10305 this.showNextMonth();
10309 this.showPrevYear();
10313 this.showNextYear();
10319 handleMouseWheel : function(e){
10320 var delta = e.getWheelDelta();
10322 this.showPrevMonth();
10324 } else if(delta < 0){
10325 this.showNextMonth();
10330 handleClick : function(e){
10331 var d = this.visibleDate;
10332 var t = e.getTarget();
10333 if(t && t.className){
10334 switch(t.className){
10336 this.handleSelection(new Date(d.getFullYear(), d.getMonth(), parseInt(t.innerHTML)));
10339 var p = this.getPrevMonth(d);
10340 this.handleSelection(new Date(p.getFullYear(), p.getMonth(), parseInt(t.innerHTML)));
10343 var n = this.getNextMonth(d);
10344 this.handleSelection(new Date(n.getFullYear(), n.getMonth(), parseInt(t.innerHTML)));
10346 case 'ypopcal-today':
10347 this.handleSelection(new Date());
10350 this.showNextMonth();
10353 this.showPrevMonth();
10360 selectToday : function(){
10361 this.handleSelection(new Date());
10364 handleSelection: function(date){
10365 this.selectedDate = date;
10366 this.callback(date);
10370 getPrevMonth : function(d){
10371 var m = d.getMonth();var y = d.getFullYear();
10372 return (m == 0 ? new Date(--y, 11, 1) : new Date(y, --m, 1));
10375 getNextMonth : function(d){
10376 var m = d.getMonth();var y = d.getFullYear();
10377 return (m == 11 ? new Date(++y, 0, 1) : new Date(y, ++m, 1));
10380 getDaysInMonth : function(m, y){
10381 return (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) ? 31 : (m == 4 || m == 6 || m == 9 || m == 11) ? 30 : this.isLeapYear(y) ? 29 : 28;
10384 isLeapYear : function(y){
10385 return (((y % 4) == 0) && ((y % 100) != 0) || ((y % 400) == 0));
10388 clearTime : function(date){
10391 date.setMinutes(0);
10392 date.setSeconds(0);
10393 date.setMilliseconds(0);
10398 refresh : function(){
10399 var d = this.visibleDate;
10400 this.buildInnerCal(d);
10401 this.calHead.update(this.monthNames[d.getMonth()] + ' ' + d.getFullYear());
10402 if(this.element.isVisible()){
10403 this.shadow.setRegion(this.element.getRegion());
10409 YAHOO.ext.DatePicker.prototype.buildControl = function(parentElement){
10410 var c = document.createElement('div');
10411 c.style.position = 'absolute';
10412 c.style.visibility = 'hidden';
10413 document.body.appendChild(c);
10414 var html = '<iframe id="'+this.id+'_shdw" frameborder="0" style="position:absolute; z-index:2000; display:none; top:0px; left:0px;" class="ypopcal-shadow"></iframe>' +
10415 '<div hidefocus="true" class="ypopcal" id="'+this.id+'" style="-moz-outline:none; position:absolute; z-index:2001; display:none; top:0px; left:0px;">' +
10416 '<table class="ypopcal-head" border=0 cellpadding=0 cellspacing=0><tbody><tr><td class="ypopcal-arrow"><div class="prev-month"> </div></td><td class="ypopcal-month"> </td><td class="ypopcal-arrow"><div class="next-month"> </div></td></tr></tbody></table>' +
10417 '<center><div class="ypopcal-inner">';
10418 html += "<table border=0 cellpadding=2 cellspacing=0 class=\"ypopcal-table\"><thead><tr class=\"ypopcal-daynames\">";
10419 var names = this.dayNames;
10420 for(var i = 0; i < names.length; i++){
10421 html += '<td>' + names[i].substr(0, 1) + '</td>';
10423 html+= "</tr></thead><tbody><tr>";
10424 for(var i = 0; i < 42; i++) {
10425 if(i % 7 == 0 && i != 0){
10426 html += '</tr><tr>';
10428 html += "<td> </td>";
10430 html += "</tr></tbody></table>";
10431 html += '</div><button class="ypopcal-today" style="margin-top:2px;">'+this.todayText+'</button></center></div>';
10432 c.innerHTML = html;
10433 this.shadow = getEl(c.childNodes[0], true);
10434 this.shadow.enableDisplayMode();
10435 this.element = getEl(c.childNodes[1], true);
10436 this.element.enableDisplayMode();
10437 document.body.appendChild(this.shadow.dom);
10438 document.body.appendChild(this.element.dom);
10439 document.body.removeChild(c);
10440 this.element.on("selectstart", function(){return false;});
10441 var tbody = this.element.dom.getElementsByTagName('tbody')[1];
10442 this.cells = tbody.getElementsByTagName('td');
10443 this.calHead = this.element.getChildrenByClassName('ypopcal-month', 'td')[0];
10444 this.element.mon('mousedown', this.handleClick, this, true);
10447 YAHOO.ext.DatePicker.prototype.buildInnerCal = function(dateVal){
10448 var days = this.getDaysInMonth(dateVal.getMonth() + 1, dateVal.getFullYear());
10449 var firstOfMonth = new Date(dateVal.getFullYear(), dateVal.getMonth(), 1);
10450 var startingPos = firstOfMonth.getDay();
10451 if(startingPos == 0) startingPos = 7;
10452 var pm = this.getPrevMonth(dateVal);
10453 var prevStart = this.getDaysInMonth(pm.getMonth()+1, pm.getFullYear())-startingPos;
10454 var cells = this.cells;
10455 days += startingPos;
10458 var day = 86400000;
10459 var date = this.clearTime(new Date(pm.getFullYear(), pm.getMonth(), prevStart));
10460 var today = this.clearTime(new Date()).getTime();
10461 var sel = this.selectedDate ? this.clearTime(this.selectedDate).getTime() : today + 1;
10462 var min = this.minDate ? this.clearTime(this.minDate).getTime() : Number.NEGATIVE_INFINITY;
10463 var max = this.maxDate ? this.clearTime(this.maxDate).getTime() : Number.POSITIVE_INFINITY;
10464 var ddMatch = this.disabledDatesRE;
10465 var ddText = this.disabledDatesText;
10466 var ddays = this.disabledDays;
10467 var ddaysText = this.disabledDaysText;
10468 var format = this.format;
10470 var setCellClass = function(cal, cell, d){
10472 var t = d.getTime();
10474 cell.className += ' today';
10475 cell.title = cal.todayText;
10478 cell.className += ' selected';
10482 cell.className = ' ypopcal-disabled';
10483 cell.title = cal.minText;
10487 cell.className = ' ypopcal-disabled';
10488 cell.title = cal.maxText;
10492 var day = d.getDay();
10493 for(var i = 0; i < ddays.length; i++) {
10494 if(day === ddays[i]){
10495 cell.title = ddaysText;
10496 cell.className = ' ypopcal-disabled';
10501 if(ddMatch && format){
10502 var fvalue = d.format(format);
10503 if(ddMatch.test(fvalue)){
10504 cell.title = ddText.replace('%0', fvalue);
10505 cell.className = ' ypopcal-disabled';
10512 for(; i < startingPos; i++) {
10513 cells[i].innerHTML = (++prevStart);
10514 date.setDate(date.getDate()+1);
10515 cells[i].className = 'prevday';
10516 setCellClass(this, cells[i], date);
10518 for(; i < days; i++){
10519 intDay = i - startingPos + 1;
10520 cells[i].innerHTML = (intDay);
10521 date.setDate(date.getDate()+1);
10522 cells[i].className = 'active';
10523 setCellClass(this, cells[i], date);
10526 for(; i < 42; i++) {
10527 cells[i].innerHTML = (++extraDays);
10528 date.setDate(date.getDate()+1);
10529 cells[i].className = 'nextday';
10530 setCellClass(this, cells[i], date);
10534 YAHOO.ext.DatePicker.prototype.todayText = "Today";
10535 YAHOO.ext.DatePicker.prototype.minDate = null;
10536 YAHOO.ext.DatePicker.prototype.maxDate = null;
10537 YAHOO.ext.DatePicker.prototype.minText = "This date is before the minimum date";
10538 YAHOO.ext.DatePicker.prototype.maxText = "This date is after the maximum date";
10539 YAHOO.ext.DatePicker.prototype.format = 'm/d/y';
10540 YAHOO.ext.DatePicker.prototype.disabledDays = null;
10541 YAHOO.ext.DatePicker.prototype.disabledDaysText = '';
10542 YAHOO.ext.DatePicker.prototype.disabledDatesRE = null;
10543 YAHOO.ext.DatePicker.prototype.disabledDatesText = '';
10544 YAHOO.ext.DatePicker.prototype.constrainToViewport = true;
10547 YAHOO.ext.DatePicker.prototype.monthNames = Date.monthNames;
10549 YAHOO.ext.DatePicker.prototype.dayNames = Date.dayNames;
10551 YAHOO.ext.grid.SelectEditor = function(element){
10552 element.hideFocus = true;
10553 YAHOO.ext.grid.SelectEditor.superclass.constructor.call(this, element);
10554 this.element.swallowEvent('click');
10556 YAHOO.extendX(YAHOO.ext.grid.SelectEditor, YAHOO.ext.grid.CellEditor);
10558 YAHOO.ext.grid.SelectEditor.prototype.fitToCell = function(box){
10559 if(YAHOO.ext.util.Browser.isGecko){
10562 this.element.setBox(box, true);
10565 YAHOO.ext.grid.TextEditor = function(config){
10566 var element = document.createElement('input');
10567 element.type = 'text';
10568 element.className = 'ygrid-editor ygrid-text-editor';
10569 element.setAttribute('autocomplete', 'off');
10570 document.body.appendChild(element);
10571 YAHOO.ext.grid.TextEditor.superclass.constructor.call(this, element);
10572 YAHOO.ext.util.Config.apply(this, config);
10574 YAHOO.extendX(YAHOO.ext.grid.TextEditor, YAHOO.ext.grid.CellEditor);
10576 YAHOO.ext.grid.TextEditor.prototype.validate = function(){
10577 var dom = this.element.dom;
10578 var value = dom.value;
10579 if(value.length < 1){
10580 if(this.allowBlank){
10582 this.element.removeClass('ygrid-editor-invalid');
10585 dom.title = this.blankText;
10586 this.element.addClass('ygrid-editor-invalid');
10590 if(value.length < this.minLength){
10591 dom.title = this.minText.replace('%0', this.minLength);
10592 this.element.addClass('ygrid-editor-invalid');
10595 if(value.length > this.maxLength){
10596 dom.title = this.maxText.replace('%0', this.maxLength);
10597 this.element.addClass('ygrid-editor-invalid');
10600 var msg = this.validator(value);
10603 this.element.addClass('ygrid-editor-invalid');
10606 if(this.regex && !this.regex.test(value)){
10607 dom.title = this.regexText;
10608 this.element.addClass('ygrid-editor-invalid');
10612 this.element.removeClass('ygrid-editor-invalid');
10616 YAHOO.ext.grid.TextEditor.prototype.initEvents = function(){
10617 YAHOO.ext.grid.TextEditor.superclass.initEvents.call(this);
10618 var vtask = new YAHOO.ext.util.DelayedTask(this.validate, this);
10619 this.element.mon('keyup', vtask.delay.createDelegate(vtask, [this.validationDelay]));
10622 YAHOO.ext.grid.TextEditor.prototype.show = function(){
10623 this.element.dom.title = '';
10624 YAHOO.ext.grid.TextEditor.superclass.show.call(this);
10625 this.element.focus();
10626 if(this.selectOnFocus){
10628 this.element.dom.select();
10631 this.validate(this.element.dom.value);
10634 YAHOO.ext.grid.TextEditor.prototype.getValue = function(){
10635 if(!this.validate()){
10636 return this.originalValue;
10638 return this.element.dom.value;
10642 YAHOO.ext.grid.TextEditor.prototype.allowBlank = true;
10643 YAHOO.ext.grid.TextEditor.prototype.minLength = 0;
10644 YAHOO.ext.grid.TextEditor.prototype.maxLength = Number.MAX_VALUE;
10645 YAHOO.ext.grid.TextEditor.prototype.minText = 'The minimum length for this field is %0';
10646 YAHOO.ext.grid.TextEditor.prototype.maxText = 'The maximum length for this field is %0';
10647 YAHOO.ext.grid.TextEditor.prototype.selectOnFocus = true;
10648 YAHOO.ext.grid.TextEditor.prototype.blankText = 'This field cannot be blank';
10649 YAHOO.ext.grid.TextEditor.prototype.validator = function(){return true;};
10650 YAHOO.ext.grid.TextEditor.prototype.validationDelay = 200;
10651 YAHOO.ext.grid.TextEditor.prototype.regex = null;
10652 YAHOO.ext.grid.TextEditor.prototype.regexText = '';
10654 YAHOO.ext.LayoutManager = function(container){
10655 YAHOO.ext.LayoutManager.superclass.constructor.call(this);
10656 this.el = getEl(container, true);
10657 this.id = this.el.id;
10658 this.el.addClass('ylayout-container');
10660 this.monitorWindowResize = true;
10664 'layout' : new YAHOO.util.CustomEvent(),
10666 'regionresized' : new YAHOO.util.CustomEvent(),
10668 'regioncollapsed' : new YAHOO.util.CustomEvent(),
10670 'regionexpanded' : new YAHOO.util.CustomEvent()
10672 this.updating = false;
10673 YAHOO.ext.EventManager.onWindowResize(this.onWindowResize, this, true);
10676 YAHOO.extendX(YAHOO.ext.LayoutManager, YAHOO.ext.util.Observable, {
10678 isUpdating : function(){
10679 return this.updating;
10683 beginUpdate : function(){
10684 this.updating = true;
10688 endUpdate : function(noLayout){
10689 this.updating = false;
10695 layout: function(){
10699 onRegionResized : function(region, newSize){
10700 this.fireEvent('regionresized', region, newSize);
10704 onRegionCollapsed : function(region){
10705 this.fireEvent('regioncollapsed', region);
10708 onRegionExpanded : function(region){
10709 this.fireEvent('regionexpanded', region);
10713 getViewSize : function(){
10715 if(this.el.dom != document.body){
10716 this.el.beginMeasure();
10717 size = this.el.getSize();
10718 this.el.endMeasure();
10720 size = {width: YAHOO.util.Dom.getViewportWidth(), height: YAHOO.util.Dom.getViewportHeight()};
10722 size.width -= this.el.getBorderWidth('lr')-this.el.getPadding('lr');
10723 size.height -= this.el.getBorderWidth('tb')-this.el.getPadding('tb');
10728 getEl : function(){
10733 getRegion : function(target){
10734 return this.regions[target.toLowerCase()];
10737 onWindowResize : function(){
10738 if(this.monitorWindowResize){
10744 YAHOO.ext.LayoutRegion = function(mgr, config, pos){
10746 this.position = pos;
10747 var dh = YAHOO.ext.DomHelper;
10749 this.el = dh.append(mgr.el.dom, {tag: 'div', cls: 'ylayout-panel ylayout-panel-' + this.position}, true);
10751 this.titleEl = dh.append(this.el.dom, {tag: 'div', unselectable: 'on', cls: 'yunselectable ylayout-panel-hd ylayout-title-'+this.position, children:[
10752 {tag: 'span', cls: 'yunselectable ylayout-panel-hd-text', unselectable: 'on', html: ' '},
10753 {tag: 'div', cls: 'yunselectable ylayout-panel-hd-tools', unselectable: 'on'}
10755 this.titleEl.enableDisplayMode();
10757 this.titleTextEl = this.titleEl.dom.firstChild;
10758 this.tools = getEl(this.titleEl.dom.childNodes[1], true);
10759 this.closeBtn = this.createTool(this.tools.dom, 'ylayout-close');
10760 this.closeBtn.enableDisplayMode();
10761 this.closeBtn.on('click', this.closeClicked, this, true);
10762 this.closeBtn.hide();
10764 this.bodyEl = dh.append(this.el.dom, {tag: 'div', cls: 'ylayout-panel-body'}, true);
10767 'beforeremove' : new YAHOO.util.CustomEvent('beforeremove'),
10769 'invalidated' : new YAHOO.util.CustomEvent('invalidated'),
10771 'visibilitychange' : new YAHOO.util.CustomEvent('visibilitychange'),
10773 'paneladded' : new YAHOO.util.CustomEvent('paneladded'),
10775 'panelremoved' : new YAHOO.util.CustomEvent('panelremoved'),
10777 'collapsed' : new YAHOO.util.CustomEvent('collapsed'),
10779 'expanded' : new YAHOO.util.CustomEvent('expanded'),
10781 'panelactivated' : new YAHOO.util.CustomEvent('panelactivated'),
10783 'resized' : new YAHOO.util.CustomEvent('resized')
10786 this.panels = new YAHOO.ext.util.MixedCollection();
10787 this.panels.getKey = this.getPanelId.createDelegate(this);
10789 this.visible = false;
10790 this.collapsed = false;
10792 this.on('paneladded', this.validateVisibility, this, true);
10793 this.on('panelremoved', this.validateVisibility, this, true);
10794 this.activePanel = null;
10796 this.applyConfig(config);
10801 YAHOO.extendX(YAHOO.ext.LayoutRegion, YAHOO.ext.util.Observable, {
10802 getPanelId : function(p){
10806 applyConfig : function(config){
10807 if(config.collapsible && this.position != 'center' && !this.collapsedEl){
10808 var dh = YAHOO.ext.DomHelper;
10809 this.collapseBtn = this.createTool(this.tools.dom, 'ylayout-collapse-'+this.position);
10810 this.collapseBtn.mon('click', this.collapse, this, true);
10812 this.collapsedEl = dh.append(this.mgr.el.dom, {tag: 'div', cls: 'ylayout-collapsed ylayout-collapsed-'+this.position, children:[
10813 {tag: 'div', cls: 'ylayout-collapsed-tools'}
10815 if(config.floatable !== false){
10816 this.collapsedEl.addClassOnOver('ylayout-collapsed-over');
10817 this.collapsedEl.mon('click', this.collapseClick, this, true);
10819 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild, 'ylayout-expand-'+this.position);
10820 this.expandBtn.mon('click', this.expand, this, true);
10822 if(this.collapseBtn){
10823 this.collapseBtn.setVisible(config.collapsible == true);
10825 this.cmargins = config.cmargins || this.cmargins ||
10826 (this.position == 'west' || this.position == 'east' ?
10827 {top: 0, left: 2, right:2, bottom: 0} :
10828 {top: 2, left: 0, right:0, bottom: 2});
10829 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
10830 this.bottomTabs = config.tabPosition != 'top';
10831 this.autoScroll = config.autoScroll || false;
10832 if(this.autoScroll){
10833 this.bodyEl.setStyle('overflow', 'auto');
10835 this.bodyEl.setStyle('overflow', 'hidden');
10837 if((!config.titlebar && !config.title) || config.titlebar === false){
10838 this.titleEl.hide();
10840 this.titleEl.show();
10842 this.titleTextEl.innerHTML = config.title;
10845 this.duration = config.duration || .30;
10846 this.slideDuration = config.slideDuration || .45;
10847 this.config = config;
10848 if(config.collapsed){
10849 this.collapse(true);
10854 resizeTo : function(newSize){
10855 switch(this.position){
10858 this.el.setWidth(newSize);
10859 this.fireEvent('resized', this, newSize);
10863 this.el.setHeight(newSize);
10864 this.fireEvent('resized', this, newSize);
10869 getBox : function(){
10871 if(!this.collapsed){
10872 b = this.el.getBox(false, true);
10874 b = this.collapsedEl.getBox(false, true);
10879 getMargins : function(){
10880 return this.collapsed ? this.cmargins : this.margins;
10883 highlight : function(){
10884 this.el.addClass('ylayout-panel-dragover');
10887 unhighlight : function(){
10888 this.el.removeClass('ylayout-panel-dragover');
10891 updateBox : function(box){
10893 if(!this.collapsed){
10894 this.el.dom.style.left = box.x + 'px';
10895 this.el.dom.style.top = box.y + 'px';
10896 this.el.setSize(box.width, box.height);
10897 var bodyHeight = this.titleEl.isVisible() ? box.height - (this.titleEl.getHeight()||0) : box.height;
10898 bodyHeight -= this.el.getBorderWidth('tb');
10899 bodyWidth = box.width - this.el.getBorderWidth('rl');
10900 this.bodyEl.setHeight(bodyHeight);
10901 this.bodyEl.setWidth(bodyWidth);
10902 var tabHeight = bodyHeight;
10904 tabHeight = this.tabs.syncHeight(bodyHeight);
10905 if(YAHOO.ext.util.Browser.isIE) this.tabs.el.repaint();
10907 this.panelSize = {width: bodyWidth, height: tabHeight};
10908 if(this.activePanel){
10909 this.activePanel.setSize(bodyWidth, tabHeight);
10912 this.collapsedEl.dom.style.left = box.x + 'px';
10913 this.collapsedEl.dom.style.top = box.y + 'px';
10914 this.collapsedEl.setSize(box.width, box.height);
10917 this.tabs.autoSizeTabs();
10922 getEl : function(){
10928 if(!this.collapsed){
10929 this.el.dom.style.left = '-2000px';
10932 this.collapsedEl.dom.style.left = '-2000px';
10933 this.collapsedEl.hide();
10935 this.visible = false;
10936 this.fireEvent('visibilitychange', this, false);
10941 if(!this.collapsed){
10944 this.collapsedEl.show();
10946 this.visible = true;
10947 this.fireEvent('visibilitychange', this, true);
10951 isVisible : function(){
10952 return this.visible;
10955 closeClicked : function(){
10956 if(this.activePanel){
10957 this.remove(this.activePanel);
10961 collapseClick : function(e){
10963 e.stopPropagation();
10966 e.stopPropagation();
10972 collapse : function(skipAnim){
10973 if(this.collapsed) return;
10974 this.collapsed = true;
10976 this.split.el.hide();
10978 if(this.config.animate && skipAnim !== true){
10979 this.fireEvent('invalidated', this);
10980 this.animateCollapse();
10982 this.el.setLocation(-20000,-20000);
10984 this.collapsedEl.show();
10985 this.fireEvent('collapsed', this);
10986 this.fireEvent('invalidated', this);
10990 animateCollapse : function(){
10995 expand : function(e, skipAnim){
10996 if(e) e.stopPropagation();
10997 if(!this.collapsed) return;
10999 this.slideIn(this.expand.createDelegate(this));
11002 this.collapsed = false;
11004 if(this.config.animate && skipAnim !== true){
11005 this.animateExpand();
11008 this.split.el.show();
11010 this.collapsedEl.setLocation(-2000,-2000);
11011 this.collapsedEl.hide();
11012 this.fireEvent('invalidated', this);
11013 this.fireEvent('expanded', this);
11017 animateExpand : function(){
11021 initTabs : function(){
11022 this.bodyEl.setStyle('overflow', 'hidden');
11023 var ts = new YAHOO.ext.TabPanel(this.bodyEl.dom, this.bottomTabs);
11025 ts.resizeTabs = this.config.resizeTabs === true;
11026 ts.minTabWidth = this.config.minTabWidth || 40;
11027 ts.maxTabWidth = this.config.maxTabWidth || 250;
11028 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
11029 ts.monitorResize = false;
11030 ts.bodyEl.setStyle('overflow', this.config.autoScroll ? 'auto' : 'hidden');
11031 this.panels.each(this.initPanelAsTab, this);
11034 initPanelAsTab : function(panel){
11035 var ti = this.tabs.addTab(panel.getEl().id, panel.getTitle(), null,
11036 this.config.closeOnTab && panel.isClosable());
11037 ti.on('activate', function(){
11038 this.setActivePanel(panel);
11040 if(this.config.closeOnTab){
11041 ti.on('beforeclose', function(t, e){
11043 this.remove(panel);
11049 updatePanelTitle : function(panel, title){
11050 if(this.activePanel == panel){
11051 this.updateTitle(title);
11054 this.tabs.getTab(panel.getEl().id).setText(title);
11058 updateTitle : function(title){
11059 if(this.titleTextEl && !this.config.title){
11060 this.titleTextEl.innerHTML = (typeof title != 'undefined' && title.length > 0 ? title : " ");
11064 setActivePanel : function(panel){
11065 panel = this.getPanel(panel);
11066 if(this.activePanel && this.activePanel != panel){
11067 this.activePanel.setActiveState(false);
11069 this.activePanel = panel;
11070 panel.setActiveState(true);
11071 if(this.panelSize){
11072 panel.setSize(this.panelSize.width, this.panelSize.height);
11074 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
11075 this.updateTitle(panel.getTitle());
11076 this.fireEvent('panelactivated', this, panel);
11081 showPanel : function(panel){
11082 if(panel = this.getPanel(panel)){
11084 this.tabs.activate(panel.getEl().id);
11086 this.setActivePanel(panel);
11093 getActivePanel : function(){
11094 return this.activePanel;
11097 validateVisibility : function(){
11098 if(this.panels.getCount() < 1){
11099 this.updateTitle(' ');
11100 this.closeBtn.hide();
11103 if(!this.isVisible()){
11110 add : function(panel){
11111 if(arguments.length > 1){
11112 for(var i = 0, len = arguments.length; i < len; i++) {
11113 this.add(arguments[i]);
11117 if(this.hasPanel(panel)){
11118 this.showPanel(panel);
11121 panel.setRegion(this);
11122 this.panels.add(panel);
11123 if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
11124 this.bodyEl.dom.appendChild(panel.getEl().dom);
11125 this.setActivePanel(panel);
11126 this.fireEvent('paneladded', this, panel);
11132 this.initPanelAsTab(panel);
11134 this.tabs.activate(panel.getEl().id);
11135 this.fireEvent('paneladded', this, panel);
11140 hasPanel : function(panel){
11141 if(typeof panel == 'object'){
11142 panel = panel.getId();
11144 return this.getPanel(panel) ? true : false;
11148 hidePanel : function(panel){
11149 if(this.tabs && (panel = this.getPanel(panel))){
11150 this.tabs.hideTab(panel.getEl().id);
11155 unhidePanel : function(panel){
11156 if(this.tabs && (panel = this.getPanel(panel))){
11157 this.tabs.unhideTab(panel.getEl().id);
11161 clearPanels : function(){
11162 while(this.panels.getCount() > 0){
11163 this.remove(this.panels.first());
11168 remove : function(panel, preservePanel){
11169 panel = this.getPanel(panel);
11174 this.fireEvent('beforeremove', this, panel, e);
11175 if(e.cancel === true){
11178 preservePanel = (typeof preservePanel != 'undefined' ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
11179 var panelId = panel.getId();
11180 this.panels.removeKey(panelId);
11182 document.body.appendChild(panel.getEl().dom);
11185 this.tabs.removeTab(panel.getEl().id);
11186 }else if (!preservePanel){
11187 this.bodyEl.dom.removeChild(panel.getEl().dom);
11189 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
11190 var p = this.panels.first();
11191 var tempEl = document.createElement('span');
11192 tempEl.appendChild(p.getEl().dom);
11193 this.bodyEl.update('');
11194 this.bodyEl.dom.appendChild(p.getEl().dom);
11196 this.updateTitle(p.getTitle());
11198 this.bodyEl.setStyle('overflow', this.config.autoScroll ? 'auto' : 'hidden');
11199 this.setActivePanel(p);
11201 panel.setRegion(null);
11202 if(this.activePanel == panel){
11203 this.activePanel = null;
11205 if(this.config.autoDestroy !== false && preservePanel !== true){
11206 try{panel.destroy();}catch(e){}
11208 this.fireEvent('panelremoved', this, panel);
11213 getTabs : function(){
11218 getPanel : function(id){
11219 if(typeof id == 'object'){
11222 return this.panels.get(id);
11226 getPosition: function(){
11227 return this.position;
11230 createTool : function(parentEl, className){
11231 var btn = YAHOO.ext.DomHelper.append(parentEl, {tag: 'div', cls: 'ylayout-tools-button',
11232 children: [{tag: 'div', cls: 'ylayout-tools-button-inner ' + className, html: ' '}]}, true);
11233 btn.addClassOnOver('ylayout-tools-button-over');
11238 YAHOO.ext.SplitLayoutRegion = function(mgr, config, pos, cursor){
11239 this.cursor = cursor;
11240 YAHOO.ext.SplitLayoutRegion.superclass.constructor.call(this, mgr, config, pos);
11246 YAHOO.extendX(YAHOO.ext.SplitLayoutRegion, YAHOO.ext.LayoutRegion, {
11247 applyConfig : function(config){
11248 YAHOO.ext.SplitLayoutRegion.superclass.applyConfig.call(this, config);
11251 var splitEl = YAHOO.ext.DomHelper.append(this.mgr.el.dom,
11252 {tag: 'div', id: this.el.id + '-split', cls: 'ylayout-split ylayout-split-'+this.position, html: ' '});
11254 this.split = new YAHOO.ext.SplitBar(splitEl, this.el);
11255 this.split.onMoved.subscribe(this.onSplitMove, this, true);
11256 this.split.useShim = config.useShim === true;
11257 YAHOO.util.Dom.setStyle([this.split.el.dom, this.split.proxy], 'cursor', this.cursor);
11258 this.split.getMaximumSize = this.getMaxSize.createDelegate(this);
11260 if(typeof config.minSize != 'undefined'){
11261 this.split.minSize = config.minSize;
11263 if(typeof config.maxSize != 'undefined'){
11264 this.split.maxSize = config.maxSize;
11269 getMaxSize : function(){
11270 var cmax = this.config.maxSize || 10000;
11271 var center = this.mgr.getRegion('center');
11272 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
11275 onSplitMove : function(split, newSize){
11276 this.fireEvent('resized', this, newSize);
11280 getSplitBar : function(){
11286 this.split.el.setLocation(-2000,-2000);
11287 this.split.el.hide();
11289 YAHOO.ext.SplitLayoutRegion.superclass.hide.call(this);
11294 this.split.el.show();
11296 YAHOO.ext.SplitLayoutRegion.superclass.show.call(this);
11299 beforeSlide: function(){
11300 if(YAHOO.ext.util.Browser.isGecko){
11301 this.bodyEl.clip();
11302 if(this.tabs) this.tabs.bodyEl.clip();
11303 if(this.activePanel){
11304 this.activePanel.getEl().clip();
11306 if(this.activePanel.beforeSlide){
11307 this.activePanel.beforeSlide();
11313 afterSlide : function(){
11314 if(YAHOO.ext.util.Browser.isGecko){
11315 this.bodyEl.unclip();
11316 if(this.tabs) this.tabs.bodyEl.unclip();
11317 if(this.activePanel){
11318 this.activePanel.getEl().unclip();
11319 if(this.activePanel.afterSlide){
11320 this.activePanel.afterSlide();
11326 slideOut : function(){
11328 this.slideEl = new YAHOO.ext.Actor(
11329 YAHOO.ext.DomHelper.append(this.mgr.el.dom, {tag: 'div', cls:'ylayout-slider'}));
11330 if(this.config.autoHide !== false){
11331 var slideInTask = new YAHOO.ext.util.DelayedTask(this.slideIn, this);
11332 this.slideEl.mon('mouseout', function(e){
11333 var to = e.getRelatedTarget();
11334 if(to && to != this.slideEl.dom && !YAHOO.util.Dom.isAncestor(this.slideEl.dom, to)){
11335 slideInTask.delay(500);
11338 this.slideEl.mon('mouseover', function(e){
11339 slideInTask.cancel();
11343 var sl = this.slideEl, c = this.collapsedEl, cm = this.cmargins;
11344 this.isSlid = true;
11346 'left': this.el.getLeft(true),
11347 'top': this.el.getTop(true),
11348 'colbtn': this.collapseBtn.isVisible(),
11349 'closebtn': this.closeBtn.isVisible()
11351 this.collapseBtn.hide();
11352 this.closeBtn.hide();
11354 this.el.setLeftTop(0,0);
11355 sl.startCapture(true);
11357 switch(this.position){
11359 sl.setLeft(c.getRight(true));
11360 sl.setTop(c.getTop(true));
11361 size = this.el.getWidth();
11364 sl.setRight(this.mgr.getViewSize().width-c.getLeft(true));
11365 sl.setTop(c.getTop(true));
11366 size = this.el.getWidth();
11369 sl.setLeft(c.getLeft(true));
11370 sl.setTop(c.getBottom(true));
11371 size = this.el.getHeight();
11374 sl.setLeft(c.getLeft(true));
11375 sl.setBottom(this.mgr.getViewSize().height-c.getTop(true));
11376 size = this.el.getHeight();
11379 sl.dom.appendChild(this.el.dom);
11380 YAHOO.util.Event.on(document.body, 'click', this.slideInIf, this, true);
11381 sl.setSize(this.el.getWidth(), this.el.getHeight());
11382 this.beforeSlide();
11383 if(this.activePanel){
11384 this.activePanel.setSize(this.bodyEl.getWidth(), this.bodyEl.getHeight());
11386 sl.slideShow(this.getAnchor(), size, this.slideDuration, null, false);
11387 sl.play(function(){
11389 }.createDelegate(this));
11392 slideInIf : function(e){
11393 var t = YAHOO.util.Event.getTarget(e);
11394 if(!YAHOO.util.Dom.isAncestor(this.el.dom, t)){
11399 slideIn : function(callback){
11400 if(this.isSlid && !this.slideEl.playlist.isPlaying()){
11401 YAHOO.util.Event.removeListener(document.body, 'click', this.slideInIf, this, true);
11402 this.slideEl.startCapture(true);
11403 this.slideEl.slideHide(this.getAnchor(), this.slideDuration, null);
11404 this.beforeSlide();
11405 this.slideEl.play(function(){
11406 this.isSlid = false;
11407 this.el.setPositioning(this.snapshot);
11408 this.collapseBtn.setVisible(this.snapshot.colbtn);
11409 this.closeBtn.setVisible(this.snapshot.closebtn);
11411 this.mgr.el.dom.appendChild(this.el.dom);
11412 if(typeof callback == 'function'){
11415 }.createDelegate(this));
11419 animateExpand : function(){
11420 var em = this.margins, cm = this.cmargins;
11421 var c = this.collapsedEl, el = this.el;
11422 var direction, distance;
11423 switch(this.position){
11425 direction = 'right';
11426 el.setLeft(-(el.getWidth() + (em.right+em.left)));
11427 el.setTop(c.getTop(true)-cm.top+em.top);
11428 distance = el.getWidth() + (em.right+em.left);
11431 direction = 'left';
11432 el.setLeft(this.mgr.getViewSize().width + em.left);
11433 el.setTop(c.getTop(true)-cm.top+em.top);
11434 distance = el.getWidth() + (em.right+em.left);
11437 direction = 'down';
11438 el.setLeft(em.left);
11439 el.setTop(-(el.getHeight() + (em.top+em.bottom)));
11440 distance = el.getHeight() + (em.top+em.bottom);
11444 el.setLeft(em.left);
11445 el.setTop(this.mgr.getViewSize().height + em.top);
11446 distance = el.getHeight() + (em.top+em.bottom);
11449 this.beforeSlide();
11450 el.setStyle('z-index', '100');
11452 c.setLocation(-2000,-2000);
11454 el.move(direction, distance, true, this.duration, function(){
11456 el.setStyle('z-index', '');
11458 this.split.el.show();
11460 this.fireEvent('invalidated', this);
11461 this.fireEvent('expanded', this);
11462 }.createDelegate(this), this.config.easing || YAHOO.util.Easing.easeOut);
11465 animateCollapse : function(){
11466 var em = this.margins, cm = this.cmargins;
11467 var c = this.collapsedEl, el = this.el;
11468 var direction, distance;
11469 switch(this.position){
11471 direction = 'left';
11472 distance = el.getWidth() + (em.right+em.left);
11475 direction = 'right';
11476 distance = el.getWidth() + (em.right+em.left);
11480 distance = el.getHeight() + (em.top+em.bottom);
11483 direction = 'down';
11484 distance = el.getHeight() + (em.top+em.bottom);
11487 this.el.setStyle('z-index', '100');
11488 this.beforeSlide();
11489 this.el.move(direction, distance, true, this.duration, function(){
11491 this.el.setStyle('z-index', '');
11492 this.el.setLocation(-20000,-20000);
11494 this.collapsedEl.show();
11495 this.fireEvent('collapsed', this);
11496 }.createDelegate(this), YAHOO.util.Easing.easeIn);
11499 getAnchor : function(){
11500 switch(this.position){
11513 YAHOO.ext.BorderLayout = function(container, config){
11514 YAHOO.ext.BorderLayout.superclass.constructor.call(this, container);
11515 this.factory = config.factory || YAHOO.ext.BorderLayout.RegionFactory;
11517 this.hideOnLayout = config.hideOnLayout || false;
11518 for(var i = 0, len = this.factory.validRegions.length; i < len; i++) {
11519 var target = this.factory.validRegions[i];
11520 if(config[target]){
11521 this.addRegion(target, config[target]);
11527 YAHOO.extendX(YAHOO.ext.BorderLayout, YAHOO.ext.LayoutManager, {
11529 addRegion : function(target, config){
11530 if(!this.regions[target]){
11531 var r = this.factory.create(target, this, config);
11532 this.regions[target] = r;
11533 r.on('visibilitychange', this.layout, this, true);
11534 r.on('paneladded', this.layout, this, true);
11535 r.on('panelremoved', this.layout, this, true);
11536 r.on('invalidated', this.layout, this, true);
11537 r.on('resized', this.onRegionResized, this, true);
11538 r.on('collapsed', this.onRegionCollapsed, this, true);
11539 r.on('expanded', this.onRegionExpanded, this, true);
11541 return this.regions[target];
11545 layout : function(){
11546 if(this.updating) return;
11549 var size = this.getViewSize();
11550 var w = size.width, h = size.height;
11551 var centerW = w, centerH = h, centerY = 0, centerX = 0;
11554 var rs = this.regions;
11555 var n = rs['north'], s = rs['south'], west = rs['west'], e = rs['east'], c = rs['center'];
11556 if(this.hideOnLayout){
11557 c.el.setStyle('display', 'none');
11559 if(n && n.isVisible()){
11560 var b = n.getBox();
11561 var m = n.getMargins();
11562 b.width = w - (m.left+m.right);
11565 centerY = b.height + b.y + m.bottom;
11566 centerH -= centerY;
11567 n.updateBox(this.safeBox(b));
11569 if(s && s.isVisible()){
11570 var b = s.getBox();
11571 var m = s.getMargins();
11572 b.width = w - (m.left+m.right);
11574 var totalHeight = (b.height + m.top + m.bottom);
11575 b.y = h - totalHeight + m.top;
11576 centerH -= totalHeight;
11577 s.updateBox(this.safeBox(b));
11579 if(west && west.isVisible()){
11580 var b = west.getBox();
11581 var m = west.getMargins();
11582 b.height = centerH - (m.top+m.bottom);
11584 b.y = centerY + m.top;
11585 var totalWidth = (b.width + m.left + m.right);
11586 centerX += totalWidth;
11587 centerW -= totalWidth;
11588 west.updateBox(this.safeBox(b));
11590 if(e && e.isVisible()){
11591 var b = e.getBox();
11592 var m = e.getMargins();
11593 b.height = centerH - (m.top+m.bottom);
11594 var totalWidth = (b.width + m.left + m.right);
11595 b.x = w - totalWidth + m.left;
11596 b.y = centerY + m.top;
11597 centerW -= totalWidth;
11598 e.updateBox(this.safeBox(b));
11601 var m = c.getMargins();
11603 x: centerX + m.left,
11604 y: centerY + m.top,
11605 width: centerW - (m.left+m.right),
11606 height: centerH - (m.top+m.bottom)
11608 if(this.hideOnLayout){
11609 c.el.setStyle('display', 'block');
11611 c.updateBox(this.safeBox(centerBox));
11614 this.fireEvent('layout', this);
11619 safeBox : function(box){
11620 box.width = Math.max(0, box.width);
11621 box.height = Math.max(0, box.height);
11626 add : function(target, panel){
11627 target = target.toLowerCase();
11628 return this.regions[target].add(panel);
11632 remove : function(target, panel){
11633 target = target.toLowerCase();
11634 return this.regions[target].remove(panel);
11638 findPanel : function(panelId){
11639 var rs = this.regions;
11640 for(var target in rs){
11641 if(typeof rs[target] != 'function'){
11642 var p = rs[target].getPanel(panelId);
11652 showPanel : function(panelId) {
11653 var rs = this.regions;
11654 for(var target in rs){
11655 var r = rs[target];
11656 if(typeof r != 'function'){
11657 if(r.hasPanel(panelId)){
11658 return r.showPanel(panelId);
11666 restoreState : function(provider){
11668 provider = YAHOO.ext.state.Manager;
11670 var sm = new YAHOO.ext.LayoutStateManager();
11671 sm.init(this, provider);
11675 YAHOO.ext.BorderLayout.RegionFactory = {};
11676 YAHOO.ext.BorderLayout.RegionFactory.validRegions = ['north','south','east','west','center'];
11677 YAHOO.ext.BorderLayout.RegionFactory.create = function(target, mgr, config){
11678 if(config.lightweight){
11679 return new YAHOO.ext.LayoutRegionLite(mgr, config);
11681 target = target.toLowerCase();
11684 return new YAHOO.ext.NorthLayoutRegion(mgr, config);
11686 return new YAHOO.ext.SouthLayoutRegion(mgr, config);
11688 return new YAHOO.ext.EastLayoutRegion(mgr, config);
11690 return new YAHOO.ext.WestLayoutRegion(mgr, config);
11692 return new YAHOO.ext.CenterLayoutRegion(mgr, config);
11694 throw 'Layout region "'+target+'" not supported.';
11697 YAHOO.ext.CenterLayoutRegion = function(mgr, config){
11698 YAHOO.ext.CenterLayoutRegion.superclass.constructor.call(this, mgr, config, 'center');
11699 this.visible = true;
11700 this.minWidth = config.minWidth || 20;
11701 this.minHeight = config.minHeight || 20;
11704 YAHOO.extendX(YAHOO.ext.CenterLayoutRegion, YAHOO.ext.LayoutRegion, {
11713 getMinWidth: function(){
11714 return this.minWidth;
11717 getMinHeight: function(){
11718 return this.minHeight;
11723 YAHOO.ext.NorthLayoutRegion = function(mgr, config){
11724 YAHOO.ext.NorthLayoutRegion.superclass.constructor.call(this, mgr, config, 'north', 'n-resize');
11726 this.split.placement = YAHOO.ext.SplitBar.TOP;
11727 this.split.orientation = YAHOO.ext.SplitBar.VERTICAL;
11728 this.split.el.addClass('ylayout-split-v');
11730 if(typeof config.initialSize != 'undefined'){
11731 this.el.setHeight(config.initialSize);
11734 YAHOO.extendX(YAHOO.ext.NorthLayoutRegion, YAHOO.ext.SplitLayoutRegion, {
11735 getBox : function(){
11736 if(this.collapsed){
11737 return this.collapsedEl.getBox();
11739 var box = this.el.getBox();
11741 box.height += this.split.el.getHeight();
11746 updateBox : function(box){
11747 if(this.split && !this.collapsed){
11748 box.height -= this.split.el.getHeight();
11749 this.split.el.setLeft(box.x);
11750 this.split.el.setTop(box.y+box.height);
11751 this.split.el.setWidth(box.width);
11753 if(this.collapsed){
11754 this.el.setWidth(box.width);
11755 var bodyWidth = box.width - this.el.getBorderWidth('rl');
11756 this.bodyEl.setWidth(bodyWidth);
11757 if(this.activePanel && this.panelSize){
11758 this.activePanel.setSize(bodyWidth, this.panelSize.height);
11761 YAHOO.ext.NorthLayoutRegion.superclass.updateBox.call(this, box);
11765 YAHOO.ext.SouthLayoutRegion = function(mgr, config){
11766 YAHOO.ext.SouthLayoutRegion.superclass.constructor.call(this, mgr, config, 'south', 's-resize');
11768 this.split.placement = YAHOO.ext.SplitBar.BOTTOM;
11769 this.split.orientation = YAHOO.ext.SplitBar.VERTICAL;
11770 this.split.el.addClass('ylayout-split-v');
11772 if(typeof config.initialSize != 'undefined'){
11773 this.el.setHeight(config.initialSize);
11776 YAHOO.extendX(YAHOO.ext.SouthLayoutRegion, YAHOO.ext.SplitLayoutRegion, {
11777 getBox : function(){
11778 if(this.collapsed){
11779 return this.collapsedEl.getBox();
11781 var box = this.el.getBox();
11783 var sh = this.split.el.getHeight();
11790 updateBox : function(box){
11791 if(this.split && !this.collapsed){
11792 var sh = this.split.el.getHeight();
11795 this.split.el.setLeft(box.x);
11796 this.split.el.setTop(box.y-sh);
11797 this.split.el.setWidth(box.width);
11799 if(this.collapsed){
11800 this.el.setWidth(box.width);
11801 var bodyWidth = box.width - this.el.getBorderWidth('rl');
11802 this.bodyEl.setWidth(bodyWidth);
11803 if(this.activePanel && this.panelSize){
11804 this.activePanel.setSize(bodyWidth, this.panelSize.height);
11807 YAHOO.ext.SouthLayoutRegion.superclass.updateBox.call(this, box);
11811 YAHOO.ext.EastLayoutRegion = function(mgr, config){
11812 YAHOO.ext.EastLayoutRegion.superclass.constructor.call(this, mgr, config, 'east', 'e-resize');
11814 this.split.placement = YAHOO.ext.SplitBar.RIGHT;
11815 this.split.orientation = YAHOO.ext.SplitBar.HORIZONTAL;
11816 this.split.el.addClass('ylayout-split-h');
11818 if(typeof config.initialSize != 'undefined'){
11819 this.el.setWidth(config.initialSize);
11822 YAHOO.extendX(YAHOO.ext.EastLayoutRegion, YAHOO.ext.SplitLayoutRegion, {
11823 getBox : function(){
11824 if(this.collapsed){
11825 return this.collapsedEl.getBox();
11827 var box = this.el.getBox();
11829 var sw = this.split.el.getWidth();
11836 updateBox : function(box){
11837 if(this.split && !this.collapsed){
11838 var sw = this.split.el.getWidth();
11840 this.split.el.setLeft(box.x);
11841 this.split.el.setTop(box.y);
11842 this.split.el.setHeight(box.height);
11845 if(this.collapsed){
11846 this.el.setHeight(box.height);
11847 var bodyHeight = this.config.titlebar ? box.height - (this.titleEl.getHeight()||0) : box.height;
11848 bodyHeight -= this.el.getBorderWidth('tb');
11849 this.bodyEl.setHeight(bodyHeight);
11850 if(this.activePanel && this.panelSize){
11851 this.activePanel.setSize(this.panelSize.width, bodyHeight);
11854 YAHOO.ext.EastLayoutRegion.superclass.updateBox.call(this, box);
11858 YAHOO.ext.WestLayoutRegion = function(mgr, config){
11859 YAHOO.ext.WestLayoutRegion.superclass.constructor.call(this, mgr, config, 'west', 'w-resize');
11861 this.split.placement = YAHOO.ext.SplitBar.LEFT;
11862 this.split.orientation = YAHOO.ext.SplitBar.HORIZONTAL;
11863 this.split.el.addClass('ylayout-split-h');
11865 if(typeof config.initialSize != 'undefined'){
11866 this.el.setWidth(config.initialSize);
11869 YAHOO.extendX(YAHOO.ext.WestLayoutRegion, YAHOO.ext.SplitLayoutRegion, {
11870 getBox : function(){
11871 if(this.collapsed){
11872 return this.collapsedEl.getBox();
11874 var box = this.el.getBox();
11876 box.width += this.split.el.getWidth();
11881 updateBox : function(box){
11882 if(this.split && !this.collapsed){
11883 var sw = this.split.el.getWidth();
11885 this.split.el.setLeft(box.x+box.width);
11886 this.split.el.setTop(box.y);
11887 this.split.el.setHeight(box.height);
11889 if(this.collapsed){
11890 this.el.setHeight(box.height);
11891 var bodyHeight = this.config.titlebar ? box.height - (this.titleEl.getHeight()||0) : box.height;
11892 bodyHeight -= this.el.getBorderWidth('tb');
11893 this.bodyEl.setHeight(bodyHeight);
11894 if(this.activePanel && this.panelSize){
11895 this.activePanel.setSize(this.panelSize.width, bodyHeight);
11898 YAHOO.ext.WestLayoutRegion.superclass.updateBox.call(this, box);
11903 YAHOO.ext.ContentPanel = function(el, config, content){
11904 YAHOO.ext.ContentPanel.superclass.constructor.call(this);
11905 this.el = getEl(el, true);
11906 if(!this.el && config && config.autoCreate){
11907 if(typeof config.autoCreate == 'object'){
11908 if(!config.autoCreate.id){
11909 config.autoCreate.id = el;
11911 this.el = YAHOO.ext.DomHelper.append(document.body,
11912 config.autoCreate, true);
11914 this.el = YAHOO.ext.DomHelper.append(document.body,
11915 {tag: 'div', cls: 'ylayout-inactive-content', id: el}, true);
11918 this.closable = false;
11919 this.loaded = false;
11920 this.active = false;
11921 if(typeof config == 'string'){
11922 this.title = config;
11924 YAHOO.ext.util.Config.apply(this, config);
11927 this.resizeEl = getEl(this.resizeEl, true);
11929 this.resizeEl = this.el;
11933 'activate' : new YAHOO.util.CustomEvent('activate'),
11935 'deactivate' : new YAHOO.util.CustomEvent('deactivate')
11937 if(this.autoScroll){
11938 this.el.setStyle('overflow', 'auto');
11941 this.setContent(content);
11945 YAHOO.extendX(YAHOO.ext.ContentPanel, YAHOO.ext.util.Observable, {
11946 setRegion : function(region){
11947 this.region = region;
11949 this.el.replaceClass('ylayout-inactive-content', 'ylayout-active-content');
11951 this.el.replaceClass('ylayout-active-content', 'ylayout-inactive-content');
11956 getToolbar : function(){
11957 return this.toolbar;
11960 setActiveState : function(active){
11961 this.active = active;
11963 this.fireEvent('deactivate', this);
11965 this.fireEvent('activate', this);
11969 setContent : function(content, loadScripts){
11970 this.el.update(content, loadScripts);
11974 getUpdateManager : function(){
11975 return this.el.getUpdateManager();
11979 setUrl : function(url, params, loadOnce){
11980 if(this.refreshDelegate){
11981 this.removeListener('activate', this.refreshDelegate);
11983 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
11984 this.on('activate', this._handleRefresh.createDelegate(this, [url, params, loadOnce]));
11985 return this.el.getUpdateManager();
11988 _handleRefresh : function(url, params, loadOnce){
11989 if(!loadOnce || !this.loaded){
11990 var updater = this.el.getUpdateManager();
11991 updater.update(url, params, this._setLoaded.createDelegate(this));
11995 _setLoaded : function(){
11996 this.loaded = true;
12000 getId : function(){
12005 getEl : function(){
12009 adjustForComponents : function(width, height){
12011 var te = this.toolbar.getEl();
12012 height -= te.getHeight();
12013 te.setWidth(width);
12015 if(this.adjustments){
12016 width += this.adjustments[0];
12017 height += this.adjustments[1];
12019 return {'width': width, 'height': height};
12022 setSize : function(width, height){
12023 if(this.fitToFrame){
12024 var size = this.adjustForComponents(width, height);
12025 this.resizeEl.setSize(this.autoWidth ? 'auto' : size.width, size.height);
12030 getTitle : function(){
12035 setTitle : function(title){
12036 this.title = title;
12038 this.region.updatePanelTitle(this, title);
12043 isClosable : function(){
12044 return this.closable;
12047 beforeSlide : function(){
12049 this.resizeEl.clip();
12052 afterSlide : function(){
12054 this.resizeEl.unclip();
12058 refresh : function(){
12059 if(this.refreshDelegate){
12060 this.loaded = false;
12061 this.refreshDelegate();
12066 destroy : function(){
12067 this.el.removeAllListeners();
12068 var tempEl = document.createElement('span');
12069 tempEl.appendChild(this.el.dom);
12070 tempEl.innerHTML = '';
12076 YAHOO.ext.GridPanel = function(grid, config){
12077 this.wrapper = YAHOO.ext.DomHelper.append(document.body,
12078 {tag: 'div', cls: 'ylayout-grid-wrapper ylayout-inactive-content'}, true);
12079 this.wrapper.dom.appendChild(grid.container.dom);
12080 YAHOO.ext.GridPanel.superclass.constructor.call(this, this.wrapper, config);
12082 this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
12084 grid.monitorWindowResize = false;
12085 grid.autoHeight = false;
12086 grid.autoWidth = false;
12088 this.grid.container.replaceClass('ylayout-inactive-content', 'ylayout-component-panel');
12091 YAHOO.extendX(YAHOO.ext.GridPanel, YAHOO.ext.ContentPanel, {
12092 getId : function(){
12093 return this.grid.id;
12097 getGrid : function(){
12101 setSize : function(width, height){
12102 var grid = this.grid;
12103 var size = this.adjustForComponents(width, height);
12104 grid.container.setSize(size.width, size.height);
12108 beforeSlide : function(){
12109 this.grid.getView().wrapEl.clip();
12112 afterSlide : function(){
12113 this.grid.getView().wrapEl.unclip();
12116 destroy : function(){
12117 this.grid.getView().unplugDataModel(this.grid.getDataModel());
12118 this.grid.container.removeAllListeners();
12119 YAHOO.ext.GridPanel.superclass.destroy.call(this);
12125 YAHOO.ext.NestedLayoutPanel = function(layout, config){
12126 YAHOO.ext.NestedLayoutPanel.superclass.constructor.call(this, layout.getEl(), config);
12127 layout.monitorWindowResize = false;
12128 this.layout = layout;
12129 this.layout.getEl().addClass('ylayout-nested-layout');
12132 YAHOO.extendX(YAHOO.ext.NestedLayoutPanel, YAHOO.ext.ContentPanel, {
12133 setSize : function(width, height){
12134 var size = this.adjustForComponents(width, height);
12135 this.layout.getEl().setSize(size.width, size.height);
12136 this.layout.layout();
12140 getLayout : function(){
12141 return this.layout;
12145 YAHOO.ext.LayoutStateManager = function(layout){
12155 YAHOO.ext.LayoutStateManager.prototype = {
12156 init : function(layout, provider){
12157 this.provider = provider;
12158 var state = provider.get(layout.id+'-layout-state');
12160 var wasUpdating = layout.isUpdating();
12162 layout.beginUpdate();
12164 for(var key in state){
12165 if(typeof state[key] != 'function'){
12166 var rstate = state[key];
12167 var r = layout.getRegion(key);
12170 r.resizeTo(rstate.size);
12172 if(rstate.collapsed == true){
12175 r.expand(null, true);
12181 layout.endUpdate();
12183 this.state = state;
12185 this.layout = layout;
12186 layout.on('regionresized', this.onRegionResized, this, true);
12187 layout.on('regioncollapsed', this.onRegionCollapsed, this, true);
12188 layout.on('regionexpanded', this.onRegionExpanded, this, true);
12191 storeState : function(){
12192 this.provider.set(this.layout.id+'-layout-state', this.state);
12195 onRegionResized : function(region, newSize){
12196 this.state[region.getPosition()].size = newSize;
12200 onRegionCollapsed : function(region){
12201 this.state[region.getPosition()].collapsed = true;
12205 onRegionExpanded : function(region){
12206 this.state[region.getPosition()].collapsed = false;
12211 YAHOO.ext.BasicDialog = function(el, config){
12212 this.el = getEl(el);
12213 var dh = YAHOO.ext.DomHelper;
12214 if(!this.el && config && config.autoCreate){
12215 if(typeof config.autoCreate == 'object'){
12216 if(!config.autoCreate.id){
12217 config.autoCreate.id = el;
12219 this.el = dh.append(document.body,
12220 config.autoCreate, true);
12222 this.el = dh.append(document.body,
12223 {tag: 'div', id: el}, true);
12227 el.setDisplayed(true);
12228 el.hide = this.hideAction;
12230 el.addClass('ydlg');
12231 this.shadowOffset = 3;
12232 this.minHeight = 80;
12233 this.minWidth = 200;
12234 this.minButtonWidth = 75;
12235 this.defaultButton = null;
12237 YAHOO.ext.util.Config.apply(this, config);
12239 this.proxy = el.createProxy('ydlg-proxy');
12240 this.proxy.hide = this.hideAction;
12241 this.proxy.setOpacity(.5);
12245 el.setWidth(config.width);
12248 el.setHeight(config.height);
12250 this.size = el.getSize();
12251 if(typeof config.x != 'undefined' && typeof config.y != 'undefined'){
12252 this.xy = [config.x,config.y];
12254 this.xy = el.getCenterXY(true);
12257 var cn = el.dom.childNodes;
12258 for(var i = 0, len = cn.length; i < len; i++) {
12260 if(node && node.nodeType == 1){
12261 if(YAHOO.util.Dom.hasClass(node, 'ydlg-hd')){
12262 this.header = getEl(node, true);
12263 }else if(YAHOO.util.Dom.hasClass(node, 'ydlg-bd')){
12264 this.body = getEl(node, true);
12265 }else if(YAHOO.util.Dom.hasClass(node, 'ydlg-ft')){
12267 this.footer = getEl(node, true);
12274 this.header = dh.append(el.dom, {tag: 'div', cls:'ydlg-hd'}, true);
12277 this.header.update(this.title);
12281 this.body = dh.append(el.dom, {tag: 'div', cls:'ydlg-bd'}, true);
12284 var hl = dh.insertBefore(this.header.dom, {tag: 'div', cls:'ydlg-hd-left'});
12285 var hr = dh.append(hl, {tag: 'div', cls:'ydlg-hd-right'});
12286 hr.appendChild(this.header.dom);
12289 this.bwrap = dh.insertBefore(this.body.dom, {tag: 'div', cls:'ydlg-dlg-body'}, true);
12290 this.bwrap.dom.appendChild(this.body.dom);
12291 if(this.footer) this.bwrap.dom.appendChild(this.footer.dom);
12293 if(this.autoScroll !== false && !this.autoTabs){
12294 this.body.setStyle('overflow', 'auto');
12296 if(this.closable !== false){
12297 this.el.addClass('ydlg-closable');
12298 this.close = dh.append(el.dom, {tag: 'div', cls:'ydlg-close'}, true);
12299 this.close.mon('click', function(){
12303 if(this.resizable !== false){
12304 this.el.addClass('ydlg-resizable');
12305 this.resizer = new YAHOO.ext.Resizable(el, {
12306 minWidth: this.minWidth || 80,
12307 minHeight:this.minHeight || 80,
12311 this.resizer.on('beforeresize', this.beforeResize, this, true);
12312 this.resizer.on('resize', this.onResize, this, true);
12314 if(this.draggable !== false){
12315 el.addClass('ydlg-draggable');
12316 if (!this.proxyDrag) {
12317 var dd = new YAHOO.util.DD(el.dom.id, 'WindowDrag');
12320 var dd = new YAHOO.util.DDProxy(el.dom.id, 'WindowDrag', {dragElId: this.proxy.id});
12322 dd.setHandleElId(this.header.id);
12323 dd.endDrag = this.endMove.createDelegate(this);
12324 dd.startDrag = this.startMove.createDelegate(this);
12325 dd.onDrag = this.onDrag.createDelegate(this);
12329 this.mask = dh.append(document.body, {tag: 'div', cls:'ydlg-mask'}, true);
12330 this.mask.enableDisplayMode('block');
12334 this.shadow = el.createProxy({tag: 'div', cls:'ydlg-shadow'});
12335 this.shadow.setOpacity(.3);
12336 this.shadow.setVisibilityMode(YAHOO.ext.Element.VISIBILITY);
12337 this.shadow.setDisplayed('block');
12338 this.shadow.hide = this.hideAction;
12339 this.shadow.hide();
12341 this.shadowOffset = 0;
12344 this.shim = this.el.createShim();
12345 this.shim.hide = this.hideAction;
12349 var tabEls = YAHOO.util.Dom.getElementsByClassName('ydlg-tab', this.tabTag || 'div', el.dom);
12350 if(tabEls.length > 0){
12351 this.body.addClass(this.tabPosition == 'bottom' ? 'ytabs-bottom' : 'ytabs-top');
12352 this.tabs = new YAHOO.ext.TabPanel(this.body.dom, this.tabPosition == 'bottom');
12353 for(var i = 0, len = tabEls.length; i < len; i++) {
12354 var tabEl = tabEls[i];
12355 this.tabs.addTab(YAHOO.util.Dom.generateId(tabEl), tabEl.title);
12358 this.tabs.activate(tabEls[0].id);
12361 this.syncBodyHeight();
12370 'beforehide' : true,
12374 'beforeshow' : true,
12378 el.mon('keydown', this.onKeyDown, this, true);
12379 el.mon("mousedown", this.toFront, this, true);
12381 YAHOO.ext.EventManager.onWindowResize(this.adjustViewport, this, true);
12383 YAHOO.ext.DialogManager.register(this);
12386 YAHOO.extendX(YAHOO.ext.BasicDialog, YAHOO.ext.util.Observable, {
12388 setTitle : function(text){
12389 this.header.update(text);
12393 beforeResize : function(){
12394 this.resizer.minHeight = Math.max(this.minHeight, this.getHeaderFooterHeight(true)+40);
12397 onResize : function(){
12398 this.refreshSize();
12399 this.syncBodyHeight();
12400 this.adjustAssets();
12401 this.fireEvent('resize', this, this.size.width, this.size.height);
12404 onKeyDown : function(e){
12405 this.fireEvent('keydown', this, e);
12409 resizeTo : function(width, height){
12410 this.el.setSize(width, height);
12411 this.size = {width: width, height: height};
12412 this.syncBodyHeight();
12413 if(this.fixedcenter){
12416 if(this.isVisible()){
12417 this.constrainXY();
12418 this.adjustAssets();
12420 this.fireEvent('resize', this, width, height);
12425 addKeyListener : function(key, fn, scope){
12426 var keyCode, shift, ctrl, alt;
12427 if(typeof key == 'object' && !(key instanceof Array)){
12428 keyCode = key['key'];
12429 shift = key['shift'];
12430 ctrl = key['ctrl'];
12435 var handler = function(dlg, e){
12436 if((!shift || e.shiftKey) && (!ctrl || e.ctrlKey) && (!alt || e.altKey)){
12437 var k = e.getKey();
12438 if(keyCode instanceof Array){
12439 for(var i = 0, len = keyCode.length; i < len; i++){
12440 if(keyCode[i] == k){
12441 fn.call(scope || window, dlg, k, e);
12447 fn.call(scope || window, dlg, k, e);
12452 this.on('keydown', handler);
12457 getTabs : function(){
12459 this.body.addClass(this.tabPosition == 'bottom' ? 'ytabs-bottom' : 'ytabs-top');
12460 this.tabs = new YAHOO.ext.TabPanel(this.body.dom, this.tabPosition == 'bottom');
12466 addButton : function(config, handler, scope){
12467 var dh = YAHOO.ext.DomHelper;
12469 this.footer = dh.append(this.bwrap.dom, {tag: 'div', cls:'ydlg-ft'}, true);
12474 minWidth: this.minButtonWidth
12476 if(typeof config == 'string'){
12477 bconfig.text = config;
12479 bconfig.dhconfig = config;
12481 var btn = new YAHOO.ext.Button(this.footer, bconfig);
12482 this.syncBodyHeight();
12486 this.buttons.push(btn);
12491 setDefaultButton : function(btn){
12492 this.defaultButton = btn;
12496 getHeaderFooterHeight : function(safe){
12499 height += this.header.getHeight();
12502 var fm = this.footer.getMargins();
12503 height += (this.footer.getHeight()+fm.top+fm.bottom);
12505 height += this.bwrap.getPadding('tb')+this.bwrap.getBorderWidth('tb');
12509 syncBodyHeight : function(){
12510 var height = this.size.height - this.getHeaderFooterHeight(false);
12511 var bm = this.body.getMargins();
12512 this.body.setHeight(height-(bm.top+bm.bottom));
12514 this.tabs.syncHeight();
12516 this.bwrap.setHeight(this.size.height-this.header.getHeight());
12518 this.body.setWidth(this.el.getWidth(true)-this.bwrap.getBorderWidth('lr')-this.bwrap.getPadding('lr'));
12522 restoreState : function(){
12523 var box = YAHOO.ext.state.Manager.get(this.el.id + '-state');
12524 if(box && box.width){
12525 this.xy = [box.x, box.y];
12526 this.resizeTo(box.width, box.height);
12531 beforeShow : function(){
12532 if(this.fixedcenter) {
12533 this.xy = this.el.getCenterXY(true);
12536 YAHOO.util.Dom.addClass(document.body, 'masked');
12537 this.mask.setSize(YAHOO.util.Dom.getDocumentWidth(), YAHOO.util.Dom.getDocumentHeight());
12540 this.constrainXY();
12543 animShow : function(){
12544 var b = getEl(this.animateTarget, true).getBox();
12545 this.proxy.setSize(b.width, b.height);
12546 this.proxy.setLocation(b.x, b.y);
12548 this.proxy.setBounds(this.xy[0], this.xy[1], this.size.width, this.size.height,
12549 true, .35, this.showEl.createDelegate(this));
12553 show : function(animateTarget){
12554 if (this.fireEvent('beforeshow', this) === false){
12557 if(this.syncHeightBeforeShow){
12558 this.syncBodyHeight();
12560 this.animateTarget = animateTarget || this.animateTarget;
12561 if(!this.el.isVisible()){
12563 if(this.animateTarget){
12572 showEl : function(){
12574 this.el.setXY(this.xy);
12576 this.adjustAssets(true);
12578 if(this.defaultButton){
12579 this.defaultButton.focus();
12581 this.fireEvent('show', this);
12584 constrainXY : function(){
12585 if(this.constraintoviewport !== false){
12586 if(!this.viewSize){
12587 this.viewSize = [YAHOO.util.Dom.getViewportWidth(), YAHOO.util.Dom.getViewportHeight()];
12589 var x = this.xy[0], y = this.xy[1];
12590 var w = this.size.width, h = this.size.height;
12591 var vw = this.viewSize[0], vh = this.viewSize[1];
12615 if(this.isVisible()){
12616 this.el.setLocation(x, y);
12617 this.adjustAssets();
12623 onDrag : function(){
12624 if(!this.proxyDrag){
12625 this.xy = this.el.getXY();
12626 this.adjustAssets();
12630 adjustAssets : function(doShow){
12631 var x = this.xy[0], y = this.xy[1];
12632 var w = this.size.width, h = this.size.height;
12633 if(doShow === true){
12635 this.shadow.show();
12641 if(this.shadow && this.shadow.isVisible()){
12642 this.shadow.setBounds(x + this.shadowOffset, y + this.shadowOffset, w, h);
12644 if(this.shim && this.shim.isVisible()){
12645 this.shim.setBounds(x, y, w, h);
12650 adjustViewport : function(w, h){
12652 w = YAHOO.util.Dom.getViewportWidth();
12653 h = YAHOO.util.Dom.getViewportHeight();
12656 this.viewSize = [w, h];
12657 if(this.modal && this.mask.isVisible()){
12658 this.mask.setSize(w, h);
12659 this.mask.setSize(YAHOO.util.Dom.getDocumentWidth(), YAHOO.util.Dom.getDocumentHeight());
12661 if(this.isVisible()){
12662 this.constrainXY();
12667 destroy : function(removeEl){
12668 YAHOO.ext.EventManager.removeResizeListener(this.adjustViewport, this);
12670 this.tabs.destroy(removeEl);
12672 if(removeEl === true){
12673 this.el.update('');
12676 YAHOO.ext.DialogManager.unregister(this);
12679 startMove : function(){
12680 if(this.proxyDrag){
12683 if(this.constraintoviewport !== false){
12684 this.dd.constrainTo(document.body, {right: this.shadowOffset, bottom: this.shadowOffset});
12688 endMove : function(){
12689 if(!this.proxyDrag){
12690 YAHOO.util.DD.prototype.endDrag.apply(this.dd, arguments);
12692 YAHOO.util.DDProxy.prototype.endDrag.apply(this.dd, arguments);
12695 this.refreshSize();
12696 this.adjustAssets();
12697 this.fireEvent('move', this, this.xy[0], this.xy[1])
12701 toFront : function(){
12702 YAHOO.ext.DialogManager.bringToFront(this);
12707 toBack : function(){
12708 YAHOO.ext.DialogManager.sendToBack(this);
12713 center : function(){
12714 this.moveTo(this.el.getCenterXY(true));
12719 moveTo : function(x, y){
12721 if(this.isVisible()){
12722 this.el.setXY(this.xy);
12723 this.adjustAssets();
12729 isVisible : function(){
12730 return this.el.isVisible();
12733 animHide : function(callback){
12734 var b = getEl(this.animateTarget, true).getBox();
12736 this.proxy.setBounds(this.xy[0], this.xy[1], this.size.width, this.size.height);
12738 this.proxy.setBounds(b.x, b.y, b.width, b.height, true, .35,
12739 this.hideEl.createDelegate(this, [callback]));
12743 hide : function(callback){
12744 if (this.fireEvent('beforehide', this) === false)
12748 this.shadow.hide();
12753 if(this.animateTarget){
12754 this.animHide(callback);
12757 this.hideEl(callback);
12762 hideEl : function(callback){
12766 YAHOO.util.Dom.removeClass(document.body, 'masked');
12768 this.fireEvent('hide', this);
12769 if(typeof callback == 'function'){
12774 hideAction : function(){
12775 this.setLeft('-10000px');
12776 this.setTop('-10000px');
12777 this.setStyle('visibility', 'hidden');
12780 refreshSize : function(){
12781 this.size = this.el.getSize();
12782 this.xy = this.el.getXY();
12783 YAHOO.ext.state.Manager.set(this.el.id + '-state', this.el.getBox());
12786 setZIndex : function(index){
12788 this.mask.setStyle('z-index', index);
12791 this.shadow.setStyle('z-index', ++index);
12794 this.shim.setStyle('z-index', ++index);
12796 this.el.setStyle('z-index', ++index);
12798 this.proxy.setStyle('z-index', ++index);
12801 this.resizer.proxy.setStyle('z-index', ++index);
12804 this.lastZIndex = index;
12808 getEl : function(){
12814 YAHOO.ext.DialogManager = function(){
12816 var accessList = [];
12819 var sortDialogs = function(d1, d2){
12820 return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
12823 var orderDialogs = function(){
12824 accessList.sort(sortDialogs);
12825 var seed = YAHOO.ext.DialogManager.zseed;
12826 for(var i = 0, len = accessList.length; i < len; i++){
12828 accessList[i].setZIndex(seed + (i*10));
12838 register : function(dlg){
12839 list[dlg.id] = dlg;
12840 accessList.push(dlg);
12843 unregister : function(dlg){
12844 delete list[dlg.id];
12845 if(!accessList.indexOf){
12846 for(var i = 0, len = accessList.length; i < len; i++){
12847 accessList.splice(i, 1);
12851 var i = accessList.indexOf(dlg);
12853 accessList.splice(i, 1);
12859 get : function(id){
12860 return typeof id == 'object' ? id : list[id];
12864 bringToFront : function(dlg){
12865 dlg = this.get(dlg);
12868 dlg._lastAccess = new Date().getTime();
12875 sendToBack : function(dlg){
12876 dlg = this.get(dlg);
12877 dlg._lastAccess = -(new Date().getTime());
12885 YAHOO.ext.LayoutDialog = function(el, config){
12886 config.autoTabs = false;
12887 YAHOO.ext.LayoutDialog.superclass.constructor.call(this, el, config);
12888 this.body.setStyle({overflow:'hidden', position:'relative'});
12889 this.layout = new YAHOO.ext.BorderLayout(this.body.dom, config);
12890 this.layout.monitorWindowResize = false;
12892 this.center = YAHOO.ext.BasicDialog.prototype.center;
12893 this.on('show', this.layout.layout, this.layout, true);
12895 YAHOO.extendX(YAHOO.ext.LayoutDialog, YAHOO.ext.BasicDialog, {
12897 endUpdate : function(){
12898 this.layout.endUpdate();
12901 beginUpdate : function(){
12902 this.layout.beginUpdate();
12905 getLayout : function(){
12906 return this.layout;
12908 syncBodyHeight : function(){
12909 YAHOO.ext.LayoutDialog.superclass.syncBodyHeight.call(this);
12910 if(this.layout)this.layout.layout();
12914 YAHOO.ext.Button = function(renderTo, config){
12915 YAHOO.ext.util.Config.apply(this, config);
12921 this.render(renderTo);
12925 YAHOO.extendX(YAHOO.ext.Button, YAHOO.ext.util.Observable, {
12926 render : function(renderTo){
12928 if(!this.dhconfig){
12929 if(!YAHOO.ext.Button.buttonTemplate){
12931 YAHOO.ext.Button.buttonTemplate = new YAHOO.ext.DomHelper.Template('<a href="#" class="ybtn-focus"><table border="0" cellpadding="0" cellspacing="0" class="ybtn-wrap"><tbody><tr><td class="ybtn-left"> </td><td class="ybtn-center" unselectable="on">{0}</td><td class="ybtn-right"> </td></tr></tbody></table></a>');
12933 btn = YAHOO.ext.Button.buttonTemplate.append(
12934 getEl(renderTo).dom, [this.text], true);
12935 this.tbl = getEl(btn.dom.firstChild, true);
12937 btn = YAHOO.ext.DomHelper.append(this.footer.dom, this.dhconfig, true);
12941 btn.addClass('ybtn');
12942 btn.mon('click', this.onClick, this, true);
12943 btn.on('mouseover', this.onMouseOver, this, true);
12944 btn.on('mouseout', this.onMouseOut, this, true);
12945 btn.on('mousedown', this.onMouseDown, this, true);
12946 btn.on('mouseup', this.onMouseUp, this, true);
12949 getEl : function(){
12953 autoWidth : function(){
12955 this.el.setWidth('auto');
12956 this.tbl.setWidth('auto');
12958 if(this.tbl.getWidth() < this.minWidth){
12959 this.tbl.setWidth(this.minWidth);
12962 this.el.setWidth(this.tbl.getWidth());
12966 setHandler : function(handler, scope){
12967 this.handler = handler;
12968 this.scope = scope;
12972 setText : function(text){
12973 this.el.dom.firstChild.firstChild.firstChild.childNodes[1].innerHTML = text;
12979 this.el.setStyle('display', '');
12984 this.el.setStyle('display', 'none');
12988 setVisible: function(visible){
12997 focus : function(){
13002 disable : function(){
13003 this.el.addClass('ybtn-disabled');
13004 this.disabled = true;
13008 enable : function(){
13009 this.el.removeClass('ybtn-disabled');
13010 this.disabled = false;
13013 onClick : function(e){
13014 e.preventDefault();
13015 if(!this.disabled){
13016 this.fireEvent('click', this, e);
13017 this.handler.call(this.scope || window, this, e);
13020 onMouseOver : function(e){
13021 if(!this.disabled){
13022 this.el.addClass('ybtn-over');
13025 onMouseOut : function(e){
13026 this.el.removeClass('ybtn-over');
13028 onMouseDown : function(){
13029 if(!this.disabled){
13030 this.el.addClass('ybtn-click');
13033 onMouseUp : function(){
13034 this.el.removeClass('ybtn-click');
13038 YAHOO.ext.View = function(container, tpl, dataModel, config){
13039 this.el = getEl(container, true);
13040 this.nodes = this.el.dom.childNodes;
13041 if(typeof tpl == 'string'){
13042 tpl = new YAHOO.ext.Template(tpl);
13047 this.setDataModel(dataModel);
13048 var CE = YAHOO.util.CustomEvent;
13056 'contextmenu' : true,
13058 'selectionchange' : true,
13061 'beforeselect' : true
13063 this.el.mon("click", this.onClick, this, true);
13064 this.el.mon("dblclick", this.onDblClick, this, true);
13065 this.el.mon("contextmenu", this.onContextMenu, this, true);
13068 this.selectedClass = 'ydataview-selected';
13070 this.emptyText = '';
13072 this.selections = [];
13073 this.lastSelection = null;
13076 this.jsonRoot = null;
13077 YAHOO.ext.util.Config.apply(this, config);
13078 if(this.renderUpdates || this.jsonRoot){
13079 var um = this.el.getUpdateManager();
13080 um.setRenderer(this);
13084 YAHOO.extendX(YAHOO.ext.View, YAHOO.ext.util.Observable, {
13086 getEl : function(){
13090 render : function(el, response){
13091 this.clearSelections();
13092 this.el.update('');
13095 o = YAHOO.ext.util.JSON.decode(response.responseText);
13097 o = eval('o.' + this.jsonRoot);
13102 this.beforeRender();
13106 beforeRender : function(){
13111 refresh : function(){
13112 this.clearSelections();
13113 this.el.update('');
13115 if(this.renderUpdates || this.jsonRoot){
13116 var o = this.jsonData;
13118 for(var i = 0, len = o.length; i < len; i++) {
13119 this.renderEach(o[i]);
13123 this.dataModel.each(this.renderEach, this);
13126 if(this.html.length > 0){
13127 strHtml = this.html.join('');
13129 strHtml = this.emptyText;
13131 this.el.update(strHtml);
13133 this.nodes = this.el.dom.childNodes;
13134 this.updateIndexes(0);
13138 prepareData : function(data, index){
13142 renderEach : function(data){
13143 this.html[this.html.length] = this.tpl.applyTemplate(this.prepareData(data));
13147 refreshNode : function(index){
13148 this.refreshNodes(index, index);
13151 refreshNodes : function(dm, startIndex, endIndex){
13152 this.clearSelections();
13153 var dm = this.dataModel;
13154 var ns = this.nodes;
13155 for(var i = startIndex; i <= endIndex; i++){
13156 var d = this.prepareData(dm.getRow(i), i);
13157 if(i < ns.length-1){
13159 this.tpl.insertBefore(old, d);
13160 this.el.dom.removeChild(old);
13162 this.tpl.append(this.el.dom, d);
13165 this.updateIndexes(startIndex, endIndex);
13168 deleteNodes : function(dm, startIndex, endIndex){
13169 this.clearSelections();
13170 if(startIndex == 0 && endIndex >= this.nodes.length-1){
13171 this.el.update('');
13173 var el = this.el.dom;
13174 for(var i = startIndex; i <= endIndex; i++){
13175 el.removeChild(this.nodes[startIndex]);
13177 this.updateIndexes(startIndex);
13181 insertNodes : function(dm, startIndex, endIndex){
13182 if(this.nodes.length == 0){
13185 this.clearSelections();
13187 var before = this.nodes[startIndex];
13188 var dm = this.dataModel;
13190 for(var i = startIndex; i <= endIndex; i++){
13191 t.insertBefore(before, this.prepareData(dm.getRow(i), i));
13194 var el = this.el.dom;
13195 for(var i = startIndex; i <= endIndex; i++){
13196 t.append(el, this.prepareData(dm.getRow(i), i));
13199 this.updateIndexes(startIndex);
13203 updateIndexes : function(dm, startIndex, endIndex){
13204 var ns = this.nodes;
13205 startIndex = startIndex || 0;
13206 endIndex = endIndex || ns.length-1;
13207 for(var i = startIndex; i <= endIndex; i++){
13208 ns[i].nodeIndex = i;
13213 setDataModel : function(dm){
13215 this.unplugDataModel(this.dataModel);
13216 this.dataModel = dm;
13217 dm.on('cellupdated', this.refreshNode, this, true);
13218 dm.on('datachanged', this.refresh, this, true);
13219 dm.on('rowsdeleted', this.deleteNodes, this, true);
13220 dm.on('rowsinserted', this.insertNodes, this, true);
13221 dm.on('rowsupdated', this.refreshNodes, this, true);
13222 dm.on('rowssorted', this.refresh, this, true);
13227 unplugDataModel : function(dm){
13229 dm.removeListener('cellupdated', this.refreshNode, this);
13230 dm.removeListener('datachanged', this.refresh, this);
13231 dm.removeListener('rowsdeleted', this.deleteNodes, this);
13232 dm.removeListener('rowsinserted', this.insertNodes, this);
13233 dm.removeListener('rowsupdated', this.refreshNodes, this);
13234 dm.removeListener('rowssorted', this.refresh, this);
13235 this.dataModel = null;
13239 findItemFromChild : function(node){
13240 var el = this.el.dom;
13241 if(!node || node.parentNode == el){
13244 var p = node.parentNode;
13245 while(p && p != el){
13246 if(p.parentNode == el){
13255 onClick : function(e){
13256 var item = this.findItemFromChild(e.getTarget());
13258 var index = this.indexOf(item);
13259 this.onItemClick(item, index, e);
13260 this.fireEvent('click', this, index, item, e);
13262 this.clearSelections();
13267 onContextMenu : function(e){
13268 var item = this.findItemFromChild(e.getTarget());
13270 this.fireEvent('contextmenu', this, this.indexOf(item), item, e);
13275 onDblClick : function(e){
13276 var item = this.findItemFromChild(e.getTarget());
13278 this.fireEvent('dblclick', this, this.indexOf(item), item, e);
13282 onItemClick : function(item, index, e){
13283 if(this.multiSelect || this.singleSelect){
13284 if(this.multiSelect && e.shiftKey && this.lastSelection){
13285 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
13287 this.select(item, this.multiSelect && e.ctrlKey);
13288 this.lastSelection = item;
13294 getSelectionCount : function(){
13295 return this.selections.length;
13299 getSelectedNodes : function(){
13300 return this.selections;
13304 getSelectedIndexes : function(){
13306 for(var i = 0, len = this.selections.length; i < len; i++) {
13307 indexes.push(this.selections[i].nodeIndex);
13313 clearSelections : function(suppressEvent){
13314 if(this.multiSelect || this.singleSelect){
13315 YAHOO.util.Dom.removeClass(this.selections, this.selectedClass);
13316 this.selections = [];
13317 if(!suppressEvent){
13318 this.fireEvent('selectionchange', this, this.selections);
13324 select : function(nodeInfo, keepExisting, suppressEvent){
13326 this.clearSelections(true);
13328 if(nodeInfo instanceof Array){
13329 for(var i = 0, len = nodeInfo.length; i < len; i++) {
13330 this.select(nodeInfo[i], true, true);
13333 var node = this.getNode(nodeInfo);
13335 if(this.fireEvent('beforeselect', this, node, this.selections) !== false){
13336 YAHOO.util.Dom.addClass(node, this.selectedClass);
13337 this.selections.push(node);
13341 if(!suppressEvent){
13342 this.fireEvent('selectionchange', this, this.selections);
13347 getNode : function(nodeInfo){
13348 if(typeof nodeInfo == 'object'){
13350 }else if(typeof nodeInfo == 'string'){
13351 return document.getElementById(nodeInfo);
13352 }else if(typeof nodeInfo == 'number'){
13353 return this.nodes[nodeInfo];
13359 getNodes : function(start, end){
13360 var ns = this.nodes;
13361 startIndex = startIndex || 0;
13362 endIndex = typeof endIndex == 'undefined' ? ns.length-1 : endIndex;
13364 for(var i = start; i <= end; i++) {
13371 indexOf : function(node){
13372 node = this.getNode(node);
13373 if(typeof node.nodeIndex == 'number'){
13374 return node.nodeIndex;
13376 var ns = this.nodes;
13377 for(var i = 0, len = ns.length; i < len; i++) {
13387 YAHOO.ext.JsonView = function(container, tpl, config){
13388 var cfg = config || {};
13389 cfg.renderUpdates = true;
13390 YAHOO.ext.JsonView.superclass.constructor.call(this, container, tpl, null, cfg);
13392 this.events['beforerender'] = true;
13394 this.events['load'] = true;
13396 this.events['loadexception'] = true;
13397 this.el.getUpdateManager().on('update', this.onLoad, this, true);
13398 this.el.getUpdateManager().on('failure', this.onLoadException, this, true);
13400 YAHOO.extendX(YAHOO.ext.JsonView, YAHOO.ext.View, {
13403 var um = this.el.getUpdateManager();
13404 um.update.apply(um, arguments);
13408 getCount : function(){
13409 return this.jsonData ? this.jsonData.length : 0;
13412 beforeRender : function(){
13413 this.snapshot = this.jsonData;
13415 this.sort.apply(this, this.sortInfo);
13417 this.fireEvent('beforerender', this, this.jsonData);
13420 onLoad : function(el, o){
13421 this.fireEvent('load', this, this.jsonData, o);
13424 onLoadException : function(el, o){
13425 this.fireEvent('loadexception', this, o);
13429 filter : function(property, value){
13432 var ss = this.snapshot;
13433 if(typeof value == 'string'){
13434 var vlen = value.length;
13436 this.clearFilter();
13439 for(var i = 0, len = ss.length; i < len; i++){
13441 if(o[property].substr(0, vlen) == value){
13445 }else if(value.exec){
13446 for(var i = 0, len = ss.length; i < len; i++){
13448 if(value.test(o[property])){
13455 this.jsonData = data;
13461 filterBy : function(fn, scope){
13464 var ss = this.snapshot;
13465 for(var i = 0, len = ss.length; i < len; i++){
13467 if(fn.call(scope|| this, o)){
13471 this.jsonData = data;
13477 clearFilter : function(){
13478 if(this.snapshot && this.jsonData != this.snapshot){
13479 this.jsonData = this.snapshot;
13486 sort : function(property, dir, sortType){
13487 this.sortInfo = Array.prototype.slice.call(arguments, 0);
13490 var dsc = dir && dir.toLowerCase() == 'desc';
13491 var f = function(o1, o2){
13492 var v1 = sortType ? sortType(o1[p]) : o1[p];
13493 var v2 = sortType ? sortType(o2[p]) : o2[p];;
13495 return dsc ? +1 : -1;
13497 return dsc ? -1 : +1;
13502 this.jsonData.sort(f);
13504 if(this.jsonData != this.snapshot){
13505 this.snapshot.sort(f);