diff options
author | Nihad Abbasov <narkoz.2008@gmail.com> | 2012-08-07 17:17:29 +0400 |
---|---|---|
committer | Nihad Abbasov <narkoz.2008@gmail.com> | 2012-08-08 12:12:05 +0400 |
commit | 1ec3bd3f8d237c1afb73d4ad1b7a0c24f9a6887c (patch) | |
tree | 4778e0f264c3cc8ac845da878f5b8d226be9b422 /app/assets/javascripts/application.js | |
parent | 34ba4e135202db79ceb29c738ee476c5f54acf50 (diff) |
ability to preview notes
Diffstat (limited to 'app/assets/javascripts/application.js')
-rw-r--r-- | app/assets/javascripts/application.js | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 56e26a06f18..be6eb922f53 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,6 +18,7 @@ //= require chosen-jquery //= require raphael //= require branch-graph +//= require Markdown.Converter //= require_tree . $(document).ready(function(){ @@ -26,7 +27,6 @@ $(document).ready(function(){ $(this).select(); }); - $('body').on('ajax:complete, ajax:beforeSend, submit', 'form', function(e){ var buttons = $('[type="submit"]', this); switch( e.type ){ @@ -70,6 +70,24 @@ $(document).ready(function(){ $(".supp_diff_link").bind("click", function() { showDiff(this); }); + + /** + * Note markdown preview + * + */ + $('#preview-link').on('click', function(e) { + var note = $('#note_note').val(); + if (note.trim().length === 0) { note = 'Nothing to preview'; } + var converter = new Markdown.Converter(); + var md_preview = converter.makeHtml(note); + $('#preview-note').html(md_preview); + + var previewLinkText = ($(this).text() == 'Preview' ? 'Edit' : 'Preview'); + $(this).text(previewLinkText); + + $('#preview-note, #note_note').toggle(); + e.preventDefault(); + }); }); function focusSearch() { @@ -108,6 +126,6 @@ function showDiff(link) { })(jQuery); -function ajaxGet(url) { - $.ajax({type: "GET", url: url, dataType: "script"}); +function ajaxGet(url) { + $.ajax({type: "GET", url: url, dataType: "script"}); } |