File tree Expand file tree Collapse file tree 2 files changed +104
-77
lines changed Expand file tree Collapse file tree 2 files changed +104
-77
lines changed Original file line number Diff line number Diff line change 441
441
setTimeout ( $ . proxy ( self . refresh , self ) , 10 ) ;
442
442
} ) ;
443
443
} ,
444
-
444
+ _getMinWidth : function ( ) {
445
+ var minVal = this . options . minWidth ;
446
+ var width = 0 ;
447
+ switch ( typeof minVal ) {
448
+ case 'number' :
449
+ width = minVal ;
450
+ break ;
451
+ case 'string' :
452
+ var lastChar = minVal [ minVal . length - 1 ] ;
453
+ width = minVal . match ( / \d + / ) ;
454
+ if ( lastChar === '%' ) {
455
+ width = this . element . parent ( ) . outerWidth ( ) * ( width / 100 ) ;
456
+ } else {
457
+ width = parseInt ( minVal , 10 ) ;
458
+ }
459
+ break ;
460
+ }
461
+ return width ;
462
+ } ,
445
463
// set button width
446
464
_setButtonWidth : function ( ) {
447
465
var width = this . element . outerWidth ( ) ;
448
- var o = this . options ;
466
+ var minVal = this . _getMinWidth ( ) ;
449
467
450
- if ( / \d / . test ( o . minWidth ) && width < o . minWidth ) {
451
- width = o . minWidth ;
468
+ if ( width < minVal ) {
469
+ width = minVal ;
452
470
}
453
-
454
471
// set widths
455
472
this . button . outerWidth ( width ) ;
456
473
} ,
457
474
458
475
// set menu width
459
476
_setMenuWidth : function ( ) {
460
477
var m = this . menu ;
461
- var width = ( this . button . outerWidth ( ) <= 0 ) ? this . options . minWidth : this . button . outerWidth ( ) ;
478
+ var width = ( this . button . outerWidth ( ) <= 0 ) ? this . _getMinWidth ( ) : this . button . outerWidth ( ) ;
462
479
m . outerWidth ( this . options . menuWidth || width ) ;
463
480
} ,
464
481
733
750
break ;
734
751
case 'minWidth' :
735
752
case 'menuWidth' :
736
- this . options [ key ] = parseInt ( value , 10 ) ;
753
+ this . options [ key ] = value ;
737
754
this . _setButtonWidth ( ) ;
738
755
this . _setMenuWidth ( ) ;
739
756
break ;
You can’t perform that action at this time.
0 commit comments