From 480673c1d1ed9b8475c14c7f874ecf20ff62e19f Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Mon, 10 Nov 2008 17:04:25 +0000 Subject: [PATCH] mooui compressed using the yuicompressor --- deluge/ui/webui/static/mooui.js | 234 +------------------------------- 1 file changed, 1 insertion(+), 233 deletions(-) diff --git a/deluge/ui/webui/static/mooui.js b/deluge/ui/webui/static/mooui.js index dfe4c271e..09752301a 100644 --- a/deluge/ui/webui/static/mooui.js +++ b/deluge/ui/webui/static/mooui.js @@ -1,233 +1 @@ - -(function(){function pad(val,len){val=String(val);len=len||2;while(val.length99?Math.round(L/10):L),t:H<12?"a":"p",tt:H<12?"am":"pm",T:H<12?"A":"P",TT:H<12?"AM":"PM",Z:utc?"UTC":(String(this).match(timezone)||[""]).pop().replace(timezoneClip,""),o:(o>0?"-":"+")+pad(Math.floor(Math.abs(o)/60)*100+Math.abs(o)%60,4),S:["th","st","nd","rd"][d%10>3?0:(d%100-d%10!=10)*d%10]};return mask.replace(token,function($0){return $0 in flags?flags[$0]:$0.slice(1,$0.length-1);});}});})() -Array.implement({sum:function(key){var total=0 -this.each(function(item){var value=item -if(!$defined(value))return;if($defined(key)){value=item[key]} -if($type(value)=='number'){total+=value}},this) -return total}}) -Element.implement({getInnerSize:function(){this.getPadding();if((/^(?:body|html)$/i).test(this.tagName))return this.getWindow().getSize();return{x:this.clientWidth-this.padding.x,y:this.clientHeight-this.padding.y};},getInnerHeight:function(){return this.getInnerSize().y;},getInnerWidth:function(){return this.getInnerSize().x;},getSizeModifiers:function(update){if(!this.modifiers){var border=this.getBorder(update);var margin=this.getMargin(update);var padding=this.getPadding(update);this.modifiers={left:border.left+margin.left+padding.left,right:border.right+margin.right+padding.right,top:border.top+margin.top+padding.top,bottom:border.bottom+margin.bottom+padding.bottom,x:border.x+margin.x+padding.x,y:border.y+margin.y+padding.y}}},getMargin:function(update){if(!this.margin||update){var parts=this.getStyle('margin').split(' ') -this.margin={left:parts[1].toInt(),right:parts[3].toInt(),top:parts[0].toInt(),bottom:parts[2].toInt(),x:parts[0].toInt()+parts[2].toInt(),y:parts[1].toInt()+parts[3].toInt()};} -return this.margin},getPadding:function(update){if(!this.padding||update){var parts=this.getStyle('padding').split(' ') -this.padding={left:parts[1].toInt(),right:parts[3].toInt(),top:parts[0].toInt(),bottom:parts[2].toInt(),x:parts[0].toInt()+parts[2].toInt(),y:parts[1].toInt()+parts[3].toInt()};} -return this.padding},getBorder:function(update){if(!this.border||update){var parts=this.getStyle('border-width').split(' ') -this.border={left:parts[1].toInt(),right:parts[3].toInt(),top:parts[0].toInt(),bottom:parts[2].toInt(),x:parts[0].toInt()+parts[2].toInt(),y:parts[1].toInt()+parts[3].toInt()};} -return this.border}}) -Number.implement({toBytes:function(){var bytes=this -if(bytes<1024){return bytes.toFixed(1)+'B';} -else{bytes=bytes/1024;} -if(bytes<1024){return bytes.toFixed(1)+'KiB';} -else{bytes=bytes/1024;} -if(bytes<1024){return bytes.toFixed(1)+'MiB';} -else{bytes=bytes/1024;} -return bytes.toFixed(1)+'GiB'},toSpeed:function(){var bits=this -if(bits<1024){return bits.toFixed(1)+'b/s';} -else{bits=bits/1024;} -if(bits<1024){return bits.toFixed(1)+'KiB/s';} -else{bits=bits/1024;} -return bits.toFixed(2)+'MiB/s'},toTime:function(){var time=this -if(time==0){return'∞'} -if(time<60){return time+'s';} -else{time=time/60;} -if(time<60){var minutes=Math.floor(time) -var seconds=Math.round(60*(time-minutes)) -if(seconds>0){return minutes+'m '+seconds+'s';}else{return minutes+'m';}} -else{time=time/60;} -if(time<24){var hours=Math.floor(time) -var minutes=Math.round(60*(time-hours)) -if(minutes>0){return hours+'h '+minutes+'m';}else{return hours+'h';}} -else{time=time/24;} -var days=Math.floor(time) -var hours=Math.round(24*(time-days)) -if(hours>0){return days+'d '+hours+'h';}else{return days+'d';}}}) -String.implement({strip:function(){var stripped=this.replace(/^\s*/,'') -stripped.replace(/\s*$/,'') -return stripped}}) -Sorters={Simple:new Class({initialize:function(column,order){this.column=column;this.order=order;},sorter:function(){return function(a,b){var av,bv;av=a.cells[this.column].value;bv=b.cells[this.column].value;return this.sort(av,bv);}.bind(this);},sort:function(a,b){if(a>b)return 1*this.order;if(a0)this.element.setStyle(property,value);if(!noFire)this.fireEvent('resize',eventArgs);}else{this[property]=value;this.element.setStyle(property,value);}},sets:function(properties){properties=new Hash(properties);var fireResize=false;var eventArgs={};properties.each(function(value,key){if(key=='height'||key=='width'){eventArgs[('old-'+key).camelCase()]=this[key];eventArgs[key]=value;fireResize=true;} -this.set(key,value,true);},this);if(fireResize)this.fireEvent('resize',eventArgs);},toElement:function(){return this.element;}});$W=function(wrap){if(!wrap.isMoouiWidget){if(wrap.retrieve){wrap=wrap.retrieve('moouiWidget');return(wrap)?wrap:new Widgets.Base(wrap);}else{return new Widgets.Base(wrap);};}else{return wrap;};};$$W=function(test){if(!test.isMoouiWidget){if(test.retrieve){test=test.retrieve('moouiWidget');return(test)?test:null;}else{return null;};}else{return wrap;};};Widgets.PopupMenu=new Class({Extends:Widgets.WidgetBase,Implements:Events,initialize:function(){this.items=[] -this.noClose=false -this.build()},add:function(item){if($type(item)=='array'){for(var i=0;i=windowSize.y){y=windowSize.y-menuSize.y-(windowSize.y-y);};this.element.setStyles({'left':x,'top':y-2});this.element.addEvent('mouseleave',function(e){this.hide();}.bind(this));},fixSize:function(el){var widest=0;el.getElements('li').each(function(item){var text=item.getElement('span');var width=text.getSize().x;if(width>widest){widest=width};});el.setStyle('width',widest+32);},fixLeft:function(el){var widest=0 -el.getElements('li').each(function(item){var width=item.getSize().x -if(width>widest){widest=width}});el.setStyle('width',widest+2) -el.getElements('li ul').each(function(item){item.setStyle('left',widest-20)});},showPos:function(x,y){}}) -Widgets.ProgressBar=new Class({Extends:Widgets.Base,initialize:function(){this.parent(new Element('div'));this.bound={onResize:this.onResize.bindWithEvent(this)};this.element.addClass('moouiProgressBar');this.bar=new Element('div').inject(this.element);this.textSpan=new Element('span').inject(this.bar);this.sets({width:200,height:20});this.addEvent('resize',this.bound.onResize);},onResize:function(){this.textSpan.setStyles({'width':this.width,'height':this.height});this.update(this.text,this.percent);},update:function(text,percent){if(this.text!=text){this.text=text;this.textSpan.set('text',text);};if(this.percent!=percent){this.percent=percent;this.bar.setStyles({'width':Math.floor(this.width/100.0*percent),'height':this.height});};}});Widgets.Spinner=new Class({Extends:Widgets.Base,options:{precision:0,step:1,limit:{high:null,low:null}},initialize:function(input,options){this.parent(new Element('div'),options);this.bound={onMouseDown:this.onMouseDown.bindWithEvent(this),onMouseUp:this.onMouseUp.bindWithEvent(this),onMouseWheel:this.onMouseWheel.bindWithEvent(this),onKeyDown:this.onKeyDown.bindWithEvent(this),onKeyUp:this.onKeyUp.bindWithEvent(this),onChange:this.onChange.bindWithEvent(this)};value=0;this.keyDown=false;if(input){this.element.replaces(input);value=new Number(input.value);};this.input=(input)?input:new Element('input');this.input.store('moouiWidget',this);this.element.grab(this.input);this.element.addClass('moouiSpinner');this.element.addEvent('mousewheel',this.bound.onMouseWheel);this.input.addEvent('keydown',this.bound.onKeyDown);this.input.addEvent('change',this.bound.onChange);this.buttons=new Element('div').addClass('moouiSpinnerButtons');this.up=new Element('div').addClass('moouiSpinnerUp');this.down=new Element('div').addClass('moouiSpinnerDown');this.up.addEvent('mousedown',this.bound.onMouseDown);this.down.addEvent('mousedown',this.bound.onMouseDown);this.buttons.grab(this.up);this.buttons.grab(this.down);this.element.grab(this.buttons);this.setValue(value);},getPrecision:function(){return Math.pow(10,this.options.precision+1)/10;},setValue:function(value){if(this.options.limit){if(this.options.limit.low&&value<=this.options.limit.low){value=this.options.limit.low;this.down.setStyle('opacity','0.5');}else if(this.options.limit.high&&value>=this.options.limit.high){value=this.options.limit.high;this.up.setStyle('opacity','0.5');}else{this.up.setStyle('opacity','1');this.down.setStyle('opacity','1');};};this.value=new Number(value);this.input.set('value',this.value.toFixed(this.options.precision));this.settingValue=true;this.input.fireEvent('change');},changeValue:function(change){value=this.value+(change/this.getPrecision());this.setValue(value);},acceleratingChange:function(change){if(this.stop)return;this.changeValue(change);if(this.interval>100)this.interval-=100 -else if(this.interval>10)this.interval-=10 -this.acceleratingChange.delay(this.interval,this,change);},onMouseDown:function(e){this.value=new Number(this.input.value);document.addEvent('mouseup',this.bound.onMouseUp);if(e.target.hasClass('moouiSpinnerUp'))change=this.options.step;else change=this.options.step*-1;this.interval=600;this.stop=false;this.acceleratingChange(change);},onMouseUp:function(e){this.stop=true;document.removeEvent('mouseup',this.bound.onMouseUp);},onKeyDown:function(e){if(e.key=='up'||e.key=='down'){if(this.keyDown)return;this.value=new Number(this.input.value);change=(e.key=='up')?this.options.step:this.options.step*-1;this.input.addEvent('keyup',this.bound.onKeyUp);this.interval=600;this.stop=false;this.keyDown=true;this.acceleratingChange(change);}else if($A(['left','right','backspace']).contains(e.key)){return;}else{e.key=(e.code==190)?'.':e.key;pattern=/[0-9]/;if(!this.input.value.match(/\./)&&this.options.precision>0){pattern=/[0-9\.]/;};if(!e.key.match(pattern)){e.stop();return;};};},onKeyUp:function(e){this.stop=true;this.keyDown=false;this.input.removeEvent('keyup',this.bound.onKeyUp);},onMouseWheel:function(e){this.changeValue(this.options.step*e.wheel);},onChange:function(e){if(this.settingValue){this.settingValue=false;return;};this.setValue(new Number(this.input.value));}});Widgets.SplitPane=new Class({Extends:Widgets.Base,options:{direction:'horizontal',name:null,splitSize:6,pane1:{},pane2:{}},initialize:function(element,pane1,pane2,options){this.parent(element,options);this.bound={onResize:this.onResize.bindWithEvent(this),onMouseDown:this.onMouseDown.bindWithEvent(this),onMouseMove:this.onMouseMove.bindWithEvent(this),onMouseUp:this.onMouseUp.bindWithEvent(this)};this.horizontal=(this.options.direction=='horizontal')?true:false;this.pane1=$W(pane1);this.pane2=$W(pane2);if(this.options.expand)this.expand();this.initPane(this.pane1,this.options.pane1);this.initPane(this.pane2,this.options.pane2);this.initSplitter();this.calculatePositions();this.setPosition(this.pane1);this.setPosition(this.splitter);this.setPosition(this.pane2);this.splitter.addEvent('mousedown',this.bound.onMouseDown);this.addEvent('resize',this.bound.onResize);},initSplitter:function(){this.splitter=new Element('div').addClass('moouiSplitter');this.splitter.inject(this.pane1,'after');this.splitter.paneinfo={};if(this.horizontal){this.splitter.addClass('moouiSplitterVertical');}else{this.splitter.addClass('moouiSplitterHorizontal');};this.splitter.grab(new Element('div'));this.splitter.grab(new Element('div'));this.splitter.grab(new Element('div'));},onMouseDown:function(e){document.addEvent('mouseup',this.bound.onMouseUp);document.addEvent('mousemove',this.bound.onMouseMove);this.mouseStart={x:e.client.x,y:e.client.y};this.paneInfo={one:{startWidth:this.pane1.paneinfo.width,startHeight:this.pane1.paneinfo.height},two:{startWidth:this.pane2.paneinfo.width,startHeight:this.pane2.paneinfo.height}};},onMouseMove:function(e){if(this.horizontal){diff=e.client.x-this.mouseStart.x;p1width=this.paneInfo.one.startWidth+diff;p2width=this.paneInfo.two.startWidth-diff;if((this.pane1.paneinfo.min+this.pane1.element.modifiers.x)>p1width){this.pane1.paneinfo.width=this.pane1.paneinfo.min;this.pane2.paneinfo.width=this.paneInfo.two.startWidth+(this.paneInfo.one.startWidth-this.pane1.paneinfo.min);}else if((this.pane2.paneinfo.min+this.pane2.element.modifiers.x)>p2width){this.pane2.paneinfo.width=this.pane2.paneinfo.min;this.pane1.paneinfo.width=this.paneInfo.one.startWidth+(this.paneInfo.two.startWidth-this.pane2.paneinfo.min);}else{this.pane1.paneinfo.width=p1width;this.pane2.paneinfo.width=p2width;};}else{diff=e.client.y-this.mouseStart.y;p1height=this.paneInfo.one.startHeight+diff;p2height=this.paneInfo.two.startHeight-diff;if((this.pane1.paneinfo.min+this.pane1.element.modifiers.y)>p1height){this.pane1.paneinfo.height=this.pane1.paneinfo.min;this.pane2.paneinfo.height=this.paneInfo.two.startHeight+(this.paneInfo.one.startHeight-this.pane1.paneinfo.min);}else if((this.pane2.paneinfo.min+this.pane2.element.modifiers.y)>p2height){this.pane2.paneinfo.height=this.pane2.paneinfo.min;this.pane1.paneinfo.height=this.paneInfo.one.startHeight+(this.paneInfo.two.startHeight-this.pane2.paneinfo.min);}else{this.pane1.paneinfo.height=p1height;this.pane2.paneinfo.height=p2height;};};this.setPosition(this.pane1);this.setPosition(this.pane2);},onMouseUp:function(e){document.removeEvent('mouseup',this.bound.onMouseUp);document.removeEvent('mousemove',this.bound.onMouseMove);},initPane:function(pane,options){pane.addClass('moouiPane');pane.paneinfo={} -if(options){pane.paneinfo.min=(options.min)?options.min:0;pane.paneinfo.expand=(options.expand)?options.expand:false;};},calculatePositions:function(resized){if(resized){if(this.horizontal){this.calculateResize(resized,'width','height','x','y');}else{this.calculateResize(resized,'height','width','y','x');}}else{if(this.horizontal){this.calculateInitial('width','height','x','y');}else{this.calculateInitial('height','width','y','x');}}},calculateInitial:function(dm,ds,pm,ps){var size=this.getInnerSize();this.pane1.getSizeModifiers();this.pane2.getSizeModifiers();this.splitter.getSizeModifiers();if(this.pane1.paneinfo.expand){this.pane2.paneinfo[dm]=this.pane2.paneinfo.min;this.pane1.paneinfo[dm]=size[pm]-this.pane2.paneinfo.min-this.options.splitSize;this.pane1.paneinfo[dm]-=this.pane1.element.modifiers[pm]+this.pane2.element.modifiers[pm];}else{this.pane1.paneinfo[dm]=this.pane1.paneinfo.min;this.pane2.paneinfo[dm]=size[pm]-this.pane1.paneinfo.min-this.options.splitSize;this.pane2.paneinfo[dm]-=this.pane2.element.modifiers[pm]+this.pane1.element.modifiers[pm];} -this.pane1.paneinfo[ds]=this.pane2.paneinfo[ds]=size[ps];this.pane1.paneinfo[ds]-=this.pane1.element.modifiers[ps];this.pane2.paneinfo[ds]-=this.pane2.element.modifiers[ps];this.splitter.paneinfo[ds]=size[ps];this.splitter.paneinfo[dm]=this.options.splitSize;},calculateResize:function(resized,dm,ds,pm,ps){size=this.getInnerSize();this.pane1.getSizeModifiers();this.pane2.getSizeModifiers();this.splitter.getSizeModifiers();if(resized[dm]&&resized[dm]!=resized[('old-'+dm).camelCase()]){if(this.pane1.paneinfo.expand){this.pane1.paneinfo[dm]=size[pm]-this.pane2.paneinfo[dm]-this.options.splitSize;this.pane1.paneinfo[dm]-=this.pane1.element.modifiers[pm]+this.pane2.element.modifiers[pm];}else{this.pane2.paneinfo[dm]=size[pm]-this.pane1.paneinfo[dm]-this.options.splitSize;this.pane2.paneinfo[dm]-=this.pane2.element.modifiers[pm]+this.pane1.element.modifiers[pm];}};if(resized[ds]&&resized[ds]!=resized[('old-'+ds).camelCase()]){this.pane1.paneinfo[ds]=this.pane2.paneinfo[ds]=size[ps];this.splitter.paneinfo[ds]=size[ps];this.splitter.paneinfo[ds]-=this.splitter.modifiers[ps];this.pane1.paneinfo[ds]-=this.pane1.element.modifiers[ps];this.pane2.paneinfo[ds]-=this.pane2.element.modifiers[ps];};},setPosition:function(object){if(object.hasClass('moouiSplitter')){sets=object.setStyles.bind(object);}else{sets=object.sets.bind(object);};sets({width:object.paneinfo.width,height:object.paneinfo.height});},onResize:function(event){this.calculatePositions(event) -this.setPosition(this.pane1);this.setPosition(this.splitter);this.setPosition(this.pane2);}}) -Widgets.Tabs=new Class({Extends:Widgets.Base,initialize:function(element){this.parent(element);this.bound={onResize:this.onResize.bindWithEvent(this)};this.pages=[];this.currentPage=-1;this.tabsList=new Element('ul').inject(this.element);this.element.addClass('moouiTabs');this.pagesDiv=new Element('div').inject(this.element);this.pagesDiv.addClass('moouiTabPages');if(this.options.expand)this.expand();},addPage:function(page){this.pages.include(page) -var tab=new Element('li') -tab.set('text',page.name) -tab.addEvent('click',function(e){this.select(pageIndex)}.bindWithEvent(this)) -page.tab=tab -this.tabsList.grab(tab) -this.pagesDiv.grab(page.element.addClass('moouiTabPage')) -var pageIndex=this.pages.indexOf(page) -if(this.currentPage<0){this.currentPage=pageIndex -this.select(pageIndex)}},select:function(id){this.pages[this.currentPage].removeClass('moouiTabPageActive') -this.pages[this.currentPage].tab.removeClass('moouiTabActive') -this.pages[id].addClass('moouiTabPageActive') -this.pages[id].tab.addClass('moouiTabActive') -this.currentPage=id -this.fireEvent('pageChanged')},onResize:function(){this._pages.each(function(page){page.resize(this.width,this.height-45)},this)}});Widgets.TabPage=new Class({Extends:Widgets.Base,options:{element:null,url:null},initialize:function(name,options){this.name=name -var element=null -if(options&&options.element)element=options.element -else element=new Element('div') -this.parent(element,options) -if(this.options.url){new Request.HTML({url:this.options.url,update:element,onSuccess:function(e){this.fireEvent('loaded')}.bindWithEvent(this)}).get()}}});Widgets.VBox=new Class({Extends:Widgets.Base,initialize:function(element,options){this.parent(element,options);this.boxes=[];if(this.options.expand)this.expand();},addBox:function(box,options){box=$W(box);box.boxInfo=(options)?options:{fixed:false};this.boxes.include(box);this.element.grab(box);},calculatePositions:function(){if(this.options.expand)this.expand();var size=this.getInnerSize();var height=size.y,resizable=0;this.boxes.each(function(box){box.getSizeModifiers();if(!box.boxInfo.fixed)resizable++;else height-=box.height+box.element.modifiers.y;},this);var boxHeight=height/resizable,remainder=height%resizable -this.boxes.each(function(box){var boxInfo={};if(!box.boxInfo.fixed){var setHeight=boxHeight-box.element.modifiers.y;if(remainder>0){setHeight-=1;remainder--};boxInfo.height=setHeight;}else{boxInfo.height=box.height;} -boxInfo.width=size.x-box.element.modifiers.x;box.sets({height:boxInfo.height,width:boxInfo.width});},this);},refreshChildren:function(){this.boxes.each(function(box){box.refresh();box.setStyle('position','relative');});}}) -Widgets.Window=new Class({Extends:Widgets.Base,initialize:function(options){var element=new Element('div');this.parent(element,options);this.addClass('moouiWindow');this.sets({width:this.options.width,height:this.options.height});this.element.setStyle('opacity',0);this.titleBar=new Element('div').addClass('moouiWindowTitlebar');this.element.grab(this.titleBar);this.title=new Element('h3').addClass('moouiWindowTitle');this.title.set('text',this.options.title);this.titleBar.grab(this.title);this.drag=new Drag(this.element,{handle:this.titleBar});this.close=new Element('div').addClass('moouiWindowClose');this.close.inject(this.titleBar);this.close.addEvent('click',function(e){this.hide();}.bindWithEvent(this));this.content=new Element('div').addClass('moouiWindowContent');this.content.inject(this.element);if(this.options.url){new Request.HTML({url:this.options.url,update:this.content,onSuccess:function(e){this.fireEvent('loaded');}.bindWithEvent(this)}).get();}},show:function(){this.fireEvent('beforeShow');var size=document.body.getInnerSize();var left=(size.x-this.options.width)/2,top=(size.y-this.options.height)/2;this.sets({left:left,top:top});document.body.grab(this.element);this.element.setStyle('opacity',1);this.fireEvent('show');},hide:function(){var tween=this.element.get('tween');tween.addEvent('complete',function(e){this.element.dispose();}.bind(this));this.element.fade(0);}}) -Widgets.DataGridCell=new Class({Implements:[Events,Options],options:{name:'',type:'text',width:0},initialize:function(options){this.setOptions(options) -this.element=new Element('td')},set:function(value){this.value=value -var text=value,set_text=true -switch(this.options.type){case'bytes':text=value.toBytes() -break;case'time':text=value.toTime() -break;case'date':this.value=new Date(value) -text=this.value.format('ddd mmm dd yyyy') -break;case'speed':text=value.toSpeed() -break;case'icon':text=value.text -this.element.setStyles({'background-repeat':'no-repeat','background-position':'2px','background-image':'url('+value.icon+')','padding-left':20}) -break;case'image':if(!this.image){this.image=new Element('img') -this.image.inject(this.element)} -this.image.src=value -set_text=false -break;case'progress':if(!this.progress){this.progress=new Widgets.ProgressBar() -this.progress.sets({'width':this.options.width,'height':14}) -this.progress.element.inject(this.element)} -this.progress.update(value.text,value.percent) -set_text=false -break;} -if(set_text){this.element.set('text',text)} -this.fireEvent('changed',{cell:this})}}) -Widgets.DataGridColumn=new Class({Implements:[Events,Options],options:{name:'',type:'string',text:'',width:50},initialize:function(options){this.setOptions(options) -this.order=1},setText:function(text){this.options.text=text -this.fireEvent('textChanged',text)},get_sorter:function(index){switch(this.options.type){case'number':return new Sorters.Number(index,this.order) -case'progress':return new Sorters.Progress(index,this.order) -default:return new Sorters.Simple(index,this.order)}}}) -Widgets.DataGridRow=new Class({Implements:[Events],initialize:function(id,columns){this.id=id -this.columns=columns -this.element=new Element('tr') -this.element.store('rowid',this.id) -this.cells=[] -this.selected=false -this.columns.each(function(col){var cell=new Widgets.DataGridCell({name:col.options.name,type:col.options.type,width:col.options.width}) -cell.element.inject(this.element) -cell.addEvent('changed',this.oncellchanged.bind(this)) -this.cells.include(cell)},this) -this.element.addEvent('contextmenu',this.oncontextmenu.bind(this)) -this.element.addEvent('click',this.onclick.bind(this))},update:function(row){row=new Hash(row) -row.getKeys().each(function(item){if(item!='data'||item!='id'){this[item]=row[item]}},this) -this.cells.each(function(cell){cell.set(row.data[cell.options.name])},this) -return this},oncellchanged:function(e){e.row=this -this.fireEvent('changed',e)},oncontextmenu:function(e){e.row=this -this.fireEvent('menu',e)},onclick:function(e){e.row=this -this.fireEvent('click',e)}}) -Widgets.DataGrid=new Class({Implements:[Options,Events],Extends:Widgets.Base,options:{columns:[],element:null},initialize:function(element,options){if(!element)element=this.createElement -this.parent(element,options) -this.bound={onResize:this.onResize.bindWithEvent(this),onRowMenu:this.onRowMenu.bindWithEvent(this),onRowClick:this.onRowClick.bindWithEvent(this)} -this.columns=[] -this.options.columns.each(function(column_info){var column=new Widgets.DataGridColumn(column_info) -column.addEvent('textChanged',function(e){var index=this.columns.indexOf(column) -this.header.getElements('th')[index].set('text',e)}.bindWithEvent(this)) -this.columns.include(column)},this) -this.rows=[] -this.displayRows=[] -this.selectedIndex=-1 -this.filterer=false -this.sorted_by=0 -this.columns[0].order=-1 -if($chk(this.element)){this.scanElement()}else{this.createElement} -this.element.setStyle('MozUserSelect','none');this.resizeColumns();this.addEvent('resize',this.bound.onResize);},createElement:function(){this.element=new Element('div') -this.table=new Element('table').inject(this.element) -this.header=new Element('thead').inject(this.table).grab(new Element('tr')) -this.body=new Element('tbody').inject(this.table) -this.options.columns.each(function(column){new Element('th',{'class':column.name,'text':column.text})},this);},scanElement:function(){this.element.addClass('moouiDataGrid') -this.table=this.element.getElement('table') -if(!this.table)this.table=new Element('table').inject(this.element) -this.header=this.table.getElement('thead') -if(!this.header)this.header=new Element('thead').inject(this.table) -this.body=this.table.getElement('tbody') -if(!this.body)this.body=new Element('tbody').inject(this.table) -this.header.empty();var headerRow=new Element('tr');this.header.grab(headerRow) -this.columns.each(function(column,index){new Element('th').addEvent('click',function(e){this.sort(column,index) -this.render()}.bindWithEvent(this)).set('text',column.options.text).inject(headerRow)},this)},addRow:function(row_info,noRender){var row=new Widgets.DataGridRow(row_info.id,this.columns) -row.store=row_info.store -this.rows.include(row) -row.update(row_info) -row.addEvent('menu',this.bound.onRowMenu);row.addEvent('click',this.bound.onRowClick);if(!noRender)this.render();},onRowMenu:function(e){if(!this.selectedRow){this.selectRow(e.row);};this.fireEvent('rowMenu',e);},onRowClick:function(e){e.row.index=this.displayRows.indexOf(this.getById(e.row.id));if(e.shift){this.deselectRows();this.selectRows(e.row.index);}else if(e.control){if(e.row.selected){this.deselectRow(e.row)} -else{this.selectRow(e.row)};}else{this.deselectRows();this.selectRow(e.row);} -this.fireEvent('rowClick',e);},deselectRow:function(row){if(!$chk(row)){return} -row.selected=false -row.element.removeClass('selected') -if(row==this.selectedRow){this.selectedRow=null -this.fireEvent('selectedChanged')}},deselectRows:function(){this.selected=-1 -this.rows.each(function(row){row.selected=false -row.element.removeClass('selected')})},filter:function(){this.filterer=(this.filterer)?this.filterer:$lambda(true);this.displayRows.empty();this.rows.each(function(row){if(this.filterer(row)){this.displayRows.include(row)}}.bind(this));},getById:function(id){var row=null -this.rows.each(function(r){if(r.id==id){row=r}}) -return row},getSelected:function(){selected=[] -this.rows.each(function(row){if(row.selected){selected.include(row)}}) -return selected},has:function(id){if(this.getById(id)){return true;}else{return false;}},remove:function(id){this.getById(id)},render:function(){this.filter();this.resort();var rows=[],rowIds=[] -this.rows.each(function(row){if(this.displayRows.contains(row)){rows.include(row.element) -rowIds.include(row.id)}},this) -this.body.adopt(rows) -this.body.getChildren().each(function(row){var id=row.retrieve('rowid') -if(!id){row.destroy()}else if(!rowIds.contains(id)){row.dispose()}},this) -var selected=this.body.getElements('tr.selected') -if(selected){this.selected=$A(this.body.rows).indexOf(selected)}},resizeColumns:function(){var totalWidth=this.options.columns.sum('width') -this.table.setStyle('width',totalWidth) -var cols=this.header.getElements('th') -cols.each(function(col,index){if(this.options.columns[index]){col.setStyle('width',this.options.columns[index].width)}},this)},onResize:function(){var width=this.width -var columnWidth=this.options.columns.sum('width') -if(columnWidth>width)this.table.setStyle('width',columnWidth) -else this.table.setStyle('width',width) -var cols=this.header.getElements('th') -cols.each(function(col,index){var colWidth=this.columns[index].options.width;if(index==cols.length-1&&width>colWidth) -col.setStyle('width',width) -else{col.setStyle('width',colWidth) -width-=colWidth}},this)},selectRows:function(index){var selectedIndex=this.displayRows.indexOf(this.selectedRow) -if(selectedIndex>index){for(var i=index;i<=selectedIndex;i++){this.displayRows[i].selected=true -this.displayRows[i].element.addClass('selected')}}else if(selectedIndex99?Math.round(N/10):N),t:Q<12?"a":"p",tt:Q<12?"am":"pm",T:Q<12?"A":"P",TT:Q<12?"AM":"PM",Z:P?"UTC":(String(this).match(B)||[""]).pop().replace(D,""),o:(F>0?"-":"+")+C(Math.floor(Math.abs(F)/60)*100+Math.abs(F)%60,4),S:["th","st","nd","rd"][K%10>3?0:(K%100-K%10!=10)*K%10]};return T.replace(A,function(H){return H in G?G[H]:H.slice(1,H.length-1)})}})})();Array.implement({sum:function(A){var B=0;this.each(function(C){var D=C;if(!$defined(D)){return}if($defined(A)){D=C[A]}if($type(D)=="number"){B+=D}},this);return B}});Element.implement({getInnerSize:function(){this.getPadding();if((/^(?:body|html)$/i).test(this.tagName)){return this.getWindow().getSize()}return{x:this.clientWidth-this.padding.x,y:this.clientHeight-this.padding.y}},getInnerHeight:function(){return this.getInnerSize().y},getInnerWidth:function(){return this.getInnerSize().x},getSizeModifiers:function(D){if(!this.modifiers){var A=this.getBorder(D);var B=this.getMargin(D);var C=this.getPadding(D);this.modifiers={left:A.left+B.left+C.left,right:A.right+B.right+C.right,top:A.top+B.top+C.top,bottom:A.bottom+B.bottom+C.bottom,x:A.x+B.x+C.x,y:A.y+B.y+C.y}}},getMargin:function(B){if(!this.margin||B){var A=this.getStyle("margin").split(" ");this.margin={left:A[1].toInt(),right:A[3].toInt(),top:A[0].toInt(),bottom:A[2].toInt(),x:A[0].toInt()+A[2].toInt(),y:A[1].toInt()+A[3].toInt()}}return this.margin},getPadding:function(B){if(!this.padding||B){var A=this.getStyle("padding").split(" ");this.padding={left:A[1].toInt(),right:A[3].toInt(),top:A[0].toInt(),bottom:A[2].toInt(),x:A[0].toInt()+A[2].toInt(),y:A[1].toInt()+A[3].toInt()}}return this.padding},getBorder:function(B){if(!this.border||B){var A=this.getStyle("border-width").split(" ");this.border={left:A[1].toInt(),right:A[3].toInt(),top:A[0].toInt(),bottom:A[2].toInt(),x:A[0].toInt()+A[2].toInt(),y:A[1].toInt()+A[3].toInt()}}return this.border}});Number.implement({toBytes:function(){var A=this;if(A<1024){return A.toFixed(1)+"B"}else{A=A/1024}if(A<1024){return A.toFixed(1)+"KiB"}else{A=A/1024}if(A<1024){return A.toFixed(1)+"MiB"}else{A=A/1024}return A.toFixed(1)+"GiB"},toSpeed:function(){var A=this;if(A<1024){return A.toFixed(1)+"b/s"}else{A=A/1024}if(A<1024){return A.toFixed(1)+"KiB/s"}else{A=A/1024}return A.toFixed(2)+"MiB/s"},toTime:function(){var C=this;if(C==0){return"∞"}if(C<60){return C+"s"}else{C=C/60}if(C<60){var B=Math.floor(C);var D=Math.round(60*(C-B));if(D>0){return B+"m "+D+"s"}else{return B+"m"}}else{C=C/60}if(C<24){var A=Math.floor(C);var B=Math.round(60*(C-A));if(B>0){return A+"h "+B+"m"}else{return A+"h"}}else{C=C/24}var E=Math.floor(C);var A=Math.round(24*(C-E));if(A>0){return E+"d "+A+"h"}else{return E+"d"}}});String.implement({strip:function(){var A=this.replace(/^\s*/,"");A.replace(/\s*$/,"");return A}});Sorters={Simple:new Class({initialize:function(B,A){this.column=B;this.order=A},sorter:function(){return function(C,B){var D,A;D=C.cells[this.column].value;A=B.cells[this.column].value;return this.sort(D,A)}.bind(this)},sort:function(B,A){if(B>A){return 1*this.order}if(B0){this.element.setStyle(C,B)}if(!D){this.fireEvent("resize",A)}}else{this[C]=B;this.element.setStyle(C,B)}},sets:function(C){C=new Hash(C);var B=false;var A={};C.each(function(E,D){if(D=="height"||D=="width"){A[("old-"+D).camelCase()]=this[D];A[D]=E;B=true}this.set(D,E,true)},this);if(B){this.fireEvent("resize",A)}},toElement:function(){return this.element}});$W=function(A){if(!A.isMoouiWidget){if(A.retrieve){A=A.retrieve("moouiWidget");return(A)?A:new Widgets.Base(A)}else{return new Widgets.Base(A)}}else{return A}};$$W=function(A){if(!A.isMoouiWidget){if(A.retrieve){A=A.retrieve("moouiWidget");return(A)?A:null}else{return null}}else{return wrap}};Widgets.PopupMenu=new Class({Extends:Widgets.WidgetBase,Implements:Events,initialize:function(){this.items=[];this.noClose=false;this.build()},add:function(B){if($type(B)=="array"){for(var A=0;A=A.y){y=A.y-B.y-(A.y-y)}this.element.setStyles({left:x,top:y-2});this.element.addEvent("mouseleave",function(D){this.hide()}.bind(this))},fixSize:function(A){var B=0;A.getElements("li").each(function(D){var E=D.getElement("span");var C=E.getSize().x;if(C>B){B=C}});A.setStyle("width",B+32)},fixLeft:function(A){var B=0;A.getElements("li").each(function(D){var C=D.getSize().x;if(C>B){B=C}});A.setStyle("width",B+2);A.getElements("li ul").each(function(C){C.setStyle("left",B-20)})},showPos:function(A,B){}});Widgets.ProgressBar=new Class({Extends:Widgets.Base,initialize:function(){this.parent(new Element("div"));this.bound={onResize:this.onResize.bindWithEvent(this)};this.element.addClass("moouiProgressBar");this.bar=new Element("div").inject(this.element);this.textSpan=new Element("span").inject(this.bar);this.sets({width:200,height:20});this.addEvent("resize",this.bound.onResize)},onResize:function(){this.textSpan.setStyles({width:this.width,height:this.height});this.update(this.text,this.percent)},update:function(B,A){if(this.text!=B){this.text=B;this.textSpan.set("text",B)}if(this.percent!=A){this.percent=A;this.bar.setStyles({width:Math.floor(this.width/100*A),height:this.height})}}});Widgets.Spinner=new Class({Extends:Widgets.Base,options:{precision:0,step:1,limit:{high:null,low:null}},initialize:function(A,B){this.parent(new Element("div"),B);this.bound={onMouseDown:this.onMouseDown.bindWithEvent(this),onMouseUp:this.onMouseUp.bindWithEvent(this),onMouseWheel:this.onMouseWheel.bindWithEvent(this),onKeyDown:this.onKeyDown.bindWithEvent(this),onKeyUp:this.onKeyUp.bindWithEvent(this),onChange:this.onChange.bindWithEvent(this)};value=0;this.keyDown=false;if(A){this.element.replaces(A);value=new Number(A.value)}this.input=(A)?A:new Element("input");this.input.store("moouiWidget",this);this.element.grab(this.input);this.element.addClass("moouiSpinner");this.element.addEvent("mousewheel",this.bound.onMouseWheel);this.input.addEvent("keydown",this.bound.onKeyDown);this.input.addEvent("change",this.bound.onChange);this.buttons=new Element("div").addClass("moouiSpinnerButtons");this.up=new Element("div").addClass("moouiSpinnerUp");this.down=new Element("div").addClass("moouiSpinnerDown");this.up.addEvent("mousedown",this.bound.onMouseDown);this.down.addEvent("mousedown",this.bound.onMouseDown);this.buttons.grab(this.up);this.buttons.grab(this.down);this.element.grab(this.buttons);this.setValue(value)},getPrecision:function(){return Math.pow(10,this.options.precision+1)/10},setValue:function(A){if(this.options.limit){if(this.options.limit.low&&A<=this.options.limit.low){A=this.options.limit.low;this.down.setStyle("opacity","0.5")}else{if(this.options.limit.high&&A>=this.options.limit.high){A=this.options.limit.high;this.up.setStyle("opacity","0.5")}else{this.up.setStyle("opacity","1");this.down.setStyle("opacity","1")}}}this.value=new Number(A);this.input.set("value",this.value.toFixed(this.options.precision));this.settingValue=true;this.input.fireEvent("change")},changeValue:function(A){value=this.value+(A/this.getPrecision());this.setValue(value)},acceleratingChange:function(A){if(this.stop){return}this.changeValue(A);if(this.interval>100){this.interval-=100}else{if(this.interval>10){this.interval-=10}}this.acceleratingChange.delay(this.interval,this,A)},onMouseDown:function(A){this.value=new Number(this.input.value);document.addEvent("mouseup",this.bound.onMouseUp);if(A.target.hasClass("moouiSpinnerUp")){change=this.options.step}else{change=this.options.step*-1}this.interval=600;this.stop=false;this.acceleratingChange(change)},onMouseUp:function(A){this.stop=true;document.removeEvent("mouseup",this.bound.onMouseUp)},onKeyDown:function(A){if(A.key=="up"||A.key=="down"){if(this.keyDown){return}this.value=new Number(this.input.value);change=(A.key=="up")?this.options.step:this.options.step*-1;this.input.addEvent("keyup",this.bound.onKeyUp);this.interval=600;this.stop=false;this.keyDown=true;this.acceleratingChange(change)}else{if($A(["left","right","backspace"]).contains(A.key)){return}else{A.key=(A.code==190)?".":A.key;pattern=/[0-9]/;if(!this.input.value.match(/\./)&&this.options.precision>0){pattern=/[0-9\.]/}if(!A.key.match(pattern)){A.stop();return}}}},onKeyUp:function(A){this.stop=true;this.keyDown=false;this.input.removeEvent("keyup",this.bound.onKeyUp)},onMouseWheel:function(A){this.changeValue(this.options.step*A.wheel)},onChange:function(A){if(this.settingValue){this.settingValue=false;return}this.setValue(new Number(this.input.value))}});Widgets.SplitPane=new Class({Extends:Widgets.Base,options:{direction:"horizontal",name:null,splitSize:6,pane1:{},pane2:{}},initialize:function(C,D,B,A){this.parent(C,A);this.bound={onResize:this.onResize.bindWithEvent(this),onMouseDown:this.onMouseDown.bindWithEvent(this),onMouseMove:this.onMouseMove.bindWithEvent(this),onMouseUp:this.onMouseUp.bindWithEvent(this)};this.horizontal=(this.options.direction=="horizontal")?true:false;this.pane1=$W(D);this.pane2=$W(B);if(this.options.expand){this.expand()}this.initPane(this.pane1,this.options.pane1);this.initPane(this.pane2,this.options.pane2);this.initSplitter();this.calculatePositions();this.setPosition(this.pane1);this.setPosition(this.splitter);this.setPosition(this.pane2);this.splitter.addEvent("mousedown",this.bound.onMouseDown);this.addEvent("resize",this.bound.onResize)},initSplitter:function(){this.splitter=new Element("div").addClass("moouiSplitter");this.splitter.inject(this.pane1,"after");this.splitter.paneinfo={};if(this.horizontal){this.splitter.addClass("moouiSplitterVertical")}else{this.splitter.addClass("moouiSplitterHorizontal")}this.splitter.grab(new Element("div"));this.splitter.grab(new Element("div"));this.splitter.grab(new Element("div"))},onMouseDown:function(A){document.addEvent("mouseup",this.bound.onMouseUp);document.addEvent("mousemove",this.bound.onMouseMove);this.mouseStart={x:A.client.x,y:A.client.y};this.paneInfo={one:{startWidth:this.pane1.paneinfo.width,startHeight:this.pane1.paneinfo.height},two:{startWidth:this.pane2.paneinfo.width,startHeight:this.pane2.paneinfo.height}}},onMouseMove:function(A){if(this.horizontal){diff=A.client.x-this.mouseStart.x;p1width=this.paneInfo.one.startWidth+diff;p2width=this.paneInfo.two.startWidth-diff;if((this.pane1.paneinfo.min+this.pane1.element.modifiers.x)>p1width){this.pane1.paneinfo.width=this.pane1.paneinfo.min;this.pane2.paneinfo.width=this.paneInfo.two.startWidth+(this.paneInfo.one.startWidth-this.pane1.paneinfo.min)}else{if((this.pane2.paneinfo.min+this.pane2.element.modifiers.x)>p2width){this.pane2.paneinfo.width=this.pane2.paneinfo.min;this.pane1.paneinfo.width=this.paneInfo.one.startWidth+(this.paneInfo.two.startWidth-this.pane2.paneinfo.min)}else{this.pane1.paneinfo.width=p1width;this.pane2.paneinfo.width=p2width}}}else{diff=A.client.y-this.mouseStart.y;p1height=this.paneInfo.one.startHeight+diff;p2height=this.paneInfo.two.startHeight-diff;if((this.pane1.paneinfo.min+this.pane1.element.modifiers.y)>p1height){this.pane1.paneinfo.height=this.pane1.paneinfo.min;this.pane2.paneinfo.height=this.paneInfo.two.startHeight+(this.paneInfo.one.startHeight-this.pane1.paneinfo.min)}else{if((this.pane2.paneinfo.min+this.pane2.element.modifiers.y)>p2height){this.pane2.paneinfo.height=this.pane2.paneinfo.min;this.pane1.paneinfo.height=this.paneInfo.one.startHeight+(this.paneInfo.two.startHeight-this.pane2.paneinfo.min)}else{this.pane1.paneinfo.height=p1height;this.pane2.paneinfo.height=p2height}}}this.setPosition(this.pane1);this.setPosition(this.pane2)},onMouseUp:function(A){document.removeEvent("mouseup",this.bound.onMouseUp);document.removeEvent("mousemove",this.bound.onMouseMove)},initPane:function(B,A){B.addClass("moouiPane");B.paneinfo={};if(A){B.paneinfo.min=(A.min)?A.min:0;B.paneinfo.expand=(A.expand)?A.expand:false}},calculatePositions:function(A){if(A){if(this.horizontal){this.calculateResize(A,"width","height","x","y")}else{this.calculateResize(A,"height","width","y","x")}}else{if(this.horizontal){this.calculateInitial("width","height","x","y")}else{this.calculateInitial("height","width","y","x")}}},calculateInitial:function(A,D,C,E){var B=this.getInnerSize();this.pane1.getSizeModifiers();this.pane2.getSizeModifiers();this.splitter.getSizeModifiers();if(this.pane1.paneinfo.expand){this.pane2.paneinfo[A]=this.pane2.paneinfo.min;this.pane1.paneinfo[A]=B[C]-this.pane2.paneinfo.min-this.options.splitSize;this.pane1.paneinfo[A]-=this.pane1.element.modifiers[C]+this.pane2.element.modifiers[C]}else{this.pane1.paneinfo[A]=this.pane1.paneinfo.min;this.pane2.paneinfo[A]=B[C]-this.pane1.paneinfo.min-this.options.splitSize;this.pane2.paneinfo[A]-=this.pane2.element.modifiers[C]+this.pane1.element.modifiers[C]}this.pane1.paneinfo[D]=this.pane2.paneinfo[D]=B[E];this.pane1.paneinfo[D]-=this.pane1.element.modifiers[E];this.pane2.paneinfo[D]-=this.pane2.element.modifiers[E];this.splitter.paneinfo[D]=B[E];this.splitter.paneinfo[A]=this.options.splitSize},calculateResize:function(B,A,D,C,E){size=this.getInnerSize();this.pane1.getSizeModifiers();this.pane2.getSizeModifiers();this.splitter.getSizeModifiers();if(B[A]&&B[A]!=B[("old-"+A).camelCase()]){if(this.pane1.paneinfo.expand){this.pane1.paneinfo[A]=size[C]-this.pane2.paneinfo[A]-this.options.splitSize;this.pane1.paneinfo[A]-=this.pane1.element.modifiers[C]+this.pane2.element.modifiers[C]}else{this.pane2.paneinfo[A]=size[C]-this.pane1.paneinfo[A]-this.options.splitSize;this.pane2.paneinfo[A]-=this.pane2.element.modifiers[C]+this.pane1.element.modifiers[C]}}if(B[D]&&B[D]!=B[("old-"+D).camelCase()]){this.pane1.paneinfo[D]=this.pane2.paneinfo[D]=size[E];this.splitter.paneinfo[D]=size[E];this.splitter.paneinfo[D]-=this.splitter.modifiers[E];this.pane1.paneinfo[D]-=this.pane1.element.modifiers[E];this.pane2.paneinfo[D]-=this.pane2.element.modifiers[E]}},setPosition:function(A){if(A.hasClass("moouiSplitter")){sets=A.setStyles.bind(A)}else{sets=A.sets.bind(A)}sets({width:A.paneinfo.width,height:A.paneinfo.height})},onResize:function(A){this.calculatePositions(A);this.setPosition(this.pane1);this.setPosition(this.splitter);this.setPosition(this.pane2)}});Widgets.Tabs=new Class({Extends:Widgets.Base,initialize:function(A){this.parent(A);this.bound={onResize:this.onResize.bindWithEvent(this)};this.pages=[];this.currentPage=-1;this.tabsList=new Element("ul").inject(this.element);this.element.addClass("moouiTabs");this.pagesDiv=new Element("div").inject(this.element);this.pagesDiv.addClass("moouiTabPages");if(this.options.expand){this.expand()}},addPage:function(C){this.pages.include(C);var B=new Element("li");B.set("text",C.name);B.addEvent("click",function(D){this.select(A)}.bindWithEvent(this));C.tab=B;this.tabsList.grab(B);this.pagesDiv.grab(C.element.addClass("moouiTabPage"));var A=this.pages.indexOf(C);if(this.currentPage<0){this.currentPage=A;this.select(A)}},select:function(A){this.pages[this.currentPage].removeClass("moouiTabPageActive");this.pages[this.currentPage].tab.removeClass("moouiTabActive");this.pages[A].addClass("moouiTabPageActive");this.pages[A].tab.addClass("moouiTabActive");this.currentPage=A;this.fireEvent("pageChanged")},onResize:function(){this._pages.each(function(A){A.resize(this.width,this.height-45)},this)}});Widgets.TabPage=new Class({Extends:Widgets.Base,options:{element:null,url:null},initialize:function(B,A){this.name=B;var C=null;if(A&&A.element){C=A.element}else{C=new Element("div")}this.parent(C,A);if(this.options.url){new Request.HTML({url:this.options.url,update:C,onSuccess:function(D){this.fireEvent("loaded")}.bindWithEvent(this)}).get()}}});Widgets.VBox=new Class({Extends:Widgets.Base,initialize:function(B,A){this.parent(B,A);this.boxes=[];if(this.options.expand){this.expand()}},addBox:function(B,A){B=$W(B);B.boxInfo=(A)?A:{fixed:false};this.boxes.include(B);this.element.grab(B)},calculatePositions:function(){if(this.options.expand){this.expand()}var C=this.getInnerSize();var A=C.y,B=0;this.boxes.each(function(F){F.getSizeModifiers();if(!F.boxInfo.fixed){B++}else{A-=F.height+F.element.modifiers.y}},this);var E=A/B,D=A%B;this.boxes.each(function(H){var G={};if(!H.boxInfo.fixed){var F=E-H.element.modifiers.y;if(D>0){F-=1;D--}G.height=F}else{G.height=H.height}G.width=C.x-H.element.modifiers.x;H.sets({height:G.height,width:G.width})},this)},refreshChildren:function(){this.boxes.each(function(A){A.refresh();A.setStyle("position","relative")})}});Widgets.Window=new Class({Extends:Widgets.Base,initialize:function(A){var B=new Element("div");this.parent(B,A);this.addClass("moouiWindow");this.sets({width:this.options.width,height:this.options.height});this.element.setStyle("opacity",0);this.titleBar=new Element("div").addClass("moouiWindowTitlebar");this.element.grab(this.titleBar);this.title=new Element("h3").addClass("moouiWindowTitle");this.title.set("text",this.options.title);this.titleBar.grab(this.title);this.drag=new Drag(this.element,{handle:this.titleBar});this.close=new Element("div").addClass("moouiWindowClose");this.close.inject(this.titleBar);this.close.addEvent("click",function(C){this.hide()}.bindWithEvent(this));this.content=new Element("div").addClass("moouiWindowContent");this.content.inject(this.element);if(this.options.url){new Request.HTML({url:this.options.url,update:this.content,onSuccess:function(C){this.fireEvent("loaded")}.bindWithEvent(this)}).get()}},show:function(){this.fireEvent("beforeShow");var A=document.body.getInnerSize();var C=(A.x-this.options.width)/2,B=(A.y-this.options.height)/2;this.sets({left:C,top:B});document.body.grab(this.element);this.element.setStyle("opacity",1);this.fireEvent("show")},hide:function(){var A=this.element.get("tween");A.addEvent("complete",function(B){this.element.dispose()}.bind(this));this.element.fade(0)}});Widgets.DataGridCell=new Class({Implements:[Events,Options],options:{name:"",type:"text",width:0},initialize:function(A){this.setOptions(A);this.element=new Element("td")},set:function(B){this.value=B;var C=B,A=true;switch(this.options.type){case"bytes":C=B.toBytes();break;case"time":C=B.toTime();break;case"date":this.value=new Date(B);C=this.value.format("ddd mmm dd yyyy");break;case"speed":C=B.toSpeed();break;case"icon":C=B.text;this.element.setStyles({"background-repeat":"no-repeat","background-position":"2px","background-image":"url("+B.icon+")","padding-left":20});break;case"image":if(!this.image){this.image=new Element("img");this.image.inject(this.element)}this.image.src=B;A=false;break;case"progress":if(!this.progress){this.progress=new Widgets.ProgressBar();this.progress.sets({width:this.options.width,height:14});this.progress.element.inject(this.element)}this.progress.update(B.text,B.percent);A=false;break}if(A){this.element.set("text",C)}this.fireEvent("changed",{cell:this})}});Widgets.DataGridColumn=new Class({Implements:[Events,Options],options:{name:"",type:"string",text:"",width:50},initialize:function(A){this.setOptions(A);this.order=1},setText:function(A){this.options.text=A;this.fireEvent("textChanged",A)},get_sorter:function(A){switch(this.options.type){case"number":return new Sorters.Number(A,this.order);case"progress":return new Sorters.Progress(A,this.order);default:return new Sorters.Simple(A,this.order)}}});Widgets.DataGridRow=new Class({Implements:[Events],initialize:function(B,A){this.id=B;this.columns=A;this.element=new Element("tr");this.element.store("rowid",this.id);this.cells=[];this.selected=false;this.columns.each(function(D){var C=new Widgets.DataGridCell({name:D.options.name,type:D.options.type,width:D.options.width});C.element.inject(this.element);C.addEvent("changed",this.oncellchanged.bind(this));this.cells.include(C)},this);this.element.addEvent("contextmenu",this.oncontextmenu.bind(this));this.element.addEvent("click",this.onclick.bind(this))},update:function(A){A=new Hash(A);A.getKeys().each(function(B){if(B!="data"||B!="id"){this[B]=A[B]}},this);this.cells.each(function(B){B.set(A.data[B.options.name])},this);return this},oncellchanged:function(A){A.row=this;this.fireEvent("changed",A)},oncontextmenu:function(A){A.row=this;this.fireEvent("menu",A)},onclick:function(A){A.row=this;this.fireEvent("click",A)}});Widgets.DataGrid=new Class({Implements:[Options,Events],Extends:Widgets.Base,options:{columns:[],element:null},initialize:function(B,A){if(!B){B=this.createElement}this.parent(B,A);this.bound={onResize:this.onResize.bindWithEvent(this),onRowMenu:this.onRowMenu.bindWithEvent(this),onRowClick:this.onRowClick.bindWithEvent(this)};this.columns=[];this.options.columns.each(function(C){var D=new Widgets.DataGridColumn(C);D.addEvent("textChanged",function(F){var E=this.columns.indexOf(D);this.header.getElements("th")[E].set("text",F)}.bindWithEvent(this));this.columns.include(D)},this);this.rows=[];this.displayRows=[];this.selectedIndex=-1;this.filterer=false;this.sorted_by=0;this.columns[0].order=-1;if($chk(this.element)){this.scanElement()}else{this.createElement}this.element.setStyle("MozUserSelect","none");this.resizeColumns();this.addEvent("resize",this.bound.onResize)},createElement:function(){this.element=new Element("div");this.table=new Element("table").inject(this.element);this.header=new Element("thead").inject(this.table).grab(new Element("tr"));this.body=new Element("tbody").inject(this.table);this.options.columns.each(function(A){new Element("th",{"class":A.name,text:A.text})},this)},scanElement:function(){this.element.addClass("moouiDataGrid");this.table=this.element.getElement("table");if(!this.table){this.table=new Element("table").inject(this.element)}this.header=this.table.getElement("thead");if(!this.header){this.header=new Element("thead").inject(this.table)}this.body=this.table.getElement("tbody");if(!this.body){this.body=new Element("tbody").inject(this.table)}this.header.empty();var A=new Element("tr");this.header.grab(A);this.columns.each(function(C,B){new Element("th").addEvent("click",function(D){this.sort(C,B);this.render()}.bindWithEvent(this)).set("text",C.options.text).inject(A)},this)},addRow:function(B,A){var C=new Widgets.DataGridRow(B.id,this.columns);C.store=B.store;this.rows.include(C);C.update(B);C.addEvent("menu",this.bound.onRowMenu);C.addEvent("click",this.bound.onRowClick);if(!A){this.render()}},onRowMenu:function(A){if(!this.selectedRow){this.selectRow(A.row)}this.fireEvent("rowMenu",A)},onRowClick:function(A){A.row.index=this.displayRows.indexOf(this.getById(A.row.id));if(A.shift){this.deselectRows();this.selectRows(A.row.index)}else{if(A.control){if(A.row.selected){this.deselectRow(A.row)}else{this.selectRow(A.row)}}else{this.deselectRows();this.selectRow(A.row)}}this.fireEvent("rowClick",A)},deselectRow:function(A){if(!$chk(A)){return}A.selected=false;A.element.removeClass("selected");if(A==this.selectedRow){this.selectedRow=null;this.fireEvent("selectedChanged")}},deselectRows:function(){this.selected=-1;this.rows.each(function(A){A.selected=false;A.element.removeClass("selected")})},filter:function(){this.filterer=(this.filterer)?this.filterer:$lambda(true);this.displayRows.empty();this.rows.each(function(A){if(this.filterer(A)){this.displayRows.include(A)}}.bind(this))},getById:function(B){var A=null;this.rows.each(function(C){if(C.id==B){A=C}});return A},getSelected:function(){selected=[];this.rows.each(function(A){if(A.selected){selected.include(A)}});return selected},has:function(A){if(this.getById(A)){return true}else{return false}},remove:function(A){this.getById(A)},render:function(){this.filter();this.resort();var C=[],A=[];this.rows.each(function(D){if(this.displayRows.contains(D)){C.include(D.element);A.include(D.id)}},this);this.body.adopt(C);this.body.getChildren().each(function(D){var E=D.retrieve("rowid");if(!E){D.destroy()}else{if(!A.contains(E)){D.dispose()}}},this);var B=this.body.getElements("tr.selected");if(B){this.selected=$A(this.body.rows).indexOf(B)}},resizeColumns:function(){var A=this.options.columns.sum("width");this.table.setStyle("width",A);var B=this.header.getElements("th");B.each(function(D,C){if(this.options.columns[C]){D.setStyle("width",this.options.columns[C].width)}},this)},onResize:function(){var A=this.width;var B=this.options.columns.sum("width");if(B>A){this.table.setStyle("width",B)}else{this.table.setStyle("width",A)}var C=this.header.getElements("th");C.each(function(E,D){var F=this.columns[D].options.width;if(D==C.length-1&&A>F){E.setStyle("width",A)}else{E.setStyle("width",F);A-=F}},this)},selectRows:function(B){var A=this.displayRows.indexOf(this.selectedRow);if(A>B){for(var C=B;C<=A;C++){this.displayRows[C].selected=true;this.displayRows[C].element.addClass("selected")}}else{if(A