diff options
Diffstat (limited to 'assets/js/src/Swimlane.js')
-rw-r--r-- | assets/js/src/Swimlane.js | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/assets/js/src/Swimlane.js b/assets/js/src/Swimlane.js index 60dbf41f..f95c6678 100644 --- a/assets/js/src/Swimlane.js +++ b/assets/js/src/Swimlane.js @@ -1,12 +1,43 @@ -function Swimlane(app) { +Kanboard.Swimlane = function(app) { this.app = app; -} +}; + +Kanboard.Swimlane.prototype.execute = function() { + if ($(".swimlanes-table").length) { + this.dragAndDrop(); + } +}; + +Kanboard.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); + } + }); +}; + +Kanboard.Swimlane.prototype.onBoardRendered = function() { + var swimlaneIds = this.getAllCollapsed(); + + for (var i = 0; i < swimlaneIds.length; i++) { + this.collapse(swimlaneIds[i]); + } +}; -Swimlane.prototype.getStorageKey = function() { +Kanboard.Swimlane.prototype.getStorageKey = function() { return "hidden_swimlanes_" + $("#board").data("project-id"); }; -Swimlane.prototype.expand = function(swimlaneId) { +Kanboard.Swimlane.prototype.expand = function(swimlaneId) { var swimlaneIds = this.getAllCollapsed(); var index = swimlaneIds.indexOf(swimlaneId); @@ -22,7 +53,7 @@ Swimlane.prototype.expand = function(swimlaneId) { $('.show-icon-swimlane-' + swimlaneId).css('display', 'none'); }; -Swimlane.prototype.collapse = function(swimlaneId) { +Kanboard.Swimlane.prototype.collapse = function(swimlaneId) { var swimlaneIds = this.getAllCollapsed(); if (swimlaneIds.indexOf(swimlaneId) < 0) { @@ -36,41 +67,15 @@ Swimlane.prototype.collapse = function(swimlaneId) { $('.show-icon-swimlane-' + swimlaneId).css('display', 'inline'); }; -Swimlane.prototype.isCollapsed = function(swimlaneId) { +Kanboard.Swimlane.prototype.isCollapsed = function(swimlaneId) { return this.getAllCollapsed().indexOf(swimlaneId) > -1; }; -Swimlane.prototype.getAllCollapsed = function() { +Kanboard.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; - self.dragAndDrop(); - - $(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); - } - }); -}; - -Swimlane.prototype.dragAndDrop = function() { +Kanboard.Swimlane.prototype.dragAndDrop = function() { var self = this; $(".draggable-row-handle").mouseenter(function() { @@ -100,7 +105,7 @@ Swimlane.prototype.dragAndDrop = function() { }).disableSelection(); }; -Swimlane.prototype.savePosition = function(swimlaneId, position) { +Kanboard.Swimlane.prototype.savePosition = function(swimlaneId, position) { var url = $(".swimlanes-table").data("save-position-url"); var self = this; |