From 2ffafaac7e8ee985eebe8c89248fc5daf6b2276e Mon Sep 17 00:00:00 2001 From: Stanislav Baiduzhyi Date: Wed, 5 Aug 2015 13:23:06 +0200 Subject: Renaming files for case-sensitive filesystems. --- assets/js/src/Board.js | 164 ++++++++++++++++++++++++++++++++++++++++++++ assets/js/src/Calendar.js | 49 +++++++++++++ assets/js/src/Screenshot.js | 131 +++++++++++++++++++++++++++++++++++ assets/js/src/Swimlane.js | 67 ++++++++++++++++++ assets/js/src/board.js | 164 -------------------------------------------- assets/js/src/calendar.js | 49 ------------- assets/js/src/screenshot.js | 131 ----------------------------------- assets/js/src/swimlane.js | 67 ------------------ 8 files changed, 411 insertions(+), 411 deletions(-) create mode 100644 assets/js/src/Board.js create mode 100644 assets/js/src/Calendar.js create mode 100644 assets/js/src/Screenshot.js create mode 100644 assets/js/src/Swimlane.js delete mode 100644 assets/js/src/board.js delete mode 100644 assets/js/src/calendar.js delete mode 100644 assets/js/src/screenshot.js delete mode 100644 assets/js/src/swimlane.js (limited to 'assets/js/src') diff --git a/assets/js/src/Board.js b/assets/js/src/Board.js new file mode 100644 index 00000000..7015f1c6 --- /dev/null +++ b/assets/js/src/Board.js @@ -0,0 +1,164 @@ +function Board() { + this.app = null; + this.checkInterval = null; +} + +Board.prototype.execute = function(app) { + this.app = app; + this.app.swimlane.refresh(); + this.app.swimlane.listen(); + this.poll(); + this.keyboardShortcuts(); + this.resizeColumnHeight(); + this.listen(); + this.dragAndDrop(); + this.compactView(); + + $(window).resize(this.resizeColumnHeight); +}; + +Board.prototype.poll = function() { + var interval = parseInt($("#board").attr("data-check-interval")); + + if (interval > 0) { + this.checkInterval = window.setInterval(this.check.bind(this), interval * 1000); + } +}; + +Board.prototype.check = function() { + if (this.app.isVisible()) { + + var self = this; + this.app.showLoadingIcon(); + + $.ajax({ + cache: false, + url: $("#board").attr("data-check-url"), + statusCode: { + 200: function(data) { self.refresh(data); }, + 304: function () { self.app.hideLoadingIcon(); } + } + }); + } +}; + +Board.prototype.save = function(taskId, columnId, position, swimlaneId) { + this.app.showLoadingIcon(); + + $.ajax({ + cache: false, + url: $("#board").attr("data-save-url"), + contentType: "application/json", + type: "POST", + processData: false, + data: JSON.stringify({ + "task_id": taskId, + "column_id": columnId, + "swimlane_id": swimlaneId, + "position": position + }), + success: this.refresh.bind(this), + error: this.app.hideLoadingIcon.bind(this) + }); +}; + +Board.prototype.refresh = function(data) { + $("#board-container").replaceWith(data); + + this.app.listen(); + this.app.swimlane.refresh(); + this.app.swimlane.listen(); + this.resizeColumnHeight(); + this.app.hideLoadingIcon(); + this.listen(); + this.dragAndDrop(); + this.compactView(); +}; + +Board.prototype.resizeColumnHeight = function() { + var position = $(".board-swimlane").position(); + + if (position) { + $(".board-task-list").height($(window).height() - position.top); + } +}; + +Board.prototype.dragAndDrop = function() { + var self = this; + $(".board-task-list").sortable({ + delay: 300, + distance: 5, + connectWith: ".board-task-list", + placeholder: "draggable-placeholder", + items: ".draggable-item", + stop: function(event, ui) { + self.save( + ui.item.attr('data-task-id'), + ui.item.parent().attr("data-column-id"), + ui.item.index() + 1, + ui.item.parent().attr('data-swimlane-id') + ); + } + }); +}; + +Board.prototype.listen = function() { + var self = this; + + $(document).on("click", ".task-board", function() { + window.location = $(this).data("task-url"); + }); + + $(document).on('click', ".filter-toggle-scrolling", function(e) { + e.preventDefault(); + self.toggleCompactView(); + }); +}; + +Board.prototype.toggleCompactView = function() { + var scrolling = localStorage.getItem("horizontal_scroll") || 1; + localStorage.setItem("horizontal_scroll", scrolling == 0 ? 1 : 0); + this.compactView(); +}; + +Board.prototype.compactView = function() { + if (localStorage.getItem("horizontal_scroll") == 0) { + $(".filter-wide").show(); + $(".filter-compact").hide(); + + $("#board-container").addClass("board-container-compact"); + $("#board th").addClass("board-column-compact"); + } + else { + $(".filter-wide").hide(); + $(".filter-compact").show(); + + $("#board-container").removeClass("board-container-compact"); + $("#board th").removeClass("board-column-compact"); + } +}; + +Board.prototype.toggleCollapsedMode = function() { + var self = this; + this.app.showLoadingIcon(); + + $.ajax({ + cache: false, + url: $('.filter-display-mode:not([style="display: none;"]) a').attr('href'), + success: function(data) { + $('.filter-display-mode').toggle(); + self.refresh(data); + } + }); +}; + +Board.prototype.keyboardShortcuts = function() { + var self = this; + + Mousetrap.bind("c", function() { self.toggleCompactView(); }); + Mousetrap.bind("s", function() { self.toggleCollapsedMode(); }); + + Mousetrap.bind("n", function() { + self.app.popover.open($("#board").data("task-creation-url")); + }); +}; diff --git a/assets/js/src/Calendar.js b/assets/js/src/Calendar.js new file mode 100644 index 00000000..ffb00dcd --- /dev/null +++ b/assets/js/src/Calendar.js @@ -0,0 +1,49 @@ +function Calendar() { + +} + +Calendar.prototype.execute = function() { + 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 new file mode 100644 index 00000000..fd50f8e7 --- /dev/null +++ b/assets/js/src/Screenshot.js @@ -0,0 +1,131 @@ +function Screenshot() { + this.pasteCatcher = null; +} + +Screenshot.prototype.execute = function() { + this.initialize(); +}; + +// Setup event listener and workarounds +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 +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 +Screenshot.prototype.setFocus = function() { + if (this.pasteCatcher !== null) { + this.pasteCatcher.focus(); + } +}; + +// Paste event callback +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 +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); + } + } + + pasteCatcher.innerHTML = ""; +}; + +// Creates a new image from a given source +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/Swimlane.js b/assets/js/src/Swimlane.js new file mode 100644 index 00000000..ce18dbfa --- /dev/null +++ b/assets/js/src/Swimlane.js @@ -0,0 +1,67 @@ +function Swimlane() { +} + +Swimlane.prototype.getStorageKey = function() { + return "hidden_swimlanes_" + $("#board").data("project-id"); +}; + +Swimlane.prototype.expand = function(swimlaneId) { + var swimlaneIds = this.getAllCollapsed(); + var index = swimlaneIds.indexOf(swimlaneId); + + if (index > -1) { + swimlaneIds.splice(index, 1); + } + + localStorage.setItem(this.getStorageKey(), JSON.stringify(swimlaneIds)); + + $('.swimlane-row-' + swimlaneId).css('display', 'table-row'); + $('.show-icon-swimlane-' + swimlaneId).css('display', 'none'); + $('.hide-icon-swimlane-' + swimlaneId).css('display', 'inline'); +}; + +Swimlane.prototype.collapse = function(swimlaneId) { + var swimlaneIds = this.getAllCollapsed(); + + if (swimlaneIds.indexOf(swimlaneId) < 0) { + swimlaneIds.push(swimlaneId); + localStorage.setItem(this.getStorageKey(), JSON.stringify(swimlaneIds)); + } + + $('.swimlane-row-' + swimlaneId).css('display', 'none'); + $('.show-icon-swimlane-' + swimlaneId).css('display', 'inline'); + $('.hide-icon-swimlane-' + swimlaneId).css('display', 'none'); +}; + +Swimlane.prototype.isCollapsed = function(swimlaneId) { + return this.getAllCollapsed().indexOf(swimlaneId) > -1; +}; + +Swimlane.prototype.getAllCollapsed = function() { + return JSON.parse(localStorage.getItem(this.getStorageKey())) || []; +}; + +Swimlane.prototype.refresh = function() { + var swimlaneIds = this.getAllCollapsed(); + + for (var i = 0; i < swimlaneIds.length; i++) { + this.collapse(swimlaneIds[i]); + } +}; + +Swimlane.prototype.listen = function() { + var self = this; + + $(document).on('click', ".board-swimlane-toggle", function(e) { + e.preventDefault(); + + var swimlaneId = $(this).data('swimlane-id'); + + if (self.isCollapsed(swimlaneId)) { + self.expand(swimlaneId); + } + else { + self.collapse(swimlaneId); + } + }); +}; diff --git a/assets/js/src/board.js b/assets/js/src/board.js deleted file mode 100644 index 7015f1c6..00000000 --- a/assets/js/src/board.js +++ /dev/null @@ -1,164 +0,0 @@ -function Board() { - this.app = null; - this.checkInterval = null; -} - -Board.prototype.execute = function(app) { - this.app = app; - this.app.swimlane.refresh(); - this.app.swimlane.listen(); - this.poll(); - this.keyboardShortcuts(); - this.resizeColumnHeight(); - this.listen(); - this.dragAndDrop(); - this.compactView(); - - $(window).resize(this.resizeColumnHeight); -}; - -Board.prototype.poll = function() { - var interval = parseInt($("#board").attr("data-check-interval")); - - if (interval > 0) { - this.checkInterval = window.setInterval(this.check.bind(this), interval * 1000); - } -}; - -Board.prototype.check = function() { - if (this.app.isVisible()) { - - var self = this; - this.app.showLoadingIcon(); - - $.ajax({ - cache: false, - url: $("#board").attr("data-check-url"), - statusCode: { - 200: function(data) { self.refresh(data); }, - 304: function () { self.app.hideLoadingIcon(); } - } - }); - } -}; - -Board.prototype.save = function(taskId, columnId, position, swimlaneId) { - this.app.showLoadingIcon(); - - $.ajax({ - cache: false, - url: $("#board").attr("data-save-url"), - contentType: "application/json", - type: "POST", - processData: false, - data: JSON.stringify({ - "task_id": taskId, - "column_id": columnId, - "swimlane_id": swimlaneId, - "position": position - }), - success: this.refresh.bind(this), - error: this.app.hideLoadingIcon.bind(this) - }); -}; - -Board.prototype.refresh = function(data) { - $("#board-container").replaceWith(data); - - this.app.listen(); - this.app.swimlane.refresh(); - this.app.swimlane.listen(); - this.resizeColumnHeight(); - this.app.hideLoadingIcon(); - this.listen(); - this.dragAndDrop(); - this.compactView(); -}; - -Board.prototype.resizeColumnHeight = function() { - var position = $(".board-swimlane").position(); - - if (position) { - $(".board-task-list").height($(window).height() - position.top); - } -}; - -Board.prototype.dragAndDrop = function() { - var self = this; - $(".board-task-list").sortable({ - delay: 300, - distance: 5, - connectWith: ".board-task-list", - placeholder: "draggable-placeholder", - items: ".draggable-item", - stop: function(event, ui) { - self.save( - ui.item.attr('data-task-id'), - ui.item.parent().attr("data-column-id"), - ui.item.index() + 1, - ui.item.parent().attr('data-swimlane-id') - ); - } - }); -}; - -Board.prototype.listen = function() { - var self = this; - - $(document).on("click", ".task-board", function() { - window.location = $(this).data("task-url"); - }); - - $(document).on('click', ".filter-toggle-scrolling", function(e) { - e.preventDefault(); - self.toggleCompactView(); - }); -}; - -Board.prototype.toggleCompactView = function() { - var scrolling = localStorage.getItem("horizontal_scroll") || 1; - localStorage.setItem("horizontal_scroll", scrolling == 0 ? 1 : 0); - this.compactView(); -}; - -Board.prototype.compactView = function() { - if (localStorage.getItem("horizontal_scroll") == 0) { - $(".filter-wide").show(); - $(".filter-compact").hide(); - - $("#board-container").addClass("board-container-compact"); - $("#board th").addClass("board-column-compact"); - } - else { - $(".filter-wide").hide(); - $(".filter-compact").show(); - - $("#board-container").removeClass("board-container-compact"); - $("#board th").removeClass("board-column-compact"); - } -}; - -Board.prototype.toggleCollapsedMode = function() { - var self = this; - this.app.showLoadingIcon(); - - $.ajax({ - cache: false, - url: $('.filter-display-mode:not([style="display: none;"]) a').attr('href'), - success: function(data) { - $('.filter-display-mode').toggle(); - self.refresh(data); - } - }); -}; - -Board.prototype.keyboardShortcuts = function() { - var self = this; - - Mousetrap.bind("c", function() { self.toggleCompactView(); }); - Mousetrap.bind("s", function() { self.toggleCollapsedMode(); }); - - Mousetrap.bind("n", function() { - self.app.popover.open($("#board").data("task-creation-url")); - }); -}; diff --git a/assets/js/src/calendar.js b/assets/js/src/calendar.js deleted file mode 100644 index ffb00dcd..00000000 --- a/assets/js/src/calendar.js +++ /dev/null @@ -1,49 +0,0 @@ -function Calendar() { - -} - -Calendar.prototype.execute = function() { - 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 deleted file mode 100644 index fd50f8e7..00000000 --- a/assets/js/src/screenshot.js +++ /dev/null @@ -1,131 +0,0 @@ -function Screenshot() { - this.pasteCatcher = null; -} - -Screenshot.prototype.execute = function() { - this.initialize(); -}; - -// Setup event listener and workarounds -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 -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 -Screenshot.prototype.setFocus = function() { - if (this.pasteCatcher !== null) { - this.pasteCatcher.focus(); - } -}; - -// Paste event callback -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 -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); - } - } - - pasteCatcher.innerHTML = ""; -}; - -// Creates a new image from a given source -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/swimlane.js b/assets/js/src/swimlane.js deleted file mode 100644 index ce18dbfa..00000000 --- a/assets/js/src/swimlane.js +++ /dev/null @@ -1,67 +0,0 @@ -function Swimlane() { -} - -Swimlane.prototype.getStorageKey = function() { - return "hidden_swimlanes_" + $("#board").data("project-id"); -}; - -Swimlane.prototype.expand = function(swimlaneId) { - var swimlaneIds = this.getAllCollapsed(); - var index = swimlaneIds.indexOf(swimlaneId); - - if (index > -1) { - swimlaneIds.splice(index, 1); - } - - localStorage.setItem(this.getStorageKey(), JSON.stringify(swimlaneIds)); - - $('.swimlane-row-' + swimlaneId).css('display', 'table-row'); - $('.show-icon-swimlane-' + swimlaneId).css('display', 'none'); - $('.hide-icon-swimlane-' + swimlaneId).css('display', 'inline'); -}; - -Swimlane.prototype.collapse = function(swimlaneId) { - var swimlaneIds = this.getAllCollapsed(); - - if (swimlaneIds.indexOf(swimlaneId) < 0) { - swimlaneIds.push(swimlaneId); - localStorage.setItem(this.getStorageKey(), JSON.stringify(swimlaneIds)); - } - - $('.swimlane-row-' + swimlaneId).css('display', 'none'); - $('.show-icon-swimlane-' + swimlaneId).css('display', 'inline'); - $('.hide-icon-swimlane-' + swimlaneId).css('display', 'none'); -}; - -Swimlane.prototype.isCollapsed = function(swimlaneId) { - return this.getAllCollapsed().indexOf(swimlaneId) > -1; -}; - -Swimlane.prototype.getAllCollapsed = function() { - return JSON.parse(localStorage.getItem(this.getStorageKey())) || []; -}; - -Swimlane.prototype.refresh = function() { - var swimlaneIds = this.getAllCollapsed(); - - for (var i = 0; i < swimlaneIds.length; i++) { - this.collapse(swimlaneIds[i]); - } -}; - -Swimlane.prototype.listen = function() { - var self = this; - - $(document).on('click', ".board-swimlane-toggle", function(e) { - e.preventDefault(); - - var swimlaneId = $(this).data('swimlane-id'); - - if (self.isCollapsed(swimlaneId)) { - self.expand(swimlaneId); - } - else { - self.collapse(swimlaneId); - } - }); -}; -- cgit v1.2.3