/* Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ if(!dojo._hasResource["dojo.dnd.Selector"]){ dojo._hasResource["dojo.dnd.Selector"]=true; dojo.provide("dojo.dnd.Selector"); dojo.require("dojo.dnd.common"); dojo.require("dojo.dnd.Container"); dojo.declare("dojo.dnd.Selector",dojo.dnd.Container,{constructor:function(_1,_2){ if(!_2){ _2={}; } this.singular=_2.singular; this.autoSync=_2.autoSync; this.selection={}; this.anchor=null; this.simpleSelection=false; this.events.push(dojo.connect(this.node,"onmousedown",this,"onMouseDown"),dojo.connect(this.node,"onmouseup",this,"onMouseUp")); },singular:false,getSelectedNodes:function(){ var t=new dojo.NodeList(); var e=dojo.dnd._empty; for(var i in this.selection){ if(i in e){ continue; } t.push(dojo.byId(i)); } return t; },selectNone:function(){ return this._removeSelection()._removeAnchor(); },selectAll:function(){ this.forInItems(function(_3,id){ this._addItemClass(dojo.byId(id),"Selected"); this.selection[id]=1; },this); return this._removeAnchor(); },deleteSelectedNodes:function(){ var e=dojo.dnd._empty; for(var i in this.selection){ if(i in e){ continue; } var n=dojo.byId(i); this.delItem(i); dojo.destroy(n); } this.anchor=null; this.selection={}; return this; },forInSelectedItems:function(f,o){ o=o||dojo.global; var s=this.selection,e=dojo.dnd._empty; for(var i in s){ if(i in e){ continue; } f.call(o,this.getItem(i),i,this); } },sync:function(){ dojo.dnd.Selector.superclass.sync.call(this); if(this.anchor){ if(!this.getItem(this.anchor.id)){ this.anchor=null; } } var t=[],e=dojo.dnd._empty; for(var i in this.selection){ if(i in e){ continue; } if(!this.getItem(i)){ t.push(i); } } dojo.forEach(t,function(i){ delete this.selection[i]; },this); return this; },insertNodes:function(_4,_5,_6,_7){ var _8=this._normalizedCreator; this._normalizedCreator=function(_9,_a){ var t=_8.call(this,_9,_a); if(_4){ if(!this.anchor){ this.anchor=t.node; this._removeItemClass(t.node,"Selected"); this._addItemClass(this.anchor,"Anchor"); }else{ if(this.anchor!=t.node){ this._removeItemClass(t.node,"Anchor"); this._addItemClass(t.node,"Selected"); } } this.selection[t.node.id]=1; }else{ this._removeItemClass(t.node,"Selected"); this._removeItemClass(t.node,"Anchor"); } return t; }; dojo.dnd.Selector.superclass.insertNodes.call(this,_5,_6,_7); this._normalizedCreator=_8; return this; },destroy:function(){ dojo.dnd.Selector.superclass.destroy.call(this); this.selection=this.anchor=null; },markupFactory:function(_b,_c){ _b._skipStartup=true; return new dojo.dnd.Selector(_c,_b); },onMouseDown:function(e){ if(this.autoSync){ this.sync(); } if(!this.current){ return; } if(!this.singular&&!dojo.isCopyKey(e)&&!e.shiftKey&&(this.current.id in this.selection)){ this.simpleSelection=true; if(e.button===dojo.mouseButtons.LEFT){ dojo.stopEvent(e); } return; } if(!this.singular&&e.shiftKey){ if(!dojo.isCopyKey(e)){ this._removeSelection(); } var c=this.getAllNodes(); if(c.length){ if(!this.anchor){ this.anchor=c[0]; this._addItemClass(this.anchor,"Anchor"); } this.selection[this.anchor.id]=1; if(this.anchor!=this.current){ var i=0; for(;i