Create a function for the event handlers of the keypress tab.

This commit is contained in:
Arpad Csanyi
2016-02-11 00:08:12 +01:00
parent 7f04de545b
commit 16232388e3

View File

@@ -310,35 +310,39 @@ $(function() {
var contentTemplate = Handlebars.compile(contentSource);
$('#key-editor-content__target').html(contentTemplate(contentContext[tplName]));
initSelect2items();
_keypress_event_handlers();
});
$('.modifiers').on('click', 'button', function() {
$(this).toggleClass('btn-primary').blur();
});
$('.btn--capture-keystroke').on('click', function(e) {
$('.btn--capture-keystroke').toggle();
_toggleScancodeForm();
});
var _keypress_event_handlers = function() {
$('.modifiers').on('click', 'button', function() {
$(this).toggleClass('btn-primary').blur();
});
$('.layer-action--buttons').on('click', '.layer-key', function(e) {
console.log('helllo');
$this = $(this);
$('.layer-key.btn-primary', '.layer-action--buttons').removeClass('btn-primary');
$this.addClass('btn-primary').blur();
if ($this.hasClass('layer-key--disabled')) {
// Enable all form controls in .global-key-setup
$('button, select', '.global-key-setup').prop('disabled', false);
$('.global-key-setup').removeClass('disabled');
$('.disabled-state--text').hide();
}
else {
// Disable all form controls in .global-key-setup
$('button, select', '.global-key-setup').prop('disabled', true);
$('.global-key-setup').addClass('disabled');
$('.disabled-state--text').show();
}
});
$('.btn--capture-keystroke').on('click', function(e) {
$('.btn--capture-keystroke').toggle();
_toggleScancodeForm();
});
$('.layer-action--buttons').on('click', '.layer-key', function(e) {
$this = $(this);
$('.layer-key.btn-primary', '.layer-action--buttons').removeClass('btn-primary');
$this.addClass('btn-primary').blur();
if ($this.hasClass('layer-key--disabled')) {
// Enable all form controls in .global-key-setup
$('button, select', '.global-key-setup').prop('disabled', false);
$('.global-key-setup').removeClass('disabled');
$('.disabled-state--text').hide();
}
else {
// Disable all form controls in .global-key-setup
$('button, select', '.global-key-setup').prop('disabled', true);
$('.global-key-setup').addClass('disabled');
$('.disabled-state--text').show();
}
});
};
_keypress_event_handlers();
});