142 lines
3.8 KiB
JavaScript
142 lines
3.8 KiB
JavaScript
//>>built
|
|
define("dojox/mobile/ComboBox",["dojo/_base/kernel","dojo/_base/declare","dojo/_base/lang","dojo/_base/window","dojo/dom-geometry","dojo/dom-style","dojo/window","dojo/touch","dijit/form/_AutoCompleterMixin","dijit/popup","./_ComboBoxMenu","./TextBox","./sniff"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d){
|
|
_1.experimental("dojox.mobile.ComboBox");
|
|
return _2("dojox.mobile.ComboBox",[_c,_9],{dropDownClass:"dojox.mobile._ComboBoxMenu",selectOnClick:false,autoComplete:false,dropDown:null,maxHeight:-1,dropDownPosition:["below","above"],_throttleOpenClose:function(){
|
|
if(this._throttleHandler){
|
|
this._throttleHandler.remove();
|
|
}
|
|
this._throttleHandler=this.defer(function(){
|
|
this._throttleHandler=null;
|
|
},500);
|
|
},_onFocus:function(){
|
|
this.inherited(arguments);
|
|
if(!this._opened&&!this._throttleHandler){
|
|
this._startSearchAll();
|
|
}
|
|
},onInput:function(e){
|
|
this._onKey(e);
|
|
this.inherited(arguments);
|
|
},_setListAttr:function(v){
|
|
this._set("list",v);
|
|
},closeDropDown:function(){
|
|
this._throttleOpenClose();
|
|
if(this.endHandler){
|
|
this.disconnect(this.startHandler);
|
|
this.disconnect(this.endHandler);
|
|
this.disconnect(this.moveHandler);
|
|
clearInterval(this.repositionTimer);
|
|
this.repositionTimer=this.endHandler=null;
|
|
}
|
|
this.inherited(arguments);
|
|
_a.close(this.dropDown);
|
|
this._opened=false;
|
|
},openDropDown:function(){
|
|
var _e=!this._opened;
|
|
var _f=this.dropDown,_10=_f.domNode,_11=this.domNode,_12=this;
|
|
if(_d("touch")){
|
|
_4.global.scrollBy(0,_5.position(_11,false).y);
|
|
}
|
|
if(!this._preparedNode){
|
|
this._preparedNode=true;
|
|
if(_10.style.width){
|
|
this._explicitDDWidth=true;
|
|
}
|
|
if(_10.style.height){
|
|
this._explicitDDHeight=true;
|
|
}
|
|
}
|
|
var _13={display:"",overflow:"hidden",visibility:"hidden"};
|
|
if(!this._explicitDDWidth){
|
|
_13.width="";
|
|
}
|
|
if(!this._explicitDDHeight){
|
|
_13.height="";
|
|
}
|
|
_6.set(_10,_13);
|
|
var _14=this.maxHeight;
|
|
if(_14==-1){
|
|
var _15=_7.getBox(),_16=_5.position(_11,false);
|
|
_14=Math.floor(Math.max(_16.y,_15.h-(_16.y+_16.h)));
|
|
}
|
|
_a.moveOffScreen(_f);
|
|
if(_f.startup&&!_f._started){
|
|
_f.startup();
|
|
}
|
|
var mb=_5.position(this.dropDown.containerNode,false);
|
|
var _17=(_14&&mb.h>_14);
|
|
if(_17){
|
|
mb.h=_14;
|
|
}
|
|
mb.w=Math.max(mb.w,_11.offsetWidth);
|
|
_5.setMarginBox(_10,mb);
|
|
var _18=_a.open({parent:this,popup:_f,around:_11,orient:this.dropDownPosition,onExecute:function(){
|
|
_12.closeDropDown();
|
|
},onCancel:function(){
|
|
_12.closeDropDown();
|
|
},onClose:function(){
|
|
_12._opened=false;
|
|
}});
|
|
this._opened=true;
|
|
if(_e){
|
|
var _19=false,_1a=false,_1b=false,_1c=_f.domNode.parentNode,_1d=_5.position(_11,false),_1e=_5.position(_1c,false),_1f=_1e.x-_1d.x,_20=_1e.y-_1d.y,_21=-1,_22=-1;
|
|
this.startHandler=this.connect(_4.doc.documentElement,_8.press,function(e){
|
|
_1a=true;
|
|
_1b=true;
|
|
_19=false;
|
|
_21=e.clientX;
|
|
_22=e.clientY;
|
|
});
|
|
this.moveHandler=this.connect(_4.doc.documentElement,_8.move,function(e){
|
|
_1a=true;
|
|
if(e.touches){
|
|
_1b=_19=true;
|
|
}else{
|
|
if(_1b&&(e.clientX!=_21||e.clientY!=_22)){
|
|
_19=true;
|
|
}
|
|
}
|
|
});
|
|
this.clickHandler=this.connect(_f.domNode,"onclick",function(){
|
|
_1a=true;
|
|
_1b=_19=false;
|
|
});
|
|
this.endHandler=this.connect(_4.doc.documentElement,"onmouseup",function(){
|
|
this.defer(function(){
|
|
_1a=true;
|
|
if(!_19&&_1b){
|
|
this.closeDropDown();
|
|
}
|
|
_1b=false;
|
|
});
|
|
});
|
|
this.repositionTimer=setInterval(_3.hitch(this,function(){
|
|
if(_1a){
|
|
_1a=false;
|
|
return;
|
|
}
|
|
var _23=_5.position(_11,false),_24=_5.position(_1c,false),_25=_24.x-_23.x,_26=_24.y-_23.y;
|
|
if(Math.abs(_25-_1f)>=1||Math.abs(_26-_20)>=1){
|
|
_6.set(_1c,{left:parseInt(_6.get(_1c,"left"))+_1f-_25+"px",top:parseInt(_6.get(_1c,"top"))+_20-_26+"px"});
|
|
}
|
|
}),50);
|
|
}
|
|
return _18;
|
|
},postCreate:function(){
|
|
this.inherited(arguments);
|
|
this.connect(this.domNode,"onclick","_onClick");
|
|
},destroy:function(){
|
|
if(this.repositionTimer){
|
|
clearInterval(this.repositionTimer);
|
|
}
|
|
this.inherited(arguments);
|
|
},_onClick:function(e){
|
|
if(!this._throttleHandler){
|
|
if(this.opened){
|
|
this.closeDropDown();
|
|
}else{
|
|
this._startSearchAll();
|
|
}
|
|
}
|
|
}});
|
|
});
|