Upgrade to ExtJS 3.1.0 - Released 12/16/2009
[extjs.git] / docs / source / Slider.html
index 764ecfc..529a424 100644 (file)
@@ -1,17 +1,12 @@
-<html>
-<head>
-  <title>The source code</title>
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
-</head>
-<body  onload="prettyPrint();">
-    <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-<div id="cls-Ext.Slider"></div>/**\r
+<html>\r
+<head>\r
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js"><div id="cls-Ext.Slider"></div>/**\r
  * @class Ext.Slider\r
  * @extends Ext.BoxComponent\r
  * Slider which supports vertical or horizontal orientation, keyboard adjustments,\r
@@ -169,12 +164,13 @@ Ext.Slider = Ext.extend(Ext.BoxComponent, {
             autoStart: 300\r
         });\r
         this.tracker.initEl(this.thumb);\r
-        this.on('beforedestroy', this.tracker.destroy, this.tracker);\r
     },\r
 \r
        // private override\r
     onMouseDown : function(e){\r
-        if(this.disabled) {return;}\r
+        if(this.disabled){\r
+            return;\r
+        }\r
         if(this.clickToChange && e.target != this.thumb.dom){\r
             var local = this.innerEl.translatePoints(e.getXY());\r
             this.onClickChange(local);\r
@@ -219,11 +215,12 @@ Ext.Slider = Ext.extend(Ext.BoxComponent, {
 \r
        // private\r
     doSnap : function(value){\r
-        if(!this.increment || this.increment == 1 || !value) {\r
+        if(!(this.increment && value)){\r
             return value;\r
         }\r
-        var newValue = value, inc = this.increment;\r
-        var m = value % inc;\r
+        var newValue = value, \r
+            inc = this.increment,\r
+            m = value % inc;\r
         if(m != 0){\r
             newValue -= m;\r
             if(m * 2 > inc){\r
@@ -251,8 +248,8 @@ Ext.Slider = Ext.extend(Ext.BoxComponent, {
 \r
        // private\r
     getRatio : function(){\r
-        var w = this.innerEl.getWidth();\r
-        var v = this.maxValue - this.minValue;\r
+        var w = this.innerEl.getWidth(),\r
+            v = this.maxValue - this.minValue;\r
         return v == 0 ? w : (w/v);\r
     },\r
 \r
@@ -285,12 +282,12 @@ Ext.Slider = Ext.extend(Ext.BoxComponent, {
        // private\r
     translateValue : function(v){\r
         var ratio = this.getRatio();\r
-        return (v * ratio)-(this.minValue * ratio)-this.halfThumb;\r
+        return (v * ratio) - (this.minValue * ratio) - this.halfThumb;\r
     },\r
 \r
        reverseValue : function(pos){\r
         var ratio = this.getRatio();\r
-        return (pos+this.halfThumb+(this.minValue * ratio))/ratio;\r
+        return (pos + this.halfThumb + (this.minValue * ratio)) / ratio;\r
     },\r
 \r
        // private\r
@@ -366,7 +363,7 @@ Ext.Slider = Ext.extend(Ext.BoxComponent, {
         this.thumb.removeClass(this.disabledClass);\r
         if(Ext.isIE){\r
             this.innerEl.removeClass(this.disabledClass).dom.disabled = false;\r
-            if (this.thumbHolder){\r
+            if(this.thumbHolder){\r
                 this.thumbHolder.hide();\r
             }\r
             this.thumb.show();\r
@@ -392,6 +389,12 @@ Ext.Slider = Ext.extend(Ext.BoxComponent, {
         */\r
     getValue : function(){\r
         return this.value;\r
+    },\r
+    \r
+    // private\r
+    beforeDestroy : function(){\r
+        Ext.destroyMembers(this, 'endEl', 'innerEl', 'thumb', 'halfThumb', 'focusEl', 'tracker', 'thumbHolder');\r
+        Ext.Slider.superclass.beforeDestroy.call(this);\r
     }\r
 });\r
 Ext.reg('slider', Ext.Slider);\r
@@ -404,8 +407,8 @@ Ext.Slider.Vertical = {
     },\r
 \r
     getRatio : function(){\r
-        var h = this.innerEl.getHeight();\r
-        var v = this.maxValue - this.minValue;\r
+        var h = this.innerEl.getHeight(),\r
+            v = this.maxValue - this.minValue;\r
         return h/v;\r
     },\r
 \r
@@ -418,18 +421,18 @@ Ext.Slider.Vertical = {
     },\r
 \r
     onDrag: function(e){\r
-        var pos = this.innerEl.translatePoints(this.tracker.getXY());\r
-        var bottom = this.innerEl.getHeight()-pos.top;\r
+        var pos = this.innerEl.translatePoints(this.tracker.getXY()),\r
+            bottom = this.innerEl.getHeight()-pos.top;\r
         this.setValue(this.minValue + Ext.util.Format.round(bottom/this.getRatio(), this.decimalPrecision), false);\r
         this.fireEvent('drag', this, e);\r
     },\r
 \r
     onClickChange : function(local){\r
         if(local.left > this.clickRange[0] && local.left < this.clickRange[1]){\r
-            var bottom = this.innerEl.getHeight()-local.top;\r
+            var bottom = this.innerEl.getHeight() - local.top;\r
             this.setValue(this.minValue + Ext.util.Format.round(bottom/this.getRatio(), this.decimalPrecision), undefined, true);\r
         }\r
     }\r
-};</pre>
-</body>
+};</pre>    \r
+</body>\r
 </html>
\ No newline at end of file