@ -11,15 +11,15 @@ import {
isNotNull ,
isNull ,
isFunction ,
each
each ,
Events ,
EVENT _BLUR ,
DOM ,
emptyFn ,
LogicFactory
} from "@/core" ;
import { Resizers } from "@/base/0.base" ;
/ * *
* @ class BI . Combo
* @ extends BI . Widget
* /
let needHideWhenAnotherComboOpen = { } ;
let currentOpenedCombos = { } ;
@ -42,7 +42,7 @@ export class Combo extends Bubble {
const conf = super . _defaultConfig ( ... arguments ) ;
return extend ( conf , {
baseCls : ` ${ conf . baseCls || "" } bi-combo ${ BI . isIE ( ) ? " hack" : ""} ` ,
baseCls : ` ${ conf . baseCls || "" } bi-comboisIE() ? " hack" : ""} ` ,
attributes : {
tabIndex : - 1 ,
} ,
@ -67,7 +67,7 @@ export class Combo extends Bubble {
adjustXOffset : 0 ,
adjustYOffset : 0 ,
supportCSSTransform : true ,
hideChecker : BI . emptyFn ,
hideChecker : emptyFn ,
offsetStyle : "" , // "",center,middle
el : { } ,
popup : { } ,
@ -86,24 +86,24 @@ export class Combo extends Bubble {
} ) ;
this . combo . on ( Controller . EVENT _CHANGE , ( type , value , obj , ... args ) => {
if ( this . isEnabled ( ) && this . isValid ( ) ) {
if ( type === BI . Events . TOGGLE ) {
if ( type === Events . TOGGLE ) {
this . _toggle ( ) ;
}
if ( type === BI . Events . EXPAND ) {
if ( type === Events . EXPAND ) {
this . _popupView ( ) ;
}
if ( type === BI . Events . COLLAPSE ) {
if ( type === Events . COLLAPSE ) {
this . _hideView ( ) ;
}
if ( type === BI . Events . EXPAND ) {
if ( type === Events . EXPAND ) {
this . fireEvent ( Controller . EVENT _CHANGE , type , value , obj , ... args ) ;
this . fireEvent ( Combo . EVENT _EXPAND ) ;
}
if ( type === BI . Events . COLLAPSE ) {
if ( type === Events . COLLAPSE ) {
this . fireEvent ( Controller . EVENT _CHANGE , type , value , obj , ... args ) ;
this . isViewVisible ( ) && this . fireEvent ( Combo . EVENT _COLLAPSE ) ;
}
if ( type === BI . Events . CLICK ) {
if ( type === Events . CLICK ) {
this . fireEvent ( Combo . EVENT _TRIGGER _CHANGE , obj ) ;
}
}
@ -126,7 +126,7 @@ export class Combo extends Bubble {
element : this ,
scrolly : false ,
} ,
BI . LogicFactory . createLogic (
LogicFactory . createLogic (
"vertical" ,
extend ( logic , {
items : [ { el : this . combo } ] ,
@ -147,7 +147,7 @@ export class Combo extends Bubble {
}
_assertPopupView ( ) {
const { showArrow , value , hideWhenClickOutside , hideWhenBlur } = this . options ;
const { showArrow , value } = this . options ;
if ( isNull ( this . popupView ) ) {
this . popupView = createWidget (
isFunction ( this . options . popup ) ? this . options . popup ( ) : this . options . popup ,
@ -159,7 +159,7 @@ export class Combo extends Bubble {
this
) ;
this . popupView . on ( Controller . EVENT _CHANGE , ( type , value , obj , ... args ) => {
if ( type === BI . Events . CLICK ) {
if ( type === Events . CLICK ) {
this . combo . setValue ( this . getValue ( ) ) ;
this . fireEvent ( Bubble . EVENT _CHANGE , value , obj ) ;
}
@ -198,7 +198,7 @@ export class Combo extends Bubble {
. createElement ( document )
. unbind ( ` mousedown. ${ this . getName ( ) } ` )
. unbind ( ` mousewheel. ${ this . getName ( ) } ` ) ;
BI . EVENT _BLUR && hideWhenBlur && Widget . _renderEngine . createElement ( window ) . unbind ( ` blur. ${ this . getName ( ) } ` ) ;
EVENT _BLUR && hideWhenBlur && Widget . _renderEngine . createElement ( window ) . unbind ( ` blur. ${ this . getName ( ) } ` ) ;
this . fireEvent ( Combo . EVENT _AFTER _HIDEVIEW , e ) ;
}
@ -228,7 +228,7 @@ export class Combo extends Bubble {
. unbind ( ` mousedown. ${ this . getName ( ) } ` )
. unbind ( ` mousewheel. ${ this . getName ( ) } ` ) ;
hideWhenClickOutside && Widget . _renderEngine . createElement ( document ) . unbind ( ` mousewheel. ${ this . getName ( ) } ` ) ;
BI . EVENT _BLUR && hideWhenBlur && Widget . _renderEngine . createElement ( window ) . unbind ( ` blur. ${ this . getName ( ) } ` ) ;
EVENT _BLUR && hideWhenBlur && Widget . _renderEngine . createElement ( window ) . unbind ( ` blur. ${ this . getName ( ) } ` ) ;
hideWhenClickOutside &&
Widget . _renderEngine . createElement ( document ) . bind ( ` mousewheel. ${ this . getName ( ) } ` , bind ( this . _hideIf , this ) ) ;
@ -237,7 +237,7 @@ export class Combo extends Bubble {
. createElement ( document )
. bind ( ` mousedown. ${ this . getName ( ) } ` , bind ( this . _hideIf , this ) )
. bind ( ` mousewheel. ${ this . getName ( ) } ` , bind ( this . _hideIf , this ) ) ;
BI . EVENT _BLUR &&
EVENT _BLUR &&
hideWhenBlur &&
Widget . _renderEngine . createElement ( window ) . bind ( ` blur. ${ this . getName ( ) } ` , bind ( this . _hideIf , this ) ) ;
this . fireEvent ( Combo . EVENT _AFTER _POPUPVIEW ) ;
@ -288,7 +288,7 @@ export class Combo extends Bubble {
}
: this . combo ;
const positionRelativeElement = supportCSSTransform
? BI . DOM . getPositionRelativeContainingBlock (
? DOM . getPositionRelativeContainingBlock (
isNull ( container )
? this . element [ 0 ]
: Widget . _renderEngine . createElement ( isFunction ( container ) ? container ( ) : container ) [ 0 ]
@ -296,198 +296,198 @@ export class Combo extends Bubble {
: null ;
const TRIANGLE _LENGTH = 12 ;
switch ( direction ) {
case "bottom" :
case "bottom,right" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight ,
[ "bottom" , "top" , "right" , "left" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "top" :
case "top,right" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight ,
[ "top" , "bottom" , "right" , "left" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "left" :
case "left,bottom" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "left" , "right" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "right" :
case "right,bottom" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "right" , "left" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "top,left" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight ,
[ "top" , "bottom" , "left" , "right" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "bottom,left" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight ,
[ "bottom" , "top" , "left" , "right" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "left,top" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "left" , "right" , "top" , "bottom" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "right,top" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "right" , "left" , "top" , "bottom" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "right,innerRight" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "right" , "left" , "innerRight" , "innerLeft" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "right,innerLeft" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "right" , "left" , "innerLeft" , "innerRight" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "innerRight" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "innerRight" , "innerLeft" , "right" , "left" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "innerLeft" :
p = BI . DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "innerLeft" , "innerRight" , "left" , "right" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "top,custom" :
case "custom,top" :
p = BI . DOM . getTopAdaptPosition (
combo ,
this . popupView ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight
) ;
p . dir = "top" ;
break ;
case "custom,bottom" :
case "bottom,custom" :
p = BI . DOM . getBottomAdaptPosition (
combo ,
this . popupView ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight
) ;
p . dir = "bottom" ;
break ;
case "left,custom" :
case "custom,left" :
p = BI . DOM . getLeftAdaptPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 )
) ;
delete p . top ;
delete p . adaptHeight ;
p . dir = "left" ;
break ;
case "custom,right" :
case "right,custom" :
p = BI . DOM . getRightAdaptPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 )
) ;
delete p . top ;
delete p . adaptHeight ;
p . dir = "right" ;
break ;
default :
break ;
case "bottom" :
case "bottom,right" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight ,
[ "bottom" , "top" , "right" , "left" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "top" :
case "top,right" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight ,
[ "top" , "bottom" , "right" , "left" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "left" :
case "left,bottom" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "left" , "right" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "right" :
case "right,bottom" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "right" , "left" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "top,left" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight ,
[ "top" , "bottom" , "left" , "right" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "bottom,left" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight ,
[ "bottom" , "top" , "left" , "right" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "left,top" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "left" , "right" , "top" , "bottom" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "right,top" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "right" , "left" , "top" , "bottom" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "right,innerRight" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "right" , "left" , "innerRight" , "innerLeft" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "right,innerLeft" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "right" , "left" , "innerLeft" , "innerRight" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "innerRight" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "innerRight" , "innerLeft" , "right" , "left" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "innerLeft" :
p = DOM . getComboPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
adjustYOffset ,
isNeedAdjustHeight ,
[ "innerLeft" , "innerRight" , "left" , "right" , "bottom" , "top" ] ,
offsetStyle ,
positionRelativeElement
) ;
break ;
case "top,custom" :
case "custom,top" :
p = DOM . getTopAdaptPosition (
combo ,
this . popupView ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight
) ;
p . dir = "top" ;
break ;
case "custom,bottom" :
case "bottom,custom" :
p = DOM . getBottomAdaptPosition (
combo ,
this . popupView ,
adjustYOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 ) ,
isNeedAdjustHeight
) ;
p . dir = "bottom" ;
break ;
case "left,custom" :
case "custom,left" :
p = DOM . getLeftAdaptPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 )
) ;
delete p . top ;
delete p . adaptHeight ;
p . dir = "left" ;
break ;
case "custom,right" :
case "right,custom" :
p = DOM . getRightAdaptPosition (
combo ,
this . popupView ,
adjustXOffset + adjustLength + ( showArrow ? TRIANGLE _LENGTH : 0 )
) ;
delete p . top ;
delete p . adaptHeight ;
p . dir = "right" ;
break ;
default :
break ;
}
if ( "adaptHeight" in p ) {