//>>built
define("dojox/mobile/_EditableIconMixin","dojo/_base/array dojo/_base/connect dojo/_base/declare dojo/_base/event dojo/_base/lang dojo/_base/window dojo/dom-geometry dojo/dom-style dojo/touch dijit/registry ./IconItem ./sniff ./viewRegistry ./_css3".split(" "),function(l,m,u,n,v,w,p,h,q,r,x,y,z,k){return u("dojox.mobile._EditableIconMixin",null,{deleteIconForEdit:"mblDomButtonBlackCircleCross",threshold:4,destroy:function(){this._blankItem&&this._blankItem.destroy();this.inherited(arguments)},startEdit:function(){if(this.editable&&
!this.isEditing){this.isEditing=!0;this._handles||(this._handles=[this.connect(this.domNode,k.name("transitionStart"),"_onTransitionStart"),this.connect(this.domNode,k.name("transitionEnd"),"_onTransitionEnd")]);var a=0;l.forEach(this.getChildren(),function(b){this.defer(function(){b.set("deleteIcon",this.deleteIconForEdit);b.deleteIconNode&&(b._deleteHandle=this.connect(b.deleteIconNode,"onclick","_deleteIconClicked"));b.highlight(0)},15*a++)},this);m.publish("/dojox/mobile/startEdit",[this]);this.onStartEdit()}},
endEdit:function(){this.isEditing&&(l.forEach(this.getChildren(),function(a){a.unhighlight();a._deleteHandle&&(this.disconnect(a._deleteHandle),a._deleteHandle=null);a.set("deleteIcon","")},this),this._movingItem=null,this._handles&&(l.forEach(this._handles,this.disconnect,this),this._handles=null),m.publish("/dojox/mobile/endEdit",[this]),this.onEndEdit(),this.isEditing=!1)},scaleItem:function(a,b){h.set(a.domNode,k.add({},{transition:y("android")?"":k.name("transform",!0)+" .1s ease-in-out",transform:1==
b?"":"scale("+b+")"}))},_onTransitionStart:function(a){n.stop(a)},_onTransitionEnd:function(a){n.stop(a);a=r.getEnclosingWidget(a.target);a._moving=!1;h.set(a.domNode,k.name("transition"),"")},_onTouchStart:function(a){this._blankItem||(this._blankItem=new x,this._blankItem.domNode.style.visibility="hidden",this._blankItem._onClick=function(){});var b=this._movingItem=r.getEnclosingWidget(a.target),d=!1,c;for(c=a.target;c!==b.domNode;c=c.parentNode)if(c===b.iconNode){d=!0;break}d&&(this._conn||(this._conn=
[this.connect(this.domNode,q.move,"_onTouchMove"),this.connect(w.doc,q.release,"_onTouchEnd")]),this._touchStartPosX=a.touches?a.touches[0].pageX:a.pageX,this._touchStartPosY=a.touches?a.touches[0].pageY:a.pageY,this.isEditing?this._onDragStart(a):this._pressTimer=this.defer(function(){this.startEdit();this._onDragStart(a)},1E3))},_onDragStart:function(a){this._dragging=!0;var b=this._movingItem;b.get("selected")&&b.set("selected",!1);this.scaleItem(b,1.1);var d=a.touches?a.touches[0].pageX:a.pageX,
c=a.touches?a.touches[0].pageY:a.pageY,g=z.getEnclosingScrollable(b.domNode),e=0,f=0;g&&(f=g.getPos(),e=f.x,f=f.y,n.stop(a));a=this._startPos=p.position(b.domNode,!0);this._offsetPos={x:a.x-d-e,y:a.y-c-f};this._startIndex=this.getIndexOfChild(b);this.addChild(this._blankItem,this._startIndex);this.moveChild(b,this.getChildren().length);h.set(b.domNode,{position:"absolute",top:a.y-f+"px",left:a.x-e+"px",zIndex:100})},_onTouchMove:function(a){var b=a.touches?a.touches[0].pageX:a.pageX,d=a.touches?a.touches[0].pageY:
a.pageY;this._dragging?(h.set(this._movingItem.domNode,{top:this._offsetPos.y+d+"px",left:this._offsetPos.x+b+"px"}),this._detectOverlap({x:b,y:d}),n.stop(a)):(a=Math.abs(this._touchStartPosY-d),(Math.abs(this._touchStartPosX-b)>this.threshold||a>this.threshold)&&this._clearPressTimer())},_onTouchEnd:function(a){this._clearPressTimer();this._conn&&(l.forEach(this._conn,this.disconnect,this),this._conn=null);if(this._dragging){this._dragging=!1;a=this._movingItem;this.scaleItem(a,1);h.set(a.domNode,
{position:"",top:"",left:"",zIndex:""});var b=this._startIndex,d=this.getIndexOfChild(this._blankItem);this.moveChild(a,d);this.removeChild(this._blankItem);m.publish("/dojox/mobile/moveIconItem",[this,a,b,d]);this.onMoveItem(a,b,d)}},_clearPressTimer:function(){this._pressTimer&&(this._pressTimer.remove(),this._pressTimer=null)},_detectOverlap:function(a){var b=this.getChildren(),d=this._blankItem,c=p.position(d.domNode,!0),g=this.getIndexOfChild(d),e=1,f;if(!this._contains(a,c)){if(a.y<c.y||a.y<=
c.y+c.h&&a.x<c.x)e=-1;for(f=g+e;0<=f&&f<b.length-1;f+=e)if(c=b[f],!c._moving)if(c=p.position(c.domNode,!0),this._contains(a,c)){this.defer(function(){this.moveChildWithAnimation(d,1==e?f+1:f)});break}else if(1==e&&c.y>a.y||-1==e&&c.y+c.h<a.y)break}},_contains:function(a,b){return b.x<a.x&&a.x<b.x+b.w&&b.y<a.y&&a.y<b.y+b.h},_animate:function(a,b){if(a!=b){var d=a<b?1:-1,c=this.getChildren(),g=[],e,f;for(e=a;e!=b;e+=d)g.push({t:c[e+d].domNode.offsetTop-c[e].domNode.offsetTop+"px",l:c[e+d].domNode.offsetLeft-
c[e].domNode.offsetLeft+"px"});e=a;for(f=0;e!=b;e+=d,f++){var t=c[e];t._moving=!0;h.set(t.domNode,{top:g[f].t,left:g[f].l});this.defer(v.hitch(t,function(){h.set(this.domNode,k.add({top:"0px",left:"0px"},{transition:"top .3s ease-in-out, left .3s ease-in-out"}))}),10*f)}}},removeChildWithAnimation:function(a){var b="number"===typeof a?a:this.getIndexOfChild(a);this.removeChild(a);this._blankItem&&this.addChild(this._blankItem);this._animate(b,this.getChildren().length-1);this._blankItem&&this.removeChild(this._blankItem)},
moveChild:function(a,b){this.addChild(a,b);this.paneContainerWidget.addChild(a.paneWidget,b)},moveChildWithAnimation:function(a,b){var d=this.getIndexOfChild(this._blankItem);this.moveChild(a,b);this._animate(d,b)},_deleteIconClicked:function(a){!1!==this.deleteIconClicked(a)&&(a=r.getEnclosingWidget(a.target),this.deleteItem(a))},deleteIconClicked:function(){},deleteItem:function(a){a._deleteHandle&&this.disconnect(a._deleteHandle);this.removeChildWithAnimation(a);m.publish("/dojox/mobile/deleteIconItem",
[this,a]);this.onDeleteItem(a);a.destroy()},onDeleteItem:function(a){},onMoveItem:function(a,b,d){},onStartEdit:function(){},onEndEdit:function(){},_setEditableAttr:function(a){this._set("editable",a);a&&!this._touchStartHandle?this._touchStartHandle=this.connect(this.domNode,q.press,"_onTouchStart"):!a&&this._touchStartHandle&&(this.disconnect(this._touchStartHandle),this._touchStartHandle=null)}})});