@ -27,11 +27,57 @@
var adjustHeight = BI . Combo . prototype . adjustHeight ;
var originalRender = BI . Widget . _renderEngine ;
var injectSearch = BI . Searcher . prototype . _search ;
var injectSearchView = BI . Searcher . prototype . setValue ;
var injectSearchSetValue = BI . Searcher . prototype . setValue ;
var injectSearchAdjustView = BI . Searcher . prototype . _assertPopupView ;
var injectTooltipsShow = BI . TooltipsController . prototype . show ;
var injectSwitcherPopup = BI . Switcher . prototype . adjustView ;
var injectCreate = BI . createWidget ;
var callback = function ( ) { } ;
BI . Searcher . prototype . _search = function ( result , searchResult , keyword ) {
var self = this , o = this . options , keyword = o . allowSearchBlank ? this . editor . getValue ( ) : this . _getLastSearchKeyword ( ) ;
if ( keyword === "" || this . _stop ) {
return ;
}
if ( o . isAutoSearch ) {
var items = ( o . adapter && ( ( o . adapter . getItems && o . adapter . getItems ( ) ) || o . adapter . attr ( "items" ) ) ) || [ ] ;
var finding = BI . Func . getSearchResult ( items , keyword ) ;
var match = finding . match , find = finding . find ;
this . popupView . populate ( find , match , keyword ) ;
o . isAutoSync && o . adapter && o . adapter . getValue && this . popupView . setValue ( o . adapter . getValue ( ) ) ;
self . fireEvent ( BI . Searcher . EVENT _SEARCHING ) ;
callback && callback . call ( self ) ;
if ( self . popupView ) {
BI . defer ( function ( ) {
self . popupView . element [ 0 ] . parentElement . style . left = parseInt ( self . popupView . element [ 0 ] . parentElement . style . left ) * scale + "px" ;
self . popupView . element [ 0 ] . parentElement . style . top = parseInt ( self . popupView . element [ 0 ] . parentElement . style . top ) * scale + "px" ;
self . popupView . element [ 0 ] . parentElement . style . transform = "scale(" + scale + ")" ;
self . popupView . element [ 0 ] . parentElement . style . transformOrigin = "left top" ;
} )
}
return ;
}
this . popupView . loading && this . popupView . loading ( ) ;
o . onSearch ( {
times : 1 ,
keyword : keyword ,
selectedValues : o . adapter && o . adapter . getValue ( )
} , function ( searchResult , matchResult ) {
if ( ! self . _stop ) {
var args = [ ] . slice . call ( arguments ) ;
if ( args . length > 0 ) {
args . push ( keyword ) ;
}
BI . Maskers . show ( self . getName ( ) ) ;
self . popupView . populate . apply ( self . popupView , args ) ;
o . isAutoSync && o . adapter && o . adapter . getValue && self . popupView . setValue ( o . adapter . getValue ( ) ) ;
self . popupView . loaded && self . popupView . loaded ( ) ;
self . fireEvent ( BI . Searcher . EVENT _SEARCHING ) ;
callback && callback . call ( self ) ;
}
} ) ;
} ;
// 修正事件偏移
function correctEvent ( e ) {
@ -70,7 +116,7 @@
wrapper . style . transformOrigin = "top left" ;
wrapper . style [ "-ms-transform" ] = "scale(" + bounds . scale + ")" ;
wrapper . style [ "-ms-transform-origin" ] = "top left" ;
wrapper . style . overflowY = "auto " ;
wrapper . style . overflowY = "hidden " ;
html . style . backgroundColor = "#ffffff" ;
scrollContainer . style . overflowX = "auto" ;
@ -277,7 +323,7 @@
this . popupView . element [ 0 ] . style . left = parseInt ( Math . min ( pBounds . left , body . clientWidth - cBounds . width ) ) - transformX + "px" ;
} else {
this . popupView . element [ 0 ] . style . top = parseInt ( pBounds . bottom ) - transformY + "px" ;
this . popupView . element [ 0 ] . style . left = parseInt ( p Bounds. left ) - transformX + "px" ;
this . popupView . element [ 0 ] . style . left = parseInt ( c Bounds. left ) * scale - transformX + "px" ;
}
}
this . popupView . element [ 0 ] . style . transform = "scale(" + scale + ")" ;
@ -304,62 +350,26 @@
}
// Searcher
BI . Searcher . prototype . _search = function ( result , searchResult , keyword ) {
var self = this , o = this . options , keyword = o . allowSearchBlank ? this . editor . getValue ( ) : this . _getLastSearchKeyword ( ) ;
if ( keyword === "" || this . _stop ) {
return ;
}
if ( o . isAutoSearch ) {
var items = ( o . adapter && ( ( o . adapter . getItems && o . adapter . getItems ( ) ) || o . adapter . attr ( "items" ) ) ) || [ ] ;
var finding = BI . Func . getSearchResult ( items , keyword ) ;
var match = finding . match , find = finding . find ;
this . popupView . populate ( find , match , keyword ) ;
o . isAutoSync && o . adapter && o . adapter . getValue && this . popupView . setValue ( o . adapter . getValue ( ) ) ;
self . fireEvent ( BI . Searcher . EVENT _SEARCHING ) ;
if ( self . popupView ) {
BI . defer ( function ( ) {
self . popupView . element [ 0 ] . parentElement . style . left = parseInt ( self . popupView . element [ 0 ] . parentElement . style . left ) * scale + "px" ;
self . popupView . element [ 0 ] . parentElement . style . top = parseInt ( self . popupView . element [ 0 ] . parentElement . style . top ) * scale + "px" ;
self . popupView . element [ 0 ] . parentElement . style . transform = "scale(" + scale + ")" ;
self . popupView . element [ 0 ] . parentElement . style . transformOrigin = "left top" ;
} )
}
return ;
}
this . popupView . loading && this . popupView . loading ( ) ;
o . onSearch ( {
times : 1 ,
keyword : keyword ,
selectedValues : o . adapter && o . adapter . getValue ( )
} , function ( searchResult , matchResult ) {
if ( ! self . _stop ) {
var args = [ ] . slice . call ( arguments ) ;
if ( args . length > 0 ) {
args . push ( keyword ) ;
}
BI . Maskers . show ( self . getName ( ) ) ;
self . popupView . populate . apply ( self . popupView , args ) ;
o . isAutoSync && o . adapter && o . adapter . getValue && self . popupView . setValue ( o . adapter . getValue ( ) ) ;
self . popupView . loaded && self . popupView . loaded ( ) ;
self . fireEvent ( BI . Searcher . EVENT _SEARCHING ) ;
if ( self . popupView ) {
self . popupView . element [ 0 ] . parentElement . style . left = parseInt ( self . popupView . element [ 0 ] . parentElement . style . left ) * scale + "px" ;
self . popupView . element [ 0 ] . parentElement . style . top = parseInt ( self . popupView . element [ 0 ] . parentElement . style . top ) * scale + "px" ;
self . popupView . element [ 0 ] . parentElement . style . transform = "scale(" + scale + ")" ;
self . popupView . element [ 0 ] . parentElement . style . transformOrigin = "left top" ;
}
callback = function ( ) {
var self = this ;
BI . defer ( function ( ) {
if ( self . popupView && self . popupView . element [ 0 ] . parentElement ) {
self . popupView . element [ 0 ] . parentElement . style . left = parseInt ( self . popupView . element [ 0 ] . parentElement . style . left ) * scale + "px" ;
self . popupView . element [ 0 ] . parentElement . style . top = parseInt ( self . popupView . element [ 0 ] . parentElement . style . top ) * scale + "px" ;
self . popupView . element [ 0 ] . parentElement . style . transform = "scale(" + scale + ")" ;
self . popupView . element [ 0 ] . parentElement . style . transformOrigin = "left top" ;
}
} ) ;
} ;
} )
}
BI . Searcher . prototype . setValue = function ( ) {
injectSearchView . call ( this , arguments ) ;
injectSearchSetValue . call ( this , arguments ) ;
if ( this . popupView && this . popupView . element [ 0 ] . parentElement ) {
this . popupView . element [ 0 ] . parentElement . style . left = parseInt ( this . popupView . element [ 0 ] . parentElement . style . left ) * scale + "px" ;
this . popupView . element [ 0 ] . parentElement . style . top = parseInt ( this . popupView . element [ 0 ] . parentElement . style . top ) * scale + "px" ;
this . popupView . element [ 0 ] . parentElement . style . transform = "scale(" + scale + ")" ;
this . popupView . element [ 0 ] . parentElement . style . transformOrigin = "left top" ;
}
}
// switcher
@ -478,8 +488,8 @@
BI . Popovers = new BI . PopoverController ( ) ;
BI . Widget . registerRenderEngine ( originalRender ) ;
BI . Searcher . prototype . _search = injectSearch ;
BI . Searcher . prototype . setValue = injectSearchView ;
callback = function ( ) { }
BI . Searcher . prototype . setValue = injectSearchSetValue ;
BI . Switcher . prototype . adjustView = injectSwitcherPopup ;
BI . TooltipsController . prototype . show = injectTooltipsShow ;