From 1167a4575eab59af6b4612bd7e51a1abe997cc6f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 15 Oct 2016 01:02:20 +0200 Subject: [PATCH] Fixed issue with target.toggleClass('is-hovered') if in the meantime the navigation bar is re-rendered and .is-hovered git lost. --- .../_dashboard/first_steps_clues.coffee | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_dashboard/first_steps_clues.coffee b/app/assets/javascripts/app/controllers/_dashboard/first_steps_clues.coffee index e995c316e..65bc6dbd6 100644 --- a/app/assets/javascripts/app/controllers/_dashboard/first_steps_clues.coffee +++ b/app/assets/javascripts/app/controllers/_dashboard/first_steps_clues.coffee @@ -12,6 +12,7 @@ class App.FirstStepsClues extends App.Controller container: '.search-holder' headline: 'Search' text: 'Here you can search for ticket, customers and organizations. Use the wildcard §*§ to find everything. E. g. §smi*§ or §rosent*l§. You also can use ||double quotes|| for searching phrases §"some phrase"§.' + actions: [] } { container: '.user-menu' @@ -53,9 +54,6 @@ class App.FirstStepsClues extends App.Controller constructor: (params) -> - # disable active navbar elements - $('.main-navigation .active').removeClass('active') - $('#app').append('
') params.el = $('#app .js-modal--clue') @@ -108,12 +106,12 @@ class App.FirstStepsClues extends App.Controller cleanUp: (callback) -> @hideWindow => clue = @clues[@position] - container = $(clue.container) + container = $("#app #{clue.container}") container.removeClass('selected-clue') # undo click perform by doing it again if clue.actions - @perform clue.actions, container + @perform clue.actions, container, 'cleanup' if callback callback() @@ -130,11 +128,11 @@ class App.FirstStepsClues extends App.Controller showClue: => clue = @clues[@position] - container = $(clue.container) + container = $("#app #{clue.container}") container.addClass('selected-clue') if clue.actions - @perform clue.actions, container + @perform clue.actions, container, 'show' # calculate bounding box after actions # to take toggled child nodes into account @@ -309,7 +307,7 @@ class App.FirstStepsClues extends App.Controller dimensions - perform: (actions, container) -> + perform: (actions, container, type) -> for action in actions if action.indexOf(' ') < 0 # 'click' @@ -321,5 +319,14 @@ class App.FirstStepsClues extends App.Controller target = container.find( action.substr action.indexOf(' ') + 1 ) switch eventName - when 'click' then target.trigger('click') - when 'hover' then target.toggleClass('is-hovered') \ No newline at end of file + when 'click' + target.trigger('click') + when 'hover' + + # disable active navbar elements + $('#app .navigation .is-active').removeClass('is-active') + + if type is 'show' + target.addClass('is-hovered') + else + target.removeClass('is-hovered')