From 8ec89c7a3381739c601b2faa450e9131119a89c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 22 May 2020 10:39:39 +0200 Subject: [PATCH] js: move code altering show issue page to its own function --- javascripts/theme.js | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/javascripts/theme.js b/javascripts/theme.js index 34b6e18..29cb5da 100644 --- a/javascripts/theme.js +++ b/javascripts/theme.js @@ -128,25 +128,7 @@ function alter_new_issue_page() { }); } -$(function() { - $('.wiki table tr:first-child td').on('click', sort_table).css('cursor', 'row-resize'); - - /* 440 is header image height (500px) - header height (60px) */ - var timestamp = ((new Date().getTime() / 1000) % 86400 ) / (86400 / 440); - $('#top-menu').css('background-position', '0 -' + timestamp + 'px'); - - // don't allow assigning issues to Entr'ouvert group - $('body.controller-issues #issue_assigned_to_id [value=21]').hide(); - - if ($('body.controller-issues.action-new').length == 1) { - alter_new_issue_page(); - return; - } - - if ($('body.controller-issues.action-show').length == 0) { - return; - } - +function alter_issue_show_page() { if ($('#attachments_fields').length) { var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { @@ -255,7 +237,6 @@ $(function() { }); } - var user_href = $('#loggedas a').attr('href'); if (user_href) { $('div.journal.has-notes').each(function(idx, entry) { @@ -315,6 +296,24 @@ $(function() { $main.css('background-attachment', 'fixed'); $main.css('background-image', 'url(' + url + ')'); } +} + +$(function() { + $('.wiki table tr:first-child td').on('click', sort_table).css('cursor', 'row-resize'); + + /* 440 is header image height (500px) - header height (60px) */ + var timestamp = ((new Date().getTime() / 1000) % 86400 ) / (86400 / 440); + $('#top-menu').css('background-position', '0 -' + timestamp + 'px'); + + // don't allow assigning issues to Entr'ouvert group + $('body.controller-issues #issue_assigned_to_id [value=21]').hide(); + + if ($('body.controller-issues.action-new').length == 1) { + alter_new_issue_page(); + } + if ($('body.controller-issues.action-show').length == 1) { + alter_issue_show_page(); + } // custom features, enabled on user request