From: Charles Connell Date: Sun, 2 Feb 2014 16:36:05 +0000 (-0500) Subject: Require download to thank and flag a note X-Git-Tag: release-20150131~185 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=73e7f4a2bb0bc86bcff8475de3e0c7b590c7e40d;p=oweals%2Fkarmaworld.git Require download to thank and flag a note --- diff --git a/karmaworld/assets/js/note-detail.js b/karmaworld/assets/js/note-detail.js index 9bd282f..150ef2d 100644 --- a/karmaworld/assets/js/note-detail.js +++ b/karmaworld/assets/js/note-detail.js @@ -1,3 +1,5 @@ + + // resize the iframe based on internal contents on page load function autoResize(id){ var newheight; @@ -62,6 +64,13 @@ function setupPdfViewer() { rescalePdf(pdfViewer, parseInt(noteFrame.width)); } +function writeNoteFrame(contents) { + var dstFrame = document.getElementById('noteframe'); + var dstDoc = dstFrame.contentDocument || dstFrame.contentWindow.document; + dstDoc.write(contents); + dstDoc.close(); +} + $(function() { $("#thank-button").click(function(event) { event.preventDefault(); @@ -120,4 +129,26 @@ $(function() { }) }; }); + + $.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.

"); + } + }); + }); diff --git a/karmaworld/templates/notes/note_detail.html b/karmaworld/templates/notes/note_detail.html index 44d97b6..a1cdff8 100644 --- a/karmaworld/templates/notes/note_detail.html +++ b/karmaworld/templates/notes/note_detail.html @@ -14,46 +14,17 @@ var note_thank_url = "{% url 'thank_note' note.id %}" var note_flag_url = "{% url 'flag_note' note.id %}" var note_downloaded_url = "{% url 'downloaded_note' note.id %}" + var note_contents_url = "{{ S3_URL }}{{ note.get_relative_s3_path }}" + {% if pdf_controls %} + var pdfControls = true; + {% else %} + var pdfControls = false; + {% endif %} var csrf_token = "{{ csrf_token }}"; - - - {% endblock %} {% block content %} @@ -85,40 +56,74 @@
-
- note_flag - note_flag -
-
- note_thank - note_thank -
-
- {% if user.is_authenticated %} + {% if user.is_authenticated %} +
+ {% if already_flagged %} + note_flag + {% else %} + + note_flag + + {% endif %} +
+
+ {% if already_thanked %} + note_thank + {% else %} + + note_thank + + {% endif %} +
+
note_download - {% else %} - note_download +
+ {% else %} +
+ note_flag +
+
+ note_thank +
+
+ note_download +
{% endif %} -
+
diff --git a/karmaworld/templates/partial/opentip_settings.html b/karmaworld/templates/partial/opentip_settings.html new file mode 100644 index 0000000..6c47c4f --- /dev/null +++ b/karmaworld/templates/partial/opentip_settings.html @@ -0,0 +1,5 @@ +data-ot-target="true" +data-ot-tip-joint="top center" +data-ot-target-joint="bottom center" +data-ot-background="white" +data-ot-border-color="black"