1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2026-02-10 16:01:33 +00:00

upgrade dojo to 1.8.3 (refs #570)

This commit is contained in:
Andrew Dolgov
2013-03-18 10:26:24 +04:00
parent 9a2885da17
commit f0cfe83e37
1568 changed files with 159866 additions and 2781 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/AutoSource",["./Source"],function(_1){return dojo.declare("dojo.dnd.AutoSource",_1,{constructor:function(_2,_3){this.autoSync=true;}});});
define("dojo/dnd/AutoSource",["../_base/declare","./Source"],function(_1,_2){return _1("dojo.dnd.AutoSource",_2,{constructor:function(){this.autoSync=true;}});});
@@ -0,0 +1,12 @@
define("dojo/dnd/AutoSource", ["../_base/declare", "./Source"], function(declare, Source){
return declare("dojo.dnd.AutoSource", Source, {
// summary:
// a source that syncs its DnD nodes by default
constructor: function(/*===== node, params =====*/){
// summary:
// constructor of the AutoSource --- see the Source constructor for details
this.autoSync = true;
}
});
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/Avatar",["../main","./common"],function(_1){_1.declare("dojo.dnd.Avatar",null,{constructor:function(_2){this.manager=_2;this.construct();},construct:function(){this.isA11y=_1.hasClass(_1.body(),"dijit_a11y");var a=_1.create("table",{"class":"dojoDndAvatar",style:{position:"absolute",zIndex:"1999",margin:"0px"}}),_3=this.manager.source,_4,b=_1.create("tbody",null,a),tr=_1.create("tr",null,b),td=_1.create("td",null,tr),_5=this.isA11y?_1.create("span",{id:"a11yIcon",innerHTML:this.manager.copy?"+":"<"},td):null,_6=_1.create("span",{innerHTML:_3.generateText?this._generateText():""},td),k=Math.min(5,this.manager.nodes.length),i=0;_1.attr(tr,{"class":"dojoDndAvatarHeader",style:{opacity:0.9}});for(;i<k;++i){if(_3.creator){_4=_3._normalizedCreator(_3.getItem(this.manager.nodes[i].id).data,"avatar").node;}else{_4=this.manager.nodes[i].cloneNode(true);if(_4.tagName.toLowerCase()=="tr"){var _7=_1.create("table"),_8=_1.create("tbody",null,_7);_8.appendChild(_4);_4=_7;}}_4.id="";tr=_1.create("tr",null,b);td=_1.create("td",null,tr);td.appendChild(_4);_1.attr(tr,{"class":"dojoDndAvatarItem",style:{opacity:(9-i)/10}});}this.node=a;},destroy:function(){_1.destroy(this.node);this.node=false;},update:function(){_1[(this.manager.canDropFlag?"add":"remove")+"Class"](this.node,"dojoDndAvatarCanDrop");if(this.isA11y){var _9=_1.byId("a11yIcon");var _a="+";if(this.manager.canDropFlag&&!this.manager.copy){_a="< ";}else{if(!this.manager.canDropFlag&&!this.manager.copy){_a="o";}else{if(!this.manager.canDropFlag){_a="x";}}}_9.innerHTML=_a;}_1.query(("tr.dojoDndAvatarHeader td span"+(this.isA11y?" span":"")),this.node).forEach(function(_b){_b.innerHTML=this._generateText();},this);},_generateText:function(){return this.manager.nodes.length.toString();}});return _1.dnd.Avatar;});
define("dojo/dnd/Avatar",["../_base/declare","../_base/window","../dom","../dom-attr","../dom-class","../dom-construct","../hccss","../query"],function(_1,_2,_3,_4,_5,_6,_7,_8){return _1("dojo.dnd.Avatar",null,{constructor:function(_9){this.manager=_9;this.construct();},construct:function(){var a=_6.create("table",{"class":"dojoDndAvatar",style:{position:"absolute",zIndex:"1999",margin:"0px"}}),_a=this.manager.source,_b,b=_6.create("tbody",null,a),tr=_6.create("tr",null,b),td=_6.create("td",null,tr),k=Math.min(5,this.manager.nodes.length),i=0;if(_7("highcontrast")){_6.create("span",{id:"a11yIcon",innerHTML:this.manager.copy?"+":"<"},td);}_6.create("span",{innerHTML:_a.generateText?this._generateText():""},td);_4.set(tr,{"class":"dojoDndAvatarHeader",style:{opacity:0.9}});for(;i<k;++i){if(_a.creator){_b=_a._normalizedCreator(_a.getItem(this.manager.nodes[i].id).data,"avatar").node;}else{_b=this.manager.nodes[i].cloneNode(true);if(_b.tagName.toLowerCase()=="tr"){var _c=_6.create("table"),_d=_6.create("tbody",null,_c);_d.appendChild(_b);_b=_c;}}_b.id="";tr=_6.create("tr",null,b);td=_6.create("td",null,tr);td.appendChild(_b);_4.set(tr,{"class":"dojoDndAvatarItem",style:{opacity:(9-i)/10}});}this.node=a;},destroy:function(){_6.destroy(this.node);this.node=false;},update:function(){_5.toggle(this.node,"dojoDndAvatarCanDrop",this.manager.canDropFlag);if(_7("highcontrast")){var _e=_3.byId("a11yIcon");var _f="+";if(this.manager.canDropFlag&&!this.manager.copy){_f="< ";}else{if(!this.manager.canDropFlag&&!this.manager.copy){_f="o";}else{if(!this.manager.canDropFlag){_f="x";}}}_e.innerHTML=_f;}_8(("tr.dojoDndAvatarHeader td span"+(_7("highcontrast")?" span":"")),this.node).forEach(function(_10){_10.innerHTML=this.manager.source.generateText?this._generateText():"";},this);},_generateText:function(){return this.manager.nodes.length.toString();}});});
+122
View File
@@ -0,0 +1,122 @@
define("dojo/dnd/Avatar", [
"../_base/declare",
"../_base/window",
"../dom",
"../dom-attr",
"../dom-class",
"../dom-construct",
"../hccss",
"../query"
], function(declare, win, dom, domAttr, domClass, domConstruct, has, query){
// module:
// dojo/dnd/Avatar
return declare("dojo.dnd.Avatar", null, {
// summary:
// Object that represents transferred DnD items visually
// manager: Object
// a DnD manager object
constructor: function(manager){
this.manager = manager;
this.construct();
},
// methods
construct: function(){
// summary:
// constructor function;
// it is separate so it can be (dynamically) overwritten in case of need
var a = domConstruct.create("table", {
"class": "dojoDndAvatar",
style: {
position: "absolute",
zIndex: "1999",
margin: "0px"
}
}),
source = this.manager.source, node,
b = domConstruct.create("tbody", null, a),
tr = domConstruct.create("tr", null, b),
td = domConstruct.create("td", null, tr),
k = Math.min(5, this.manager.nodes.length), i = 0;
if(has("highcontrast")){
domConstruct.create("span", {
id : "a11yIcon",
innerHTML : this.manager.copy ? '+' : "<"
}, td)
}
domConstruct.create("span", {
innerHTML: source.generateText ? this._generateText() : ""
}, td);
// we have to set the opacity on IE only after the node is live
domAttr.set(tr, {
"class": "dojoDndAvatarHeader",
style: {opacity: 0.9}
});
for(; i < k; ++i){
if(source.creator){
// create an avatar representation of the node
node = source._normalizedCreator(source.getItem(this.manager.nodes[i].id).data, "avatar").node;
}else{
// or just clone the node and hope it works
node = this.manager.nodes[i].cloneNode(true);
if(node.tagName.toLowerCase() == "tr"){
// insert extra table nodes
var table = domConstruct.create("table"),
tbody = domConstruct.create("tbody", null, table);
tbody.appendChild(node);
node = table;
}
}
node.id = "";
tr = domConstruct.create("tr", null, b);
td = domConstruct.create("td", null, tr);
td.appendChild(node);
domAttr.set(tr, {
"class": "dojoDndAvatarItem",
style: {opacity: (9 - i) / 10}
});
}
this.node = a;
},
destroy: function(){
// summary:
// destructor for the avatar; called to remove all references so it can be garbage-collected
domConstruct.destroy(this.node);
this.node = false;
},
update: function(){
// summary:
// updates the avatar to reflect the current DnD state
domClass.toggle(this.node, "dojoDndAvatarCanDrop", this.manager.canDropFlag);
if(has("highcontrast")){
var icon = dom.byId("a11yIcon");
var text = '+'; // assume canDrop && copy
if (this.manager.canDropFlag && !this.manager.copy){
text = '< '; // canDrop && move
}else if (!this.manager.canDropFlag && !this.manager.copy){
text = "o"; //!canDrop && move
}else if(!this.manager.canDropFlag){
text = 'x'; // !canDrop && copy
}
icon.innerHTML=text;
}
// replace text
query(("tr.dojoDndAvatarHeader td span" +(has("highcontrast") ? " span" : "")), this.node).forEach(
function(node){
node.innerHTML = this.manager.source.generateText ? this._generateText() : "";
}, this);
},
_generateText: function(){
// summary:
// generates a proper text to reflect copying or moving of items
return this.manager.nodes.length.toString();
}
});
});
File diff suppressed because one or more lines are too long
+456
View File
@@ -0,0 +1,456 @@
define("dojo/dnd/Container", [
"../_base/array",
"../_base/declare",
"../_base/event",
"../_base/kernel",
"../_base/lang",
"../_base/window",
"../dom",
"../dom-class",
"../dom-construct",
"../Evented",
"../has",
"../on",
"../query",
"../ready",
"../touch",
"./common"
], function(
array, declare, event, kernel, lang, win,
dom, domClass, domConstruct, Evented, has, on, query, ready, touch, dnd){
// module:
// dojo/dnd/Container
/*
Container states:
"" - normal state
"Over" - mouse over a container
Container item states:
"" - normal state
"Over" - mouse over a container item
*/
var Container = declare("dojo.dnd.Container", Evented, {
// summary:
// a Container object, which knows when mouse hovers over it,
// and over which element it hovers
// object attributes (for markup)
skipForm: false,
// allowNested: Boolean
// Indicates whether to allow dnd item nodes to be nested within other elements.
// By default this is false, indicating that only direct children of the container can
// be draggable dnd item nodes
allowNested: false,
/*=====
// current: DomNode
// The DOM node the mouse is currently hovered over
current: null,
// map: Hash<String, Container.Item>
// Map from an item's id (which is also the DOMNode's id) to
// the dojo/dnd/Container.Item itself.
map: {},
=====*/
constructor: function(node, params){
// summary:
// a constructor of the Container
// node: Node
// node or node's id to build the container on
// params: Container.__ContainerArgs
// a dictionary of parameters
this.node = dom.byId(node);
if(!params){ params = {}; }
this.creator = params.creator || null;
this.skipForm = params.skipForm;
this.parent = params.dropParent && dom.byId(params.dropParent);
// class-specific variables
this.map = {};
this.current = null;
// states
this.containerState = "";
domClass.add(this.node, "dojoDndContainer");
// mark up children
if(!(params && params._skipStartup)){
this.startup();
}
// set up events
this.events = [
on(this.node, touch.over, lang.hitch(this, "onMouseOver")),
on(this.node, touch.out, lang.hitch(this, "onMouseOut")),
// cancel text selection and text dragging
on(this.node, "dragstart", lang.hitch(this, "onSelectStart")),
on(this.node, "selectstart", lang.hitch(this, "onSelectStart"))
];
},
// object attributes (for markup)
creator: function(){
// summary:
// creator function, dummy at the moment
},
// abstract access to the map
getItem: function(/*String*/ key){
// summary:
// returns a data item by its key (id)
return this.map[key]; // Container.Item
},
setItem: function(/*String*/ key, /*Container.Item*/ data){
// summary:
// associates a data item with its key (id)
this.map[key] = data;
},
delItem: function(/*String*/ key){
// summary:
// removes a data item from the map by its key (id)
delete this.map[key];
},
forInItems: function(/*Function*/ f, /*Object?*/ o){
// summary:
// iterates over a data map skipping members that
// are present in the empty object (IE and/or 3rd-party libraries).
o = o || kernel.global;
var m = this.map, e = dnd._empty;
for(var i in m){
if(i in e){ continue; }
f.call(o, m[i], i, this);
}
return o; // Object
},
clearItems: function(){
// summary:
// removes all data items from the map
this.map = {};
},
// methods
getAllNodes: function(){
// summary:
// returns a list (an array) of all valid child nodes
return query((this.allowNested ? "" : "> ") + ".dojoDndItem", this.parent); // NodeList
},
sync: function(){
// summary:
// sync up the node list with the data map
var map = {};
this.getAllNodes().forEach(function(node){
if(node.id){
var item = this.getItem(node.id);
if(item){
map[node.id] = item;
return;
}
}else{
node.id = dnd.getUniqueId();
}
var type = node.getAttribute("dndType"),
data = node.getAttribute("dndData");
map[node.id] = {
data: data || node.innerHTML,
type: type ? type.split(/\s*,\s*/) : ["text"]
};
}, this);
this.map = map;
return this; // self
},
insertNodes: function(data, before, anchor){
// summary:
// inserts an array of new nodes before/after an anchor node
// data: Array
// a list of data items, which should be processed by the creator function
// before: Boolean
// insert before the anchor, if true, and after the anchor otherwise
// anchor: Node
// the anchor node to be used as a point of insertion
if(!this.parent.firstChild){
anchor = null;
}else if(before){
if(!anchor){
anchor = this.parent.firstChild;
}
}else{
if(anchor){
anchor = anchor.nextSibling;
}
}
var i, t;
if(anchor){
for(i = 0; i < data.length; ++i){
t = this._normalizedCreator(data[i]);
this.setItem(t.node.id, {data: t.data, type: t.type});
anchor.parentNode.insertBefore(t.node, anchor);
}
}else{
for(i = 0; i < data.length; ++i){
t = this._normalizedCreator(data[i]);
this.setItem(t.node.id, {data: t.data, type: t.type});
this.parent.appendChild(t.node);
}
}
return this; // self
},
destroy: function(){
// summary:
// prepares this object to be garbage-collected
array.forEach(this.events, function(handle){ handle.remove(); });
this.clearItems();
this.node = this.parent = this.current = null;
},
// markup methods
markupFactory: function(params, node, Ctor){
params._skipStartup = true;
return new Ctor(node, params);
},
startup: function(){
// summary:
// collects valid child items and populate the map
// set up the real parent node
if(!this.parent){
// use the standard algorithm, if not assigned
this.parent = this.node;
if(this.parent.tagName.toLowerCase() == "table"){
var c = this.parent.getElementsByTagName("tbody");
if(c && c.length){ this.parent = c[0]; }
}
}
this.defaultCreator = dnd._defaultCreator(this.parent);
// process specially marked children
this.sync();
},
// mouse events
onMouseOver: function(e){
// summary:
// event processor for onmouseover or touch, to mark that element as the current element
// e: Event
// mouse event
var n = e.relatedTarget;
while(n){
if(n == this.node){ break; }
try{
n = n.parentNode;
}catch(x){
n = null;
}
}
if(!n){
this._changeState("Container", "Over");
this.onOverEvent();
}
n = this._getChildByEvent(e);
if(this.current == n){ return; }
if(this.current){ this._removeItemClass(this.current, "Over"); }
if(n){ this._addItemClass(n, "Over"); }
this.current = n;
},
onMouseOut: function(e){
// summary:
// event processor for onmouseout
// e: Event
// mouse event
for(var n = e.relatedTarget; n;){
if(n == this.node){ return; }
try{
n = n.parentNode;
}catch(x){
n = null;
}
}
if(this.current){
this._removeItemClass(this.current, "Over");
this.current = null;
}
this._changeState("Container", "");
this.onOutEvent();
},
onSelectStart: function(e){
// summary:
// event processor for onselectevent and ondragevent
// e: Event
// mouse event
if(!this.skipForm || !dnd.isFormElement(e)){
event.stop(e);
}
},
// utilities
onOverEvent: function(){
// summary:
// this function is called once, when mouse is over our container
},
onOutEvent: function(){
// summary:
// this function is called once, when mouse is out of our container
},
_changeState: function(type, newState){
// summary:
// changes a named state to new state value
// type: String
// a name of the state to change
// newState: String
// new state
var prefix = "dojoDnd" + type;
var state = type.toLowerCase() + "State";
//domClass.replace(this.node, prefix + newState, prefix + this[state]);
domClass.replace(this.node, prefix + newState, prefix + this[state]);
this[state] = newState;
},
_addItemClass: function(node, type){
// summary:
// adds a class with prefix "dojoDndItem"
// node: Node
// a node
// type: String
// a variable suffix for a class name
domClass.add(node, "dojoDndItem" + type);
},
_removeItemClass: function(node, type){
// summary:
// removes a class with prefix "dojoDndItem"
// node: Node
// a node
// type: String
// a variable suffix for a class name
domClass.remove(node, "dojoDndItem" + type);
},
_getChildByEvent: function(e){
// summary:
// gets a child, which is under the mouse at the moment, or null
// e: Event
// a mouse event
var node = e.target;
if(node){
for(var parent = node.parentNode; parent; node = parent, parent = node.parentNode){
if((parent == this.parent || this.allowNested) && domClass.contains(node, "dojoDndItem")){ return node; }
}
}
return null;
},
_normalizedCreator: function(/*Container.Item*/ item, /*String*/ hint){
// summary:
// adds all necessary data to the output of the user-supplied creator function
var t = (this.creator || this.defaultCreator).call(this, item, hint);
if(!lang.isArray(t.type)){ t.type = ["text"]; }
if(!t.node.id){ t.node.id = dnd.getUniqueId(); }
domClass.add(t.node, "dojoDndItem");
return t;
}
});
dnd._createNode = function(tag){
// summary:
// returns a function, which creates an element of given tag
// (SPAN by default) and sets its innerHTML to given text
// tag: String
// a tag name or empty for SPAN
if(!tag){ return dnd._createSpan; }
return function(text){ // Function
return domConstruct.create(tag, {innerHTML: text}); // Node
};
};
dnd._createTrTd = function(text){
// summary:
// creates a TR/TD structure with given text as an innerHTML of TD
// text: String
// a text for TD
var tr = domConstruct.create("tr");
domConstruct.create("td", {innerHTML: text}, tr);
return tr; // Node
};
dnd._createSpan = function(text){
// summary:
// creates a SPAN element with given text as its innerHTML
// text: String
// a text for SPAN
return domConstruct.create("span", {innerHTML: text}); // Node
};
// dnd._defaultCreatorNodes: Object
// a dictionary that maps container tag names to child tag names
dnd._defaultCreatorNodes = {ul: "li", ol: "li", div: "div", p: "div"};
dnd._defaultCreator = function(node){
// summary:
// takes a parent node, and returns an appropriate creator function
// node: Node
// a container node
var tag = node.tagName.toLowerCase();
var c = tag == "tbody" || tag == "thead" ? dnd._createTrTd :
dnd._createNode(dnd._defaultCreatorNodes[tag]);
return function(item, hint){ // Function
var isObj = item && lang.isObject(item), data, type, n;
if(isObj && item.tagName && item.nodeType && item.getAttribute){
// process a DOM node
data = item.getAttribute("dndData") || item.innerHTML;
type = item.getAttribute("dndType");
type = type ? type.split(/\s*,\s*/) : ["text"];
n = item; // this node is going to be moved rather than copied
}else{
// process a DnD item object or a string
data = (isObj && item.data) ? item.data : item;
type = (isObj && item.type) ? item.type : ["text"];
n = (hint == "avatar" ? dnd._createSpan : c)(String(data));
}
if(!n.id){
n.id = dnd.getUniqueId();
}
return {node: n, data: data, type: type};
};
};
/*=====
Container.__ContainerArgs = declare([], {
creator: function(){
// summary:
// a creator function, which takes a data item, and returns an object like that:
// {node: newNode, data: usedData, type: arrayOfStrings}
},
// skipForm: Boolean
// don't start the drag operation, if clicked on form elements
skipForm: false,
// dropParent: Node||String
// node or node's id to use as the parent node for dropped items
// (must be underneath the 'node' parameter in the DOM)
dropParent: null,
// _skipStartup: Boolean
// skip startup(), which collects children, for deferred initialization
// (this is used in the markup mode)
_skipStartup: false
});
Container.Item = function(){
// summary:
// Represents (one of) the source node(s) being dragged.
// Contains (at least) the "type" and "data" attributes.
// type: String[]
// Type(s) of this item, by default this is ["text"]
// data: Object
// Logical representation of the object being dragged.
// If the drag object's type is "text" then data is a String,
// if it's another type then data could be a different Object,
// perhaps a name/value hash.
this.type = type;
this.data = data;
};
=====*/
return Container;
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/Manager",["../main","../Evented","./common","./autoscroll","./Avatar"],function(_1,_2){var _3=_1.declare("dojo.dnd.Manager",[_2],{constructor:function(){this.avatar=null;this.source=null;this.nodes=[];this.copy=true;this.target=null;this.canDropFlag=false;this.events=[];},OFFSET_X:16,OFFSET_Y:16,overSource:function(_4){if(this.avatar){this.target=(_4&&_4.targetState!="Disabled")?_4:null;this.canDropFlag=Boolean(this.target);this.avatar.update();}_1.publish("/dnd/source/over",[_4]);},outSource:function(_5){if(this.avatar){if(this.target==_5){this.target=null;this.canDropFlag=false;this.avatar.update();_1.publish("/dnd/source/over",[null]);}}else{_1.publish("/dnd/source/over",[null]);}},startDrag:function(_6,_7,_8){this.source=_6;this.nodes=_7;this.copy=Boolean(_8);this.avatar=this.makeAvatar();_1.body().appendChild(this.avatar.node);_1.publish("/dnd/start",[_6,_7,this.copy]);this.events=[_1.connect(_1.doc,"onmousemove",this,"onMouseMove"),_1.connect(_1.doc,"onmouseup",this,"onMouseUp"),_1.connect(_1.doc,"onkeydown",this,"onKeyDown"),_1.connect(_1.doc,"onkeyup",this,"onKeyUp"),_1.connect(_1.doc,"ondragstart",_1.stopEvent),_1.connect(_1.body(),"onselectstart",_1.stopEvent)];var c="dojoDnd"+(_8?"Copy":"Move");_1.addClass(_1.body(),c);},canDrop:function(_9){var _a=Boolean(this.target&&_9);if(this.canDropFlag!=_a){this.canDropFlag=_a;this.avatar.update();}},stopDrag:function(){_1.removeClass(_1.body(),["dojoDndCopy","dojoDndMove"]);_1.forEach(this.events,_1.disconnect);this.events=[];this.avatar.destroy();this.avatar=null;this.source=this.target=null;this.nodes=[];},makeAvatar:function(){return new _1.dnd.Avatar(this);},updateAvatar:function(){this.avatar.update();},onMouseMove:function(e){var a=this.avatar;if(a){_1.dnd.autoScrollNodes(e);var s=a.node.style;s.left=(e.pageX+this.OFFSET_X)+"px";s.top=(e.pageY+this.OFFSET_Y)+"px";var _b=Boolean(this.source.copyState(_1.isCopyKey(e)));if(this.copy!=_b){this._setCopyStatus(_b);}}},onMouseUp:function(e){if(this.avatar){if(this.target&&this.canDropFlag){var _c=Boolean(this.source.copyState(_1.isCopyKey(e))),_d=[this.source,this.nodes,_c,this.target,e];_1.publish("/dnd/drop/before",_d);_1.publish("/dnd/drop",_d);}else{_1.publish("/dnd/cancel");}this.stopDrag();}},onKeyDown:function(e){if(this.avatar){switch(e.keyCode){case _1.keys.CTRL:var _e=Boolean(this.source.copyState(true));if(this.copy!=_e){this._setCopyStatus(_e);}break;case _1.keys.ESCAPE:_1.publish("/dnd/cancel");this.stopDrag();break;}}},onKeyUp:function(e){if(this.avatar&&e.keyCode==_1.keys.CTRL){var _f=Boolean(this.source.copyState(false));if(this.copy!=_f){this._setCopyStatus(_f);}}},_setCopyStatus:function(_10){this.copy=_10;this.source._markDndStatus(this.copy);this.updateAvatar();_1.replaceClass(_1.body(),"dojoDnd"+(this.copy?"Copy":"Move"),"dojoDnd"+(this.copy?"Move":"Copy"));}});_1.dnd._manager=null;_3.manager=_1.dnd.manager=function(){if(!_1.dnd._manager){_1.dnd._manager=new _1.dnd.Manager();}return _1.dnd._manager;};return _3;});
define("dojo/dnd/Manager",["../_base/array","../_base/declare","../_base/event","../_base/lang","../_base/window","../dom-class","../Evented","../has","../keys","../on","../topic","../touch","./common","./autoscroll","./Avatar"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,on,_a,_b,_c,_d,_e){var _f=_2("dojo.dnd.Manager",[_7],{constructor:function(){this.avatar=null;this.source=null;this.nodes=[];this.copy=true;this.target=null;this.canDropFlag=false;this.events=[];},OFFSET_X:_8("touch")?0:16,OFFSET_Y:_8("touch")?-64:16,overSource:function(_10){if(this.avatar){this.target=(_10&&_10.targetState!="Disabled")?_10:null;this.canDropFlag=Boolean(this.target);this.avatar.update();}_a.publish("/dnd/source/over",_10);},outSource:function(_11){if(this.avatar){if(this.target==_11){this.target=null;this.canDropFlag=false;this.avatar.update();_a.publish("/dnd/source/over",null);}}else{_a.publish("/dnd/source/over",null);}},startDrag:function(_12,_13,_14){_d.autoScrollStart(_5.doc);this.source=_12;this.nodes=_13;this.copy=Boolean(_14);this.avatar=this.makeAvatar();_5.body().appendChild(this.avatar.node);_a.publish("/dnd/start",_12,_13,this.copy);this.events=[on(_5.doc,_b.move,_4.hitch(this,"onMouseMove")),on(_5.doc,_b.release,_4.hitch(this,"onMouseUp")),on(_5.doc,"keydown",_4.hitch(this,"onKeyDown")),on(_5.doc,"keyup",_4.hitch(this,"onKeyUp")),on(_5.doc,"dragstart",_3.stop),on(_5.body(),"selectstart",_3.stop)];var c="dojoDnd"+(_14?"Copy":"Move");_6.add(_5.body(),c);},canDrop:function(_15){var _16=Boolean(this.target&&_15);if(this.canDropFlag!=_16){this.canDropFlag=_16;this.avatar.update();}},stopDrag:function(){_6.remove(_5.body(),["dojoDndCopy","dojoDndMove"]);_1.forEach(this.events,function(_17){_17.remove();});this.events=[];this.avatar.destroy();this.avatar=null;this.source=this.target=null;this.nodes=[];},makeAvatar:function(){return new _e(this);},updateAvatar:function(){this.avatar.update();},onMouseMove:function(e){var a=this.avatar;if(a){_d.autoScrollNodes(e);var s=a.node.style;s.left=(e.pageX+this.OFFSET_X)+"px";s.top=(e.pageY+this.OFFSET_Y)+"px";var _18=Boolean(this.source.copyState(_c.getCopyKeyState(e)));if(this.copy!=_18){this._setCopyStatus(_18);}}if(_8("touch")){e.preventDefault();}},onMouseUp:function(e){if(this.avatar){if(this.target&&this.canDropFlag){var _19=Boolean(this.source.copyState(_c.getCopyKeyState(e)));_a.publish("/dnd/drop/before",this.source,this.nodes,_19,this.target,e);_a.publish("/dnd/drop",this.source,this.nodes,_19,this.target,e);}else{_a.publish("/dnd/cancel");}this.stopDrag();}},onKeyDown:function(e){if(this.avatar){switch(e.keyCode){case _9.CTRL:var _1a=Boolean(this.source.copyState(true));if(this.copy!=_1a){this._setCopyStatus(_1a);}break;case _9.ESCAPE:_a.publish("/dnd/cancel");this.stopDrag();break;}}},onKeyUp:function(e){if(this.avatar&&e.keyCode==_9.CTRL){var _1b=Boolean(this.source.copyState(false));if(this.copy!=_1b){this._setCopyStatus(_1b);}}},_setCopyStatus:function(_1c){this.copy=_1c;this.source._markDndStatus(this.copy);this.updateAvatar();_6.replace(_5.body(),"dojoDnd"+(this.copy?"Copy":"Move"),"dojoDnd"+(this.copy?"Move":"Copy"));}});_c._manager=null;_f.manager=_c.manager=function(){if(!_c._manager){_c._manager=new _f();}return _c._manager;};return _f;});
+223
View File
@@ -0,0 +1,223 @@
define("dojo/dnd/Manager", [
"../_base/array", "../_base/declare", "../_base/event", "../_base/lang", "../_base/window",
"../dom-class", "../Evented", "../has", "../keys", "../on", "../topic", "../touch",
"./common", "./autoscroll", "./Avatar"
], function(array, declare, event, lang, win, domClass, Evented, has, keys, on, topic, touch,
dnd, autoscroll, Avatar){
// module:
// dojo/dnd/Manager
var Manager = declare("dojo.dnd.Manager", [Evented], {
// summary:
// the manager of DnD operations (usually a singleton)
constructor: function(){
this.avatar = null;
this.source = null;
this.nodes = [];
this.copy = true;
this.target = null;
this.canDropFlag = false;
this.events = [];
},
// avatar's offset from the mouse
OFFSET_X: has("touch") ? 0 : 16,
OFFSET_Y: has("touch") ? -64 : 16,
// methods
overSource: function(source){
// summary:
// called when a source detected a mouse-over condition
// source: Object
// the reporter
if(this.avatar){
this.target = (source && source.targetState != "Disabled") ? source : null;
this.canDropFlag = Boolean(this.target);
this.avatar.update();
}
topic.publish("/dnd/source/over", source);
},
outSource: function(source){
// summary:
// called when a source detected a mouse-out condition
// source: Object
// the reporter
if(this.avatar){
if(this.target == source){
this.target = null;
this.canDropFlag = false;
this.avatar.update();
topic.publish("/dnd/source/over", null);
}
}else{
topic.publish("/dnd/source/over", null);
}
},
startDrag: function(source, nodes, copy){
// summary:
// called to initiate the DnD operation
// source: Object
// the source which provides items
// nodes: Array
// the list of transferred items
// copy: Boolean
// copy items, if true, move items otherwise
// Tell autoscroll that a drag is starting
autoscroll.autoScrollStart(win.doc);
this.source = source;
this.nodes = nodes;
this.copy = Boolean(copy); // normalizing to true boolean
this.avatar = this.makeAvatar();
win.body().appendChild(this.avatar.node);
topic.publish("/dnd/start", source, nodes, this.copy);
this.events = [
on(win.doc, touch.move, lang.hitch(this, "onMouseMove")),
on(win.doc, touch.release, lang.hitch(this, "onMouseUp")),
on(win.doc, "keydown", lang.hitch(this, "onKeyDown")),
on(win.doc, "keyup", lang.hitch(this, "onKeyUp")),
// cancel text selection and text dragging
on(win.doc, "dragstart", event.stop),
on(win.body(), "selectstart", event.stop)
];
var c = "dojoDnd" + (copy ? "Copy" : "Move");
domClass.add(win.body(), c);
},
canDrop: function(flag){
// summary:
// called to notify if the current target can accept items
var canDropFlag = Boolean(this.target && flag);
if(this.canDropFlag != canDropFlag){
this.canDropFlag = canDropFlag;
this.avatar.update();
}
},
stopDrag: function(){
// summary:
// stop the DnD in progress
domClass.remove(win.body(), ["dojoDndCopy", "dojoDndMove"]);
array.forEach(this.events, function(handle){ handle.remove(); });
this.events = [];
this.avatar.destroy();
this.avatar = null;
this.source = this.target = null;
this.nodes = [];
},
makeAvatar: function(){
// summary:
// makes the avatar; it is separate to be overwritten dynamically, if needed
return new Avatar(this);
},
updateAvatar: function(){
// summary:
// updates the avatar; it is separate to be overwritten dynamically, if needed
this.avatar.update();
},
// mouse event processors
onMouseMove: function(e){
// summary:
// event processor for onmousemove
// e: Event
// mouse event
var a = this.avatar;
if(a){
autoscroll.autoScrollNodes(e);
//autoscroll.autoScroll(e);
var s = a.node.style;
s.left = (e.pageX + this.OFFSET_X) + "px";
s.top = (e.pageY + this.OFFSET_Y) + "px";
var copy = Boolean(this.source.copyState(dnd.getCopyKeyState(e)));
if(this.copy != copy){
this._setCopyStatus(copy);
}
}
if(has("touch")){
// Prevent page from scrolling so that user can drag instead.
e.preventDefault();
}
},
onMouseUp: function(e){
// summary:
// event processor for onmouseup
// e: Event
// mouse event
if(this.avatar){
if(this.target && this.canDropFlag){
var copy = Boolean(this.source.copyState(dnd.getCopyKeyState(e)));
topic.publish("/dnd/drop/before", this.source, this.nodes, copy, this.target, e);
topic.publish("/dnd/drop", this.source, this.nodes, copy, this.target, e);
}else{
topic.publish("/dnd/cancel");
}
this.stopDrag();
}
},
// keyboard event processors
onKeyDown: function(e){
// summary:
// event processor for onkeydown:
// watching for CTRL for copy/move status, watching for ESCAPE to cancel the drag
// e: Event
// keyboard event
if(this.avatar){
switch(e.keyCode){
case keys.CTRL:
var copy = Boolean(this.source.copyState(true));
if(this.copy != copy){
this._setCopyStatus(copy);
}
break;
case keys.ESCAPE:
topic.publish("/dnd/cancel");
this.stopDrag();
break;
}
}
},
onKeyUp: function(e){
// summary:
// event processor for onkeyup, watching for CTRL for copy/move status
// e: Event
// keyboard event
if(this.avatar && e.keyCode == keys.CTRL){
var copy = Boolean(this.source.copyState(false));
if(this.copy != copy){
this._setCopyStatus(copy);
}
}
},
// utilities
_setCopyStatus: function(copy){
// summary:
// changes the copy status
// copy: Boolean
// the copy status
this.copy = copy;
this.source._markDndStatus(this.copy);
this.updateAvatar();
domClass.replace(win.body(),
"dojoDnd" + (this.copy ? "Copy" : "Move"),
"dojoDnd" + (this.copy ? "Move" : "Copy"));
}
});
// dnd._manager:
// The manager singleton variable. Can be overwritten if needed.
dnd._manager = null;
Manager.manager = dnd.manager = function(){
// summary:
// Returns the current DnD manager. Creates one if it is not created yet.
if(!dnd._manager){
dnd._manager = new Manager();
}
return dnd._manager; // Object
};
return Manager;
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/Moveable",["../main","../Evented","../touch","./Mover"],function(_1,_2,_3){_1.declare("dojo.dnd.Moveable",[_2],{handle:"",delay:0,skip:false,constructor:function(_4,_5){this.node=_1.byId(_4);if(!_5){_5={};}this.handle=_5.handle?_1.byId(_5.handle):null;if(!this.handle){this.handle=this.node;}this.delay=_5.delay>0?_5.delay:0;this.skip=_5.skip;this.mover=_5.mover?_5.mover:_1.dnd.Mover;this.events=[_1.connect(this.handle,_3.press,this,"onMouseDown"),_1.connect(this.handle,"ondragstart",this,"onSelectStart"),_1.connect(this.handle,"onselectstart",this,"onSelectStart")];},markupFactory:function(_6,_7,_8){return new _8(_7,_6);},destroy:function(){_1.forEach(this.events,_1.disconnect);this.events=this.node=this.handle=null;},onMouseDown:function(e){if(this.skip&&_1.dnd.isFormElement(e)){return;}if(this.delay){this.events.push(_1.connect(this.handle,_3.move,this,"onMouseMove"),_1.connect(this.handle,_3.release,this,"onMouseUp"));this._lastX=e.pageX;this._lastY=e.pageY;}else{this.onDragDetected(e);}_1.stopEvent(e);},onMouseMove:function(e){if(Math.abs(e.pageX-this._lastX)>this.delay||Math.abs(e.pageY-this._lastY)>this.delay){this.onMouseUp(e);this.onDragDetected(e);}_1.stopEvent(e);},onMouseUp:function(e){for(var i=0;i<2;++i){_1.disconnect(this.events.pop());}_1.stopEvent(e);},onSelectStart:function(e){if(!this.skip||!_1.dnd.isFormElement(e)){_1.stopEvent(e);}},onDragDetected:function(e){new this.mover(this.node,e,this);},onMoveStart:function(_9){_1.publish("/dnd/move/start",[_9]);_1.addClass(_1.body(),"dojoMove");_1.addClass(this.node,"dojoMoveItem");},onMoveStop:function(_a){_1.publish("/dnd/move/stop",[_a]);_1.removeClass(_1.body(),"dojoMove");_1.removeClass(this.node,"dojoMoveItem");},onFirstMove:function(_b,e){},onMove:function(_c,_d,e){this.onMoving(_c,_d);var s=_c.node.style;s.left=_d.l+"px";s.top=_d.t+"px";this.onMoved(_c,_d);},onMoving:function(_e,_f){},onMoved:function(_10,_11){}});return _1.dnd.Moveable;});
define("dojo/dnd/Moveable",["../_base/array","../_base/declare","../_base/event","../_base/lang","../dom","../dom-class","../Evented","../on","../topic","../touch","./common","./Mover","../_base/window"],function(_1,_2,_3,_4,_5,_6,_7,on,_8,_9,_a,_b,_c){var _d=_2("dojo.dnd.Moveable",[_7],{handle:"",delay:0,skip:false,constructor:function(_e,_f){this.node=_5.byId(_e);if(!_f){_f={};}this.handle=_f.handle?_5.byId(_f.handle):null;if(!this.handle){this.handle=this.node;}this.delay=_f.delay>0?_f.delay:0;this.skip=_f.skip;this.mover=_f.mover?_f.mover:_b;this.events=[on(this.handle,_9.press,_4.hitch(this,"onMouseDown")),on(this.handle,"dragstart",_4.hitch(this,"onSelectStart")),on(this.handle,"selectstart",_4.hitch(this,"onSelectStart"))];},markupFactory:function(_10,_11,_12){return new _12(_11,_10);},destroy:function(){_1.forEach(this.events,function(_13){_13.remove();});this.events=this.node=this.handle=null;},onMouseDown:function(e){if(this.skip&&_a.isFormElement(e)){return;}if(this.delay){this.events.push(on(this.handle,_9.move,_4.hitch(this,"onMouseMove")),on(this.handle,_9.release,_4.hitch(this,"onMouseUp")));this._lastX=e.pageX;this._lastY=e.pageY;}else{this.onDragDetected(e);}_3.stop(e);},onMouseMove:function(e){if(Math.abs(e.pageX-this._lastX)>this.delay||Math.abs(e.pageY-this._lastY)>this.delay){this.onMouseUp(e);this.onDragDetected(e);}_3.stop(e);},onMouseUp:function(e){for(var i=0;i<2;++i){this.events.pop().remove();}_3.stop(e);},onSelectStart:function(e){if(!this.skip||!_a.isFormElement(e)){_3.stop(e);}},onDragDetected:function(e){new this.mover(this.node,e,this);},onMoveStart:function(_14){_8.publish("/dnd/move/start",_14);_6.add(_c.body(),"dojoMove");_6.add(this.node,"dojoMoveItem");},onMoveStop:function(_15){_8.publish("/dnd/move/stop",_15);_6.remove(_c.body(),"dojoMove");_6.remove(this.node,"dojoMoveItem");},onFirstMove:function(){},onMove:function(_16,_17){this.onMoving(_16,_17);var s=_16.node.style;s.left=_17.l+"px";s.top=_17.t+"px";this.onMoved(_16,_17);},onMoving:function(){},onMoved:function(){}});return _d;});
+185
View File
@@ -0,0 +1,185 @@
define("dojo/dnd/Moveable", [
"../_base/array", "../_base/declare", "../_base/event", "../_base/lang",
"../dom", "../dom-class", "../Evented", "../on", "../topic", "../touch", "./common", "./Mover", "../_base/window"
], function(array, declare, event, lang, dom, domClass, Evented, on, topic, touch, dnd, Mover, win){
// module:
// dojo/dnd/Moveable
var Moveable = declare("dojo.dnd.Moveable", [Evented], {
// summary:
// an object, which makes a node movable
// object attributes (for markup)
handle: "",
delay: 0,
skip: false,
constructor: function(node, params){
// node: Node
// a node (or node's id) to be moved
// params: Moveable.__MoveableArgs?
// optional parameters
this.node = dom.byId(node);
if(!params){ params = {}; }
this.handle = params.handle ? dom.byId(params.handle) : null;
if(!this.handle){ this.handle = this.node; }
this.delay = params.delay > 0 ? params.delay : 0;
this.skip = params.skip;
this.mover = params.mover ? params.mover : Mover;
this.events = [
on(this.handle, touch.press, lang.hitch(this, "onMouseDown")),
// cancel text selection and text dragging
on(this.handle, "dragstart", lang.hitch(this, "onSelectStart")),
on(this.handle, "selectstart", lang.hitch(this, "onSelectStart"))
];
},
// markup methods
markupFactory: function(params, node, Ctor){
return new Ctor(node, params);
},
// methods
destroy: function(){
// summary:
// stops watching for possible move, deletes all references, so the object can be garbage-collected
array.forEach(this.events, function(handle){ handle.remove(); });
this.events = this.node = this.handle = null;
},
// mouse event processors
onMouseDown: function(e){
// summary:
// event processor for onmousedown/ontouchstart, creates a Mover for the node
// e: Event
// mouse/touch event
if(this.skip && dnd.isFormElement(e)){ return; }
if(this.delay){
this.events.push(
on(this.handle, touch.move, lang.hitch(this, "onMouseMove")),
on(this.handle, touch.release, lang.hitch(this, "onMouseUp"))
);
this._lastX = e.pageX;
this._lastY = e.pageY;
}else{
this.onDragDetected(e);
}
event.stop(e);
},
onMouseMove: function(e){
// summary:
// event processor for onmousemove/ontouchmove, used only for delayed drags
// e: Event
// mouse/touch event
if(Math.abs(e.pageX - this._lastX) > this.delay || Math.abs(e.pageY - this._lastY) > this.delay){
this.onMouseUp(e);
this.onDragDetected(e);
}
event.stop(e);
},
onMouseUp: function(e){
// summary:
// event processor for onmouseup, used only for delayed drags
// e: Event
// mouse event
for(var i = 0; i < 2; ++i){
this.events.pop().remove();
}
event.stop(e);
},
onSelectStart: function(e){
// summary:
// event processor for onselectevent and ondragevent
// e: Event
// mouse event
if(!this.skip || !dnd.isFormElement(e)){
event.stop(e);
}
},
// local events
onDragDetected: function(/*Event*/ e){
// summary:
// called when the drag is detected;
// responsible for creation of the mover
new this.mover(this.node, e, this);
},
onMoveStart: function(/*Mover*/ mover){
// summary:
// called before every move operation
topic.publish("/dnd/move/start", mover);
domClass.add(win.body(), "dojoMove");
domClass.add(this.node, "dojoMoveItem");
},
onMoveStop: function(/*Mover*/ mover){
// summary:
// called after every move operation
topic.publish("/dnd/move/stop", mover);
domClass.remove(win.body(), "dojoMove");
domClass.remove(this.node, "dojoMoveItem");
},
onFirstMove: function(/*===== mover, e =====*/){
// summary:
// called during the very first move notification;
// can be used to initialize coordinates, can be overwritten.
// mover: Mover
// e: Event
// default implementation does nothing
},
onMove: function(mover, leftTop /*=====, e =====*/){
// summary:
// called during every move notification;
// should actually move the node; can be overwritten.
// mover: Mover
// leftTop: Object
// e: Event
this.onMoving(mover, leftTop);
var s = mover.node.style;
s.left = leftTop.l + "px";
s.top = leftTop.t + "px";
this.onMoved(mover, leftTop);
},
onMoving: function(/*===== mover, leftTop =====*/){
// summary:
// called before every incremental move; can be overwritten.
// mover: Mover
// leftTop: Object
// default implementation does nothing
},
onMoved: function(/*===== mover, leftTop =====*/){
// summary:
// called after every incremental move; can be overwritten.
// mover: Mover
// leftTop: Object
// default implementation does nothing
}
});
/*=====
Moveable.__MoveableArgs = declare([], {
// handle: Node||String
// A node (or node's id), which is used as a mouse handle.
// If omitted, the node itself is used as a handle.
handle: null,
// delay: Number
// delay move by this number of pixels
delay: 0,
// skip: Boolean
// skip move of form elements
skip: false,
// mover: Object
// a constructor of custom Mover
mover: dnd.Mover
});
=====*/
return Moveable;
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/Mover",["../main","../Evented","../touch","./common","./autoscroll"],function(_1,_2,_3){_1.declare("dojo.dnd.Mover",[_2],{constructor:function(_4,e,_5){this.node=_1.byId(_4);this.marginBox={l:e.pageX,t:e.pageY};this.mouseButton=e.button;var h=(this.host=_5),d=_4.ownerDocument;this.events=[_1.connect(d,_3.move,this,"onFirstMove"),_1.connect(d,_3.move,this,"onMouseMove"),_1.connect(d,_3.release,this,"onMouseUp"),_1.connect(d,"ondragstart",_1.stopEvent),_1.connect(d.body,"onselectstart",_1.stopEvent)];if(h&&h.onMoveStart){h.onMoveStart(this);}},onMouseMove:function(e){_1.dnd.autoScroll(e);var m=this.marginBox;this.host.onMove(this,{l:m.l+e.pageX,t:m.t+e.pageY},e);_1.stopEvent(e);},onMouseUp:function(e){if(_1.isWebKit&&_1.isMac&&this.mouseButton==2?e.button==0:this.mouseButton==e.button){this.destroy();}_1.stopEvent(e);},onFirstMove:function(e){var s=this.node.style,l,t,h=this.host;switch(s.position){case "relative":case "absolute":l=Math.round(parseFloat(s.left))||0;t=Math.round(parseFloat(s.top))||0;break;default:s.position="absolute";var m=_1.marginBox(this.node);var b=_1.doc.body;var bs=_1.getComputedStyle(b);var bm=_1._getMarginBox(b,bs);var bc=_1._getContentBox(b,bs);l=m.l-(bc.l-bm.l);t=m.t-(bc.t-bm.t);break;}this.marginBox.l=l-this.marginBox.l;this.marginBox.t=t-this.marginBox.t;if(h&&h.onFirstMove){h.onFirstMove(this,e);}_1.disconnect(this.events.shift());},destroy:function(){_1.forEach(this.events,_1.disconnect);var h=this.host;if(h&&h.onMoveStop){h.onMoveStop(this);}this.events=this.node=this.host=null;}});return _1.dnd.Mover;});
define("dojo/dnd/Mover",["../_base/array","../_base/declare","../_base/event","../_base/lang","../sniff","../_base/window","../dom","../dom-geometry","../dom-style","../Evented","../on","../touch","./common","./autoscroll"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,on,_b,_c,_d){return _2("dojo.dnd.Mover",[_a],{constructor:function(_e,e,_f){this.node=_7.byId(_e);this.marginBox={l:e.pageX,t:e.pageY};this.mouseButton=e.button;var h=(this.host=_f),d=_e.ownerDocument;this.events=[on(d,_b.move,_4.hitch(this,"onFirstMove")),on(d,_b.move,_4.hitch(this,"onMouseMove")),on(d,_b.release,_4.hitch(this,"onMouseUp")),on(d,"dragstart",_3.stop),on(d.body,"selectstart",_3.stop)];_d.autoScrollStart(d);if(h&&h.onMoveStart){h.onMoveStart(this);}},onMouseMove:function(e){_d.autoScroll(e);var m=this.marginBox;this.host.onMove(this,{l:m.l+e.pageX,t:m.t+e.pageY},e);_3.stop(e);},onMouseUp:function(e){if(_5("webkit")&&_5("mac")&&this.mouseButton==2?e.button==0:this.mouseButton==e.button){this.destroy();}_3.stop(e);},onFirstMove:function(e){var s=this.node.style,l,t,h=this.host;switch(s.position){case "relative":case "absolute":l=Math.round(parseFloat(s.left))||0;t=Math.round(parseFloat(s.top))||0;break;default:s.position="absolute";var m=_8.getMarginBox(this.node);var b=_6.doc.body;var bs=_9.getComputedStyle(b);var bm=_8.getMarginBox(b,bs);var bc=_8.getContentBox(b,bs);l=m.l-(bc.l-bm.l);t=m.t-(bc.t-bm.t);break;}this.marginBox.l=l-this.marginBox.l;this.marginBox.t=t-this.marginBox.t;if(h&&h.onFirstMove){h.onFirstMove(this,e);}this.events.shift().remove();},destroy:function(){_1.forEach(this.events,function(_10){_10.remove();});var h=this.host;if(h&&h.onMoveStop){h.onMoveStop(this);}this.events=this.node=this.host=null;}});});
+124
View File
@@ -0,0 +1,124 @@
define("dojo/dnd/Mover", [
"../_base/array", "../_base/declare", "../_base/event", "../_base/lang", "../sniff", "../_base/window",
"../dom", "../dom-geometry", "../dom-style", "../Evented", "../on", "../touch", "./common", "./autoscroll"
], function(array, declare, event, lang, has, win, dom, domGeom, domStyle, Evented, on, touch, dnd, autoscroll){
// module:
// dojo/dnd/Mover
return declare("dojo.dnd.Mover", [Evented], {
// summary:
// an object which makes a node follow the mouse, or touch-drag on touch devices.
// Used as a default mover, and as a base class for custom movers.
constructor: function(node, e, host){
// node: Node
// a node (or node's id) to be moved
// e: Event
// a mouse event, which started the move;
// only pageX and pageY properties are used
// host: Object?
// object which implements the functionality of the move,
// and defines proper events (onMoveStart and onMoveStop)
this.node = dom.byId(node);
this.marginBox = {l: e.pageX, t: e.pageY};
this.mouseButton = e.button;
var h = (this.host = host), d = node.ownerDocument;
this.events = [
// At the start of a drag, onFirstMove is called, and then the following
// listener is disconnected.
on(d, touch.move, lang.hitch(this, "onFirstMove")),
// These are called continually during the drag
on(d, touch.move, lang.hitch(this, "onMouseMove")),
// And these are called at the end of the drag
on(d, touch.release, lang.hitch(this, "onMouseUp")),
// cancel text selection and text dragging
on(d, "dragstart", event.stop),
on(d.body, "selectstart", event.stop)
];
// Tell autoscroll that a drag is starting
autoscroll.autoScrollStart(d);
// notify that the move has started
if(h && h.onMoveStart){
h.onMoveStart(this);
}
},
// mouse event processors
onMouseMove: function(e){
// summary:
// event processor for onmousemove/ontouchmove
// e: Event
// mouse/touch event
autoscroll.autoScroll(e);
var m = this.marginBox;
this.host.onMove(this, {l: m.l + e.pageX, t: m.t + e.pageY}, e);
event.stop(e);
},
onMouseUp: function(e){
if(has("webkit") && has("mac") && this.mouseButton == 2 ?
e.button == 0 : this.mouseButton == e.button){ // TODO Should condition be met for touch devices, too?
this.destroy();
}
event.stop(e);
},
// utilities
onFirstMove: function(e){
// summary:
// makes the node absolute; it is meant to be called only once.
// relative and absolutely positioned nodes are assumed to use pixel units
var s = this.node.style, l, t, h = this.host;
switch(s.position){
case "relative":
case "absolute":
// assume that left and top values are in pixels already
l = Math.round(parseFloat(s.left)) || 0;
t = Math.round(parseFloat(s.top)) || 0;
break;
default:
s.position = "absolute"; // enforcing the absolute mode
var m = domGeom.getMarginBox(this.node);
// event.pageX/pageY (which we used to generate the initial
// margin box) includes padding and margin set on the body.
// However, setting the node's position to absolute and then
// doing domGeom.marginBox on it *doesn't* take that additional
// space into account - so we need to subtract the combined
// padding and margin. We use getComputedStyle and
// _getMarginBox/_getContentBox to avoid the extra lookup of
// the computed style.
var b = win.doc.body;
var bs = domStyle.getComputedStyle(b);
var bm = domGeom.getMarginBox(b, bs);
var bc = domGeom.getContentBox(b, bs);
l = m.l - (bc.l - bm.l);
t = m.t - (bc.t - bm.t);
break;
}
this.marginBox.l = l - this.marginBox.l;
this.marginBox.t = t - this.marginBox.t;
if(h && h.onFirstMove){
h.onFirstMove(this, e);
}
// Disconnect touch.move that call this function
this.events.shift().remove();
},
destroy: function(){
// summary:
// stops the move, deletes all references, so the object can be garbage-collected
array.forEach(this.events, function(handle){ handle.remove(); });
// undo global settings
var h = this.host;
if(h && h.onMoveStop){
h.onMoveStop(this);
}
// destroy objects
this.events = this.node = this.host = null;
}
});
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/Selector",["../main","./common","./Container"],function(_1){_1.declare("dojo.dnd.Selector",_1.dnd.Container,{constructor:function(_2,_3){if(!_3){_3={};}this.singular=_3.singular;this.autoSync=_3.autoSync;this.selection={};this.anchor=null;this.simpleSelection=false;this.events.push(_1.connect(this.node,"onmousedown",this,"onMouseDown"),_1.connect(this.node,"onmouseup",this,"onMouseUp"));},singular:false,getSelectedNodes:function(){var t=new _1.NodeList();var e=_1.dnd._empty;for(var i in this.selection){if(i in e){continue;}t.push(_1.byId(i));}return t;},selectNone:function(){return this._removeSelection()._removeAnchor();},selectAll:function(){this.forInItems(function(_4,id){this._addItemClass(_1.byId(id),"Selected");this.selection[id]=1;},this);return this._removeAnchor();},deleteSelectedNodes:function(){var e=_1.dnd._empty;for(var i in this.selection){if(i in e){continue;}var n=_1.byId(i);this.delItem(i);_1.destroy(n);}this.anchor=null;this.selection={};return this;},forInSelectedItems:function(f,o){o=o||_1.global;var s=this.selection,e=_1.dnd._empty;for(var i in s){if(i in e){continue;}f.call(o,this.getItem(i),i,this);}},sync:function(){_1.dnd.Selector.superclass.sync.call(this);if(this.anchor){if(!this.getItem(this.anchor.id)){this.anchor=null;}}var t=[],e=_1.dnd._empty;for(var i in this.selection){if(i in e){continue;}if(!this.getItem(i)){t.push(i);}}_1.forEach(t,function(i){delete this.selection[i];},this);return this;},insertNodes:function(_5,_6,_7,_8){var _9=this._normalizedCreator;this._normalizedCreator=function(_a,_b){var t=_9.call(this,_a,_b);if(_5){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;};_1.dnd.Selector.superclass.insertNodes.call(this,_6,_7,_8);this._normalizedCreator=_9;return this;},destroy:function(){_1.dnd.Selector.superclass.destroy.call(this);this.selection=this.anchor=null;},onMouseDown:function(e){if(this.autoSync){this.sync();}if(!this.current){return;}if(!this.singular&&!_1.isCopyKey(e)&&!e.shiftKey&&(this.current.id in this.selection)){this.simpleSelection=true;if(e.button===_1.mouseButtons.LEFT){_1.stopEvent(e);}return;}if(!this.singular&&e.shiftKey){if(!_1.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<c.length;++i){var _c=c[i];if(_c==this.anchor||_c==this.current){break;}}for(++i;i<c.length;++i){var _c=c[i];if(_c==this.anchor||_c==this.current){break;}this._addItemClass(_c,"Selected");this.selection[_c.id]=1;}this._addItemClass(this.current,"Selected");this.selection[this.current.id]=1;}}}else{if(this.singular){if(this.anchor==this.current){if(_1.isCopyKey(e)){this.selectNone();}}else{this.selectNone();this.anchor=this.current;this._addItemClass(this.anchor,"Anchor");this.selection[this.current.id]=1;}}else{if(_1.isCopyKey(e)){if(this.anchor==this.current){delete this.selection[this.anchor.id];this._removeAnchor();}else{if(this.current.id in this.selection){this._removeItemClass(this.current,"Selected");delete this.selection[this.current.id];}else{if(this.anchor){this._removeItemClass(this.anchor,"Anchor");this._addItemClass(this.anchor,"Selected");}this.anchor=this.current;this._addItemClass(this.current,"Anchor");this.selection[this.current.id]=1;}}}else{if(!(this.current.id in this.selection)){this.selectNone();this.anchor=this.current;this._addItemClass(this.current,"Anchor");this.selection[this.current.id]=1;}}}}_1.stopEvent(e);},onMouseUp:function(e){if(!this.simpleSelection){return;}this.simpleSelection=false;this.selectNone();if(this.current){this.anchor=this.current;this._addItemClass(this.anchor,"Anchor");this.selection[this.current.id]=1;}},onMouseMove:function(e){this.simpleSelection=false;},onOverEvent:function(){this.onmousemoveEvent=_1.connect(this.node,"onmousemove",this,"onMouseMove");},onOutEvent:function(){_1.disconnect(this.onmousemoveEvent);delete this.onmousemoveEvent;},_removeSelection:function(){var e=_1.dnd._empty;for(var i in this.selection){if(i in e){continue;}var _d=_1.byId(i);if(_d){this._removeItemClass(_d,"Selected");}}this.selection={};return this;},_removeAnchor:function(){if(this.anchor){this._removeItemClass(this.anchor,"Anchor");this.anchor=null;}return this;}});return _1.dnd.Selector;});
define("dojo/dnd/Selector",["../_base/array","../_base/declare","../_base/event","../_base/kernel","../_base/lang","../dom","../dom-construct","../mouse","../_base/NodeList","../on","../touch","./common","./Container"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,on,_a,_b,_c){var _d=_2("dojo.dnd.Selector",_c,{constructor:function(_e,_f){if(!_f){_f={};}this.singular=_f.singular;this.autoSync=_f.autoSync;this.selection={};this.anchor=null;this.simpleSelection=false;this.events.push(on(this.node,_a.press,_5.hitch(this,"onMouseDown")),on(this.node,_a.release,_5.hitch(this,"onMouseUp")));},singular:false,getSelectedNodes:function(){var t=new _9();var e=_b._empty;for(var i in this.selection){if(i in e){continue;}t.push(_6.byId(i));}return t;},selectNone:function(){return this._removeSelection()._removeAnchor();},selectAll:function(){this.forInItems(function(_10,id){this._addItemClass(_6.byId(id),"Selected");this.selection[id]=1;},this);return this._removeAnchor();},deleteSelectedNodes:function(){var e=_b._empty;for(var i in this.selection){if(i in e){continue;}var n=_6.byId(i);this.delItem(i);_7.destroy(n);}this.anchor=null;this.selection={};return this;},forInSelectedItems:function(f,o){o=o||_4.global;var s=this.selection,e=_b._empty;for(var i in s){if(i in e){continue;}f.call(o,this.getItem(i),i,this);}},sync:function(){_d.superclass.sync.call(this);if(this.anchor){if(!this.getItem(this.anchor.id)){this.anchor=null;}}var t=[],e=_b._empty;for(var i in this.selection){if(i in e){continue;}if(!this.getItem(i)){t.push(i);}}_1.forEach(t,function(i){delete this.selection[i];},this);return this;},insertNodes:function(_11,_12,_13,_14){var _15=this._normalizedCreator;this._normalizedCreator=function(_16,_17){var t=_15.call(this,_16,_17);if(_11){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;};_d.superclass.insertNodes.call(this,_12,_13,_14);this._normalizedCreator=_15;return this;},destroy:function(){_d.superclass.destroy.call(this);this.selection=this.anchor=null;},onMouseDown:function(e){if(this.autoSync){this.sync();}if(!this.current){return;}if(!this.singular&&!_b.getCopyKeyState(e)&&!e.shiftKey&&(this.current.id in this.selection)){this.simpleSelection=true;if(_8.isLeft(e)){_3.stop(e);}return;}if(!this.singular&&e.shiftKey){if(!_b.getCopyKeyState(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,_18;for(;i<c.length;++i){_18=c[i];if(_18==this.anchor||_18==this.current){break;}}for(++i;i<c.length;++i){_18=c[i];if(_18==this.anchor||_18==this.current){break;}this._addItemClass(_18,"Selected");this.selection[_18.id]=1;}this._addItemClass(this.current,"Selected");this.selection[this.current.id]=1;}}}else{if(this.singular){if(this.anchor==this.current){if(_b.getCopyKeyState(e)){this.selectNone();}}else{this.selectNone();this.anchor=this.current;this._addItemClass(this.anchor,"Anchor");this.selection[this.current.id]=1;}}else{if(_b.getCopyKeyState(e)){if(this.anchor==this.current){delete this.selection[this.anchor.id];this._removeAnchor();}else{if(this.current.id in this.selection){this._removeItemClass(this.current,"Selected");delete this.selection[this.current.id];}else{if(this.anchor){this._removeItemClass(this.anchor,"Anchor");this._addItemClass(this.anchor,"Selected");}this.anchor=this.current;this._addItemClass(this.current,"Anchor");this.selection[this.current.id]=1;}}}else{if(!(this.current.id in this.selection)){this.selectNone();this.anchor=this.current;this._addItemClass(this.current,"Anchor");this.selection[this.current.id]=1;}}}}_3.stop(e);},onMouseUp:function(){if(!this.simpleSelection){return;}this.simpleSelection=false;this.selectNone();if(this.current){this.anchor=this.current;this._addItemClass(this.anchor,"Anchor");this.selection[this.current.id]=1;}},onMouseMove:function(){this.simpleSelection=false;},onOverEvent:function(){this.onmousemoveEvent=on(this.node,_a.move,_5.hitch(this,"onMouseMove"));},onOutEvent:function(){if(this.onmousemoveEvent){this.onmousemoveEvent.remove();delete this.onmousemoveEvent;}},_removeSelection:function(){var e=_b._empty;for(var i in this.selection){if(i in e){continue;}var _19=_6.byId(i);if(_19){this._removeItemClass(_19,"Selected");}}this.selection={};return this;},_removeAnchor:function(){if(this.anchor){this._removeItemClass(this.anchor,"Anchor");this.anchor=null;}return this;}});return _d;});
+331
View File
@@ -0,0 +1,331 @@
define("dojo/dnd/Selector", [
"../_base/array", "../_base/declare", "../_base/event", "../_base/kernel", "../_base/lang",
"../dom", "../dom-construct", "../mouse", "../_base/NodeList", "../on", "../touch", "./common", "./Container"
], function(array, declare, event, kernel, lang, dom, domConstruct, mouse, NodeList, on, touch, dnd, Container){
// module:
// dojo/dnd/Selector
/*
Container item states:
"" - an item is not selected
"Selected" - an item is selected
"Anchor" - an item is selected, and is an anchor for a "shift" selection
*/
/*=====
var __SelectorArgs = declare([Container.__ContainerArgs], {
// singular: Boolean
// allows selection of only one element, if true
singular: false,
// autoSync: Boolean
// autosynchronizes the source with its list of DnD nodes,
autoSync: false
});
=====*/
var Selector = declare("dojo.dnd.Selector", Container, {
// summary:
// a Selector object, which knows how to select its children
/*=====
// selection: Set<String>
// The set of id's that are currently selected, such that this.selection[id] == 1
// if the node w/that id is selected. Can iterate over selected node's id's like:
// | for(var id in this.selection)
selection: {},
=====*/
constructor: function(node, params){
// summary:
// constructor of the Selector
// node: Node||String
// node or node's id to build the selector on
// params: __SelectorArgs?
// a dictionary of parameters
if(!params){ params = {}; }
this.singular = params.singular;
this.autoSync = params.autoSync;
// class-specific variables
this.selection = {};
this.anchor = null;
this.simpleSelection = false;
// set up events
this.events.push(
on(this.node, touch.press, lang.hitch(this, "onMouseDown")),
on(this.node, touch.release, lang.hitch(this, "onMouseUp"))
);
},
// object attributes (for markup)
singular: false, // is singular property
// methods
getSelectedNodes: function(){
// summary:
// returns a list (an array) of selected nodes
var t = new NodeList();
var e = dnd._empty;
for(var i in this.selection){
if(i in e){ continue; }
t.push(dom.byId(i));
}
return t; // NodeList
},
selectNone: function(){
// summary:
// unselects all items
return this._removeSelection()._removeAnchor(); // self
},
selectAll: function(){
// summary:
// selects all items
this.forInItems(function(data, id){
this._addItemClass(dom.byId(id), "Selected");
this.selection[id] = 1;
}, this);
return this._removeAnchor(); // self
},
deleteSelectedNodes: function(){
// summary:
// deletes all selected items
var e = dnd._empty;
for(var i in this.selection){
if(i in e){ continue; }
var n = dom.byId(i);
this.delItem(i);
domConstruct.destroy(n);
}
this.anchor = null;
this.selection = {};
return this; // self
},
forInSelectedItems: function(/*Function*/ f, /*Object?*/ o){
// summary:
// iterates over selected items;
// see `dojo/dnd/Container.forInItems()` for details
o = o || kernel.global;
var s = this.selection, e = dnd._empty;
for(var i in s){
if(i in e){ continue; }
f.call(o, this.getItem(i), i, this);
}
},
sync: function(){
// summary:
// sync up the node list with the data map
Selector.superclass.sync.call(this);
// fix the anchor
if(this.anchor){
if(!this.getItem(this.anchor.id)){
this.anchor = null;
}
}
// fix the selection
var t = [], e = dnd._empty;
for(var i in this.selection){
if(i in e){ continue; }
if(!this.getItem(i)){
t.push(i);
}
}
array.forEach(t, function(i){
delete this.selection[i];
}, this);
return this; // self
},
insertNodes: function(addSelected, data, before, anchor){
// summary:
// inserts new data items (see `dojo/dnd/Container.insertNodes()` method for details)
// addSelected: Boolean
// all new nodes will be added to selected items, if true, no selection change otherwise
// data: Array
// a list of data items, which should be processed by the creator function
// before: Boolean
// insert before the anchor, if true, and after the anchor otherwise
// anchor: Node
// the anchor node to be used as a point of insertion
var oldCreator = this._normalizedCreator;
this._normalizedCreator = function(item, hint){
var t = oldCreator.call(this, item, hint);
if(addSelected){
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;
};
Selector.superclass.insertNodes.call(this, data, before, anchor);
this._normalizedCreator = oldCreator;
return this; // self
},
destroy: function(){
// summary:
// prepares the object to be garbage-collected
Selector.superclass.destroy.call(this);
this.selection = this.anchor = null;
},
// mouse events
onMouseDown: function(e){
// summary:
// event processor for onmousedown
// e: Event
// mouse event
if(this.autoSync){ this.sync(); }
if(!this.current){ return; }
if(!this.singular && !dnd.getCopyKeyState(e) && !e.shiftKey && (this.current.id in this.selection)){
this.simpleSelection = true;
if(mouse.isLeft(e)){
// Accept the left button and stop the event. Stopping the event prevents text selection while
// dragging. However, don't stop the event on mobile because that prevents a click event,
// and also prevents scroll (see #15838).
// For IE we don't stop event when multiple buttons are pressed.
event.stop(e);
}
return;
}
if(!this.singular && e.shiftKey){
if(!dnd.getCopyKeyState(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, node;
for(; i < c.length; ++i){
node = c[i];
if(node == this.anchor || node == this.current){ break; }
}
for(++i; i < c.length; ++i){
node = c[i];
if(node == this.anchor || node == this.current){ break; }
this._addItemClass(node, "Selected");
this.selection[node.id] = 1;
}
this._addItemClass(this.current, "Selected");
this.selection[this.current.id] = 1;
}
}
}else{
if(this.singular){
if(this.anchor == this.current){
if(dnd.getCopyKeyState(e)){
this.selectNone();
}
}else{
this.selectNone();
this.anchor = this.current;
this._addItemClass(this.anchor, "Anchor");
this.selection[this.current.id] = 1;
}
}else{
if(dnd.getCopyKeyState(e)){
if(this.anchor == this.current){
delete this.selection[this.anchor.id];
this._removeAnchor();
}else{
if(this.current.id in this.selection){
this._removeItemClass(this.current, "Selected");
delete this.selection[this.current.id];
}else{
if(this.anchor){
this._removeItemClass(this.anchor, "Anchor");
this._addItemClass(this.anchor, "Selected");
}
this.anchor = this.current;
this._addItemClass(this.current, "Anchor");
this.selection[this.current.id] = 1;
}
}
}else{
if(!(this.current.id in this.selection)){
this.selectNone();
this.anchor = this.current;
this._addItemClass(this.current, "Anchor");
this.selection[this.current.id] = 1;
}
}
}
}
event.stop(e);
},
onMouseUp: function(/*===== e =====*/){
// summary:
// event processor for onmouseup
// e: Event
// mouse event
if(!this.simpleSelection){ return; }
this.simpleSelection = false;
this.selectNone();
if(this.current){
this.anchor = this.current;
this._addItemClass(this.anchor, "Anchor");
this.selection[this.current.id] = 1;
}
},
onMouseMove: function(/*===== e =====*/){
// summary:
// event processor for onmousemove
// e: Event
// mouse event
this.simpleSelection = false;
},
// utilities
onOverEvent: function(){
// summary:
// this function is called once, when mouse is over our container
this.onmousemoveEvent = on(this.node, touch.move, lang.hitch(this, "onMouseMove"));
},
onOutEvent: function(){
// summary:
// this function is called once, when mouse is out of our container
if(this.onmousemoveEvent){
this.onmousemoveEvent.remove();
delete this.onmousemoveEvent;
}
},
_removeSelection: function(){
// summary:
// unselects all items
var e = dnd._empty;
for(var i in this.selection){
if(i in e){ continue; }
var node = dom.byId(i);
if(node){ this._removeItemClass(node, "Selected"); }
}
this.selection = {};
return this; // self
},
_removeAnchor: function(){
if(this.anchor){
this._removeItemClass(this.anchor, "Anchor");
this.anchor = null;
}
return this; // self
}
});
return Selector;
});
File diff suppressed because one or more lines are too long
+506
View File
@@ -0,0 +1,506 @@
define("dojo/dnd/Source", [
"../_base/array", "../_base/connect", "../_base/declare", "../_base/kernel", "../_base/lang",
"../dom-class", "../dom-geometry", "../mouse", "../ready", "../topic",
"./common", "./Selector", "./Manager"
], function(array, connect, declare, kernel, lang, domClass, domGeom, mouse, ready, topic,
dnd, Selector, Manager){
// module:
// dojo/dnd/Source
/*
Container property:
"Horizontal"- if this is the horizontal container
Source states:
"" - normal state
"Moved" - this source is being moved
"Copied" - this source is being copied
Target states:
"" - normal state
"Disabled" - the target cannot accept an avatar
Target anchor state:
"" - item is not selected
"Before" - insert point is before the anchor
"After" - insert point is after the anchor
*/
/*=====
var __SourceArgs = {
// summary:
// a dict of parameters for DnD Source configuration. Note that any
// property on Source elements may be configured, but this is the
// short-list
// isSource: Boolean?
// can be used as a DnD source. Defaults to true.
// accept: Array?
// list of accepted types (text strings) for a target; defaults to
// ["text"]
// autoSync: Boolean
// if true refreshes the node list on every operation; false by default
// copyOnly: Boolean?
// copy items, if true, use a state of Ctrl key otherwise,
// see selfCopy and selfAccept for more details
// delay: Number
// the move delay in pixels before detecting a drag; 0 by default
// horizontal: Boolean?
// a horizontal container, if true, vertical otherwise or when omitted
// selfCopy: Boolean?
// copy items by default when dropping on itself,
// false by default, works only if copyOnly is true
// selfAccept: Boolean?
// accept its own items when copyOnly is true,
// true by default, works only if copyOnly is true
// withHandles: Boolean?
// allows dragging only by handles, false by default
// generateText: Boolean?
// generate text node for drag and drop, true by default
};
=====*/
// For back-compat, remove in 2.0.
if(!kernel.isAsync){
ready(0, function(){
var requires = ["dojo/dnd/AutoSource", "dojo/dnd/Target"];
require(requires); // use indirection so modules not rolled into a build
});
}
var Source = declare("dojo.dnd.Source", Selector, {
// summary:
// a Source object, which can be used as a DnD source, or a DnD target
// object attributes (for markup)
isSource: true,
horizontal: false,
copyOnly: false,
selfCopy: false,
selfAccept: true,
skipForm: false,
withHandles: false,
autoSync: false,
delay: 0, // pixels
accept: ["text"],
generateText: true,
constructor: function(/*DOMNode|String*/ node, /*__SourceArgs?*/ params){
// summary:
// a constructor of the Source
// node:
// node or node's id to build the source on
// params:
// any property of this class may be configured via the params
// object which is mixed-in to the `dojo/dnd/Source` instance
lang.mixin(this, lang.mixin({}, params));
var type = this.accept;
if(type.length){
this.accept = {};
for(var i = 0; i < type.length; ++i){
this.accept[type[i]] = 1;
}
}
// class-specific variables
this.isDragging = false;
this.mouseDown = false;
this.targetAnchor = null;
this.targetBox = null;
this.before = true;
this._lastX = 0;
this._lastY = 0;
// states
this.sourceState = "";
if(this.isSource){
domClass.add(this.node, "dojoDndSource");
}
this.targetState = "";
if(this.accept){
domClass.add(this.node, "dojoDndTarget");
}
if(this.horizontal){
domClass.add(this.node, "dojoDndHorizontal");
}
// set up events
this.topics = [
topic.subscribe("/dnd/source/over", lang.hitch(this, "onDndSourceOver")),
topic.subscribe("/dnd/start", lang.hitch(this, "onDndStart")),
topic.subscribe("/dnd/drop", lang.hitch(this, "onDndDrop")),
topic.subscribe("/dnd/cancel", lang.hitch(this, "onDndCancel"))
];
},
// methods
checkAcceptance: function(source, nodes){
// summary:
// checks if the target can accept nodes from this source
// source: Object
// the source which provides items
// nodes: Array
// the list of transferred items
if(this == source){
return !this.copyOnly || this.selfAccept;
}
for(var i = 0; i < nodes.length; ++i){
var type = source.getItem(nodes[i].id).type;
// type instanceof Array
var flag = false;
for(var j = 0; j < type.length; ++j){
if(type[j] in this.accept){
flag = true;
break;
}
}
if(!flag){
return false; // Boolean
}
}
return true; // Boolean
},
copyState: function(keyPressed, self){
// summary:
// Returns true if we need to copy items, false to move.
// It is separated to be overwritten dynamically, if needed.
// keyPressed: Boolean
// the "copy" key was pressed
// self: Boolean?
// optional flag that means that we are about to drop on itself
if(keyPressed){ return true; }
if(arguments.length < 2){
self = this == Manager.manager().target;
}
if(self){
if(this.copyOnly){
return this.selfCopy;
}
}else{
return this.copyOnly;
}
return false; // Boolean
},
destroy: function(){
// summary:
// prepares the object to be garbage-collected
Source.superclass.destroy.call(this);
array.forEach(this.topics, function(t){t.remove();});
this.targetAnchor = null;
},
// mouse event processors
onMouseMove: function(e){
// summary:
// event processor for onmousemove
// e: Event
// mouse event
if(this.isDragging && this.targetState == "Disabled"){ return; }
Source.superclass.onMouseMove.call(this, e);
var m = Manager.manager();
if(!this.isDragging){
if(this.mouseDown && this.isSource &&
(Math.abs(e.pageX - this._lastX) > this.delay || Math.abs(e.pageY - this._lastY) > this.delay)){
var nodes = this.getSelectedNodes();
if(nodes.length){
m.startDrag(this, nodes, this.copyState(dnd.getCopyKeyState(e), true));
}
}
}
if(this.isDragging){
// calculate before/after
var before = false;
if(this.current){
if(!this.targetBox || this.targetAnchor != this.current){
this.targetBox = domGeom.position(this.current, true);
}
if(this.horizontal){
// In LTR mode, the left part of the object means "before", but in RTL mode it means "after".
before = (e.pageX - this.targetBox.x < this.targetBox.w / 2) == domGeom.isBodyLtr(this.current.ownerDocument);
}else{
before = (e.pageY - this.targetBox.y) < (this.targetBox.h / 2);
}
}
if(this.current != this.targetAnchor || before != this.before){
this._markTargetAnchor(before);
m.canDrop(!this.current || m.source != this || !(this.current.id in this.selection));
}
}
},
onMouseDown: function(e){
// summary:
// event processor for onmousedown
// e: Event
// mouse event
if(!this.mouseDown && this._legalMouseDown(e) && (!this.skipForm || !dnd.isFormElement(e))){
this.mouseDown = true;
this._lastX = e.pageX;
this._lastY = e.pageY;
Source.superclass.onMouseDown.call(this, e);
}
},
onMouseUp: function(e){
// summary:
// event processor for onmouseup
// e: Event
// mouse event
if(this.mouseDown){
this.mouseDown = false;
Source.superclass.onMouseUp.call(this, e);
}
},
// topic event processors
onDndSourceOver: function(source){
// summary:
// topic event processor for /dnd/source/over, called when detected a current source
// source: Object
// the source which has the mouse over it
if(this !== source){
this.mouseDown = false;
if(this.targetAnchor){
this._unmarkTargetAnchor();
}
}else if(this.isDragging){
var m = Manager.manager();
m.canDrop(this.targetState != "Disabled" && (!this.current || m.source != this || !(this.current.id in this.selection)));
}
},
onDndStart: function(source, nodes, copy){
// summary:
// topic event processor for /dnd/start, called to initiate the DnD operation
// source: Object
// the source which provides items
// nodes: Array
// the list of transferred items
// copy: Boolean
// copy items, if true, move items otherwise
if(this.autoSync){ this.sync(); }
if(this.isSource){
this._changeState("Source", this == source ? (copy ? "Copied" : "Moved") : "");
}
var accepted = this.accept && this.checkAcceptance(source, nodes);
this._changeState("Target", accepted ? "" : "Disabled");
if(this == source){
Manager.manager().overSource(this);
}
this.isDragging = true;
},
onDndDrop: function(source, nodes, copy, target){
// summary:
// topic event processor for /dnd/drop, called to finish the DnD operation
// source: Object
// the source which provides items
// nodes: Array
// the list of transferred items
// copy: Boolean
// copy items, if true, move items otherwise
// target: Object
// the target which accepts items
if(this == target){
// this one is for us => move nodes!
this.onDrop(source, nodes, copy);
}
this.onDndCancel();
},
onDndCancel: function(){
// summary:
// topic event processor for /dnd/cancel, called to cancel the DnD operation
if(this.targetAnchor){
this._unmarkTargetAnchor();
this.targetAnchor = null;
}
this.before = true;
this.isDragging = false;
this.mouseDown = false;
this._changeState("Source", "");
this._changeState("Target", "");
},
// local events
onDrop: function(source, nodes, copy){
// summary:
// called only on the current target, when drop is performed
// source: Object
// the source which provides items
// nodes: Array
// the list of transferred items
// copy: Boolean
// copy items, if true, move items otherwise
if(this != source){
this.onDropExternal(source, nodes, copy);
}else{
this.onDropInternal(nodes, copy);
}
},
onDropExternal: function(source, nodes, copy){
// summary:
// called only on the current target, when drop is performed
// from an external source
// source: Object
// the source which provides items
// nodes: Array
// the list of transferred items
// copy: Boolean
// copy items, if true, move items otherwise
var oldCreator = this._normalizedCreator;
// transferring nodes from the source to the target
if(this.creator){
// use defined creator
this._normalizedCreator = function(node, hint){
return oldCreator.call(this, source.getItem(node.id).data, hint);
};
}else{
// we have no creator defined => move/clone nodes
if(copy){
// clone nodes
this._normalizedCreator = function(node /*=====, hint =====*/){
var t = source.getItem(node.id);
var n = node.cloneNode(true);
n.id = dnd.getUniqueId();
return {node: n, data: t.data, type: t.type};
};
}else{
// move nodes
this._normalizedCreator = function(node /*=====, hint =====*/){
var t = source.getItem(node.id);
source.delItem(node.id);
return {node: node, data: t.data, type: t.type};
};
}
}
this.selectNone();
if(!copy && !this.creator){
source.selectNone();
}
this.insertNodes(true, nodes, this.before, this.current);
if(!copy && this.creator){
source.deleteSelectedNodes();
}
this._normalizedCreator = oldCreator;
},
onDropInternal: function(nodes, copy){
// summary:
// called only on the current target, when drop is performed
// from the same target/source
// nodes: Array
// the list of transferred items
// copy: Boolean
// copy items, if true, move items otherwise
var oldCreator = this._normalizedCreator;
// transferring nodes within the single source
if(this.current && this.current.id in this.selection){
// do nothing
return;
}
if(copy){
if(this.creator){
// create new copies of data items
this._normalizedCreator = function(node, hint){
return oldCreator.call(this, this.getItem(node.id).data, hint);
};
}else{
// clone nodes
this._normalizedCreator = function(node/*=====, hint =====*/){
var t = this.getItem(node.id);
var n = node.cloneNode(true);
n.id = dnd.getUniqueId();
return {node: n, data: t.data, type: t.type};
};
}
}else{
// move nodes
if(!this.current){
// do nothing
return;
}
this._normalizedCreator = function(node /*=====, hint =====*/){
var t = this.getItem(node.id);
return {node: node, data: t.data, type: t.type};
};
}
this._removeSelection();
this.insertNodes(true, nodes, this.before, this.current);
this._normalizedCreator = oldCreator;
},
onDraggingOver: function(){
// summary:
// called during the active DnD operation, when items
// are dragged over this target, and it is not disabled
},
onDraggingOut: function(){
// summary:
// called during the active DnD operation, when items
// are dragged away from this target, and it is not disabled
},
// utilities
onOverEvent: function(){
// summary:
// this function is called once, when mouse is over our container
Source.superclass.onOverEvent.call(this);
Manager.manager().overSource(this);
if(this.isDragging && this.targetState != "Disabled"){
this.onDraggingOver();
}
},
onOutEvent: function(){
// summary:
// this function is called once, when mouse is out of our container
Source.superclass.onOutEvent.call(this);
Manager.manager().outSource(this);
if(this.isDragging && this.targetState != "Disabled"){
this.onDraggingOut();
}
},
_markTargetAnchor: function(before){
// summary:
// assigns a class to the current target anchor based on "before" status
// before: Boolean
// insert before, if true, after otherwise
if(this.current == this.targetAnchor && this.before == before){ return; }
if(this.targetAnchor){
this._removeItemClass(this.targetAnchor, this.before ? "Before" : "After");
}
this.targetAnchor = this.current;
this.targetBox = null;
this.before = before;
if(this.targetAnchor){
this._addItemClass(this.targetAnchor, this.before ? "Before" : "After");
}
},
_unmarkTargetAnchor: function(){
// summary:
// removes a class of the current target anchor based on "before" status
if(!this.targetAnchor){ return; }
this._removeItemClass(this.targetAnchor, this.before ? "Before" : "After");
this.targetAnchor = null;
this.targetBox = null;
this.before = true;
},
_markDndStatus: function(copy){
// summary:
// changes source's state based on "copy" status
this._changeState("Source", copy ? "Copied" : "Moved");
},
_legalMouseDown: function(e){
// summary:
// checks if user clicked on "approved" items
// e: Event
// mouse event
// accept only the left mouse button, or the left finger
if(e.type != "touchstart" && !mouse.isLeft(e)){ return false; }
if(!this.withHandles){ return true; }
// check for handles
for(var node = e.target; node && node !== this.node; node = node.parentNode){
if(domClass.contains(node, "dojoDndHandle")){ return true; }
if(domClass.contains(node, "dojoDndItem") || domClass.contains(node, "dojoDndIgnore")){ break; }
}
return false; // Boolean
}
});
return Source;
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/Target",["./Source"],function(_1){return dojo.declare("dojo.dnd.Target",_1,{constructor:function(_2,_3){this.isSource=false;dojo.removeClass(this.node,"dojoDndSource");}});});
define("dojo/dnd/Target",["../_base/declare","../dom-class","./Source"],function(_1,_2,_3){return _1("dojo.dnd.Target",_3,{constructor:function(){this.isSource=false;_2.remove(this.node,"dojoDndSource");}});});
+13
View File
@@ -0,0 +1,13 @@
define("dojo/dnd/Target", [ "../_base/declare", "../dom-class", "./Source" ], function(declare, domClass, Source){
return declare("dojo.dnd.Target", Source, {
// summary:
// a Target object, which can be used as a DnD target
constructor: function(/*===== node, params =====*/){
// summary:
// a constructor of the Target --- see the `dojo/dnd/Source` constructor for details
this.isSource = false;
domClass.remove(this.node, "dojoDndSource");
}
});
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/TimedMoveable",["../main","./Moveable"],function(_1){var _2=_1.dnd.Moveable.prototype.onMove;_1.declare("dojo.dnd.TimedMoveable",_1.dnd.Moveable,{timeout:40,constructor:function(_3,_4){if(!_4){_4={};}if(_4.timeout&&typeof _4.timeout=="number"&&_4.timeout>=0){this.timeout=_4.timeout;}},onMoveStop:function(_5){if(_5._timer){clearTimeout(_5._timer);_2.call(this,_5,_5._leftTop);}_1.dnd.Moveable.prototype.onMoveStop.apply(this,arguments);},onMove:function(_6,_7){_6._leftTop=_7;if(!_6._timer){var _8=this;_6._timer=setTimeout(function(){_6._timer=null;_2.call(_8,_6,_6._leftTop);},this.timeout);}}});return _1.dnd.TimedMoveable;});
define("dojo/dnd/TimedMoveable",["../_base/declare","./Moveable"],function(_1,_2){var _3=_2.prototype.onMove;return _1("dojo.dnd.TimedMoveable",_2,{timeout:40,constructor:function(_4,_5){if(!_5){_5={};}if(_5.timeout&&typeof _5.timeout=="number"&&_5.timeout>=0){this.timeout=_5.timeout;}},onMoveStop:function(_6){if(_6._timer){clearTimeout(_6._timer);_3.call(this,_6,_6._leftTop);}_2.prototype.onMoveStop.apply(this,arguments);},onMove:function(_7,_8){_7._leftTop=_8;if(!_7._timer){var _9=this;_7._timer=setTimeout(function(){_7._timer=null;_3.call(_9,_7,_7._leftTop);},this.timeout);}}});});
@@ -0,0 +1,64 @@
define("dojo/dnd/TimedMoveable", ["../_base/declare", "./Moveable" /*=====, "./Mover" =====*/], function(declare, Moveable /*=====, Mover =====*/){
// module:
// dojo/dnd/TimedMoveable
/*=====
var __TimedMoveableArgs = declare([Moveable.__MoveableArgs], {
// timeout: Number
// delay move by this number of ms,
// accumulating position changes during the timeout
timeout: 0
});
=====*/
// precalculate long expressions
var oldOnMove = Moveable.prototype.onMove;
return declare("dojo.dnd.TimedMoveable", Moveable, {
// summary:
// A specialized version of Moveable to support an FPS throttling.
// This class puts an upper restriction on FPS, which may reduce
// the CPU load. The additional parameter "timeout" regulates
// the delay before actually moving the moveable object.
// object attributes (for markup)
timeout: 40, // in ms, 40ms corresponds to 25 fps
constructor: function(node, params){
// summary:
// an object that makes a node moveable with a timer
// node: Node||String
// a node (or node's id) to be moved
// params: __TimedMoveableArgs
// object with additional parameters.
// sanitize parameters
if(!params){ params = {}; }
if(params.timeout && typeof params.timeout == "number" && params.timeout >= 0){
this.timeout = params.timeout;
}
},
onMoveStop: function(/*Mover*/ mover){
if(mover._timer){
// stop timer
clearTimeout(mover._timer);
// reflect the last received position
oldOnMove.call(this, mover, mover._leftTop);
}
Moveable.prototype.onMoveStop.apply(this, arguments);
},
onMove: function(/*Mover*/ mover, /*Object*/ leftTop){
mover._leftTop = leftTop;
if(!mover._timer){
var _t = this; // to avoid using dojo.hitch()
mover._timer = setTimeout(function(){
// we don't have any pending requests
mover._timer = null;
// reflect the last received position
oldOnMove.call(_t, mover, mover._leftTop);
}, this.timeout);
}
}
});
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/autoscroll",["../main","../window"],function(_1){_1.getObject("dnd",true,_1);_1.dnd.getViewport=_1.window.getBox;_1.dnd.V_TRIGGER_AUTOSCROLL=32;_1.dnd.H_TRIGGER_AUTOSCROLL=32;_1.dnd.V_AUTOSCROLL_VALUE=16;_1.dnd.H_AUTOSCROLL_VALUE=16;_1.dnd.autoScroll=function(e){var v=_1.window.getBox(),dx=0,dy=0;if(e.clientX<_1.dnd.H_TRIGGER_AUTOSCROLL){dx=-_1.dnd.H_AUTOSCROLL_VALUE;}else{if(e.clientX>v.w-_1.dnd.H_TRIGGER_AUTOSCROLL){dx=_1.dnd.H_AUTOSCROLL_VALUE;}}if(e.clientY<_1.dnd.V_TRIGGER_AUTOSCROLL){dy=-_1.dnd.V_AUTOSCROLL_VALUE;}else{if(e.clientY>v.h-_1.dnd.V_TRIGGER_AUTOSCROLL){dy=_1.dnd.V_AUTOSCROLL_VALUE;}}window.scrollBy(dx,dy);};_1.dnd._validNodes={"div":1,"p":1,"td":1};_1.dnd._validOverflow={"auto":1,"scroll":1};_1.dnd.autoScrollNodes=function(e){var b,t,w,h,rx,ry,dx=0,dy=0,_2,_3;for(var n=e.target;n;){if(n.nodeType==1&&(n.tagName.toLowerCase() in _1.dnd._validNodes)){var s=_1.getComputedStyle(n),_4=(s.overflow.toLowerCase() in _1.dnd._validOverflow),_5=(s.overflowX.toLowerCase() in _1.dnd._validOverflow),_6=(s.overflowY.toLowerCase() in _1.dnd._validOverflow);if(_4||_5||_6){b=_1._getContentBox(n,s);t=_1.position(n,true);}if(_4||_5){w=Math.min(_1.dnd.H_TRIGGER_AUTOSCROLL,b.w/2);rx=e.pageX-t.x;if(_1.isWebKit||_1.isOpera){rx+=_1.body().scrollLeft;}dx=0;if(rx>0&&rx<b.w){if(rx<w){dx=-w;}else{if(rx>b.w-w){dx=w;}}_2=n.scrollLeft;n.scrollLeft=n.scrollLeft+dx;}}if(_4||_6){h=Math.min(_1.dnd.V_TRIGGER_AUTOSCROLL,b.h/2);ry=e.pageY-t.y;if(_1.isWebKit||_1.isOpera){ry+=_1.body().scrollTop;}dy=0;if(ry>0&&ry<b.h){if(ry<h){dy=-h;}else{if(ry>b.h-h){dy=h;}}_3=n.scrollTop;n.scrollTop=n.scrollTop+dy;}}if(dx||dy){return;}}try{n=n.parentNode;}catch(x){n=null;}}_1.dnd.autoScroll(e);};return _1.dnd;});
define("dojo/dnd/autoscroll",["../_base/lang","../sniff","../_base/window","../dom-geometry","../dom-style","../window"],function(_1,_2,_3,_4,_5,_6){var _7={};_1.setObject("dojo.dnd.autoscroll",_7);_7.getViewport=_6.getBox;_7.V_TRIGGER_AUTOSCROLL=32;_7.H_TRIGGER_AUTOSCROLL=32;_7.V_AUTOSCROLL_VALUE=16;_7.H_AUTOSCROLL_VALUE=16;var _8,_9=_3.doc,_a=Infinity,_b=Infinity;_7.autoScrollStart=function(d){_9=d;_8=_6.getBox(_9);var _c=_3.body(_9).parentNode;_a=Math.max(_c.scrollHeight-_8.h,0);_b=Math.max(_c.scrollWidth-_8.w,0);};_7.autoScroll=function(e){var v=_8||_6.getBox(_9),_d=_3.body(_9).parentNode,dx=0,dy=0;if(e.clientX<_7.H_TRIGGER_AUTOSCROLL){dx=-_7.H_AUTOSCROLL_VALUE;}else{if(e.clientX>v.w-_7.H_TRIGGER_AUTOSCROLL){dx=Math.min(_7.H_AUTOSCROLL_VALUE,_b-_d.scrollLeft);}}if(e.clientY<_7.V_TRIGGER_AUTOSCROLL){dy=-_7.V_AUTOSCROLL_VALUE;}else{if(e.clientY>v.h-_7.V_TRIGGER_AUTOSCROLL){dy=Math.min(_7.V_AUTOSCROLL_VALUE,_a-_d.scrollTop);}}window.scrollBy(dx,dy);};_7._validNodes={"div":1,"p":1,"td":1};_7._validOverflow={"auto":1,"scroll":1};_7.autoScrollNodes=function(e){var b,t,w,h,rx,ry,dx=0,dy=0,_e,_f;for(var n=e.target;n;){if(n.nodeType==1&&(n.tagName.toLowerCase() in _7._validNodes)){var s=_5.getComputedStyle(n),_10=(s.overflow.toLowerCase() in _7._validOverflow),_11=(s.overflowX.toLowerCase() in _7._validOverflow),_12=(s.overflowY.toLowerCase() in _7._validOverflow);if(_10||_11||_12){b=_4.getContentBox(n,s);t=_4.position(n,true);}if(_10||_11){w=Math.min(_7.H_TRIGGER_AUTOSCROLL,b.w/2);rx=e.pageX-t.x;if(_2("webkit")||_2("opera")){rx+=_3.body().scrollLeft;}dx=0;if(rx>0&&rx<b.w){if(rx<w){dx=-w;}else{if(rx>b.w-w){dx=w;}}_e=n.scrollLeft;n.scrollLeft=n.scrollLeft+dx;}}if(_10||_12){h=Math.min(_7.V_TRIGGER_AUTOSCROLL,b.h/2);ry=e.pageY-t.y;if(_2("webkit")||_2("opera")){ry+=_3.body().scrollTop;}dy=0;if(ry>0&&ry<b.h){if(ry<h){dy=-h;}else{if(ry>b.h-h){dy=h;}}_f=n.scrollTop;n.scrollTop=n.scrollTop+dy;}}if(dx||dy){return;}}try{n=n.parentNode;}catch(x){n=null;}}_7.autoScroll(e);};return _7;});
+149
View File
@@ -0,0 +1,149 @@
define("dojo/dnd/autoscroll", ["../_base/lang", "../sniff", "../_base/window", "../dom-geometry", "../dom-style", "../window"],
function(lang, has, win, domGeom, domStyle, winUtils){
// module:
// dojo/dnd/autoscroll
var exports = {
// summary:
// Used by dojo/dnd/Manager to scroll document or internal node when the user
// drags near the edge of the viewport or a scrollable node
};
lang.setObject("dojo.dnd.autoscroll", exports);
exports.getViewport = winUtils.getBox;
exports.V_TRIGGER_AUTOSCROLL = 32;
exports.H_TRIGGER_AUTOSCROLL = 32;
exports.V_AUTOSCROLL_VALUE = 16;
exports.H_AUTOSCROLL_VALUE = 16;
// These are set by autoScrollStart().
// Set to default values in case autoScrollStart() isn't called. (back-compat, remove for 2.0)
var viewport,
doc = win.doc,
maxScrollTop = Infinity,
maxScrollLeft = Infinity;
exports.autoScrollStart = function(d){
// summary:
// Called at the start of a drag.
// d: Document
// The document of the node being dragged.
doc = d;
viewport = winUtils.getBox(doc);
// Save height/width of document at start of drag, before it gets distorted by a user dragging an avatar past
// the document's edge
var html = win.body(doc).parentNode;
maxScrollTop = Math.max(html.scrollHeight - viewport.h, 0);
maxScrollLeft = Math.max(html.scrollWidth - viewport.w, 0); // usually 0
};
exports.autoScroll = function(e){
// summary:
// a handler for mousemove and touchmove events, which scrolls the window, if
// necessary
// e: Event
// mousemove/touchmove event
// FIXME: needs more docs!
var v = viewport || winUtils.getBox(doc), // getBox() call for back-compat, in case autoScrollStart() wasn't called
html = win.body(doc).parentNode,
dx = 0, dy = 0;
if(e.clientX < exports.H_TRIGGER_AUTOSCROLL){
dx = -exports.H_AUTOSCROLL_VALUE;
}else if(e.clientX > v.w - exports.H_TRIGGER_AUTOSCROLL){
dx = Math.min(exports.H_AUTOSCROLL_VALUE, maxScrollLeft - html.scrollLeft); // don't scroll past edge of doc
}
if(e.clientY < exports.V_TRIGGER_AUTOSCROLL){
dy = -exports.V_AUTOSCROLL_VALUE;
}else if(e.clientY > v.h - exports.V_TRIGGER_AUTOSCROLL){
dy = Math.min(exports.V_AUTOSCROLL_VALUE, maxScrollTop - html.scrollTop); // don't scroll past edge of doc
}
window.scrollBy(dx, dy);
};
exports._validNodes = {"div": 1, "p": 1, "td": 1};
exports._validOverflow = {"auto": 1, "scroll": 1};
exports.autoScrollNodes = function(e){
// summary:
// a handler for mousemove and touchmove events, which scrolls the first available
// Dom element, it falls back to exports.autoScroll()
// e: Event
// mousemove/touchmove event
// FIXME: needs more docs!
var b, t, w, h, rx, ry, dx = 0, dy = 0, oldLeft, oldTop;
for(var n = e.target; n;){
if(n.nodeType == 1 && (n.tagName.toLowerCase() in exports._validNodes)){
var s = domStyle.getComputedStyle(n),
overflow = (s.overflow.toLowerCase() in exports._validOverflow),
overflowX = (s.overflowX.toLowerCase() in exports._validOverflow),
overflowY = (s.overflowY.toLowerCase() in exports._validOverflow);
if(overflow || overflowX || overflowY){
b = domGeom.getContentBox(n, s);
t = domGeom.position(n, true);
}
// overflow-x
if(overflow || overflowX){
w = Math.min(exports.H_TRIGGER_AUTOSCROLL, b.w / 2);
rx = e.pageX - t.x;
if(has("webkit") || has("opera")){
// FIXME: this code should not be here, it should be taken into account
// either by the event fixing code, or the domGeom.position()
// FIXME: this code doesn't work on Opera 9.5 Beta
rx += win.body().scrollLeft;
}
dx = 0;
if(rx > 0 && rx < b.w){
if(rx < w){
dx = -w;
}else if(rx > b.w - w){
dx = w;
}
oldLeft = n.scrollLeft;
n.scrollLeft = n.scrollLeft + dx;
}
}
// overflow-y
if(overflow || overflowY){
//console.log(b.l, b.t, t.x, t.y, n.scrollLeft, n.scrollTop);
h = Math.min(exports.V_TRIGGER_AUTOSCROLL, b.h / 2);
ry = e.pageY - t.y;
if(has("webkit") || has("opera")){
// FIXME: this code should not be here, it should be taken into account
// either by the event fixing code, or the domGeom.position()
// FIXME: this code doesn't work on Opera 9.5 Beta
ry += win.body().scrollTop;
}
dy = 0;
if(ry > 0 && ry < b.h){
if(ry < h){
dy = -h;
}else if(ry > b.h - h){
dy = h;
}
oldTop = n.scrollTop;
n.scrollTop = n.scrollTop + dy;
}
}
if(dx || dy){ return; }
}
try{
n = n.parentNode;
}catch(x){
n = null;
}
}
exports.autoScroll(e);
};
return exports;
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/common",["../main"],function(_1){_1.getObject("dnd",true,_1);_1.dnd.getCopyKeyState=_1.isCopyKey;_1.dnd._uniqueId=0;_1.dnd.getUniqueId=function(){var id;do{id=_1._scopeName+"Unique"+(++_1.dnd._uniqueId);}while(_1.byId(id));return id;};_1.dnd._empty={};_1.dnd.isFormElement=function(e){var t=e.target;if(t.nodeType==3){t=t.parentNode;}return " button textarea input select option ".indexOf(" "+t.tagName.toLowerCase()+" ")>=0;};return _1.dnd;});
define("dojo/dnd/common",["../_base/connect","../_base/kernel","../_base/lang","../dom"],function(_1,_2,_3,_4){var _5=_3.getObject("dojo.dnd",true);_5.getCopyKeyState=_1.isCopyKey;_5._uniqueId=0;_5.getUniqueId=function(){var id;do{id=_2._scopeName+"Unique"+(++_5._uniqueId);}while(_4.byId(id));return id;};_5._empty={};_5.isFormElement=function(e){var t=e.target;if(t.nodeType==3){t=t.parentNode;}return " button textarea input select option ".indexOf(" "+t.tagName.toLowerCase()+" ")>=0;};return _5;});
+42
View File
@@ -0,0 +1,42 @@
define("dojo/dnd/common", ["../_base/connect", "../_base/kernel", "../_base/lang", "../dom"],
function(connect, kernel, lang, dom){
// module:
// dojo/dnd/common
var exports = lang.getObject("dojo.dnd", true);
/*=====
// TODO: for 2.0, replace line above with this code.
var exports = {
// summary:
// TODOC
};
=====*/
exports.getCopyKeyState = connect.isCopyKey;
exports._uniqueId = 0;
exports.getUniqueId = function(){
// summary:
// returns a unique string for use with any DOM element
var id;
do{
id = kernel._scopeName + "Unique" + (++exports._uniqueId);
}while(dom.byId(id));
return id;
};
exports._empty = {};
exports.isFormElement = function(/*Event*/ e){
// summary:
// returns true if user clicked on a form element
var t = e.target;
if(t.nodeType == 3 /*TEXT_NODE*/){
t = t.parentNode;
}
return " button textarea input select option ".indexOf(" " + t.tagName.toLowerCase() + " ") >= 0; // Boolean
};
return exports;
});
+2 -2
View File
@@ -1,8 +1,8 @@
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Copyright (c) 2004-2012, 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
*/
//>>built
define("dojo/dnd/move",["../main","./Mover","./Moveable"],function(_1){_1.declare("dojo.dnd.move.constrainedMoveable",_1.dnd.Moveable,{constraints:function(){},within:false,constructor:function(_2,_3){if(!_3){_3={};}this.constraints=_3.constraints;this.within=_3.within;},onFirstMove:function(_4){var c=this.constraintBox=this.constraints.call(this,_4);c.r=c.l+c.w;c.b=c.t+c.h;if(this.within){var mb=_1._getMarginSize(_4.node);c.r-=mb.w;c.b-=mb.h;}},onMove:function(_5,_6){var c=this.constraintBox,s=_5.node.style;this.onMoving(_5,_6);_6.l=_6.l<c.l?c.l:c.r<_6.l?c.r:_6.l;_6.t=_6.t<c.t?c.t:c.b<_6.t?c.b:_6.t;s.left=_6.l+"px";s.top=_6.t+"px";this.onMoved(_5,_6);}});_1.declare("dojo.dnd.move.boxConstrainedMoveable",_1.dnd.move.constrainedMoveable,{box:{},constructor:function(_7,_8){var _9=_8&&_8.box;this.constraints=function(){return _9;};}});_1.declare("dojo.dnd.move.parentConstrainedMoveable",_1.dnd.move.constrainedMoveable,{area:"content",constructor:function(_a,_b){var _c=_b&&_b.area;this.constraints=function(){var n=this.node.parentNode,s=_1.getComputedStyle(n),mb=_1._getMarginBox(n,s);if(_c=="margin"){return mb;}var t=_1._getMarginExtents(n,s);mb.l+=t.l,mb.t+=t.t,mb.w-=t.w,mb.h-=t.h;if(_c=="border"){return mb;}t=_1._getBorderExtents(n,s);mb.l+=t.l,mb.t+=t.t,mb.w-=t.w,mb.h-=t.h;if(_c=="padding"){return mb;}t=_1._getPadExtents(n,s);mb.l+=t.l,mb.t+=t.t,mb.w-=t.w,mb.h-=t.h;return mb;};}});_1.dnd.constrainedMover=_1.dnd.move.constrainedMover;_1.dnd.boxConstrainedMover=_1.dnd.move.boxConstrainedMover;_1.dnd.parentConstrainedMover=_1.dnd.move.parentConstrainedMover;return _1.dnd.move;});
define("dojo/dnd/move",["../_base/declare","../dom-geometry","../dom-style","./common","./Mover","./Moveable"],function(_1,_2,_3,_4,_5,_6){var _7=_1("dojo.dnd.move.constrainedMoveable",_6,{constraints:function(){},within:false,constructor:function(_8,_9){if(!_9){_9={};}this.constraints=_9.constraints;this.within=_9.within;},onFirstMove:function(_a){var c=this.constraintBox=this.constraints.call(this,_a);c.r=c.l+c.w;c.b=c.t+c.h;if(this.within){var mb=_2.getMarginSize(_a.node);c.r-=mb.w;c.b-=mb.h;}},onMove:function(_b,_c){var c=this.constraintBox,s=_b.node.style;this.onMoving(_b,_c);_c.l=_c.l<c.l?c.l:c.r<_c.l?c.r:_c.l;_c.t=_c.t<c.t?c.t:c.b<_c.t?c.b:_c.t;s.left=_c.l+"px";s.top=_c.t+"px";this.onMoved(_b,_c);}});var _d=_1("dojo.dnd.move.boxConstrainedMoveable",_7,{box:{},constructor:function(_e,_f){var box=_f&&_f.box;this.constraints=function(){return box;};}});var _10=_1("dojo.dnd.move.parentConstrainedMoveable",_7,{area:"content",constructor:function(_11,_12){var _13=_12&&_12.area;this.constraints=function(){var n=this.node.parentNode,s=_3.getComputedStyle(n),mb=_2.getMarginBox(n,s);if(_13=="margin"){return mb;}var t=_2.getMarginExtents(n,s);mb.l+=t.l,mb.t+=t.t,mb.w-=t.w,mb.h-=t.h;if(_13=="border"){return mb;}t=_2.getBorderExtents(n,s);mb.l+=t.l,mb.t+=t.t,mb.w-=t.w,mb.h-=t.h;if(_13=="padding"){return mb;}t=_2.getPadExtents(n,s);mb.l+=t.l,mb.t+=t.t,mb.w-=t.w,mb.h-=t.h;return mb;};}});return {constrainedMoveable:_7,boxConstrainedMoveable:_d,parentConstrainedMoveable:_10};});
+147
View File
@@ -0,0 +1,147 @@
define("dojo/dnd/move", [
"../_base/declare",
"../dom-geometry", "../dom-style",
"./common", "./Mover", "./Moveable"
], function(declare, domGeom, domStyle, dnd, Mover, Moveable){
// module:
// dojo/dnd/move
/*=====
var __constrainedMoveableArgs = declare([Moveable.__MoveableArgs], {
// constraints: Function
// Calculates a constraint box.
// It is called in a context of the moveable object.
constraints: function(){},
// within: Boolean
// restrict move within boundaries.
within: false
});
=====*/
var constrainedMoveable = declare("dojo.dnd.move.constrainedMoveable", Moveable, {
// object attributes (for markup)
constraints: function(){},
within: false,
constructor: function(node, params){
// summary:
// an object that makes a node moveable
// node: Node
// a node (or node's id) to be moved
// params: __constrainedMoveableArgs?
// an optional object with additional parameters;
// the rest is passed to the base class
if(!params){ params = {}; }
this.constraints = params.constraints;
this.within = params.within;
},
onFirstMove: function(/*Mover*/ mover){
// summary:
// called during the very first move notification;
// can be used to initialize coordinates, can be overwritten.
var c = this.constraintBox = this.constraints.call(this, mover);
c.r = c.l + c.w;
c.b = c.t + c.h;
if(this.within){
var mb = domGeom.getMarginSize(mover.node);
c.r -= mb.w;
c.b -= mb.h;
}
},
onMove: function(/*Mover*/ mover, /*Object*/ leftTop){
// summary:
// called during every move notification;
// should actually move the node; can be overwritten.
var c = this.constraintBox, s = mover.node.style;
this.onMoving(mover, leftTop);
leftTop.l = leftTop.l < c.l ? c.l : c.r < leftTop.l ? c.r : leftTop.l;
leftTop.t = leftTop.t < c.t ? c.t : c.b < leftTop.t ? c.b : leftTop.t;
s.left = leftTop.l + "px";
s.top = leftTop.t + "px";
this.onMoved(mover, leftTop);
}
});
/*=====
var __boxConstrainedMoveableArgs = declare([__constrainedMoveableArgs], {
// box: Object
// a constraint box
box: {}
});
=====*/
var boxConstrainedMoveable = declare("dojo.dnd.move.boxConstrainedMoveable", constrainedMoveable, {
// box:
// object attributes (for markup)
box: {},
constructor: function(node, params){
// summary:
// an object, which makes a node moveable
// node: Node
// a node (or node's id) to be moved
// params: __boxConstrainedMoveableArgs?
// an optional object with parameters
var box = params && params.box;
this.constraints = function(){ return box; };
}
});
/*=====
var __parentConstrainedMoveableArgs = declare( [__constrainedMoveableArgs], {
// area: String
// A parent's area to restrict the move.
// Can be "margin", "border", "padding", or "content".
area: ""
});
=====*/
var parentConstrainedMoveable = declare("dojo.dnd.move.parentConstrainedMoveable", constrainedMoveable, {
// area:
// object attributes (for markup)
area: "content",
constructor: function(node, params){
// summary:
// an object, which makes a node moveable
// node: Node
// a node (or node's id) to be moved
// params: __parentConstrainedMoveableArgs?
// an optional object with parameters
var area = params && params.area;
this.constraints = function(){
var n = this.node.parentNode,
s = domStyle.getComputedStyle(n),
mb = domGeom.getMarginBox(n, s);
if(area == "margin"){
return mb; // Object
}
var t = domGeom.getMarginExtents(n, s);
mb.l += t.l, mb.t += t.t, mb.w -= t.w, mb.h -= t.h;
if(area == "border"){
return mb; // Object
}
t = domGeom.getBorderExtents(n, s);
mb.l += t.l, mb.t += t.t, mb.w -= t.w, mb.h -= t.h;
if(area == "padding"){
return mb; // Object
}
t = domGeom.getPadExtents(n, s);
mb.l += t.l, mb.t += t.t, mb.w -= t.w, mb.h -= t.h;
return mb; // Object
};
}
});
return {
// summary:
// TODOC
constrainedMoveable: constrainedMoveable,
boxConstrainedMoveable: boxConstrainedMoveable,
parentConstrainedMoveable: parentConstrainedMoveable
};
});