r739 - in trunk: tests/visual ui
Author: pazu2k@gmail.com
Date: Tue Sep 23 00:58:29 2008
New Revision: 739
Modified:
trunk/tests/visual/spinner.html
trunk/ui/ui.spinner.js
Log:
Spinner: Add change event to dblclick and created a new visual test for all
callbacks. timer is now set to 0 after being cleared.
Modified: trunk/tests/visual/spinner.html
==============================================================================
--- trunk/tests/visual/spinner.html (original)
+++ trunk/tests/visual/spinner.html Tue Sep 23 00:58:29 2008
@@ -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]+"
");
+ $('#log').scrollTop(999999);
+ }
+ };
+ }
+
var itemList = [
{url: "http://ejohn.org", title: "John Resig"},
{url: "http://bassistance.de/", title: "Jörn Zaefferer"},
@@ -45,6 +56,24 @@
// method 2: use the format and items options in combination
format: '%(title) <a href="%(url)" target="_blank">»</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 @@
<hr />
+
<label for="s4">Data List: </label>
<ul id="s4">
<li>item 1</li>
@@ -200,7 +231,7 @@
<li>item 18</li>
<li>item 19</li>
<li>item 20</li>
-</ul>
+</ul>
<button id="s4-disable">disable</button>
@@ -211,8 +242,8 @@
<hr />
-
<label for="s5">Presenters: </label>
-<div id="s5"></div>
+<div><label for="s5">Presenters: </label>
+<div id="s5"></div></div>
<button id="s5-disable">disable</button>
@@ -223,6 +254,19 @@
<hr />
+
<label for="s6">Callbacks: </label>
+<input type="text" id="s6" />
+
+
+<button id="s6-disable">disable</button>
+<button id="s6-enable">enable</button>
+<button id="s6-destroy">destroy</button>
+<button id="s6-create">create</button>
+
+
+<div id="log"></div>
+
+<hr />
</body>
</html>
Modified: trunk/ui/ui.spinner.js
==============================================================================
--- trunk/ui/ui.spinner.js (original)
+++ trunk/ui/ui.spinner.js Tue Sep 23 00:58:29 2008
@@ -61,12 +61,15 @@
})
.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 @@
})
.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 @@
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 @@
this.counter = 0;
if (this.timer) {
window.clearInterval(this.timer);
+ this.timer = 0;
}
this.element[0].focus();
this._propagate('change', e);