From 0f6ece0c3095492cef30383d4c5530d9c57779f9 Mon Sep 17 00:00:00 2001 From: Fernando Blat Date: Thu, 22 Dec 2016 17:38:02 +0100 Subject: [PATCH] Toggle only works on column when the section is not visible --- app/assets/javascripts/allegations.js.coffee | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) 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()