aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCa-Phun Ung <pazu2k@gmail.com>2008-09-23 07:58:29 +0000
committerCa-Phun Ung <pazu2k@gmail.com>2008-09-23 07:58:29 +0000
commitb5ce43ac6afa4b78b33164a10da4c6c12e83473a (patch)
tree65fd175d0d7ca1d84ce11cb18852651449e483a6
parent6d39f52942a6c75458c9f1eb828ae1d567e0f742 (diff)
downloadjquery-ui-b5ce43ac6afa4b78b33164a10da4c6c12e83473a.tar.gz
jquery-ui-b5ce43ac6afa4b78b33164a10da4c6c12e83473a.zip
Spinner: Add change event to dblclick and created a new visual test for all callbacks. timer is now set to 0 after being cleared.
-rw-r--r--tests/visual/spinner.html50
-rw-r--r--ui/ui.spinner.js12
2 files changed, 57 insertions, 5 deletions
diff --git a/tests/visual/spinner.html b/tests/visual/spinner.html
index c3f12ad29..438ce110e 100644
--- a/tests/visual/spinner.html
+++ b/tests/visual/spinner.html
@@ -10,6 +10,17 @@
<script type="text/javascript">
$(function(){
+
+ if(!window.console) {
+ $('#log').css({overflow:'auto',width:'300px',height:'100px',fontSize:'10px',border:'2px inset #ccc',backgroundColor:'#f4f4f4'});
+ window.console = {
+ log: function() {
+ $('#log').append(arguments[0]+"<br>");
+ $('#log').scrollTop(999999);
+ }
+ };
+ }
+
var itemList = [
{url: "http://ejohn.org", title: "John Resig"},
{url: "http://bassistance.de/", title: "J&ouml;rn Zaefferer"},
@@ -45,6 +56,24 @@ $(function(){
// method 2: use the format and items options in combination
format: '%(title) <a href="%(url)" target="_blank">&raquo;</a>',
items: itemList
+ },
+ // callbacks
+ 's6': {
+ init: function(e, ui) {
+ console.log('init: '+ ui.value);
+ },
+ up: function(e, ui) {
+ console.log('up: '+ ui.value);
+ },
+ down: function(e, ui) {
+ console.log('down: '+ ui.value);
+ },
+ spin: function(e, ui) {
+ console.log('spin: '+ ui.value);
+ },
+ change: function(e, ui) {
+ console.log('change: '+ ui.value);
+ }
}
};
@@ -58,6 +87,7 @@ $(function(){
});
});
+
</script>
<style type="text/css">
@@ -178,6 +208,7 @@ label {
<hr />
+
<p><label for="s4">Data List: </label>
<ul id="s4">
<li>item 1</li>
@@ -200,7 +231,7 @@ label {
<li>item 18</li>
<li>item 19</li>
<li>item 20</li>
-</ul>
+</ul></p>
<p>
<button id="s4-disable">disable</button>
@@ -211,8 +242,8 @@ label {
<hr />
-<p><label for="s5">Presenters: </label>
-<div id="s5"></div>
+<div><label for="s5">Presenters: </label>
+<div id="s5"></div></div>
<p>
<button id="s5-disable">disable</button>
@@ -223,6 +254,19 @@ label {
<hr />
+<p><label for="s6">Callbacks: </label>
+<input type="text" id="s6" /></p>
+
+<p>
+<button id="s6-disable">disable</button>
+<button id="s6-enable">enable</button>
+<button id="s6-destroy">destroy</button>
+<button id="s6-create">create</button>
+</p>
+
+<div id="log"></div>
+
+<hr />
</body>
</html> \ No newline at end of file
diff --git a/ui/ui.spinner.js b/ui/ui.spinner.js
index b9fa7a1b3..cbce210e8 100644
--- a/ui/ui.spinner.js
+++ b/ui/ui.spinner.js
@@ -61,12 +61,15 @@ $.widget('ui.spinner', {
})
.bind('mouseout', function(e) {
$(this).removeClass('ui-spinner-pressed');
- self._mouseup(e);
+ if (self.timer) {
+ self._mouseup(e);
+ }
})
// mousedown/mouseup capture first click, now handle second click
.bind('dblclick', function(e) {
$(this).removeClass('ui-spinner-pressed');
self._up(e);
+ self._mouseup(e);
})
.bind('keydown.spinner', function(e) {
var KEYS = $.keyCode;
@@ -106,12 +109,15 @@ $.widget('ui.spinner', {
})
.bind('mouseout', function(e) {
$(this).removeClass('ui-spinner-pressed');
- self._mouseup(e);
+ if (self.timer) {
+ self._mouseup(e);
+ }
})
// mousedown/mouseup capture first click, now handle second click
.bind('dblclick', function(e) {
$(this).removeClass('ui-spinner-pressed');
self._down(e);
+ self._mouseup(e);
})
.bind('keydown.spinner', function(e) {
var KEYS = $.keyCode;
@@ -215,6 +221,7 @@ $.widget('ui.spinner', {
i = i || 100;
if (this.timer) {
window.clearInterval(this.timer);
+ this.timer = 0;
}
this.timer = window.setInterval(function() {
self[d](e);
@@ -227,6 +234,7 @@ $.widget('ui.spinner', {
this.counter = 0;
if (this.timer) {
window.clearInterval(this.timer);
+ this.timer = 0;
}
this.element[0].focus();
this._propagate('change', e);