Remove dependency on Mousetrap
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -2,16 +2,6 @@ Kanboard.BoardCollapsedMode = function(app) {
|
||||
this.app = app;
|
||||
};
|
||||
|
||||
Kanboard.BoardCollapsedMode.prototype.keyboardShortcuts = function() {
|
||||
var self = this;
|
||||
|
||||
if (self.app.hasId("board")) {
|
||||
Mousetrap.bind("s", function() {
|
||||
self.toggle();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Kanboard.BoardCollapsedMode.prototype.toggle = function() {
|
||||
var self = this;
|
||||
this.app.showLoadingIcon();
|
||||
|
||||
@@ -17,16 +17,6 @@ Kanboard.BoardHorizontalScrolling.prototype.listen = function() {
|
||||
});
|
||||
};
|
||||
|
||||
Kanboard.BoardHorizontalScrolling.prototype.keyboardShortcuts = function() {
|
||||
var self = this;
|
||||
|
||||
if (self.app.hasId("board")) {
|
||||
Mousetrap.bind("c", function () {
|
||||
self.toggle();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Kanboard.BoardHorizontalScrolling.prototype.onBoardRendered = function() {
|
||||
this.render();
|
||||
};
|
||||
|
||||
@@ -17,13 +17,3 @@ Kanboard.BoardTask.prototype.listen = function() {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Kanboard.BoardTask.prototype.keyboardShortcuts = function() {
|
||||
var self = this;
|
||||
|
||||
if (self.app.hasId("board")) {
|
||||
Mousetrap.bind("n", function () {
|
||||
self.app.get("Popover").open($("#board").data("task-creation-url"));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,60 +38,3 @@ Kanboard.Search.prototype.listen = function() {
|
||||
$("form.search").submit();
|
||||
});
|
||||
};
|
||||
|
||||
Kanboard.Search.prototype.goToView = function(label) {
|
||||
var link = $(label);
|
||||
|
||||
if (link.length) {
|
||||
window.location = link.attr('href');
|
||||
}
|
||||
};
|
||||
|
||||
Kanboard.Search.prototype.keyboardShortcuts = function() {
|
||||
var self = this;
|
||||
|
||||
// Switch view mode for projects: go to the overview page
|
||||
Mousetrap.bind("v o", function() {
|
||||
self.goToView(".view-overview");
|
||||
});
|
||||
|
||||
// Switch view mode for projects: go to the board
|
||||
Mousetrap.bind("v b", function() {
|
||||
self.goToView(".view-board");
|
||||
});
|
||||
|
||||
// Switch view mode for projects: go to the calendar
|
||||
Mousetrap.bind("v c", function() {
|
||||
self.goToView(".view-calendar");
|
||||
});
|
||||
|
||||
// Switch view mode for projects: go to the listing
|
||||
Mousetrap.bind("v l", function() {
|
||||
self.goToView(".view-listing");
|
||||
});
|
||||
|
||||
// Switch view mode for projects: go to the gantt chart
|
||||
Mousetrap.bind("v g", function() {
|
||||
self.goToView(".view-gantt");
|
||||
});
|
||||
|
||||
// Focus to the search field
|
||||
Mousetrap.bind("f", function(e) {
|
||||
e.preventDefault();
|
||||
var input = document.getElementById("form-search");
|
||||
|
||||
if (input) {
|
||||
input.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Reset to the search field
|
||||
Mousetrap.bind("r", function(e) {
|
||||
e.preventDefault();
|
||||
var reset = $(".filter-reset").data("filter");
|
||||
var input = $("#form-search");
|
||||
|
||||
input.val(reset);
|
||||
$("form.search").submit();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,29 +2,6 @@ Kanboard.Task = function(app) {
|
||||
this.app = app;
|
||||
};
|
||||
|
||||
Kanboard.Task.prototype.keyboardShortcuts = function() {
|
||||
var taskView = $("#task-view");
|
||||
var self = this;
|
||||
|
||||
if (this.app.hasId("task-view")) {
|
||||
Mousetrap.bind("e", function() {
|
||||
self.app.get("Popover").open(taskView.data("edit-url"));
|
||||
});
|
||||
|
||||
Mousetrap.bind("c", function() {
|
||||
self.app.get("Popover").open(taskView.data("comment-url"));
|
||||
});
|
||||
|
||||
Mousetrap.bind("s", function() {
|
||||
self.app.get("Popover").open(taskView.data("subtask-url"));
|
||||
});
|
||||
|
||||
Mousetrap.bind("l", function() {
|
||||
self.app.get("Popover").open(taskView.data("internal-link-url"));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Kanboard.Task.prototype.onPopoverOpened = function() {
|
||||
var self = this;
|
||||
var reloadingProjectId = 0;
|
||||
|
||||
Reference in New Issue
Block a user