/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */
//>>built
define("esri/dijit/PopupMobile",["require","dojo/_base/declare","dojo/_base/lang","dojo/_base/connect","dojo/_base/array","dojo/_base/window","dojo/_base/kernel","dojo/has","dojo/query","dojo/dom","dojo/dom-attr","dojo/dom-class","dojo/dom-construct","dojo/dom-geometry","dojo/dom-style","esri/InfoWindowBase","esri/PopupBase","esri/dijit/InfoView","esri/dijit/NavigationBar","esri/kernel","esri/domUtils","dojo/i18n!esri/nls/jsapi","dojo/NodeList-dom"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f,_10,_11,_12,_13,_14,_15,_16){var PUM=_2([_10,_11],{declaredClass:"esri.dijit.PopupMobile",offsetX:3,offsetY:3,zoomFactor:4,marginLeft:10,marginTop:10,highlight:true,popupNavigationBar:null,popupInfoView:null,location:null,xIcon:_1.toUrl("esri/dijit/images/whitex.png"),dArrowIcon:_1.toUrl("esri/dijit/images/whitedown.png"),lArrowIcon:_1.toUrl("esri/dijit/images/whitel.png"),rArrowIcon:_1.toUrl("esri/dijit/images/whiter.png"),constructor:function(_17,_18){this.initialize();_3.mixin(this,_17);this.domNode=_a.byId(_18);var nls=this._nls=_3.mixin({},_16.widgets.popup);var _19=this.domNode;_c.add(_19,"esriPopupMobile");var _1a="<div class='sizer'>"+"<div class='titlePane'>"+"<div class='spinner hidden'>"+"</div>"+"<div class='title'></div>"+"<div style='text-align:center'>"+"<div class='titleButton prev hidden'></div>"+"<div class='footer' style='display:inline-block;width:60px;height:15px;'></div>"+"<div class='titleButton next hidden'></div>"+"</div>"+"<div class='titleButton close'></div>"+"<div class='titleButton arrow hidden'></div>"+"</div>"+"</div>"+"<div class='pointer top hidden'></div>"+"<div class='pointer bottom hidden'></div>";_b.set(_19,"innerHTML",_1a);var _1b=_7.query(".titlePane",_19)[0];this._arrowButton=_7.query(".arrow",_1b)[0];this._pointerTop=_7.query(".top",_19)[0];this._pointerBottom=_7.query(".bottom",_19)[0];this._title=_7.query(".title",_1b)[0];this._footer=_7.query(".footer",_1b)[0];this._prev=_7.query(".prev",_1b)[0];this._next=_7.query(".next",_1b)[0];this._spinner=_7.query(".spinner",_1b)[0];this._eventConnections=[_4.connect(_7.query(".close",_1b)[0],"onclick",this,this.hide),_4.connect(this._arrowButton,"onclick",this,this._toggleView),_4.connect(this._prev,"onclick",this,function(){this.selectPrevious();this._updateUI();}),_4.connect(this._next,"onclick",this,function(){this.selectNext();this._updateUI();})];this._initPopupNavigationBar();this._initPopupInfoView();_15.hide(_19);this.isShowing=false;},setMap:function(map){this.inherited(arguments);_d.place(this.domNode,map.root);if(this.highlight){this.enableHighlight(map);}},unsetMap:function(){this.disableHighlight(this.map);this.inherited(arguments);},setTitle:function(_1c,_1d){this.destroyDijits(this._title);this.place(_1c,this._title);this.destroyDijits(this._footer);this.place(_1d,this._footer);if(this.isShowing){this.startupDijits(this._title);this.startupDijits(this._footer);}},setContent:function(_1e){this.destroyDijits(this._contentPane);this.place(_1e,this._contentPane);this.startupDijits(this._contentPane);},show:function(_1f){if(!_1f){_15.show(this.domNode);this.isShowing=true;return;}var map=this.map,_20;if(_1f.spatialReference){this._location=_1f;_20=map.toScreen(_1f);}else{this._location=map.toMap(_1f);_20=_1f;}if(this._maximized){this.restore();}else{this._setPosition(_20);}if(!this.isShowing){_15.show(this.domNode);this.isShowing=true;this.onShow();}},hide:function(){if(this.isShowing){_15.hide(this.domNode);this.isShowing=false;this.onHide();}},onShow:function(){this._followMap();this.startupDijits(this._title);this.showHighlight();},onHide:function(){this._unfollowMap();this.hideHighlight();},destroy:function(){if(this.map){this.unsetMap();}this.cleanup();if(this.isShowing){this.hide();}this.destroyDijits(this._title);this.destroyDijits(this._footer);_5.forEach(this._eventConnections,_4.disconnect);_d.destroy(this.domNode);},selectNext:function(){this.select(this.selectedIndex+1);},selectPrevious:function(){this.select(this.selectedIndex-1);},setFeatures:function(){this.inherited(arguments);this._updateUI();},onSetFeatures:function(){},onClearFeatures:function(){this.setTitle("&nbsp;","&nbsp;");_c.add(this._arrowButton,"hidden");this._updateUI();this.hideHighlight();},onSelectionChange:function(){var ptr=this.selectedIndex;this._updateUI();if(ptr>=0){this.setContent(this.features[ptr].getContent());this.updateHighlight(this.map,this.features[ptr]);if(this.isShowing){this.showHighlight();}}},onDfdComplete:function(){this._updateUI();},_followMap:function(){this._unfollowMap();var map=this.map;this._handles=[_4.connect(map,"onPanStart",this,this._onPanStart),_4.connect(map,"onPan",this,this._onPan),_4.connect(map,"onZoomStart",this,this._onZoomStart),_4.connect(map,"onExtentChange",this,this._onExtentChange)];},_unfollowMap:function(){var _21=this._handles;if(_21){_5.forEach(_21,_4.disconnect);this._handles=null;}},_onPanStart:function(){var _22=this.domNode.style;this._panOrigin={left:_22.left,top:_22.top,right:_22.right,bottom:_22.bottom};},_onPan:function(_23,_24){var _25=this._panOrigin,dx=_24.x,dy=_24.y,_26=_25.left,top=_25.top,_27=_25.right,_28=_25.bottom;if(_26){_26=(parseFloat(_26)+dx)+"px";}if(top){top=(parseFloat(top)+dy)+"px";}if(_27){_27=(parseFloat(_27)-dx)+"px";}if(_28){_28=(parseFloat(_28)-dy)+"px";}_f.set(this.domNode,{left:_26,top:top,right:_27,bottom:_28});},_onZoomStart:function(){_15.hide(this.domNode);},_onExtentChange:function(_29,_2a,_2b){if(_2b){_15.show(this.domNode);this.show(this._targetLocation||this._location);this._targetLocation=null;}},_setPosition:function(_2c){var _2d=_2c.x,_2e=_2c.y,_2f=_e.getContentBox(this.map.container),_30=_2f.w,_31=_2f.h;var _32=0,_33=_2e+10,_34=118,_35=18,_36=_30-_35;if(_2d>_35&&_2d<_36){_32=_2d-130;if(_32<0){_32=0;}else{if(_32>_30-260){_32=_30-260;}}}else{if(_2d<=_35){_32=_2d-_35;}else{if(_2d>=_36){_32=(_30-260)+(_2d-_36);}}}if(_2d>118&&_2d<_30-130){_34=118;}else{if(_2d<=118){if(_2d>_35){_34=_2d-12;}else{if(_2d<=_35){_34=6;}}}else{if(_2d>=_30-130){if(_2d<_36){_34=118+_2d-(_30-130);}else{if(_2d>=_36){_34=118+_36-(_30-130);}}}}}if(_2e<=_31/2){_f.set(this.domNode,{left:_32+"px",top:_33+"px",bottom:null});_f.set(this._pointerTop,{left:_34+"px"});_c.add(this._pointerBottom,"hidden");_c.remove(this._pointerTop,"hidden");}else{_f.set(this.domNode,{left:_32+"px",top:_33-64+"px",bottom:null});_f.set(this._pointerBottom,{left:_34+"px"});_c.add(this._pointerTop,"hidden");_c.remove(this._pointerBottom,"hidden");}},_showPointer:function(_37){var _38=["topLeft","topRight","bottomRight","bottomLeft"];_5.forEach(_38,function(ptr){if(ptr===_37){_7.query(".pointer."+ptr,this.domNode).removeClass("hidden");}else{_7.query(".pointer."+ptr,this.domNode).addClass("hidden");}},this);},_toggleView:function(){if(!this.popupNavigationBar){this._initPopupNavigationBar();}if(!this.popupInfoView){this._initPopupInfoView();}this.hide();_15.show(this.popupNavigationBar.container);_15.show(this.popupInfoView.container);var _39="";if(this.selectedIndex>=0){_39=(this.selectedIndex+1)+" of "+this.features.length;this.setContent(this.features[this.selectedIndex].getContent());}},_handleNavigationBar:function(_3a){this.popupInfoView.animateTo(0);switch(_3a.name){case "CloseButton":_15.hide(this.popupNavigationBar.container);_15.hide(this.popupInfoView.container);this.hide();break;case "ToggleButton":_15.hide(this.popupNavigationBar.container);_15.hide(this.popupInfoView.container);this.show(this._location);break;case "PreviousButton":this.selectPrevious();this._updateUI();break;case "NextButton":this.selectNext();this._updateUI();break;}},_initPopupNavigationBar:function(){var _3b={};_3b.items=[{name:"CloseButton",type:"img",src:this.xIcon,srcAlt:this.xIcon,position:"left"},{name:"Title",type:"span",text:"",position:"center"},{name:"ToggleButton",type:"img",src:this.dArrowIcon,srcAlt:this.dArrowIcon,position:"right",toggleGroup:"toggle"},{name:"PreviousButton",type:"img",src:this.lArrowIcon,srcAlt:this.lArrowIcon,position:"right2",toggleGroup:"previous"},{name:"NextButton",type:"img",src:this.rArrowIcon,srcAlt:this.rArrowIcon,position:"right1",toggleGroup:"next"}];this.popupNavigationBar=new _13(_3b,_d.create("div",{},_6.body()));_4.connect(this.popupNavigationBar,"onCreate",this,function(_3c){this._prevFeatureButton=_3c[3]._node;this._nextFeatureButton=_3c[4]._node;});_4.connect(this.popupNavigationBar,"onSelect",this,this._handleNavigationBar);_4.connect(this.popupNavigationBar,"onUnSelect",this,this._handleNavigationBar);this.popupNavigationBar.startup();_15.hide(this.popupNavigationBar.container);},_initPopupInfoView:function(){var _3d={items:[{name:"Navigator",type:"div",text:""},{name:"content",type:"div",text:""},{name:"attachment",type:"div",text:""}]};this.popupInfoView=new _12(_3d,_d.create("div",{},_6.body()));_c.add(this.popupInfoView.container,"esriMobilePopupInfoView");this.popupInfoView.enableTouchScroll();_4.connect(this.popupInfoView,"onCreate",this,function(_3e){this._contentPane=_3e[1]._node;if(this.selectedIndex>=0){this.setContent(this.features[this.selectedIndex].getContent());}});_4.connect(this.popupInfoView,"onSwipeLeft",this,function(){});_4.connect(this.popupInfoView,"onSwipeRight",this,function(){});this.popupInfoView.startup();},_updateUI:function(){var _3f="&nbsp;",_40="&nbsp;",ptr=this.selectedIndex,_41=this.features,_42=this.deferreds,_43=this._prevFeatureButton.parentNode,_44=this._nextFeatureButton.parentNode,_45=this._spinner,_46=this._actionList,nls=this._nls;if(_41&&_41.length>=1){_3f=_41[ptr].getTitle();_40=(ptr+1)+" of "+_41.length;_c.remove(this._arrowButton,"hidden");if(ptr===0){_c.add(_43,"hidden");_c.add(this._prev,"hidden");}else{_c.remove(_43,"hidden");_c.remove(this._prev,"hidden");}if(ptr===_41.length-1){_c.add(_44,"hidden");_c.add(this._next,"hidden");}else{_c.remove(_44,"hidden");_c.remove(this._next,"hidden");}}else{_c.add(this._arrowButton,"hidden");_c.add(_43,"hidden");_c.add(_44,"hidden");_c.add(this._prev,"hidden");_c.add(this._next,"hidden");}this.setTitle(_3f,_40);this.popupNavigationBar.getItems()[1]._node.innerHTML=_40;if(_42&&_42.length){_c.remove(_45,"hidden");this.setTitle(nls.NLS_searching+"...","&nbsp;");}else{_c.add(_45,"hidden");if(!_41||!_41.length){this.setTitle("No Information","&nbsp;");}}}});if(_8("extend-esri")){_3.setObject("dijit.PopupMobile",PUM,_14);}return PUM;});