Author: damoxc

Revision: 5079

Log:
        move the contents of the spinner files into ext-extensions-debug.js

Diff:
Deleted: trunk/deluge/ui/web/js/Spinner.js
===================================================================
--- trunk/deluge/ui/web/js/Spinner.js   2009-04-18 16:11:18 UTC (rev 5078)
+++ trunk/deluge/ui/web/js/Spinner.js   2009-04-18 16:14:56 UTC (rev 5079)
@@ -1,302 +0,0 @@
-/**
- * Copyright (c) 2008, Steven Chim
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:
- * 
- *     * Redistributions of source code must retain the above copyright 
notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright 
notice, this list of conditions and the following disclaimer in the 
documentation and/or other materials provided with the distribution.
- *     * The names of its contributors may not be used to endorse or promote 
products derived from this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
-  * Ext.ux.form.Spinner Class
-       *
-       * @author  Steven Chim
-       * @version Spinner.js 2008-08-27 v0.35
-  *
-  * @class Ext.ux.form.Spinner
-  * @extends Ext.form.TriggerField
-  */
-
-Ext.namespace("Ext.ux.form");
-
-Ext.ux.form.Spinner = function(config){
-       Ext.ux.form.Spinner.superclass.constructor.call(this, config);
-       this.addEvents({
-               'spin' : true,
-               'spinup' : true,
-               'spindown' : true
-       });
-}
-
-Ext.extend(Ext.ux.form.Spinner, Ext.form.TriggerField, {
-       triggerClass : 'x-form-spinner-trigger',
-       splitterClass : 'x-form-spinner-splitter',
-
-       alternateKey : Ext.EventObject.shiftKey,
-       strategy : undefined,
-
-       //private
-       onRender : function(ct, position){
-               Ext.ux.form.Spinner.superclass.onRender.call(this, ct, 
position);
-
-               this.splitter = this.wrap.createChild({tag:'div', 
cls:this.splitterClass, style:'width:13px; height:2px;'});
-               this.splitter.show().setRight( (Ext.isIE) ? 1 : 2 );
-               this.splitter.show().setTop(10);
-
-               this.proxy = this.trigger.createProxy('', this.splitter, true);
-               this.proxy.addClass("x-form-spinner-proxy");
-               this.proxy.setStyle('left','0px');  
-               this.proxy.setSize(14, 1);
-               this.proxy.hide();
-               this.dd = new Ext.dd.DDProxy(this.splitter.dom.id, 
"SpinnerDrag", {dragElId: this.proxy.id});
-
-               this.initSpinner();
-       },
-
-       //private
-       initTrigger : function(){
-               this.trigger.addClassOnOver('x-form-trigger-over');
-               this.trigger.addClassOnClick('x-form-trigger-click');
-       },
-
-       //private
-       initSpinner : function(){
-               this.keyNav = new Ext.KeyNav(this.el, {
-                       "up" : function(e){
-                               e.preventDefault();
-                               this.onSpinUp();
-                       },
-
-                       "down" : function(e){
-                               e.preventDefault();
-                               this.onSpinDown();
-                       },
-
-                       "pageUp" : function(e){
-                               e.preventDefault();
-                               this.onSpinUpAlternate();
-                       },
-
-                       "pageDown" : function(e){
-                               e.preventDefault();
-                               this.onSpinDownAlternate();
-                       },
-
-                       scope : this
-               });
-
-               this.repeater = new Ext.util.ClickRepeater(this.trigger);
-               this.repeater.on("click", this.onTriggerClick, this, 
{preventDefault:true});
-               this.trigger.on("mouseover", this.onMouseOver, this, 
{preventDefault:true});
-               this.trigger.on("mouseout",  this.onMouseOut,  this, 
{preventDefault:true});
-               this.trigger.on("mousemove", this.onMouseMove, this, 
{preventDefault:true});
-               this.trigger.on("mousedown", this.onMouseDown, this, 
{preventDefault:true});
-               this.trigger.on("mouseup",   this.onMouseUp,   this, 
{preventDefault:true});
-               this.wrap.on("mousewheel",   this.handleMouseWheel, this);
-
-               this.dd.setXConstraint(0, 0, 10)
-               this.dd.setYConstraint(1500, 1500, 10);
-               this.dd.endDrag = this.endDrag.createDelegate(this);
-               this.dd.startDrag = this.startDrag.createDelegate(this);
-               this.dd.onDrag = this.onDrag.createDelegate(this);
-
-        /*
-        jsakalos suggestion
-        http://extjs.com/forum/showthread.php?p=121850#post121850 */
-        if('object' == typeof this.strategy && this.strategy.xtype) {
-            switch(this.strategy.xtype) {
-                case 'number':
-                    this.strategy = new 
Ext.ux.form.Spinner.NumberStrategy(this.strategy);
-                       break;
-
-                case 'date':
-                    this.strategy = new 
Ext.ux.form.Spinner.DateStrategy(this.strategy);
-                       break;
-
-                case 'time':
-                    this.strategy = new 
Ext.ux.form.Spinner.TimeStrategy(this.strategy);
-                       break;
-
-                default:
-                    delete(this.strategy);
-                       break;
-            }
-            delete(this.strategy.xtype);
-        }
-
-               if(this.strategy == undefined){
-                       this.strategy = new 
Ext.ux.form.Spinner.NumberStrategy();
-               }
-       },
-
-       //private
-       onMouseOver : function(){
-               if(this.disabled){
-                       return;
-               }
-               var middle = this.getMiddle();
-               this.__tmphcls = (Ext.EventObject.getPageY() < middle) ? 
'x-form-spinner-overup' : 'x-form-spinner-overdown';
-               this.trigger.addClass(this.__tmphcls);
-       },
-
-       //private
-       onMouseOut : function(){
-               this.trigger.removeClass(this.__tmphcls);
-       },
-
-       //private
-       onMouseMove : function(){
-               if(this.disabled){
-                       return;
-               }
-               var middle = this.getMiddle();
-               if( ((Ext.EventObject.getPageY() > middle) && this.__tmphcls == 
"x-form-spinner-overup") ||
-                       ((Ext.EventObject.getPageY() < middle) && 
this.__tmphcls == "x-form-spinner-overdown")){
-               }
-       },
-
-       //private
-       onMouseDown : function(){
-               if(this.disabled){
-                       return;
-               }
-               var middle = this.getMiddle();
-               this.__tmpccls = (Ext.EventObject.getPageY() < middle) ? 
'x-form-spinner-clickup' : 'x-form-spinner-clickdown';
-               this.trigger.addClass(this.__tmpccls);
-       },
-
-       //private
-       onMouseUp : function(){
-               this.trigger.removeClass(this.__tmpccls);
-       },
-
-       //private
-       onTriggerClick : function(){
-               if(this.disabled || this.getEl().dom.readOnly){
-                       return;
-               }
-               var middle = this.getMiddle();
-               var ud = (Ext.EventObject.getPageY() < middle) ? 'Up' : 'Down';
-               this['onSpin'+ud]();
-       },
-
-       //private
-       getMiddle : function(){
-               var t = this.trigger.getTop();
-               var h = this.trigger.getHeight();
-               var middle = t + (h/2);
-               return middle;
-       },
-       
-       //private
-       //checks if control is allowed to spin
-       isSpinnable : function(){
-               if(this.disabled || this.getEl().dom.readOnly){
-                       Ext.EventObject.preventDefault();       //prevent 
scrolling when disabled/readonly
-                       return false;
-               }
-               return true;
-       },
-
-       handleMouseWheel : function(e){
-               //disable scrolling when not focused
-               if(this.wrap.hasClass('x-trigger-wrap-focus') == false){
-                       return;
-               }
-
-               var delta = e.getWheelDelta();
-               if(delta > 0){
-                       this.onSpinUp();
-                       e.stopEvent();
-               } else if(delta < 0){
-                       this.onSpinDown();
-                       e.stopEvent();
-               }
-       },
-
-       //private
-       startDrag : function(){
-               this.proxy.show();
-               this._previousY = Ext.fly(this.dd.getDragEl()).getTop();
-       },
-
-       //private
-       endDrag : function(){
-               this.proxy.hide();
-       },
-
-       //private
-       onDrag : function(){
-               if(this.disabled){
-                       return;
-               }
-               var y = Ext.fly(this.dd.getDragEl()).getTop();
-               var ud = '';
-
-               if(this._previousY > y){ud = 'Up';}         //up
-               if(this._previousY < y){ud = 'Down';}       //down
-
-               if(ud != ''){
-                       this['onSpin'+ud]();
-               }
-
-               this._previousY = y;
-       },
-
-       //private
-       onSpinUp : function(){
-               if(this.isSpinnable() == false) {
-                       return;
-               }
-               if(Ext.EventObject.shiftKey == true){
-                       this.onSpinUpAlternate();
-                       return;
-               }else{
-                       this.strategy.onSpinUp(this);
-               }
-               this.fireEvent("spin", this);
-               this.fireEvent("spinup", this);
-       },
-
-       //private
-       onSpinDown : function(){
-               if(this.isSpinnable() == false) {
-                       return;
-               }
-               if(Ext.EventObject.shiftKey == true){
-                       this.onSpinDownAlternate();
-                       return;
-               }else{
-                       this.strategy.onSpinDown(this);
-               }
-               this.fireEvent("spin", this);
-               this.fireEvent("spindown", this);
-       },
-
-       //private
-       onSpinUpAlternate : function(){
-               if(this.isSpinnable() == false) {
-                       return;
-               }
-               this.strategy.onSpinUpAlternate(this);
-               this.fireEvent("spin", this);
-               this.fireEvent("spinup", this);
-       },
-
-       //private
-       onSpinDownAlternate : function(){
-               if(this.isSpinnable() == false) {
-                       return;
-               }
-               this.strategy.onSpinDownAlternate(this);
-               this.fireEvent("spin", this);
-               this.fireEvent("spindown", this);
-       }
-
-});
-
-Ext.reg('uxspinner', Ext.ux.form.Spinner);

