Remove dependency on Mousetrap

This commit is contained in:
Frederic Guillot
2016-12-30 20:14:36 -05:00
parent e1344e3e44
commit ff79ec72c1
20 changed files with 348 additions and 202 deletions

View File

@@ -23,52 +23,15 @@ Kanboard.App.prototype.execute = function() {
if (typeof controller.focus === "function") {
controller.focus();
}
if (typeof controller.keyboardShortcuts === "function") {
controller.keyboardShortcuts();
}
}
}
this.focus();
this.keyboardShortcuts();
this.datePicker();
this.autoComplete();
this.tagAutoComplete();
};
Kanboard.App.prototype.keyboardShortcuts = function() {
var self = this;
// Submit form
Mousetrap.bindGlobal("mod+enter", function() {
var forms = $("form");
if (forms.length == 1) {
forms.submit();
} else if (forms.length > 1) {
if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') {
$(document.activeElement).parents("form").submit();
} else if (self.get("Popover").isOpen()) {
$("#popover-container form").submit();
}
}
});
// Close popover and dropdown
Mousetrap.bindGlobal("esc", function() {
if (! document.getElementById('suggest-menu')) {
self.get("Popover").close();
self.get("Dropdown").close();
}
});
// Show keyboard shortcut
Mousetrap.bind("?", function() {
self.get("Popover").open($("body").data("keyboard-shortcut-url"));
});
};
Kanboard.App.prototype.focus = function() {
// Auto-select input fields
$(document).on('focus', '.auto-select', function() {