diff options
Diffstat (limited to 'assets/js/app.js')
-rw-r--r-- | assets/js/app.js | 58 |
1 files changed, 57 insertions, 1 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 { |