Deleted: trunk/deluge/ui/web/js/SpinnerStrategy.js
===================================================================
--- trunk/deluge/ui/web/js/SpinnerStrategy.js   2009-04-18 16:11:18 UTC (rev 
5078)
+++ trunk/deluge/ui/web/js/SpinnerStrategy.js   2009-04-18 16:14:56 UTC (rev 
5079)
@@ -1,172 +0,0 @@
-/**
- * Copyright (c) 2008, Steven Chim
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:
- * 
- *     * Redistributions of source code must retain the above copyright 
notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright 
notice, this list of conditions and the following disclaimer in the 
documentation and/or other materials provided with the distribution.
- *     * The names of its contributors may not be used to endorse or promote 
products derived from this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/***
- * Abstract Strategy
- */
-Ext.ux.form.Spinner.Strategy = function(config){
-       Ext.apply(this, config);
-};
-
-Ext.extend(Ext.ux.form.Spinner.Strategy, Ext.util.Observable, {
-       defaultValue : 0,
-       minValue : undefined,
-       maxValue : undefined,
-       incrementValue : 1,
-       alternateIncrementValue : 5,
-       validationTask : new Ext.util.DelayedTask(),
-       
-       onSpinUp : function(field){
-               this.spin(field, false, false);
-       },
-
-       onSpinDown : function(field){
-               this.spin(field, true, false);
-       },
-
-       onSpinUpAlternate : function(field){
-               this.spin(field, false, true);
-       },
-
-       onSpinDownAlternate : function(field){
-               this.spin(field, true, true);
-       },
-
-       spin : function(field, down, alternate){
-               this.validationTask.delay(500, function(){field.validate()});
-               //extend
-       },
-
-       fixBoundries : function(value){
-               return value;
-               //overwrite
-       }
-       
-});
-
-/***
- * Concrete Strategy: Numbers
- */
-Ext.ux.form.Spinner.NumberStrategy = function(config){
-       Ext.ux.form.Spinner.NumberStrategy.superclass.constructor.call(this, 
config);
-};
-
-Ext.extend(Ext.ux.form.Spinner.NumberStrategy, Ext.ux.form.Spinner.Strategy, {
-
-    allowDecimals : true,
-    decimalPrecision : 2,
-    
-       spin : function(field, down, alternate){
-               Ext.ux.form.Spinner.NumberStrategy.superclass.spin.call(this, 
field, down, alternate);
-
-               var v = parseFloat(field.getValue());
-               var incr = (alternate == true) ? this.alternateIncrementValue : 
this.incrementValue;
-
-               (down == true) ? v -= incr : v += incr ;
-               v = (isNaN(v)) ? this.defaultValue : v;
-               v = this.fixBoundries(v);
-               field.setRawValue(v);
-       },
-
-       fixBoundries : function(value){
-               var v = value;
-
-               if(this.minValue != undefined && v < this.minValue){
-                       v = this.minValue;
-               }
-               if(this.maxValue != undefined && v > this.maxValue){
-                       v = this.maxValue;
-               }
-
-               return this.fixPrecision(v);
-       },
-       
-    // private
-    fixPrecision : function(value){
-        var nan = isNaN(value);
-        if(!this.allowDecimals || this.decimalPrecision == -1 || nan || 
!value){
-            return nan ? '' : value;
-        }
-        return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
-    }
-});
-
-
-/***
- * Concrete Strategy: Date
- */
-Ext.ux.form.Spinner.DateStrategy = function(config){
-       Ext.ux.form.Spinner.DateStrategy.superclass.constructor.call(this, 
config);
-};
-
-Ext.extend(Ext.ux.form.Spinner.DateStrategy, Ext.ux.form.Spinner.Strategy, {
-       defaultValue : new Date(),
-       format : "Y-m-d",
-       incrementValue : 1,
-       incrementConstant : Date.DAY,
-       alternateIncrementValue : 1,
-       alternateIncrementConstant : Date.MONTH,
-
-       spin : function(field, down, alternate){
-               Ext.ux.form.Spinner.DateStrategy.superclass.spin.call(this);
-
-               var v = field.getRawValue();
-               
-               v = Date.parseDate(v, this.format);
-               var dir = (down == true) ? -1 : 1 ;
-               var incr = (alternate == true) ? this.alternateIncrementValue : 
this.incrementValue;
-               var dtconst = (alternate == true) ? 
this.alternateIncrementConstant : this.incrementConstant;
-
-               if(typeof this.defaultValue == 'string'){
-                       this.defaultValue = Date.parseDate(this.defaultValue, 
this.format);
-               }
-
-               v = (v) ? v.add(dtconst, dir*incr) : this.defaultValue;
-
-               v = this.fixBoundries(v);
-               field.setRawValue(Ext.util.Format.date(v,this.format));
-       },
-       
-       //private
-       fixBoundries : function(date){
-               var dt = date;
-               var min = (typeof this.minValue == 'string') ? 
Date.parseDate(this.minValue, this.format) : this.minValue ;
-               var max = (typeof this.maxValue == 'string') ? 
Date.parseDate(this.maxValue, this.format) : this.maxValue ;
-
-               if(this.minValue != undefined && dt < min){
-                       dt = min;
-               }
-               if(this.maxValue != undefined && dt > max){
-                       dt = max;
-               }
-
-               return dt;
-       }
-
-});
-
-
-/***
- * Concrete Strategy: Time
- */
-Ext.ux.form.Spinner.TimeStrategy = function(config){
-       Ext.ux.form.Spinner.TimeStrategy.superclass.constructor.call(this, 
config);
-};
-
-Ext.extend(Ext.ux.form.Spinner.TimeStrategy, Ext.ux.form.Spinner.DateStrategy, 
{
-       format : "H:i",
-       incrementValue : 1,
-       incrementConstant : Date.MINUTE,
-       alternateIncrementValue : 1,
-       alternateIncrementConstant : Date.HOUR
-});

