@@ -19,12 +19,15 @@ const Widget = (($) => {
1919 const Event = {
2020 EXPANDED : `expanded${ EVENT_KEY } ` ,
2121 COLLAPSED : `collapsed${ EVENT_KEY } ` ,
22+ MAXIMIZED : `maximized${ EVENT_KEY } ` ,
23+ MINIMIZED : `minimized${ EVENT_KEY } ` ,
2224 REMOVED : `removed${ EVENT_KEY } `
2325 }
2426
2527 const Selector = {
2628 DATA_REMOVE : '[data-widget="remove"]' ,
2729 DATA_COLLAPSE : '[data-widget="collapse"]' ,
30+ DATA_MAXIMIZE : '[data-widget="maximize"]' ,
2831 CARD : '.card' ,
2932 CARD_HEADER : '.card-header' ,
3033 CARD_BODY : '.card-body' ,
@@ -36,8 +39,12 @@ const Widget = (($) => {
3639
3740 const ClassName = {
3841 COLLAPSED : 'collapsed-card' ,
42+ WAS_COLLAPSED : 'was-collapsed' ,
43+ MAXIMIZED : 'maximized-card' ,
3944 COLLAPSE_ICON : 'fa-minus' ,
40- EXPAND_ICON : 'fa-plus'
45+ EXPAND_ICON : 'fa-plus' ,
46+ MAXIMIZE_ICON : 'fa-expand' ,
47+ MINIMIZE_ICON : 'fa-compress' ,
4148 }
4249
4350 const Default = {
@@ -99,6 +106,44 @@ const Widget = (($) => {
99106
100107 this . collapse ( )
101108 }
109+
110+ toggleMaximize ( ) {
111+ var button = this . _element . find ( 'i' )
112+
113+ if ( this . _parent . hasClass ( ClassName . MAXIMIZED ) ) {
114+ button . addClass ( ClassName . MAXIMIZE_ICON ) . removeClass ( ClassName . MINIMIZE_ICON )
115+ this . _parent . css ( 'cssText' , 'height:' + this . _parent [ 0 ] . style . height + ' !important;' +
116+ 'width:' + this . _parent [ 0 ] . style . width + ' !important; transition: all .15s;'
117+ ) . delay ( 100 ) . queue ( function ( ) {
118+ $ ( this ) . removeClass ( ClassName . MAXIMIZED )
119+ $ ( 'html' ) . removeClass ( ClassName . MAXIMIZED )
120+ $ ( this ) . trigger ( Event . MINIMIZED )
121+ $ ( this ) . css ( {
122+ 'height' : 'inherit' ,
123+ 'width' : 'inherit'
124+ } )
125+ if ( $ ( this ) . hasClass ( ClassName . WAS_COLLAPSED ) ) {
126+ $ ( this ) . removeClass ( ClassName . WAS_COLLAPSED )
127+ }
128+ $ ( this ) . dequeue ( )
129+ } )
130+ } else {
131+ button . addClass ( ClassName . MINIMIZE_ICON ) . removeClass ( ClassName . MAXIMIZE_ICON )
132+ this . _parent . css ( {
133+ 'height' : this . _parent . height ( ) ,
134+ 'width' : this . _parent . width ( ) ,
135+ 'transition' : 'all .15s'
136+ } ) . delay ( 150 ) . queue ( function ( ) {
137+ $ ( this ) . addClass ( ClassName . MAXIMIZED )
138+ $ ( 'html' ) . addClass ( ClassName . MAXIMIZED )
139+ $ ( this ) . trigger ( Event . MAXIMIZED )
140+ if ( $ ( this ) . hasClass ( ClassName . COLLAPSED ) ) {
141+ $ ( this ) . addClass ( ClassName . WAS_COLLAPSED )
142+ }
143+ $ ( this ) . dequeue ( )
144+ } )
145+ }
146+ }
102147
103148 // Private
104149
@@ -155,6 +200,14 @@ const Widget = (($) => {
155200 Widget . _jQueryInterface . call ( $ ( this ) , 'remove' )
156201 } )
157202
203+ $ ( document ) . on ( 'click' , Selector . DATA_MAXIMIZE , function ( event ) {
204+ if ( event ) {
205+ event . preventDefault ( )
206+ }
207+
208+ Widget . _jQueryInterface . call ( $ ( this ) , 'toggleMaximize' )
209+ } )
210+
158211 /**
159212 * jQuery API
160213 * ====================================================
0 commit comments