]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: make internal methods internal, fixs #3207
authorChi Cheng <cloudream@gmail.com>
Sat, 16 Aug 2008 05:55:17 +0000 (05:55 +0000)
committerChi Cheng <cloudream@gmail.com>
Sat, 16 Aug 2008 05:55:17 +0000 (05:55 +0000)
functional demo fix(not associate with internal change)

demos/functional/templates/ui.spinner.html
ui/ui.spinner.js

index 571163f2e10ab0d3ba492c5f130d0404609e5b18..4ec12cc94de2195627a5b42a2144d4878efb66ec 100644 (file)
@@ -18,8 +18,8 @@
                                        { desc: 'A spinner with min and max value', source: '$("#spinner").spinner({min:-100, max:150});' },\r
                                        { desc: 'Big stepping', source: '$("#spinner").spinner({stepping:100});' },\r
                                        { desc: 'Disable incremental option', source: '$("#spinner").spinner({incremental:false});' },\r
-                                       { desc: 'Enable the spinner', source: '$("#spinner").attr("disabled","");' },\r
-                                       { desc: 'Disable the spinner', source: '$("#spinner").attr("disabled","disabled");' }\r
+                                       { desc: 'Enable the spinner', source: '$("#spinner").spinner().attr("disabled","");' },\r
+                                       { desc: 'Disable the spinner', source: '$("#spinner").spinner().attr("disabled","disabled");' }\r
                                ]\r
                        }\r
 \r