Added: trunk/deluge/ui/web/js/ext-extensions-debug.js
===================================================================
--- trunk/deluge/ui/web/js/ext-extensions-debug.js                              
(rev 0)
+++ trunk/deluge/ui/web/js/ext-extensions-debug.js      2009-04-18 16:14:56 UTC 
(rev 5079)
@@ -0,0 +1,475 @@
+/**
+ * Copyright (c) 2008, Steven Chim
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:
+ * 
+ *     * Redistributions of source code must retain the above copyright 
notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright 
notice, this list of conditions and the following disclaimer in the 
documentation and/or other materials provided with the distribution.
+ *     * The names of its contributors may not be used to endorse or promote 
products derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+  * Ext.ux.form.Spinner Class
+       *
+       * @author  Steven Chim
+       * @version Spinner.js 2008-08-27 v0.35
+  *
+  * @class Ext.ux.form.Spinner
+  * @extends Ext.form.TriggerField
+  */
+
+Ext.namespace("Ext.ux.form");
+
+Ext.ux.form.Spinner = function(config){
+       Ext.ux.form.Spinner.superclass.constructor.call(this, config);
+       this.addEvents({
+               'spin' : true,
+               'spinup' : true,
+               'spindown' : true
+       });
+}
+
+Ext.extend(Ext.ux.form.Spinner, Ext.form.TriggerField, {
+       triggerClass : 'x-form-spinner-trigger',
+       splitterClass : 'x-form-spinner-splitter',
+
+       alternateKey : Ext.EventObject.shiftKey,
+       strategy : undefined,
+
+       //private
+       onRender : function(ct, position){
+               Ext.ux.form.Spinner.superclass.onRender.call(this, ct, 
position);
+
+               this.splitter = this.wrap.createChild({tag:'div', 
cls:this.splitterClass, style:'width:13px; height:2px;'});
+               this.splitter.show().setRight( (Ext.isIE) ? 1 : 2 );
+               this.splitter.show().setTop(10);
+
+               this.proxy = this.trigger.createProxy('', this.splitter, true);
+               this.proxy.addClass("x-form-spinner-proxy");
+               this.proxy.setStyle('left','0px');  
+               this.proxy.setSize(14, 1);
+               this.proxy.hide();
+               this.dd = new Ext.dd.DDProxy(this.splitter.dom.id, 
"SpinnerDrag", {dragElId: this.proxy.id});
+
+               this.initSpinner();
+       },
+
+       //private
+       initTrigger : function(){
+               this.trigger.addClassOnOver('x-form-trigger-over');
+               this.trigger.addClassOnClick('x-form-trigger-click');
+       },
+
+       //private
+       initSpinner : function(){
+               this.keyNav = new Ext.KeyNav(this.el, {
+                       "up" : function(e){
+                               e.preventDefault();
+                               this.onSpinUp();
+                       },
+
+                       "down" : function(e){
+                               e.preventDefault();
+                               this.onSpinDown();
+                       },
+
+                       "pageUp" : function(e){
+                               e.preventDefault();
+                               this.onSpinUpAlternate();
+                       },
+
+                       "pageDown" : function(e){
+                               e.preventDefault();
+                               this.onSpinDownAlternate();
+                       },
+
+                       scope : this
+               });
+
+               this.repeater = new Ext.util.ClickRepeater(this.trigger);
+               this.repeater.on("click", this.onTriggerClick, this, 
{preventDefault:true});
+               this.trigger.on("mouseover", this.onMouseOver, this, 
{preventDefault:true});
+               this.trigger.on("mouseout",  this.onMouseOut,  this, 
{preventDefault:true});
+               this.trigger.on("mousemove", this.onMouseMove, this, 
{preventDefault:true});
+               this.trigger.on("mousedown", this.onMouseDown, this, 
{preventDefault:true});
+               this.trigger.on("mouseup",   this.onMouseUp,   this, 
{preventDefault:true});
+               this.wrap.on("mousewheel",   this.handleMouseWheel, this);
+
+               this.dd.setXConstraint(0, 0, 10)
+               this.dd.setYConstraint(1500, 1500, 10);
+               this.dd.endDrag = this.endDrag.createDelegate(this);
+               this.dd.startDrag = this.startDrag.createDelegate(this);
+               this.dd.onDrag = this.onDrag.createDelegate(this);
+
+        /*
+        jsakalos suggestion
+        http://extjs.com/forum/showthread.php?p=121850#post121850 */
+        if('object' == typeof this.strategy && this.strategy.xtype) {
+            switch(this.strategy.xtype) {
+                case 'number':
+                    this.strategy = new 
Ext.ux.form.Spinner.NumberStrategy(this.strategy);
+                       break;
+
+                case 'date':
+                    this.strategy = new 
Ext.ux.form.Spinner.DateStrategy(this.strategy);
+                       break;
+
+                case 'time':
+                    this.strategy = new 
Ext.ux.form.Spinner.TimeStrategy(this.strategy);
+                       break;
+
+                default:
+                    delete(this.strategy);
+                       break;
+            }
+            delete(this.strategy.xtype);
+        }
+
+               if(this.strategy == undefined){
+                       this.strategy = new 
Ext.ux.form.Spinner.NumberStrategy();
+               }
+       },
+
+       //private
+       onMouseOver : function(){
+               if(this.disabled){
+                       return;
+               }
+               var middle = this.getMiddle();
+               this.__tmphcls = (Ext.EventObject.getPageY() < middle) ? 
'x-form-spinner-overup' : 'x-form-spinner-overdown';
+               this.trigger.addClass(this.__tmphcls);
+       },
+
+       //private
+       onMouseOut : function(){
+               this.trigger.removeClass(this.__tmphcls);
+       },
+
+       //private
+       onMouseMove : function(){
+               if(this.disabled){
+                       return;
+               }
+               var middle = this.getMiddle();
+               if( ((Ext.EventObject.getPageY() > middle) && this.__tmphcls == 
"x-form-spinner-overup") ||
+                       ((Ext.EventObject.getPageY() < middle) && 
this.__tmphcls == "x-form-spinner-overdown")){
+               }
+       },
+
+       //private
+       onMouseDown : function(){
+               if(this.disabled){
+                       return;
+               }
+               var middle = this.getMiddle();
+               this.__tmpccls = (Ext.EventObject.getPageY() < middle) ? 
'x-form-spinner-clickup' : 'x-form-spinner-clickdown';
+               this.trigger.addClass(this.__tmpccls);
+       },
+
+       //private
+       onMouseUp : function(){
+               this.trigger.removeClass(this.__tmpccls);
+       },
+
+       //private
+       onTriggerClick : function(){
+               if(this.disabled || this.getEl().dom.readOnly){
+                       return;
+               }
+               var middle = this.getMiddle();
+               var ud = (Ext.EventObject.getPageY() < middle) ? 'Up' : 'Down';
+               this['onSpin'+ud]();
+       },
+
+       //private
+       getMiddle : function(){
+               var t = this.trigger.getTop();
+               var h = this.trigger.getHeight();
+               var middle = t + (h/2);
+               return middle;
+       },
+       
+       //private
+       //checks if control is allowed to spin
+       isSpinnable : function(){
+               if(this.disabled || this.getEl().dom.readOnly){
+                       Ext.EventObject.preventDefault();       //prevent 
scrolling when disabled/readonly
+                       return false;
+               }
+               return true;
+       },
+
+       handleMouseWheel : function(e){
+               //disable scrolling when not focused
+               if(this.wrap.hasClass('x-trigger-wrap-focus') == false){
+                       return;
+               }
+
+               var delta = e.getWheelDelta();
+               if(delta > 0){
+                       this.onSpinUp();
+                       e.stopEvent();
+               } else if(delta < 0){
+                       this.onSpinDown();
+                       e.stopEvent();
+               }
+       },
+
+       //private
+       startDrag : function(){
+               this.proxy.show();
+               this._previousY = Ext.fly(this.dd.getDragEl()).getTop();
+       },
+
+       //private
+       endDrag : function(){
+               this.proxy.hide();
+       },
+
+       //private
+       onDrag : function(){
+               if(this.disabled){
+                       return;
+               }
+               var y = Ext.fly(this.dd.getDragEl()).getTop();
+               var ud = '';
+
+               if(this._previousY > y){ud = 'Up';}         //up
+               if(this._previousY < y){ud = 'Down';}       //down
+
+               if(ud != ''){
+                       this['onSpin'+ud]();
+               }
+
+               this._previousY = y;
+       },
+
+       //private
+       onSpinUp : function(){
+               if(this.isSpinnable() == false) {
+                       return;
+               }
+               if(Ext.EventObject.shiftKey == true){
+                       this.onSpinUpAlternate();
+                       return;
+               }else{
+                       this.strategy.onSpinUp(this);
+               }
+               this.fireEvent("spin", this);
+               this.fireEvent("spinup", this);
+       },
+
+       //private
+       onSpinDown : function(){
+               if(this.isSpinnable() == false) {
+                       return;
+               }
+               if(Ext.EventObject.shiftKey == true){
+                       this.onSpinDownAlternate();
+                       return;
+               }else{
+                       this.strategy.onSpinDown(this);
+               }
+               this.fireEvent("spin", this);
+               this.fireEvent("spindown", this);
+       },
+
+       //private
+       onSpinUpAlternate : function(){
+               if(this.isSpinnable() == false) {
+                       return;
+               }
+               this.strategy.onSpinUpAlternate(this);
+               this.fireEvent("spin", this);
+               this.fireEvent("spinup", this);
+       },
+
+       //private
+       onSpinDownAlternate : function(){
+               if(this.isSpinnable() == false) {
+                       return;
+               }
+               this.strategy.onSpinDownAlternate(this);
+               this.fireEvent("spin", this);
+               this.fireEvent("spindown", this);
+       }
+
+});
+
+Ext.reg('uxspinner', Ext.ux.form.Spinner);
+
+/**
+ * Copyright (c) 2008, Steven Chim
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:
+ * 
+ *     * Redistributions of source code must retain the above copyright 
notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright 
notice, this list of conditions and the following disclaimer in the 
documentation and/or other materials provided with the distribution.
+ *     * The names of its contributors may not be used to endorse or promote 
products derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/***
+ * Abstract Strategy
+ */
+Ext.ux.form.Spinner.Strategy = function(config){
+       Ext.apply(this, config);
+};
+
+Ext.extend(Ext.ux.form.Spinner.Strategy, Ext.util.Observable, {
+       defaultValue : 0,
+       minValue : undefined,
+       maxValue : undefined,
+       incrementValue : 1,
+       alternateIncrementValue : 5,
+       validationTask : new Ext.util.DelayedTask(),
+       
+       onSpinUp : function(field){
+               this.spin(field, false, false);
+       },
+
+       onSpinDown : function(field){
+               this.spin(field, true, false);
+       },
+
+       onSpinUpAlternate : function(field){
+               this.spin(field, false, true);
+       },
+
+       onSpinDownAlternate : function(field){
+               this.spin(field, true, true);
+       },
+
+       spin : function(field, down, alternate){
+               this.validationTask.delay(500, function(){field.validate()});
+               //extend
+       },
+
+       fixBoundries : function(value){
+               return value;
+               //overwrite
+       }
+       
+});
+
+/***
+ * Concrete Strategy: Numbers
+ */
+Ext.ux.form.Spinner.NumberStrategy = function(config){
+       Ext.ux.form.Spinner.NumberStrategy.superclass.constructor.call(this, 
config);
+};
+
+Ext.extend(Ext.ux.form.Spinner.NumberStrategy, Ext.ux.form.Spinner.Strategy, {
+
+    allowDecimals : true,
+    decimalPrecision : 2,
+    
+       spin : function(field, down, alternate){
+               Ext.ux.form.Spinner.NumberStrategy.superclass.spin.call(this, 
field, down, alternate);
+
+               var v = parseFloat(field.getValue());
+               var incr = (alternate == true) ? this.alternateIncrementValue : 
this.incrementValue;
+
+               (down == true) ? v -= incr : v += incr ;
+               v = (isNaN(v)) ? this.defaultValue : v;
+               v = this.fixBoundries(v);
+               field.setRawValue(v);
+       },
+
+       fixBoundries : function(value){
+               var v = value;
+
+               if(this.minValue != undefined && v < this.minValue){
+                       v = this.minValue;
+               }
+               if(this.maxValue != undefined && v > this.maxValue){
+                       v = this.maxValue;
+               }
+
+               return this.fixPrecision(v);
+       },
+       
+    // private
+    fixPrecision : function(value){
+        var nan = isNaN(value);
+        if(!this.allowDecimals || this.decimalPrecision == -1 || nan || 
!value){
+            return nan ? '' : value;
+        }
+        return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
+    }
+});
+
+
+/***
+ * Concrete Strategy: Date
+ */
+Ext.ux.form.Spinner.DateStrategy = function(config){
+       Ext.ux.form.Spinner.DateStrategy.superclass.constructor.call(this, 
config);
+};
+
+Ext.extend(Ext.ux.form.Spinner.DateStrategy, Ext.ux.form.Spinner.Strategy, {
+       defaultValue : new Date(),
+       format : "Y-m-d",
+       incrementValue : 1,
+       incrementConstant : Date.DAY,
+       alternateIncrementValue : 1,
+       alternateIncrementConstant : Date.MONTH,
+
+       spin : function(field, down, alternate){
+               Ext.ux.form.Spinner.DateStrategy.superclass.spin.call(this);
+
+               var v = field.getRawValue();
+               
+               v = Date.parseDate(v, this.format);
+               var dir = (down == true) ? -1 : 1 ;
+               var incr = (alternate == true) ? this.alternateIncrementValue : 
this.incrementValue;
+               var dtconst = (alternate == true) ? 
this.alternateIncrementConstant : this.incrementConstant;
+
+               if(typeof this.defaultValue == 'string'){
+                       this.defaultValue = Date.parseDate(this.defaultValue, 
this.format);
+               }
+
+               v = (v) ? v.add(dtconst, dir*incr) : this.defaultValue;
+
+               v = this.fixBoundries(v);
+               field.setRawValue(Ext.util.Format.date(v,this.format));
+       },
+       
+       //private
+       fixBoundries : function(date){
+               var dt = date;
+               var min = (typeof this.minValue == 'string') ? 
Date.parseDate(this.minValue, this.format) : this.minValue ;
+               var max = (typeof this.maxValue == 'string') ? 
Date.parseDate(this.maxValue, this.format) : this.maxValue ;
+
+               if(this.minValue != undefined && dt < min){
+                       dt = min;
+               }
+               if(this.maxValue != undefined && dt > max){
+                       dt = max;
+               }
+
+               return dt;
+       }
+
+});
+
+
+/***
+ * Concrete Strategy: Time
+ */
+Ext.ux.form.Spinner.TimeStrategy = function(config){
+       Ext.ux.form.Spinner.TimeStrategy.superclass.constructor.call(this, 
config);
+};
+
+Ext.extend(Ext.ux.form.Spinner.TimeStrategy, Ext.ux.form.Spinner.DateStrategy, 
{
+       format : "H:i",
+       incrementValue : 1,
+       incrementConstant : Date.MINUTE,
+       alternateIncrementValue : 1,
+       alternateIncrementConstant : Date.HOUR
+});
\ No newline at end of file

