Permalink
Browse files

fixing bug that prevents user from input values by keyboard

also fixed limit the keyboard input to min/max
  • Loading branch information...
1 parent 66921ff commit 35e53f586295871450624c79d32addd10eaa9ce9 @eskimoblood eskimoblood committed May 11, 2012
Showing with 16 additions and 4 deletions.
  1. +16 −4 js/jquery.knob-1.1.0.js
View
@@ -189,8 +189,18 @@ $(function() {
var keys={37: -1, 38:1, 39:1, 40: -1}
$this.keydown(function(event){
- setVal( keys[event.keyCode]);
- event.preventDefault();
+ var direction = keys[event.keyCode];
+ if(direction){
+ setVal(direction);
+ event.preventDefault();
+ }
+ });
+
+ $this.keyup(function(event){
+ var direction = keys[event.keyCode];
+ if(!direction) {
+ setVal();
+ }
});
$this.bind('mousewheel DOMMouseScroll', function(event){
@@ -202,8 +212,10 @@ $(function() {
});
function setVal(dir){
- if(dir){
- k.val( (limitValue(parseInt($this.val()) + dir) ));
+ if(!opt.readOnly) {
+ var value = limitValue(parseInt($this.val(), 10) + (dir ? dir: 0));
+ $this.val(value)
+ k.val( parseInt(value, 10) || 0);
}
}

0 comments on commit 35e53f5

Please sign in to comment.