widget-position-constrained-debug.js revision 29ad6902d913bb5cc1db6fc9ff780bb236a30ab2
/**
* Provides constrained XY positioning support for Widgets, through an extension.
*
* It builds on top of the widget-position module, to provide constrained positioning support.
*
* @module widget-position-constrained
*/
var CONSTRAIN = "constrain",
CONSTRAIN_XYCHANGE = "constrain|xyChange",
CONSTRAIN_CHANGE = "constrainChange",
PREVENT_OVERLAP = "preventOverlap",
ALIGN = "align",
EMPTY_STR = "",
BINDUI = "bindUI",
XY = "xy",
X_COORD = "x",
Y_COORD = "y",
VIEWPORT_REGION = "viewportRegion",
REGION = "region",
/**
* Widget extension, which can be used to add extended XY positioning support to the base Widget class,
* through the <a href="Base.html#method_build">Base.build</a> method. This extension requires that
* the WidgetPosition extension be added to the Widget (before WidgetPositionConstrained, if part of the same
* extension list passed to Base.build).
*
* @class WidgetPositionConstrained
* @param {Object} User configuration object
*/
function PositionConstrained(config) {
if (!this._posNode) {
Y.error("WidgetPosition needs to be added to the Widget, before WidgetPositionConstrained is added");
}
}
/**
* Static property used to define the default attribute
* configuration introduced by WidgetPositionConstrained.
*
* @property WidgetPositionConstrained.ATTRS
* @type Object
* @static
*/
constrain : {
value: null,
setter: "_setConstrain"
},
preventOverlap : {
value:false
}
};
x: {
"tltr": 1,
"blbr": 1,
"brbl": 1,
"trtl": 1
},
y : {
"trbr": 1,
"tlbl": 1,
"bltl": 1,
"brtr": 1
}
};
/**
* @method getConstrainedXY
* @param {Array} xy
* @param {Node | boolean} node
* @return {Array} The constrained XY values
*/
return [
];
},
/**
* @method constrain
* @param {Object} xy
* @param {Object} node
*/
var currentXY,
if (constraint) {
}
}
},
/**
* @method _setConstrain
* @param {Object} val
*/
_setConstrain : function(val) {
},
/**
* @method _constrain
* @param {Number} val
* @param {String} axis
* @param {Region} nodeRegion
* @param {Region} constrainingRegion
*/
if (constrainingRegion) {
if (this.get(PREVENT_OVERLAP)) {
}
if (nodeSize < regionSize) {
if (val < minConstraint) {
val = minConstraint;
} else if (val > maxConstraint) {
val = maxConstraint;
}
} else {
val = minConstraint;
}
}
}
return val;
},
/**
* @method _preventOverlap
* @param {Number} val
* @param {String} axis
* @param {Region} nodeRegion
* @param {Region} constrainingRegion
*/
if (alignRegion) {
spaceOnNearSide = (x) ? alignRegion.left - constrainingRegion.left : alignRegion.top - constrainingRegion.top;
spaceOnFarSide = (x) ? constrainingRegion.right - alignRegion.right : constrainingRegion.bottom - alignRegion.bottom;
}
}
} else {
}
}
}
return val;
},
/**
* Binds event listeners responsible for updating the UI state in response to
* Widget extended positioning related state changes.
* <p>
* This method is invoked after bindUI is invoked for the Widget class
* using YUI's aop infrastructure.
* </p>
* @method _bindUIPosConstrained
* @protected
*/
_bindUIPosConstrained : function() {
},
/**
* @method _afterConstrainChange
* @param {EventFacade} e
*/
_afterConstrainChange : function(e) {
this._enableConstraints(e.newVal);
},
/**
* @method enable or disable constraints listeners
* @param {Object} enable
*/
_enableConstraints : function(enable) {
if (enable) {
this.constrain();
} else if (this._cxyHandle) {
this._cxyHandle.detach();
}
},
/**
* Default attribute change listener for the align attribute, responsible
* for updating the UI, in response to attribute changes.
*
* @method _afterAlignChange
* @protected
* @param {EventFacade} e The event facade for the attribute change
*/
_constrainOnXYChange : function(e) {
if (!e.constrained) {
}
},
/**
* @method _getRegion
* @param {Node} (Optional) node
*/
_getRegion : function(node) {
var region;
if (!node) {
} else {
if (node) {
}
}
return region;
}
};