From 4e07ad6555bee33c6e48992f8f8e56706aff7c58 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 5 Feb 2016 18:30:16 -0500 Subject: Improve subtask toggle status and timer --- assets/js/src/App.js | 15 ++------------- assets/js/src/Subtask.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 assets/js/src/Subtask.js (limited to 'assets/js/src') diff --git a/assets/js/src/App.js b/assets/js/src/App.js index cd5df66e..d44d9f81 100644 --- a/assets/js/src/App.js +++ b/assets/js/src/App.js @@ -8,6 +8,7 @@ function App() { this.popover = new Popover(this); this.task = new Task(); this.project = new Project(); + this.subtask = new Subtask(); this.keyboardShortcuts(); this.chosen(); this.poll(); @@ -37,23 +38,11 @@ App.prototype.listen = function() { this.search.listen(); this.task.listen(); this.swimlane.listen(); + this.subtask.listen(); this.search.focus(); this.autoComplete(); this.datePicker(); this.focus(); - - $(document).on("click", ".ajax-replace", function(e) { - e.preventDefault(); - var el = $(this); - - $.ajax({ - cache: false, - url: el.attr("href"), - success: function(data) { - el.replaceWith(data); - } - }); - }); }; App.prototype.refresh = function() { diff --git a/assets/js/src/Subtask.js b/assets/js/src/Subtask.js new file mode 100644 index 00000000..c6cae641 --- /dev/null +++ b/assets/js/src/Subtask.js @@ -0,0 +1,34 @@ +function Subtask() { +} + +Subtask.prototype.listen = function() { + $(document).on("click", ".subtask-toggle-status", function(e) { + e.preventDefault(); + var el = $(this); + + $.ajax({ + cache: false, + url: el.attr("href"), + success: function(data) { + if (el.hasClass("subtask-refresh-table")) { + $(".subtasks-table").replaceWith(data); + } else { + el.replaceWith(data); + } + } + }); + }); + + $(document).on("click", ".subtask-toggle-timer", function(e) { + e.preventDefault(); + var el = $(this); + + $.ajax({ + cache: false, + url: el.attr("href"), + success: function(data) { + $(".subtasks-table").replaceWith(data); + } + }); + }); +}; -- cgit v1.2.3