From: jzaefferer Date: Sat, 23 Oct 2010 00:06:25 +0000 (+0200) Subject: Using button widget for the spinner buttons. Can still use some improvements, droppin... X-Git-Tag: 1.9m3~1^2~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eebf8c31fff4653cfcbb273f7da5fa7177217dca;p=jquery-ui.git Using button widget for the spinner buttons. Can still use some improvements, dropping custom theme stuff in favor of button styles. --- diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 4fc77389b..f4227b8f6 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -101,16 +101,18 @@ $.widget('ui.spinner', { // button bindings this.buttons = uiSpinner.find('.ui-spinner-button') .attr("tabIndex", -1) + .button() + .first() + .removeClass("ui-corner-all") + .end() + .last() + .removeClass("ui-corner-all") + .end() .bind('mousedown', function(event) { if (self._start(event) === false) { return false; } self._repeat(null, $(this).hasClass('ui-spinner-up') ? 1 : -1, event); - - if (!self.options.disabled) { - $(this).addClass(active); - uiSpinner.addClass(active); - } }) .bind('mouseup', function(event) { if (self.counter == 1) { @@ -120,19 +122,22 @@ $.widget('ui.spinner', { self._stop(event); self._change(event); } - $(this).removeClass(active); }) - .hover(function() { - if (!self.options.disabled) { - $(this).addClass(hover); + .bind("mouseenter", function() { + // button will add ui-state-active if mouse was down while mouseleave and kept down + if ($(this).hasClass("ui-state-active")) { + if (self._start(event) === false) { + return false; + } + self._repeat(null, $(this).hasClass('ui-spinner-up') ? 1 : -1, event); } - }, function(event) { - $(this).removeClass(active + ' ' + hover); + }) + .bind("mouseleave", function() { if (self.timer && self.spinning) { self._stop(event); self._change(event); } - }); + }) self.uiSpinner = uiSpinner; }, @@ -143,9 +148,9 @@ $.widget('ui.spinner', { '">'; }, _buttonHtml: function() { - return '' + - ''; }, _start: function(event) {