align-plugin.js revision b0614bd702ed299874c87fd5d4d48bccda498c73
/**
* Provides advanced positioning support for Node via a Plugin
* for centering and alignment.
* @module shim-plugin
*/
var OFFSET_WIDTH = 'offsetWidth',
OFFSET_HEIGHT = 'offsetHeight',
/**
* Node plugin which can be used to align a node with another node,
* region, or the viewport.
*
* @class Plugin.Align
* @param {Object} User configuration object
*/
// TODO: allow for boundingBox
};
/**
* Aligns node with a point on another node or region.
* Possible alignment points are:
* <dl>
* <dt>tl</dt>
* <dd>top left</dd>
* <dt>tr</dt>
* <dd>top right</dd>
* <dt>bl</dt>
* <dd>bottom left</dd>
* <dt>br</dt>
* <dd>bottom right</dd>
* <dt>tc</dt>
* <dd>top center</dd>
* <dt>bc</dt>
* <dd>bottom center</dd>
* <dt>rc</dt>
* <dd>right center</dd>
* <dt>lc</dt>
* <dd>left center</dd>
* </dl>
* @method to
* @parm region {String || Node || HTMLElement || Object} The node or
* region to align with. Defaults to the viewport region.
* @parm regionPoint {String} The point of the region to align with.
* @parm point {String} The point of the node aligned to the region.
* @parm fixed {Boolean} Whether or not the node should re-align when
* the window is resized. Defaults to false.
*/
// default align point is node's top left
// cache original args for syncing
}
x = left,
y = top,
xy;
// align to region
switch(regionPoint) {
case 'tl':
break;
case 'tr':
x = right;
break;
case 'bl':
y = bottom;
break;
case 'br':
x = right;
y = bottom;
break;
case 'tc':
break;
case 'bc':
y = bottom;
break;
case 'lc':
break;
case 'rc':
x = right;
break;
case 'cc':
break;
}
// align our node
switch (point) {
case 'tl':
xy = [x, y];
break;
case 'tr':
break;
case 'bl':
break;
case 'br':
break;
case 'tc':
break;
case 'bc':
break;
case 'lc':
break;
case 'rc':
break;
case 'cc':
break;
default:
}
}
},
sync: function() {
},
_setStyleFixed: function(add) {
this._isStyleFixed = add;
},
_onresize: function() {
this.sync();
},
if (fixed) {
if (!this._fixing) {
this._fixing = true;
// use scroll listener for IE6 and IE quirks
// otherwise use position :fixed
} else if (!this._isStyleFixed) {
this._setStyleFixed(true);
}
}
} else { // "unfix"
this._fixing = false;
if (this._isStyleFixed) {
this._setStyleFixed(false);
}
}
},
/**
* Aligns the center of a node to the center of another node or region.
* @method center
* @parm region {Node || HTMLElement || Object} optional The node or
* region to align with. Defaults to the viewport region.
* @parm fixed {Boolean} Whether or not the node should re-align when
* the window is resized. If centering to viewport, this defaults
* to true, otherwise default is false.
*/
},
/**
* Removes the resize handler, if any. This is called automatically
* when unplugged from the host node.
* @method destroy
*/
destroy: function() {
Y.detach('alignfixed');
}
};
Y.namespace('Plugin');