diff options
Diffstat (limited to 'assets/js/src')
-rw-r--r-- | assets/js/src/analytic.js | 211 | ||||
-rw-r--r-- | assets/js/src/base.js | 112 | ||||
-rw-r--r-- | assets/js/src/board.js | 181 | ||||
-rw-r--r-- | assets/js/src/calendar.js | 188 | ||||
-rw-r--r-- | assets/js/src/screenshot.js | 61 | ||||
-rw-r--r-- | assets/js/src/swimlane.js | 2 |
6 files changed, 405 insertions, 350 deletions
diff --git a/assets/js/src/analytic.js b/assets/js/src/analytic.js index 8066165b..a5df0ac6 100644 --- a/assets/js/src/analytic.js +++ b/assets/js/src/analytic.js @@ -1,5 +1,4 @@ - -Kanboard.Analytic = (function() { +(function() { // CFD diagram function drawCfd() @@ -7,6 +6,9 @@ Kanboard.Analytic = (function() { 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++) { @@ -20,7 +22,12 @@ Kanboard.Analytic = (function() { } } else { + columns[j].push(metrics[i][j]); + + if (j == 0) { + categories.push(outputFormat(inputFormat.parse(metrics[i][j]))); + } } } } @@ -28,16 +35,13 @@ Kanboard.Analytic = (function() { c3.generate({ data: { columns: columns, - x: metrics[0][0], type: 'area-spline', groups: [groups] }, axis: { x: { - type: 'timeseries', - tick: { - format: $("#chart").data("date-format") - } + type: 'category', + categories: categories } } }); @@ -48,6 +52,9 @@ Kanboard.Analytic = (function() { { 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++) { @@ -67,21 +74,22 @@ Kanboard.Analytic = (function() { columns[0][i] += metrics[i][j]; } + + if (j == 0) { + categories.push(outputFormat(inputFormat.parse(metrics[i][j]))); + } } } } c3.generate({ data: { - columns: columns, - x: metrics[0][0] + columns: columns }, axis: { x: { - type: 'timeseries', - tick: { - format: $("#chart").data("date-format") - } + type: 'category', + categories: categories } } }); @@ -126,11 +134,13 @@ Kanboard.Analytic = (function() { // Draw budget chart function drawBudget() { + var categories = []; var metrics = $("#chart").data("metrics"); var labels = $("#chart").data("labels"); + var inputFormat = d3.time.format("%Y-%m-%d"); + var outputFormat = d3.time.format($("#chart").data("date-format")); var columns = [ - [labels["date"]], [labels["in"]], [labels["left"]], [labels["out"]] @@ -142,30 +152,178 @@ Kanboard.Analytic = (function() { colors[labels["out"]] = '#DF3A01'; for (var i = 0; i < metrics.length; i++) { - columns[0].push(metrics[i]["date"]); - columns[1].push(metrics[i]["in"]); - columns[2].push(metrics[i]["left"]); - columns[3].push(metrics[i]["out"]); + categories.push(outputFormat(inputFormat.parse(metrics[i]["date"]))); + columns[0].push(metrics[i]["in"]); + columns[1].push(metrics[i]["left"]); + columns[2].push(metrics[i]["out"]); } c3.generate({ data: { - x: columns[0][0], columns: columns, colors: colors, type : 'bar' }, + bar: { + width: { + ratio: 0.25 + } + }, + grid: { + x: { + show: true + }, + y: { + show: true + } + }, + axis: { + x: { + type: 'category', + categories: categories + } + } + }); + } + + // Draw chart for average time spent into each column + function drawAvgTimeColumn() + { + 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: 'timeseries', + type: 'category', + categories: categories + }, + y: { tick: { - format: $("#chart").data("date-format") + format: formatDuration } } + }, + legend: { + show: false } }); } + // Draw chart for average time spent into each column + function drawTaskTimeColumn() + { + 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: formatDuration + } + } + }, + legend: { + show: false + } + }); + } + + // Draw lead and cycle time for the project + function drawLeadAndCycleTime() + { + 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: formatDuration + } + } + } + }); + } + + function formatDuration(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"; + } + jQuery(document).ready(function() { if (Kanboard.Exists("analytic-task-repartition")) { @@ -183,8 +341,15 @@ Kanboard.Analytic = (function() { else if (Kanboard.Exists("budget-chart")) { drawBudget(); } + else if (Kanboard.Exists("analytic-avg-time-column")) { + drawAvgTimeColumn(); + } + else if (Kanboard.Exists("analytic-task-time-column")) { + drawTaskTimeColumn(); + } + else if (Kanboard.Exists("analytic-lead-cycle-time")) { + drawLeadAndCycleTime(); + } }); - return {}; - })(); diff --git a/assets/js/src/base.js b/assets/js/src/base.js index 0d46b503..6bd8a144 100644 --- a/assets/js/src/base.js +++ b/assets/js/src/base.js @@ -1,4 +1,3 @@ -// Common functions var Kanboard = (function() { jQuery(document).ready(function() { @@ -40,7 +39,7 @@ var Kanboard = (function() { $("body").append('<div id="popover-container"><div id="popover-content">' + content + '</div></div>'); $("#popover-container").click(function() { - $(this).remove(); + Kanboard.ClosePopover(); }); $("#popover-content").click(function(e) { @@ -49,11 +48,11 @@ var Kanboard = (function() { $(".close-popover").click(function(e) { e.preventDefault(); - $('#popover-container').remove(); + Kanboard.ClosePopover(); }); - Mousetrap.bind("esc", function() { - $('#popover-container').remove(); + Mousetrap.bindGlobal("esc", function() { + Kanboard.ClosePopover(); }); if (callback) { @@ -62,6 +61,11 @@ var Kanboard = (function() { }); }, + ClosePopover: function() { + $('#popover-container').remove(); + Kanboard.Screenshot.Destroy(); + }, + // Return true if the page is visible IsVisible: function() { @@ -186,18 +190,101 @@ var Kanboard = (function() { // Check the session every 60s window.setInterval(Kanboard.CheckSession, 60000); - // Keyboard shortcuts + // Submit form Mousetrap.bindGlobal("mod+enter", function() { $("form").submit(); }); + // Open board selector Mousetrap.bind("b", function(e) { e.preventDefault(); $('#board-selector').trigger('chosen:open'); }); + // Focus to the search box + Mousetrap.bind("f", function(e) { + e.preventDefault(); + + var input = document.getElementById("form-search"); + + if (input) { + input.focus(); + } + }); + + // 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'); + } + }); + + // 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'); + } + }); + + // 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'); + } + }); + + // 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); + } + }); + + // Filter helper for search + $(document).on("click", ".filter-helper", function (e) { + e.preventDefault(); + $("#form-search").val($(this).data("filter")); + $("form.search").submit(); + }); + + // Collapse sidebar + $(document).on("click", ".sidebar-collapse", function (e) { + e.preventDefault(); + $(".sidebar-container").addClass("sidebar-collapsed"); + $(".sidebar-expand").show(); + $(".sidebar h2").hide(); + $(".sidebar ul").hide(); + $(".sidebar-collapse").hide(); + }); + + // Expand sidebar + $(document).on("click", ".sidebar-expand", function (e) { + e.preventDefault(); + $(".sidebar-container").removeClass("sidebar-collapsed"); + $(".sidebar-collapse").show(); + $(".sidebar h2").show(); + $(".sidebar ul").show(); + $(".sidebar-expand").hide(); + }); + + $("select.task-reload-project-destination").change(function() { + window.location = $(this).data("redirect").replace(/PROJECT_ID/g, $(this).val()); + }); + + // Datepicker translation $.datepicker.setDefaults($.datepicker.regional[$("body").data("js-lang")]); + // Alert box fadeout + $(".alert-fade-out").delay(4000).fadeOut(800, function() { + $(this).remove(); + }); + Kanboard.InitAfterAjax(); }, @@ -219,6 +306,15 @@ var Kanboard = (function() { constrainInput: false }); + // Datetime picker + $(".form-datetime").datetimepicker({ + controlType: 'select', + oneLine: true, + dateFormat: 'yy-mm-dd', + // timeFormat: 'h:mm tt', + constrainInput: false + }); + // Markdown Preview for textareas $("#markdown-preview").click(Kanboard.MarkdownPreview); $("#markdown-write").click(Kanboard.MarkdownWriter); @@ -252,7 +348,7 @@ var Kanboard = (function() { } // Tooltip for column description - $(".column-tooltip").tooltip({ + $(".tooltip").tooltip({ content: function() { return '<div class="markdown">' + $(this).attr("title") + '</div>'; }, @@ -268,7 +364,7 @@ var Kanboard = (function() { $("<div>") .addClass("tooltip-arrow") .addClass(feedback.vertical) - .addClass(arrow_pos == 0 ? "align-left" : "align-right") + .addClass(arrow_pos < 1 ? "align-left" : "align-right") .appendTo(this); } } diff --git a/assets/js/src/board.js b/assets/js/src/board.js index 9f93a869..45dbd24a 100644 --- a/assets/js/src/board.js +++ b/assets/js/src/board.js @@ -1,4 +1,4 @@ -Kanboard.Board = (function() { +(function() { var checkInterval = null; @@ -13,7 +13,6 @@ Kanboard.Board = (function() { function keyboard_shortcuts() { Mousetrap.bind("n", function() { - Kanboard.OpenPopover( $("#board").data("task-creation-url"), Kanboard.InitAfterAjax @@ -21,7 +20,19 @@ Kanboard.Board = (function() { }); Mousetrap.bind("s", function() { - stack_toggle(); + $.ajax({ + cache: false, + url: $('.filter-display-mode:not([style="display: none;"]) a').attr('href'), + success: function(data) { + $("#board-container").remove(); + $("#main").append(data); + Kanboard.InitAfterAjax(); + board_unload_events(); + board_load_events(); + compactview_reload(); + $('.filter-display-mode').toggle(); + } + }); }); Mousetrap.bind("c", function() { @@ -29,74 +40,6 @@ Kanboard.Board = (function() { }); } - // Collapse/Expand tasks - function stack_load_events() - { - $(".filter-expand-link").click(function(e) { - e.preventDefault(); - stack_expand(); - Kanboard.SetStorageItem(stack_key(), "expanded"); - }); - - $(".filter-collapse-link").click(function(e) { - e.preventDefault(); - stack_collapse(); - Kanboard.SetStorageItem(stack_key(), "collapsed"); - }); - - stack_show(); - } - - function stack_key() - { - var projectId = $('#board').data('project-id'); - return "board_stacking_" + projectId; - } - - function stack_collapse() - { - $(".filter-collapse").hide(); - $(".task-board-collapsed").show(); - - $(".filter-expand").show(); - $(".task-board-expanded").hide(); - } - - function stack_expand() - { - $(".filter-collapse").show(); - $(".task-board-collapsed").hide(); - - $(".filter-expand").hide(); - $(".task-board-expanded").show(); - } - - function stack_toggle() - { - var state = Kanboard.GetStorageItem(stack_key()) || "expanded"; - - if (state === "expanded") { - stack_collapse(); - Kanboard.SetStorageItem(stack_key(), "collapsed"); - } - else { - stack_expand(); - Kanboard.SetStorageItem(stack_key(), "expanded"); - } - } - - function stack_show() - { - var state = Kanboard.GetStorageItem(stack_key()) || "expanded"; - - if (state === "expanded") { - stack_expand(); - } - else { - stack_collapse(); - } - } - // Setup the board function board_load_events() { @@ -106,6 +49,7 @@ Kanboard.Board = (function() { distance: 5, connectWith: ".column", placeholder: "draggable-placeholder", + items: ".draggable-item", stop: function(event, ui) { board_save( ui.item.attr('data-task-id'), @@ -139,7 +83,7 @@ Kanboard.Board = (function() { $("<div>") .addClass("tooltip-arrow") .addClass(feedback.vertical) - .addClass(arrow_pos == 0 ? "align-left" : "align-right") + .addClass(arrow_pos < 1 ? "align-left" : "align-right") .appendTo(this); } }, @@ -243,8 +187,6 @@ Kanboard.Board = (function() { $("#main").append(data); Kanboard.InitAfterAjax(); board_load_events(); - filter_apply(); - stack_show(); compactview_reload(); } }); @@ -264,8 +206,6 @@ Kanboard.Board = (function() { Kanboard.InitAfterAjax(); board_unload_events(); board_load_events(); - filter_apply(); - stack_show(); compactview_reload(); } } @@ -273,93 +213,6 @@ Kanboard.Board = (function() { } } - // Apply user or date filter (change tasks opacity) - function filter_apply() - { - var selectedUserId = $("#form-user_id").val(); - var selectedCategoryId = $("#form-category_id").val(); - var filterDueDate = $("#more-filters option[value=filter-due-date]").is(":selected") - var filterRecent = $("#more-filters option[value=filter-recent]").is(":selected") - var projectId = $('#board').data('project-id'); - - $("[data-task-id]").each(function(index, item) { - - var ownerId = item.getAttribute("data-owner-id"); - var dueDate = item.getAttribute("data-due-date"); - var categoryId = item.getAttribute("data-category-id"); - var recent = $(item).hasClass("task-board-recent"); - - if (ownerId != selectedUserId && selectedUserId != -1) { - item.style.display = "none"; - } - else { - item.style.display = "block"; - } - - if (filterDueDate && (dueDate == "" || dueDate == "0")) { - item.style.display = "none"; - } - - if (categoryId != selectedCategoryId && selectedCategoryId != -1) { - item.style.display = "none"; - } - - if (filterRecent && ! recent) { - item.style.display = "none"; - } - }); - - // Save filter settings - Kanboard.SetStorageItem("board_filter_" + projectId + "_form-user_id", selectedUserId); - Kanboard.SetStorageItem("board_filter_" + projectId + "_form-category_id", selectedCategoryId); - Kanboard.SetStorageItem("board_filter_" + projectId + "_filter-due-date", ~~(filterDueDate)); - Kanboard.SetStorageItem("board_filter_" + projectId + "_filter-recent", ~~(filterRecent)); - } - - // Load filter events - function filter_load_events() - { - var projectId = $('#board').data('project-id'); - - $("#form-user_id").chosen({ - width: "180px", - no_results_text: $("#form-user_id").data("notfound") - }); - - $("#form-category_id").chosen({ - width: "200px", - no_results_text: $("#form-category_id").data("notfound") - }); - - $("#more-filters").chosen({ - width: "30%", - no_results_text: $("#more-filters").data("notfound") - }); - - $(".apply-filters").change(function(e) { - filter_apply(); - }); - - // Get and set filters from localStorage - $("#form-user_id").val(Kanboard.GetStorageItem("board_filter_" + projectId + "_form-user_id") || -1); - $("#form-user_id").trigger("chosen:updated"); - - $("#form-category_id").val(Kanboard.GetStorageItem("board_filter_" + projectId + "_form-category_id") || -1); - $("#form-category_id").trigger("chosen:updated"); - - if (+Kanboard.GetStorageItem("board_filter_" + projectId + "_filter-due-date")) { - $("#more-filters option[value=filter-due-date]").attr("selected", true); - } - - if (+Kanboard.GetStorageItem("board_filter_" + projectId + "_filter-recent")) { - $("#more-filters option[value=filter-recent]").attr("selected", true); - } - - $("#more-filters").trigger("chosen:updated"); - - filter_apply(); - } - function compactview_load_events() { jQuery(document).on('click', ".filter-toggle-scrolling", function(e) { @@ -401,8 +254,6 @@ Kanboard.Board = (function() { if (Kanboard.Exists("board")) { board_load_events(); - filter_load_events(); - stack_load_events(); compactview_load_events(); keyboard_shortcuts(); } diff --git a/assets/js/src/calendar.js b/assets/js/src/calendar.js index 5e20f962..68da57ee 100644 --- a/assets/js/src/calendar.js +++ b/assets/js/src/calendar.js @@ -1,150 +1,50 @@ -Kanboard.Calendar = (function() { - - var filter_storage_key = ""; - - // Save the new due date for a moved task - function move_calendar_event(calendar_event) - { - var url = $("#calendar").data("save-url") || $("#user-calendar").data("save-url"); - - $.ajax({ - cache: false, - url: url, - contentType: "application/json", - type: "POST", - processData: false, - data: JSON.stringify({ - "task_id": calendar_event.id, - "date_due": calendar_event.start.format() - }) - }); - } - - // Show the user calendar - function show_user_calendar() - { - var calendar = $("#user-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' - }, - viewRender: refresh_user_calendar, - eventDrop: move_calendar_event - }); - } - - // Refresh the calendar events - function refresh_user_calendar() - { - var calendar = $("#user-calendar"); - var url = calendar.data("check-url"); - var params = { - "start": calendar.fullCalendar('getView').start.format(), - "end": calendar.fullCalendar('getView').end.format(), - "user_id": calendar.data("user-id") - }; - - for (var key in params) { - url += "&" + key + "=" + params[key]; - } - - $.getJSON(url, function(events) { - calendar.fullCalendar('removeEvents'); - calendar.fullCalendar('addEventSource', events); - calendar.fullCalendar('rerenderEvents'); - }); - } - - // Show the project calendar - function show_project_calendar() - { - var calendar = $("#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' - }, - viewRender: load_project_filters, - eventDrop: move_calendar_event - }); - } - - // Refresh the calendar events - function refresh_project_calendar(filters) - { - var calendar = $("#calendar"); - var url = calendar.data("check-url"); - var params = { - "start": calendar.fullCalendar('getView').start.format(), - "end": calendar.fullCalendar('getView').end.format() - }; - - jQuery.extend(params, filters); - - for (var key in params) { - url += "&" + key + "=" + params[key]; - } - - $.getJSON(url, function(events) { - calendar.fullCalendar('removeEvents'); - calendar.fullCalendar('addEventSource', events); - calendar.fullCalendar('rerenderEvents'); - }); - } - - // Restore saved filters - function load_project_filters() - { - var filters = Kanboard.GetStorageItem(filter_storage_key); - - if (filters !== "") { - filters = JSON.parse(filters); - - for (var filter in filters) { - $("select[name=" + filter + "]").val(filters[filter]); - } - } - - refresh_project_calendar(filters || {}); - - $('.calendar-filter').change(apply_project_filters); - } - - // Apply filters on change - function apply_project_filters() - { - var filters = {}; - - $('.calendar-filter').each(function() { - filters[$(this).attr("name")] = $(this).val(); - }); - - Kanboard.SetStorageItem(filter_storage_key, JSON.stringify(filters)); - refresh_project_calendar(filters); - } +(function() { jQuery(document).ready(function() { - if (Kanboard.Exists("calendar")) { - filter_storage_key = "calendar_filters_" + $("#calendar").data("project-id"); - show_project_calendar(); - load_project_filters(); - } - else if (Kanboard.Exists("user-calendar")) { - show_user_calendar(); + var calendar = $('#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/screenshot.js b/assets/js/src/screenshot.js index fef37356..dce49c77 100644 --- a/assets/js/src/screenshot.js +++ b/assets/js/src/screenshot.js @@ -5,22 +5,59 @@ Kanboard.Screenshot = (function() { // Setup event listener and workarounds function init() { + destroy(); + if (! window.Clipboard) { // Create a contenteditable element pasteCatcher = document.createElement("div"); - pasteCatcher.setAttribute("contenteditable", ""); + pasteCatcher.id = "screenshot-pastezone"; + pasteCatcher.contentEditable = "true"; + + // Insert the content editable at the top to avoid scrolling down in the board view pasteCatcher.style.opacity = 0; - document.body.appendChild(pasteCatcher); + pasteCatcher.style.position = "fixed"; + pasteCatcher.style.top = 0; + pasteCatcher.style.right = 0; + pasteCatcher.style.width = 0; + + document.body.insertBefore(pasteCatcher, document.body.firstChild); - // Make sure it is always in focus + // Set focus on the contenteditable element pasteCatcher.focus(); - document.addEventListener("click", function() { pasteCatcher.focus(); }); + + // Set the focus when clicked anywhere in the document + document.addEventListener("click", setFocus); + + // Set the focus when clicked in screenshot dropzone (popover) + document.getElementById("screenshot-zone").addEventListener("click", setFocus); } window.addEventListener("paste", pasteHandler); } + // Set focus on the contentEditable element + function setFocus() + { + if (pasteCatcher !== null) { + pasteCatcher.focus(); + } + } + + // Destroy contenteditable + function destroy() + { + if (pasteCatcher != null) { + document.body.removeChild(pasteCatcher); + } + else if (document.getElementById("screenshot-pastezone")) { + document.body.removeChild(document.getElementById("screenshot-pastezone")); + } + + document.removeEventListener("click", setFocus); + pasteCatcher = null; + } + // Paste event callback function pasteHandler(e) { @@ -60,7 +97,6 @@ Kanboard.Screenshot = (function() { function checkInput() { var child = pasteCatcher.childNodes[0]; - pasteCatcher.innerHTML = ""; if (child) { // If the user pastes an image, the src attribute @@ -69,6 +105,8 @@ Kanboard.Screenshot = (function() { createImage(child.src); } } + + pasteCatcher.innerHTML = ""; } // Creates a new image from a given source @@ -84,9 +122,13 @@ Kanboard.Screenshot = (function() { $("input[name=screenshot]").val(sourceString); }; - document.getElementById("screenshot-inner").style.display = "none"; - document.getElementById("screenshot-zone").className = "screenshot-pasted"; - document.getElementById("screenshot-zone").appendChild(pastedImage); + var zone = document.getElementById("screenshot-zone"); + zone.innerHTML = ""; + zone.className = "screenshot-pasted"; + zone.appendChild(pastedImage); + + destroy(); + init(); } jQuery(document).ready(function() { @@ -97,6 +139,7 @@ Kanboard.Screenshot = (function() { }); return { - Init: init + Init: init, + Destroy: destroy }; })();
\ No newline at end of file diff --git a/assets/js/src/swimlane.js b/assets/js/src/swimlane.js index 77f45907..212d6d36 100644 --- a/assets/js/src/swimlane.js +++ b/assets/js/src/swimlane.js @@ -1,4 +1,4 @@ -Kanboard.Swimlane = (function() {
+(function() {
// Expand a Swimlane via display attributes
function expand(swimlaneId)
|