/*
	Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

//>>built
define("dojo/dnd/Container","../_base/array ../_base/declare ../_base/kernel ../_base/lang ../_base/window ../dom ../dom-class ../dom-construct ../Evented ../has ../on ../query ../touch ./common".split(" "),function(t,n,u,g,x,q,h,k,v,y,l,w,r,e){n=n("dojo.dnd.Container",v,{skipForm:!1,allowNested:!1,constructor:function(a,b){this.node=q.byId(a);b||(b={});this.creator=b.creator||null;this.skipForm=b.skipForm;this.parent=b.dropParent&&q.byId(b.dropParent);this.map={};this.current=null;this.containerState=
"";h.add(this.node,"dojoDndContainer");b&&b._skipStartup||this.startup();this.events=[l(this.node,r.over,g.hitch(this,"onMouseOver")),l(this.node,r.out,g.hitch(this,"onMouseOut")),l(this.node,"dragstart",g.hitch(this,"onSelectStart")),l(this.node,"selectstart",g.hitch(this,"onSelectStart"))]},creator:function(){},getItem:function(a){return this.map[a]},setItem:function(a,b){this.map[a]=b},delItem:function(a){delete this.map[a]},forInItems:function(a,b){b=b||u.global;var c=this.map,d=e._empty,f;for(f in c)f in
d||a.call(b,c[f],f,this);return b},clearItems:function(){this.map={}},getAllNodes:function(){return w((this.allowNested?"":"\x3e ")+".dojoDndItem",this.parent)},sync:function(){var a={};this.getAllNodes().forEach(function(b){if(b.id){var c=this.getItem(b.id);if(c){a[b.id]=c;return}}else b.id=e.getUniqueId();c=b.getAttribute("dndType");var d=b.getAttribute("dndData");a[b.id]={data:d||b.innerHTML,type:c?c.split(/\s*,\s*/):["text"]}},this);this.map=a;return this},insertNodes:function(a,b,c){this.parent.firstChild?
b?c||(c=this.parent.firstChild):c&&(c=c.nextSibling):c=null;if(c)for(b=0;b<a.length;++b){var d=this._normalizedCreator(a[b]);this.setItem(d.node.id,{data:d.data,type:d.type});c.parentNode.insertBefore(d.node,c)}else for(b=0;b<a.length;++b)d=this._normalizedCreator(a[b]),this.setItem(d.node.id,{data:d.data,type:d.type}),this.parent.appendChild(d.node);return this},destroy:function(){t.forEach(this.events,function(a){a.remove()});this.clearItems();this.node=this.parent=this.current=null},markupFactory:function(a,
b,c){a._skipStartup=!0;return new c(b,a)},startup:function(){if(!this.parent&&(this.parent=this.node,"table"==this.parent.tagName.toLowerCase())){var a=this.parent.getElementsByTagName("tbody");a&&a.length&&(this.parent=a[0])}this.defaultCreator=e._defaultCreator(this.parent);this.sync()},onMouseOver:function(a){for(var b=a.relatedTarget;b&&b!=this.node;)try{b=b.parentNode}catch(c){b=null}b||(this._changeState("Container","Over"),this.onOverEvent());b=this._getChildByEvent(a);this.current!=b&&(this.current&&
this._removeItemClass(this.current,"Over"),b&&this._addItemClass(b,"Over"),this.current=b)},onMouseOut:function(a){for(a=a.relatedTarget;a;){if(a==this.node)return;try{a=a.parentNode}catch(b){a=null}}this.current&&(this._removeItemClass(this.current,"Over"),this.current=null);this._changeState("Container","");this.onOutEvent()},onSelectStart:function(a){this.withHandles||this.skipForm&&e.isFormElement(a)||(a.stopPropagation(),a.preventDefault())},onOverEvent:function(){},onOutEvent:function(){},_changeState:function(a,
b){var c="dojoDnd"+a,d=a.toLowerCase()+"State";h.replace(this.node,c+b,c+this[d]);this[d]=b},_addItemClass:function(a,b){h.add(a,"dojoDndItem"+b)},_removeItemClass:function(a,b){h.remove(a,"dojoDndItem"+b)},_getChildByEvent:function(a){if(a=a.target)for(var b=a.parentNode;b;a=b,b=a.parentNode)if((b==this.parent||this.allowNested)&&h.contains(a,"dojoDndItem"))return a;return null},_normalizedCreator:function(a,b){var c=(this.creator||this.defaultCreator).call(this,a,b);g.isArray(c.type)||(c.type=["text"]);
c.node.id||(c.node.id=e.getUniqueId());h.add(c.node,"dojoDndItem");return c}});e._createNode=function(a){return a?function(b){return k.create(a,{innerHTML:b})}:e._createSpan};e._createTrTd=function(a){var b=k.create("tr");k.create("td",{innerHTML:a},b);return b};e._createSpan=function(a){return k.create("span",{innerHTML:a})};e._defaultCreatorNodes={ul:"li",ol:"li",div:"div",p:"div"};e._defaultCreator=function(a){a=a.tagName.toLowerCase();var b="tbody"==a||"thead"==a?e._createTrTd:e._createNode(e._defaultCreatorNodes[a]);
return function(c,d){var f=c&&g.isObject(c);if(f&&c.tagName&&c.nodeType&&c.getAttribute){var p=c.getAttribute("dndData")||c.innerHTML;f=(f=c.getAttribute("dndType"))?f.split(/\s*,\s*/):["text"];var m=c}else p=f&&c.data?c.data:c,f=f&&c.type?c.type:["text"],m=("avatar"==d?e._createSpan:b)(String(p));m.id||(m.id=e.getUniqueId());return{node:m,data:p,type:f}}};return n});