mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-27 11:45:44 +00:00
add a check to see if the ui is initialized before running an update
This commit is contained in:
parent
f2dc542aba
commit
a027010073
@ -44,18 +44,7 @@ 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(a<b)
|
||||
return-1*this.order
|
||||
return 0}})}
|
||||
Sorters.Number=new Class({Extends:Sorters.Simple,sort:function(a,b){return(a-b)*this.order;}})
|
||||
Sorters.Progress=new Class({Extends:Sorters.Simple,sort:function(a,b){return(a.percent-b.percent)*this.order;}})
|
||||
Widgets={version:0.1,authors:['Damien Churchill'],license:'GPLv3'};elementMethods=['addClass','hasClass','removeClass','toggleClass','getInnerSize','getTop','getLeft','getWidth','getHeight','getScrollTop','getScrollLeft','getScrollHeight','getScrollWidth','getSize','getScrollSize','getScroll','getScrolls','getOffsetParent','getOffsets','getPosition','getCoordinates','getInnerWidth','getInnerHeight','getStyle','getParent','getSizeModifiers','setStyle'];Widgets.Base=new Class({Implements:[Events,Options],options:{expand:false},initialize:function(element,options){this.setOptions(options);this.element=$(element);this.element.store('moouiWidget',this);this.isMoouiWidget=true;this.width=this.element.getStyle('width');this.height=this.element.getStyle('height');this.width=(this.width)?this.width.toInt():-1;this.height=(this.height)?this.height.toInt():-1;elementMethods.each(function(method){if(this.element[method]){this[method]=this.element[method].bind(this.element);};},this);},refresh:function(){this.element.removeProperty('style');this.width=this.element.getStyle('width');this.height=this.element.getStyle('height');this.width=(this.width)?this.width.toInt():-1;this.height=(this.height)?this.height.toInt():-1;this.getSizeModifiers(true);if(this.refreshChildren)this.refreshChildren();},expand:function(){var parent=this.getParent();var parentSize=this.getParent().getInnerSize();this.element.getSizeModifiers();parentSize.y-=this.element.modifiers.y;parentSize.x-=this.element.modifiers.x;this.sets({'width':parentSize.x,'height':parentSize.y});},set:function(property,value,noFire){if(property=='height'||property=='width'){var eventArgs={};eventArgs[property]=value;eventArgs[('old-'+property).camelCase()]=this[property];this[property]=value;if(value>0)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;}
|
||||
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(a<b)return-1*this.order;return 0;}})};Sorters.Number=new Class({Extends:Sorters.Simple,sort:function(a,b){return(a-b)*this.order;}});Sorters.Progress=new Class({Extends:Sorters.Simple,sort:function(a,b){return(a.percent-b.percent)*this.order;}});Widgets={version:0.1,authors:['Damien Churchill'],license:'GPLv3'};elementMethods=['addClass','hasClass','removeClass','toggleClass','getInnerSize','getTop','getLeft','getWidth','getHeight','getScrollTop','getScrollLeft','getScrollHeight','getScrollWidth','getSize','getScrollSize','getScroll','getScrolls','getOffsetParent','getOffsets','getPosition','getCoordinates','getInnerWidth','getInnerHeight','getStyle','getParent','getSizeModifiers','setStyle'];Widgets.Base=new Class({Implements:[Events,Options],options:{expand:false},initialize:function(element,options){this.setOptions(options);this.element=$(element);this.element.store('moouiWidget',this);this.isMoouiWidget=true;this.width=this.element.getStyle('width');this.height=this.element.getStyle('height');this.width=(this.width)?this.width.toInt():-1;this.height=(this.height)?this.height.toInt():-1;elementMethods.each(function(method){if(this.element[method]){this[method]=this.element[method].bind(this.element);};},this);},refresh:function(){this.element.removeProperty('style');this.width=this.element.getStyle('width');this.height=this.element.getStyle('height');this.width=(this.width)?this.width.toInt():-1;this.height=(this.height)?this.height.toInt():-1;this.getSizeModifiers(true);if(this.refreshChildren)this.refreshChildren();},expand:function(){var parent=this.getParent();var parentSize=this.getParent().getInnerSize();this.element.getSizeModifiers();parentSize.y-=this.element.modifiers.y;parentSize.x-=this.element.modifiers.x;this.sets({'width':parentSize.x,'height':parentSize.y});},set:function(property,value,noFire){if(property=='height'||property=='width'){var eventArgs={};eventArgs[property]=value;eventArgs[('old-'+property).camelCase()]=this[property];this[property]=value;if(value>0)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<item.length;i++){item[i].parent=this}
|
||||
|
@ -88,6 +88,7 @@ Deluge.UI = {
|
||||
this.details.expand();
|
||||
}.bindWithEvent(this));
|
||||
|
||||
this.initialized = true;
|
||||
window.addEvent('resize', this.bound.onResize);
|
||||
Deluge.UI.update();
|
||||
this.overlay = $('overlay').dispose();
|
||||
@ -201,7 +202,8 @@ Deluge.UI = {
|
||||
*/
|
||||
update: function() {
|
||||
filter = {};
|
||||
var type = this.labels.filterType, name = this.labels.filterName
|
||||
if (!this.initialized) return;
|
||||
var type = this.labels.filterType, name = this.labels.filterName
|
||||
if (type && !(type == 'state' && name == 'All')) {
|
||||
filter[this.labels.filterType] = this.labels.filterName;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user