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