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 | |
parent | 3525458926dfa47e6c7bcedb4304cc243e78d47a (diff) |
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.
-rw-r--r-- | sitestatic/archweb.css | 4 | ||||
-rw-r--r-- | sitestatic/archweb.js | 17 | ||||
-rw-r--r-- | templates/news/add.html | 18 |
3 files changed, 20 insertions, 19 deletions
diff --git a/sitestatic/archweb.css b/sitestatic/archweb.css index f4b791ac..efa5c04d 100644 --- a/sitestatic/archweb.css +++ b/sitestatic/archweb.css @@ -653,6 +653,10 @@ div.news-article .article-info { width: 75%; } +#news-preview { + display: none; +} + /* todolists: list */ .todolist-nav { float: right; diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js index b8ad6817..ae4a1f1c 100644 --- a/sitestatic/archweb.js +++ b/sitestatic/archweb.js @@ -178,23 +178,6 @@ if (typeof $ !== 'undefined' && typeof $.tablesorter !== 'undefined') { }; })(jQuery); -/* news/add.html */ -function enablePreview() { - $('#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()); - }); -} - /* packages/details.html */ function ajaxifyFiles() { $('#filelink').click(function(event) { 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 %} |