dd.js revision 8ecbe68b759d486bf0e7b14e09e789bfd951b34b
d048f1c15089c16b8ca1b264513a2f92ff86e703JazzyNico * Provides the base Drag Drop Manger required for making a Node draggable.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @module dd
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @submodule dd-ddm-base
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * Provides the base Drag Drop Manger required for making a Node draggable.
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @class DDM
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @extends Base
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * @constructor
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * @namespace DD
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico var DDMBase = function() {
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico DDMBase.superclass.constructor.apply(this, arguments);
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @attribute dragCursor
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description The cursor to apply when dragging, if shimmed the shim will get the cursor.
d048f1c15089c16b8ca1b264513a2f92ff86e703JazzyNico * @type String
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @attribute clickPixelThresh
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @description The number of pixels to move to start a drag operation, default is 3.
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @type Number
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @attribute clickTimeThresh
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description The number of milliseconds a mousedown has to pass to start a drag operation, default is 1000.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @type Number
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @attribute dragMode
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description This attribute only works if the dd-drop module is active. It will set the dragMode (point, intersect, strict) of all future Drag instances.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @type String
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @property _active
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description flag set when we activate our first drag, so DDM can start listening for events.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @type {Boolean}
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @method _setDragMode
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description Handler for dragMode attribute setter.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @param String/Number The Number value or the String for the DragMode to default all future drag instances to.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @return Number The Mode to be set
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife if (mode === null) {
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife case 'intersect':
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife case 'strict':
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico case 'point':
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @property CSS_PREFIX
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description The PREFIX to attach to all DD CSS class names
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @type {String}
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife _activateTargets: function() {},
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @property _drags
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description Holder for all registered drag elements.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @type {Array}
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @property activeDrag
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description A reference to the currently active draggable object.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @type {Drag}
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @method _regDrag
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description Adds a reference to the drag object to the DDM._drags array, called in the constructor of Drag.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @param {Drag} d The Drag object
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico _regDrag: function(d) {
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico return false;
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife return true;
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @method _unregDrag
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description Remove this drag object from the DDM._drags array.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @param {Drag} d The drag object.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife _unregDrag: function(d) {
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife if (n !== d) {
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @method _setupListeners
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description Add the document listeners.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico //Y.Event.nativeAdd(document, 'mousemove', Y.bind(this._move, this));
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @method _start
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description Internal method used by Drag to signal the start of a drag operation
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico _start: function() {
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @method _startDrag
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description Factory method to be overwritten by other DDM's
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @param {Number} x The x position of the drag element
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @param {Number} y The y position of the drag element
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @param {Number} w The width of the drag element
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @param {Number} h The height of the drag element
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife _startDrag: function() {},
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method _endDrag
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description Factory method to be overwritten by other DDM's
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife _endDrag: function() {},
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife _dropMove: function() {},
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method _end
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description Internal method used by Drag to signal the end of a drag operation
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico _end: function() {
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @method stopDrag
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description Method will forcefully stop a drag operation. For example calling this from inside an ESC keypress handler will stop this drag.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @return {Self}
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @chainable
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico stopDrag: function() {
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife return this;
03a66cd4de660bda047af143016e23dbcbbc9b1aJazzyNico * @method _move
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description Internal listener for the mousemove DOM event to pass to the Drag's move method.
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @param {Event.Facade} ev The Dom mousemove Event
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * //TODO Private, rename??...
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method cssSizestoObject
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description Helper method to use to set the gutter from the attribute setter.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @param {String} gutter CSS style string for gutter: '5 0' (sets top and bottom to 5px, left and right to 0px), '1 2 3 4' (top 1px, right 2px, bottom 3px, left 4px)
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * @return {Object} The gutter Object Literal.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico switch (x.length) {
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method getDrag
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @description Get a valid Drag instance back from a Node or a selector string, false otherwise
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @param {String/Object} node The Node instance or Selector string to check for a valid Drag Object
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @return {Object}
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife var drag = false,
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife if (n instanceof Y.Node) {
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @event ddm:start
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @description Fires from the DDM before all drag events fire.
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @type {Event.Custom}
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @event ddm:end
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @description Fires from the DDM after the DDM finishes, before the drag end events.
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @type {Event.Custom}
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife}, '@VERSION@' ,{requires:['node', 'base'], skinnable:false});
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * Extends the dd-ddm-base Class to add support for the viewport shim to allow a draggable node to drag to be dragged over an iframe or any other node that traps mousemove events.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * It is also required to have Drop Targets enabled, as the viewport shim will contain the shims for the Drop Targets.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @module dd
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @submodule dd-ddm
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @namespace DD
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @property _pg
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description The shim placed over the screen to track the mousemove event.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @type {Node}
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @property _debugShim
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description Set this to true to set the shims opacity to .5 for debugging it, default: false.
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @type {Boolean}
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico _activateTargets: function() {},
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife _endDrag: function() {
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method _pg_deactivate
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @description Deactivates the shim
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method _pg_activate
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @description Activates the shim
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife var ah = this.activeDrag.get('activeHandle'), cur = 'auto';
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @method _pg_size
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description Sizes the shim on: activatation, window:scroll, window:resize
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife _pg_size: function() {
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @method _createPG
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @description Creates the shim and adds it's listeners to it.
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife this._pg.on('mousemove', Y.bind(this._move, this));
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico Y.on('domready', Y.bind(Y.DD.DDM._createPG, Y.DD.DDM));
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife}, '@VERSION@' ,{requires:['dd-ddm-base'], skinnable:false});
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * Extends the dd-ddm Class to add support for the placement of Drop Target shims inside the viewport shim. It also handles all Drop Target related events and interactions.
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @module dd
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @submodule dd-ddm-drop
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @namespace DD
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico //TODO CSS class name for the bestMatch..
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @property _noShim
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description This flag turns off the use of the mouseover/mouseout shim. It should not be used unless you know what you are doing.
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @type {Boolean}
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @property _activeShims
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @description Placeholder for all active shims on the page
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @type {Array}
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method _hasActiveShim
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @description This method checks the _activeShims Object to see if there is a shim active.
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @return {Boolean}
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico return true;
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @method _addActiveShim
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description Adds a Drop Target to the list of active shims
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @param {Object} d The Drop instance to add to the list.
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife this._activeShims[this._activeShims.length] = d;
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method _removeActiveShim
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @description Removes a Drop Target to the list of active shims
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @param {Object} d The Drop instance to remove from the list.
2e734f1580cbb232b4e4af131bec198b888bf177Firas Hanife * @method syncActiveShims
d048f1c15089c16b8ca1b264513a2f92ff86e703JazzyNico * @description This method will sync the position of the shims on the Drop Targets that are currently active.
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @param {Boolean} force Resize/sync all Targets.
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico var drops = ((force) ? this.targets : this._lookup());
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @property mode
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description The mode that the drag operations will run in 0 for Point, 1 for Intersect, 2 for Strict
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @type Number
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @property POINT
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @description In point mode, a Drop is targeted by the cursor being over the Target
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @type Number
037bf91e68f10e796fecad5054b332b003c3a562JazzyNico * @property INTERSECT
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @description In intersect mode, a Drop is targeted by "part" of the drag node being over the Target
bc04be9b255d3b398ec9857b8d582014be08d6d5Firas Hanife * @type Number
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @property STRICT
* @description Should we only check targets that are in the viewport on drags (for performance), default: true
useHash: true,
activeDrop: null,
validDrops: [],
* @description An object literal of Other Drop Targets that we encountered during this interaction (in the case of overlapping Drop Targets)
otherDrops: {},
targets: [],
* @description Add a Drop Target to the list of Valid Targets. This list get's regenerated on each new drag operation.
* @description Removes a Drop Target from the list of Valid Targets. This list get's regenerated on each new drag operation.
var drops = [];
if (v !== drop) {
clearCache: function() {
this.validDrops = [];
this.otherDrops = {};
this._activeShims = [];
_activateTargets: function() {
this.clearCache();
this._handleTargetOver();
* @description This method will gather the area for all potential targets and see which has the hightest covered area and return it.
* @param {Boolean} all If present, it returns an Array. First item is best match, second is an Array of the other items in the original Array.
biggest = v;
if (all) {
out = [];
if (v !== biggest) {
return biggest;
* @description This method fires the drop:hit, drag:drophit, drag:dropmiss methods and deactivates the shims..
_deactivateTargets: function() {
if (activeDrop) {
} else if (activeDrag) {
this.activeDrop = null;
_dropMove: function() {
if (this._hasActiveShim()) {
this._handleTargetOver();
_lookup: function() {
return this.validDrops;
var drops = [];
return drops;
_handleTargetOver: function() {
_regTarget: function(t) {
if (v != drop) {
vdrops = [];
if (v !== drop) {
var drop = false,
if (n instanceof Y.Node) {
drop = v;
return drop;
* The Drag & Drop Utility allows you to create a draggable interface efficiently, buffering you from browser-level abnormalities and enabling you to focus on the interesting logic surrounding your particular implementation. This component enables you to create a variety of standard draggable objects with just a few lines of code and then, using its extensive API, add your own specific implementation logic.
* @description Handles the mousedown DOM event, checks to see if you have a valid handle then starts the drag timers.
Drag = function(o) {
this._lazyAddAttrs = false;
if (!valid) {
node: {
dragNode: {
offsetNode: {
value: true
* @description The number of milliseconds a mousedown has to pass to start a drag operation, default is 1000.
lock: {
value: false,
if (lock) {
return lock;
* @description A payload holder to store arbitrary data about this drag object, can be used to store any value.
data: {
value: false
* @description If this is false, the drag element will not move with the cursor: default true. Can be used to "resize" the element.
move: {
value: true
* @description Use the protective shim on all drag operations: default true. Only works with dd-ddm, not dd-ddm-base.
useShim: {
value: true
* @description This config option is set by Drag to inform you of which handle fired the drag event (in the case that there are several handles): default false.
activeHandle: {
value: false
* @description By default a drag operation will only begin if the mousedown occurred with the primary mouse button. Setting this to false will allow for all mousedown events to trigger a drag.
value: true
* @description This attribute is not meant to be used by the implementor, it is meant to be used as an Event tracker so you can listen for it to change.
dragging: {
value: false
parent: {
value: false
* @description This attribute only works if the dd-drop module has been loaded. It will make this node a drop target as well as draggable.
target: {
value: false,
return config;
* @description This attribute only works if the dd-drop module is active. It will set the dragMode (point, intersect, strict) of this Drag instance.
dragMode: {
value: null,
groups: {
getter: function() {
if (!this._groups) {
this._groups = {};
var ret = [];
return ret;
setter: function(g) {
this._groups = {};
Y.each(g, function(v, k) {
this._groups[v] = true;
* @description Array of valid handles to add. Adding something here will set all handles, even if previously added with addHandle
handles: {
value: null,
setter: function(g) {
this._handles = {};
Y.each(g, function(v, k) {
this._handles[v] = true;
this._handles = null;
* @description Controls the default bubble parent for this Drag instance. Default: Y.DD.DDM. Set to false to disable bubbling.
bubbles: {
writeOnce: true,
* @description Add this Drag instance to a group, this should be used for on-the-fly group additions.
addToGroup: function(g) {
this._groups[g] = true;
* @description Remove this Drag instance from a group, this should be used for on-the-fly group removals.
removeFromGroup: function(g) {
delete this._groups[g];
* @description This will be a reference to the Drop instance associated with this drag if the target: true config attribute is set..
target: null,
if (config === false) {
if (this.target) {
this.target = null;
config = {};
_groups: null,
* @description This method creates all the events for this Event Target and publishes them so we get Event Bubbling.
_createEvents: function() {
queuable: false,
emitFacade: true,
bubbles: true,
queuable: false,
emitFacade: true,
bubbles: true,
queuable: false,
emitFacade: true,
bubbles: true,
queuable: false,
emitFacade: true,
bubbles: true,
var ev = [
this.publish(v, {
type: v,
emitFacade: true,
bubbles: true,
preventable: false,
queuable: false,
_ev_md: null,
* @description The getTime of the mousedown event. Not used, just here in case someone wants/needs to use it.
_startTime: null,
* @description The getTime of the mouseup event. Not used, just here in case someone wants/needs to use it.
_endTime: null,
_handles: null,
_invalids: null,
* @description A private hash of the default invalid selector strings: {'textarea': true, 'input': true, 'a': true, 'button': true}
_dragThreshMet: null,
_fromTimeout: null,
_clickTimeout: null,
deltaXY: null,
startXY: null,
nodeXY: null,
lastXY: null,
* @description The xy that the node will be set to. Changing this will alter the position as it's dragged.
actXY: null,
realXY: null,
mouseXY: null,
region: null,
this._fixIEMouseUp();
* @description The function we use as the ondragstart handler when we start a drag in Internet Explorer. This keeps IE from blowing up on images as drag handles.
_fixDragStart: function(e) {
e.preventDefault();
* @description The function we use as the onselectstart handler when we start a drag in Internet Explorer
_ieSelectFix: function() {
* @description We will hold a copy of the current "onselectstart" method on this property, and reset it after we are done using it.
_ieSelectBack: null,
* @description This method copies the onselectstart listner on the document to the _ieSelectFix property
_fixIEMouseDown: function() {
* @description This method copies the _ieSelectFix property back to the onselectstart listner on the document.
_fixIEMouseUp: function() {
_defMouseDownFn: function(e) {
this._dragThreshMet = false;
this._fixIEMouseDown();
* @description Method first checks to see if we have handles, if so it validates the click against the handle. Then if it finds a valid handle, it checks it against the invalid handles list. Returns true if a good handle was used, false otherwise.
hTest = null,
els = null,
set = false;
if (this._handles) {
hTest = n;
if (this._invalids) {
if (hTest) {
set = false;
set = true;
_timeoutCheck: function() {
this.start();
* @description Add a handle to a drag element. Drag only initiates when a mousedown happens on this element.
if (!this._handles) {
this._handles = {};
* @description Add a selector string to test the handle against. If the test passes the drag operation will not continue.
initializer: function() {
this.actXY = [];
this._createEvents();
_prep: function() {
this._dragThreshMet = false;
_unprep: function() {
start: function() {
this.region = {
end: function() {
if (this._clickTimeout) {
this._dragThreshMet = false;
this._fromTimeout = false;
* @description Handler for preventing the drag:end event. It will reset the node back to it's start position
_prevEndFn: function(e) {
_defAlignFn: function(e) {
this._moveNode();
this.region = {
info: {
_defDragFn: function(e) {
if (e.scroll) {
if (!this._dragThreshMet) {
this._dragThreshMet = true;
this.start();
if (this._clickTimeout) {
* @description Method will forcefully stop a drag operation. For example calling this from inside an ESC keypress handler will stop this drag.
stopDrag: function() {
destructor: function() {
this._unprep();
this.detachAll();
if (this.target) {
* The Drag & Drop Utility allows you to create a draggable interface efficiently, buffering you from browser-level abnormalities and enabling you to focus on the interesting logic surrounding your particular implementation. This component enables you to create a variety of standard draggable objects with just a few lines of code and then, using its extensive API, add your own specific implementation logic.
TRUE = true;
var P = function(config) {
P.ATTRS = {
host: {
moveOnEnd: {
hideOnEnd: {
resizeFrame: {
borderStyle: {
var proto = {
_hands: null,
_init: function() {
if (!this._hands) {
this._hands = [];
v.detach();
initializer: function() {
this._init();
destructor: function() {
v.detach();
_createFrame: function() {
p.setStyles({
* @description If resizeProxy is set to true (default) it will resize the proxy element to match the size of the Drag Element.
* If positionProxy is set to true (default) it will position the proxy element in the same location as the Drag Element.
if (ah) {
d.setStyles({
* The Drag & Drop Utility allows you to create a draggable interface efficiently, buffering you from browser-level abnormalities and enabling you to focus on the interesting logic surrounding your particular implementation. This component enables you to create a variety of standard draggable objects with just a few lines of code and then, using its extensive API, add your own specific implementation logic.
* This is a plugin for the dd-drag module to add the constraining methods to it. It supports constraining to a renodenode or viewport. It anode* supports tick based moves and XY axis constraints.
proto = null;
var C = function(config) {
* @description The Constrained instance will be placed on the Drag instance under the con namespace.
C.ATTRS = {
host: {
stickX: {
value: false
stickY: {
value: false
* @description The X tick offset the drag node should snap to on each drag move. False for no ticks. Default: false
tickX: {
value: false
* @description The Y tick offset the drag node should snap to on each drag move. False for no ticks. Default: false
tickY: {
value: false
tickXArray: {
value: false
tickYArray: {
value: false
* @description An Object Literal containing a valid region (top, right, bottom, left) of page positions to constrain the drag node to.
value: false,
getter: function(r) {
Y.mix(o, r);
setter: function (r) {
if (Y.Lang.isNumber(r[TOP]) && Y.Lang.isNumber(r[RIGHT]) && Y.Lang.isNumber(r[LEFT]) && Y.Lang.isNumber(r[BOTTOM])) {
Y.mix(o, r);
* @description CSS style string for the gutter of a region (supports negative values): '5 0' (sets top and bottom to 5px, left and right to 0px), '1 2 3 4' (top 1px, right 2px, bottom 3px, left 4px)
gutter: {
value: false,
setter: function(n) {
if (node) {
return node;
value: false
proto = {
initializer: function() {
_handleStart: function() {
this._regionCache = null;
_regionCache: null,
_cacheRegion: function() {
if (!this._regionCache) {
this._cacheRegion();
Y.each(g, function(i, n) {
if (inc) {
* @param {Array} _xy The XY to check if it's in the current region, if it isn't inside the region, it will reset the xy array to be inside the region.
r = this.getRegion(),
return _xy;
inside = false;
inside = true;
return inside;
* @description Modifies the Drag.actXY method from the after drag:align event. This is where the constraining happens.
align: function() {
r = this.getRegion(true);
return xy;
return pos;
return pos;
if (ticks[i]) {
return ret;
* The Drag & Drop Utility allows you to create a draggable interface efficiently, buffering you from browser-level abnormalities and enabling you to focus on the interesting logic surrounding your particular implementation. This component enables you to create a variety of standard draggable objects with just a few lines of code and then, using its extensive API, add your own specific implementation logic.
* This class is the base scroller class used to create the Plugin.DDNodeScroll and Plugin.DDWinScroll.
S.ATTRS = {
* @description Internal config option to hold the node that we are scrolling. Should not be set by the developer.
parentScroll: {
value: false,
if (node) {
return node;
buffer: {
scrollDelay: {
host: {
value: null
windowScroll: {
value: false
vertical: {
value: true
horizontal: {
value: true
_scrolling: null,
_vpRegionCache: null,
_dimCache: null,
_scrollTimer: null,
* @description Sets the _vpRegionCache property with an Object containing the dims from the viewport.
_getVPRegion: function() {
top: t + b,
left: l + b
this._vpRegionCache = r;
initializer: function() {
this._vpRegionCache = null;
* @description Check to see if we need to fire the scroll timer. If scroll timer is running this will scroll the window.
var r = this._getVPRegion(),
scroll = false,
w = this._dimCache.w,
h = this._dimCache.h,
scroll = true;
scroll = true;
scroll = true;
scroll = true;
if (move) {
this._cancelScroll();
if (scroll) {
this._initScroll();
this._cancelScroll();
_initScroll: function() {
this._cancelScroll();
this._scrollTimer = Y.Lang.later(this.get('scrollDelay'), this, this._checkWinScroll, [true], true);
_cancelScroll: function() {
this._scrolling = false;
if (this._scrollTimer) {
delete this._scrollTimer;
align: function(e) {
if (this._scrolling) {
this._cancelScroll();
e.preventDefault();
if (!this._scrolling) {
this._checkWinScroll();
_setDimCache: function() {
this._dimCache = {
start: function() {
this._setDimCache();
this._dimCache = null;
this._cancelScroll();
toString: function() {
var WS = function() {
windowScroll: {
value: true,
if (scroll) {
return scroll;
initializer: function() {
var NS = function() {
node: {
value: false,
if (node !== false) {
initializer: function() {
config.node = ((Y.Widget && config.host instanceof Y.Widget) ? config.host.get('boundingBox') : config.host);
* @description The Drag instance will be placed on the Node instance under the dd namespace. It can be accessed via Node.dd;
* The Drag & Drop Utility allows you to create a draggable interface efficiently, buffering you from browser-level abnormalities and enabling you to focus on the interesting logic surrounding your particular implementation. This component enables you to create a variety of standard draggable objects with just a few lines of code and then, using its extensive API, add your own specific implementation logic.
Drop = function() {
this._lazyAddAttrs = false;
node: {
groups: {
setter: function(g) {
this._groups = {};
Y.each(g, function(v, k) {
this._groups[v] = true;
padding: {
setter: function(p) {
lock: {
value: false,
if (lock) {
return lock;
* @description Controls the default bubble parent for this Drop instance. Default: Y.DD.DDM. Set to false to disable bubbling.
bubbles: {
writeOnce: true,
* @description This method creates all the events for this Event Target and publishes them so we get Event Bubbling.
_createEvents: function() {
var ev = [
this.publish(v, {
type: v,
emitFacade: true,
preventable: false,
bubbles: true,
queuable: false,
_valid: null,
_groups: null,
shim: null,
* @description A region object associated with this target, used for checking regions while dragging.
region: null,
overTarget: null,
this._valid = false;
var ret = false;
if (this._groups[v]) {
ret = true;
this._valid = true;
return ret;
initializer: function() {
destructor: function() {
if (this.shim) {
this.shim = null;
this.detachAll();
* @description Removes classes from the target, resets some flags and sets the shims deactive position [-999, -999]
_deactivateShim: function() {
if (!this.shim) {
this.overTarget = false;
_activateShim: function() {
this.overTarget = false;
this.sizeShim();
* @description Positions and sizes the shim with the raw data from the node, this can be used to programatically adjust the Targets shim for Animation..
sizeShim: function() {
if (!this.shim) {
this.region = {
_createShim: function() {
if (this.shim) {
s.setStyles({
this.shim = s;
_handleTargetOver: function() {
if (this.overTarget) {
this.overTarget = true;
this._handleOut();
_handleOverEvent: function() {
_handleOutEvent: function() {
if (this.overTarget) {
this.overTarget = false;
if (!force) {
* @description The Drop instance will be placed on the Node instance under the drop namespace. It can be accessed via Node.drop;