don't use inline js to adhere to csp

pull/6827/head
Markus Kahl 6 years ago
parent 80150c6006
commit 3e1efcde0d
  1. 14
      app/assets/javascripts/backlogs/taskboard.js
  2. 8
      app/helpers/rb_master_backlogs_helper.rb

@ -66,6 +66,8 @@ RB.Taskboard = (function ($) {
this.initializeNewButtons();
this.initializeSortables();
this.initializeTaskboardMenus();
},
initializeNewButtons : function () {
@ -117,6 +119,18 @@ RB.Taskboard = (function ($) {
});
},
initializeTaskboardMenus : function () {
var toggleOpen = "open icon-pulldown-up icon-pulldown";
$(".backlog .menu > div.menu-trigger").on("click", function() {
$(this).toggleClass(toggleOpen);
});
$(".backlog .menu > ul.items li.item").on("click", function() {
$(this).closest(".menu").find("div.menu-trigger").toggleClass(toggleOpen);
});
},
dragComplete: function (e, ui) {
// Handler is triggered for source and target. Thus the need to check.
var isDropTarget = (ui.sender === null);

@ -37,15 +37,13 @@ module RbMasterBacklogsHelper
include Redmine::I18n
def render_backlog_menu(backlog)
closeJS = "jQuery(this).closest('ul').siblings('.menu-trigger').toggleClass('open icon-pulldown-up icon-pulldown');"
openJS = "jQuery(this).toggleClass('open icon-pulldown-up icon-pulldown');"
# associated javascript defined in taskboard.js
content_tag(:div, class: 'menu') do
[
content_tag(:div, '', class: "menu-trigger icon-context icon-pulldown icon-small", onClick: openJS),
content_tag(:div, '', class: "menu-trigger icon-context icon-pulldown icon-small"),
content_tag(:ul, class: 'items') do
backlog_menu_items_for(backlog).map { |item|
content_tag(:li, item, class: 'item', onClick: closeJS)
content_tag(:li, item, class: 'item')
}.join.html_safe
end
].join.html_safe

Loading…
Cancel
Save