r2589 - Spinner: Removed show/hide public methods

r2589 - Spinner: Removed show/hide public methods


Author: btburnett3
Date: Tue May 19 15:23:49 2009
New Revision: 2589
Modified:
branches/dev/spinner/demos/spinner/autohide.html
branches/dev/spinner/ui/ui.spinner.js
Log:
Spinner: Removed show/hide public methods
Modified: branches/dev/spinner/demos/spinner/autohide.html
==============================================================================
--- branches/dev/spinner/demos/spinner/autohide.html    (original)
+++ branches/dev/spinner/demos/spinner/autohide.html    Tue May 19 15:23:49
2009
@@ -25,12 +25,6 @@
            $("#s1, #s2").spinner("option", "hide", getSpeed());
            $("#speedp").css("display", "block");
        });
-        $("#hide").click(function() {
-            $("#s1, #s2").spinner("hide", getSpeed());
-        });
-        $("#show").click(function() {
-            $("#s1, #s2").spinner("show", getSpeed());
-        });
        $("#speed").change(function() {
            $("#s1, #s2").spinner("option", "hide", getSpeed());
        });
@@ -49,8 +43,6 @@


<button id="autohide" class="ui-button ui-state-default
ui-corner-all">Toggle auto hide</button>
-<button id="hide" class="ui-button ui-state-default ui-corner-all">Hide
buttons</button>
-<button id="show" class="ui-button ui-state-default ui-corner-all">Show
buttons</button>








<p id="speedp"><label for="speed">Select show/hide speed:</label>
Modified: branches/dev/spinner/ui/ui.spinner.js
==============================================================================
--- branches/dev/spinner/ui/ui.spinner.js    (original)
+++ branches/dev/spinner/ui/ui.spinner.js    Tue May 19 15:23:49 2009
@@ -141,11 +141,11 @@
            .hover(function() {
                self.hovered = true;
                if (typeof self.options.hide != 'boolean' && !self.focused
&& !self.disabled)
-                    self._delay(self.show, 100, 'hide', self.options.hide);
+                    self._delay(self._show, 100, 'hide', self.options.hide);
            }, function() {
                self.hovered = false;
                if (typeof self.options.hide != 'boolean' && !self.focused)
-                    self._delay(self.hide, 100, 'hide', self.options.hide);
+                    self._delay(self._hide, 100, 'hide', self.options.hide);
            });
        
        self.buttons = widget.find('button')
@@ -158,7 +158,7 @@
                }
            });
        if (self.options.hide)
-            self.hide();
+            self._hide();
        // Give the spinner casing a unique id only if one exists in original
input
        // - this should aid targetted customisations if a page contains
multiple instances
@@ -205,12 +205,12 @@
        .bind('focus'+namespace, function() {
            self.focused = true;
            if (!self.hovered && typeof self.options.hide != 'boolean'
&& !self.disabled)
-                self._delay(self.show, 100, 'hide', self.options.hide);
+                self._delay(self._show, 100, 'hide', self.options.hide);
        })
        .bind('blur'+namespace, function(event) {
            self.focused = false;
            if (!self.hovered && typeof self.options.hide != 'boolean')
-                self._delay(self.hide, 100, 'hide', self.options.hide);
+                self._delay(self._hide, 100, 'hide', self.options.hide);
            self._cleanUp();
        });
@@ -415,18 +415,33 @@
            curDelay.f.apply(self, args);
        }, delay);
    },
+    _show: function(speed) {
+        var buttons = this.buttons.stop();
+        if (!speed)
+            buttons.css('opacity', 1);
+        else
+            buttons.fadeTo(speed, 1);
+        return this;
+    },
+    _hide: function(speed) {
+        // also removeClass(hover) in case it was left despite losing mouse hover
+        var buttons = this.buttons.stop().removeClass(hover);
+        if (!speed)
+            buttons.css('opacity', 0);
+        else
+            buttons.fadeTo(speed, 0);
+        return this;
+    },
    _setData: function(key, value) {
        if ((key == 'mouseWheel') && (value != this.options.mouseWheel) &&
$.fn.mousewheel)
            this.element[value ? 'mousewheel' : 'unmousewheel'](this._mousewheel);
        else if (key == 'hide') {
-            if (typeof value != 'boolean') {
-                if (!this.hovered && !this.focused)
-                    this.hide();
-            }
+            if (typeof value != 'boolean')
+                this[this.hovered || this.focused ? '_show' : '_hide']();
            else if (value)
-                this.hide();
+                this._hide();
            else
-                this.show();
+                this._show();
        }
        
        $.widget.prototype._setData.call(this, key, value);
@@ -496,24 +511,6 @@
            return this._getValue();
            
        this._setValue(newVal);
-        return this;
-    },
-    show: function(speed) {
-        var buttons = this.buttons.stop();
-        if (!speed)
-            buttons.css('opacity', 1);
-        else
-            buttons.fadeTo(speed, 1);
-        return this;
-    },
-    
-    hide: function(speed) {
-        // also removeClass(hover) in case it was left despite losing mouse hover
-        var buttons = this.buttons.stop().removeClass(hover);
-        if (!speed)
-            buttons.css('opacity', 0);
-        else
-            buttons.fadeTo(speed, 0);
        return this;
    }
});