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 442442 setTimeout ( $ . proxy ( self . refresh , self ) , 10 ) ;
443443 } ) ;
444444 } ,
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+ } ,
446464 // set button width
447465 _setButtonWidth : function ( ) {
448466 var width = this . element . outerWidth ( ) ;
449- var o = this . options ;
467+ var minVal = this . _getMinWidth ( ) ;
450468
451- if ( / \d / . test ( o . minWidth ) && width < o . minWidth ) {
452- width = o . minWidth ;
469+ if ( width < minVal ) {
470+ width = minVal ;
453471 }
454-
455472 // set widths
456473 this . button . outerWidth ( width ) ;
457474 } ,
458475
459476 // set menu width
460477 _setMenuWidth : function ( ) {
461478 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 ( ) ;
463480 m . outerWidth ( this . options . menuWidth || width ) ;
464481 } ,
465482
734751 break ;
735752 case 'minWidth' :
736753 case 'menuWidth' :
737- this . options [ key ] = parseInt ( value , 10 ) ;
754+ this . options [ key ] = value ;
738755 this . _setButtonWidth ( ) ;
739756 this . _setMenuWidth ( ) ;
740757 break ;
You can’t perform that action at this time.
0 commit comments