js: move code altering show issue page to its own function

This commit is contained in:
Frédéric Péters 2020-05-22 10:39:39 +02:00
parent fd7319f48f
commit 8ec89c7a33
1 changed files with 19 additions and 20 deletions

View File

@ -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