diff options
author | Jelle van der Waa <jelle@vdwaa.nl> | 2019-01-29 21:02:53 +0100 |
---|---|---|
committer | Jelle van der Waa <jelle@archlinux.org> | 2019-02-18 16:42:51 +0100 |
commit | 0c27985c1c8d19d70bab8510770b3ea1df43e5a5 (patch) | |
tree | b474a84e423121d6f4e952033288a21e53c7b937 /templates | |
parent | 3525458926dfa47e6c7bcedb4304cc243e78d47a (diff) | |
download | archweb-0c27985c1c8d19d70bab8510770b3ea1df43e5a5.tar.gz archweb-0c27985c1c8d19d70bab8510770b3ea1df43e5a5.zip |
news: get rid of inline css styles
Remove the usage of an inline style for hiding #news-preview and hide it
in our global css. Also move the newspreview function to it's sole user
to reduce our global JS size.
Diffstat (limited to 'templates')
-rw-r--r-- | templates/news/add.html | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/templates/news/add.html b/templates/news/add.html index f171b503..7efc7b72 100644 --- a/templates/news/add.html +++ b/templates/news/add.html @@ -29,13 +29,27 @@ </form> </div> -<div id="news-preview" class="news-article box" style="display:none;"> +<div id="news-preview" class="news-article box"> <h2>News Preview: <span id="news-preview-title"></span></h2> <div id="news-preview-data" class="article-content"></div> </div> {% load cdn %}{% jquery %} <script type="text/javascript" src="{% static "archweb.js" %}"></script> <script type="text/javascript" nonce={{ CSP_NONCE }}> -$(document).ready(enablePreview); +$(document).ready(function() { + $('#news-preview-button').click(function(event) { + event.preventDefault(); + $.post('/news/preview/', { + data: $('#id_content').val(), + csrfmiddlewaretoken: $('#newsform input[name=csrfmiddlewaretoken]').val() + }, + function(data) { + $('#news-preview-data').html(data); + $('#news-preview').show(); + } + ); + $('#news-preview-title').html($('#id_title').val()); + }); +}); </script> {% endblock %} |