Skip to content

Commit

Permalink
API Doc tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Jul 28, 2011
1 parent 85e7d45 commit 18e8268
Show file tree
Hide file tree
Showing 20 changed files with 279 additions and 107 deletions.
13 changes: 8 additions & 5 deletions sandbox/dd/js/constrain.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
YUI.add('dd-constrain', function(Y) {

/**
* Plugin for the dd-drag module to add the constraining methods to it. It supports constraining to a node or viewport. It supports tick based moves and XY axis constraints.
* @class DDConstrained
/**
* 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.
* @module dd
* @submodule dd-constrain
*/
/**
* Plugin for the dd-drag module to add the constraining methods to it. It supports constraining to a node or viewport. It supports tick based moves and XY axis constraints.
* @class DDConstrained
* @extends Base
* @constructor
* @namespace Plugin
Expand All @@ -27,15 +30,15 @@ YUI.add('dd-constrain', function(Y) {
/**
* @event drag:tickAlignX
* @description Fires when this node is aligned with the tickX value.
* @param {EventFacade} event An EventFacade object
* @param {EventFacade} event An Event Facade object
* @type {CustomEvent}
*/
EV_TICK_ALIGN_X = 'drag:tickAlignX',

/**
* @event drag:tickAlignY
* @description Fires when this node is aligned with the tickY value.
* @param {EventFacade} event An EventFacade object
* @param {EventFacade} event An Event Facade object
* @type {CustomEvent}
*/
EV_TICK_ALIGN_Y = 'drag:tickAlignY',
Expand Down
4 changes: 3 additions & 1 deletion sandbox/dd/js/dd-drop-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ YUI.add('dd-drop-plugin', function(Y) {
* Simple Drop plugin that can be attached to a Node via the plug method.
* @module dd
* @submodule dd-drop-plugin
*/
/**
* Simple Drop plugin that can be attached to a Node via the plug method.
* @class Drop
* @extends DD.Drop
* @constructor
Expand Down Expand Up @@ -35,5 +38,4 @@ YUI.add('dd-drop-plugin', function(Y) {
Y.Plugin.Drop = Drop;



}, '@VERSION@' ,{requires:['dd-drop'], skinnable:false});
132 changes: 123 additions & 9 deletions sandbox/dd/js/dd-plugin.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
YUI.add('dd-plugin', function(Y) {


/**
* Simple Drag plugin that can be attached to a Node via the plug method.
* Simple Drag plugin that can be attached to a Node or Widget via the plug method.
* @module dd
* @submodule dd-plugin
*/
/**
* Simple Drag plugin that can be attached to a Node or Widget via the plug method.
* @class Drag
* @extends DD.Drag
* @constructor
* @namespace Plugin
* @module dd
* @submodule dd-plugin
*/


var Drag = function(config) {
config.node = ((Y.Widget && config.host instanceof Y.Widget) ? config.host.get('boundingBox') : config.host);
Drag.superclass.constructor.call(this, config);
};
if (Y.Widget && config.host instanceof Y.Widget) {
config.node = config.host.get('boundingBox');
config.widget = config.host;
}
else {
config.node = config.host;
config.widget = false;
}
Drag.superclass.constructor.call(this, config);
},

EV_DRAG = 'drag:drag',
EV_DRAG_END = 'drag:end';

/**
* @property NAME
Expand All @@ -30,8 +42,110 @@ YUI.add('dd-plugin', function(Y) {
*/
Drag.NS = "dd";

Y.extend(Drag, Y.DD.Drag, {


/**
* refers to a Y.Widget if its the host, otherwise = false.
*
* @attribute _widget
* @private
*/
_widget: undefined,


/**
* refers to the [x,y] coordinate where the drag was stopped last
*
* @attribute _stoppedPosition
* @private
*/
_stoppedPosition: undefined,


/**
* Returns true if widget uses widgetPosition, otherwise returns false
*
* @method _usesWidgetPosition
* @private
*/
_usesWidgetPosition: function(widget) {
var r = false;
if (widget) {
r = (widget.hasImpl && widget.hasImpl(Y.WidgetPosition)) ? true : false;
}
return r;
},


/**
* Sets up event listeners on drag events if interacting with a widget
*
* @method initializer
* @protected
*/
initializer: function(config) {


this._widget = config.widget;

//if this thing is a widget, and it uses widgetposition...
if (this._usesWidgetPosition(this._widget)) {

//set the x,y on the widget's ATTRS
this.on(EV_DRAG, this._setWidgetCoords);

//store the new position that the widget ends up on
this.on(EV_DRAG_END, this._updateStopPosition);
}


},

/**
* Updates x,y or xy attributes on widget based on where the widget is dragged
*
* @method initializer
* @param {EventFacade} e Event Facade
* @private
*/
_setWidgetCoords: function(e) {

//get the last position where the widget was, or get the starting point
var nodeXY = this._stoppedPosition || e.target.nodeXY,
realXY = e.target.realXY,

//amount moved = [(x2 - x1) , (y2 - y1)]
movedXY = [realXY[0] - nodeXY[0], realXY[1] - nodeXY[0]];

//if both have changed..
if (movedXY[0] !== 0 && movedXY[1] !== 0) {
this._widget.set('xy', realXY);
}

//if only x is 0, set the Y
else if (movedXY[0] === 0) {
this._widget.set('y',realXY[1]);
}

//otherwise, y is 0, so set X
else if (movedXY[1] === 0){
this._widget.set('x', realXY[0]);
}
},

/**
* Updates the last position where the widget was stopped.
*
* @method updateStopPosition
* @param {EventFacade} e Event Facade
* @private
*/
updateStopPosition: function(e) {
this._stoppedPosition = e.target.realXY;
}
});

Y.extend(Drag, Y.DD.Drag);
Y.namespace('Plugin');
Y.Plugin.Drag = Drag;

Expand Down
9 changes: 6 additions & 3 deletions sandbox/dd/js/ddm-base.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
YUI.add('dd-ddm-base', function(Y) {

/**
* Provides the base Drag Drop Manger required for making a Node draggable.
* @module dd
* @submodule dd-ddm-base
*/
/**
* Provides the base Drag Drop Manger required for making a Node draggable.
* @class DDM
* @extends Base
* @constructor
* @namespace DD
* @module dd
* @submodule dd-ddm-base
*/

var DDMBase = function() {
Expand Down Expand Up @@ -217,7 +220,7 @@ YUI.add('dd-ddm-base', function(Y) {
* @private
* @method _move
* @description Internal listener for the mousemove DOM event to pass to the Drag's move method.
* @param {EventFacade} ev The Dom mousemove Event
* @param {Event.Facade} ev The Dom mousemove Event
*/
_move: function(ev) {
if (this.activeDrag) {
Expand Down
3 changes: 0 additions & 3 deletions sandbox/dd/js/ddm-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,6 @@ YUI.add('dd-ddm-drop', function(Y) {
return drop;
}
}, true);





}, '@VERSION@' ,{requires:['dd-ddm'], skinnable:false});
13 changes: 9 additions & 4 deletions sandbox/dd/js/delegate.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
YUI.add('dd-delegate', function(Y) {

/**
* Provides the ability to drag multiple nodes under a container element using only one Y.DD.Drag instance as a delegate.
* @module dd
* @submodule dd-delegate
*/
/**
* Provides the ability to drag multiple nodes under a container element using only one Y.DD.Drag instance as a delegate.
* @class Delegate
* @extends Base
* @constructor
* @namespace DD
* @module dd
* @submodule dd-delegate
*/


Expand Down Expand Up @@ -113,7 +116,8 @@ YUI.add('dd-delegate', function(Y) {
initializer: function(cfg) {
this._handles = [];
//Create a tmp DD instance under the hood.
var conf = Y.clone(this.get('dragConfig') || {}),
//var conf = Y.clone(this.get('dragConfig') || {}),
var conf = this.get('dragConfig') || {},
cont = this.get(CONT);

conf.node = _tmpNode.cloneNode(true);
Expand Down Expand Up @@ -307,7 +311,7 @@ YUI.add('dd-delegate', function(Y) {
* @for DDM
* @method getDelegate
* @description Get a delegate instance from a container node
* @returns Y.DD.Delegate
* @return Y.DD.Delegate
*/
getDelegate: function(node) {
var del = null;
Expand All @@ -324,4 +328,5 @@ YUI.add('dd-delegate', function(Y) {
Y.namespace('DD');
Y.DD.Delegate = Delegate;


}, '@VERSION@' ,{requires:['dd-drag', 'event-mouseenter'], skinnable:false});
3 changes: 2 additions & 1 deletion sandbox/dd/js/drag-gestures.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
YUI.add('drag-gestures', function(Y) {
/**

/*
* This module is the conditional loaded DD file to support gesture events.
* In the event that DD is loaded onto a device that support touch based events
* This module is loaded and over rides 2 key methods on DD.Drag and DD.DDM to
Expand Down
Loading

0 comments on commit 18e8268

Please sign in to comment.