Skip to content

Commit 36758cf

Browse files
committed
Add keydown event for size & border_width inputs
- Up arrow increase by 1 (10 w/ shift) - Down arrow decrease by 1 (10 w/ shift)
1 parent 1b4fb74 commit 36758cf

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

public/js/lib/views/arrow_configuration_view.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)