index 8486f3ecf266d69c209cb65917b60f6c3fca6a7a..536d3001cdba5fd1fcf13c9aec6e054745cd0d47 100644 (file)
@@ -34,14 +34,14 @@ $.widget("ui.spinner", {
                        .css("float", this.element.css("float"))\r
                        .prepend('<div class="ui-spinner-up"></div>')\r
                        .find("div.ui-spinner-up")\r
-                               .bind("mousedown", function() { if(!self.counter) self.counter = 1; self.mousedown(100, "up"); })\r
-                               .bind("mouseup", function(e) { self.counter = 0; if(self.timer) window.clearInterval(self.timer); self.element[0].focus(); self.propagate("change", e); })\r
+                               .bind("mousedown", function() { if(!self.counter) self.counter = 1; self._mousedown(100, "_up"); })\r
+                               .bind("mouseup", function(e) { self.counter = 0; if(self.timer) window.clearInterval(self.timer); self.element[0].focus(); self._propagate("change", e); })\r
                                .css({ height: pickerHeight, top: parseInt(this.element.css("borderTopWidth"),10)+1, right: parseInt(this.element.css("borderRightWidth"),10)+1 })\r
                        .end()\r
                        .append('<div class="ui-spinner-down"></div>')\r
                        .find("div.ui-spinner-down")\r
-                               .bind("mousedown", function() { if(!self.counter) self.counter = 1; self.mousedown(100, "down"); })\r
-                               .bind("mouseup", function(e) { self.counter = 0; if(self.timer) window.clearInterval(self.timer); self.element[0].focus(); self.propagate("change", e); })\r
+                               .bind("mousedown", function() { if(!self.counter) self.counter = 1; self._mousedown(100, "_down"); })\r
+                               .bind("mouseup", function(e) { self.counter = 0; if(self.timer) window.clearInterval(self.timer); self.element[0].focus(); self._propagate("change", e); })\r
                                .css({ height: pickerHeight, bottom: parseInt(this.element.css("borderBottomWidth"),10)+1, right: parseInt(this.element.css("borderRightWidth"),10)+1 })\r
                        .end()\r
                ;\r
@@ -49,60 +49,60 @@ $.widget("ui.spinner", {
                this.element\r
                .bind("keydown.spinner", function(e) {\r
                        if(!self.counter) self.counter = 1;\r
-                       self.keydown.call(self, e);\r
+                       self._keydown.call(self, e);\r
                })\r
                .bind("keyup.spinner", function(e) {\r
                        self.counter = 0;\r
-                       self.cleanUp();\r
-                       self.propagate("change", e);\r
+                       self._cleanUp();\r
+                       self._propagate("change", e);\r
                })\r
                ;\r
                if ($.fn.mousewheel) {\r
-                       this.element.mousewheel(function(e, delta) { self.mousewheel(e, delta); });\r
+                       this.element.mousewheel(function(e, delta) { self._mousewheel(e, delta); });\r
                }\r
 \r
        },\r
        plugins: {},\r
-       constrain: function() {\r
+       _constrain: function() {\r
                if(this.options.min != undefined && this.element[0].value < this.options.min) this.element[0].value = this.options.min;\r
                if(this.options.max != undefined && this.element[0].value > this.options.max) this.element[0].value = this.options.max;\r
        },\r
-       cleanUp: function() {\r
+       _cleanUp: function() {\r
                this.element[0].value = this.element[0].value.replace(/[^0-9\-]/g, '');\r
-               this.constrain();\r
+               this._constrain();\r
        },\r
-       down: function(e) {\r
+       _down: function(e) {\r
                if(isNaN(parseInt(this.element[0].value,10))) this.element[0].value = this.options.start;\r
                this.element[0].value -= (this.options.incremental && this.counter > 100 ? (this.counter > 200 ? 100 : 10) : 1) * this.options.stepping;\r
-               this.constrain();\r
+               this._constrain();\r
                if(this.counter) this.counter++;\r
-               this.propagate("spin", e);\r
+               this._propagate("spin", e);\r
        },\r
-       up: function(e) {\r
+       _up: function(e) {\r
                if(isNaN(parseInt(this.element[0].value,10))) this.element[0].value = this.options.start;\r
                this.element[0].value = parseFloat(this.element[0].value) + (this.options.incremental && this.counter > 100 ? (this.counter > 200 ? 100 : 10) : 1) * this.options.stepping;\r
-               this.constrain();\r
+               this._constrain();\r
                if(this.counter) this.counter++;\r
-               this.propagate("spin", e);\r
+               this._propagate("spin", e);\r
        },\r
-       mousedown: function(i, d) {\r
+       _mousedown: function(i, d) {\r
                var self = this;\r
                i = i || 100;\r
                if(this.timer) window.clearInterval(this.timer);\r
                this.timer = window.setInterval(function() {\r
                        self[d]();\r
-                       if(self.counter > 20) self.mousedown(20, d);\r
+                       if(self.counter > 20) self._mousedown(20, d);\r
                }, i);\r
        },\r
-       keydown: function(e) {\r
-               if(e.keyCode == 38 || e.keyCode == 39) this.up(e);\r
-               if(e.keyCode == 40 || e.keyCode == 37) this.down(e);\r
+       _keydown: function(e) {\r
+               if(e.keyCode == 38 || e.keyCode == 39) this._up(e);\r
+               if(e.keyCode == 40 || e.keyCode == 37) this._down(e);\r
                if(e.keyCode == 36) this.element[0].value = this.options.min || this.options.start; //Home key goes to min, if defined, else to start\r
                if(e.keyCode == 35 && this.options.max != undefined) this.element[0].value = this.options.max; //End key goes to maximum\r
        },\r
-       mousewheel: function(e, delta) {\r
+       _mousewheel: function(e, delta) {\r
                delta = ($.browser.opera ? -delta / Math.abs(delta) : delta);\r
-               delta > 0 ? this.up(e) : this.down(e);\r
+               delta > 0 ? this._up(e) : this._down(e);\r
                e.preventDefault();\r
        },\r
        ui: function(e) {\r
@@ -112,7 +112,7 @@ $.widget("ui.spinner", {
                        element: this.element                           \r
                };\r
        },\r
-       propagate: function(n,e) {\r
+       _propagate: function(n,e) {\r
                $.ui.plugin.call(this, n, [e, this.ui()]);\r
                return this.element.triggerHandler(n == "spin" ? n : "spin"+n, [e, this.ui()], this.options[n]);\r
        },\r