},
/**
* fire this manually after loading a grid in the table for example
- *
+ * @param {string} (left|right|top|bottom) where to try and put it
+ * @param {Boolean} try and move it if we cant get right position.
*/
- updatePosition : function(placement)
+ updatePosition : function(placement, try_move)
{
this.el.addClass(placement + ' roo-popover-' + placement);
if (!this.alignEl ) {
- return;
+ return false;
+ }
+
+ switch (placement) {
+ case 'right':
+ var exact = this.el.getAlignToXY(this.alignEl, 'tl-tr', [10,0]);
+ var offset = this.el.getAlignToXY(this.alignEl, 'tl-tr?',[10,0]);
+ if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
+ //normal display... or moved up/down.
+ this.setXY(offset);
+ var xy = this.alignEl.getAnchorXY('tr', false);
+ xy[0]+=2;xy[1]+=5;
+ this.arrowEl.setXY(xy);
+ return true;
+ }
+ return this.updatePosition('left', false);
+
+ case 'left':
+ var exact = this.el.getAlignToXY(this.alignEl, 'tr-tl', [-10,0]);
+ var offset = this.el.getAlignToXY(this.alignEl, 'tl-tr?',[-10,0]);
+ if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
+ //normal display... or moved up/down.
+ this.setXY(offset);
+ var xy = this.alignEl.getAnchorXY('tl', false);
+ xy[0]+=2;xy[1]+=5;
+ this.arrowEl.setXY(xy);
+ return true;
+ }
+ return this.updatePosition('right', false);
+
+
}
- switch ()
- this.el.alignTo(this.alignEl , this.alignment[0],this.alignment[1]);
// work out the pointy position.
var p1 = this.alignment[0].split('-').pop().replace('?','');
var xy = this.alignEl.getAnchorXY(p1, false);
xy[0]+=2;xy[1]+=5;
this.arrowEl.setXY(xy);
-
+ return true;
},
hide : function()