Skip to content
Permalink
Browse files

Spinner: Add change event to dblclick and created a new visual test f…

…or all callbacks. timer is now set to 0 after being cleared.
  • Loading branch information...
Ca-Phun Ung
Ca-Phun Ung committed Sep 23, 2008
1 parent 6d39f52 commit b5ce43ac6afa4b78b33164a10da4c6c12e83473a
Showing with 57 additions and 5 deletions.
  1. +47 −3 tests/visual/spinner.html
  2. +10 −2 ui/ui.spinner.js
@@ -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 @@
// 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 @@
});
});
</script>

<style type="text/css">
@@ -178,6 +208,7 @@ <h1>jQuery UI Spinner Test Page</h1>

<hr />


<p><label for="s4">Data List: </label>
<ul id="s4">
<li>item 1</li>
@@ -200,7 +231,7 @@ <h1>jQuery UI Spinner Test Page</h1>
<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 @@ <h1>jQuery UI Spinner Test Page</h1>

<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 @@ <h1>jQuery UI Spinner Test Page</h1>

<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>
@@ -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);

0 comments on commit b5ce43a

Please sign in to comment.
You can’t perform that action at this time.