r2777 - + Synchronization update (no new features).

r2777 - + Synchronization update (no new features).


Author: vtGavin
Date: Mon Jun 15 19:10:14 2009
New Revision: 2777
Modified:
branches/dev/positionTo/ui/utils.positionTo.js
Log:
+ Synchronization update (no new features).
Modified: branches/dev/positionTo/ui/utils.positionTo.js
==============================================================================
--- branches/dev/positionTo/ui/utils.positionTo.js    (original)
+++ branches/dev/positionTo/ui/utils.positionTo.js    Mon Jun 15 19:10:14 2009
@@ -13,22 +13,31 @@
$.fn.positionTo = function(parentElem, options){
    // !!!
    // think about implementing an indexing scheme using a document-bound
data tuple to
-    // reduce the need for constant selector invocation
+    // reduce the need for constant selector invocation.
+    //
+    // need this for multiple calls to positionTo without corresponding
reverts...
+    
+    // !!! possible parameter:
+    // remember initial positionTo or checkpoint the revert on each one
    
var positionTo_handlers = {
- scroll: function(){
- console.log('scroll detected');
+ mouseMove: function(){
+ console.log('mouse move detected');
}
};
var $parentElem = $(parentElem),
- parentOffset = $parentElem.offset(),
+ parentPosition = $parentElem.position(),
// calculate parent element coordinates and pad accordingly for
any border styling
parentElem_coords = {
- left: parentOffset.left,
- right: parentOffset.left + $parentElem.outerWidth(),
- top: parentOffset.top,
- bottom: parentOffset.top + $parentElem.outerHeight()
+ left: parentPosition.left
+         + parseInt($parentElem.css('margin-left').replace(/px/, '')),
+ right: parentPosition.left + $parentElem.outerWidth()
+ -
parseInt($parentElem.css('margin-right').replace(/px/, '')),
+ top: parentPosition.top
+         + parseInt($parentElem.css('margin-top').replace(/px/, '')),
+ bottom: parentPosition.top + $parentElem.outerHeight()
+         -
parseInt($parentElem.css('margin-bottom').replace(/px/, ''))
};
this.data('positionTo_uniqueNodeID', {
@@ -48,10 +57,10 @@
});
// set the pertinent ordinal sibling for this positionable element
before it is appended
- // to the body
+ // to the DOM just after the parent
// !!!
- $('body').append(this);
+ $parentElem.after(this);
// prep this element for being positioned
this.css('display', 'block')
@@ -60,14 +69,6 @@
// !!! arbitrarily position the element
this.css('left', parentElem_coords.right + 'px')
.css('top', parentElem_coords.top + 'px');
-
- // bind document and all 'parent' parent divs to scroll event and
ensure that position
- // is adjusted to match the new scroll left/top values
- $(document).bind('scroll.positionTo_uniqueNodeID',
positionTo_handlers.scroll);
- $parentElem.parents().each(function(ctr){
- $(this).bind('scroll.positionTo_uniqueNodeID',
positionTo_handlers.scroll)
- .addClass('positionTo_tagged_uniqueNodeID');
- });
};
/**
@@ -117,10 +118,6 @@
     .css('right', originalCSS.right)
     .css('top', originalCSS.top)
     .css('bottom', originalCSS.bottom);
-    
- $(document).unbind('.positionTo_uniqueNodeID');
- $('.positionTo_tagged_uniqueNodeID').unbind('.positionTo_uniqueNodeID')
- .removeClass('positionTo_tagged_uniqueNodeID');
this.removeData('positionTo_uniqueNodeID');
}