diff options
Diffstat (limited to 'assets/js')
-rw-r--r-- | assets/js/app.js | 58 | ||||
-rw-r--r-- | assets/js/base.js | 54 | ||||
-rw-r--r-- | assets/js/task.js | 4 |
3 files changed, 113 insertions, 3 deletions
diff --git a/assets/js/app.js b/assets/js/app.js index 1342e090..286746d0 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -80,6 +80,54 @@ var Kanboard = (function() { return true; }, + // Generate Markdown preview + MarkdownPreview: function(e) { + + e.preventDefault(); + + var link = $(this); + var nav = $(this).closest("ul"); + var write = $(".write-area"); + var preview = $(".preview-area"); + var textarea = $("textarea"); + + var request = $.ajax({ + url: "?controller=app&action=preview", + contentType: "application/json", + type: "POST", + processData: false, + dataType: "html", + data: JSON.stringify({ + "text": textarea.val() + }), + }); + + request.done(function(data) { + + nav.find("li").removeClass("form-tab-selected"); + link.parent().addClass("form-tab-selected"); + + preview.find(".markdown").html(data) + preview.css("height", textarea.css("height")); + preview.css("width", textarea.css("width")); + + write.hide(); + preview.show(); + }); + }, + + // Show the Markdown textarea + MarkdownWriter: function(e) { + + e.preventDefault(); + + $(this).closest("ul").find("li").removeClass("form-tab-selected") + $(this).parent().addClass("form-tab-selected"); + + $(".write-area").show(); + $(".preview-area").hide(); + }, + // Common init Init: function() { @@ -99,10 +147,15 @@ var Kanboard = (function() { $("#board-selector").change(function() { window.location = $(this).attr("data-board-url").replace(/%d/g, $(this).val()); }); + + // Markdown Preview for textareas + $("#markdown-preview").click(Kanboard.MarkdownPreview); + $("#markdown-write").click(Kanboard.MarkdownWriter); } }; -})();// Board related functions +})(); +// Board related functions Kanboard.Board = (function() { var checkInterval = null; @@ -261,13 +314,16 @@ Kanboard.Board = (function() { Kanboard.Task = (function() { return { + Init: function() { + // Image preview for attachments $(".file-popover").click(Kanboard.Popover); } }; })(); + Kanboard.Analytic = (function() { return { diff --git a/assets/js/base.js b/assets/js/base.js index 0a17696e..d6c332f4 100644 --- a/assets/js/base.js +++ b/assets/js/base.js @@ -65,6 +65,54 @@ var Kanboard = (function() { return true; }, + // Generate Markdown preview + MarkdownPreview: function(e) { + + e.preventDefault(); + + var link = $(this); + var nav = $(this).closest("ul"); + var write = $(".write-area"); + var preview = $(".preview-area"); + var textarea = $("textarea"); + + var request = $.ajax({ + url: "?controller=app&action=preview", + contentType: "application/json", + type: "POST", + processData: false, + dataType: "html", + data: JSON.stringify({ + "text": textarea.val() + }), + }); + + request.done(function(data) { + + nav.find("li").removeClass("form-tab-selected"); + link.parent().addClass("form-tab-selected"); + + preview.find(".markdown").html(data) + preview.css("height", textarea.css("height")); + preview.css("width", textarea.css("width")); + + write.hide(); + preview.show(); + }); + }, + + // Show the Markdown textarea + MarkdownWriter: function(e) { + + e.preventDefault(); + + $(this).closest("ul").find("li").removeClass("form-tab-selected") + $(this).parent().addClass("form-tab-selected"); + + $(".write-area").show(); + $(".preview-area").hide(); + }, + // Common init Init: function() { @@ -84,7 +132,11 @@ var Kanboard = (function() { $("#board-selector").change(function() { window.location = $(this).attr("data-board-url").replace(/%d/g, $(this).val()); }); + + // Markdown Preview for textareas + $("#markdown-preview").click(Kanboard.MarkdownPreview); + $("#markdown-write").click(Kanboard.MarkdownWriter); } }; -})();
\ No newline at end of file +})(); diff --git a/assets/js/task.js b/assets/js/task.js index 8ce283cd..968f25db 100644 --- a/assets/js/task.js +++ b/assets/js/task.js @@ -2,10 +2,12 @@ Kanboard.Task = (function() { return { + Init: function() { + // Image preview for attachments $(".file-popover").click(Kanboard.Popover); } }; -})();
\ No newline at end of file +})(); |