Added: trunk/deluge/ui/web/js/ext-extensions.js
===================================================================
--- trunk/deluge/ui/web/js/ext-extensions.js                            (rev 0)
+++ trunk/deluge/ui/web/js/ext-extensions.js    2009-04-18 16:14:56 UTC (rev 
5079)
@@ -0,0 +1 @@
+Ext.namespace("Ext.ux.form");Ext.ux.form.Spinner=function(a){Ext.ux.form.Spinner.superclass.constructor.call(this,a);this.addEvents({spin:true,spinup:true,spindown:true})};Ext.extend(Ext.ux.form.Spinner,Ext.form.TriggerField,{triggerClass:"x-form-spinner-trigger",splitterClass:"x-form-spinner-splitter",alternateKey:Ext.EventObject.shiftKey,strategy:undefined,onRender:function(b,a){Ext.ux.form.Spinner.superclass.onRender.call(this,b,a);this.splitter=this.wrap.createChild({tag:"div",cls:this.splitterClass,style:"width:13px;
 
height:2px;"});this.splitter.show().setRight((Ext.isIE)?1:2);this.splitter.show().setTop(10);this.proxy=this.trigger.createProxy("",this.splitter,true);this.proxy.addClass("x-form-spinner-proxy");this.proxy.setStyle("left","0px");this.proxy.setSize(14,1);this.proxy.hide();this.dd=new
 
Ext.dd.DDProxy(this.splitter.dom.id,"SpinnerDrag",{dragElId:this.proxy.id});this.initSpinner()},initTrigger:function(){this.trigger.addClassOnOver("x-form-trigger-over");this.t
 
rigger.addClassOnClick("x-form-trigger-click")},initSpinner:function(){this.keyNav=new
 
Ext.KeyNav(this.el,{up:function(a){a.preventDefault();this.onSpinUp()},down:function(a){a.preventDefault();this.onSpinDown()},pageUp:function(a){a.preventDefault();this.onSpinUpAlternate()},pageDown:function(a){a.preventDefault();this.onSpinDownAlternate()},scope:this});this.repeater=new
 
Ext.util.ClickRepeater(this.trigger);this.repeater.on("click",this.onTriggerClick,this,{preventDefault:true});this.trigger.on("mouseover",this.onMouseOver,this,{preventDefault:true});this.trigger.on("mouseout",this.onMouseOut,this,{preventDefault:true});this.trigger.on("mousemove",this.onMouseMove,this,{preventDefault:true});this.trigger.on("mousedown",this.onMouseDown,this,{preventDefault:true});this.trigger.on("mouseup",this.onMouseUp,this,{preventDefault:true});this.wrap.on("mousewheel",this.handleMouseWheel,this);this.dd.setXConstraint(0,0,10);this.dd.setYConstraint(1500,1500,10);this.dd.endDrag=this.e
 
ndDrag.createDelegate(this);this.dd.startDrag=this.startDrag.createDelegate(this);this.dd.onDrag=this.onDrag.createDelegate(this);if("object"==typeof
 
this.strategy&&this.strategy.xtype){switch(this.strategy.xtype){case"number":this.strategy=new
 
Ext.ux.form.Spinner.NumberStrategy(this.strategy);break;case"date":this.strategy=new
 
Ext.ux.form.Spinner.DateStrategy(this.strategy);break;case"time":this.strategy=new
 Ext.ux.form.Spinner.TimeStrategy(this.strategy);break;default:delete 
(this.strategy);break}delete 
(this.strategy.xtype)}if(this.strategy==undefined){this.strategy=new 
Ext.ux.form.Spinner.NumberStrategy()}},onMouseOver:function(){if(this.disabled){return}var
 
a=this.getMiddle();this.__tmphcls=(Ext.EventObject.getPageY()<a)?"x-form-spinner-overup":"x-form-spinner-overdown";this.trigger.addClass(this.__tmphcls)},onMouseOut:function(){this.trigger.removeClass(this.__tmphcls)},onMouseMove:function(){if(this.disabled){return}var
 a=this.getMiddle();if(((Ext.EventObject.getPageY
 
()>a)&&this.__tmphcls=="x-form-spinner-overup")||((Ext.EventObject.getPageY()<a)&&this.__tmphcls=="x-form-spinner-overdown")){}},onMouseDown:function(){if(this.disabled){return}var
 
a=this.getMiddle();this.__tmpccls=(Ext.EventObject.getPageY()<a)?"x-form-spinner-clickup":"x-form-spinner-clickdown";this.trigger.addClass(this.__tmpccls)},onMouseUp:function(){this.trigger.removeClass(this.__tmpccls)},onTriggerClick:function(){if(this.disabled||this.getEl().dom.readOnly){return}var
 b=this.getMiddle();var 
a=(Ext.EventObject.getPageY()<b)?"Up":"Down";this["onSpin"+a]()},getMiddle:function(){var
 b=this.trigger.getTop();var c=this.trigger.getHeight();var a=b+(c/2);return 
a},isSpinnable:function(){if(this.disabled||this.getEl().dom.readOnly){Ext.EventObject.preventDefault();return
 false}return 
true},handleMouseWheel:function(a){if(this.wrap.hasClass("x-trigger-wrap-focus")==false){return}var
 
b=a.getWheelDelta();if(b>0){this.onSpinUp();a.stopEvent()}else{if(b<0){this.onSpinDown();a.sto
 
pEvent()}}},startDrag:function(){this.proxy.show();this._previousY=Ext.fly(this.dd.getDragEl()).getTop()},endDrag:function(){this.proxy.hide()},onDrag:function(){if(this.disabled){return}var
 b=Ext.fly(this.dd.getDragEl()).getTop();var 
a="";if(this._previousY>b){a="Up"}if(this._previousY<b){a="Down"}if(a!=""){this["onSpin"+a]()}this._previousY=b},onSpinUp:function(){if(this.isSpinnable()==false){return}if(Ext.EventObject.shiftKey==true){this.onSpinUpAlternate();return}else{this.strategy.onSpinUp(this)}this.fireEvent("spin",this);this.fireEvent("spinup",this)},onSpinDown:function(){if(this.isSpinnable()==false){return}if(Ext.EventObject.shiftKey==true){this.onSpinDownAlternate();return}else{this.strategy.onSpinDown(this)}this.fireEvent("spin",this);this.fireEvent("spindown",this)},onSpinUpAlternate:function(){if(this.isSpinnable()==false){return}this.strategy.onSpinUpAlternate(this);this.fireEvent("spin",this);this.fireEvent("spinup",this)},onSpinDownAlternate:function(){if(th
 
is.isSpinnable()==false){return}this.strategy.onSpinDownAlternate(this);this.fireEvent("spin",this);this.fireEvent("spindown",this)}});Ext.reg("uxspinner",Ext.ux.form.Spinner);Ext.ux.form.Spinner.Strategy=function(a){Ext.apply(this,a)};Ext.extend(Ext.ux.form.Spinner.Strategy,Ext.util.Observable,{defaultValue:0,minValue:undefined,maxValue:undefined,incrementValue:1,alternateIncrementValue:5,validationTask:new
 
Ext.util.DelayedTask(),onSpinUp:function(a){this.spin(a,false,false)},onSpinDown:function(a){this.spin(a,true,false)},onSpinUpAlternate:function(a){this.spin(a,false,true)},onSpinDownAlternate:function(a){this.spin(a,true,true)},spin:function(a,c,b){this.validationTask.delay(500,function(){a.validate()})},fixBoundries:function(a){return
 
a}});Ext.ux.form.Spinner.NumberStrategy=function(a){Ext.ux.form.Spinner.NumberStrategy.superclass.constructor.call(this,a)};Ext.extend(Ext.ux.form.Spinner.NumberStrategy,Ext.ux.form.Spinner.Strategy,{allowDecimals:true,decimalPrecision:2,
 
spin:function(b,e,c){Ext.ux.form.Spinner.NumberStrategy.superclass.spin.call(this,b,e,c);var
 a=parseFloat(b.getValue());var 
d=(c==true)?this.alternateIncrementValue:this.incrementValue;(e==true)?a-=d:a+=d;a=(isNaN(a))?this.defaultValue:a;a=this.fixBoundries(a);b.setRawValue(a)},fixBoundries:function(b){var
 
a=b;if(this.minValue!=undefined&&a<this.minValue){a=this.minValue}if(this.maxValue!=undefined&&a>this.maxValue){a=this.maxValue}return
 this.fixPrecision(a)},fixPrecision:function(b){var 
a=isNaN(b);if(!this.allowDecimals||this.decimalPrecision==-1||a||!b){return 
a?"":b}return 
parseFloat(parseFloat(b).toFixed(this.decimalPrecision))}});Ext.ux.form.Spinner.DateStrategy=function(a){Ext.ux.form.Spinner.DateStrategy.superclass.constructor.call(this,a)};Ext.extend(Ext.ux.form.Spinner.DateStrategy,Ext.ux.form.Spinner.Strategy,{defaultValue:new
 
Date(),format:"Y-m-d",incrementValue:1,incrementConstant:Date.DAY,alternateIncrementValue:1,alternateIncrementConstant:Date.MONTH,spin:func
 tion(d,g,e){Ext.ux.form.Spinner.DateStrategy.superclass.spin.call(this);var 
a=d.getRawValue();a=Date.parseDate(a,this.format);var c=(g==true)?-1:1;var 
f=(e==true)?this.alternateIncrementValue:this.incrementValue;var 
b=(e==true)?this.alternateIncrementConstant:this.incrementConstant;if(typeof 
this.defaultValue=="string"){this.defaultValue=Date.parseDate(this.defaultValue,this.format)}a=(a)?a.add(b,c*f):this.defaultValue;a=this.fixBoundries(a);d.setRawValue(Ext.util.Format.date(a,this.format))},fixBoundries:function(b){var
 d=b;var c=(typeof 
this.minValue=="string")?Date.parseDate(this.minValue,this.format):this.minValue;var
 a=(typeof 
this.maxValue=="string")?Date.parseDate(this.maxValue,this.format):this.maxValue;if(this.minValue!=undefined&&d<c){d=c}if(this.maxValue!=undefined&&d>a){d=a}return
 
d}});Ext.ux.form.Spinner.TimeStrategy=function(a){Ext.ux.form.Spinner.TimeStrategy.superclass.constructor.call(this,a)};Ext.extend(Ext.ux.form.Spinner.TimeStrategy,Ext.ux.form.Spinner.D
 
ateStrategy,{format:"H:i",incrementValue:1,incrementConstant:Date.MINUTE,alternateIncrementValue:1,alternateIncrementConstant:Date.HOUR});
\ No newline at end of file



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to