From c57a320d8d74d583886f23cb1e469442e1ef5220 Mon Sep 17 00:00:00 2001 From: Denny Bresch Date: Fri, 26 Jul 2019 16:18:55 +0200 Subject: [PATCH] Added 'dropdown' buttons and dropdown-menu to layout_ref/button. --- .../app/controllers/layout_ref.coffee | 26 +++++++++++++++++ .../app/views/layout_ref/buttons.jst.eco | 29 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/app/assets/javascripts/app/controllers/layout_ref.coffee b/app/assets/javascripts/app/controllers/layout_ref.coffee index 484a223ca..85c367069 100644 --- a/app/assets/javascripts/app/controllers/layout_ref.coffee +++ b/app/assets/javascripts/app/controllers/layout_ref.coffee @@ -1619,6 +1619,14 @@ App.Config.set( 'layout_ref/calendar_subscriptions', CalendarSubscriptionsRef, ' class ButtonsRef extends App.ControllerContent + elements: + '.js-submitDropdown': 'buttonDropdown' + + events: + 'click .js-openDropdown': 'toggleMenu' + 'mouseenter .js-dropdownAction': 'onActionMouseEnter' + 'mouseleave .js-dropdownAction': 'onActionMouseLeave' + constructor: -> super @render() @@ -1626,6 +1634,24 @@ class ButtonsRef extends App.ControllerContent render: -> @html App.view('layout_ref/buttons') + toggleMenu: => + if @buttonDropdown.hasClass('is-open') + @closeMenu() + return + @openMenu() + + closeMenu: => + @buttonDropdown.removeClass 'is-open' + + openMenu: => + @buttonDropdown.addClass 'is-open' + + onActionMouseEnter: (e) => + @$(e.currentTarget).addClass('is-active') + + onActionMouseLeave: (e) => + @$(e.currentTarget).removeClass('is-active') + App.Config.set( 'layout_ref/buttons', ButtonsRef, 'Routes' ) class MergeCustomerRef extends App.ControllerContent diff --git a/app/assets/javascripts/app/views/layout_ref/buttons.jst.eco b/app/assets/javascripts/app/views/layout_ref/buttons.jst.eco index fb71fbb69..5561ebab8 100644 --- a/app/assets/javascripts/app/views/layout_ref/buttons.jst.eco +++ b/app/assets/javascripts/app/views/layout_ref/buttons.jst.eco @@ -55,4 +55,33 @@
Split
Split Last
+ +

Dropdown

+ +
+ + + +
+ +
+ + + \ No newline at end of file