mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
Using button widget for the spinner buttons. Can still use some improvements, dropping custom theme stuff in favor of button styles.
This commit is contained in:
parent
bc3d283d2c
commit
eebf8c31ff
33
ui/jquery.ui.spinner.js
vendored
33
ui/jquery.ui.spinner.js
vendored
@ -101,16 +101,18 @@ $.widget('ui.spinner', {
|
|||||||
// button bindings
|
// button bindings
|
||||||
this.buttons = uiSpinner.find('.ui-spinner-button')
|
this.buttons = uiSpinner.find('.ui-spinner-button')
|
||||||
.attr("tabIndex", -1)
|
.attr("tabIndex", -1)
|
||||||
|
.button()
|
||||||
|
.first()
|
||||||
|
.removeClass("ui-corner-all")
|
||||||
|
.end()
|
||||||
|
.last()
|
||||||
|
.removeClass("ui-corner-all")
|
||||||
|
.end()
|
||||||
.bind('mousedown', function(event) {
|
.bind('mousedown', function(event) {
|
||||||
if (self._start(event) === false) {
|
if (self._start(event) === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
self._repeat(null, $(this).hasClass('ui-spinner-up') ? 1 : -1, event);
|
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) {
|
.bind('mouseup', function(event) {
|
||||||
if (self.counter == 1) {
|
if (self.counter == 1) {
|
||||||
@ -120,19 +122,22 @@ $.widget('ui.spinner', {
|
|||||||
self._stop(event);
|
self._stop(event);
|
||||||
self._change(event);
|
self._change(event);
|
||||||
}
|
}
|
||||||
$(this).removeClass(active);
|
|
||||||
})
|
})
|
||||||
.hover(function() {
|
.bind("mouseenter", function() {
|
||||||
if (!self.options.disabled) {
|
// button will add ui-state-active if mouse was down while mouseleave and kept down
|
||||||
$(this).addClass(hover);
|
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) {
|
if (self.timer && self.spinning) {
|
||||||
self._stop(event);
|
self._stop(event);
|
||||||
self._change(event);
|
self._change(event);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
self.uiSpinner = uiSpinner;
|
self.uiSpinner = uiSpinner;
|
||||||
},
|
},
|
||||||
@ -143,9 +148,9 @@ $.widget('ui.spinner', {
|
|||||||
'"></div>';
|
'"></div>';
|
||||||
},
|
},
|
||||||
_buttonHtml: function() {
|
_buttonHtml: function() {
|
||||||
return '<a class="ui-spinner-button ui-spinner-up ui-state-default ui-corner-t' + this.options.dir.substr(-1,1) +
|
return '<a class="ui-spinner-button ui-spinner-up ui-corner-t' + this.options.dir.substr(-1,1) +
|
||||||
'"><span class="ui-icon ui-icon-triangle-1-n">▲</span></a>' +
|
'"><span class="ui-icon ui-icon-triangle-1-n">▲</span></a>' +
|
||||||
'<a class="ui-spinner-button ui-spinner-down ui-state-default ui-corner-b' + this.options.dir.substr(-1,1) +
|
'<a class="ui-spinner-button ui-spinner-down ui-corner-b' + this.options.dir.substr(-1,1) +
|
||||||
'"><span class="ui-icon ui-icon-triangle-1-s">▼</span></a>';
|
'"><span class="ui-icon ui-icon-triangle-1-s">▼</span></a>';
|
||||||
},
|
},
|
||||||
_start: function(event) {
|
_start: function(event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user