From 261c5c714e0b873e10857428a761ae4fc987b1e5 Mon Sep 17 00:00:00 2001 From: hendimarcos Date: Thu, 31 Jan 2019 15:00:03 -0300 Subject: [PATCH] fix(js): AdminLTE 3 collapse button (#1938) https://github.com/almasaeed2010/AdminLTE/issues/1910 --- build/js/Widget.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/build/js/Widget.js b/build/js/Widget.js index d21b91fec..86b3c46a0 100644 --- a/build/js/Widget.js +++ b/build/js/Widget.js @@ -23,17 +23,21 @@ const Widget = (($) => { } const Selector = { - DATA_REMOVE : '[data-widget="remove"]', - DATA_COLLAPSE: '[data-widget="collapse"]', - CARD : '.card', - CARD_HEADER : '.card-header', - CARD_BODY : '.card-body', - CARD_FOOTER : '.card-footer', - COLLAPSED : '.collapsed-card' + DATA_REMOVE : '[data-widget="remove"]', + DATA_COLLAPSE : '[data-widget="collapse"]', + CARD : '.card', + CARD_HEADER : '.card-header', + CARD_BODY : '.card-body', + CARD_FOOTER : '.card-footer', + COLLAPSED : '.collapsed-card', + COLLAPSE_ICON : '.fa-minus', + EXPAND_ICON : '.fa-plus' } const ClassName = { - COLLAPSED: 'collapsed-card' + COLLAPSED : 'collapsed-card', + COLLAPSE_ICON : 'fa-minus', + EXPAND_ICON : 'fa-plus' } const Default = { @@ -55,6 +59,10 @@ const Widget = (($) => { this._parent.addClass(ClassName.COLLAPSED) }) + this._element.children(Selector.COLLAPSE_ICON) + .addClass(ClassName.EXPAND_ICON) + .removeClass(ClassName.COLLAPSE_ICON) + const collapsed = $.Event(Event.COLLAPSED) this._element.trigger(collapsed, this._parent) @@ -66,6 +74,10 @@ const Widget = (($) => { this._parent.removeClass(ClassName.COLLAPSED) }) + this._element.children(Selector.EXPAND_ICON) + .addClass(ClassName.COLLAPSE_ICON) + .removeClass(ClassName.EXPAND_ICON) + const expanded = $.Event(Event.EXPANDED) this._element.trigger(expanded, this._parent)