@@ -51,16 +51,20 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {};
5151 **/
5252 _attachEvents : function ( ) {
5353 var _updateModelProxy = $ . proxy ( this . _updateModel , this ) ,
54+ _updateInputProxy = $ . proxy ( this . _updateInput , this ) ,
5455 container = this . container ,
55- selectors = [ '.position' ,
56- '.size' ,
57- '.base_color' ,
58- '.border_width' ,
59- '.border_color'
56+ selectors = [ { classname : '.position' , keyboard_interactive : false } ,
57+ { classname : '.size' , keyboard_interactive : true } ,
58+ { classname : '.base_color' , keyboard_interactive : false } ,
59+ { classname : '.border_width' , keyboard_interactive : true } ,
60+ { classname : '.border_color' , keyboard_interactive : false }
6061 ] ;
6162
6263 $ . each ( selectors , function ( i , selector ) {
63- container . delegate ( selector , 'change' , _updateModelProxy ) ;
64+ container . delegate ( selector . classname , 'change' , _updateModelProxy ) ;
65+ if ( selector . keyboard_interactive ) {
66+ container . delegate ( selector . classname , 'keydown' , _updateInputProxy ) ;
67+ }
6468 } ) ;
6569 } ,
6670
@@ -85,6 +89,18 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {};
8589
8690 if ( attr === 'borderWidth' || attr === 'size' ) val = parseInt ( val , 10 ) ;
8791 this . model . set ( attr , val ) ;
92+ } ,
93+
94+ _updateInput : function ( ev ) {
95+ if ( ev . keyCode != 38 && ev . keyCode != 40 ) return ;
96+
97+ var target = $ ( ev . currentTarget ) ,
98+ val = parseInt ( target . val ( ) ) ,
99+ increment = ev . keyCode == 38 ? 1 : - 1 ,
100+ multiply = ev . shiftKey ? 10 : 1
101+
102+ target . val ( val + increment * multiply ) ;
103+ this . _updateModel ( ev )
88104 }
89105
90106 } ;
0 commit comments