Added Markdown editor and Javascript code refactoring

This commit is contained in:
Frederic Guillot
2016-03-20 15:45:02 -04:00
parent 787e91ca41
commit f77d6c590b
64 changed files with 1154 additions and 3644 deletions

View File

@@ -1,18 +1,21 @@
function Search(app) {
Kanboard.Search = function(app) {
this.app = app;
this.keyboardShortcuts();
}
};
Kanboard.Search.prototype.focus = function() {
Search.prototype.focus = function() {
// Place cursor at the end when focusing on the search box
$(document).on("focus", "#form-search", function() {
if ($("#form-search")[0].setSelectionRange) {
$('#form-search')[0].setSelectionRange($('#form-search').val().length, $('#form-search').val().length);
var input = $("#form-search");
if (input[0].setSelectionRange) {
var len = input.val().length * 2;
input[0].setSelectionRange(len, len);
}
});
};
Search.prototype.listen = function() {
Kanboard.Search.prototype.listen = function() {
var self = this;
// Filter helper for search
@@ -21,68 +24,51 @@ Search.prototype.listen = function() {
var filter = $(this).data("filter");
var appendFilter = $(this).data("append-filter");
var input = $("#form-search");
if (appendFilter) {
filter = $("#form-search").val() + " " + appendFilter;
filter = input.val() + " " + appendFilter;
}
$("#form-search").val(filter);
if ($('#board').length) {
self.app.board.reloadFilters(filter);
}
else {
$("form.search").submit();
}
input.val(filter);
$("form.search").submit();
});
};
Search.prototype.keyboardShortcuts = function() {
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(e) {
var link = $(".view-overview");
if (link.length) {
window.location = link.attr('href');
}
Mousetrap.bind("v o", function() {
self.goToView(".view-overview");
});
// Switch view mode for projects: go to the board
Mousetrap.bind("v b", function(e) {
var link = $(".view-board");
if (link.length) {
window.location = link.attr('href');
}
Mousetrap.bind("v b", function() {
self.goToView(".view-board");
});
// Switch view mode for projects: go to the calendar
Mousetrap.bind("v c", function(e) {
var link = $(".view-calendar");
if (link.length) {
window.location = link.attr('href');
}
Mousetrap.bind("v c", function() {
self.goToView(".view-calendar");
});
// Switch view mode for projects: go to the listing
Mousetrap.bind("v l", function(e) {
var link = $(".view-listing");
if (link.length) {
window.location = link.attr('href');
}
Mousetrap.bind("v l", function() {
self.goToView(".view-listing");
});
// Switch view mode for projects: go to the gantt chart
Mousetrap.bind("v g", function(e) {
var link = $(".view-gantt");
if (link.length) {
window.location = link.attr('href');
}
Mousetrap.bind("v g", function() {
self.goToView(".view-gantt");
});
// Focus to the search field
@@ -99,14 +85,9 @@ Search.prototype.keyboardShortcuts = function() {
Mousetrap.bind("r", function(e) {
e.preventDefault();
var reset = $(".filter-reset").data("filter");
var input = $("#form-search");
$("#form-search").val(reset);
if ($('#board').length) {
self.app.board.reloadFilters(reset);
}
else {
$("form.search").submit();
}
input.val(reset);
$("form.search").submit();
});
};