diff --git a/app/assets/javascripts/allegations.js.coffee b/app/assets/javascripts/allegations.js.coffee index 34b51e798..d57fa30ed 100644 --- a/app/assets/javascripts/allegations.js.coffee +++ b/app/assets/javascripts/allegations.js.coffee @@ -1,19 +1,17 @@ App.Allegations = - + toggle_comments: -> $('.draft-allegation').toggleClass('comments-on'); - + initialize: -> $('.js-toggle-allegations .draft-panel').on - click: -> - console.log("panel") + click: (e) -> + e.preventDefault(); + e.stopPropagation(); App.Allegations.toggle_comments() - + $('.js-toggle-allegations').on - click: -> - console.log("column") - if $('.draft-allegation').hasClass('comments-on') - console.log("comments-on") - return false - else + click: (e) -> + # Toggle comments when the section title is visible + if $(this).find('.draft-panel .panel-title:visible').length == 0 App.Allegations.toggle_comments()