From 3caf97a4ffa3e895678e87ead70bbbbfbb376cfe Mon Sep 17 00:00:00 2001 From: Jacob Hilker Date: Tue, 11 Mar 2014 16:19:45 -0400 Subject: [PATCH] remove iframe and noscript if markdown exists --- karmaworld/assets/js/note-detail.js | 79 ++++++++++----------- karmaworld/templates/notes/note_detail.html | 14 ++-- 2 files changed, 44 insertions(+), 49 deletions(-) diff --git a/karmaworld/assets/js/note-detail.js b/karmaworld/assets/js/note-detail.js index 772419b..b4b3b6a 100644 --- a/karmaworld/assets/js/note-detail.js +++ b/karmaworld/assets/js/note-detail.js @@ -133,50 +133,45 @@ $(function() { // Embed the converted markdown if it is on the page, else default to the iframe if ($('#note-markdown').length > 0) { $('#note-markdown').html(marked($('#note-markdown').data('markdown'))); - } - - $('#note-iframe-toggle').click(function(){ - $('#noteframe').slideToggle(); - autoResize('noteframe'); - }); - - $.ajax(note_contents_url, { - type: 'GET', - xhrFields: { - onprogress: function (progress) { - var percentage = Math.floor((progress.loaded / progress.total) * 100); - writeNoteFrame("

" + percentage + "%

"); - } - }, - success: function(data, textStatus, jqXHR) { - writeNoteFrame(data); - autoResize('noteframe'); - if (pdfControls == true) { - setupPdfViewer(); + } else { + $.ajax(note_contents_url, { + type: 'GET', + xhrFields: { + onprogress: function (progress) { + var percentage = Math.floor((progress.loaded / progress.total) * 100); + writeNoteFrame("

" + percentage + "%

"); + } + }, + success: function(data, textStatus, jqXHR) { + writeNoteFrame(data); + autoResize('noteframe'); + if (pdfControls == true) { + setupPdfViewer(); + } + }, + error: function(data, textStatus, jqXHR) { + writeNoteFrame("

Sorry, your note could not be retrieved.

"); } - }, - error: function(data, textStatus, jqXHR) { - writeNoteFrame("

Sorry, your note could not be retrieved.

"); - } - }); + }); - $('#edit_note_tags').click(function(event) { - $('#note_tags_form').slideToggle(); - }); + $('#edit_note_tags').click(function(event) { + $('#note_tags_form').slideToggle(); + }); - $('#save_note_tags').click(function(event) { - $.ajax({ - url: edit_note_tags_url, - dataType: 'json', - data: $('#note_tags_input').val(), - type: 'POST', - success: function(data) { - $('#note_tags_form').slideUp(); - $('.tags').empty(); - $.each(data.fields.tags, function(index, tag) { - $('.tags').append($('', { class: 'tag-span', text: tag })); - }); - } + $('#save_note_tags').click(function(event) { + $.ajax({ + url: edit_note_tags_url, + dataType: 'json', + data: $('#note_tags_input').val(), + type: 'POST', + success: function(data) { + $('#note_tags_form').slideUp(); + $('.tags').empty(); + $.each(data.fields.tags, function(index, tag) { + $('.tags').append($('', { class: 'tag-span', text: tag })); + }); + } + }); }); - }); + } }); diff --git a/karmaworld/templates/notes/note_detail.html b/karmaworld/templates/notes/note_detail.html index 415576e..030af9d 100644 --- a/karmaworld/templates/notes/note_detail.html +++ b/karmaworld/templates/notes/note_detail.html @@ -193,14 +193,14 @@
{% if note.has_markdown %} - Show original document - {% endif %} - - + id="noteframe"> + + {% endif %}
{% else %} {# note.static_html #} -- 2.25.1