fixed the resizable text area with IE problem fixed the ad space with IE problem merged the 7.2.0 and 7.1.4 change logs
479 lines
175 KiB
JavaScript
479 lines
175 KiB
JavaScript
/*
|
|
* YUI Extensions
|
|
* Copyright(c) 2006, Jack Slocum.
|
|
*
|
|
* This code is licensed under BSD license.
|
|
* http://www.opensource.org/licenses/bsd-license.php
|
|
*/
|
|
|
|
|
|
YAHOO.namespace('ext');YAHOO.namespace('ext.util');YAHOO.ext.Strict=(document.compatMode=='CSS1Compat');Function.prototype.createCallback=function(){var args=arguments;var method=this;return function(){return method.apply(window,args);}};Function.prototype.createDelegate=function(obj,args,appendArgs){var method=this;return function(){var callargs=args||arguments;if(appendArgs){callargs=Array.prototype.concat.apply(arguments,args);}
|
|
return method.apply(obj||window,callargs);}};Function.prototype.createSequence=function(fcn,scope){if(typeof fcn!='function'){return this;}
|
|
var method=this;return function(){var retval=method.apply(this||window,arguments);fcn.apply(scope||this||window,arguments);return retval;}};Function.prototype.createInterceptor=function(fcn,scope){if(typeof fcn!='function'){return this;}
|
|
var method=this;return function(){fcn.target=this;fcn.method=method;if(fcn.apply(scope||this||window,arguments)===false)
|
|
return;return method.apply(this||window,arguments);;}};YAHOO.ext.util.Browser=new function(){var ua=navigator.userAgent.toLowerCase();this.isOpera=(ua.indexOf('opera')>-1);this.isSafari=(ua.indexOf('webkit')>-1);this.isIE=(window.ActiveXObject);this.isIE7=(ua.indexOf('msie 7')>-1);this.isGecko=!this.isSafari&&(ua.indexOf('gecko')>-1);}();YAHOO.util.CustomEvent.prototype.fireDirect=function(){var len=this.subscribers.length;for(var i=0;i<len;++i){var s=this.subscribers[i];if(s){var scope=(s.override)?s.obj:this.scope;if(s.fn.apply(scope,arguments)===false){return false;}}}
|
|
return true;};YAHOO.extendX=function(subclass,superclass,overrides){YAHOO.extend(subclass,superclass);subclass.override=function(o){YAHOO.override(subclass,o);};subclass.prototype.override=function(o){for(var method in o){this[method]=o[method];}};if(overrides){subclass.override(overrides);}};YAHOO.override=function(origclass,overrides){if(overrides){var p=origclass.prototype;for(var method in overrides){p[method]=overrides[method];}}};YAHOO.ext.util.Bench=function(){this.timers={};this.lastKey=null;};YAHOO.ext.util.Bench.prototype={start:function(key){this.lastKey=key;this.timers[key]={};this.timers[key].startTime=new Date().getTime();},stop:function(key){key=key||this.lastKey;this.timers[key].endTime=new Date().getTime();},getElapsed:function(key){key=key||this.lastKey;return this.timers[key].endTime-this.timers[key].startTime;},toString:function(html){var results="Results: \n";for(var key in this.timers){if(typeof this.timers[key]!='function'){results+=key+":\t"+(this.getElapsed(key)/1000)+" seconds\n";}}
|
|
if(html){results=results.replace("\n",'<br>');}
|
|
return results;},show:function(){alert(this.toString());}};YAHOO.ext.util.DelayedTask=function(fn,scope,args){var timeoutId=null;this.delay=function(delay,newFn,newScope,newArgs){if(timeoutId){clearTimeout(timeoutId);}
|
|
fn=newFn||fn;scope=newScope||scope;args=newArgs||args;timeoutId=setTimeout(fn.createDelegate(scope,args),delay);};this.cancel=function(){if(timeoutId){clearTimeout(timeoutId);timeoutId=null;}};};YAHOO.ext.util.Observable=function(){};YAHOO.ext.util.Observable.prototype={fireEvent:function(){var ce=this.events[arguments[0].toLowerCase()];ce.fireDirect.apply(ce,Array.prototype.slice.call(arguments,1));},addListener:function(eventName,fn,scope,override){eventName=eventName.toLowerCase();if(!this.events[eventName]){throw'You are trying to listen for an event that does not exist: "'+eventName+'".';}
|
|
this.events[eventName].subscribe(fn,scope,override);},delayedListener:function(eventName,fn,scope,delay){var newFn=function(){setTimeout(fn.createDelegate(scope,arguments),delay||1);}
|
|
this.addListener(eventName,newFn);return newFn;},removeListener:function(eventName,fn,scope){this.events[eventName.toLowerCase()].unsubscribe(fn,scope);}};YAHOO.ext.util.Observable.prototype.on=YAHOO.ext.util.Observable.prototype.addListener;YAHOO.ext.util.Config={apply:function(obj,config){if(config){for(var prop in config){obj[prop]=config[prop];}}}};YAHOO.ext.util.CSS=new function(){var rules=null;var toCamel=function(property){var convert=function(prop){var test=/(-[a-z])/i.exec(prop);return prop.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());};while(property.indexOf('-')>-1){property=convert(property);}
|
|
return property;};this.getRules=function(refreshCache){if(rules==null||refreshCache){rules={};var ds=document.styleSheets;for(var i=0,len=ds.length;i<len;i++){try{var ss=ds[i];var ssRules=ss.cssRules||ss.rules;for(var j=ssRules.length-1;j>=0;--j){rules[ssRules[j].selectorText]=ssRules[j];}}catch(e){}}}
|
|
return rules;};this.getRule=function(selector,refreshCache){var rs=this.getRules(refreshCache);if(!(selector instanceof Array)){return rs[selector];}
|
|
for(var i=0;i<selector.length;i++){if(rs[selector[i]]){return rs[selector[i]];}}
|
|
return null;};this.updateRule=function(selector,property,value){if(!(selector instanceof Array)){var rule=this.getRule(selector);if(rule){rule.style[property]=value;return true;}}else{for(var i=0;i<selector.length;i++){if(this.updateRule(selector[i],property,value)){return true;}}}
|
|
return false;};this.apply=function(el,selector){if(!(selector instanceof Array)){var rule=this.getRule(selector);if(rule){var s=rule.style;for(var key in s){if(typeof s[key]!='function'){if(s[key]&&String(s[key]).indexOf(':')<0&&s[key]!='false'){try{el.style[key]=s[key];}catch(e){}}}}
|
|
return true;}}else{for(var i=0;i<selector.length;i++){if(this.apply(el,selector[i])){return true;}}}
|
|
return false;};this.applyFirst=function(el,id,selector){var selectors=['#'+id+' '+selector,selector];return this.apply(el,selectors);};this.revert=function(el,selector){if(!(selector instanceof Array)){var rule=this.getRule(selector);if(rule){for(key in rule.style){if(rule.style[key]&&String(rule.style[key]).indexOf(':')<0&&rule.style[key]!='false'){try{el.style[key]='';}catch(e){}}}
|
|
return true;}}else{for(var i=0;i<selector.length;i++){if(this.revert(el,selector[i])){return true;}}}
|
|
return false;};this.revertFirst=function(el,id,selector){var selectors=['#'+id+' '+selector,selector];return this.revert(el,selectors);};}();Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(format){if(Date.formatFunctions[format]==null){Date.createNewFormat(format);}
|
|
var func=Date.formatFunctions[format];return this[func]();};Date.prototype.format=Date.prototype.dateFormat;Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var code="Date.prototype."+funcName+" = function(){return ";var special=false;var ch='';for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}
|
|
else if(special){special=false;code+="'"+String.escape(ch)+"' + ";}
|
|
else{code+=Date.getFormatCode(ch);}}
|
|
eval(code.substring(0,code.length-3)+";}");};Date.getFormatCode=function(character){switch(character){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(character)+"' + ";};};Date.parseDate=function(input,format){if(Date.parseFunctions[format]==null){Date.createParser(format);}
|
|
var func=Date.parseFunctions[format];return Date[func](input);};Date.createParser=function(format){var funcName="parse"+Date.parseFunctions.count++;var regexNum=Date.parseRegexes.length;var currentGroup=1;Date.parseFunctions[format]=funcName;var code="Date."+funcName+" = function(input){\n"
|
|
+"var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1;\n"
|
|
+"var d = new Date();\n"
|
|
+"y = d.getFullYear();\n"
|
|
+"m = d.getMonth();\n"
|
|
+"d = d.getDate();\n"
|
|
+"var results = input.match(Date.parseRegexes["+regexNum+"]);\n"
|
|
+"if (results && results.length > 0) {"
|
|
var regex="";var special=false;var ch='';for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}
|
|
else if(special){special=false;regex+=String.escape(ch);}
|
|
else{obj=Date.formatCodeToRegex(ch,currentGroup);currentGroup+=obj.g;regex+=obj.s;if(obj.g&&obj.c){code+=obj.c;}}}
|
|
code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"
|
|
+"{return new Date(y, m, d, h, i, s);}\n"
|
|
+"else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"
|
|
+"{return new Date(y, m, d, h, i);}\n"
|
|
+"else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n"
|
|
+"{return new Date(y, m, d, h);}\n"
|
|
+"else if (y > 0 && m >= 0 && d > 0)\n"
|
|
+"{return new Date(y, m, d);}\n"
|
|
+"else if (y > 0 && m >= 0)\n"
|
|
+"{return new Date(y, m);}\n"
|
|
+"else if (y > 0)\n"
|
|
+"{return new Date(y);}\n"
|
|
+"}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code);};Date.formatCodeToRegex=function(character,currentGroup){switch(character){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+currentGroup+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:0,c:null,s:"(?:\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+currentGroup+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+currentGroup+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+currentGroup+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+currentGroup+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+currentGroup+"], 10);\n"
|
|
+"y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+currentGroup+"] == 'am') {\n"
|
|
+"if (h == 12) { h = 0; }\n"
|
|
+"} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+currentGroup+"] == 'AM') {\n"
|
|
+"if (h == 12) { h = 0; }\n"
|
|
+"} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+currentGroup+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+currentGroup+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+currentGroup+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(character)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")
|
|
+String.leftPad(Math.floor(this.getTimezoneOffset()/60),2,"0")
|
|
+String.leftPad(this.getTimezoneOffset()%60,2,"0");};Date.prototype.getDayOfYear=function(){var num=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var i=0;i<this.getMonth();++i){num+=Date.daysInMonth[i];}
|
|
return num+this.getDate()-1;};Date.prototype.getWeekOfYear=function(){var now=this.getDayOfYear()+(4-this.getDay());var jan1=new Date(this.getFullYear(),0,1);var then=(7-jan1.getDay()+4);document.write(then);return String.leftPad(((now-then)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var year=this.getFullYear();return((year&3)==0&&(year%100||(year%400==0&&year)));};Date.prototype.getFirstDayOfMonth=function(){var day=(this.getDay()-(this.getDate()-1))%7;return(day<0)?(day+7):day;};Date.prototype.getLastDayOfMonth=function(){var day=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(day<0)?(day+7):day;};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};if(!String.escape){String.escape=function(string){return string.replace(/('|\\)/g,"\\$1");};};String.leftPad=function(val,size,ch){var result=new String(val);if(ch==null){ch=" ";}
|
|
while(result.length<size){result=ch+result;}
|
|
return result;};if(!Object.dump){Object.dump=function(o){var s="\n{";for(var k in o){if(typeof o[k]!='function'){s+="\n\t"+k+': '+o[k]+',';}}
|
|
if(s.length>3){s=s.substring(0,s.length-1);}
|
|
s+="\n}";return s;}}
|
|
Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};
|
|
|
|
YAHOO.ext.DomHelper=new function(){var d=document;this.useDom=false;function applyStyles(el,styles){if(styles){var D=YAHOO.util.Dom;var re=/\s?(.*?)\:(.*?);/g;var matches;while((matches=re.exec(styles))!=null){D.setStyle(el,matches[1],matches[2]);}}}
|
|
function createHtml(o){var b='';b+='<'+o.tag;for(var attr in o){if(attr=='tag'||attr=='children'||attr=='html'||typeof o[attr]=='function')continue;if(attr=='cls'){b+=' class="'+o['cls']+'"';}else{b+=' '+attr+'="'+o[attr]+'"';}}
|
|
b+='>';if(o.children){for(var i=0,len=o.children.length;i<len;i++){b+=createHtml(o.children[i],b);}}
|
|
if(o.html){b+=o.html;}
|
|
b+='</'+o.tag+'>';return b;}
|
|
function createDom(o,parentNode){var el=d.createElement(o.tag);var useSet=el.setAttribute?true:false;for(var attr in o){if(attr=='tag'||attr=='children'||attr=='html'||attr=='style'||typeof o[attr]=='function')continue;if(attr=='cls'){el.className=o['cls'];}else{if(useSet)el.setAttribute(attr,o[attr]);else el[attr]=o[attr];}}
|
|
applyStyles(el,o.style);if(o.children){for(var i=0,len=o.children.length;i<len;i++){createDom(o.children[i],el);}}
|
|
if(o.html){el.innerHTML=o.html;}
|
|
if(parentNode){parentNode.appendChild(el);}
|
|
return el;}
|
|
this.insertHtml=function(where,el,html){if(el.insertAdjacentHTML){if(where=='beforeBegin'){el.insertAdjacentHTML(where,html);return el.previousSibling;}else if(where=='afterBegin'){el.insertAdjacentHTML(where,html);return el.firstChild;}else if(where=='beforeEnd'){el.insertAdjacentHTML(where,html);return el.lastChild;}else if(where=='afterEnd'){el.insertAdjacentHTML(where,html);return el.nextSibling;}
|
|
throw'Illegal insertion point -> "'+where+'"';}
|
|
var range=el.ownerDocument.createRange();var frag;if(where=='beforeBegin'){range.setStartBefore(el);frag=range.createContextualFragment(html);el.parentNode.insertBefore(frag,el);return el.previousSibling;}else if(where=='afterBegin'){range.selectNodeContents(el);range.collapse(true);frag=range.createContextualFragment(html);el.insertBefore(frag,el.firstChild);return el.firstChild;}else if(where=='beforeEnd'){range.selectNodeContents(el);range.collapse(false);frag=range.createContextualFragment(html);el.appendChild(frag);return el.lastChild;}else if(where=='afterEnd'){range.setStartAfter(el);frag=range.createContextualFragment(html);el.parentNode.insertBefore(frag,el.nextSibling);return el.nextSibling;}else{throw'Illegal insertion point -> "'+where+'"';}};this.insertBefore=function(el,o,returnElement){el=YAHOO.util.Dom.get(el);var newNode;if(this.useDom){newNode=createDom(o,null);el.parentNode.insertBefore(newNode,el);}else{var html=createHtml(o);newNode=this.insertHtml('beforeBegin',el,html);}
|
|
return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;};this.insertAfter=function(el,o,returnElement){el=YAHOO.util.Dom.get(el);var newNode;if(this.useDom){newNode=createDom(o,null);el.parentNode.insertBefore(newNode,el.nextSibling);}else{var html=createHtml(o);newNode=this.insertHtml('afterEnd',el,html);}
|
|
return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;};this.append=function(el,o,returnElement){el=YAHOO.util.Dom.get(el);var newNode;if(this.useDom){newNode=createDom(o,null);el.appendChild(newNode);}else{var html=createHtml(o);newNode=this.insertHtml('beforeEnd',el,html);}
|
|
return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;};this.overwrite=function(el,o,returnElement){el=YAHOO.util.Dom.get(el);el.innerHTML=createHtml(o);return returnElement?YAHOO.ext.Element.get(el.firstChild,true):el.firstChild;};this.createTemplate=function(o){var html=createHtml(o);return new YAHOO.ext.DomHelper.Template(html);};}();YAHOO.ext.DomHelper.Template=function(html){this.html=html;this.re=/\{(\w+)\}/g;};YAHOO.ext.DomHelper.Template.prototype={applyTemplate:function(values){if(this.compiled){return this.compiled(values);}
|
|
var empty='';var fn=function(match,index){if(typeof values[index]!='undefined'){return values[index];}else{return empty;}}
|
|
return this.html.replace(this.re,fn);},compile:function(){var html=this.html;var re=/\{(\w+)\}/g;var body=[];body.push("this.compiled = function(values){ return ");var result;var lastMatchEnd=0;while((result=re.exec(html))!=null){body.push("'",html.substring(lastMatchEnd,result.index),"' + ");body.push("values[",html.substring(result.index+1,re.lastIndex-1),"] + ");lastMatchEnd=re.lastIndex;}
|
|
body.push("'",html.substr(lastMatchEnd),"';};");eval(body.join(''));},insertBefore:function(el,values,returnElement){el=YAHOO.util.Dom.get(el);var newNode=YAHOO.ext.DomHelper.insertHtml('beforeBegin',el,this.applyTemplate(values));return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;},insertAfter:function(el,values,returnElement){el=YAHOO.util.Dom.get(el);var newNode=YAHOO.ext.DomHelper.insertHtml('afterEnd',el,this.applyTemplate(values));return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;},append:function(el,values,returnElement){el=YAHOO.util.Dom.get(el);var newNode=YAHOO.ext.DomHelper.insertHtml('beforeEnd',el,this.applyTemplate(values));return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;},overwrite:function(el,values,returnElement){el=YAHOO.util.Dom.get(el);el.innerHTML='';var newNode=YAHOO.ext.DomHelper.insertHtml('beforeEnd',el,this.applyTemplate(values));return returnElement?YAHOO.ext.Element.get(newNode,true):newNode;}};
|
|
|
|
YAHOO.ext.Element=function(elementId,forceNew){var dom=YAHOO.util.Dom.get(elementId);if(!dom){return;}
|
|
if(!forceNew&&YAHOO.ext.Element.cache[dom.id]){return YAHOO.ext.Element.cache[dom.id];}
|
|
this.dom=dom;this.id=this.dom.id;this.visibilityMode=YAHOO.ext.Element.VISIBILITY;this.originalDisplay=YAHOO.util.Dom.getStyle(this.dom,'display');if(!this.originalDisplay||this.originalDisplay=='none'){this.originalDisplay='';}
|
|
this.defaultUnit='px';this.originalClip=YAHOO.util.Dom.getStyle(this.dom,'overflow');this.onVisibilityChanged=new YAHOO.util.CustomEvent('visibilityChanged');this.onMoved=new YAHOO.util.CustomEvent('moved');this.onResized=new YAHOO.util.CustomEvent('resized');this.visibilityDelegate=this.fireVisibilityChanged.createDelegate(this);this.resizedDelegate=this.fireResized.createDelegate(this);this.movedDelegate=this.fireMoved.createDelegate(this);}
|
|
YAHOO.ext.Element.prototype={fireMoved:function(){this.onMoved.fireDirect(this,this.getX(),this.getY());},fireVisibilityChanged:function(){this.onVisibilityChanged.fireDirect(this,this.isVisible());},fireResized:function(){this.onResized.fireDirect(this,this.getWidth(),this.getHeight());},setVisibilityMode:function(visMode){this.visibilityMode=visMode;},enableDisplayMode:function(){this.setVisibilityMode(YAHOO.ext.Element.DISPLAY)},animate:function(args,duration,onComplete,easing,animType){this.anim(args,duration,onComplete,easing,animType);},anim:function(args,duration,onComplete,easing,animType){animType=animType||YAHOO.util.Anim;var anim=new animType(this.dom,args,duration||.35,easing||YAHOO.util.Easing.easeBoth);if(onComplete){if(!(onComplete instanceof Array)){anim.onComplete.subscribe(onComplete);}else{for(var i=0;i<onComplete.length;i++){var fn=onComplete[i];if(fn)anim.onComplete.subscribe(fn);}}}
|
|
anim.animate();},isVisible:function(deep){var vis=YAHOO.util.Dom.getStyle(this.dom,'visibility')!='hidden'&&YAHOO.util.Dom.getStyle(this.dom,'display')!='none';if(!deep||!vis){return vis;}
|
|
var p=this.dom.parentNode;while(p&&p.tagName.toLowerCase()!='body'){if(YAHOO.util.Dom.getStyle(p,'visibility')=='hidden'||YAHOO.util.Dom.getStyle(p,'display')=='none'){return false;}
|
|
p=p.parentNode;}
|
|
return true;},setVisible:function(visible,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){if(this.visibilityMode==YAHOO.ext.Element.DISPLAY){this.setDisplayed(visible);}else{YAHOO.util.Dom.setStyle(this.dom,'visibility',visible?'visible':'hidden');}
|
|
this.fireVisibilityChanged();}else{YAHOO.util.Dom.setStyle(this.dom,'visibility','visible');if(this.visibilityMode==YAHOO.ext.Element.DISPLAY){this.setDisplayed(true);}
|
|
var args={opacity:{from:(visible?0:1),to:(visible?1:0)}};var anim=new YAHOO.util.Anim(this.dom,args,duration||.35,easing||(visible?YAHOO.util.Easing.easeIn:YAHOO.util.Easing.easeOut));anim.onComplete.subscribe((function(){if(this.visibilityMode==YAHOO.ext.Element.DISPLAY){this.setDisplayed(visible);}else{YAHOO.util.Dom.setStyle(this.dom,'visibility',visible?'visible':'hidden');}
|
|
this.fireVisibilityChanged();}).createDelegate(this));if(onComplete){anim.onComplete.subscribe(onComplete);}
|
|
anim.animate();}},isDisplayed:function(){return YAHOO.util.Dom.getStyle(this.dom,'display')!='none';},toggle:function(animate,duration,onComplete,easing){this.setVisible(!this.isVisible(),animate,duration,onComplete,easing);},setDisplayed:function(value){YAHOO.util.Dom.setStyle(this.dom,'display',value?this.originalDisplay:'none');},focus:function(){try{this.dom.focus();}catch(e){}},addClass:function(className){YAHOO.util.Dom.addClass(this.dom,className);},radioClass:function(className){var siblings=this.dom.parentNode.childNodes;for(var i=0;i<siblings.length;i++){var s=siblings[i];if(s.nodeType==1){YAHOO.util.Dom.removeClass(s,className);}}
|
|
YAHOO.util.Dom.addClass(this.dom,className);},removeClass:function(className){YAHOO.util.Dom.removeClass(this.dom,className);},toggleClass:function(className){if(YAHOO.util.Dom.hasClass(this.dom,className)){YAHOO.util.Dom.removeClass(this.dom,className);}else{YAHOO.util.Dom.addClass(this.dom,className);}},hasClass:function(className){return YAHOO.util.Dom.hasClass(this.dom,className);},replaceClass:function(oldClassName,newClassName){YAHOO.util.Dom.replaceClass(this.dom,oldClassName,newClassName);},getStyle:function(name){return YAHOO.util.Dom.getStyle(this.dom,name);},setStyle:function(name,value){YAHOO.util.Dom.setStyle(this.dom,name,value);},getX:function(){return YAHOO.util.Dom.getX(this.dom);},getY:function(){return YAHOO.util.Dom.getY(this.dom);},getXY:function(){return YAHOO.util.Dom.getXY(this.dom);},setX:function(x){YAHOO.util.Dom.setX(this.dom,x);this.fireMoved();},setY:function(y){YAHOO.util.Dom.setY(this.dom,y);this.fireMoved();},setLeft:function(left){YAHOO.util.Dom.setStyle(this.dom,'left',this.addUnits(left));this.fireMoved();},setTop:function(top){YAHOO.util.Dom.setStyle(this.dom,'top',this.addUnits(top));this.fireMoved();},setRight:function(right){YAHOO.util.Dom.setStyle(this.dom,'right',this.addUnits(right));this.fireMoved();},setBottom:function(bottom){YAHOO.util.Dom.setStyle(this.dom,'bottom',this.addUnits(bottom));this.fireMoved();},setXY:function(pos,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setXY(this.dom,pos);this.fireMoved();}else{this.anim({points:{to:pos}},duration,[onComplete,this.movedDelegate],easing,YAHOO.util.Motion);}},setLocation:function(x,y,animate,duration,onComplete,easing){this.setXY([x,y],animate,duration,onComplete,easing);},moveTo:function(x,y,animate,duration,onComplete,easing){this.setXY([x,y],animate,duration,onComplete,easing);},getRegion:function(){return YAHOO.util.Dom.getRegion(this.dom);},getHeight:function(){return this.dom.offsetHeight;},getWidth:function(){return this.dom.offsetWidth;},getSize:function(){return{width:this.getWidth(),height:this.getHeight()};},adjustWidth:function(width){if(this.autoBoxAdjust&&typeof width=='number'&&!this.isBorderBox()){width-=(this.getBorderWidth('lr')+this.getPadding('lr'));}
|
|
return width;},adjustHeight:function(height){if(this.autoBoxAdjust&&typeof height=='number'&&!this.isBorderBox()){height-=(this.getBorderWidth('tb')+this.getPadding('tb'));}
|
|
return height;},setWidth:function(width,animate,duration,onComplete,easing){width=this.adjustWidth(width);if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setStyle(this.dom,'width',this.addUnits(width));this.fireResized();}else{this.anim({width:{to:width}},duration,[onComplete,this.resizedDelegate],easing||(width>this.getWidth()?YAHOO.util.Easing.easeOut:YAHOO.util.Easing.easeIn));}},setHeight:function(height,animate,duration,onComplete,easing){height=this.adjustHeight(height);if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setStyle(this.dom,'height',this.addUnits(height));this.fireResized();}else{this.anim({height:{to:height}},duration,[onComplete,this.resizedDelegate],easing||(height>this.getHeight()?YAHOO.util.Easing.easeOut:YAHOO.util.Easing.easeIn));}},setSize:function(width,height,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){this.setWidth(width);this.setHeight(height);this.fireResized();}else{width=this.adjustWidth(width);height=this.adjustHeight(height);this.anim({width:{to:width},height:{to:height}},duration,[onComplete,this.resizedDelegate],easing);}},setBounds:function(x,y,width,height,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){this.setWidth(width);this.setHeight(height);this.setLocation(x,y);this.fireResized();this.fireMoved();}else{width=this.adjustWidth(width);height=this.adjustHeight(height);this.anim({points:{to:[x,y]},width:{to:width},height:{to:height}},duration,[onComplete,this.movedDelegate],easing,YAHOO.util.Motion);}},setRegion:function(region,animate,duration,onComplete,easing){this.setBounds(region.left,region.top,region.right-region.left,region.bottom-region.top,animate,duration,onComplete,easing);},addListener:function(eventName,handler,scope,override){YAHOO.util.Event.addListener(this.dom,eventName,handler,scope,override);},addHandler:function(eventName,stopPropagation,handler,scope,override){var fn=YAHOO.ext.Element.createStopHandler(stopPropagation,handler,scope,override);YAHOO.util.Event.addListener(this.dom,eventName,fn);},on:function(eventName,handler,scope,override){YAHOO.util.Event.addListener(this.dom,eventName,handler,scope,override);},addManagedListener:function(eventName,fn,scope,override){return YAHOO.ext.EventManager.on(this.dom,eventName,fn,scope,override);},mon:function(eventName,fn,scope,override){return YAHOO.ext.EventManager.on(this.dom,eventName,fn,scope,override);},removeListener:function(eventName,handler){YAHOO.util.Event.removeListener(this.dom,eventName,handler);},removeAllListeners:function(){YAHOO.util.Event.purgeElement(this.dom);},setOpacity:function(opacity,animate,duration,onComplete,easing){if(!animate||!YAHOO.util.Anim){YAHOO.util.Dom.setStyle(this.dom,'opacity',opacity);}else{this.anim({opacity:{to:opacity}},duration,onComplete,easing);}},getLeft:function(){return this.getX();},getRight:function(){return this.getX()+this.getWidth();},getTop:function(){return this.getY();},getBottom:function(){return this.getY()+this.getHeight();},setAbsolutePositioned:function(zIndex){this.setStyle('position','absolute');if(zIndex){this.setStyle('z-index',zIndex);}},setRelativePositioned:function(zIndex){this.setStyle('position','relative');if(zIndex){this.setStyle('z-index',zIndex);}},clearPositioning:function(){this.setStyle('position','');this.setStyle('left','');this.setStyle('right','');this.setStyle('top','');this.setStyle('bottom','');},getPositioning:function(){return{'position':this.getStyle('position'),'left':this.getStyle('left'),'right':this.getStyle('right'),'top':this.getStyle('top'),'bottom':this.getStyle('bottom')};},getBorderWidth:function(side){var width=0;var b=YAHOO.ext.Element.borders;for(var s in b){if(typeof b[s]!='function'){if(side.indexOf(s)!==-1){var w=parseInt(this.getStyle(b[s]),10);if(!isNaN(w))width+=w;}}}
|
|
return width;},getPadding:function(side){var pad=0;var b=YAHOO.ext.Element.paddings;for(var s in b){if(typeof s[b]!='function'){if(side.indexOf(s)!==-1){var w=parseInt(this.getStyle(b[s]),10);if(!isNaN(w))pad+=w;}}}
|
|
return pad;},setPositioning:function(positionCfg){this.setStyle('position',positionCfg.position);this.setStyle('left',positionCfg.left);this.setStyle('right',positionCfg.right);this.setStyle('top',positionCfg.top);this.setStyle('bottom',positionCfg.bottom);},move:function(direction,distance,animate,duration,onComplete,easing){var xy=this.getXY();direction=direction.toLowerCase();switch(direction){case'left':this.moveTo(xy[0]-distance,xy[1],animate,duration,onComplete,easing);return;case'right':this.moveTo(xy[0]+distance,xy[1],animate,duration,onComplete,easing);return;case'up':this.moveTo(xy[0],xy[1]-distance,animate,duration,onComplete,easing);return;case'down':this.moveTo(xy[0],xy[1]+distance,animate,duration,onComplete,easing);return;}},clip:function(){this.setStyle('overflow','hidden');},unclip:function(){this.setStyle('overflow',this.originalClip);},alignTo:function(element,position,offsets,animate,duration,onComplete,easing){var otherEl=getEl(element);if(!otherEl){return;}
|
|
offsets=offsets||[0,0];var r=otherEl.getRegion();position=position.toLowerCase();switch(position){case'bl':this.moveTo(r.left+offsets[0],r.bottom+offsets[1],animate,duration,onComplete,easing);return;case'br':this.moveTo(r.right+offsets[0],r.bottom+offsets[1],animate,duration,onComplete,easing);return;case'tl':this.moveTo(r.left+offsets[0],r.top+offsets[1],animate,duration,onComplete,easing);return;case'tr':this.moveTo(r.right+offsets[0],r.top+offsets[1],animate,duration,onComplete,easing);return;}},clearOpacity:function(){if(window.ActiveXObject){this.dom.style.filter='';}else{this.dom.style.opacity='';this.dom.style['-moz-opacity']='';this.dom.style['-khtml-opacity']='';}},hide:function(animate,duration,onComplete,easing){this.setVisible(false,animate,duration,onComplete,easing);},show:function(animate,duration,onComplete,easing){this.setVisible(true,animate,duration,onComplete,easing);},addUnits:function(size){if(typeof size=='number'||!YAHOO.ext.Element.unitPattern.test(size)){return size+this.defaultUnit;}
|
|
return size;},beginMeasure:function(){var p=this.dom;if(p.offsetWidth||p.offsetHeight){return;}
|
|
var changed=[];var p=this.dom;while(p&&p.tagName.toLowerCase()!='body'){if(YAHOO.util.Dom.getStyle(p,'display')=='none'){changed.push({el:p,visibility:YAHOO.util.Dom.getStyle(p,'visibility')});p.style.visibility='hidden';p.style.display='block';}
|
|
p=p.parentNode;}
|
|
this._measureChanged=changed;},endMeasure:function(){var changed=this._measureChanged;if(changed){for(var i=0,len=changed.length;i<len;i++){var r=changed[i];r.el.style.visibility=r.visibility;r.el.style.display='none';}
|
|
this._measureChanged=null;}},update:function(html,loadScripts){this.dom.innerHTML=html;if(!loadScripts)return;var dom=this.dom;var _parseScripts=function(){var s=this.dom.getElementsByTagName("script");var docHead=document.getElementsByTagName("head")[0];if(s.length==0){var re=/(?:<script.*(?:src=[\"\'](.*)[\"\']).*>.*<\/script>)|(?:<script.*>([\S\s]*?)<\/script>)/ig;var match;while(match=re.exec(html)){var s0=document.createElement("script");if(match[1])
|
|
s0.src=match[1];else if(match[2])
|
|
s0.text=match[2];else
|
|
continue;docHead.appendChild(s0);}}else{for(var i=0;i<s.length;i++){var s0=document.createElement("script");s0.type=s[i].type;if(s[i].text){s0.text=s[i].text;}else{s0.src=s[i].src;}
|
|
docHead.appendChild(s0);}}}
|
|
setTimeout(_parseScripts,10);},getUpdateManager:function(){if(!this.updateManager){this.updateManager=new YAHOO.ext.UpdateManager(this);}
|
|
return this.updateManager;},getCenterXY:function(offsetScroll){var centerX=Math.round((YAHOO.util.Dom.getViewportWidth()-this.getWidth())/2);var centerY=Math.round((YAHOO.util.Dom.getViewportHeight()-this.getHeight())/2);if(!offsetScroll){return[centerX,centerY];}else{var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft||0;var scrollY=document.documentElement.scrollTop||document.body.scrollTop||0;return[centerX+scrollX,centerY+scrollY];}},getChildrenByTagName:function(tagName){var children=this.dom.getElementsByTagName(tagName);var len=children.length;var ce=[len];for(var i=0;i<len;++i){ce[i]=YAHOO.ext.Element.get(children[i],true);}
|
|
return ce;},getChildrenByClassName:function(className,tagName){var children=YAHOO.util.Dom.getElementsByClassName(className,tagName,this.dom);var len=children.length;var ce=[len];for(var i=0;i<len;++i){ce[i]=YAHOO.ext.Element.get(children[i],true);}
|
|
return ce;},isBorderBox:function(){var el=this.dom;var b=YAHOO.ext.util.Browser;var strict=YAHOO.ext.Strict;return((b.isIE&&!b.isIE7)||(b.isIE7&&!strict&&el.style.boxSizing!='content-box')||(b.isGecko&&YAHOO.util.Dom.getStyle(el,"-moz-box-sizing")=='border-box')||(!b.isSafari&&YAHOO.util.Dom.getStyle(el,"box-sizing")=='border-box'));},getBox:function(contentBox){var xy=this.getXY();var el=this.dom;var w=el.offsetWidth;var h=el.offsetHeight;if(!contentBox){return{x:xy[0],y:xy[1],width:w,height:h};}else{var l=this.getBorderWidth('l')+this.getPadding('l');var r=this.getBorderWidth('r')+this.getPadding('r');var t=this.getBorderWidth('t')+this.getPadding('t');var b=this.getBorderWidth('b')+this.getPadding('b');return{x:xy[0]+l,y:xy[1]+t,width:w-(l+r),height:h-(t+b)};}},setBox:function(box,adjust,animate,duration,onComplete,easing){var w=box.width,h=box.height;if((adjust&&!this.autoBoxAdjust)&&!this.isBorderBox()){w-=(this.getBorderWidth('lr')+this.getPadding('lr'));h-=(this.getBorderWidth('tb')+this.getPadding('tb'));}
|
|
this.setBounds(box.x,box.y,w,h,animate,duration,onComplete,easing);},repaint:function(){var dom=this.dom;YAHOO.util.Dom.addClass(dom,'yui-ext-repaint');setTimeout(function(){YAHOO.util.Dom.removeClass(dom,'yui-ext-repaint');},1);}};YAHOO.ext.Element.prototype.autoBoxAdjust=true;YAHOO.ext.Element.unitPattern=/\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i;YAHOO.ext.Element.VISIBILITY=1;YAHOO.ext.Element.DISPLAY=2;YAHOO.ext.Element.borders={l:'border-left-width',r:'border-right-width',t:'border-top-width',b:'border-bottom-width'};YAHOO.ext.Element.paddings={l:'padding-left',r:'padding-right',t:'padding-top',b:'padding-bottom'};YAHOO.ext.Element.createStopHandler=function(stopPropagation,handler,scope,override){return function(e){if(e){if(stopPropagation){YAHOO.util.Event.stopEvent(e);}else{YAHOO.util.Event.preventDefault(e);}}
|
|
handler.call(override&&scope?scope:window,e,scope);};};YAHOO.ext.Element.cache={};YAHOO.ext.Element.get=function(el,autoGenerateId){if(!el){return null;}
|
|
if(el instanceof YAHOO.ext.Element){el.dom=YAHOO.util.Dom.get(el.id);YAHOO.ext.Element.cache[el.id]=el;return el;}
|
|
var key=el;if(typeof el!='string'){if(!el.id&&!autoGenerateId){return null;}
|
|
YAHOO.util.Dom.generateId(el,'elgen-');key=el.id;}
|
|
var element=YAHOO.ext.Element.cache[key];if(!element){element=new YAHOO.ext.Element(key);YAHOO.ext.Element.cache[key]=element;}else{element.dom=YAHOO.util.Dom.get(key);}
|
|
return element;};var getEl=YAHOO.ext.Element.get;YAHOO.util.Event.addListener(window,'unload',function(){YAHOO.ext.Element.cache=null;});
|
|
|
|
YAHOO.namespace('ext.state');YAHOO.ext.state.Provider=function(){YAHOO.ext.state.Provider.superclass.constructor.call(this);this.events={'statechange':new YAHOO.util.CustomEvent('statechange')};this.state={};};YAHOO.extendX(YAHOO.ext.state.Provider,YAHOO.ext.util.Observable,{get:function(name){return this.state[name];},clear:function(name){delete this.state[name];this.fireEvent('statechange',this,name,null);},set:function(name,value){this.state[name]=value;this.fireEvent('statechange',this,name,value);}});YAHOO.ext.state.Manager=new function(){var provider=new YAHOO.ext.state.Provider();return{setProvider:function(stateProvider){provider=stateProvider;},get:function(key){return provider.get(key);},set:function(key,value){provider.set(key,value);},clear:function(key){provider.clear(key);},getProvider:function(){return provider;}};}();YAHOO.ext.state.CookieProvider=function(config){YAHOO.ext.state.CookieProvider.superclass.constructor.call(this);this.path='/';this.expires=new Date(new Date().getTime()+(1000*60*60*24*7));this.domain=null;this.secure=false;YAHOO.ext.util.Config.apply(this,config);this.state=this.readCookies();};YAHOO.extendX(YAHOO.ext.state.CookieProvider,YAHOO.ext.state.Provider,{set:function(name,value){if(typeof value=='undefined'||value===null){this.clear(name);return;}
|
|
this.setCookie(name,value);YAHOO.ext.state.CookieProvider.superclass.set.call(this,name,value);},clear:function(name){this.clearCookie(name);YAHOO.ext.state.CookieProvider.superclass.clear.call(this,name);},readCookies:function(){var cookies={};var c=document.cookie+';';var re=/\s?(.*?)=(.*?);/g;var matches;while((matches=re.exec(c))!=null){var name=matches[1];var value=matches[2];if(name&&name.substring(0,3)=='ys-'){cookies[name.substr(3)]=this.decodeValue(value);}}
|
|
return cookies;},decodeValue:function(cookie){var re=/^(a|n|d|b|s|o)\:(.*)$/;var matches=re.exec(unescape(cookie));if(!matches||!matches[1])return;var type=matches[1];var v=matches[2];switch(type){case'n':return parseFloat(v);case'd':return new Date(Date.parse(v));case'b':return(v=='1');case'a':var all=[];var values=v.split('^');for(var i=0,len=values.length;i<len;i++){all.push(this.decodeValue(values[i]))}
|
|
return all;case'o':var all={};var values=v.split('^');for(var i=0,len=values.length;i<len;i++){var kv=values[i].split('=');all[kv[0]]=this.decodeValue(kv[1]);}
|
|
return all;default:return v;}},encodeValue:function(v){var enc;if(typeof v=='number'){enc='n:'+v;}else if(typeof v=='boolean'){enc='b:'+(v?'1':'0');}else if(v instanceof Date){enc='d:'+v.toGMTString();}else if(v instanceof Array){var flat='';for(var i=0,len=v.length;i<len;i++){flat+=this.encodeValue(v[i]);if(i!=len-1)flat+='^';}
|
|
enc='a:'+flat;}else if(typeof v=='object'){var flat='';for(var key in v){if(typeof v[key]!='function'){flat+=key+'='+this.encodeValue(v[key])+'^';}}
|
|
enc='o:'+flat.substring(0,flat.length-1);}else{enc='s:'+v;}
|
|
return escape(enc);},setCookie:function(name,value){document.cookie="ys-"+name+"="+this.encodeValue(value)+
|
|
((this.expires==null)?"":("; expires="+this.expires.toGMTString()))+
|
|
((this.path==null)?"":("; path="+this.path))+
|
|
((this.domain==null)?"":("; domain="+this.domain))+
|
|
((this.secure==true)?"; secure":"");},clearCookie:function(name){document.cookie="ys-"+name+"=null; expires=Thu, 01-Jan-70 00:00:01 GMT"+
|
|
((this.path==null)?"":("; path="+this.path))+
|
|
((this.domain==null)?"":("; domain="+this.domain))+
|
|
((this.secure==true)?"; secure":"");}});
|
|
|
|
YAHOO.ext.EventManager=new function(){var docReadyEvent;var docReadyProcId;var docReadyState=false;this.ieDeferSrc="javascript:false";var fireDocReady=function(){if(!docReadyState){docReadyState=true;if(docReadyProcId){clearInterval(docReadyProcId);}
|
|
if(docReadyEvent){docReadyEvent.fire();}}};var initDocReady=function(){docReadyEvent=new YAHOO.util.CustomEvent('documentready');if(document.addEventListener){YAHOO.util.Event.on(document,"DOMContentLoaded",fireDocReady);}else if(YAHOO.ext.util.Browser.isIE){document.write('<s'+'cript id="ie-deferred-loader" defer="defer" src="'+
|
|
YAHOO.ext.EventManager.ieDeferSrc+'"></s'+'cript>');YAHOO.util.Event.on('ie-deferred-loader','readystatechange',function(){if(this.readyState=='complete'){fireDocReady();}});}else if(YAHOO.ext.util.Browser.isSafari){docReadyProcId=setInterval(function(){var rs=document.readyState;if(rs=='loaded'||rs=='complete'){fireDocReady();}},10);}
|
|
YAHOO.util.Event.on(window,'load',fireDocReady);};this.wrap=function(fn,scope,override){var wrappedFn=function(e){YAHOO.ext.EventObject.setEvent(e);fn.call(override?scope||window:window,YAHOO.ext.EventObject,scope);};return wrappedFn;};this.addListener=function(element,eventName,fn,scope,override){var wrappedFn=this.wrap(fn,scope,override);YAHOO.util.Event.addListener(element,eventName,wrappedFn);return wrappedFn;};this.removeListener=function(element,eventName,wrappedFn){return YAHOO.util.Event.removeListener(element,eventName,wrappedFn);};this.on=function(element,eventName,fn,scope,override){var wrappedFn=this.wrap(fn,scope,override);YAHOO.util.Event.addListener(element,eventName,wrappedFn);return wrappedFn;};this.onDocumentReady=function(fn,scope,override){if(!docReadyEvent){initDocReady();}
|
|
docReadyEvent.subscribe(fn,scope,override);}};YAHOO.ext.EventObject=new function(){this.browserEvent=null;this.button=-1;this.shiftKey=false;this.ctrlKey=false;this.altKey=false;this.BACKSPACE=8;this.TAB=9;this.RETURN=13;this.ESC=27;this.SPACE=32;this.PAGEUP=33;this.PAGEDOWN=34;this.END=35;this.HOME=36;this.LEFT=37;this.UP=38;this.RIGHT=39;this.DOWN=40;this.DELETE=46;this.F5=116;this.setEvent=function(e){this.browserEvent=e;if(e){this.button=e.button;this.shiftKey=e.shiftKey;this.ctrlKey=e.ctrlKey;this.altKey=e.altKey;}else{this.button=-1;this.shiftKey=false;this.ctrlKey=false;this.altKey=false;}};this.stopEvent=function(){if(this.browserEvent){YAHOO.util.Event.stopEvent(this.browserEvent);}};this.preventDefault=function(){if(this.browserEvent){YAHOO.util.Event.preventDefault(this.browserEvent);}};this.isNavKeyPress=function(){return(this.browserEvent.keyCode&&this.browserEvent.keyCode>=33&&this.browserEvent.keyCode<=40);};this.stopPropagation=function(){if(this.browserEvent){YAHOO.util.Event.stopPropagation(this.browserEvent);}};this.getCharCode=function(){if(this.browserEvent){return YAHOO.util.Event.getCharCode(this.browserEvent);}
|
|
return null;};this.getPageX=function(){if(this.browserEvent){return YAHOO.util.Event.getPageX(this.browserEvent);}
|
|
return null;};this.getPageY=function(){if(this.browserEvent){return YAHOO.util.Event.getPageY(this.browserEvent);}
|
|
return null;};this.getTime=function(){if(this.browserEvent){return YAHOO.util.Event.getTime(this.browserEvent);}
|
|
return null;};this.getXY=function(){if(this.browserEvent){return YAHOO.util.Event.getXY(this.browserEvent);}
|
|
return[];};this.getTarget=function(){if(this.browserEvent){return YAHOO.util.Event.getTarget(this.browserEvent);}
|
|
return null;};this.findTarget=function(className,tagName){if(tagName)tagName=tagName.toLowerCase();if(this.browserEvent){function isMatch(el){if(!el){return false;}
|
|
if(className&&!YAHOO.util.Dom.hasClass(el,className)){return false;}
|
|
if(tagName&&el.tagName.toLowerCase()!=tagName){return false;}
|
|
return true;};var t=this.getTarget();if(!t||isMatch(t)){return t;}
|
|
var p=t.parentNode;while(p&&p.tagName.toUpperCase()!='BODY'){if(isMatch(p)){return p;}
|
|
p=p.parentNode;}}
|
|
return null;};this.getRelatedTarget=function(){if(this.browserEvent){return YAHOO.util.Event.getRelatedTarget(this.browserEvent);}
|
|
return null;};this.getWheelDelta=function(){var e=this.browserEvent;var delta=0;if(e.wheelDelta){delta=e.wheelDelta/120;if(window.opera)delta=-delta;}else if(e.detail){delta=-e.detail/3;}
|
|
return delta;};this.hasModifier=function(){return this.ctrlKey||this.altKey||this.shiftKey;};}();
|
|
|
|
YAHOO.ext.UpdateManager=function(el,forceNew){el=YAHOO.ext.Element.get(el);if(!forceNew&&el.updateManager){return el.updateManager;}
|
|
this.el=el;this.defaultUrl=null;this.beforeUpdate=new YAHOO.util.CustomEvent('UpdateManager.beforeUpdate');this.onUpdate=new YAHOO.util.CustomEvent('UpdateManager.onUpdate');this.onFailure=new YAHOO.util.CustomEvent('UpdateManager.onFailure');this.sslBlankUrl=YAHOO.ext.UpdateManager.defaults.sslBlankUrl;this.disableCaching=YAHOO.ext.UpdateManager.defaults.disableCaching;this.indicatorText=YAHOO.ext.UpdateManager.defaults.indicatorText;this.showLoadIndicator=YAHOO.ext.UpdateManager.defaults.showLoadIndicator;this.timeout=YAHOO.ext.UpdateManager.defaults.timeout;this.loadScripts=YAHOO.ext.UpdateManager.defaults.loadScripts;this.transaction=null;this.autoRefreshProcId=null;this.refreshDelegate=this.refresh.createDelegate(this);this.updateDelegate=this.update.createDelegate(this);this.formUpdateDelegate=this.formUpdate.createDelegate(this);this.successDelegate=this.processSuccess.createDelegate(this);this.failureDelegate=this.processFailure.createDelegate(this);this.renderer=new YAHOO.ext.UpdateManager.BasicRenderer();};YAHOO.ext.UpdateManager.prototype={getEl:function(){return this.el;},update:function(url,params,callback,discardUrl){if(this.beforeUpdate.fireDirect(this.el,url,params)!==false){this.showLoading();if(!discardUrl){this.defaultUrl=url;}
|
|
if(typeof url=='function'){url=url();}
|
|
if(params&&typeof params!='string'){var buf=[];for(var key in params){if(typeof params[key]!='function'){buf.push(encodeURIComponent(key),'=',encodeURIComponent(params[key]),'&');}}
|
|
delete buf[buf.length-1];params=buf.join('');}
|
|
var callback={success:this.successDelegate,failure:this.failureDelegate,timeout:(this.timeout*1000),argument:{'url':url,'form':null,'callback':callback,'params':params}};var method=params?'POST':'GET';if(method=='GET'){url=this.prepareUrl(url);}
|
|
this.transaction=YAHOO.util.Connect.asyncRequest(method,url,callback,params);}},formUpdate:function(form,url,reset,callback){if(this.beforeUpdate.fireDirect(this.el,form,url)!==false){this.showLoading();formEl=YAHOO.util.Dom.get(form);if(typeof url=='function'){url=url();}
|
|
url=url||formEl.action;var callback={success:this.successDelegate,failure:this.failureDelegate,timeout:(this.timeout*1000),argument:{'url':url,'form':form,'callback':callback,'reset':reset}};var isUpload=false;var enctype=formEl.getAttribute('enctype');if(enctype&&enctype.toLowerCase()=='multipart/form-data'){isUpload=true;}
|
|
YAHOO.util.Connect.setForm(form,isUpload,this.sslBlankUrl);this.transaction=YAHOO.util.Connect.asyncRequest('POST',url,callback);}},refresh:function(callback){if(this.defaultUrl==null){return;}
|
|
this.update(this.defaultUrl,null,callback,true);},startAutoRefresh:function(interval,url,params,callback,refreshNow){if(refreshNow){this.update(url||this.defaultUrl,params,callback,true);}
|
|
if(this.autoRefreshProcId){clearInterval(this.autoRefreshProcId);}
|
|
this.autoRefreshProcId=setInterval(this.update.createDelegate(this,[url||this.defaultUrl,params,callback,true]),interval*1000);},stopAutoRefresh:function(){if(this.autoRefreshProcId){clearInterval(this.autoRefreshProcId);}},showLoading:function(){if(this.showLoadIndicator){this.el.update(this.indicatorText);}},prepareUrl:function(url){if(this.disableCaching){var append='_dc='+(new Date().getTime());if(url.indexOf('?')!==-1){url+='&'+append;}else{url+='?'+append;}}
|
|
return url;},processSuccess:function(response){this.transaction=null;this.renderer.render(this.el,response,this);if(response.argument.form&&response.argument.reset){try{response.argument.form.reset();}catch(e){}}
|
|
this.onUpdate.fireDirect(this.el,response);if(typeof response.argument.callback=='function'){response.argument.callback(this.el,true);}},processFailure:function(response){this.transaction=null;this.onFailure.fireDirect(this.el,response);if(typeof response.argument.callback=='function'){response.argument.callback(this.el,false);}},setRenderer:function(renderer){this.renderer=renderer;},getRenderer:function(){return this.renderer;},setDefaultUrl:function(defaultUrl){this.defaultUrl=defaultUrl;},abort:function(){if(this.transaction){YAHOO.util.Connect.abort(this.transaction);}},isUpdating:function(){if(this.transaction){return YAHOO.util.Connect.isCallInProgress(this.transaction);}
|
|
return false;}};YAHOO.ext.UpdateManager.update=function(el,url,params,options){var um=getEl(el,true).getUpdateManager();YAHOO.ext.util.Config.apply(um,options);um.update(url,params,options.callback);}
|
|
YAHOO.ext.UpdateManager.BasicRenderer=function(){};YAHOO.ext.UpdateManager.BasicRenderer.prototype={render:function(el,response,updateManager){el.update(response.responseText,updateManager.loadScripts);}};YAHOO.ext.UpdateManager.defaults={};YAHOO.ext.UpdateManager.defaults.timeout=30;YAHOO.ext.UpdateManager.defaults.loadScripts=false;YAHOO.ext.UpdateManager.defaults.sslBlankUrl='about:blank';YAHOO.ext.UpdateManager.defaults.disableCaching=false;YAHOO.ext.UpdateManager.defaults.showLoadIndicator=true;YAHOO.ext.UpdateManager.defaults.indicatorText='<div class="loading-indicator">Loading...</div>';
|
|
|
|
YAHOO.ext.TabPanel=function(container,onBottom){this.el=getEl(container);if(onBottom){this.bodyEl=getEl(this.createBody(this.el.dom));this.el.addClass('ytabs-bottom');}
|
|
this.stripWrap=getEl(this.createStrip(this.el.dom));this.stripEl=getEl(this.createStripList(this.stripWrap.dom));if(!onBottom){this.bodyEl=getEl(this.createBody(this.el.dom));}
|
|
this.items={};this.active=null;this.onTabChange=new YAHOO.util.CustomEvent('TabItem.onTabChange');this.activateDelegate=this.activate.createDelegate(this);}
|
|
YAHOO.ext.TabPanel.prototype={addTab:function(id,text,content){var item=new YAHOO.ext.TabPanelItem(this,id,text);this.addTabItem(item);if(content){item.setContent(content);}
|
|
return item;},getTab:function(id){return this.items[id];},addTabItem:function(item){this.items[item.id]=item;},removeTab:function(id){var tab=this.items[id];if(tab&&this.active==tab){for(var key in this.items){if(typeof this.items[key]!='function'&&this.items[key]!=tab){this.items[key].activate();break;}}}
|
|
this.stripEl.dom.removeChild(tab.onEl.dom);this.stripEl.dom.removeChild(tab.offEl.dom);this.bodyEl.dom.removeChild(tab.bodyEl.dom);delete this.items[id];},disableTab:function(id){var tab=this.items[id];if(tab&&this.active!=tab){tab.disable();}},enableTab:function(id){var tab=this.items[id];tab.enable();},activate:function(id){var tab=this.items[id];if(!tab.disabled){if(this.active){this.active.hide();}
|
|
this.active=this.items[id];this.active.show();this.onTabChange.fireDirect(this,this.active);}},getActiveTab:function(){return this.active;}};YAHOO.ext.TabPanelItem=function(tabPanel,id,text){this.tabPanel=tabPanel;this.id=id;this.disabled=false;this.text=text;this.loaded=false;this.bodyEl=getEl(tabPanel.createItemBody(tabPanel.bodyEl.dom,id));this.bodyEl.originalDisplay='block';this.bodyEl.setStyle('display','none');this.bodyEl.enableDisplayMode();var stripElements=tabPanel.createStripElements(tabPanel.stripEl.dom,text);this.onEl=getEl(stripElements.on,true);this.offEl=getEl(stripElements.off,true);this.onEl.originalDisplay='inline';this.onEl.enableDisplayMode();this.offEl.originalDisplay='inline';this.offEl.enableDisplayMode();this.offEl.on('click',tabPanel.activateDelegate.createCallback(id));this.onActivate=new YAHOO.util.CustomEvent('TabItem.onActivate');this.onDeactivate=new YAHOO.util.CustomEvent('TabItem.onDeactivate');};YAHOO.ext.TabPanelItem.prototype={show:function(){this.onEl.show();this.offEl.hide();this.bodyEl.show();this.onActivate.fireDirect(this.tabPanel,this);},setText:function(text){this.onEl.dom.firstChild.firstChild.firstChild.innerHTML=text;this.offEl.dom.firstChild.firstChild.innerHTML=text;},activate:function(){this.tabPanel.activate(this.id);},hide:function(){this.onEl.hide();this.offEl.show();this.bodyEl.hide();this.onDeactivate.fireDirect(this.tabPanel,this);},disable:function(){if(this.tabPanel.active!=this){this.disabled=true;this.offEl.addClass('disabled');this.offEl.dom.title='disabled';}},enable:function(){this.disabled=false;this.offEl.removeClass('disabled');this.offEl.dom.title='';},setContent:function(content){this.bodyEl.update(content);},getUpdateManager:function(){return this.bodyEl.getUpdateManager();},setUrl:function(url,params,loadOnce){this.onActivate.subscribe(this._handleRefresh.createDelegate(this,[url,params,loadOnce]));},_handleRefresh:function(url,params,loadOnce){if(!loadOnce||!this.loaded){var updater=this.bodyEl.getUpdateManager();updater.update(url,params,this._setLoaded.createDelegate(this));}},_setLoaded:function(){this.loaded=true;}};YAHOO.ext.TabPanel.prototype.createStrip=function(container){var strip=document.createElement('div');YAHOO.util.Dom.addClass(strip,'tabset');container.appendChild(strip);var stripInner=document.createElement('div');YAHOO.util.Dom.generateId(stripInner,'tab-strip');YAHOO.util.Dom.addClass(stripInner,'hd');strip.appendChild(stripInner);return stripInner;};YAHOO.ext.TabPanel.prototype.createStripList=function(strip){var list=document.createElement('ul');YAHOO.util.Dom.generateId(list,'tab-strip-list');strip.appendChild(list);return list;};YAHOO.ext.TabPanel.prototype.createBody=function(container){var body=document.createElement('div');YAHOO.util.Dom.generateId(body,'tab-body');YAHOO.util.Dom.addClass(body,'yui-ext-tabbody');container.appendChild(body);return body;};YAHOO.ext.TabPanel.prototype.createItemBody=function(bodyEl,id){var body=YAHOO.util.Dom.get(id);if(!body){body=document.createElement('div');body.id=id;}
|
|
YAHOO.util.Dom.addClass(body,'yui-ext-tabitembody');bodyEl.appendChild(body);return body;};YAHOO.ext.TabPanel.prototype.createStripElements=function(stripEl,text){var li=document.createElement('li');var a=document.createElement('a');var em=document.createElement('em');stripEl.appendChild(li);li.appendChild(a);a.appendChild(em);em.innerHTML=text;var li2=document.createElement('li');var a2=document.createElement('a');var em2=document.createElement('em');var strong=document.createElement('strong');stripEl.appendChild(li2);YAHOO.util.Dom.addClass(li2,'on');YAHOO.util.Dom.setStyle(li2,'display','none');li2.appendChild(a2);a2.appendChild(strong);strong.appendChild(em2);em2.innerHTML=text;return{on:li2,off:li};};
|
|
|
|
YAHOO.ext.Animator=function(){this.actors=[];this.playlist=new YAHOO.ext.Animator.AnimSequence();this.captureDelegate=this.capture.createDelegate(this);this.playDelegate=this.play.createDelegate(this);this.syncing=false;this.stopping=false;this.playing=false;for(var i=0;i<arguments.length;i++){this.addActor(arguments[i]);}};YAHOO.ext.Animator.prototype={capture:function(actor,action){if(this.syncing){if(!this.syncMap[actor.id]){this.syncMap[actor.id]=new YAHOO.ext.Animator.AnimSequence();}
|
|
this.syncMap[actor.id].add(action);}else{this.playlist.add(action);}},addActor:function(actor){actor.onCapture.subscribe(this.captureDelegate);this.actors.push(actor);},startCapture:function(clearPlaylist){for(var i=0;i<this.actors.length;i++){var a=this.actors[i];if(!this.isCapturing(a)){a.onCapture.subscribe(this.captureDelegate);}
|
|
a.capturing=true;}
|
|
if(clearPlaylist){this.playlist=new YAHOO.ext.Animator.AnimSequence();}},isCapturing:function(actor){var subscribers=actor.onCapture.subscribers;if(subscribers){for(var i=0;i<subscribers.length;i++){if(subscribers[i]&&subscribers[i].contains(this.captureDelegate)){return true;}}}
|
|
return false;},stopCapture:function(){for(var i=0;i<this.actors.length;i++){var a=this.actors[i];a.onCapture.unsubscribe(this.captureDelegate);a.capturing=false;}},beginSync:function(){this.syncing=true;this.syncMap={};},endSync:function(){this.syncing=false;var composite=new YAHOO.ext.Animator.CompositeSequence();for(key in this.syncMap){if(typeof this.syncMap[key]!='function'){composite.add(this.syncMap[key]);}}
|
|
this.playlist.add(composite);this.syncMap=null;},play:function(oncomplete){if(this.playing)return;this.stopCapture();this.playlist.play(oncomplete);},stop:function(){this.playlist.stop();},isPlaying:function(){return this.playlist.isPlaying();},clear:function(){this.playlist=new YAHOO.ext.Animator.AnimSequence();},addCall:function(fcn,args,scope){this.playlist.add(new YAHOO.ext.Actor.Action(scope,fcn,args||[]));},addAsyncCall:function(fcn,callbackIndex,args,scope){this.playlist.add(new YAHOO.ext.Actor.AsyncAction(scope,fcn,args||[],callbackIndex));},pause:function(seconds){this.playlist.add(new YAHOO.ext.Actor.PauseAction(seconds));}};YAHOO.ext.Animator.AnimSequence=function(){this.actions=[];this.nextDelegate=this.next.createDelegate(this);this.playDelegate=this.play.createDelegate(this);this.oncomplete=null;this.playing=false;this.stopping=false;this.actionIndex=-1;};YAHOO.ext.Animator.AnimSequence.prototype={add:function(action){this.actions.push(action);},next:function(){if(this.stopping){this.playing=false;if(this.oncomplete){this.oncomplete(this,false);}
|
|
return;}
|
|
var nextAction=this.actions[++this.actionIndex];if(nextAction){nextAction.play(this.nextDelegate);}else{this.playing=false;if(this.oncomplete){this.oncomplete(this,true);}}},play:function(oncomplete){if(this.playing)return;this.oncomplete=oncomplete;this.stopping=false;this.playing=true;this.actionIndex=-1;this.next();},stop:function(){this.stopping=true;},isPlaying:function(){return this.playing;},clear:function(){this.actions=[];},addCall:function(fcn,args,scope){this.actions.push(new YAHOO.ext.Actor.Action(scope,fcn,args||[]));},addAsyncCall:function(fcn,callbackIndex,args,scope){this.actions.push(new YAHOO.ext.Actor.AsyncAction(scope,fcn,args||[],callbackIndex));},pause:function(seconds){this.actions.push(new YAHOO.ext.Actor.PauseAction(seconds));}};YAHOO.ext.Animator.CompositeSequence=function(){this.sequences=[];this.completed=0;this.trackDelegate=this.trackCompletion.createDelegate(this);}
|
|
YAHOO.ext.Animator.CompositeSequence.prototype={add:function(sequence){this.sequences.push(sequence);},play:function(onComplete){this.completed=0;if(this.sequences.length<1){if(onComplete)onComplete();return;}
|
|
this.onComplete=onComplete;for(var i=0;i<this.sequences.length;i++){this.sequences[i].play(this.trackDelegate);}},trackCompletion:function(){++this.completed;if(this.completed>=this.sequences.length&&this.onComplete){this.onComplete();}},stop:function(){for(var i=0;i<this.sequences.length;i++){this.sequences[i].stop();}},isPlaying:function(){for(var i=0;i<this.sequences.length;i++){if(this.sequences[i].isPlaying()){return true;}}
|
|
return false;}};
|
|
|
|
YAHOO.ext.Actor=function(element,animator,selfCapture){YAHOO.ext.Actor.superclass.constructor.call(this,element,true);this.el=YAHOO.ext.Element.get(this.id);this.onCapture=new YAHOO.util.CustomEvent('Actor.onCapture');if(animator){animator.addActor(this);}
|
|
this.capturing=selfCapture;this.playlist=selfCapture?new YAHOO.ext.Animator.AnimSequence():null;};YAHOO.extendX(YAHOO.ext.Actor,YAHOO.ext.Element);YAHOO.ext.Actor.prototype.capture=function(action){if(this.playlist!=null){this.playlist.add(action);}
|
|
this.onCapture.fireDirect(this,action);return action;};YAHOO.ext.Actor.overrideAnimation=function(method,animParam,onParam){return function(){if(!this.capturing){return method.apply(this,arguments);}
|
|
var args=Array.prototype.slice.call(arguments,0);if(args[animParam]===true){return this.capture(new YAHOO.ext.Actor.AsyncAction(this,method,args,onParam));}else{return this.capture(new YAHOO.ext.Actor.Action(this,method,args));}};}
|
|
YAHOO.ext.Actor.overrideBasic=function(method){return function(){if(!this.capturing){return method.apply(this,arguments);}
|
|
var args=Array.prototype.slice.call(arguments,0);return this.capture(new YAHOO.ext.Actor.Action(this,method,args));};}
|
|
YAHOO.ext.Actor.prototype.setVisibilityMode=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setVisibilityMode);YAHOO.ext.Actor.prototype.enableDisplayMode=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.enableDisplayMode);YAHOO.ext.Actor.prototype.focus=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.focus);YAHOO.ext.Actor.prototype.addClass=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.addClass);YAHOO.ext.Actor.prototype.removeClass=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.removeClass);YAHOO.ext.Actor.prototype.replaceClass=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.replaceClass);YAHOO.ext.Actor.prototype.setStyle=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setStyle);YAHOO.ext.Actor.prototype.setX=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setX);YAHOO.ext.Actor.prototype.setY=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setY);YAHOO.ext.Actor.prototype.setLeft=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setLeft);YAHOO.ext.Actor.prototype.setTop=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setTop);YAHOO.ext.Actor.prototype.setAbsolutePositioned=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setAbsolutePositioned);YAHOO.ext.Actor.prototype.setRelativePositioned=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setRelativePositioned);YAHOO.ext.Actor.prototype.clearPositioning=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.clearPositioning);YAHOO.ext.Actor.prototype.setPositioning=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.setPositioning);YAHOO.ext.Actor.prototype.clip=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.clip);YAHOO.ext.Actor.prototype.unclip=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.unclip);YAHOO.ext.Actor.prototype.clearOpacity=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.clearOpacity);YAHOO.ext.Actor.prototype.update=YAHOO.ext.Actor.overrideBasic(YAHOO.ext.Actor.superclass.update);YAHOO.ext.Actor.prototype.animate=function(args,duration,onComplete,easing,animType){if(!this.capturing){return YAHOO.ext.Actor.superclass.animate.apply(this,arguments);}
|
|
return this.capture(new YAHOO.ext.Actor.AsyncAction(this,YAHOO.ext.Actor.superclass.animate,[args,duration,onComplete,easing,animType],2));};YAHOO.ext.Actor.prototype.setVisible=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setVisible,1,3);YAHOO.ext.Actor.prototype.toggle=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.toggle,0,2);YAHOO.ext.Actor.prototype.setXY=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setXY,1,3);YAHOO.ext.Actor.prototype.setLocation=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setLocation,2,4);YAHOO.ext.Actor.prototype.setWidth=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setWidth,1,3);YAHOO.ext.Actor.prototype.setHeight=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setHeight,1,3);YAHOO.ext.Actor.prototype.setSize=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setSize,2,4);YAHOO.ext.Actor.prototype.setBounds=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setBounds,4,6);YAHOO.ext.Actor.prototype.setOpacity=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.setHeight,1,3);YAHOO.ext.Actor.prototype.moveTo=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.moveTo,2,4);YAHOO.ext.Actor.prototype.move=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.move,2,4);YAHOO.ext.Actor.prototype.alignTo=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.alignTo,3,5);YAHOO.ext.Actor.prototype.hide=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.hide,0,2);YAHOO.ext.Actor.prototype.show=YAHOO.ext.Actor.overrideAnimation(YAHOO.ext.Actor.superclass.show,0,2);YAHOO.ext.Actor.prototype.startCapture=function(){this.capturing=true;this.playlist=new YAHOO.ext.Animator.AnimSequence();};YAHOO.ext.Actor.prototype.stopCapture=function(){this.capturing=false;};YAHOO.ext.Actor.prototype.clear=function(){this.playlist=new YAHOO.ext.Animator.AnimSequence();};YAHOO.ext.Actor.prototype.play=function(oncomplete){this.capturing=false;if(this.playlist){this.playlist.play(oncomplete);}};YAHOO.ext.Actor.prototype.addCall=function(fcn,args,scope){this.capture(new YAHOO.ext.Actor.Action(scope,fcn,args||[]));};YAHOO.ext.Actor.prototype.addAsyncCall=function(fcn,callbackIndex,args,scope){this.capture(new YAHOO.ext.Actor.AsyncAction(scope,fcn,args||[],callbackIndex));},YAHOO.ext.Actor.prototype.pause=function(seconds){this.capture(new YAHOO.ext.Actor.PauseAction(seconds));};YAHOO.ext.Actor.prototype.shake=function(){this.move('left',20,true,.05);this.move('right',40,true,.05);this.move('left',40,true,.05);this.move('right',20,true,.05);};YAHOO.ext.Actor.prototype.bounce=function(){this.move('up',20,true,.05);this.move('down',40,true,.05);this.move('up',40,true,.05);this.move('down',20,true,.05);};YAHOO.ext.Actor.prototype.blindShow=function(anchor,newSize,duration,easing){var size=newSize||this.getSize();this.clip();this.setVisible(true);anchor=anchor.toLowerCase();switch(anchor){case't':case'top':this.setHeight(1);this.setHeight(newSize,true,duration||.5,null,easing||YAHOO.util.Easing.easeOut);break;case'l':case'left':this.setWidth(1);this.setWidth(newSize,true,duration||.5,null,easing||YAHOO.util.Easing.easeOut);break;}
|
|
this.unclip();return size;};YAHOO.ext.Actor.prototype.blindHide=function(anchor,duration,easing){var size=this.getSize();this.clip();anchor=anchor.toLowerCase();switch(anchor){case't':case'top':this.setSize(size.width,1,true,duration||.5,null,easing||YAHOO.util.Easing.easeIn);this.setVisible(false);break;case'l':case'left':this.setSize(1,size.height,true,duration||.5,null,easing||YAHOO.util.Easing.easeIn);this.setVisible(false);break;case'r':case'right':this.animate({width:{to:1},points:{by:[this.getWidth(),0]}},duration||.5,null,YAHOO.util.Easing.easeIn,YAHOO.util.Motion);this.setVisible(false);break;case'b':case'bottom':this.animate({height:{to:1},points:{by:[0,this.getHeight()]}},duration||.5,null,YAHOO.util.Easing.easeIn,YAHOO.util.Motion);this.setVisible(false);break;}
|
|
return size;};YAHOO.ext.Actor.prototype.slideShow=function(anchor,newSize,duration,easing){var size=newSize||this.getSize();this.clip();var firstChild=this.dom.firstChild;if(!firstChild||(firstChild.nodeName&&"#TEXT"==firstChild.nodeName.toUpperCase())){this.blindShow(anchor,newSize,duration,easing);return;}
|
|
var child=YAHOO.ext.Element.get(firstChild,true);var pos=child.getPositioning();this.addCall(child.setAbsolutePositioned,null,child);this.setVisible(true);anchor=anchor.toLowerCase();switch(anchor){case't':case'top':this.addCall(child.setStyle,['left','0px'],child);this.addCall(child.setStyle,['bottom','0px'],child);this.setHeight(1);this.setHeight(newSize,true,duration||.5,null,easing||YAHOO.util.Easing.easeOut);break;case'l':case'left':this.addCall(child.setStyle,['right','0px'],child);this.addCall(child.setStyle,['top','0px'],child);this.setWidth(1);this.setWidth(newSize,true,duration||.5,null,easing||YAHOO.util.Easing.easeOut);break;}
|
|
this.addCall(child.setPositioning,[pos],child);this.unclip();return size;};YAHOO.ext.Actor.prototype.slideHide=function(anchor,duration,easing){var size=this.getSize();this.clip();var firstChild=this.dom.firstChild;if(!firstChild||(firstChild.nodeName&&"#TEXT"==firstChild.nodeName.toUpperCase())){this.blindHide(anchor,duration,easing);return;}
|
|
var child=YAHOO.ext.Element.get(firstChild,true);var pos=child.getPositioning();this.addCall(child.setAbsolutePositioned,null,child);anchor=anchor.toLowerCase();switch(anchor){case't':case'top':this.addCall(child.setStyle,['left','0px'],child);this.addCall(child.setStyle,['bottom','0px'],child);this.setSize(size.width,1,true,duration||.5,null,easing||YAHOO.util.Easing.easeIn);this.setVisible(false);break;case'l':case'left':this.addCall(child.setStyle,['right','0px'],child);this.addCall(child.setStyle,['top','0px'],child);this.setSize(1,size.height,true,duration||.5,null,easing||YAHOO.util.Easing.easeIn);this.setVisible(false);break;case'r':case'right':this.addCall(child.setStyle,['left','0px'],child);this.addCall(child.setStyle,['top','0px'],child);this.animate({width:{to:1},points:{by:[this.getWidth(),0]}},duration||.5,null,YAHOO.util.Easing.easeIn,YAHOO.util.Motion);this.setVisible(false);break;case'b':case'bottom':this.addCall(child.setStyle,['left','0px'],child);this.addCall(child.setStyle,['bottom','0px'],child);this.animate({height:{to:1},points:{by:[0,this.getHeight()]}},duration||.5,null,YAHOO.util.Easing.easeIn,YAHOO.util.Motion);this.setVisible(false);break;}
|
|
this.addCall(child.setPositioning,[pos],child);return size;};YAHOO.ext.Actor.prototype.squish=function(duration){var size=this.getSize();this.clip();this.setSize(1,1,true,duration||.5);this.setVisible(false);return size;};YAHOO.ext.Actor.prototype.appear=function(duration){this.setVisible(true,true,duration);};YAHOO.ext.Actor.prototype.fade=function(duration){this.setVisible(false,true,duration);};YAHOO.ext.Actor.prototype.switchOff=function(duration){this.clip();this.setVisible(false,true,.1);this.clearOpacity();this.setVisible(true);this.animate({height:{to:1},points:{by:[0,this.getHeight()/2]}},duration||.5,null,YAHOO.util.Easing.easeOut,YAHOO.util.Motion);this.setVisible(false);};YAHOO.ext.Actor.prototype.highlight=function(color,fromColor,duration,attribute){attribute=attribute||'backgroundColor';var original=this.getStyle(attribute);fromColor=fromColor||((original&&original!=''&&original!='transparent')?original:'#FFFFFF');var cfg={};cfg[attribute]={to:color,from:fromColor};this.setVisible(true);this.animate(cfg,duration||.5,null,YAHOO.util.Easing.bounceOut,YAHOO.util.ColorAnim);this.setStyle(attribute,original);};YAHOO.ext.Actor.prototype.pulsate=function(count,duration){count=count||3;for(var i=0;i<count;i++){this.toggle(true,duration||.25);this.toggle(true,duration||.25);}};YAHOO.ext.Actor.prototype.dropOut=function(duration){this.animate({opacity:{to:0},points:{by:[0,this.getHeight()]}},duration||.5,null,YAHOO.util.Easing.easeIn,YAHOO.util.Motion);this.setVisible(false);};YAHOO.ext.Actor.prototype.moveOut=function(anchor,duration,easing){var Y=YAHOO.util;var vw=Y.Dom.getViewportWidth();var vh=Y.Dom.getViewportHeight();var cpoints=this.getCenterXY()
|
|
var centerX=cpoints[0];var centerY=cpoints[1];var anchor=anchor.toLowerCase();var p;switch(anchor){case't':case'top':p=[centerX,-this.getHeight()];break;case'l':case'left':p=[-this.getWidth(),centerY];break;case'r':case'right':p=[vw+this.getWidth(),centerY];break;case'b':case'bottom':p=[centerX,vh+this.getHeight()];break;case'tl':case'top-left':p=[-this.getWidth(),-this.getHeight()];break;case'bl':case'bottom':p=[-this.getWidth(),vh+this.getHeight()];break;case'br':case'bottom-right':p=[vw+this.getWidth(),vh+this.getHeight()];break;case'tr':case'top-right':p=[vw+this.getWidth(),-this.getHeight()];break;}
|
|
this.moveTo(p[0],p[1],true,duration||.35,null,easing||Y.Easing.easeIn);this.setVisible(false);};YAHOO.ext.Actor.prototype.moveIn=function(anchor,to,duration,easing){to=to||this.getCenterXY();this.moveOut(anchor,.01);this.setVisible(true);this.setXY(to,true,duration||.35,null,easing||YAHOO.util.Easing.easeOut);};YAHOO.ext.Actor.Action=function(actor,method,args){this.actor=actor;this.method=method;this.args=args;}
|
|
YAHOO.ext.Actor.Action.prototype={play:function(onComplete){this.method.apply(this.actor||window,this.args);onComplete();}};YAHOO.ext.Actor.AsyncAction=function(actor,method,args,onIndex){YAHOO.ext.Actor.AsyncAction.superclass.constructor.call(this,actor,method,args);this.onIndex=onIndex;this.originalCallback=this.args[onIndex];}
|
|
YAHOO.extendX(YAHOO.ext.Actor.AsyncAction,YAHOO.ext.Actor.Action);YAHOO.ext.Actor.AsyncAction.prototype.play=function(onComplete){var callbackArg=this.originalCallback?this.originalCallback.createSequence(onComplete):onComplete;this.args[this.onIndex]=callbackArg;this.method.apply(this.actor,this.args);};YAHOO.ext.Actor.PauseAction=function(seconds){this.seconds=seconds;};YAHOO.ext.Actor.PauseAction.prototype={play:function(onComplete){setTimeout(onComplete,this.seconds*1000);}};
|
|
|
|
YAHOO.ext.Toolbar=function(container){this.el=getEl(container,true);var div=document.createElement('div');div.className='ytoolbar';var tb=document.createElement('table');tb.border=0;tb.cellPadding=0;tb.cellSpacing=0;div.appendChild(tb);var tbody=document.createElement('tbody');tb.appendChild(tbody);var tr=document.createElement('tr');tbody.appendChild(tr);this.el.dom.appendChild(div);this.tr=tr;};YAHOO.ext.Toolbar.prototype={add:function(){for(var i=0;i<arguments.length;i++){var el=arguments[i];var td=document.createElement('td');this.tr.appendChild(td);if(el instanceof YAHOO.ext.ToolbarButton){el.init(td);}else if(typeof el=='string'){var span=document.createElement('span');if(el=='separator'){span.className='ytb-sep';}else{span.innerHTML=el;span.className='ytb-text';}
|
|
td.appendChild(span);}else if(typeof el=='object'){td.appendChild(el);}}},addSeparator:function(){var td=document.createElement('td');this.tr.appendChild(td);var span=document.createElement('span');span.className='ytb-sep';td.appendChild(span);},addButton:function(config){var b=new YAHOO.ext.ToolbarButton(config);this.add(b);return b;},addText:function(text){var td=document.createElement('td');this.tr.appendChild(td);var span=document.createElement('span');span.className='ytb-text';span.innerHTML=text;td.appendChild(span);return span;}};YAHOO.ext.ToolbarButton=function(config){YAHOO.ext.util.Config.apply(this,config);};YAHOO.ext.ToolbarButton.prototype={init:function(appendTo){var element=document.createElement('span');element.className='ytb-button';this.disabled=(this.disabled===true);var inner=document.createElement('span');inner.className='ytb-button-inner '+this.className;if(this.tooltip){element.setAttribute('title',this.tooltip);}
|
|
element.appendChild(inner);appendTo.appendChild(element);this.el=getEl(element,true);inner.innerHTML=(this.text?this.text:' ');this.el.mon('click',this.onClick,this,true);this.el.mon('mouseover',this.onMouseOver,this,true);this.el.mon('mouseout',this.onMouseOut,this,true);},disable:function(){this.disabled=true;if(this.el){this.el.addClass('ytb-button-disabled');}},enable:function(){this.disabled=false;if(this.el){this.el.removeClass('ytb-button-disabled');}},isDisabled:function(){return this.disabled===true;},setDisabled:function(disabled){if(disabled){this.disable();}else{this.enable();}},onClick:function(){if(!this.disabled&&this.click){this.click.call(this.scope||window,this);}},onMouseOver:function(){if(!this.disabled){this.el.addClass('ytb-button-over');if(this.mouseover){this.mouseover.call(this.scope||window,this);}}},onMouseOut:function(){this.el.removeClass('ytb-button-over');if(!this.disabled){if(this.mouseout){this.mouseout.call(this.scope||window,this);}}}};
|
|
|
|
YAHOO.ext.Resizable=function(el,config){var getEl=YAHOO.ext.Element.get;this.el=getEl(el,true);this.el.autoBoxAdjust=true;if(this.el.getStyle('position')!='absolute'){this.el.setStyle('position','relative');}
|
|
var dh=YAHOO.ext.DomHelper;var tpl=dh.createTemplate({tag:'div',cls:'yresizable-handle yresizable-handle-{0}',html:' '});this.east=getEl(tpl.append(this.el.dom,['east']),true);this.south=getEl(tpl.append(this.el.dom,['south']),true);if(config&&config.multiDirectional){this.west=getEl(tpl.append(this.el.dom,['west']),true);this.north=getEl(tpl.append(this.el.dom,['north']),true);}
|
|
this.corner=getEl(tpl.append(this.el.dom,['southeast']),true);this.proxy=getEl(dh.insertBefore(document.body.firstChild,{tag:'div',cls:'yresizable-proxy',id:this.el.id+'-rzproxy'}),true);this.proxy.autoBoxAdjust=true;this.moveHandler=YAHOO.ext.EventManager.wrap(this.onMouseMove,this,true);this.upHandler=YAHOO.ext.EventManager.wrap(this.onMouseUp,this,true);this.selHandler=YAHOO.ext.EventManager.wrap(this.cancelSelection,this,true);this.events={'beforeresize':new YAHOO.util.CustomEvent(),'resize':new YAHOO.util.CustomEvent()};this.dir=null;this.resizeChild=false;this.adjustments=[0,0];this.minWidth=5;this.minHeight=5;this.maxWidth=10000;this.maxHeight=10000;this.enabled=true;this.animate=false;this.duration=.35;this.dynamic=false;this.multiDirectional=false;this.disableTrackOver=false;this.easing=YAHOO.util.Easing?YAHOO.util.Easing.easeOutStrong:null;YAHOO.ext.util.Config.apply(this,config);var mdown=this.onMouseDown.createDelegate(this);this.east.mon('mousedown',mdown);this.south.mon('mousedown',mdown);if(this.multiDirectional){this.west.mon('mousedown',mdown);this.north.mon('mousedown',mdown);}
|
|
this.corner.mon('mousedown',mdown);if(!this.disableTrackOver){var mover=this.onMouseOver.createDelegate(this);var mout=this.onMouseOut.createDelegate(this);this.east.mon('mouseover',mover);this.east.mon('mouseout',mout);this.south.mon('mouseover',mover);this.south.mon('mouseout',mout);if(this.multiDirectional){this.west.mon('mouseover',mover);this.west.mon('mouseout',mout);this.north.mon('mouseover',mover);this.north.mon('mouseout',mout);}
|
|
this.corner.mon('mouseover',mover);this.corner.mon('mouseout',mout);}
|
|
this.updateChildSize();};YAHOO.extendX(YAHOO.ext.Resizable,YAHOO.ext.util.Observable,{resizeTo:function(width,height){this.el.setSize(width,height);this.fireEvent('resize',this,width,height,null);},cancelSelection:function(e){e.preventDefault();},startSizing:function(e){this.fireEvent('beforeresize',this,e);if(this.enabled){e.preventDefault();this.startBox=this.el.getBox();this.startPoint=e.getXY();this.offsets=[(this.startBox.x+this.startBox.width)-this.startPoint[0],(this.startBox.y+this.startBox.height)-this.startPoint[1]];this.proxy.setBox(this.startBox);if(!this.dynamic){this.proxy.show();}
|
|
YAHOO.util.Event.on(document.body,'selectstart',this.selHandler);YAHOO.util.Event.on(document.body,'mousemove',this.moveHandler);YAHOO.util.Event.on(document.body,'mouseup',this.upHandler);}},onMouseDown:function(e){if(this.enabled){var t=e.getTarget();if(t==this.corner.dom){this.dir='both';this.proxy.setStyle('cursor',this.corner.getStyle('cursor'));this.startSizing(e);}else if(t==this.east.dom){this.dir='east';this.proxy.setStyle('cursor',this.east.getStyle('cursor'));this.startSizing(e);}else if(t==this.south.dom){this.dir='south';this.proxy.setStyle('cursor',this.south.getStyle('cursor'));this.startSizing(e);}else if(t==this.west.dom){this.dir='west';this.proxy.setStyle('cursor',this.west.getStyle('cursor'));this.startSizing(e);}else if(t==this.north.dom){this.dir='north';this.proxy.setStyle('cursor',this.north.getStyle('cursor'));this.startSizing(e);}}},onMouseUp:function(e){YAHOO.util.Event.removeListener(document.body,'selectstart',this.selHandler);YAHOO.util.Event.removeListener(document.body,'mousemove',this.moveHandler);YAHOO.util.Event.removeListener(document.body,'mouseup',this.upHandler);var size=this.resizeElement();this.fireEvent('resize',this,size.width,size.height,e);},updateChildSize:function(){if(this.resizeChild&&this.el.dom.firstChild&&this.el.dom.offsetWidth){var el=this.el;var adj=this.adjustments;setTimeout(function(){var c=YAHOO.ext.Element.get(el.dom.firstChild,true);var b=el.getBox(true);c.setSize(b.width+adj[0],b.height+adj[1]);},1);}},resizeElement:function(){var box=this.proxy.getBox();this.el.setBox(box,false,this.animate,this.duration,null,this.easing);this.updateChildSize();this.proxy.hide();return box;},onMouseMove:function(e){if(this.enabled){var xy=e.getXY();if(this.dir=='both'||this.dir=='east'||this.dir=='south'){var w=Math.min(Math.max(this.minWidth,xy[0]-this.startBox.x+this.offsets[0]),this.maxWidth);var h=Math.min(Math.max(this.minHeight,xy[1]-this.startBox.y+this.offsets[1]),this.maxHeight);if(this.dir=='both'){this.proxy.setSize(w,h);}else if(this.dir=='east'){this.proxy.setWidth(w);}else if(this.dir=='south'){this.proxy.setHeight(h);}}else{var x=this.startBox.x+(xy[0]-this.startPoint[0]);var y=this.startBox.y+(xy[1]-this.startPoint[1]);var w=this.startBox.width+(this.startBox.x-x);var h=this.startBox.height+(this.startBox.y-y);if(this.dir=='west'&&w<=this.maxWidth&&w>=this.minWidth){this.proxy.setX(x);this.proxy.setWidth(w);}else if(this.dir=='north'&&h<=this.maxHeight&&h>=this.minHeight){this.proxy.setY(y);this.proxy.setHeight(h);}}
|
|
if(this.dynamic){this.resizeElement();}}},onMouseOver:function(){if(this.enabled)this.el.addClass('yresizable-over');},onMouseOut:function(){this.el.removeClass('yresizable-over');}});
|
|
|
|
YAHOO.util.DragDropMgr.clickTimeThresh=350;YAHOO.ext.SplitBar=function(dragElement,resizingElement,orientation,placement){this.el=YAHOO.ext.Element.get(dragElement,true);this.resizingEl=YAHOO.ext.Element.get(resizingElement,true);this.orientation=orientation||YAHOO.ext.SplitBar.HORIZONTAL;this.minSize=0;this.maxSize=2000;this.onMoved=new YAHOO.util.CustomEvent("SplitBarMoved",this);this.animate=false;this.useShim=false;this.shim=null;this.proxy=YAHOO.ext.SplitBar.createProxy(this.orientation);this.dd=new YAHOO.util.DDProxy(this.el.dom.id,"SplitBars",{dragElId:this.proxy.id});this.dd.b4StartDrag=this.onStartProxyDrag.createDelegate(this);this.dd.endDrag=this.onEndProxyDrag.createDelegate(this);this.dragSpecs={};this.adapter=new YAHOO.ext.SplitBar.BasicLayoutAdapter();this.adapter.init(this);if(this.orientation==YAHOO.ext.SplitBar.HORIZONTAL){this.placement=placement||(this.el.getX()>this.resizingEl.getX()?YAHOO.ext.SplitBar.LEFT:YAHOO.ext.SplitBar.RIGHT);this.el.setStyle('cursor','e-resize');}else{this.placement=placement||(this.el.getY()>this.resizingEl.getY()?YAHOO.ext.SplitBar.TOP:YAHOO.ext.SplitBar.BOTTOM);this.el.setStyle('cursor','n-resize');}
|
|
this.events={'resize':this.onMoved,'moved':this.onMoved}}
|
|
YAHOO.ext.SplitBar.prototype={fireEvent:YAHOO.ext.util.Observable.prototype.fireEvent,addListener:YAHOO.ext.util.Observable.prototype.addListener,delayedListener:YAHOO.ext.util.Observable.prototype.delayedListener,removeListener:YAHOO.ext.util.Observable.prototype.removeListener,onStartProxyDrag:function(x,y){if(this.useShim){if(!this.shim){this.shim=YAHOO.ext.SplitBar.createShim();}
|
|
this.shim.setVisible(true);}
|
|
YAHOO.util.Dom.setStyle(this.proxy,'display','block');var size=this.adapter.getElementSize(this);var c1=size-this.minSize;var c2=Math.max(this.maxSize-size,0);if(this.orientation==YAHOO.ext.SplitBar.HORIZONTAL){this.dd.resetConstraints();this.dd.setXConstraint(this.placement==YAHOO.ext.SplitBar.LEFT?c1:c2,this.placement==YAHOO.ext.SplitBar.LEFT?c2:c1);this.dd.setYConstraint(0,0);}else{this.dd.resetConstraints();this.dd.setXConstraint(0,0);this.dd.setYConstraint(this.placement==YAHOO.ext.SplitBar.TOP?c1:c2,this.placement==YAHOO.ext.SplitBar.TOP?c2:c1);}
|
|
this.dragSpecs.startSize=size;this.dragSpecs.startPoint=[x,y];YAHOO.util.DDProxy.prototype.b4StartDrag.call(this.dd,x,y);},onEndProxyDrag:function(e){YAHOO.util.Dom.setStyle(this.proxy,'display','none');var endPoint=YAHOO.util.Event.getXY(e);if(this.useShim){this.shim.setVisible(false);}
|
|
var newSize;if(this.orientation==YAHOO.ext.SplitBar.HORIZONTAL){newSize=this.dragSpecs.startSize+
|
|
(this.placement==YAHOO.ext.SplitBar.LEFT?endPoint[0]-this.dragSpecs.startPoint[0]:this.dragSpecs.startPoint[0]-endPoint[0]);}else{newSize=this.dragSpecs.startSize+
|
|
(this.placement==YAHOO.ext.SplitBar.TOP?endPoint[1]-this.dragSpecs.startPoint[1]:this.dragSpecs.startPoint[1]-endPoint[1]);}
|
|
newSize=Math.min(Math.max(newSize,this.minSize),this.maxSize);if(newSize!=this.dragSpecs.startSize){this.adapter.setElementSize(this,newSize);this.onMoved.fireDirect(this,newSize);}},getAdapter:function(){return this.adapter;},setAdapter:function(adapter){this.adapter=adapter;this.adapter.init(this);},getMinimumSize:function(){return this.minSize;},setMinimumSize:function(minSize){this.minSize=minSize;},getMaximumSize:function(){return this.maxSize;},setMaximumSize:function(maxSize){this.maxSize=maxSize;},setCurrentSize:function(size){var oldAnimate=this.animate;this.animate=false;this.adapter.setElementSize(this,size);this.animate=oldAnimate;}};YAHOO.ext.SplitBar.createShim=function(){var shim=document.createElement('div');YAHOO.util.Dom.generateId(shim,'split-shim');YAHOO.util.Dom.setStyle(shim,'width','100%');YAHOO.util.Dom.setStyle(shim,'height','100%');YAHOO.util.Dom.setStyle(shim,'position','absolute');YAHOO.util.Dom.setStyle(shim,'background','white');YAHOO.util.Dom.setStyle(shim,'visibility','hidden');YAHOO.util.Dom.setStyle(shim,'z-index',2);window.document.body.appendChild(shim);var shimEl=YAHOO.ext.Element.get(shim);shimEl.setOpacity(.01);shimEl.setXY([0,0]);return shimEl;}
|
|
YAHOO.ext.SplitBar.createProxy=function(orientation){var proxy=document.createElement('div');YAHOO.util.Dom.generateId(proxy,'split-proxy');YAHOO.util.Dom.setStyle(proxy,'position','absolute');YAHOO.util.Dom.setStyle(proxy,'visibility','hidden');YAHOO.util.Dom.setStyle(proxy,'z-index',999);YAHOO.util.Dom.setStyle(proxy,'background-color',"#aaa");if(orientation==YAHOO.ext.SplitBar.HORIZONTAL){YAHOO.util.Dom.setStyle(proxy,'cursor','e-resize');}else{YAHOO.util.Dom.setStyle(proxy,'cursor','n-resize');}
|
|
YAHOO.util.Dom.setStyle(proxy,'line-height','0px');YAHOO.util.Dom.setStyle(proxy,'font-size','0px');window.document.body.appendChild(proxy);return proxy;}
|
|
YAHOO.ext.SplitBar.BasicLayoutAdapter=function(){}
|
|
YAHOO.ext.SplitBar.BasicLayoutAdapter.prototype={init:function(s){},getElementSize:function(s){if(s.orientation==YAHOO.ext.SplitBar.HORIZONTAL){return s.resizingEl.getWidth();}else{return s.resizingEl.getHeight();}},setElementSize:function(s,newSize,onComplete){if(s.orientation==YAHOO.ext.SplitBar.HORIZONTAL){if(!YAHOO.util.Anim||!s.animate){s.resizingEl.setWidth(newSize);if(onComplete){onComplete(s,newSize);}}else{s.resizingEl.setWidth(newSize,true,.1,onComplete,YAHOO.util.Easing.easeOut);}}else{if(!YAHOO.util.Anim||!s.animate){s.resizingEl.setHeight(newSize);if(onComplete){onComplete(s,newSize);}}else{s.resizingEl.setHeight(newSize,true,.1,onComplete,YAHOO.util.Easing.easeOut);}}}};YAHOO.ext.SplitBar.AbsoluteLayoutAdapter=function(container){this.basic=new YAHOO.ext.SplitBar.BasicLayoutAdapter();this.container=getEl(container);}
|
|
YAHOO.ext.SplitBar.AbsoluteLayoutAdapter.prototype={init:function(s){this.basic.init(s);},getElementSize:function(s){return this.basic.getElementSize(s);},setElementSize:function(s,newSize,onComplete){this.basic.setElementSize(s,newSize,this.moveSplitter.createDelegate(this,[s]));},moveSplitter:function(s){var yes=YAHOO.ext.SplitBar;switch(s.placement){case yes.LEFT:s.el.setX(s.resizingEl.getRight());break;case yes.RIGHT:s.el.setStyle('right',(this.container.getWidth()-s.resizingEl.getLeft())+'px');break;case yes.TOP:s.el.setY(s.resizingEl.getBottom());break;case yes.BOTTOM:s.el.setY(s.resizingEl.getTop()-s.el.getHeight());break;}}};YAHOO.ext.SplitBar.VERTICAL=1;YAHOO.ext.SplitBar.HORIZONTAL=2;YAHOO.ext.SplitBar.LEFT=1;YAHOO.ext.SplitBar.RIGHT=2;YAHOO.ext.SplitBar.TOP=3;YAHOO.ext.SplitBar.BOTTOM=4;
|
|
|
|
YAHOO.namespace('ext.grid');YAHOO.ext.grid.Grid=function(container,dataModel,colModel,selectionModel){this.container=YAHOO.ext.Element.get(container);if(this.container.getStyle('position')!='absolute'){this.container.setStyle('position','relative');}
|
|
this.id=this.container.id;this.rows=[];this.rowCount=0;this.fieldId=null;this.dataModel=dataModel;this.colModel=colModel;this.selModel=selectionModel;this.activeEditor=null;this.editingCell=null;this.minColumnWidth=25;this.autoSizeColumns=false;this.autoSizeHeaders=false;this.monitorWindowResize=true;this.maxRowsToMeasure=0;this.trackMouseOver=false;this.enableDragDrop=false;this.stripeRows=true;this.allowTextSelectionPattern=/INPUT|TEXTAREA|SELECT/i;this.setValueDelegate=this.setCellValue.createDelegate(this);var CE=YAHOO.util.CustomEvent;this.events={'click':new CE('click'),'dblclick':new CE('dblclick'),'mousedown':new CE('mousedown'),'mouseup':new CE('mouseup'),'mouseover':new CE('mouseover'),'mouseout':new CE('mouseout'),'keypress':new CE('keypress'),'keydown':new CE('keydown'),'cellclick':new CE('cellclick'),'celldblclick':new CE('celldblclick'),'rowclick':new CE('rowclick'),'rowdblclick':new CE('rowdblclick'),'headerclick':new CE('headerclick'),'rowcontextmenu':new CE('rowcontextmenu'),'headercontextmenu':new CE('headercontextmenu'),'beforeedit':new CE('beforeedit'),'afteredit':new CE('afteredit'),'bodyscroll':new CE('bodyscroll'),'columnresize':new CE('columnresize'),'startdrag':new CE('startdrag'),'enddrag':new CE('enddrag'),'dragdrop':new CE('dragdrop'),'dragover':new CE('dragover'),'dragenter':new CE('dragenter'),'dragout':new CE('dragout')};};YAHOO.ext.grid.Grid.prototype={render:function(){if(!this.view){if(this.dataModel.isPaged()){this.view=new YAHOO.ext.grid.PagedGridView();}else{this.view=new YAHOO.ext.grid.GridView();}}
|
|
this.view.init(this);this.el=getEl(this.view.render(),true);var c=this.container;c.mon("click",this.onClick,this,true);c.mon("dblclick",this.onDblClick,this,true);c.mon("contextmenu",this.onContextMenu,this,true);c.mon("selectstart",this.cancelTextSelection,this,true);c.mon("mousedown",this.cancelTextSelection,this,true);c.mon("mousedown",this.onMouseDown,this,true);c.mon("mouseup",this.onMouseUp,this,true);if(this.trackMouseOver){this.el.mon("mouseover",this.onMouseOver,this,true);this.el.mon("mouseout",this.onMouseOut,this,true);}
|
|
c.mon("keypress",this.onKeyPress,this,true);c.mon("keydown",this.onKeyDown,this,true);this.init();},init:function(){this.rows=this.el.dom.rows;if(!this.disableSelection){if(!this.selModel){this.selModel=new YAHOO.ext.grid.DefaultSelectionModel(this);}
|
|
this.selModel.init(this);this.selModel.onSelectionChange.subscribe(this.updateField,this,true);}else{this.selModel=new YAHOO.ext.grid.DisableSelectionModel(this);this.selModel.init(this);}
|
|
if(this.enableDragDrop){this.dd=new YAHOO.ext.grid.GridDD(this,this.container.dom);}},onMouseDown:function(e){this.fireEvent('mousedown',e);},onMouseUp:function(e){this.fireEvent('mouseup',e);},onMouseOver:function(e){this.fireEvent('mouseover',e);},onMouseOut:function(e){this.fireEvent('mouseout',e);},onKeyPress:function(e){this.fireEvent('keypress',e);},onKeyDown:function(e){this.fireEvent('keydown',e);},fireEvent:function(){var ce=this.events[arguments[0].toLowerCase()];ce.fireDirect.apply(ce,Array.prototype.slice.call(arguments,1));},addListener:function(eventName,fn,scope,override){this.events[eventName.toLowerCase()].subscribe(fn,scope,override);},on:function(eventName,fn,scope,override){this.events[eventName.toLowerCase()].subscribe(fn,scope,override);},removeListener:function(eventName,fn,scope){this.events[eventName.toLowerCase()].unsubscribe(fn,scope);},onClick:function(e){this.fireEvent('click',e);var target=e.getTarget();var row=this.getRowFromChild(target);var cell=this.getCellFromChild(target);var header=this.getHeaderFromChild(target);if(row){this.fireEvent('rowclick',this,row.rowIndex,e);}
|
|
if(cell){this.fireEvent('cellclick',this,row.rowIndex,cell.columnIndex,e);}
|
|
if(header){this.fireEvent('headerclick',this,header.columnIndex,e);}},onContextMenu:function(e){var target=e.getTarget();var row=this.getRowFromChild(target);var header=this.getHeaderFromChild(target);if(row){this.fireEvent('rowcontextmenu',this,row.rowIndex,e);}
|
|
if(header){this.fireEvent('headercontextmenu',this,header.columnIndex,e);}
|
|
e.preventDefault();},onDblClick:function(e){this.fireEvent('dblclick',e);var target=e.getTarget();var row=this.getRowFromChild(target);var cell=this.getCellFromChild(target);if(row){this.fireEvent('rowdblclick',this,row.rowIndex,e);}
|
|
if(cell){this.fireEvent('celldblclick',this,row.rowIndex,cell.columnIndex,e);}},startEditing:function(rowIndex,colIndex){var row=this.rows[rowIndex];var cell=row.childNodes[colIndex];this.stopEditing();setTimeout(this.doEdit.createDelegate(this,[row,cell]),10);},stopEditing:function(){if(this.activeEditor){this.activeEditor.stopEditing();}},doEdit:function(row,cell){if(!row||!cell)return;var cm=this.colModel;var dm=this.dataModel;var colIndex=cell.columnIndex;var rowIndex=row.rowIndex;if(cm.isCellEditable(colIndex,rowIndex)){var ed=cm.getCellEditor(colIndex,rowIndex);if(ed){if(this.activeEditor){this.activeEditor.stopEditing();}
|
|
this.fireEvent('beforeedit',this,rowIndex,colIndex);this.activeEditor=ed;this.editingCell=cell;this.view.ensureVisible(row,true);try{cell.focus();}catch(e){}
|
|
ed.init(this,this.el.dom.parentNode,this.setValueDelegate);var value=dm.getValueAt(rowIndex,cm.getDataIndex(colIndex));setTimeout(ed.startEditing.createDelegate(ed,[value,row,cell]),1);}}},setCellValue:function(value,rowIndex,colIndex){this.dataModel.setValueAt(value,rowIndex,this.colModel.getDataIndex(colIndex));this.fireEvent('afteredit',this,rowIndex,colIndex);},cancelTextSelection:function(e){var target=e.getTarget();if(target&&target!=this.el.dom.parentNode&&!this.allowTextSelectionPattern.test(target.tagName)){e.preventDefault();}},autoSize:function(){this.view.updateWrapHeight();this.view.adjustForScroll();},scrollTo:function(row){if(typeof row=='number'){row=this.rows[row];}
|
|
this.view.ensureVisible(row,true);},getEditingCell:function(){return this.editingCell;},bindToField:function(fieldId){this.fieldId=fieldId;this.readField();},updateField:function(){if(this.fieldId){var field=YAHOO.util.Dom.get(this.fieldId);field.value=this.getSelectedRowIds().join(',');}},readField:function(){if(this.fieldId){var field=YAHOO.util.Dom.get(this.fieldId);var values=field.value.split(',');var rows=this.getRowsById(values);this.selModel.selectRows(rows,false);}},getRow:function(index){return this.rows[index];},getRowsById:function(id){var dm=this.dataModel;if(!(id instanceof Array)){for(var i=0;i<this.rows.length;i++){if(dm.getRowId(i)==id){return this.rows[i];}}
|
|
return null;}
|
|
var found=[];var re="^(?:";for(var i=0;i<id.length;i++){re+=id[i];if(i!=id.length-1)re+="|";}
|
|
var regex=new RegExp(re+")$");for(var i=0;i<this.rows.length;i++){if(regex.test(dm.getRowId(i))){found.push(this.rows[i]);}}
|
|
return found;},getRowAfter:function(row){return this.getSibling('next',row);},getRowBefore:function(row){return this.getSibling('previous',row);},getCellAfter:function(cell,includeHidden){var next=this.getSibling('next',cell);if(next&&!includeHidden&&this.colModel.isHidden(next.columnIndex)){return this.getCellAfter(next);}
|
|
return next;},getCellBefore:function(cell,includeHidden){var prev=this.getSibling('previous',cell);if(prev&&!includeHidden&&this.colModel.isHidden(prev.columnIndex)){return this.getCellBefore(prev);}
|
|
return prev;},getLastCell:function(row,includeHidden){var cell=this.getElement('previous',row.lastChild);if(cell&&!includeHidden&&this.colModel.isHidden(cell.columnIndex)){return this.getCellBefore(cell);}
|
|
return cell;},getFirstCell:function(row,includeHidden){var cell=this.getElement('next',row.firstChild);if(cell&&!includeHidden&&this.colModel.isHidden(cell.columnIndex)){return this.getCellAfter(cell);}
|
|
return cell;},getSibling:function(type,node){if(!node)return null;type+='Sibling';var n=node[type];while(n&&n.nodeType!=1){n=n[type];}
|
|
return n;},getElement:function(direction,node){if(!node||node.nodeType==1)return node;else return this.getSibling(direction,node);},getElementFromChild:function(childEl,parentClass){if(!childEl||(YAHOO.util.Dom.hasClass(childEl,parentClass))){return childEl;}
|
|
var p=childEl.parentNode;while(p&&p.tagName.toUpperCase()!='BODY'){if(YAHOO.util.Dom.hasClass(p,parentClass)){return p;}
|
|
p=p.parentNode;}
|
|
return null;},getRowFromChild:function(childEl){return this.getElementFromChild(childEl,'ygrid-row');},getCellFromChild:function(childEl){return this.getElementFromChild(childEl,'ygrid-col');},getHeaderFromChild:function(childEl){return this.getElementFromChild(childEl,'ygrid-hd');},getSelectedRows:function(){return this.selModel.getSelectedRows();},getSelectedRow:function(){if(this.selModel.hasSelection()){return this.selModel.getSelectedRows()[0];}
|
|
return null;},getSelectedRowIndexes:function(){var a=[];var rows=this.selModel.getSelectedRows();for(var i=0;i<rows.length;i++){a[i]=rows[i].rowIndex;}
|
|
return a;},getSelectedRowIndex:function(){if(this.selModel.hasSelection()){return this.selModel.getSelectedRows()[0].rowIndex;}
|
|
return-1;},getSelectedRowId:function(){if(this.selModel.hasSelection()){return this.selModel.getSelectedRowIds()[0];}
|
|
return null;},getSelectedRowIds:function(){return this.selModel.getSelectedRowIds();},clearSelections:function(){this.selModel.clearSelections();},selectAll:function(){this.selModel.selectAll();},getSelectionCount:function(){return this.selModel.getCount();},hasSelection:function(){return this.selModel.hasSelection();},getSelectionModel:function(){if(!this.selModel){this.selModel=new DefaultSelectionModel();}
|
|
return this.selModel;},getDataModel:function(){return this.dataModel;},getColumnModel:function(){return this.colModel;},getView:function(){return this.view;},getDragDropText:function(){return this.ddText.replace('%0',this.selModel.getCount());}};YAHOO.ext.grid.Grid.prototype.ddText="%0 selected row(s)";
|
|
|
|
if(YAHOO.util.DDProxy){YAHOO.ext.grid.GridDD=function(grid,bwrap){this.grid=grid;var ddproxy=document.createElement('div');ddproxy.id=grid.container.id+'-ddproxy';ddproxy.className='ygrid-drag-proxy';document.body.insertBefore(ddproxy,document.body.firstChild);YAHOO.util.Dom.setStyle(ddproxy,'opacity',.80);var ddicon=document.createElement('span');ddicon.className='ygrid-drop-icon ygrid-drop-nodrop';ddproxy.appendChild(ddicon);var ddtext=document.createElement('span');ddtext.className='ygrid-drag-text';ddtext.innerHTML=" ";ddproxy.appendChild(ddtext);this.ddproxy=ddproxy;this.ddtext=ddtext;this.ddicon=ddicon;YAHOO.util.Event.on(bwrap,'click',this.handleClick,this,true);YAHOO.ext.grid.GridDD.superclass.constructor.call(this,bwrap.id,'GridDD',{dragElId:ddproxy.id,resizeFrame:false});this.unlockDelegate=grid.selModel.unlock.createDelegate(grid.selModel);};YAHOO.extendX(YAHOO.ext.grid.GridDD,YAHOO.util.DDProxy);YAHOO.ext.grid.GridDD.prototype.handleMouseDown=function(e){var row=this.grid.getRowFromChild(YAHOO.util.Event.getTarget(e));if(!row)return;if(this.grid.selModel.isSelected(row)){YAHOO.ext.grid.GridDD.superclass.handleMouseDown.call(this,e);}else{this.grid.selModel.unlock();YAHOO.ext.EventObject.setEvent(e);this.grid.selModel.rowClick(this.grid,row.rowIndex,YAHOO.ext.EventObject);YAHOO.ext.grid.GridDD.superclass.handleMouseDown.call(this,e);this.grid.selModel.lock();}};YAHOO.ext.grid.GridDD.prototype.handleClick=function(e){if(this.grid.selModel.isLocked()){setTimeout(this.unlockDelegate,1);YAHOO.util.Event.stopEvent(e);}};YAHOO.ext.grid.GridDD.prototype.setDropStatus=function(dropStatus){if(dropStatus===true){YAHOO.util.Dom.replaceClass(this.ddicon,'ygrid-drop-nodrop','ygrid-drop-ok');}else{YAHOO.util.Dom.replaceClass(this.ddicon,'ygrid-drop-ok','ygrid-drop-nodrop');}};YAHOO.ext.grid.GridDD.prototype.startDrag=function(e){this.ddtext.innerHTML=this.grid.getDragDropText();this.setDropStatus(false);this.grid.selModel.lock();this.grid.fireEvent('startdrag',this.grid,this,e);};YAHOO.ext.grid.GridDD.prototype.endDrag=function(e){YAHOO.util.Dom.setStyle(this.ddproxy,'visibility','hidden');this.grid.fireEvent('enddrag',this.grid,this,e);};YAHOO.ext.grid.GridDD.prototype.autoOffset=function(iPageX,iPageY){this.setDelta(-12,-20);};YAHOO.ext.grid.GridDD.prototype.onDragEnter=function(e,id){this.setDropStatus(true);this.grid.fireEvent('dragenter',this.grid,this,id,e);};YAHOO.ext.grid.GridDD.prototype.onDragDrop=function(e,id){this.grid.fireEvent('dragdrop',this.grid,this,id,e);};YAHOO.ext.grid.GridDD.prototype.onDragOver=function(e,id){this.grid.fireEvent('dragover',this.grid,this,id,e);};YAHOO.ext.grid.GridDD.prototype.onDragOut=function(e,id){this.setDropStatus(false);this.grid.fireEvent('dragout',this.grid,this,id,e);};};
|
|
|
|
YAHOO.ext.grid.GridView=function(){this.grid=null;this.lastFocusedRow=null;this.onScroll=new YAHOO.util.CustomEvent('onscroll');this.adjustScrollTask=new YAHOO.ext.util.DelayedTask(this._adjustForScroll,this);this.ensureVisibleTask=new YAHOO.ext.util.DelayedTask();};YAHOO.ext.grid.GridView.prototype={init:function(grid){this.grid=grid;},fireScroll:function(scrollLeft,scrollTop){this.onScroll.fireDirect(this.grid,scrollLeft,scrollTop);},getColumnRenderers:function(){var renderers=[];var cm=this.grid.colModel;var colCount=cm.getColumnCount();for(var i=0;i<colCount;i++){renderers.push(cm.getRenderer(i));}
|
|
return renderers;},buildIndexMap:function(){var colToData={};var dataToCol={};var cm=this.grid.colModel;for(var i=0,len=cm.getColumnCount();i<len;i++){var di=cm.getDataIndex(i);colToData[i]=di;dataToCol[di]=i;}
|
|
return{'colToData':colToData,'dataToCol':dataToCol};},getDataIndexes:function(){if(!this.indexMap){this.indexMap=this.buildIndexMap();}
|
|
return this.indexMap.colToData;},getColumnIndexByDataIndex:function(dataIndex){if(!this.indexMap){this.indexMap=this.buildIndexMap();}
|
|
return this.indexMap.dataToCol[dataIndex];},updateHeaders:function(){var colModel=this.grid.colModel;var hcells=this.headers;var colCount=colModel.getColumnCount();for(var i=0;i<colCount;i++){hcells[i].textNode.innerHTML=colModel.getColumnHeader(i);}},adjustForScroll:function(disableDelay){if(!disableDelay){this.adjustScrollTask.delay(50);}else{this._adjustForScroll();}},getCellAtPoint:function(x,y){var colIndex=null;var rowIndex=null;var xy=YAHOO.util.Dom.getXY(this.wrap);x=(x-xy[0])+this.wrap.scrollLeft;y=(y-xy[1])+this.wrap.scrollTop;var colModel=this.grid.colModel;var pos=0;var colCount=colModel.getColumnCount();for(var i=0;i<colCount;i++){if(colModel.isHidden(i))continue;var width=colModel.getColumnWidth(i);if(x>=pos&&x<pos+width){colIndex=i;break;}
|
|
pos+=width;}
|
|
if(colIndex!=null){rowIndex=(y==0?0:Math.floor(y/this.getRowHeight()));if(rowIndex>=this.grid.dataModel.getRowCount()){return null;}
|
|
return[colIndex,rowIndex];}
|
|
return null;},_adjustForScroll:function(){this.forceScrollUpdate();if(this.scrollbarMode==YAHOO.ext.grid.GridView.SCROLLBARS_OVERLAP){var adjustment=0;if(this.wrap.clientWidth&&this.wrap.clientWidth!=0){adjustment=this.wrap.offsetWidth-this.wrap.clientWidth;}
|
|
this.hwrap.setWidth(this.wrap.offsetWidth-adjustment);}else{this.hwrap.setWidth(this.wrap.offsetWidth);}
|
|
this.bwrap.setWidth(Math.max(this.grid.colModel.getTotalWidth(),this.wrap.clientWidth));},focusRow:function(row){if(typeof row=='number'){row=this.getBodyTable().childNodes[row];}
|
|
if(!row)return;var left=this.wrap.scrollLeft;try{row.childNodes.item(0).hideFocus=true;row.childNodes.item(0).focus();}catch(e){}
|
|
this.ensureVisible(row);this.wrap.scrollLeft=left;this.handleScroll();this.lastFocusedRow=row;},ensureVisible:function(row,disableDelay){if(!disableDelay){this.ensureVisibleTask.delay(50,this._ensureVisible,this,[row]);}else{this._ensureVisible(row);}},_ensureVisible:function(row){if(typeof row=='number'){row=this.getBodyTable().childNodes[row];}
|
|
if(!row)return;var left=this.wrap.scrollLeft;var rowTop=parseInt(row.offsetTop,10);var rowBottom=rowTop+row.offsetHeight;var clientTop=parseInt(this.wrap.scrollTop,10);var clientBottom=clientTop+this.wrap.clientHeight;if(rowTop<clientTop){this.wrap.scrollTop=rowTop;}else if(rowBottom>clientBottom){this.wrap.scrollTop=rowBottom-this.wrap.clientHeight;}
|
|
this.wrap.scrollLeft=left;this.handleScroll();},updateColumns:function(){this.grid.stopEditing();var colModel=this.grid.colModel;var hcols=this.headers;var colCount=colModel.getColumnCount();var pos=0;var totalWidth=colModel.getTotalWidth();for(var i=0;i<colCount;i++){if(colModel.isHidden(i))continue;var width=colModel.getColumnWidth(i);hcols[i].style.width=width+'px';hcols[i].style.left=pos+'px';hcols[i].split.style.left=(pos+width-3)+'px';this.setCSSWidth(i,width,pos);pos+=width;}
|
|
this.lastWidth=totalWidth;this.bwrap.setWidth(Math.max(totalWidth,this.wrap.clientWidth));if(!YAHOO.ext.util.Browser.isIE){this.wrap.scrollLeft=this.hwrap.dom.scrollLeft;}
|
|
this.syncScroll();this.forceScrollUpdate();},setCSSWidth:function(colIndex,width,pos){var selector=["#"+this.grid.id+" .ygrid-col-"+colIndex,".ygrid-col-"+colIndex];YAHOO.ext.util.CSS.updateRule(selector,'width',width+'px');if(typeof pos=='number'){YAHOO.ext.util.CSS.updateRule(selector,'left',pos+'px');}},handleHiddenChange:function(colModel,colIndex,hidden){if(hidden){this.hideColumn(colIndex);}else{this.unhideColumn(colIndex);}
|
|
this.updateColumns();},hideColumn:function(colIndex){var selector=["#"+this.grid.id+" .ygrid-col-"+colIndex,".ygrid-col-"+colIndex];YAHOO.ext.util.CSS.updateRule(selector,'position','absolute');YAHOO.ext.util.CSS.updateRule(selector,'visibility','hidden');this.headers[colIndex].style.display='none';this.headers[colIndex].split.style.display='none';},unhideColumn:function(colIndex){var selector=["#"+this.grid.id+" .ygrid-col-"+colIndex,".ygrid-col-"+colIndex];YAHOO.ext.util.CSS.updateRule(selector,'position','');YAHOO.ext.util.CSS.updateRule(selector,'visibility','visible');this.headers[colIndex].style.display='';this.headers[colIndex].split.style.display='';},getBodyTable:function(){return this.bwrap.dom;},updateRowIndexes:function(firstRow,lastRow){var stripeRows=this.grid.stripeRows;var bt=this.getBodyTable();var nodes=bt.childNodes;firstRow=firstRow||0;lastRow=lastRow||nodes.length-1;var re=/^(?:ygrid-row ygrid-row-alt|ygrid-row)/;for(var rowIndex=firstRow;rowIndex<=lastRow;rowIndex++){var node=nodes[rowIndex];if(stripeRows&&(rowIndex+1)%2==0){node.className=node.className.replace(re,'ygrid-row ygrid-row-alt');}else{node.className=node.className.replace(re,'ygrid-row');}
|
|
node.rowIndex=rowIndex;nodes[rowIndex].style.top=(rowIndex*this.rowHeight)+'px';}},insertRows:function(dataModel,firstRow,lastRow){this.updateBodyHeight();this.adjustForScroll(true);var renderers=this.getColumnRenderers();var dindexes=this.getDataIndexes();var colCount=this.grid.colModel.getColumnCount();var beforeRow=null;var bt=this.getBodyTable();if(firstRow<bt.childNodes.length){beforeRow=bt.childNodes[firstRow];}
|
|
for(var rowIndex=firstRow;rowIndex<=lastRow;rowIndex++){var row=document.createElement('span');row.className='ygrid-row';row.style.top=(rowIndex*this.rowHeight)+'px';this.renderRow(dataModel,row,rowIndex,colCount,renderers,dindexes);if(beforeRow){bt.insertBefore(row,beforeRow);}else{bt.appendChild(row);}}
|
|
this.updateRowIndexes(firstRow);this.adjustForScroll();},renderRow:function(dataModel,row,rowIndex,colCount,renderers,dindexes){for(var colIndex=0;colIndex<colCount;colIndex++){var td=document.createElement('span');td.className='ygrid-col ygrid-col-'+colIndex+(colIndex==colCount-1?' ygrid-col-last':'');td.columnIndex=colIndex;td.tabIndex=0;var span=document.createElement('span');span.className='ygrid-cell-text';td.appendChild(span);var val=renderers[colIndex](dataModel.getValueAt(rowIndex,dindexes[colIndex]),rowIndex,colIndex);if(val=='')val=' ';span.innerHTML=val;row.appendChild(td);}},deleteRows:function(dataModel,firstRow,lastRow){this.updateBodyHeight();this.grid.selModel.deselectRange(firstRow,lastRow);var bt=this.getBodyTable();var rows=[];for(var rowIndex=firstRow;rowIndex<=lastRow;rowIndex++){rows.push(bt.childNodes[rowIndex]);}
|
|
for(var i=0;i<rows.length;i++){bt.removeChild(rows[i]);rows[i]=null;}
|
|
rows=null;this.updateRowIndexes(firstRow);this.adjustForScroll();},updateRows:function(dataModel,firstRow,lastRow){var bt=this.getBodyTable();var dindexes=this.getDataIndexes();var renderers=this.getColumnRenderers();var colCount=this.grid.colModel.getColumnCount();for(var rowIndex=firstRow;rowIndex<=lastRow;rowIndex++){var row=bt.rows[rowIndex];var cells=row.childNodes;for(var colIndex=0;colIndex<colCount;colIndex++){var td=cells[colIndex];var val=renderers[colIndex](dataModel.getValueAt(rowIndex,dindexes[colIndex]),rowIndex,colIndex);if(val=='')val=' ';td.firstChild.innerHTML=val;}}},handleSort:function(dataModel,sortColumnIndex,sortDir,noRefresh){this.grid.selModel.syncSelectionsToIds();if(!noRefresh){this.updateRows(dataModel,0,dataModel.getRowCount()-1);}
|
|
this.updateHeaderSortState();if(this.lastFocusedRow){this.focusRow(this.lastFocusedRow);}},syncScroll:function(){this.hwrap.dom.scrollLeft=this.wrap.scrollLeft;},handleScroll:function(){this.syncScroll();this.fireScroll(this.wrap.scrollLeft,this.wrap.scrollTop);this.grid.fireEvent('bodyscroll',this.wrap.scrollLeft,this.wrap.scrollTop);},getRowHeight:function(){if(!this.rowHeight){var rule=YAHOO.ext.util.CSS.getRule(["#"+this.grid.id+" .ygrid-row",".ygrid-row"]);if(rule&&rule.style.height){this.rowHeight=parseInt(rule.style.height,10);}else{this.rowHeight=21;}}
|
|
return this.rowHeight;},renderRows:function(dataModel){if(this.grid.selModel){this.grid.selModel.clearSelections();}
|
|
var bt=this.getBodyTable();bt.innerHTML='';this.rowHeight=this.getRowHeight();this.insertRows(dataModel,0,dataModel.getRowCount()-1);},updateCell:function(dataModel,rowIndex,dataIndex){var colIndex=this.getColumnIndexByDataIndex(dataIndex);if(typeof colIndex=='undefined'){return;}
|
|
var bt=this.getBodyTable();var row=bt.childNodes[rowIndex];var cell=row.childNodes[colIndex];var renderer=this.grid.colModel.getRenderer(colIndex);var val=renderer(dataModel.getValueAt(rowIndex,dataIndex),rowIndex,colIndex);if(val=='')val=' ';cell.firstChild.innerHTML=val;},calcColumnWidth:function(colIndex,maxRowsToMeasure){var maxWidth=0;var bt=this.getBodyTable();var rows=bt.childNodes;var stopIndex=Math.min(maxRowsToMeasure||rows.length,rows.length);if(this.grid.autoSizeHeaders){var h=this.headers[colIndex];var curWidth=h.style.width;h.style.width=this.grid.minColumnWidth+'px';maxWidth=Math.max(maxWidth,h.scrollWidth);h.style.width=curWidth;}
|
|
for(var i=0;i<stopIndex;i++){var cell=rows[i].childNodes[colIndex].firstChild;maxWidth=Math.max(maxWidth,cell.scrollWidth);}
|
|
return maxWidth+5;},autoSizeColumn:function(colIndex,forceMinSize){if(forceMinSize){this.setCSSWidth(colIndex,this.grid.minColumnWidth);}
|
|
var newWidth=this.calcColumnWidth(colIndex);this.grid.colModel.setColumnWidth(colIndex,Math.max(this.grid.minColumnWidth,newWidth));this.grid.fireEvent('columnresize',colIndex,newWidth);},autoSizeColumns:function(){var colModel=this.grid.colModel;var colCount=colModel.getColumnCount();var wrap=this.wrap;for(var i=0;i<colCount;i++){this.setCSSWidth(i,this.grid.minColumnWidth);colModel.setColumnWidth(i,this.calcColumnWidth(i,this.grid.maxRowsToMeasure),true);}
|
|
if(colModel.getTotalWidth()<wrap.clientWidth){var diff=Math.floor((wrap.clientWidth-colModel.getTotalWidth())/colCount);for(var i=0;i<colCount;i++){colModel.setColumnWidth(i,colModel.getColumnWidth(i)+diff,true);}}
|
|
this.updateColumns();},onWindowResize:function(){if(this.grid.monitorWindowResize){this.updateWrapHeight();this.adjustForScroll();}},updateWrapHeight:function(){this.grid.container.beginMeasure();var box=this.grid.container.getBox(true);this.wrapEl.setHeight(box.height-this.footerHeight-parseInt(this.wrap.offsetTop,10));this.grid.container.endMeasure();},forceScrollUpdate:function(){var wrap=this.wrap;YAHOO.util.Dom.setStyle(wrap,'width',(wrap.offsetWidth)+'px');setTimeout(function(){YAHOO.util.Dom.setStyle(wrap,'width','');},1);},updateHeaderSortState:function(){var state=this.grid.dataModel.getSortState();var sortColumn=this.getColumnIndexByDataIndex(state.column);var sortDir=state.direction;for(var i=0,len=this.headers.length;i<len;i++){var h=this.headers[i];if(i!=sortColumn){h.sortDesc.style.display='none';h.sortAsc.style.display='none';}else{h.sortDesc.style.display=sortDir=='DESC'?'block':'none';h.sortAsc.style.display=sortDir=='ASC'?'block':'none';}}},render:function(){var grid=this.grid;var container=grid.container.dom;var dataModel=grid.dataModel;dataModel.onCellUpdated.subscribe(this.updateCell,this,true);dataModel.onTableDataChanged.subscribe(this.renderRows,this,true);dataModel.onRowsDeleted.subscribe(this.deleteRows,this,true);dataModel.onRowsInserted.subscribe(this.insertRows,this,true);dataModel.onRowsUpdated.subscribe(this.updateRows,this,true);dataModel.onRowsSorted.subscribe(this.handleSort,this,true);var colModel=grid.colModel;colModel.onWidthChange.subscribe(this.updateColumns,this,true);colModel.onHeaderChange.subscribe(this.updateHeaders,this,true);colModel.onHiddenChange.subscribe(this.handleHiddenChange,this,true);YAHOO.util.Event.on(window,'resize',this.onWindowResize,this,true);var autoSizeDelegate=this.autoSizeColumn.createDelegate(this);var colCount=colModel.getColumnCount();var dh=YAHOO.ext.DomHelper;var wrap=dh.append(container,{tag:'div',cls:'ygrid-wrap'});this.wrap=wrap;this.wrapEl=getEl(wrap,true);YAHOO.ext.EventManager.on(wrap,'scroll',this.handleScroll,this,true);var hwrap=dh.append(container,{tag:'div',cls:'ygrid-wrap-headers'});this.hwrap=getEl(hwrap,true);var bwrap=dh.append(wrap,{tag:'div',cls:'ygrid-wrap-body',id:container.id+'-body'});this.bwrap=getEl(bwrap,true);this.bwrap.setWidth(colModel.getTotalWidth());bwrap.rows=bwrap.childNodes;this.footerHeight=0;var foot=this.appendFooter(container);if(foot){this.footer=getEl(foot,true);this.footerHeight=this.footer.getHeight();}
|
|
this.updateWrapHeight();var hrow=dh.append(hwrap,{tag:'span',cls:'ygrid-hrow'});this.hrow=hrow;var iframe=document.createElement('iframe');iframe.className='ygrid-hrow-frame';iframe.frameBorder=0;hwrap.appendChild(iframe);this.headerCtrl=new YAHOO.ext.grid.HeaderController(this.grid);this.headers=[];this.cols=[];var htemplate=dh.createTemplate({tag:'span',cls:'ygrid-hd ygrid-header-{0}',children:[{tag:'span',cls:'ygrid-hd-body',html:'<table border="0" cellpadding="0" cellspacing="0">'+'<tbody><tr><td><span>{1}</span></td>'+'<td><span class="sort-desc"></span><span class="sort-asc"></span></td>'+'</tr></tbody></table>'}]});htemplate.compile();for(var i=0;i<colCount;i++){var hd=htemplate.append(hrow,[i,colModel.getColumnHeader(i)]);var spans=hd.getElementsByTagName('span');hd.textNode=spans[1];hd.sortDesc=spans[2];hd.sortAsc=spans[3];hd.columnIndex=i;this.headers.push(hd);if(colModel.isSortable(i)){this.headerCtrl.register(hd);}
|
|
var split=dh.append(hrow,{tag:'span',cls:'ygrid-hd-split'});hd.split=split;YAHOO.util.Event.on(split,'dblclick',autoSizeDelegate.createCallback(i+0,true));var sb=new YAHOO.ext.SplitBar(split,hd,null,YAHOO.ext.SplitBar.LEFT);sb.columnIndex=i;sb.minSize=grid.minColumnWidth;sb.onMoved.subscribe(this.onColumnSplitterMoved,this,true);YAHOO.util.Dom.addClass(sb.proxy,'ygrid-column-sizer');YAHOO.util.Dom.setStyle(sb.proxy,'background-color','');sb.dd._resizeProxy=function(){var el=this.getDragEl();YAHOO.util.Dom.setStyle(el,'height',(hwrap.clientHeight+wrap.clientHeight-2)+'px');};}
|
|
if(grid.autoSizeColumns){this.renderRows(dataModel);this.autoSizeColumns();}else{this.updateColumns();this.renderRows(dataModel);}
|
|
for(var i=0;i<colCount;i++){if(colModel.isHidden(i)){this.hideColumn(i);}}
|
|
return this.bwrap;},onColumnSplitterMoved:function(splitter,newSize){this.grid.colModel.setColumnWidth(splitter.columnIndex,newSize);this.grid.fireEvent('columnresize',splitter.columnIndex,newSize);},appendFooter:function(parentEl){return null;},updateBodyHeight:function(){YAHOO.util.Dom.setStyle(this.getBodyTable(),'height',(this.grid.dataModel.getRowCount()*this.rowHeight)+'px');}};YAHOO.ext.grid.GridView.SCROLLBARS_UNDER=0;YAHOO.ext.grid.GridView.SCROLLBARS_OVERLAP=1;YAHOO.ext.grid.GridView.prototype.scrollbarMode=YAHOO.ext.grid.GridView.SCROLLBARS_UNDER;YAHOO.ext.grid.HeaderController=function(grid){this.grid=grid;this.headers=[];};YAHOO.ext.grid.HeaderController.prototype={register:function(header){this.headers.push(header);YAHOO.ext.EventManager.on(header,'selectstart',this.cancelTextSelection,this,true);YAHOO.ext.EventManager.on(header,'mousedown',this.cancelTextSelection,this,true);YAHOO.ext.EventManager.on(header,'mouseover',this.headerOver,this,true);YAHOO.ext.EventManager.on(header,'mouseout',this.headerOut,this,true);YAHOO.ext.EventManager.on(header,'click',this.headerClick,this,true);},headerClick:function(e){var grid=this.grid,cm=grid.colModel,dm=grid.dataModel;grid.stopEditing();var header=grid.getHeaderFromChild(e.getTarget());var direction=header.sortDir||'ASC';var state=dm.getSortState();if(typeof state.column!='undefined'&&grid.getView().getColumnIndexByDataIndex(state.column)==header.columnIndex){direction=(direction=='ASC'?'DESC':'ASC');}
|
|
header.sortDir=direction;dm.sort(cm,cm.getDataIndex(header.columnIndex),direction);},headerOver:function(e){var header=this.grid.getHeaderFromChild(e.getTarget());YAHOO.util.Dom.addClass(header,'ygrid-hd-over');},headerOut:function(e){var header=this.grid.getHeaderFromChild(e.getTarget());YAHOO.util.Dom.removeClass(header,'ygrid-hd-over');},cancelTextSelection:function(e){e.preventDefault();}};
|
|
|
|
YAHOO.ext.grid.PagedGridView=function(){YAHOO.ext.grid.PagedGridView.superclass.constructor.call(this);this.cursor=1;};YAHOO.extendX(YAHOO.ext.grid.PagedGridView,YAHOO.ext.grid.GridView);YAHOO.ext.grid.PagedGridView.prototype.appendFooter=function(parentEl){var fwrap=document.createElement('div');fwrap.className='ygrid-wrap-footer';var fbody=document.createElement('span');fbody.className='ygrid-footer';fwrap.appendChild(fbody);parentEl.appendChild(fwrap);this.createPagingToolbar(fbody);return fwrap;};YAHOO.ext.grid.PagedGridView.prototype.createPagingToolbar=function(container){var tb=new YAHOO.ext.Toolbar(container);this.pageToolbar=tb;this.first=tb.addButton({tooltip:this.firstText,className:'ygrid-page-first',disabled:true,click:this.onClick.createDelegate(this,['first'])});this.prev=tb.addButton({tooltip:this.prevText,className:'ygrid-page-prev',disabled:true,click:this.onClick.createDelegate(this,['prev'])});tb.addSeparator();tb.add(this.beforePageText);var pageBox=document.createElement('input');pageBox.type='text';pageBox.size=3;pageBox.value='1';pageBox.className='ygrid-page-number';tb.add(pageBox);this.field=getEl(pageBox,true);this.field.mon('keydown',this.onEnter,this,true);this.field.on('focus',function(){pageBox.select();});this.afterTextEl=tb.addText(this.afterPageText.replace('%0','1'));this.field.setHeight(18);tb.addSeparator();this.next=tb.addButton({tooltip:this.nextText,className:'ygrid-page-next',disabled:true,click:this.onClick.createDelegate(this,['next'])});this.last=tb.addButton({tooltip:this.lastText,className:'ygrid-page-last',disabled:true,click:this.onClick.createDelegate(this,['last'])});tb.addSeparator();this.loading=tb.addButton({tooltip:this.refreshText,className:'ygrid-loading',disabled:true,click:this.onClick.createDelegate(this,['refresh'])});this.onPageLoaded(1,this.grid.dataModel.getTotalPages());};YAHOO.ext.grid.PagedGridView.prototype.getPageToolbar=function(){return this.pageToolbar;};YAHOO.ext.grid.PagedGridView.prototype.onPageLoaded=function(pageNum,totalPages){this.cursor=pageNum;this.lastPage=totalPages;this.afterTextEl.innerHTML=this.afterPageText.replace('%0',totalPages);this.field.dom.value=pageNum;this.first.setDisabled(pageNum==1);this.prev.setDisabled(pageNum==1);this.next.setDisabled(pageNum==totalPages);this.last.setDisabled(pageNum==totalPages);this.loading.enable();};YAHOO.ext.grid.PagedGridView.prototype.onEnter=function(e){if(e.browserEvent.keyCode==e.RETURN){var v=this.field.dom.value;if(!v){this.field.dom.value=this.cursor;return;}
|
|
var pageNum=parseInt(v,10);if(isNaN(v)){this.field.dom.value=this.cursor;return;}
|
|
pageNum=Math.min(Math.max(1,pageNum),this.lastPage);this.grid.dataModel.loadPage(pageNum);e.stopEvent();}};YAHOO.ext.grid.PagedGridView.prototype.beforeLoad=function(){if(this.loading){this.loading.disable();}};YAHOO.ext.grid.PagedGridView.prototype.onClick=function(which){switch(which){case'first':this.grid.dataModel.loadPage(1);break;case'prev':this.grid.dataModel.loadPage(this.cursor-1);break;case'next':this.grid.dataModel.loadPage(this.cursor+1);break;case'last':this.grid.dataModel.loadPage(this.lastPage);break;case'refresh':this.grid.dataModel.loadPage(this.cursor);break;}};YAHOO.ext.grid.PagedGridView.prototype.render=function(){this.grid.dataModel.addListener('beforeload',this.beforeLoad,this,true);this.grid.dataModel.addListener('load',this.onPageLoaded,this,true);return YAHOO.ext.grid.PagedGridView.superclass.render.call(this);};YAHOO.ext.grid.PagedGridView.prototype.beforePageText="Page";YAHOO.ext.grid.PagedGridView.prototype.afterPageText="of %0";YAHOO.ext.grid.PagedGridView.prototype.firstText="First Page";YAHOO.ext.grid.PagedGridView.prototype.prevText="Previous Page";YAHOO.ext.grid.PagedGridView.prototype.nextText="Next Page";YAHOO.ext.grid.PagedGridView.prototype.lastText="Last Page";YAHOO.ext.grid.PagedGridView.prototype.refreshText="Refresh";
|
|
|
|
YAHOO.ext.grid.EditorGrid=function(container,dataModel,colModel){YAHOO.ext.grid.EditorGrid.superclass.constructor.call(this,container,dataModel,colModel,new YAHOO.ext.grid.EditorSelectionModel());this.container.addClass('yeditgrid');};YAHOO.extendX(YAHOO.ext.grid.EditorGrid,YAHOO.ext.grid.Grid);
|
|
|
|
YAHOO.ext.grid.AbstractColumnModel=function(){this.onWidthChange=new YAHOO.util.CustomEvent('widthChanged');this.onHeaderChange=new YAHOO.util.CustomEvent('headerChanged');this.onHiddenChange=new YAHOO.util.CustomEvent('hiddenChanged');};YAHOO.ext.grid.AbstractColumnModel.prototype={fireWidthChange:function(colIndex,newWidth){this.onWidthChange.fireDirect(this,colIndex,newWidth);},fireHeaderChange:function(colIndex,newHeader){this.onHeaderChange.fireDirect(this,colIndex,newHeader);},fireHiddenChange:function(colIndex,hidden){this.onHiddenChange.fireDirect(this,colIndex,hidden);},getColumnCount:function(){return 0;},isSortable:function(col){return false;},isHidden:function(col){return false;},getSortType:function(col){return YAHOO.ext.grid.DefaultColumnModel.sortTypes.none;},getRenderer:function(col){return YAHOO.ext.grid.DefaultColumnModel.defaultRenderer;},getColumnWidth:function(col){return 0;},getTotalWidth:function(){return 0;},getColumnHeader:function(col){return'';}};
|
|
|
|
YAHOO.ext.grid.DefaultColumnModel=function(config){YAHOO.ext.grid.DefaultColumnModel.superclass.constructor.call(this);this.config=config;this.defaultWidth=100;this.defaultSortable=false;};YAHOO.extendX(YAHOO.ext.grid.DefaultColumnModel,YAHOO.ext.grid.AbstractColumnModel);YAHOO.ext.grid.DefaultColumnModel.prototype.getColumnCount=function(){return this.config.length;};YAHOO.ext.grid.DefaultColumnModel.prototype.isSortable=function(col){if(typeof this.config[col].sortable=='undefined'){return this.defaultSortable;}
|
|
return this.config[col].sortable;};YAHOO.ext.grid.DefaultColumnModel.prototype.getSortType=function(col){if(!this.dataMap){var map=[];for(var i=0,len=this.config.length;i<len;i++){map[this.getDataIndex(i)]=i;}
|
|
this.dataMap=map;}
|
|
col=this.dataMap[col];if(!this.config[col].sortType){return YAHOO.ext.grid.DefaultColumnModel.sortTypes.none;}
|
|
return this.config[col].sortType;};YAHOO.ext.grid.DefaultColumnModel.prototype.setSortType=function(col,fn){this.config[col].sortType=fn;};YAHOO.ext.grid.DefaultColumnModel.prototype.getRenderer=function(col){if(!this.config[col].renderer){return YAHOO.ext.grid.DefaultColumnModel.defaultRenderer;}
|
|
return this.config[col].renderer;};YAHOO.ext.grid.DefaultColumnModel.prototype.setRenderer=function(col,fn){this.config[col].renderer=fn;};YAHOO.ext.grid.DefaultColumnModel.prototype.getColumnWidth=function(col){return this.config[col].width||this.defaultWidth;};YAHOO.ext.grid.DefaultColumnModel.prototype.setColumnWidth=function(col,width,suppressEvent){this.config[col].width=width;this.totalWidth=null;if(!suppressEvent){this.onWidthChange.fireDirect(this,col,width);}};YAHOO.ext.grid.DefaultColumnModel.prototype.getTotalWidth=function(includeHidden){if(!this.totalWidth){this.totalWidth=0;for(var i=0;i<this.config.length;i++){if(includeHidden||!this.isHidden(i)){this.totalWidth+=this.getColumnWidth(i);}}}
|
|
return this.totalWidth;};YAHOO.ext.grid.DefaultColumnModel.prototype.getColumnHeader=function(col){return this.config[col].header;};YAHOO.ext.grid.DefaultColumnModel.prototype.setColumnHeader=function(col,header){this.config[col].header=header;this.onHeaderChange.fireDirect(this,col,header);};YAHOO.ext.grid.DefaultColumnModel.prototype.getDataIndex=function(col){if(typeof this.config[col].dataIndex!='number'){return col;}
|
|
return this.config[col].dataIndex;};YAHOO.ext.grid.DefaultColumnModel.prototype.setDataIndex=function(col,dataIndex){this.config[col].dataIndex=dataIndex;};YAHOO.ext.grid.DefaultColumnModel.prototype.isCellEditable=function(colIndex,rowIndex){return this.config[colIndex].editable||(typeof this.config[colIndex].editable=='undefined'&&this.config[colIndex].editor);};YAHOO.ext.grid.DefaultColumnModel.prototype.getCellEditor=function(colIndex,rowIndex){return this.config[colIndex].editor;};YAHOO.ext.grid.DefaultColumnModel.prototype.setEditable=function(col,editable){this.config[col].editable=editable;};YAHOO.ext.grid.DefaultColumnModel.prototype.isHidden=function(colIndex){return this.config[colIndex].hidden;};YAHOO.ext.grid.DefaultColumnModel.prototype.setHidden=function(colIndex,hidden){this.config[colIndex].hidden=hidden;this.totalWidth=null;this.fireHiddenChange(colIndex,hidden);};YAHOO.ext.grid.DefaultColumnModel.prototype.setEditor=function(col,editor){this.config[col].editor=editor;};YAHOO.ext.grid.DefaultColumnModel.defaultRenderer=function(value){if(typeof value=='string'&&value.length<1){return' ';}
|
|
return value;}
|
|
YAHOO.ext.grid.DefaultColumnModel.sortTypes={};YAHOO.ext.grid.DefaultColumnModel.sortTypes.none=function(s){return s;};YAHOO.ext.grid.DefaultColumnModel.sortTypes.asUCString=function(s){return String(s).toUpperCase();};YAHOO.ext.grid.DefaultColumnModel.sortTypes.asDate=function(s){if(s instanceof Date){return s;}
|
|
return Date.parse(String(s));};YAHOO.ext.grid.DefaultColumnModel.sortTypes.asFloat=function(s){var val=parseFloat(String(s).replace(/,/g,''));if(isNaN(val))val=0;return val;};YAHOO.ext.grid.DefaultColumnModel.sortTypes.asInt=function(s){var val=parseInt(String(s).replace(/,/g,''));if(isNaN(val))val=0;return val;};
|
|
|
|
YAHOO.ext.grid.AbstractDataModel=function(){this.onCellUpdated=new YAHOO.util.CustomEvent('onCellUpdated');this.onTableDataChanged=new YAHOO.util.CustomEvent('onTableDataChanged');this.onRowsDeleted=new YAHOO.util.CustomEvent('onRowsDeleted');this.onRowsInserted=new YAHOO.util.CustomEvent('onRowsInserted');this.onRowsUpdated=new YAHOO.util.CustomEvent('onRowsUpdated');this.onRowsSorted=new YAHOO.util.CustomEvent('onRowsSorted');this.events={'cellupdated':this.onCellUpdated,'datachanged':this.onTableDataChanged,'rowsdeleted':this.onRowsDeleted,'rowsinserted':this.onRowsInserted,'rowsupdated':this.onRowsUpdated,'rowssorted':this.onRowsSorted};};YAHOO.ext.grid.AbstractDataModel.prototype={addListener:YAHOO.ext.grid.Grid.prototype.addListener,removeListener:YAHOO.ext.grid.Grid.prototype.removeListener,fireEvent:YAHOO.ext.grid.Grid.prototype.fireEvent,fireCellUpdated:function(row,col){this.onCellUpdated.fireDirect(this,row,col);},fireTableDataChanged:function(){this.onTableDataChanged.fireDirect(this);},fireRowsDeleted:function(firstRow,lastRow){this.onRowsDeleted.fireDirect(this,firstRow,lastRow);},fireRowsInserted:function(firstRow,lastRow){this.onRowsInserted.fireDirect(this,firstRow,lastRow);},fireRowsUpdated:function(firstRow,lastRow){this.onRowsUpdated.fireDirect(this,firstRow,lastRow);},fireRowsSorted:function(sortColumnIndex,sortDir,noRefresh){this.onRowsSorted.fireDirect(this,sortColumnIndex,sortDir,noRefresh);},sort:function(columnModel,columnIndex,direction,suppressEvent){},getSortState:function(){return{column:this.sortColumn,direction:this.sortDir};},getRowCount:function(){},getTotalRowCount:function(){return this.getRowCount();},getRowId:function(rowIndex){},getValueAt:function(rowIndex,colIndex){},setValueAt:function(value,rowIndex,colIndex){},isPaged:function(){return false;}};
|
|
|
|
YAHOO.ext.grid.DefaultDataModel=function(data){YAHOO.ext.grid.DefaultDataModel.superclass.constructor.call(this);this.data=data;};YAHOO.extendX(YAHOO.ext.grid.DefaultDataModel,YAHOO.ext.grid.AbstractDataModel);YAHOO.ext.grid.DefaultDataModel.prototype.getRowCount=function(){return this.data.length;};YAHOO.ext.grid.DefaultDataModel.prototype.getRowId=function(rowIndex){return this.data[rowIndex][0];};YAHOO.ext.grid.DefaultDataModel.prototype.getRow=function(rowIndex){return this.data[rowIndex];};YAHOO.ext.grid.DefaultDataModel.prototype.getRows=function(indexes){var data=this.data;var r=[];for(var i=0;i<indexes.length;i++){r.push(data[indexes[i]]);}
|
|
return r;};YAHOO.ext.grid.DefaultDataModel.prototype.getValueAt=function(rowIndex,colIndex){return this.data[rowIndex][colIndex];};YAHOO.ext.grid.DefaultDataModel.prototype.setValueAt=function(value,rowIndex,colIndex){this.data[rowIndex][colIndex]=value;this.fireCellUpdated(rowIndex,colIndex);};YAHOO.ext.grid.DefaultDataModel.prototype.removeRows=function(startIndex,endIndex){endIndex=endIndex||startIndex;this.data.splice(startIndex,endIndex-startIndex+1);this.fireRowsDeleted(startIndex,endIndex);};YAHOO.ext.grid.DefaultDataModel.prototype.removeRow=function(index){this.data.splice(index,1);this.fireRowsDeleted(index,index);};YAHOO.ext.grid.DefaultDataModel.prototype.removeAll=function(){var count=this.getRowCount();if(count>0){this.removeRows(0,count-1);}};YAHOO.ext.grid.DefaultDataModel.prototype.query=function(spec,returnUnmatched){var d=this.data;var r=[];for(var i=0;i<d.length;i++){var row=d[i];var isMatch=true;for(var col in spec){if(typeof spec[col]!='function'){if(!isMatch)continue;var filter=spec[col];switch(typeof filter){case'string':case'number':case'boolean':if(row[col]!=filter){isMatch=false;}
|
|
break;case'function':if(!filter(row[col],row)){isMatch=false;}
|
|
break;case'object':if(filter instanceof RegExp){if(String(row[col]).search(filter)===-1){isMatch=false;}}
|
|
break;}}}
|
|
if(isMatch&&!returnUnmatched){r.push(i);}else if(!isMatch&&returnUnmatched){r.push(i);}}
|
|
return r;};YAHOO.ext.grid.DefaultDataModel.prototype.filter=function(query){var matches=this.query(query,true);var data=this.data;for(var i=0;i<matches.length;i++){data[matches[i]]._deleted=true;}
|
|
for(var i=0;i<data.length;i++){while(data[i]&&data[i]._deleted===true){this.removeRow(i);}}
|
|
return matches.length;};YAHOO.ext.grid.DefaultDataModel.prototype.addRow=function(cellValues){this.data.push(cellValues);var newIndex=this.data.length-1;this.fireRowsInserted(newIndex,newIndex);this.applySort();return newIndex;};YAHOO.ext.grid.DefaultDataModel.prototype.addRows=function(rowData){this.data=this.data.concat(rowData);var firstIndex=this.data.length-rowData.length;this.fireRowsInserted(firstIndex,firstIndex+rowData.length-1);this.applySort();};YAHOO.ext.grid.DefaultDataModel.prototype.insertRow=function(index,cellValues){this.data.splice(index,0,cellValues);this.fireRowsInserted(index,index);this.applySort();return index;};YAHOO.ext.grid.DefaultDataModel.prototype.insertRows=function(index,rowData){var args=rowData.concat();args.splice(0,0,index,0);this.data.splice.apply(this.data,args);this.fireRowsInserted(index,index+rowData.length-1);this.applySort();};YAHOO.ext.grid.DefaultDataModel.prototype.applySort=function(suppressEvent){if(this.columnModel&&typeof this.sortColumn!='undefined'){this.sort(this.columnModel,this.sortColumn,this.sortDir,suppressEvent);}};YAHOO.ext.grid.DefaultDataModel.prototype.setDefaultSort=function(columnModel,columnIndex,direction){this.columnModel=columnModel;this.sortColumn=columnIndex;this.sortDir=direction;};YAHOO.ext.grid.DefaultDataModel.prototype.sort=function(columnModel,columnIndex,direction,suppressEvent){this.columnModel=columnModel;this.sortColumn=columnIndex;this.sortDir=direction;var dsc=direction=='DESC';var sortType=columnModel.getSortType(columnIndex);var fn=function(cells,cells2){var v1=sortType(cells[columnIndex],cells);var v2=sortType(cells2[columnIndex],cells2);if(v1<v2)
|
|
return dsc?-1:+1;if(v1>v2)
|
|
return dsc?+1:-1;return 0;};this.data.sort(fn);if(!suppressEvent){this.fireRowsSorted(columnIndex,direction);}};
|
|
|
|
YAHOO.ext.grid.LoadableDataModel=function(dataType){YAHOO.ext.grid.LoadableDataModel.superclass.constructor.call(this,[]);this.onLoad=new YAHOO.util.CustomEvent('load');this.onLoadException=new YAHOO.util.CustomEvent('loadException');this.events['load']=this.onLoad;this.events['beforeload']=new YAHOO.util.CustomEvent('beforeload');this.events['loadexception']=this.onLoadException;this.dataType=dataType;this.preprocessors=[];this.postprocessors=[];this.loadedPage=1;this.remoteSort=false;this.pageSize=0;this.pageUrl=null;this.baseParams={};this.paramMap={'page':'page','pageSize':'pageSize','sortColumn':'sortColumn','sortDir':'sortDir'};};YAHOO.extendX(YAHOO.ext.grid.LoadableDataModel,YAHOO.ext.grid.DefaultDataModel);YAHOO.ext.grid.LoadableDataModel.prototype.setLoadedPage=function(pageNum,userCallback){this.loadedPage=pageNum;if(typeof userCallback=='function'){userCallback();}};YAHOO.ext.grid.LoadableDataModel.prototype.isPaged=function(){return this.pageSize>0;};YAHOO.ext.grid.LoadableDataModel.prototype.getTotalRowCount=function(){return this.totalCount||this.getRowCount();};YAHOO.ext.grid.LoadableDataModel.prototype.getPageSize=function(){return this.pageSize;};YAHOO.ext.grid.LoadableDataModel.prototype.getTotalPages=function(){if(this.getPageSize()==0||this.getTotalRowCount()==0){return 1;}
|
|
return Math.ceil(this.getTotalRowCount()/this.getPageSize());};YAHOO.ext.grid.LoadableDataModel.prototype.initPaging=function(url,pageSize,baseParams){this.pageUrl=url;this.pageSize=pageSize;this.remoteSort=true;if(baseParams)this.baseParams=baseParams;};YAHOO.ext.grid.LoadableDataModel.prototype.createParams=function(pageNum,sortColumn,sortDir){var params={},map=this.paramMap;for(var key in this.baseParams){if(typeof this.baseParams[key]!='function'){params[key]=this.baseParams[key];}}
|
|
params[map['page']]=pageNum;params[map['pageSize']]=this.getPageSize();params[map['sortColumn']]=(typeof sortColumn=='undefined'?'':sortColumn);params[map['sortDir']]=sortDir||'';return params;};YAHOO.ext.grid.LoadableDataModel.prototype.loadPage=function(pageNum,callback,keepExisting){var sort=this.getSortState();var params=this.createParams(pageNum,sort.column,sort.direction);this.load(this.pageUrl,params,this.setLoadedPage.createDelegate(this,[pageNum,callback]),keepExisting?(pageNum-1)*this.pageSize:null);};YAHOO.ext.grid.LoadableDataModel.prototype.applySort=function(suppressEvent){if(!this.remoteSort){YAHOO.ext.grid.LoadableDataModel.superclass.applySort.apply(this,arguments);}else if(!suppressEvent){var sort=this.getSortState();if(sort.column){this.fireRowsSorted(sort.column,sort.direction,true);}}};YAHOO.ext.grid.LoadableDataModel.prototype.resetPaging=function(){this.loadedPage=1;};YAHOO.ext.grid.LoadableDataModel.prototype.sort=function(columnModel,columnIndex,direction,suppressEvent){if(!this.remoteSort){YAHOO.ext.grid.LoadableDataModel.superclass.sort.apply(this,arguments);}else{this.columnModel=columnModel;this.sortColumn=columnIndex;this.sortDir=direction;var params=this.createParams(this.loadedPage,columnIndex,direction);this.load(this.pageUrl,params,this.fireRowsSorted.createDelegate(this,[columnIndex,direction,true]));}}
|
|
YAHOO.ext.grid.LoadableDataModel.prototype.load=function(url,params,callback,insertIndex){this.fireEvent('beforeload');if(params&&typeof params!='string'){var buf=[];for(var key in params){if(typeof params[key]!='function'){buf.push(encodeURIComponent(key),'=',encodeURIComponent(params[key]),'&');}}
|
|
delete buf[buf.length-1];params=buf.join('');}
|
|
var cb={success:this.processResponse,failure:this.processException,scope:this,argument:{callback:callback,insertIndex:insertIndex}};var method=params?'POST':'GET';YAHOO.util.Connect.asyncRequest(method,url,cb,params);};YAHOO.ext.grid.LoadableDataModel.prototype.processResponse=function(response){var cb=response.argument.callback;var keepExisting=(typeof response.argument.insertIndex=='number');var insertIndex=response.argument.insertIndex;switch(this.dataType){case YAHOO.ext.grid.LoadableDataModel.XML:this.loadData(response.responseXML,cb,keepExisting,insertIndex);break;case YAHOO.ext.grid.LoadableDataModel.JSON:var rtext=response.responseText;try{while(rtext.substring(0,1)==" "){rtext=rtext.substring(1,rtext.length);}
|
|
if(rtext.indexOf("{")<0){throw"Invalid JSON response";}
|
|
if(rtext.indexOf("{}")===0){this.loadData({},response.argument.callback);return;}
|
|
var jsonObjRaw=eval("("+rtext+")");if(!jsonObjRaw){throw"Error evaling JSON response";}
|
|
this.loadData(jsonObjRaw,cb,keepExisting,insertIndex);}catch(e){this.fireLoadException(e,response);if(typeof callback=='function'){callback(this,false);}}
|
|
break;case YAHOO.ext.grid.LoadableDataModel.TEXT:this.loadData(response.responseText,cb,keepExisting,insertIndex);break;};};YAHOO.ext.grid.LoadableDataModel.prototype.processException=function(response){this.fireLoadException(null,response);if(typeof response.argument.callback=='function'){response.argument.callback(this,false);}};YAHOO.ext.grid.LoadableDataModel.prototype.fireLoadException=function(e,responseObj){this.onLoadException.fireDirect(this,e,responseObj);};YAHOO.ext.grid.LoadableDataModel.prototype.fireLoadEvent=function(){this.fireEvent('load',this.loadedPage,this.getTotalPages());};YAHOO.ext.grid.LoadableDataModel.prototype.addPreprocessor=function(columnIndex,fn){this.preprocessors[columnIndex]=fn;};YAHOO.ext.grid.LoadableDataModel.prototype.getPreprocessor=function(columnIndex){return this.preprocessors[columnIndex];};YAHOO.ext.grid.LoadableDataModel.prototype.removePreprocessor=function(columnIndex){this.preprocessors[columnIndex]=null;};YAHOO.ext.grid.LoadableDataModel.prototype.addPostprocessor=function(columnIndex,fn){this.postprocessors[columnIndex]=fn;};YAHOO.ext.grid.LoadableDataModel.prototype.getPostprocessor=function(columnIndex){return this.postprocessors[columnIndex];};YAHOO.ext.grid.LoadableDataModel.prototype.removePostprocessor=function(columnIndex){this.postprocessors[columnIndex]=null;};YAHOO.ext.grid.LoadableDataModel.prototype.loadData=function(data,callback,keepExisting,insertIndex){};YAHOO.ext.grid.LoadableDataModel.XML='xml';YAHOO.ext.grid.LoadableDataModel.JSON='json';YAHOO.ext.grid.LoadableDataModel.TEXT='text';
|
|
|
|
YAHOO.ext.grid.XMLDataModel=function(schema,xml){YAHOO.ext.grid.XMLDataModel.superclass.constructor.call(this,YAHOO.ext.grid.LoadableDataModel.XML);this.schema=schema;this.xml=xml;if(xml){this.loadData(xml);}};YAHOO.extendX(YAHOO.ext.grid.XMLDataModel,YAHOO.ext.grid.LoadableDataModel);YAHOO.ext.grid.XMLDataModel.prototype.getDocument=function(){return this.xml;};YAHOO.ext.grid.XMLDataModel.prototype.loadData=function(doc,callback,keepExisting,insertIndex){this.xml=doc;var idField=this.schema.id;var fields=this.schema.fields;if(this.schema.totalTag){this.totalCount=null;var totalNode=doc.getElementsByTagName(this.schema.totalTag);if(totalNode&&totalNode.item(0)&&totalNode.item(0).firstChild){var v=parseInt(totalNode.item(0).firstChild.nodeValue,10);if(!isNaN(v)){this.totalCount=v;}}}
|
|
var rowData=[];var nodes=doc.getElementsByTagName(this.schema.tagName);if(nodes&&nodes.length>0){for(var i=0;i<nodes.length;i++){var node=nodes.item(i);var colData=[];colData.node=node;colData.id=this.getNamedValue(node,idField,String(i));for(var j=0;j<fields.length;j++){var val=this.getNamedValue(node,fields[j],"");if(this.preprocessors[j]){val=this.preprocessors[j](val);}
|
|
colData.push(val);}
|
|
rowData.push(colData);}}
|
|
if(keepExisting!==true){YAHOO.ext.grid.XMLDataModel.superclass.removeAll.call(this);}
|
|
if(typeof insertIndex!='number'){insertIndex=this.getRowCount();}
|
|
YAHOO.ext.grid.XMLDataModel.superclass.insertRows.call(this,insertIndex,rowData);if(typeof callback=='function'){callback(this,true);}
|
|
this.fireLoadEvent();};YAHOO.ext.grid.XMLDataModel.prototype.addRow=function(id,cellValues){var newIndex=this.getRowCount();var node=this.createNode(this.xml,id,cellValues);cellValues.id=id||newIndex;cellValues.node=node;YAHOO.ext.grid.XMLDataModel.superclass.addRow.call(this,cellValues);return newIndex;};YAHOO.ext.grid.XMLDataModel.prototype.insertRow=function(index,id,cellValues){var node=this.createNode(this.xml,id,cellValues);cellValues.id=id||this.getRowCount();cellValues.node=node;YAHOO.ext.grid.XMLDataModel.superclass.insertRow.call(this,index,cellValues);return index;};YAHOO.ext.grid.XMLDataModel.prototype.removeRow=function(index){var node=this.data[index].node;node.parentNode.removeChild(node);YAHOO.ext.grid.XMLDataModel.superclass.removeRow.call(this,index,index);};YAHOO.ext.grid.XMLDataModel.prototype.getNode=function(rowIndex){return this.data[rowIndex].node;};YAHOO.ext.grid.XMLDataModel.prototype.createNode=function(xmlDoc,id,colData){var template=this.data[0].node;var newNode=template.cloneNode(true);var fields=this.schema.fields;for(var i=0;i<fields.length;i++){var nodeValue=colData[i];if(this.postprocessors[i]){nodeValue=this.postprocessors[i](nodeValue);}
|
|
this.setNamedValue(newNode,fields[i],nodeValue);}
|
|
if(id){this.setNamedValue(newNode,this.schema.idField,id);}
|
|
template.parentNode.appendChild(newNode);return newNode;};YAHOO.ext.grid.XMLDataModel.prototype.getNamedValue=function(node,name,defaultValue){if(!node||!name){return defaultValue;}
|
|
var nodeValue=defaultValue;var attrNode=node.attributes.getNamedItem(name);if(attrNode){nodeValue=attrNode.value;}else{var childNode=node.getElementsByTagName(name);if(childNode&&childNode.item(0)&&childNode.item(0).firstChild){nodeValue=childNode.item(0).firstChild.nodeValue;}else{var index=name.indexOf(':');if(index>0){return this.getNamedValue(node,name.substr(index+1),defaultValue);}}}
|
|
return nodeValue;};YAHOO.ext.grid.XMLDataModel.prototype.setNamedValue=function(node,name,value){if(!node||!name){return;}
|
|
var attrNode=node.attributes.getNamedItem(name);if(attrNode){attrNode.value=value;return;}
|
|
var childNode=node.getElementsByTagName(name);if(childNode&&childNode.item(0)&&childNode.item(0).firstChild){childNode.item(0).firstChild.nodeValue=value;}else{var index=name.indexOf(':');if(index>0){this.setNamedValue(node,name.substr(index+1),value);}}};YAHOO.ext.grid.XMLDataModel.prototype.setValueAt=function(value,rowIndex,colIndex){var node=this.data[rowIndex].node;if(node){var nodeValue=value;if(this.postprocessors[colIndex]){nodeValue=this.postprocessors[colIndex](value);}
|
|
this.setNamedValue(node,this.schema.fields[colIndex],nodeValue);}
|
|
YAHOO.ext.grid.XMLDataModel.superclass.setValueAt.call(this,value,rowIndex,colIndex);};YAHOO.ext.grid.XMLDataModel.prototype.getRowId=function(rowIndex){return this.data[rowIndex].id;};
|
|
|
|
YAHOO.ext.grid.JSONDataModel=function(schema){YAHOO.ext.grid.JSONDataModel.superclass.constructor.call(this,YAHOO.ext.grid.LoadableDataModel.JSON);this.schema=schema;};YAHOO.extendX(YAHOO.ext.grid.JSONDataModel,YAHOO.ext.grid.LoadableDataModel);YAHOO.ext.grid.JSONDataModel.prototype.loadData=function(data,callback,keepExisting){var idField=this.schema.id;var fields=this.schema.fields;var rowData=[];try{var root=eval('data.'+this.schema.root);for(var i=0;i<root.length;i++){var node=root[i];var colData=[];colData.node=node;colData.id=(typeof node[idField]!='undefined'&&node[idField]!==''?node[idField]:String(i));for(var j=0;j<fields.length;j++){var val=node[fields[j]];if(typeof val=='undefined'){val='';}
|
|
if(this.preprocessors[j]){val=this.preprocessors[j](val);}
|
|
colData.push(val);}
|
|
rowData.push(colData);}
|
|
if(keepExisting!==true){this.removeAll();}
|
|
this.addRows(rowData);if(typeof callback=='function'){callback(this,true);}
|
|
this.fireLoadEvent();}catch(e){this.fireLoadException(e,null);if(typeof callback=='function'){callback(this,false);}}};YAHOO.ext.grid.JSONDataModel.prototype.getRowId=function(rowIndex){return this.data[rowIndex].id;};
|
|
|
|
YAHOO.ext.grid.DefaultSelectionModel=function(){this.selectedRows=[];this.selectedRowIds=[];this.lastSelectedRow=null;this.onRowSelect=new YAHOO.util.CustomEvent('SelectionTable.rowSelected');this.onSelectionChange=new YAHOO.util.CustomEvent('SelectionTable.selectionChanged');this.events={'selectionchange':this.onSelectionChange,'rowselect':this.onRowSelect};this.locked=false;};YAHOO.ext.grid.DefaultSelectionModel.prototype={init:function(grid){this.grid=grid;this.initEvents();},lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isLocked:function(){return this.locked;},initEvents:function(){if(this.grid.trackMouseOver){this.grid.addListener("mouseover",this.handleOver,this,true);this.grid.addListener("mouseout",this.handleOut,this,true);}
|
|
this.grid.addListener("rowclick",this.rowClick,this,true);this.grid.addListener("keydown",this.keyDown,this,true);},addListener:YAHOO.ext.grid.Grid.prototype.addListener,removeListener:YAHOO.ext.grid.Grid.prototype.removeListener,fireEvent:YAHOO.ext.grid.Grid.prototype.fireEvent,syncSelectionsToIds:function(){if(this.getCount()>0){var ids=this.selectedRowIds.concat();this.clearSelections();this.selectRowsById(ids,true);}},selectRowsById:function(id,keepExisting){var rows=this.grid.getRowsById(id);this.selectRows(rows,keepExisting);},getCount:function(){return this.selectedRows.length;},selectFirstRow:function(){for(var j=0;j<this.grid.rows.length;j++){if(this.isSelectable(this.grid.rows[j])){this.focusRow(this.grid.rows[j]);this.setRowState(this.grid.rows[j],true);return;}}},selectNext:function(keepExisting){if(this.lastSelectedRow){for(var j=(this.lastSelectedRow.rowIndex+1);j<this.grid.rows.length;j++){var row=this.grid.rows[j];if(this.isSelectable(row)){this.focusRow(row);this.setRowState(row,true,keepExisting);return;}}}},selectPrevious:function(keepExisting){if(this.lastSelectedRow){for(var j=(this.lastSelectedRow.rowIndex-1);j>=0;j--){var row=this.grid.rows[j];if(this.isSelectable(row)){this.focusRow(row);this.setRowState(row,true,keepExisting);return;}}}},getSelectedRows:function(){return this.selectedRows;},getSelectedRowIds:function(){return this.selectedRowIds;},clearSelections:function(){if(this.isLocked())return;var oldSelections=this.selectedRows.concat();for(var j=0;j<oldSelections.length;j++){this.setRowState(oldSelections[j],false);}
|
|
this.selectedRows=[];this.selectedRowIds=[];},selectAll:function(){if(this.isLocked())return;for(var j=0;j<this.grid.rows.length;j++){this.setRowState(this.grid.rows[j],true,true);}},hasSelection:function(){return this.selectedRows.length>0;},isSelected:function(row){return row&&(row.selected===true||row.getAttribute('selected')=='true');},isSelectable:function(row){return row&&row.getAttribute('selectable')!='false';},rowClick:function(grid,rowIndex,e){if(this.isLocked())return;var row=grid.getRow(rowIndex);if(this.isSelectable(row)){if(e.shiftKey&&this.lastSelectedRow){var lastIndex=this.lastSelectedRow.rowIndex;this.selectRange(this.lastSelectedRow,row,e.ctrlKey);this.lastSelectedRow=this.grid.el.dom.rows[lastIndex];}else{this.focusRow(row);var rowState=e.ctrlKey?!this.isSelected(row):true;this.setRowState(row,rowState,e.hasModifier());}}},focusRow:function(row){this.grid.view.focusRow(row);},selectRow:function(row,keepExisting){this.setRowState(this.getRow(row),true,keepExisting);},selectRows:function(rows,keepExisting){if(!keepExisting){this.clearSelections();}
|
|
for(var i=0;i<rows.length;i++){this.selectRow(rows[i],true);}},deselectRow:function(row){this.setRowState(this.getRow(row),false);},getRow:function(row){if(typeof row=='number'){row=this.grid.rows[row];}
|
|
return row;},selectRange:function(startRow,endRow,keepExisting){startRow=this.getRow(startRow);endRow=this.getRow(endRow);this.setRangeState(startRow,endRow,true,keepExisting);},deselectRange:function(startRow,endRow){startRow=this.getRow(startRow);endRow=this.getRow(endRow);this.setRangeState(startRow,endRow,false,true);},setRowStateFromChild:function(childEl,selected,keepExisting){var row=this.grid.getRowFromChild(childEl);this.setRowState(row,selected,keepExisting);},setRangeState:function(startRow,endRow,selected,keepExisting){if(this.isLocked())return;if(!keepExisting){this.clearSelections();}
|
|
var curRow=startRow;while(curRow.rowIndex!=endRow.rowIndex){this.setRowState(curRow,selected,true);curRow=(startRow.rowIndex<endRow.rowIndex?this.grid.getRowAfter(curRow):this.grid.getRowBefore(curRow))}
|
|
this.setRowState(endRow,selected,true);},setRowState:function(row,selected,keepExisting){if(this.isLocked())return;if(this.isSelectable(row)){if(selected){if(!keepExisting){this.clearSelections();}
|
|
this.setRowClass(row,'selected');row.selected=true;this.selectedRows.push(row);this.selectedRowIds.push(this.grid.dataModel.getRowId(row.rowIndex));this.lastSelectedRow=row;}else{this.setRowClass(row,'');row.selected=false;this._removeSelected(row);}
|
|
this.fireEvent('rowselect',this,row,selected);this.fireEvent('selectionchange',this,this.selectedRows,this.selectedRowIds);}},handleOver:function(e){var row=this.grid.getRowFromChild(e.getTarget());if(this.isSelectable(row)&&!this.isSelected(row)){this.setRowClass(row,'over');}},handleOut:function(e){var row=this.grid.getRowFromChild(e.getTarget());if(this.isSelectable(row)&&!this.isSelected(row)){this.setRowClass(row,'');}},keyDown:function(e){if(e.browserEvent.keyCode==e.DOWN){this.selectNext(e.shiftKey);e.preventDefault();}else if(e.browserEvent.keyCode==e.UP){this.selectPrevious(e.shiftKey);e.preventDefault();}},setRowClass:function(row,cssClass){if(this.isSelectable(row)){if(cssClass=='selected'){YAHOO.util.Dom.removeClass(row,'ygrid-row-over');YAHOO.util.Dom.addClass(row,'ygrid-row-selected');}else if(cssClass=='over'){YAHOO.util.Dom.removeClass(row,'ygrid-row-selected');YAHOO.util.Dom.addClass(row,'ygrid-row-over');}else if(cssClass==''){YAHOO.util.Dom.removeClass(row,'ygrid-row-selected');YAHOO.util.Dom.removeClass(row,'ygrid-row-over');}}},_removeSelected:function(row){var sr=this.selectedRows;for(var i=0;i<sr.length;i++){if(sr[i]===row){this.selectedRows.splice(i,1);this.selectedRowIds.splice(i,1);return;}}}};YAHOO.ext.grid.SingleSelectionModel=function(){YAHOO.ext.grid.SingleSelectionModel.superclass.constructor.call(this);};YAHOO.extendX(YAHOO.ext.grid.SingleSelectionModel,YAHOO.ext.grid.DefaultSelectionModel);YAHOO.ext.grid.SingleSelectionModel.prototype.setRowState=function(row,selected){YAHOO.ext.grid.SingleSelectionModel.superclass.setRowState.call(this,row,selected,false);};YAHOO.ext.grid.DisableSelectionModel=function(){YAHOO.ext.grid.DisableSelectionModel.superclass.constructor.call(this);};YAHOO.extendX(YAHOO.ext.grid.DisableSelectionModel,YAHOO.ext.grid.DefaultSelectionModel);YAHOO.ext.grid.DisableSelectionModel.prototype.initEvents=function(){};
|
|
|
|
YAHOO.ext.grid.EditorSelectionModel=function(){YAHOO.ext.grid.EditorSelectionModel.superclass.constructor.call(this);this.clicksToActivateCell=1;this.events['cellactivate']=new YAHOO.util.CustomEvent('cellactivate');};YAHOO.extendX(YAHOO.ext.grid.EditorSelectionModel,YAHOO.ext.grid.DefaultSelectionModel);YAHOO.ext.grid.EditorSelectionModel.prototype.disableArrowNavigation=false;YAHOO.ext.grid.EditorSelectionModel.prototype.controlForArrowNavigation=false;YAHOO.ext.grid.EditorSelectionModel.prototype.initEvents=function(){this.grid.addListener("cellclick",this.onCellClick,this,true);this.grid.addListener("celldblclick",this.onCellDblClick,this,true);this.grid.addListener("keydown",this.keyDown,this,true);};YAHOO.ext.grid.EditorSelectionModel.prototype.onCellClick=function(grid,rowIndex,colIndex){if(this.clicksToActivateCell==1){var row=this.grid.getRow(rowIndex);var cell=row.childNodes[colIndex];if(cell){this.activate(row,cell);}}};YAHOO.ext.grid.EditorSelectionModel.prototype.activate=function(row,cell){this.fireEvent('cellactivate',this,row,cell);this.grid.doEdit(row,cell);};YAHOO.ext.grid.EditorSelectionModel.prototype.onCellDblClick=function(grid,rowIndex,colIndex){if(this.clicksToActivateCell==2){var row=this.grid.getRow(rowIndex);var cell=row.childNodes[colIndex];if(cell){this.activate(row,cell);}}};YAHOO.ext.grid.EditorSelectionModel.prototype.setRowState=function(row,selected){YAHOO.ext.grid.EditorSelectionModel.superclass.setRowState.call(this,row,false,false);};YAHOO.ext.grid.EditorSelectionModel.prototype.focusRow=function(row,selected){};YAHOO.ext.grid.EditorSelectionModel.prototype.getEditorCellAfter=function(cell,spanRows){var g=this.grid;var next=g.getCellAfter(cell);while(next&&!g.colModel.isCellEditable(next.columnIndex)){next=g.getCellAfter(next);}
|
|
if(!next&&spanRows){var row=g.getRowAfter(g.getRowFromChild(cell));next=g.getFirstCell(row);if(!g.colModel.isCellEditable(next.columnIndex)){next=this.getEditorCellAfter(next);}}
|
|
return next;};YAHOO.ext.grid.EditorSelectionModel.prototype.getEditorCellBefore=function(cell,spanRows){var g=this.grid;var prev=g.getCellBefore(cell);while(prev&&!g.colModel.isCellEditable(prev.columnIndex)){prev=g.getCellBefore(prev);}
|
|
if(!prev&&spanRows){var row=g.getRowBefore(g.getRowFromChild(cell));prev=g.getLastCell(row);if(!g.colModel.isCellEditable(prev.columnIndex)){prev=this.getEditorCellBefore(prev);}}
|
|
return prev;};YAHOO.ext.grid.EditorSelectionModel.prototype.allowArrowNav=function(e){return(!this.disableArrowNavigation&&(!this.controlForArrowNavigation||e.ctrlKey));}
|
|
YAHOO.ext.grid.EditorSelectionModel.prototype.keyDown=function(e){var g=this.grid,cm=g.colModel,cell=g.getEditingCell();if(!cell)return;var newCell;switch(e.browserEvent.keyCode){case e.TAB:if(e.shiftKey){newCell=this.getEditorCellBefore(cell,true);}else{newCell=this.getEditorCellAfter(cell,true);}
|
|
break;case e.DOWN:if(this.allowArrowNav(e)){var next=g.getRowAfter(g.getRowFromChild(cell));if(next){newCell=next.childNodes[cell.columnIndex];}}
|
|
break;case e.UP:if(this.allowArrowNav(e)){var prev=g.getRowBefore(g.getRowFromChild(cell));if(prev){newCell=prev.childNodes[cell.columnIndex];}}
|
|
break;case e.RETURN:if(e.shiftKey){var prev=g.getRowBefore(g.getRowFromChild(cell));if(prev){newCell=prev.childNodes[cell.columnIndex];}}else{var next=g.getRowAfter(g.getRowFromChild(cell));if(next){newCell=next.childNodes[cell.columnIndex];}}
|
|
break;case e.RIGHT:if(this.allowArrowNav(e)){newCell=this.getEditorCellAfter(cell);}
|
|
break;case e.LEFT:if(this.allowArrowNav(e)){newCell=this.getEditorCellBefore(cell);}
|
|
break;};if(newCell){this.activate(g.getRowFromChild(newCell),newCell);e.stopEvent();}};YAHOO.ext.grid.EditorAndSelectionModel=function(){YAHOO.ext.grid.EditorAndSelectionModel.superclass.constructor.call(this);this.events['cellactivate']=new YAHOO.util.CustomEvent('cellactivate');};YAHOO.extendX(YAHOO.ext.grid.EditorAndSelectionModel,YAHOO.ext.grid.DefaultSelectionModel);YAHOO.ext.grid.EditorAndSelectionModel.prototype.initEvents=function(){YAHOO.ext.grid.EditorAndSelectionModel.superclass.initEvents.call(this);this.grid.addListener("celldblclick",this.onCellDblClick,this,true);};YAHOO.ext.grid.EditorAndSelectionModel.prototype.onCellDblClick=function(grid,rowIndex,colIndex){var row=this.grid.getRow(rowIndex);var cell=row.childNodes[colIndex];if(cell){this.fireEvent('cellactivate',this,row,cell);this.grid.doEdit(row,cell);}};
|
|
|
|
YAHOO.ext.grid.CellEditor=function(element){this.colIndex=null;this.rowIndex=null;this.grid=null;this.editing=false;this.originalValue=null;this.element=getEl(element,true);this.element.addClass('ygrid-editor');this.element.dom.tabIndex=1;this.initialized=false;this.callback=null;};YAHOO.ext.grid.CellEditor.prototype={init:function(grid,bodyElement,callback){if(this.initialized)return;this.initialized=true;this.callback=callback;this.grid=grid;bodyElement.appendChild(this.element.dom);this.initEvents();},initEvents:function(){var stopOnEnter=function(e){if(e.browserEvent.keyCode==e.RETURN){this.stopEditing(true);}}
|
|
this.element.mon('keydown',stopOnEnter,this,true);this.element.on('blur',this.stopEditing,this,true);},startEditing:function(value,row,cell){this.originalValue=value;this.rowIndex=row.rowIndex;this.colIndex=cell.columnIndex;this.cell=cell;this.setValue(value);var cellbox=getEl(cell,true).getBox();this.fitToCell(cellbox);this.editing=true;this.show();},stopEditing:function(focusCell){if(this.editing){this.editing=false;var newValue=this.getValue();this.hide();if(this.originalValue!=newValue){this.callback(newValue,this.rowIndex,this.colIndex);}}},setValue:function(value){this.element.dom.value=value;},getValue:function(){return this.element.dom.value;},fitToCell:function(box){this.element.setBox(box,true);},show:function(){this.element.show();this.element.focus();},hide:function(){try{this.element.dom.blur();}catch(e){}
|
|
this.element.hide();}};
|
|
|
|
YAHOO.ext.grid.CheckboxEditor=function(){var div=document.createElement('span');div.className='ygrid-editor ygrid-checkbox-editor';var cb=document.createElement('input');cb.type='checkbox';cb.setAttribute('autocomplete','off');div.appendChild(cb);document.body.appendChild(div);YAHOO.ext.grid.CheckboxEditor.superclass.constructor.call(this,div);div.tabIndex='';cb.tabIndex=1;this.cb=getEl(cb,true);};YAHOO.extendX(YAHOO.ext.grid.CheckboxEditor,YAHOO.ext.grid.CellEditor);YAHOO.ext.grid.CheckboxEditor.prototype.fitToCell=function(box){this.element.setBox(box,true);};YAHOO.ext.grid.CheckboxEditor.prototype.setValue=function(value){this.cb.dom.checked=(value===true||value==='true'||value===1||value==='1');};YAHOO.ext.grid.CheckboxEditor.prototype.getValue=function(){return this.cb.dom.checked;};YAHOO.ext.grid.CheckboxEditor.prototype.show=function(){this.element.show();this.cb.focus();};YAHOO.ext.grid.CheckboxEditor.prototype.initEvents=function(){var stopOnEnter=function(e){if(e.browserEvent.keyCode==e.RETURN){this.stopEditing(true);}}
|
|
this.cb.mon('keydown',stopOnEnter,this,true);this.cb.on('blur',this.stopEditing,this,true);};YAHOO.ext.grid.CheckboxEditor.prototype.hide=function(){try{this.cb.dom.blur();}catch(e){}
|
|
this.element.hide();};
|
|
|
|
YAHOO.ext.grid.DateEditor=function(config){var div=document.createElement('span');div.className='ygrid-editor ygrid-editor-container';var element=document.createElement('input');element.type='text';element.tabIndex=1;element.setAttribute('autocomplete','off');div.appendChild(element);var pick=document.createElement('span');pick.className='pick-button';div.appendChild(pick);document.body.appendChild(div);this.div=getEl(div,true);this.element=getEl(element,true);this.pick=getEl(pick,true);this.colIndex=null;this.rowIndex=null;this.grid=null;this.editing=false;this.originalValue=null;this.initialized=false;this.callback=null;this.cal=null;this.mouseDownHandler=YAHOO.ext.EventManager.wrap(this.handleMouseDown,this,true);YAHOO.ext.util.Config.apply(this,config);if(typeof this.minValue=='string')this.minValue=this.parseDate(this.minValue);if(typeof this.maxValue=='string')this.maxValue=this.parseDate(this.maxValue);this.ddMatch=/ddnone/;if(this.disabledDates){var dd=this.disabledDates;var re="(?:";for(var i=0;i<dd.length;i++){re+=dd[i];if(i!=dd.length-1)re+="|";}
|
|
this.ddMatch=new RegExp(re+")");}};YAHOO.ext.grid.DateEditor.prototype={init:function(grid,bodyElement,callback){if(this.initialized)return;this.initialized=true;this.callback=callback;this.grid=grid;bodyElement.appendChild(this.div.dom);this.initEvents();},initEvents:function(){var stopOnEnter=function(e){if(e.browserEvent.keyCode==e.RETURN){this.stopEditing(true);}}
|
|
this.element.mon('keydown',stopOnEnter,this,true);var vtask=new YAHOO.ext.util.DelayedTask(this.validate,this);this.element.mon('keyup',vtask.delay.createDelegate(vtask,[this.validationDelay]));this.pick.on('click',this.showCalendar,this,true);},startEditing:function(value,row,cell){this.originalValue=value;this.rowIndex=row.rowIndex;this.colIndex=cell.columnIndex;this.cell=cell;this.setValue(value);this.validate();var cellbox=getEl(cell,true).getBox();this.div.setBox(cellbox,true);this.element.setWidth(cellbox.width-this.pick.getWidth());this.editing=true;YAHOO.util.Event.on(document,"mousedown",this.mouseDownHandler);this.show();},stopEditing:function(focusCell){if(this.editing){YAHOO.util.Event.removeListener(document,"mousedown",this.mouseDownHandler);this.editing=false;var newValue=this.getValue();this.hide();if(this.originalValue!=newValue){this.callback(newValue,this.rowIndex,this.colIndex);}}},setValue:function(value){this.element.dom.value=this.formatDate(value);this.validate();},getValue:function(){if(!this.validate()){return this.originalValue;}else{var value=this.element.dom.value;if(value.length<1){return value;}else{return this.parseDate(value);}}},show:function(){this.div.show();this.element.focus();this.validate();},hide:function(){try{this.element.dom.blur();}catch(e){}
|
|
this.div.hide();},validate:function(){var dom=this.element.dom;var value=dom.value;if(value.length<1){if(this.allowBlank){dom.title='';this.element.removeClass('ygrid-editor-invalid');return true;}else{dom.title=this.blankText;this.element.addClass('ygrid-editor-invalid');return false;}}
|
|
value=this.parseDate(value);if(!value){dom.title=this.invalidText.replace('%0',dom.value).replace('%1',this.format);this.element.addClass('ygrid-editor-invalid');return false;}
|
|
var time=value.getTime();if(this.minValue&&time<this.minValue.getTime()){dom.title=this.minText.replace('%0',this.formatDate(this.minValue));this.element.addClass('ygrid-editor-invalid');return false;}
|
|
if(this.maxValue&&time>this.maxValue.getTime()){dom.title=this.maxText.replace('%0',this.formatDate(this.maxValue));this.element.addClass('ygrid-editor-invalid');return false;}
|
|
if(this.disabledDays){var day=value.getDay();for(var i=0;i<this.disabledDays.length;i++){if(day===this.disabledDays[i]){dom.title=this.disabledDaysText;this.element.addClass('ygrid-editor-invalid');return false;}}}
|
|
var fvalue=this.formatDate(value);if(this.ddMatch.test(fvalue)){dom.title=this.disabledDatesText.replace('%0',fvalue);this.element.addClass('ygrid-editor-invalid');return false;}
|
|
var msg=this.validator(value);if(msg!==true){dom.title=msg;this.element.addClass('ygrid-editor-invalid');return false;}
|
|
dom.title='';this.element.removeClass('ygrid-editor-invalid');return true;},handleMouseDown:function(e){var t=e.getTarget();var dom=this.div.dom;if(t!=dom&&!YAHOO.util.Dom.isAncestor(dom,t)){this.stopEditing();}},showCalendar:function(value){if(this.cal==null){this.cal=new YAHOO.ext.DatePicker(this.div.dom.parentNode.parentNode);}
|
|
this.cal.minDate=this.minValue;this.cal.maxDate=this.maxValue;this.cal.disabledDatesRE=this.ddMatch;this.cal.disabledDatesText=this.disabledDatesText;this.cal.disabledDays=this.disabledDays;this.cal.disabledDaysText=this.disabledDaysText;this.cal.format=this.format;if(this.minValue){this.cal.minText=this.minText.replace('%0',this.formatDate(this.minValue));}
|
|
if(this.maxValue){this.cal.maxText=this.maxText.replace('%0',this.formatDate(this.maxValue));}
|
|
var r=this.div.getRegion();this.cal.show(r.left,r.bottom,this.getValue(),this.setValue.createDelegate(this));},parseDate:function(value){if(!value||value instanceof Date)return value;return Date.parseDate(value,this.format);},formatDate:function(date){if(!date||!(date instanceof Date))return date;return date.format(this.format);}};YAHOO.ext.grid.DateEditor.prototype.format='m/d/y';YAHOO.ext.grid.DateEditor.prototype.disabledDays=null;YAHOO.ext.grid.DateEditor.prototype.disabledDaysText='';YAHOO.ext.grid.DateEditor.prototype.disabledDates=null;YAHOO.ext.grid.DateEditor.prototype.disabledDatesText='';YAHOO.ext.grid.DateEditor.prototype.allowBlank=true;YAHOO.ext.grid.DateEditor.prototype.minValue=null;YAHOO.ext.grid.DateEditor.prototype.maxValue=null;YAHOO.ext.grid.DateEditor.prototype.minText='The date in this field must be after %0';YAHOO.ext.grid.DateEditor.prototype.maxText='The date in this field must be before %0';YAHOO.ext.grid.DateEditor.prototype.blankText='This field cannot be blank';YAHOO.ext.grid.DateEditor.prototype.invalidText='%0 is not a valid date - it must be in the format %1';YAHOO.ext.grid.DateEditor.prototype.validationDelay=200;YAHOO.ext.grid.DateEditor.prototype.validator=function(){return true;};
|
|
|
|
YAHOO.ext.grid.NumberEditor=function(config){var element=document.createElement('input');element.type='text';element.className='ygrid-editor ygrid-num-editor';element.setAttribute('autocomplete','off');document.body.appendChild(element);YAHOO.ext.grid.NumberEditor.superclass.constructor.call(this,element);YAHOO.ext.util.Config.apply(this,config);};YAHOO.extendX(YAHOO.ext.grid.NumberEditor,YAHOO.ext.grid.CellEditor);YAHOO.ext.grid.NumberEditor.prototype.initEvents=function(){var stopOnEnter=function(e){if(e.browserEvent.keyCode==e.RETURN){this.stopEditing(true);}};var allowed="0123456789";if(this.allowDecimals){allowed+=this.decimalSeparator;}
|
|
if(this.allowNegative){allowed+='-';}
|
|
var keyPress=function(e){var c=e.getCharCode();if(c!=e.BACKSPACE&&allowed.indexOf(String.fromCharCode(c))===-1){e.stopEvent();}};this.element.mon('keydown',stopOnEnter,this,true);var vtask=new YAHOO.ext.util.DelayedTask(this.validate,this);this.element.mon('keyup',vtask.delay.createDelegate(vtask,[this.validationDelay]));this.element.mon('keypress',keyPress,this,true);this.element.on('blur',this.stopEditing,this,true);};YAHOO.ext.grid.NumberEditor.prototype.validate=function(){var dom=this.element.dom;var value=dom.value;if(value.length<1){if(this.allowBlank){dom.title='';this.element.removeClass('ygrid-editor-invalid');return true;}else{dom.title=this.blankText;this.element.addClass('ygrid-editor-invalid');return false;}}
|
|
if(value.search(/\d+/)===-1){dom.title=this.nanText.replace('%0',value);this.element.addClass('ygrid-editor-invalid');return false;}
|
|
var num=this.parseValue(value);if(num<this.minValue){dom.title=this.minText.replace('%0',this.minValue);this.element.addClass('ygrid-editor-invalid');return false;}
|
|
if(num>this.maxValue){dom.title=this.maxText.replace('%0',this.maxValue);this.element.addClass('ygrid-editor-invalid');return false;}
|
|
var msg=this.validator(value);if(msg!==true){dom.title=msg;this.element.addClass('ygrid-editor-invalid');return false;}
|
|
dom.title='';this.element.removeClass('ygrid-editor-invalid');return true;};YAHOO.ext.grid.NumberEditor.prototype.show=function(){this.element.dom.title='';YAHOO.ext.grid.NumberEditor.superclass.show.call(this);if(this.selectOnFocus){try{this.element.dom.select();}catch(e){}}
|
|
this.validate(this.element.dom.value);};YAHOO.ext.grid.NumberEditor.prototype.getValue=function(){if(!this.validate()){return this.originalValue;}else{var value=this.element.dom.value;if(value.length<1){return value;}else{return this.fixPrecision(this.parseValue(value));}}};YAHOO.ext.grid.NumberEditor.prototype.parseValue=function(value){return parseFloat(new String(value).replace(this.decimalSeparator,'.'));};YAHOO.ext.grid.NumberEditor.prototype.fixPrecision=function(value){if(!this.allowDecimals||this.decimalPrecision==-1||isNaN(value)||value==0||!value){return value;}
|
|
var scale=Math.pow(10,this.decimalPrecision+1);var fixed=this.decimalPrecisionFcn(value*scale);fixed=this.decimalPrecisionFcn(fixed/10);return fixed/(scale/10);};YAHOO.ext.grid.NumberEditor.prototype.allowBlank=true;YAHOO.ext.grid.NumberEditor.prototype.allowDecimals=true;YAHOO.ext.grid.NumberEditor.prototype.decimalSeparator='.';YAHOO.ext.grid.NumberEditor.prototype.decimalPrecision=2;YAHOO.ext.grid.NumberEditor.prototype.decimalPrecisionFcn=Math.floor;YAHOO.ext.grid.NumberEditor.prototype.allowNegative=true;YAHOO.ext.grid.NumberEditor.prototype.selectOnFocus=true;YAHOO.ext.grid.NumberEditor.prototype.minValue=Number.NEGATIVE_INFINITY;YAHOO.ext.grid.NumberEditor.prototype.maxValue=Number.MAX_VALUE;YAHOO.ext.grid.NumberEditor.prototype.minText='The minimum value for this field is %0';YAHOO.ext.grid.NumberEditor.prototype.maxText='The maximum value for this field is %0';YAHOO.ext.grid.NumberEditor.prototype.blankText='This field cannot be blank';YAHOO.ext.grid.NumberEditor.prototype.nanText='%0 is not a valid number';YAHOO.ext.grid.NumberEditor.prototype.validationDelay=100;YAHOO.ext.grid.NumberEditor.prototype.validator=function(){return true;};
|
|
|
|
YAHOO.ext.DatePicker=function(id,parentElement){this.id=id;this.selectedDate=new Date();this.visibleDate=new Date();this.element=null;this.shadow=null;this.callback=null;this.buildControl(parentElement||document.body);this.mouseDownHandler=YAHOO.ext.EventManager.wrap(this.handleMouseDown,this,true);this.keyDownHandler=YAHOO.ext.EventManager.wrap(this.handleKeyDown,this,true);this.wheelHandler=YAHOO.ext.EventManager.wrap(this.handleMouseWheel,this,true);};YAHOO.ext.DatePicker.prototype={show:function(x,y,value,callback){this.hide();this.selectedDate=value;this.visibleDate=value;this.callback=callback;this.refresh();this.element.show();this.element.moveTo(x,y);this.shadow.show();this.shadow.setRegion(this.element.getRegion());this.element.dom.tabIndex=1;this.element.focus();YAHOO.util.Event.on(document,"mousedown",this.mouseDownHandler);YAHOO.util.Event.on(document,"keydown",this.keyDownHandler);YAHOO.util.Event.on(document,"mousewheel",this.wheelHandler);YAHOO.util.Event.on(document,"DOMMouseScroll",this.wheelHandler);},hide:function(){this.shadow.hide();this.element.hide();YAHOO.util.Event.removeListener(document,"mousedown",this.mouseDownHandler);YAHOO.util.Event.removeListener(document,"keydown",this.keyDownHandler);YAHOO.util.Event.removeListener(document,"mousewheel",this.wheelHandler);YAHOO.util.Event.removeListener(document,"DOMMouseScroll",this.wheelHandler);},setSelectedDate:function(date){this.selectedDate=date;},getSelectedDate:function(){return this.selectedDate;},showPrevMonth:function(){this.visibleDate=this.getPrevMonth(this.visibleDate);this.refresh();},showNextMonth:function(){this.visibleDate=this.getNextMonth(this.visibleDate);this.refresh();},showPrevYear:function(){var d=this.visibleDate;this.visibleDate=new Date(d.getFullYear()-1,d.getMonth(),d.getDate());this.refresh();},showNextYear:function(){var d=this.visibleDate;this.visibleDate=new Date(d.getFullYear()+1,d.getMonth(),d.getDate());this.refresh();},handleMouseDown:function(e){var target=e.getTarget();if(target!=this.element.dom&&!YAHOO.util.Dom.isAncestor(this.element.dom,target)){this.hide();}},handleKeyDown:function(e){switch(e.browserEvent.keyCode){case e.LEFT:this.showPrevMonth();e.stopEvent();break;case e.RIGHT:this.showNextMonth();e.stopEvent();break;case e.DOWN:this.showPrevYear();e.stopEvent();break;case e.UP:this.showNextYear();e.stopEvent();break;}},handleMouseWheel:function(e){var delta=e.getWheelDelta();if(delta>0){this.showPrevMonth();e.stopEvent();}else if(delta<0){this.showNextMonth();e.stopEvent();}},handleClick:function(e){var d=this.visibleDate;var t=e.getTarget();if(t&&t.className){switch(t.className){case'active':this.handleSelection(new Date(d.getFullYear(),d.getMonth(),parseInt(t.innerHTML)));break;case'prevday':var p=this.getPrevMonth(d);this.handleSelection(new Date(p.getFullYear(),p.getMonth(),parseInt(t.innerHTML)));break;case'nextday':var n=this.getNextMonth(d);this.handleSelection(new Date(n.getFullYear(),n.getMonth(),parseInt(t.innerHTML)));break;case'ypopcal-today':this.handleSelection(new Date());break;case'next-month':this.showNextMonth();break;case'prev-month':this.showPrevMonth();break;}}
|
|
e.stopEvent();},selectToday:function(){this.handleSelection(new Date());},handleSelection:function(date){this.selectedDate=date;this.callback(date);this.hide();},getPrevMonth:function(d){var m=d.getMonth();var y=d.getFullYear();return(m==0?new Date(--y,11,1):new Date(y,--m,1));},getNextMonth:function(d){var m=d.getMonth();var y=d.getFullYear();return(m==11?new Date(++y,0,1):new Date(y,++m,1));},getDaysInMonth:function(m,y){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;},isLeapYear:function(y){return(((y%4)==0)&&((y%100)!=0)||((y%400)==0));},clearTime:function(date){if(date){date.setHours(0);date.setMinutes(0);date.setSeconds(0);date.setMilliseconds(0);}
|
|
return date;},refresh:function(){var d=this.visibleDate;this.buildInnerCal(d);this.calHead.update(this.monthNames[d.getMonth()]+' '+d.getFullYear());if(this.element.isVisible()){this.shadow.setRegion(this.element.getRegion());}}};YAHOO.ext.DatePicker.prototype.buildControl=function(parentElement){var c=document.createElement('div');c.style.position='absolute';c.style.visibility='hidden';document.body.appendChild(c);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>'+'<div hidefocus="true" class="ypopcal" id="'+this.id+'" style="-moz-outline:none; position:absolute; z-index:2001; display:none; top:0px; left:0px;">'+'<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>'+'<center><div class="ypopcal-inner">';html+="<table border=0 cellpadding=2 cellspacing=0 class=\"ypopcal-table\"><thead><tr class=\"ypopcal-daynames\">";var names=this.dayNames;for(var i=0;i<names.length;i++){html+='<td>'+names[i].substr(0,1)+'</td>';}
|
|
html+="</tr></thead><tbody><tr>";for(var i=0;i<42;i++){if(i%7==0&&i!=0){html+='</tr><tr>';}
|
|
html+="<td> </td>";}
|
|
html+="</tr></tbody></table>";html+='</div><button class="ypopcal-today" style="margin-top:2px;">'+this.todayText+'</button></center></div>';c.innerHTML=html;this.shadow=getEl(c.childNodes[0],true);this.shadow.enableDisplayMode();this.element=getEl(c.childNodes[1],true);this.element.enableDisplayMode();document.body.appendChild(this.shadow.dom);document.body.appendChild(this.element.dom);document.body.removeChild(c);this.element.on("selectstart",function(){return false;});var tbody=this.element.dom.getElementsByTagName('tbody')[1];this.cells=tbody.getElementsByTagName('td');this.calHead=this.element.getChildrenByClassName('ypopcal-month','td')[0];this.element.mon('mousedown',this.handleClick,this,true);};YAHOO.ext.DatePicker.prototype.buildInnerCal=function(dateVal){var days=this.getDaysInMonth(dateVal.getMonth()+1,dateVal.getFullYear());var firstOfMonth=new Date(dateVal.getFullYear(),dateVal.getMonth(),1);var startingPos=firstOfMonth.getDay();if(startingPos==0)startingPos=7;var pm=this.getPrevMonth(dateVal);var prevStart=this.getDaysInMonth(pm.getMonth()+1,pm.getFullYear())-startingPos;var cells=this.cells;days+=startingPos;var day=86400000;var date=this.clearTime(new Date(pm.getFullYear(),pm.getMonth(),prevStart));var today=this.clearTime(new Date()).getTime();var sel=this.selectedDate?this.clearTime(this.selectedDate).getTime():today+1;var min=this.minDate?this.clearTime(this.minDate).getTime():Number.NEGATIVE_INFINITY;var max=this.maxDate?this.clearTime(this.maxDate).getTime():Number.POSITIVE_INFINITY;var ddMatch=this.disabledDatesRE;var ddText=this.disabledDatesText;var ddays=this.disabledDays;var ddaysText=this.disabledDaysText;var format=this.format;var setCellClass=function(cal,cell,d){cell.title='';var t=d.getTime();if(t==today){cell.className+=' today';cell.title=cal.todayText;}
|
|
if(t==sel){cell.className+=' selected';}
|
|
if(t<min){cell.className=' ypopcal-disabled';cell.title=cal.minText;return;}
|
|
if(t>max){cell.className=' ypopcal-disabled';cell.title=cal.maxText;return;}
|
|
if(ddays){var day=d.getDay();for(var i=0;i<ddays.length;i++){if(day===ddays[i]){cell.title=ddaysText;cell.className=' ypopcal-disabled';return;}}}
|
|
if(ddMatch&&format){var fvalue=d.format(format);if(ddMatch.test(fvalue)){cell.title=ddText.replace('%0',fvalue);cell.className=' ypopcal-disabled';return;}}};var i=0;for(;i<startingPos;i++){cells[i].innerHTML=(++prevStart);date.setDate(date.getDate()+1);cells[i].className='prevday';setCellClass(this,cells[i],date);}
|
|
for(;i<days;i++){intDay=i-startingPos+1;cells[i].innerHTML=(intDay);date.setDate(date.getDate()+1);cells[i].className='active';setCellClass(this,cells[i],date);}
|
|
var extraDays=0;for(;i<42;i++){cells[i].innerHTML=(++extraDays);date.setDate(date.getDate()+1);cells[i].className='nextday';setCellClass(this,cells[i],date);}};YAHOO.ext.DatePicker.prototype.todayText="Today";YAHOO.ext.DatePicker.prototype.minDate=null;YAHOO.ext.DatePicker.prototype.maxDate=null;YAHOO.ext.DatePicker.prototype.minText="This date is before the minimum date";YAHOO.ext.DatePicker.prototype.maxText="This date is after the maximum date";YAHOO.ext.DatePicker.prototype.format='m/d/y';YAHOO.ext.DatePicker.prototype.disabledDays=null;YAHOO.ext.DatePicker.prototype.disabledDaysText='';YAHOO.ext.DatePicker.prototype.disabledDatesRE=null;YAHOO.ext.DatePicker.prototype.disabledDatesText='';YAHOO.ext.DatePicker.prototype.monthNames=Date.monthNames;YAHOO.ext.DatePicker.prototype.dayNames=Date.dayNames;
|
|
|
|
YAHOO.ext.grid.SelectEditor=function(element){element.hideFocus=true;YAHOO.ext.grid.SelectEditor.superclass.constructor.call(this,element);};YAHOO.extendX(YAHOO.ext.grid.SelectEditor,YAHOO.ext.grid.CellEditor);YAHOO.ext.grid.SelectEditor.prototype.fitToCell=function(box){if(YAHOO.ext.util.Browser.isGecko){box.height-=3;}
|
|
this.element.setBox(box,true);};
|
|
|
|
YAHOO.ext.grid.TextEditor=function(config){var element=document.createElement('input');element.type='text';element.className='ygrid-editor ygrid-text-editor';element.setAttribute('autocomplete','off');document.body.appendChild(element);YAHOO.ext.grid.TextEditor.superclass.constructor.call(this,element);YAHOO.ext.util.Config.apply(this,config);};YAHOO.extendX(YAHOO.ext.grid.TextEditor,YAHOO.ext.grid.CellEditor);YAHOO.ext.grid.TextEditor.prototype.validate=function(){var dom=this.element.dom;var value=dom.value;if(value.length<1){if(this.allowBlank){dom.title='';this.element.removeClass('ygrid-editor-invalid');return true;}else{dom.title=this.blankText;this.element.addClass('ygrid-editor-invalid');return false;}}
|
|
if(value.length<this.minLength){dom.title=this.minText.replace('%0',this.minLength);this.element.addClass('ygrid-editor-invalid');return false;}
|
|
if(value.length>this.maxLength){dom.title=this.maxText.replace('%0',this.maxLength);this.element.addClass('ygrid-editor-invalid');return false;}
|
|
var msg=this.validator(value);if(msg!==true){dom.title=msg;this.element.addClass('ygrid-editor-invalid');return false;}
|
|
if(this.regex&&!this.regex.test(value)){dom.title=this.regexText;this.element.addClass('ygrid-editor-invalid');return false;}
|
|
dom.title='';this.element.removeClass('ygrid-editor-invalid');return true;};YAHOO.ext.grid.TextEditor.prototype.initEvents=function(){YAHOO.ext.grid.TextEditor.superclass.initEvents.call(this);var vtask=new YAHOO.ext.util.DelayedTask(this.validate,this);this.element.mon('keyup',vtask.delay.createDelegate(vtask,[this.validationDelay]));};YAHOO.ext.grid.TextEditor.prototype.show=function(){this.element.dom.title='';YAHOO.ext.grid.TextEditor.superclass.show.call(this);this.element.focus();if(this.selectOnFocus){try{this.element.dom.select();}catch(e){}}
|
|
this.validate(this.element.dom.value);};YAHOO.ext.grid.TextEditor.prototype.getValue=function(){if(!this.validate()){return this.originalValue;}else{return this.element.dom.value;}};YAHOO.ext.grid.TextEditor.prototype.allowBlank=true;YAHOO.ext.grid.TextEditor.prototype.minLength=0;YAHOO.ext.grid.TextEditor.prototype.maxLength=Number.MAX_VALUE;YAHOO.ext.grid.TextEditor.prototype.minText='The minimum length for this field is %0';YAHOO.ext.grid.TextEditor.prototype.maxText='The maximum length for this field is %0';YAHOO.ext.grid.TextEditor.prototype.selectOnFocus=true;YAHOO.ext.grid.TextEditor.prototype.blankText='This field cannot be blank';YAHOO.ext.grid.TextEditor.prototype.validator=function(){return true;};YAHOO.ext.grid.TextEditor.prototype.validationDelay=200;YAHOO.ext.grid.TextEditor.prototype.regex=null;YAHOO.ext.grid.TextEditor.prototype.regexText='';
|