summaryrefslogtreecommitdiff
path: root/assets/js/src
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/src')
-rw-r--r--assets/js/src/Accordion.js18
-rw-r--r--assets/js/src/App.js83
-rw-r--r--assets/js/src/AvgTimeColumnChart.js47
-rw-r--r--assets/js/src/BoardCollapsedMode.js10
-rw-r--r--assets/js/src/BoardColumnScrolling.js85
-rw-r--r--assets/js/src/BoardDragAndDrop.js25
-rw-r--r--assets/js/src/BoardHorizontalScrolling.js10
-rw-r--r--assets/js/src/BoardTask.js13
-rw-r--r--assets/js/src/Bootstrap.js6
-rw-r--r--assets/js/src/BurndownChart.js56
-rw-r--r--assets/js/src/Calendar.js55
-rw-r--r--assets/js/src/CompareHoursColumnChart.js46
-rw-r--r--assets/js/src/CumulativeFlowDiagram.js55
-rw-r--r--assets/js/src/Dropdown.js5
-rw-r--r--assets/js/src/FileUpload.js125
-rw-r--r--assets/js/src/LeadCycleTimeChart.js53
-rw-r--r--assets/js/src/Markdown.js59
-rw-r--r--assets/js/src/Namespace.js2
-rw-r--r--assets/js/src/Notification.js9
-rw-r--r--assets/js/src/Popover.js151
-rw-r--r--assets/js/src/ProjectCreation.js15
-rw-r--r--assets/js/src/ProjectPermission.js19
-rw-r--r--assets/js/src/Screenshot.js134
-rw-r--r--assets/js/src/Search.js58
-rw-r--r--assets/js/src/Session.js21
-rw-r--r--assets/js/src/Task.js48
-rw-r--r--assets/js/src/TaskRepartitionChart.js25
-rw-r--r--assets/js/src/TaskTimeColumnChart.js47
-rw-r--r--assets/js/src/UserRepartitionChart.js25
29 files changed, 31 insertions, 1274 deletions
diff --git a/assets/js/src/Accordion.js b/assets/js/src/Accordion.js
deleted file mode 100644
index f05dc5ff..00000000
--- a/assets/js/src/Accordion.js
+++ /dev/null
@@ -1,18 +0,0 @@
-Kanboard.Accordion = function(app) {
- this.app = app;
-};
-
-Kanboard.Accordion.prototype.listen = function() {
- $(document).on("click", ".accordion-toggle", function(e) {
- var section = $(this).parents(".accordion-section");
- e.preventDefault();
-
- if (section.hasClass("accordion-collapsed")) {
- section.find(".accordion-content").show();
- section.removeClass("accordion-collapsed");
- } else {
- section.find(".accordion-content").hide();
- section.addClass("accordion-collapsed");
- }
- });
-};
diff --git a/assets/js/src/App.js b/assets/js/src/App.js
index b85d5d3c..9aa97061 100644
--- a/assets/js/src/App.js
+++ b/assets/js/src/App.js
@@ -23,57 +23,15 @@ Kanboard.App.prototype.execute = function() {
if (typeof controller.focus === "function") {
controller.focus();
}
-
- if (typeof controller.keyboardShortcuts === "function") {
- controller.keyboardShortcuts();
- }
}
}
this.focus();
- this.chosen();
- 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();
- }
- }
- });
-
- // Open board selector
- Mousetrap.bind("b", function(e) {
- e.preventDefault();
- $('#board-selector').trigger('chosen:open');
- });
-
- // Close popover and dropdown
- Mousetrap.bindGlobal("esc", function() {
- 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() {
@@ -86,27 +44,6 @@ Kanboard.App.prototype.focus = function() {
});
};
-Kanboard.App.prototype.chosen = function() {
- $(".chosen-select").each(function() {
- var searchThreshold = $(this).data("search-threshold");
-
- if (searchThreshold === undefined) {
- searchThreshold = 10;
- }
-
- $(this).chosen({
- width: "180px",
- no_results_text: $(this).data("notfound"),
- disable_search_threshold: searchThreshold
- });
- });
-
- $(".select-auto-redirect").change(function() {
- var regex = new RegExp($(this).data('redirect-regex'), 'g');
- window.location = $(this).data('redirect-url').replace(regex, $(this).val());
- });
-};
-
Kanboard.App.prototype.datePicker = function() {
var bodyElement = $("body");
var dateFormat = bodyElement.data("js-date-format");
@@ -135,7 +72,7 @@ Kanboard.App.prototype.datePicker = function() {
Kanboard.App.prototype.tagAutoComplete = function() {
$(".tag-autocomplete").select2({
tags: true
- })
+ });
};
Kanboard.App.prototype.autoComplete = function() {
@@ -144,7 +81,7 @@ Kanboard.App.prototype.autoComplete = function() {
var field = input.data("dst-field");
var extraField = input.data("dst-extra-field");
- if ($('#form-' + field).val() == '') {
+ if ($('#form-' + field).val() === '') {
input.parent().find("button[type=submit]").attr('disabled','disabled');
}
@@ -176,20 +113,6 @@ Kanboard.App.prototype.hideLoadingIcon = function() {
$("#app-loading-icon").remove();
};
-Kanboard.App.prototype.formatDuration = function(d) {
- if (d >= 86400) {
- return Math.round(d/86400) + "d";
- }
- else if (d >= 3600) {
- return Math.round(d/3600) + "h";
- }
- else if (d >= 60) {
- return Math.round(d/60) + "m";
- }
-
- return d + "s";
-};
-
Kanboard.App.prototype.isVisible = function() {
var property = "";
@@ -203,7 +126,7 @@ Kanboard.App.prototype.isVisible = function() {
property = "webkitVisibilityState";
}
- if (property != "") {
+ if (property !== "") {
return document[property] == "visible";
}
diff --git a/assets/js/src/AvgTimeColumnChart.js b/assets/js/src/AvgTimeColumnChart.js
deleted file mode 100644
index 803aa2c2..00000000
--- a/assets/js/src/AvgTimeColumnChart.js
+++ /dev/null
@@ -1,47 +0,0 @@
-Kanboard.AvgTimeColumnChart = function(app) {
- this.app = app;
-};
-
-Kanboard.AvgTimeColumnChart.prototype.execute = function() {
- if (this.app.hasId("analytic-avg-time-column")) {
- this.show();
- }
-};
-
-Kanboard.AvgTimeColumnChart.prototype.show = function() {
- var chart = $("#chart");
- var metrics = chart.data("metrics");
- var plots = [chart.data("label")];
- var categories = [];
-
- for (var column_id in metrics) {
- plots.push(metrics[column_id].average);
- categories.push(metrics[column_id].title);
- }
-
- c3.generate({
- data: {
- columns: [plots],
- type: 'bar'
- },
- bar: {
- width: {
- ratio: 0.5
- }
- },
- axis: {
- x: {
- type: 'category',
- categories: categories
- },
- y: {
- tick: {
- format: this.app.formatDuration
- }
- }
- },
- legend: {
- show: false
- }
- });
-};
diff --git a/assets/js/src/BoardCollapsedMode.js b/assets/js/src/BoardCollapsedMode.js
index 8365d3fb..1be7a150 100644
--- a/assets/js/src/BoardCollapsedMode.js
+++ b/assets/js/src/BoardCollapsedMode.js
@@ -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();
diff --git a/assets/js/src/BoardColumnScrolling.js b/assets/js/src/BoardColumnScrolling.js
deleted file mode 100644
index e637180d..00000000
--- a/assets/js/src/BoardColumnScrolling.js
+++ /dev/null
@@ -1,85 +0,0 @@
-Kanboard.BoardColumnScrolling = function(app) {
- this.app = app;
-};
-
-Kanboard.BoardColumnScrolling.prototype.execute = function() {
- if (this.app.hasId("board")) {
- this.render();
-
- $(window).on("load", this.render);
- $(window).resize(this.render);
- }
-};
-
-Kanboard.BoardColumnScrolling.prototype.listen = function() {
- var self = this;
-
- $(document).on('click', ".filter-toggle-height", function(e) {
- e.preventDefault();
- self.toggle();
- });
-};
-
-Kanboard.BoardColumnScrolling.prototype.onBoardRendered = function() {
- this.render();
-};
-
-Kanboard.BoardColumnScrolling.prototype.toggle = function() {
- var scrolling = localStorage.getItem("column_scroll");
-
- if (scrolling == undefined) {
- scrolling = 1;
- }
-
- localStorage.setItem("column_scroll", scrolling == 0 ? 1 : 0);
- this.render();
-};
-
-Kanboard.BoardColumnScrolling.prototype.render = function() {
- var taskList = $(".board-task-list");
- var rotationWrapper = $(".board-rotation-wrapper");
- var filterMax = $(".filter-max-height");
- var filterMin = $(".filter-min-height");
-
- if (localStorage.getItem("column_scroll") == 0) {
- var height = 80;
-
- filterMax.show();
- filterMin.hide();
- rotationWrapper.css("min-height", '');
-
- taskList.each(function() {
- var columnHeight = $(this).height();
-
- if (columnHeight > height) {
- height = columnHeight;
- }
- });
-
- taskList.css("min-height", height);
- taskList.css("height", '');
- }
- else {
-
- filterMax.hide();
- filterMin.show();
-
- if ($(".board-swimlane").length > 1) {
- taskList.each(function() {
- if ($(this).height() > 500) {
- $(this).css("height", 500);
- }
- else {
- $(this).css("min-height", 320); // Height of the dropdown menu
- rotationWrapper.css("min-height", 320);
- }
- });
- }
- else {
- var height = $(window).height() - 170;
-
- taskList.css("height", height);
- rotationWrapper.css("min-height", height);
- }
- }
-};
diff --git a/assets/js/src/BoardDragAndDrop.js b/assets/js/src/BoardDragAndDrop.js
index 4d2ae3ec..5d2844de 100644
--- a/assets/js/src/BoardDragAndDrop.js
+++ b/assets/js/src/BoardDragAndDrop.js
@@ -12,10 +12,11 @@ Kanboard.BoardDragAndDrop.prototype.execute = function() {
Kanboard.BoardDragAndDrop.prototype.dragAndDrop = function() {
var self = this;
+ var dropzone = $(".board-task-list");
var params = {
forcePlaceholderSize: true,
tolerance: "pointer",
- connectWith: ".board-task-list",
+ connectWith: ".sortable-column",
placeholder: "draggable-placeholder",
items: ".draggable-item",
stop: function(event, ui) {
@@ -33,7 +34,7 @@ Kanboard.BoardDragAndDrop.prototype.dragAndDrop = function() {
if (newColumnId != taskColumnId || newSwimlaneId != taskSwimlaneId || newPosition != taskPosition) {
self.changeTaskState(taskId);
- self.save(taskId, newColumnId, newPosition, newSwimlaneId);
+ self.save(taskId, taskColumnId, newColumnId, newPosition, newSwimlaneId);
}
},
start: function(event, ui) {
@@ -44,10 +45,15 @@ Kanboard.BoardDragAndDrop.prototype.dragAndDrop = function() {
if (isMobile.any) {
$(".task-board-sort-handle").css("display", "inline");
- params["handle"] = ".task-board-sort-handle";
+ params.handle = ".task-board-sort-handle";
}
- $(".board-task-list").sortable(params);
+ // Set dropzone height to the height of the table cell
+ dropzone.each(function() {
+ $(this).css("min-height", $(this).parent().height());
+ });
+
+ dropzone.sortable(params);
};
Kanboard.BoardDragAndDrop.prototype.changeTaskState = function(taskId) {
@@ -56,7 +62,7 @@ Kanboard.BoardDragAndDrop.prototype.changeTaskState = function(taskId) {
task.find('.task-board-saving-icon').show();
};
-Kanboard.BoardDragAndDrop.prototype.save = function(taskId, columnId, position, swimlaneId) {
+Kanboard.BoardDragAndDrop.prototype.save = function(taskId, srcColumnId, dstColumnId, position, swimlaneId) {
var self = this;
self.app.showLoadingIcon();
self.savingInProgress = true;
@@ -69,7 +75,8 @@ Kanboard.BoardDragAndDrop.prototype.save = function(taskId, columnId, position,
processData: false,
data: JSON.stringify({
"task_id": taskId,
- "column_id": columnId,
+ "src_column_id": srcColumnId,
+ "dst_column_id": dstColumnId,
"swimlane_id": swimlaneId,
"position": position
}),
@@ -80,6 +87,12 @@ Kanboard.BoardDragAndDrop.prototype.save = function(taskId, columnId, position,
error: function() {
self.app.hideLoadingIcon();
self.savingInProgress = false;
+ },
+ statusCode: {
+ 403: function(data) {
+ window.alert(data.responseJSON.message);
+ document.location.reload(true);
+ }
}
});
};
diff --git a/assets/js/src/BoardHorizontalScrolling.js b/assets/js/src/BoardHorizontalScrolling.js
index d4c3aaf3..cd4d0d76 100644
--- a/assets/js/src/BoardHorizontalScrolling.js
+++ b/assets/js/src/BoardHorizontalScrolling.js
@@ -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();
};
diff --git a/assets/js/src/BoardTask.js b/assets/js/src/BoardTask.js
index 2b8ac132..8a0577d9 100644
--- a/assets/js/src/BoardTask.js
+++ b/assets/js/src/BoardTask.js
@@ -2,13 +2,14 @@ Kanboard.BoardTask = function(app) {
this.app = app;
};
+// TODO: rewrite this code
Kanboard.BoardTask.prototype.listen = function() {
var self = this;
$(document).on("click", ".task-board-change-assignee", function(e) {
e.preventDefault();
e.stopPropagation();
- self.app.get("Popover").open($(this).data('url'));
+ KB.modal.open($(this).data("url"), "medium", false);
});
$(document).on("click", ".task-board", function(e) {
@@ -17,13 +18,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"));
- });
- }
-};
diff --git a/assets/js/src/Bootstrap.js b/assets/js/src/Bootstrap.js
index d5f3c7ef..94b1f2ca 100644
--- a/assets/js/src/Bootstrap.js
+++ b/assets/js/src/Bootstrap.js
@@ -1,4 +1,6 @@
+var _KB = null;
+
jQuery(document).ready(function() {
- var app = new Kanboard.App();
- app.execute();
+ _KB = new Kanboard.App();
+ _KB.execute();
});
diff --git a/assets/js/src/BurndownChart.js b/assets/js/src/BurndownChart.js
deleted file mode 100644
index 63231d3c..00000000
--- a/assets/js/src/BurndownChart.js
+++ /dev/null
@@ -1,56 +0,0 @@
-Kanboard.BurndownChart = function(app) {
- this.app = app;
-};
-
-Kanboard.BurndownChart.prototype.execute = function() {
- if (this.app.hasId("analytic-burndown")) {
- this.show();
- }
-};
-
-Kanboard.BurndownChart.prototype.show = function() {
- var chart = $("#chart");
- var metrics = chart.data("metrics");
- var columns = [[chart.data("label-total")]];
- var categories = [];
- var inputFormat = d3.time.format("%Y-%m-%d");
- var outputFormat = d3.time.format(chart.data("date-format"));
-
- for (var i = 0; i < metrics.length; i++) {
-
- for (var j = 0; j < metrics[i].length; j++) {
-
- if (i == 0) {
- columns.push([metrics[i][j]]);
- }
- else {
- columns[j + 1].push(metrics[i][j]);
-
- if (j > 0) {
-
- if (columns[0][i] == undefined) {
- columns[0].push(0);
- }
-
- columns[0][i] += metrics[i][j];
- }
-
- if (j == 0) {
- categories.push(outputFormat(inputFormat.parse(metrics[i][j])));
- }
- }
- }
- }
-
- c3.generate({
- data: {
- columns: columns
- },
- axis: {
- x: {
- type: 'category',
- categories: categories
- }
- }
- });
-};
diff --git a/assets/js/src/Calendar.js b/assets/js/src/Calendar.js
deleted file mode 100644
index 20079a38..00000000
--- a/assets/js/src/Calendar.js
+++ /dev/null
@@ -1,55 +0,0 @@
-Kanboard.Calendar = function(app) {
- this.app = app;
-};
-
-Kanboard.Calendar.prototype.execute = function() {
- var calendar = $('#calendar');
-
- if (calendar.length == 1) {
- this.show(calendar);
- }
-};
-
-Kanboard.Calendar.prototype.show = function(calendar) {
- calendar.fullCalendar({
- lang: $("body").data("js-lang"),
- editable: true,
- eventLimit: true,
- defaultView: "month",
- header: {
- left: 'prev,next today',
- center: 'title',
- right: 'month,agendaWeek,agendaDay'
- },
- eventDrop: function(event) {
- $.ajax({
- cache: false,
- url: calendar.data("save-url"),
- contentType: "application/json",
- type: "POST",
- processData: false,
- data: JSON.stringify({
- "task_id": event.id,
- "date_due": event.start.format()
- })
- });
- },
- viewRender: function() {
- var url = calendar.data("check-url");
- var params = {
- "start": calendar.fullCalendar('getView').start.format(),
- "end": calendar.fullCalendar('getView').end.format()
- };
-
- for (var key in params) {
- url += "&" + key + "=" + params[key];
- }
-
- $.getJSON(url, function(events) {
- calendar.fullCalendar('removeEvents');
- calendar.fullCalendar('addEventSource', events);
- calendar.fullCalendar('rerenderEvents');
- });
- }
- });
-};
diff --git a/assets/js/src/CompareHoursColumnChart.js b/assets/js/src/CompareHoursColumnChart.js
deleted file mode 100644
index 00786c67..00000000
--- a/assets/js/src/CompareHoursColumnChart.js
+++ /dev/null
@@ -1,46 +0,0 @@
-Kanboard.CompareHoursColumnChart = function(app) {
- this.app = app;
-};
-
-Kanboard.CompareHoursColumnChart.prototype.execute = function() {
- if (this.app.hasId("analytic-compare-hours")) {
- this.show();
- }
-};
-
-Kanboard.CompareHoursColumnChart.prototype.show = function() {
- var chart = $("#chart");
- var metrics = chart.data("metrics");
- var labelOpen = chart.data("label-open");
- var labelClosed = chart.data("label-closed");
- var spent = [chart.data("label-spent")];
- var estimated = [chart.data("label-estimated")];
- var categories = [];
-
- for (var status in metrics) {
- spent.push(parseFloat(metrics[status].time_spent));
- estimated.push(parseFloat(metrics[status].time_estimated));
- categories.push(status == 'open' ? labelOpen : labelClosed);
- }
-
- c3.generate({
- data: {
- columns: [spent, estimated],
- type: 'bar'
- },
- bar: {
- width: {
- ratio: 0.2
- }
- },
- axis: {
- x: {
- type: 'category',
- categories: categories
- }
- },
- legend: {
- show: true
- }
- });
-};
diff --git a/assets/js/src/CumulativeFlowDiagram.js b/assets/js/src/CumulativeFlowDiagram.js
deleted file mode 100644
index b22fd2e9..00000000
--- a/assets/js/src/CumulativeFlowDiagram.js
+++ /dev/null
@@ -1,55 +0,0 @@
-Kanboard.CumulativeFlowDiagram = function(app) {
- this.app = app;
-};
-
-Kanboard.CumulativeFlowDiagram.prototype.execute = function() {
- if (this.app.hasId("analytic-cfd")) {
- this.show();
- }
-};
-
-Kanboard.CumulativeFlowDiagram.prototype.show = function() {
- var chart = $("#chart");
- var metrics = chart.data("metrics");
- var columns = [];
- var groups = [];
- var categories = [];
- var inputFormat = d3.time.format("%Y-%m-%d");
- var outputFormat = d3.time.format(chart.data("date-format"));
-
- for (var i = 0; i < metrics.length; i++) {
-
- for (var j = 0; j < metrics[i].length; j++) {
-
- if (i == 0) {
- columns.push([metrics[i][j]]);
-
- if (j > 0) {
- groups.push(metrics[i][j]);
- }
- }
- else {
-
- columns[j].push(metrics[i][j]);
-
- if (j == 0) {
- categories.push(outputFormat(inputFormat.parse(metrics[i][j])));
- }
- }
- }
- }
-
- c3.generate({
- data: {
- columns: columns,
- type: 'area-spline',
- groups: [groups]
- },
- axis: {
- x: {
- type: 'category',
- categories: categories
- }
- }
- });
-};
diff --git a/assets/js/src/Dropdown.js b/assets/js/src/Dropdown.js
index 46652ba0..ec033b3e 100644
--- a/assets/js/src/Dropdown.js
+++ b/assets/js/src/Dropdown.js
@@ -2,6 +2,7 @@ Kanboard.Dropdown = function(app) {
this.app = app;
};
+// TODO: rewrite this code
Kanboard.Dropdown.prototype.listen = function() {
var self = this;
@@ -52,7 +53,3 @@ Kanboard.Dropdown.prototype.listen = function() {
Kanboard.Dropdown.prototype.close = function() {
$("#dropdown").remove();
};
-
-Kanboard.Dropdown.prototype.onPopoverOpened = function() {
- this.close();
-};
diff --git a/assets/js/src/FileUpload.js b/assets/js/src/FileUpload.js
deleted file mode 100644
index f53b9bf8..00000000
--- a/assets/js/src/FileUpload.js
+++ /dev/null
@@ -1,125 +0,0 @@
-Kanboard.FileUpload = function(app) {
- this.app = app;
- this.files = [];
- this.currentFile = 0;
-};
-
-Kanboard.FileUpload.prototype.onPopoverOpened = function() {
- var dropzone = document.getElementById("file-dropzone");
- var self = this;
-
- if (dropzone) {
- dropzone.ondragover = dropzone.ondragenter = function(e) {
- e.stopPropagation();
- e.preventDefault();
- };
-
- dropzone.ondrop = function(e) {
- e.stopPropagation();
- e.preventDefault();
- self.files = e.dataTransfer.files;
- self.show();
- $("#file-error-max-size").hide();
- };
-
- $(document).on("click", "#file-browser", function(e) {
- e.preventDefault();
- $("#file-form-element").get(0).click();
- });
-
- $(document).on("click", "#file-upload-button", function(e) {
- e.preventDefault();
- self.currentFile = 0;
- self.checkFiles();
- });
-
- $("#file-form-element").change(function() {
- self.files = document.getElementById("file-form-element").files;
- self.show();
- $("#file-error-max-size").hide();
- });
- }
-};
-
-Kanboard.FileUpload.prototype.show = function() {
- $("#file-list").remove();
-
- if (this.files.length > 0) {
- $("#file-upload-button").prop("disabled", false);
- $("#file-dropzone-inner").hide();
-
- var ul = jQuery("<ul>", {"id": "file-list"});
-
- for (var i = 0; i < this.files.length; i++) {
- var percentage = jQuery("<span>", {"id": "file-percentage-" + i}).append("(0%)");
- var progress = jQuery("<progress>", {"id": "file-progress-" + i, "value": 0});
- var li = jQuery("<li>", {"id": "file-label-" + i})
- .append(progress)
- .append("&nbsp;")
- .append(this.files[i].name)
- .append("&nbsp;")
- .append(percentage);
-
- ul.append(li);
- }
-
- $("#file-dropzone").append(ul);
- } else {
- $("#file-dropzone-inner").show();
- }
-};
-
-Kanboard.FileUpload.prototype.checkFiles = function() {
- var max = parseInt($("#file-dropzone").data("max-size"));
-
- for (var i = 0; i < this.files.length; i++) {
- if (this.files[i].size > max) {
- $("#file-error-max-size").show();
- $("#file-label-" + i).addClass("file-error");
- $("#file-upload-button").prop("disabled", true);
- return;
- }
- }
-
- this.uploadFiles();
-};
-
-Kanboard.FileUpload.prototype.uploadFiles = function() {
- if (this.files.length > 0) {
- this.uploadFile(this.files[this.currentFile]);
- }
-};
-
-Kanboard.FileUpload.prototype.uploadFile = function(file) {
- var dropzone = document.getElementById("file-dropzone");
- var url = dropzone.dataset.url;
- var xhr = new XMLHttpRequest();
- var fd = new FormData();
-
- xhr.upload.addEventListener("progress", this.updateProgress.bind(this));
- xhr.upload.addEventListener("load", this.transferComplete.bind(this));
-
- xhr.open("POST", url, true);
- fd.append('files[]', file);
- xhr.send(fd);
-};
-
-Kanboard.FileUpload.prototype.updateProgress = function(e) {
- if (e.lengthComputable) {
- $("#file-progress-" + this.currentFile).val(e.loaded / e.total);
- $("#file-percentage-" + this.currentFile).text('(' + Math.floor((e.loaded / e.total) * 100) + '%)');
- }
-};
-
-Kanboard.FileUpload.prototype.transferComplete = function() {
- this.currentFile++;
-
- if (this.currentFile < this.files.length) {
- this.uploadFile(this.files[this.currentFile]);
- } else {
- var uploadButton = $("#file-upload-button");
- uploadButton.prop("disabled", true);
- uploadButton.parent().hide();
- $("#file-done").show();
- }
-};
diff --git a/assets/js/src/LeadCycleTimeChart.js b/assets/js/src/LeadCycleTimeChart.js
deleted file mode 100644
index 7eee77fc..00000000
--- a/assets/js/src/LeadCycleTimeChart.js
+++ /dev/null
@@ -1,53 +0,0 @@
-Kanboard.LeadCycleTimeChart = function(app) {
- this.app = app;
-};
-
-Kanboard.LeadCycleTimeChart.prototype.execute = function() {
- if (this.app.hasId("analytic-lead-cycle-time")) {
- this.show();
- }
-};
-
-Kanboard.LeadCycleTimeChart.prototype.show = function() {
- var chart = $("#chart");
- var metrics = chart.data("metrics");
- var cycle = [chart.data("label-cycle")];
- var lead = [chart.data("label-lead")];
- var categories = [];
-
- var types = {};
- types[chart.data("label-cycle")] = 'area';
- types[chart.data("label-lead")] = 'area-spline';
-
- var colors = {};
- colors[chart.data("label-lead")] = '#afb42b';
- colors[chart.data("label-cycle")] = '#4e342e';
-
- for (var i = 0; i < metrics.length; i++) {
- cycle.push(parseInt(metrics[i].avg_cycle_time));
- lead.push(parseInt(metrics[i].avg_lead_time));
- categories.push(metrics[i].day);
- }
-
- c3.generate({
- data: {
- columns: [
- lead,
- cycle
- ],
- types: types,
- colors: colors
- },
- axis: {
- x: {
- type: 'category',
- categories: categories
- },
- y: {
- tick: {
- format: this.app.formatDuration
- }
- }
- }
- });
-};
diff --git a/assets/js/src/Markdown.js b/assets/js/src/Markdown.js
deleted file mode 100644
index 11673eec..00000000
--- a/assets/js/src/Markdown.js
+++ /dev/null
@@ -1,59 +0,0 @@
-Kanboard.Markdown = function(app) {
- this.app = app;
- this.editor = null;
-};
-
-Kanboard.Markdown.prototype.onPopoverOpened = function() {
- this.listen();
-};
-
-Kanboard.Markdown.prototype.onPopoverClosed = function() {
- this.listen();
-};
-
-Kanboard.Markdown.prototype.listen = function() {
- var editors = $(".markdown-editor");
-
- if (this.editor) {
- this.destroy();
- }
-
- if (editors.length > 0) {
- this.show(editors[0]);
- }
-};
-
-Kanboard.Markdown.prototype.destroy = function() {
- var cm = this.editor.codemirror;
- var wrapper = cm.getWrapperElement();
-
- for (var item in ["toolbar", "statusbar", "sideBySide"]) {
- if (this.editor.gui[item]) {
- wrapper.parentNode.removeChild(this.editor.gui[item]);
- }
- }
-
- cm.toTextArea();
- this.editor = null;
-};
-
-Kanboard.Markdown.prototype.show = function(textarea) {
- var toolbar = ["bold", "italic", "strikethrough", "heading", "|", "unordered-list", "ordered-list", "link", "|", "code", "table"];
-
- this.editor = new SimpleMDE({
- element: textarea,
- status: false,
- toolbarTips: false,
- autoDownloadFontAwesome: false,
- spellChecker: false,
- autosave: {
- enabled: false
- },
- forceSync: true,
- blockStyles: {
- italic: "_"
- },
- toolbar: textarea.hasAttribute("data-markdown-editor-disable-toolbar") ? false : toolbar,
- placeholder: textarea.getAttribute("placeholder")
- });
-};
diff --git a/assets/js/src/Namespace.js b/assets/js/src/Namespace.js
index 6b4b0543..ada17047 100644
--- a/assets/js/src/Namespace.js
+++ b/assets/js/src/Namespace.js
@@ -1,3 +1 @@
-'use strict';
-
var Kanboard = {};
diff --git a/assets/js/src/Notification.js b/assets/js/src/Notification.js
deleted file mode 100644
index 840ee988..00000000
--- a/assets/js/src/Notification.js
+++ /dev/null
@@ -1,9 +0,0 @@
-Kanboard.Notification = function(app) {
- this.app = app;
-};
-
-Kanboard.Notification.prototype.execute = function() {
- $(".alert-fade-out").delay(4000).fadeOut(800, function() {
- $(this).remove();
- });
-};
diff --git a/assets/js/src/Popover.js b/assets/js/src/Popover.js
deleted file mode 100644
index 273916ea..00000000
--- a/assets/js/src/Popover.js
+++ /dev/null
@@ -1,151 +0,0 @@
-Kanboard.Popover = function(app) {
- this.app = app;
-};
-
-Kanboard.Popover.prototype.listen = function() {
- var self = this;
-
- $(document).on("click", ".popover", function(e) {
- self.onClick(e);
- });
-
- $(document).on("click", ".close-popover", function(e) {
- self.close(e);
- });
-
- $(document).on("click", "#popover-container", function(e) {
- self.close(e);
- });
-
- $(document).on("click", "#popover-content", function(e) {
- e.stopPropagation();
- });
-};
-
-Kanboard.Popover.prototype.onClick = function(e) {
- e.preventDefault();
- e.stopPropagation();
-
- var target = e.currentTarget || e.target;
- var link = target.getAttribute("href");
-
- if (! link) {
- link = target.getAttribute("data-href");
- }
-
- if (link) {
- this.open(link);
- }
-};
-
-Kanboard.Popover.prototype.isOpen = function() {
- return $('#popover-container').size() > 0;
-};
-
-Kanboard.Popover.prototype.open = function(link) {
- var self = this;
-
- if (!self.isOpen()) {
- $.get(link, function(content) {
- $("body").prepend('<div id="popover-container"><div id="popover-content">' + content + '</div></div>');
- self.executeOnOpenedListeners();
- });
- }
-};
-
-Kanboard.Popover.prototype.close = function(e) {
- if (this.isOpen()) {
- if (e) {
- e.preventDefault();
- }
-
- $("#popover-container").remove();
- this.executeOnClosedListeners();
- }
-};
-
-Kanboard.Popover.prototype.ajaxReload = function(data, request, self) {
- var redirect = request.getResponseHeader("X-Ajax-Redirect");
-
- if (redirect === 'self') {
- window.location.reload();
- } else if (redirect && redirect.indexOf('#') > -1) {
- window.location = redirect.split('#')[0];
- } else if (redirect) {
- window.location = redirect;
- } else {
- $("#popover-content").html(data);
- $("#popover-content input[autofocus]").focus();
- self.executeOnOpenedListeners();
- }
-};
-
-Kanboard.Popover.prototype.executeOnOpenedListeners = function() {
- for (var className in this.app.controllers) {
- var controller = this.app.get(className);
-
- if (typeof controller.onPopoverOpened === "function") {
- controller.onPopoverOpened();
- }
- }
-
- this.afterOpen();
-};
-
-Kanboard.Popover.prototype.executeOnClosedListeners = function() {
- for (var className in this.app.controllers) {
- var controller = this.app.get(className);
-
- if (typeof controller.onPopoverClosed === "function") {
- controller.onPopoverClosed();
- }
- }
-};
-
-Kanboard.Popover.prototype.afterOpen = function() {
- var self = this;
- var popoverForm = $("#popover-content .popover-form");
-
- // Submit forms with Ajax request
- if (popoverForm) {
- popoverForm.on("submit", function(e) {
- e.preventDefault();
-
- $.ajax({
- type: "POST",
- url: popoverForm.attr("action"),
- data: popoverForm.serialize(),
- success: function(data, textStatus, request) {
- self.ajaxReload(data, request, self);
- },
- beforeSend: function() {
- var button = $('.popover-form button[type="submit"]');
- button.html('<i class="fa fa-spinner fa-pulse"></i> ' + button.html());
- button.attr("disabled", true);
- }
- });
- });
- }
-
- // Submit link with Ajax request
- $(document).on("click", ".popover-link", function(e) {
- e.preventDefault();
-
- $.ajax({
- type: "GET",
- url: $(this).attr("href"),
- success: function(data, textStatus, request) {
- self.ajaxReload(data, request, self);
- }
- });
- });
-
- // Autofocus fields (html5 autofocus works only with page onload)
- $("[autofocus]").each(function() {
- $(this).focus();
- });
-
- this.app.datePicker();
- this.app.autoComplete();
- this.app.tagAutoComplete();
-};
diff --git a/assets/js/src/ProjectCreation.js b/assets/js/src/ProjectCreation.js
deleted file mode 100644
index 180eab94..00000000
--- a/assets/js/src/ProjectCreation.js
+++ /dev/null
@@ -1,15 +0,0 @@
-Kanboard.ProjectCreation = function(app) {
- this.app = app;
-};
-
-Kanboard.ProjectCreation.prototype.onPopoverOpened = function() {
- $('#project-creation-form #form-src_project_id').on('change', function() {
- var srcProjectId = $(this).val();
-
- if (srcProjectId == 0) {
- $(".project-creation-options").hide();
- } else {
- $(".project-creation-options").show();
- }
- });
-};
diff --git a/assets/js/src/ProjectPermission.js b/assets/js/src/ProjectPermission.js
deleted file mode 100644
index fec666b1..00000000
--- a/assets/js/src/ProjectPermission.js
+++ /dev/null
@@ -1,19 +0,0 @@
-Kanboard.ProjectPermission = function(app) {
- this.app = app;
-};
-
-Kanboard.ProjectPermission.prototype.listen = function() {
- $('.project-change-role').on('change', function () {
- $.ajax({
- cache: false,
- url: $(this).data('url'),
- contentType: "application/json",
- type: "POST",
- processData: false,
- data: JSON.stringify({
- "id": $(this).data('id'),
- "role": $(this).val()
- })
- });
- });
-};
diff --git a/assets/js/src/Screenshot.js b/assets/js/src/Screenshot.js
deleted file mode 100644
index 5c74288b..00000000
--- a/assets/js/src/Screenshot.js
+++ /dev/null
@@ -1,134 +0,0 @@
-Kanboard.Screenshot = function(app) {
- this.app = app;
- this.pasteCatcher = null;
-};
-
-Kanboard.Screenshot.prototype.onPopoverOpened = function() {
- if (this.app.hasId("screenshot-zone")) {
- this.initialize();
- }
-};
-
-// Setup event listener and workarounds
-Kanboard.Screenshot.prototype.initialize = function() {
- this.destroy();
-
- if (! window.Clipboard) {
-
- // Create a contenteditable element
- this.pasteCatcher = document.createElement("div");
- this.pasteCatcher.id = "screenshot-pastezone";
- this.pasteCatcher.contentEditable = "true";
-
- // Insert the content editable at the top to avoid scrolling down in the board view
- this.pasteCatcher.style.opacity = 0;
- this.pasteCatcher.style.position = "fixed";
- this.pasteCatcher.style.top = 0;
- this.pasteCatcher.style.right = 0;
- this.pasteCatcher.style.width = 0;
-
- document.body.insertBefore(this.pasteCatcher, document.body.firstChild);
-
- // Set focus on the contenteditable element
- this.pasteCatcher.focus();
-
- // Set the focus when clicked anywhere in the document
- document.addEventListener("click", this.setFocus.bind(this));
-
- // Set the focus when clicked in screenshot dropzone (popover)
- document.getElementById("screenshot-zone").addEventListener("click", this.setFocus.bind(this));
- }
-
- window.addEventListener("paste", this.pasteHandler.bind(this));
-};
-
-// Destroy contentEditable element
-Kanboard.Screenshot.prototype.destroy = function() {
- if (this.pasteCatcher != null) {
- document.body.removeChild(this.pasteCatcher);
- }
- else if (document.getElementById("screenshot-pastezone")) {
- document.body.removeChild(document.getElementById("screenshot-pastezone"));
- }
-
- document.removeEventListener("click", this.setFocus.bind(this));
- this.pasteCatcher = null;
-};
-
-// Set focus on contentEditable element
-Kanboard.Screenshot.prototype.setFocus = function() {
- if (this.pasteCatcher !== null) {
- this.pasteCatcher.focus();
- }
-};
-
-// Paste event callback
-Kanboard.Screenshot.prototype.pasteHandler = function(e) {
- // Firefox doesn't have the property e.clipboardData.items (only Chrome)
- if (e.clipboardData && e.clipboardData.items) {
-
- var items = e.clipboardData.items;
-
- if (items) {
-
- for (var i = 0; i < items.length; i++) {
-
- // Find an image in pasted elements
- if (items[i].type.indexOf("image") !== -1) {
-
- var blob = items[i].getAsFile();
-
- // Get the image as base64 data
- var reader = new FileReader();
- var self = this;
- reader.onload = function(event) {
- self.createImage(event.target.result);
- };
-
- reader.readAsDataURL(blob);
- }
- }
- }
- }
- else {
-
- // Handle Firefox
- setTimeout(this.checkInput.bind(this), 100);
- }
-};
-
-// Parse the input in the paste catcher element
-Kanboard.Screenshot.prototype.checkInput = function() {
- var child = this.pasteCatcher.childNodes[0];
-
- if (child) {
- // If the user pastes an image, the src attribute
- // will represent the image as a base64 encoded string.
- if (child.tagName === "IMG") {
- this.createImage(child.src);
- }
- }
-
- this.pasteCatcher.innerHTML = "";
-};
-
-// Creates a new image from a given source
-Kanboard.Screenshot.prototype.createImage = function(blob) {
- var pastedImage = new Image();
- pastedImage.src = blob;
-
- // Send the image content to the form variable
- pastedImage.onload = function() {
- var sourceSplit = blob.split("base64,");
- var sourceString = sourceSplit[1];
- $("input[name=screenshot]").val(sourceString);
- };
-
- var zone = document.getElementById("screenshot-zone");
- zone.innerHTML = "";
- zone.className = "screenshot-pasted";
- zone.appendChild(pastedImage);
-
- this.destroy();
- this.initialize();
-};
diff --git a/assets/js/src/Search.js b/assets/js/src/Search.js
index f6409f54..b61710a4 100644
--- a/assets/js/src/Search.js
+++ b/assets/js/src/Search.js
@@ -15,6 +15,7 @@ Kanboard.Search.prototype.focus = function() {
});
};
+// TODO: rewrite this code
Kanboard.Search.prototype.listen = function() {
$(document).on("click", ".filter-helper", function (e) {
e.preventDefault();
@@ -38,60 +39,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();
- });
-};
diff --git a/assets/js/src/Session.js b/assets/js/src/Session.js
deleted file mode 100644
index c07bc58d..00000000
--- a/assets/js/src/Session.js
+++ /dev/null
@@ -1,21 +0,0 @@
-Kanboard.Session = function(app) {
- this.app = app;
-};
-
-Kanboard.Session.prototype.execute = function() {
- window.setInterval(this.checkSession, 60000);
-};
-
-Kanboard.Session.prototype.checkSession = function() {
- if (! $(".form-login").length) {
- $.ajax({
- cache: false,
- url: $("body").data("status-url"),
- statusCode: {
- 401: function() {
- window.location = $("body").data("login-url");
- }
- }
- });
- }
-};
diff --git a/assets/js/src/Task.js b/assets/js/src/Task.js
index 06419207..19cf39e8 100644
--- a/assets/js/src/Task.js
+++ b/assets/js/src/Task.js
@@ -2,32 +2,9 @@ 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"));
- });
- }
-};
-
+// TODO: rewrite this code
Kanboard.Task.prototype.onPopoverOpened = function() {
var self = this;
- var reloadingProjectId = 0;
self.renderColorPicker();
@@ -42,29 +19,6 @@ Kanboard.Task.prototype.onPopoverOpened = function() {
$(dropdownId).val(currentId);
}
});
-
- // Reload page when a destination project is changed
- $(document).on("change", "select.task-reload-project-destination", function() {
- if (reloadingProjectId > 0) {
- $(this).val(reloadingProjectId);
- }
- else {
- reloadingProjectId = $(this).val();
- var url = $(this).data("redirect").replace(/PROJECT_ID/g, reloadingProjectId);
-
- $(".loading-icon").show();
-
- $.ajax({
- type: "GET",
- url: url,
- success: function(data, textStatus, request) {
- reloadingProjectId = 0;
- $(".loading-icon").hide();
- self.app.get("Popover").ajaxReload(data, request, self.app.get("Popover"));
- }
- });
- }
- });
};
Kanboard.Task.prototype.renderColorPicker = function() {
diff --git a/assets/js/src/TaskRepartitionChart.js b/assets/js/src/TaskRepartitionChart.js
deleted file mode 100644
index 621be630..00000000
--- a/assets/js/src/TaskRepartitionChart.js
+++ /dev/null
@@ -1,25 +0,0 @@
-Kanboard.TaskRepartitionChart = function(app) {
- this.app = app;
-};
-
-Kanboard.TaskRepartitionChart.prototype.execute = function() {
- if (this.app.hasId("analytic-task-repartition")) {
- this.show();
- }
-};
-
-Kanboard.TaskRepartitionChart.prototype.show = function() {
- var metrics = $("#chart").data("metrics");
- var columns = [];
-
- for (var i = 0; i < metrics.length; i++) {
- columns.push([metrics[i].column_title, metrics[i].nb_tasks]);
- }
-
- c3.generate({
- data: {
- columns: columns,
- type : 'donut'
- }
- });
-};
diff --git a/assets/js/src/TaskTimeColumnChart.js b/assets/js/src/TaskTimeColumnChart.js
deleted file mode 100644
index 9b26d76e..00000000
--- a/assets/js/src/TaskTimeColumnChart.js
+++ /dev/null
@@ -1,47 +0,0 @@
-Kanboard.TaskTimeColumnChart = function(app) {
- this.app = app;
-};
-
-Kanboard.TaskTimeColumnChart.prototype.execute = function() {
- if (this.app.hasId("analytic-task-time-column")) {
- this.show();
- }
-};
-
-Kanboard.TaskTimeColumnChart.prototype.show = function() {
- var chart = $("#chart");
- var metrics = chart.data("metrics");
- var plots = [chart.data("label")];
- var categories = [];
-
- for (var i = 0; i < metrics.length; i++) {
- plots.push(metrics[i].time_spent);
- categories.push(metrics[i].title);
- }
-
- c3.generate({
- data: {
- columns: [plots],
- type: 'bar'
- },
- bar: {
- width: {
- ratio: 0.5
- }
- },
- axis: {
- x: {
- type: 'category',
- categories: categories
- },
- y: {
- tick: {
- format: this.app.formatDuration
- }
- }
- },
- legend: {
- show: false
- }
- });
-};
diff --git a/assets/js/src/UserRepartitionChart.js b/assets/js/src/UserRepartitionChart.js
deleted file mode 100644
index 96c08ab3..00000000
--- a/assets/js/src/UserRepartitionChart.js
+++ /dev/null
@@ -1,25 +0,0 @@
-Kanboard.UserRepartitionChart = function(app) {
- this.app = app;
-};
-
-Kanboard.UserRepartitionChart.prototype.execute = function() {
- if (this.app.hasId("analytic-user-repartition")) {
- this.show();
- }
-};
-
-Kanboard.UserRepartitionChart.prototype.show = function() {
- var metrics = $("#chart").data("metrics");
- var columns = [];
-
- for (var i = 0; i < metrics.length; i++) {
- columns.push([metrics[i].user, metrics[i].nb_tasks]);
- }
-
- c3.generate({
- data: {
- columns: columns,
- type : 'donut'
- }
- });
-};