/*
 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/InfoView",["dojo/_base/declare","dojo/_base/lang","dojo/_base/array","dojo/_base/connect","dojo/_base/kernel","dojo/has","dojo/query","dojo/dom","dojo/dom-class","dojo/dom-construct","dojo/dom-geometry","esri/kernel","esri/dijit/_TouchBase"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d){var IV=_1(null,{declaredClass:"esri.dijit.InfoView",_items:[],_top:null,_sections:[],_isDecelerate:false,constructor:function(_e,_f){var i;this.container=_8.byId(_f);this._touchBase=_d(this.container,null);this._slideDiv=_a.create("div",null,this.container,"first");this.events=[];this._items=_e.items;if(_e.sections){this._sections=_e.sections;}_9.add(this.container,"esriMobileInfoView");if(this._sections.length===0){_a.create("div",{},this._slideDiv);}else{for(i=0;i<this._sections.length;i++){var _10=_a.create("div",{"class":"esriMobileInfoViewSection"},this._slideDiv);_a.create("div",{innerHTML:this._sections[i].title},_10);}}for(i=0;i<this._items.length;i++){var _11,div;var _12=0;if(this._items[i].section){_12=this._items[i].section;}switch(this._items[i].type){case "div":div=_a.create("div",{"class":"esriMobileInfoViewItem",style:this._items[i].style},this._slideDiv.childNodes[_12]);_11=_a.create("div",{innerHTML:this._items[i].text},div);break;}if(this._items[i].className){_9.add(_11,this._items[i].className);}_11._index=i;_11._item=this._items[i];this._items[i]._node=_11;}this.startTouchY=0;},startup:function(){this.onCreate(this._items);this._animateTo(0);},destroy:function(){_3.forEach(this.events,_4.disconnect);this._touchBase=null;_5.query("img",this.container).forEach(function(_13){_13._index=null;_13._item=null;_a.destroy(_13);_13=null;});this._items=null;_a.destroy(this._slideDiv);_a.destroy(this.container);this.container=this._slideDiv=null;},getItems:function(){return this._items;},setPreventDefault:function(_14){this._touchBase.setPreventDefault(_14);},enableTouchScroll:function(){this._touchBase.setPreventDefault(true);this.events.push(_4.connect(this._touchBase,"onTouchStart",this,this._onTouchStartHandler));this.events.push(_4.connect(this._touchBase,"onTouchMove",this,this._onTouchMoveHandler));this.events.push(_4.connect(this._touchBase,"onTouchEnd",this,this._onTouchEndHandler));this._slideDiv.style.webkitTransform="translate3d(0,"+this._top+"px, 0)";},disableTouchScroll:function(){_4.disconnect(this.events.pop());_4.disconnect(this.events.pop());_4.disconnect(this.events.pop());this._touchBase.setPreventDefault(false);this._slideDiv.style.webkitTransform="translate3d(0, 0px, 0)";},animateTo:function(){this._slideDiv.style.WebkitTransitionDuration="0s";this._animateTo(0);},onSelect:function(_15){},onUnSelect:function(_16){},onCreate:function(_17){},onClick:function(e){},onSwipeLeft:function(){},onSwipeRight:function(){},_onTouchStartHandler:function(e){this._slideDiv.style.WebkitTransitionDuration="0s";this._moveDirection=null;this._startTime=new Date();this.startTouchY=e.touches[0].clientY;this.contentStartOffsetY=this.contentOffsetY;},_onTouchMoveHandler:function(e){if(!this._moveDirection){if(Math.abs(e.curY)>Math.abs(e.curX)){this._moveDirection="vertical";}else{this._moveDirection="horizontal";}}if(this._moveDirection==="horizontal"){return;}else{if(this._moveDirection==="vertical"){var _18=e.touches[0].clientY;var _19=_18-this.startTouchY;var _1a=_19+this.contentStartOffsetY;this._animateTo(_1a);}}},_onTouchEndHandler:function(e){this._endTime=new Date();this._deltaMovement=e.curY;if(this._moveDirection==="vertical"){if(this._shouldStartMomentum()){this._doMomentum();}else{this._snapToBounds();}}else{if(this._moveDirection==="horizontal"){if(e.swipeDirection==="left"){this.onSwipeLeft();}else{if(e.swipeDirection==="right"){this.onSwipeRight();}}}}},_shouldStartMomentum:function(){this._diff=this._endTime-this._startTime;this._velocity=this._deltaMovement/this._diff;if(Math.abs(this._velocity)>0.2&&this._diff<200){return true;}else{return false;}},_pullToStop:function(_1b){if(Math.abs(_1b)>80){_1b=_1b>0?80:(-contentBox.h+parentBox.h-10)-80;}console.log(_1b);this._slideDiv.style.webkitTransition="-webkit-transform 200ms cubic-bezier(0, 0, 1, 1)";var _1c=_4.connect(this._slideDiv,"webkitTransitionEnd",this,function(){if(_1b>0){this._animateTo(0);}else{this._animateTo(-contentBox.h+parentBox.h-10);}_4.disconnect(_1c);});this._animateTo(_1b);},_doMomentum:function(){var i;var il;var _1d=_b.getContentBox(this.container);var _1e=this._velocity<0?0.001:-0.001;var _1f=-(this._velocity*this._velocity)/(2*_1e);var _20=-this._velocity/_1e;var p0={x:0,y:0};var p1={x:0,y:0.3};var p2={x:0.6,y:1};var p3={x:1,y:1};var cx=3*(p1.x-p0.x);var bx=3*(p2.x-p1.x)-cx;var ax=p3.x-p0.x-cx-bx;var cy=3*(p1.y-p0.y);var by=3*(p2.y-p1.y)-cy;var ay=p3.y-p0.y-cy-by;var _21=0,_22=0;if(_1d.h>this._slideDiv.scrollHeight){this.contentOffsetY=0;_22=300;}else{if(this.contentOffsetY+_1f>0){for(i=0,il=Math.floor(_20/20);i<il;i++){_21=(ax*(i*20)^3)+(bx*(i*20)^2)+cx*(i*20)+p0.x;_21=this._velocity<0?-_21:_21;if(this.contentOffsetY+_21>0){_22=i*20;break;}}if(_22===0){_22=300;}this.contentOffsetY=0;}else{if(Math.abs(this.contentOffsetY+_1f)+_1d.h>this._slideDiv.scrollHeight){this.contentOffsetY=_1d.h-this._slideDiv.scrollHeight;for(i=0,il=Math.floor(_20/20);i<il;i++){_21=(ax*(i*20)^3)+(bx*(i*20)^2)+cx*(i*20)+p0.x;_21=this._velocity<0?-_21:_21;if(Math.abs(this.contentOffsetY+_21)>this._slideDiv.scrollHeight){_22=i*20;break;}}}else{_22=_20;this.contentOffsetY=this.contentOffsetY+_1f;}}}this._slideDiv.style.webkitTransition="-webkit-transform "+_22+"ms cubic-bezier(0, 0.3, 0.6, 1)";this._animateTo(this.contentOffsetY);},_snapToBounds:function(){var _23=_b.getContentBox(this.container);if(_23.h>this._slideDiv.scrollHeight){this.contentOffsetY=0;}else{if(this.contentOffsetY>0){this.contentOffsetY=0;}else{if(Math.abs(this.contentOffsetY)+_23.h>this._slideDiv.scrollHeight){this.contentOffsetY=_23.h-this._slideDiv.scrollHeight;}}}this._slideDiv.style.WebkitTransitionDuration="0.5s";this._animateTo(this.contentOffsetY);},_animateTo:function(_24){this.contentOffsetY=_24;this._slideDiv.style.webkitTransform="translate3d(0, "+_24+"px, 0)";},_stopMomentum:function(){if(this._isDecelerating()){var _25=document.defaultView.getComputedStyle(this._slideDiv,null);var _26=new WebKitCSSMatrix(_25.webkitTransform);this._slideDiv.style.webkitTransition="";this.animateTo(_26.m42);}},_isDecelerating:function(){if(this.isDecelerate){return true;}else{return false;}},_toggleNode:function(_27,_28){if(_28.toggleState==="ON"){_28.toggleState="OFF";if(_28.src){_27.src=_28.src.toString();}this.onUnSelect(_28);}else{_28.toggleState="ON";if(_28.srcAlt){_27.src=_28.srcAlt;}this.onSelect(_28);}}});if(_6("extend-esri")){_2.setObject("dijit.InfoView",IV,_c);}return IV;});