Author: pyaschenko
Date: 2010-04-07 13:27:33 -0400 (Wed, 07 Apr 2010)
New Revision: 16743
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/jquery.position.js
Log:
https://jira.jboss.org/jira/browse/RF-8507
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/jquery.position.js
===================================================================
---
root/framework/trunk/impl/src/main/resources/META-INF/resources/jquery.position.js 2010-04-07
00:19:36 UTC (rev 16742)
+++
root/framework/trunk/impl/src/main/resources/META-INF/resources/jquery.position.js 2010-04-07
17:27:33 UTC (rev 16743)
@@ -1,3 +1,9 @@
+/**
+ * @fileOverview jQuery setPosition Plugin to place elements on the page
+ * @author Pavel Yaschenko
+ * @version 0.5
+ */
+
// draft examples of usage
// jQuery('#tooltip').setPosition('#aaa',{from:'LB',
to:'AA'});
//
jQuery('#bbb').bind("click",function(e){jQuery('#tooltip').setPosition(e);});
@@ -14,12 +20,49 @@
// event
//
// params:
+// type: string // position type
// collision: string // not implemented
// offset: array [x,y] // implemented only for noPositionType
// from: string // place target relative of source
// to: string // direction for target
+ /**
+ * @name jQuery
+ * @namespace jQuery
+ * */
+
(function($) {
+ /**
+ * Place DOM element relative to another element or using position parameters
+ *
+ * @example
jQuery('#tooltip').setPosition('#myDiv',{from:'LB',
to:'AA'});
+ * @example
jQuery('#myClickDiv').bind("click",function(e){jQuery('#tooltip').setPosition(e);});
+ *
+ * @function
+ * @name jQuery#setPosition
+ *
+ * @param {object} source - object that provides information about new position.
<p>
+ * accepts:
+ * <ul>
+ * <li>jQuery selector or object</li>
+ * <li>object with id:
<code>{id:'myDiv'}</code></li>
+ * <li>object with region settings: <code>{left:0, top:0, width:100,
height:100}</code></li>
+ * <li>DOM Element</li>
+ * <li>Event object</li>
+ * </ul>
+ * </p>
+ * @param {object} params - position parameters:
+ * <dl><dt>
+ * @param {string} [params.type] - position type that defines positioning and auto
positioning rules ["TOOLTIP","DROPDOWN"]</dt><dt>
+ * @param {string} [params.collision] - not implemented yet</dt><dt>
+ * @param {array} [params.offset] - provides array(2) with x and y for manually
position definition<br/>
+ * affects only if "type", "from" and "to" not
defined</dt><dt>
+ * @param {string} [params.from] - place target relative of source // draft
definition</dt><dt>
+ * @param {string} [params.to] - direction for target // draft definition</dt>
+ * </blockquote>
+ *
+ * @return {jQuery} jQuery wrapped DOM elements
+ * */
$.fn.setPosition = function(source, params) {
var stype = typeof source;
if (stype == "object" || stype == "string") {
@@ -54,6 +97,7 @@
};
var re = /^(left|right)-(top|buttom|auto)$/i;
+ // TODO: make it private
$.PositionTypes = {
// horisontal constants: L-left, R-right, C-center, A-auto
// vertical constants: T-top, B-bottom, M-middle, A-auto
@@ -62,6 +106,15 @@
DROPDOWN:{from:"AA", to:"AA", auto:["LBRB",
"LTRT", "RBLB", "RTLT"]}
};
+ /**
+ * Add or replace position type rules for auto positioning.
+ * Does not fully determinated with parameters yet, only draft version.
+ *
+ * @function
+ * @name jQuery.addPositionType
+ * @param {string} type - name of position rules
+ * @param {object} option - options of position rules
+ * */
$.addPositionType = function (type, options) {
// TODO: change [options] to [from, to, auto]
/*var obj = {};