Skip to content

Commit eebf8c3

Browse files
committed
Using button widget for the spinner buttons. Can still use some improvements, dropping custom theme stuff in favor of button styles.
1 parent bc3d283 commit eebf8c3

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

ui/jquery.ui.spinner.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,18 @@ $.widget('ui.spinner', {
101101
// button bindings
102102
this.buttons = uiSpinner.find('.ui-spinner-button')
103103
.attr("tabIndex", -1)
104+
.button()
105+
.first()
106+
.removeClass("ui-corner-all")
107+
.end()
108+
.last()
109+
.removeClass("ui-corner-all")
110+
.end()
104111
.bind('mousedown', function(event) {
105112
if (self._start(event) === false) {
106113
return false;
107114
}
108115
self._repeat(null, $(this).hasClass('ui-spinner-up') ? 1 : -1, event);
109-
110-
if (!self.options.disabled) {
111-
$(this).addClass(active);
112-
uiSpinner.addClass(active);
113-
}
114116
})
115117
.bind('mouseup', function(event) {
116118
if (self.counter == 1) {
@@ -120,19 +122,22 @@ $.widget('ui.spinner', {
120122
self._stop(event);
121123
self._change(event);
122124
}
123-
$(this).removeClass(active);
124125
})
125-
.hover(function() {
126-
if (!self.options.disabled) {
127-
$(this).addClass(hover);
126+
.bind("mouseenter", function() {
127+
// button will add ui-state-active if mouse was down while mouseleave and kept down
128+
if ($(this).hasClass("ui-state-active")) {
129+
if (self._start(event) === false) {
130+
return false;
131+
}
132+
self._repeat(null, $(this).hasClass('ui-spinner-up') ? 1 : -1, event);
128133
}
129-
}, function(event) {
130-
$(this).removeClass(active + ' ' + hover);
134+
})
135+
.bind("mouseleave", function() {
131136
if (self.timer && self.spinning) {
132137
self._stop(event);
133138
self._change(event);
134139
}
135-
});
140+
})
136141

137142
self.uiSpinner = uiSpinner;
138143
},
@@ -143,9 +148,9 @@ $.widget('ui.spinner', {
143148
'"></div>';
144149
},
145150
_buttonHtml: function() {
146-
return '<a class="ui-spinner-button ui-spinner-up ui-state-default ui-corner-t' + this.options.dir.substr(-1,1) +
151+
return '<a class="ui-spinner-button ui-spinner-up ui-corner-t' + this.options.dir.substr(-1,1) +
147152
'"><span class="ui-icon ui-icon-triangle-1-n">&#9650;</span></a>' +
148-
'<a class="ui-spinner-button ui-spinner-down ui-state-default ui-corner-b' + this.options.dir.substr(-1,1) +
153+
'<a class="ui-spinner-button ui-spinner-down ui-corner-b' + this.options.dir.substr(-1,1) +
149154
'"><span class="ui-icon ui-icon-triangle-1-s">&#9660;</span></a>';
150155
},
151156
_start: function(event) {

0 commit comments

Comments
 (0)