r2841 - positionTo: Fixed indentation.

r2841 - positionTo: Fixed indentation.


Author: scott.gonzalez
Date: Thu Jun 25 10:21:56 2009
New Revision: 2841
Modified:
branches/dev/positionTo/ui/utils.positionTo.js
Log:
positionTo: Fixed indentation.
Modified: branches/dev/positionTo/ui/utils.positionTo.js
==============================================================================
--- branches/dev/positionTo/ui/utils.positionTo.js    (original)
+++ branches/dev/positionTo/ui/utils.positionTo.js    Thu Jun 25 10:21:56 2009
@@ -8,137 +8,137 @@
* TODO: create document page for positionTo and add link here
*/
$.fn.positionTo = function(options){
- options = $.extend({
- my: 'left top',
- at: 'left bottom',
- offset: '0 0',
- collisionDetect: 'flip',
- stackFix: true
- }, options);
-
- var $targetElem = $(options.of);
-
- // if: the specified target selector (of) does not resolve to an
element in the DOM
- // then: return an error condition
- if ($targetElem.length <= 0)
- {
- return false;
- }
-
- var targetPosition = $targetElem.offset();
-
- // if: a parent node exists for the target node
- // then: estimate the target node's position by comparing their
relative absolute offsets
- if ($targetElem.parent().length)
- {
- $targetElem.parent().css('position', 'relative');
-
- var targetParentOffset = $targetElem.parent().offset();
- targetPosition = {
- top: targetPosition.top - targetParentOffset.top,
- left: targetPosition.left - targetParentOffset.left
- };
- }
-
- targetPosition.right = targetPosition.left + $targetElem.outerWidth();
- targetPosition.bottom = targetPosition.top + $targetElem.outerHeight();
-
- $targetElem.after(this);
-
- // prep this element for being positioned
- this.css('display', 'block')
- .css('position', 'absolute');
-
- var positionableOffset_x = 0,
- positionableOffset_y = 0,
- array_positionableAnchor_chunks = options.my.split(' '),
- array_targetAnchor_chunks = options.at.split(' '),
- array_offset_chunks =
options.offset.replace(/px/gi, '').split(' ');
-
- if (array_positionableAnchor_chunks.length == 2)
- {     
-     // now, figure out the horizontal positionable offset
-     switch (array_positionableAnchor_chunks[0])
-     {
-         case 'center':
-             positionableOffset_x -= (this.outerWidth() / 2);
-             break;
-             
-         case 'right':
-             positionableOffset_x -= this.outerWidth();
-             break;
-     }
-     
-     // figure out the vertical positionable offset
-     switch(array_positionableAnchor_chunks[1])
-     {     
-         case 'middle':
-             positionableOffset_y -= (this.outerHeight() / 2);
-             break;
-             
-         case 'bottom':
-             positionableOffset_y -= this.outerHeight();
-             break;
-     }
- }
-
- if (array_targetAnchor_chunks.length == 2)
- {     
-     // figure out the horizontal target offset
-     switch (array_targetAnchor_chunks[0])
-     {
-         case 'center':
-             positionableOffset_x += (targetPosition.right -
targetPosition.left) / 2;
-             break;
-             
-         case 'right':
-             positionableOffset_x += (targetPosition.right -
targetPosition.left);
-             break;
-     }
-     
-     // figure out the vertical target offset
-     switch (array_targetAnchor_chunks[1])
-     {
-         case 'middle':
-             positionableOffset_y += (targetPosition.bottom -
targetPosition.top) / 2;
-             break;
-             
-         case 'bottom':
-             positionableOffset_y += (targetPosition.bottom -
targetPosition.top);
-             break;
-     }
- }
-
- if (array_offset_chunks.length == 2)
- {     
-     var offset_horizontal_px = parseInt(array_offset_chunks[0]);
-     // if: a valid integer was specified for the horizontal offset
-     // then: apply it to the calculated horizontal offset
-     if (!isNaN(offset_horizontal_px))
-     {
-         positionableOffset_x += offset_horizontal_px;
-     }
-     
-     var offset_vertical_px = parseInt(array_offset_chunks[1]);
-     // if: a valid integer was specified for the vertical offset
-     // then: apply it to the calculated vertical offset
-     if (!isNaN(offset_vertical_px))
-     {
-         positionableOffset_y += offset_vertical_px;
-     }
- }
- else if (array_offset_chunks.length == 1)
- {
- var offset_px = parseInt(array_offset_chunks[0]);
- // if: a valid integer was specified for the offset
- // then: apply it to the calculated horizontal and vertical offsets
- if (!isNaN(offset_px))
- {
- positionableOffset_x += offset_px;
- positionableOffset_y += offset_px;
- }
- }
-
- this.css('left', (targetPosition.left + positionableOffset_x) + 'px')
-     .css('top', (targetPosition.top + positionableOffset_y) + 'px');
+    options = $.extend({
+        my: 'left top',
+        at: 'left bottom',
+        offset: '0 0',
+        collisionDetect: 'flip',
+        stackFix: true
+    }, options);
+
+    var $targetElem = $(options.of);
+
+    // if: the specified target selector (of) does not resolve to an element
in the DOM
+    // then: return an error condition
+    if ($targetElem.length <= 0)
+    {
+        return false;
+    }
+
+    var targetPosition = $targetElem.offset();
+
+    // if: a parent node exists for the target node
+    // then: estimate the target node's position by comparing their relative
absolute offsets
+    if ($targetElem.parent().length)
+    {
+        $targetElem.parent().css('position', 'relative');
+
+        var targetParentOffset = $targetElem.parent().offset();
+        targetPosition = {
+            top: targetPosition.top - targetParentOffset.top,
+            left: targetPosition.left - targetParentOffset.left
+        };
+    }
+
+    targetPosition.right = targetPosition.left + $targetElem.outerWidth();
+    targetPosition.bottom = targetPosition.top + $targetElem.outerHeight();
+
+    $targetElem.after(this);
+
+    // prep this element for being positioned
+    this.css('display', 'block')
+        .css('position', 'absolute');
+
+    var positionableOffset_x = 0,
+        positionableOffset_y = 0,
+        array_positionableAnchor_chunks = options.my.split(' '),
+        array_targetAnchor_chunks = options.at.split(' '),
+        array_offset_chunks = options.offset.replace(/px/gi, '').split(' ');
+
+    if (array_positionableAnchor_chunks.length == 2)
+    {
+        // now, figure out the horizontal positionable offset
+        switch (array_positionableAnchor_chunks[0])
+        {
+            case 'center':
+                positionableOffset_x -= (this.outerWidth() / 2);
+                break;
+
+            case 'right':
+                positionableOffset_x -= this.outerWidth();
+                break;
+        }
+
+        // figure out the vertical positionable offset
+        switch(array_positionableAnchor_chunks[1])
+        {
+            case 'middle':
+                positionableOffset_y -= (this.outerHeight() / 2);
+                break;
+                
+            case 'bottom':
+            positionableOffset_y -= this.outerHeight();
+                break;
+        }
+}
+
+    if (array_targetAnchor_chunks.length == 2)
+    {
+        // figure out the horizontal target offset
+        switch (array_targetAnchor_chunks[0])
+        {
+            case 'center':
+                positionableOffset_x += (targetPosition.right - targetPosition.left) /
2;
+                break;
+
+            case 'right':
+                positionableOffset_x += (targetPosition.right - targetPosition.left);
+                break;
+        }
+
+        // figure out the vertical target offset
+        switch (array_targetAnchor_chunks[1])
+        {
+            case 'middle':
+                positionableOffset_y += (targetPosition.bottom - targetPosition.top) /
2;
+                break;
+
+            case 'bottom':
+                positionableOffset_y += (targetPosition.bottom - targetPosition.top);
+                break;
+        }
+    }
+
+    if (array_offset_chunks.length == 2)
+    {
+        var offset_horizontal_px = parseInt(array_offset_chunks[0]);
+        // if: a valid integer was specified for the horizontal offset
+        // then: apply it to the calculated horizontal offset
+        if (!isNaN(offset_horizontal_px))
+        {
+            positionableOffset_x += offset_horizontal_px;
+        }
+
+        var offset_vertical_px = parseInt(array_offset_chunks[1]);
+        // if: a valid integer was specified for the vertical offset
+        // then: apply it to the calculated vertical offset
+        if (!isNaN(offset_vertical_px))
+        {
+            positionableOffset_y += offset_vertical_px;
+        }
+    }
+    else if (array_offset_chunks.length == 1)
+    {
+        var offset_px = parseInt(array_offset_chunks[0]);
+        // if: a valid integer was specified for the offset
+        // then: apply it to the calculated horizontal and vertical offsets
+        if (!isNaN(offset_px))
+        {
+            positionableOffset_x += offset_px;
+            positionableOffset_y += offset_px;
+        }
+    }
+
+    this.css('left', (targetPosition.left + positionableOffset_x) + 'px')
+        .css('top', (targetPosition.top + positionableOffset_y) + 'px');
};