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 441441 setTimeout ( $ . proxy ( self . refresh , self ) , 10 ) ;
442442 } ) ;
443443 } ,
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+ } ,
445463 // set button width
446464 _setButtonWidth : function ( ) {
447465 var width = this . element . outerWidth ( ) ;
448- var o = this . options ;
466+ var minVal = this . _getMinWidth ( ) ;
449467
450- if ( / \d / . test ( o . minWidth ) && width < o . minWidth ) {
451- width = o . minWidth ;
468+ if ( width < minVal ) {
469+ width = minVal ;
452470 }
453-
454471 // set widths
455472 this . button . outerWidth ( width ) ;
456473 } ,
457474
458475 // set menu width
459476 _setMenuWidth : function ( ) {
460477 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 ( ) ;
462479 m . outerWidth ( this . options . menuWidth || width ) ;
463480 } ,
464481
733750 break ;
734751 case 'minWidth' :
735752 case 'menuWidth' :
736- this . options [ key ] = parseInt ( value , 10 ) ;
753+ this . options [ key ] = value ;
737754 this . _setButtonWidth ( ) ;
738755 this . _setMenuWidth ( ) ;
739756 break ;
You can’t perform that action at this time.
0 commit comments