X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-bootstrap-debug.js;h=92cdce670752f97aba5802ea809f7f2c6b320cc4;hb=refs%2Fheads%2Fwip_alan_T6597_Popover_api_improvements;hp=1f91028a0e1d98455dad2e334b0df5b95127f464;hpb=0aa8fdb26c7c25cab2f4b3da56f3be842a1af420;p=roojs1 diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 1f91028a0e..92cdce6707 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -19877,15 +19877,14 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, { } + this.alignEl = on_el; + if (!this.el) { this.render(document.body); } - this.el.removeClass([ - 'fade','top','bottom', 'left', 'right','in', - 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right' - ]); + if (this.title === false) { this.headerEl.hide(); @@ -19895,11 +19894,9 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, { this.el.show(); this.el.dom.style.display = 'block'; - - this.el.addClass(placement + ' roo-popover-' + placement); - - if (on_el) { - this.updatePosition(); + + if (this.alignEl) { + this.updatePosition(this.placement, true); } else { // this is usually just done by the builder = to show the popoup in the middle of the scren. @@ -19933,12 +19930,20 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, { }, /** * 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 {string} (left|right|top|bottom) where to try and put it (use false to use the last one) * @param {Boolean} try and move it if we cant get right position. */ updatePosition : function(placement, try_move) { - this.el.addClass(placement + ' roo-popover-' + placement); + // allow for calling with no parameters + placement = placement ? placement : this.placement; + try_move = typeof(try_move) == 'undefined' ? true : try_move; + + this.el.removeClass([ + 'fade','top','bottom', 'left', 'right','in', + 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right' + ]); + this.el.addClass(placement + ' bs-popover-' + placement); if (!this.alignEl ) { return false; @@ -19948,24 +19953,65 @@ Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, { 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 (exact.equals(offset)) { - //normal display... - this.setXY(exact, this.preanim(arguments, 3)); - var xy = this.alignEl.getAnchorXY(p1, false); - + if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) { + //normal display... or moved up/down. + this.el.setXY(offset); + var xy = this.alignEl.getAnchorXY('tr', false); + xy[0]+=2;xy[1]+=5; + this.arrowEl.setXY(xy); + return true; } + // continue through... + 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, 'tr-tl?',[-10,0]); + if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) { + //normal display... or moved up/down. + this.el.setXY(offset); + var xy = this.alignEl.getAnchorXY('tl', false); + xy[0]-=10;xy[1]+=5; // << fix me + this.arrowEl.setXY(xy); + return true; + } + // call self... + return this.updatePosition('right', false); + + case 'top': + var exact = this.el.getAlignToXY(this.alignEl, 'b-t', [0,-10]); + var offset = this.el.getAlignToXY(this.alignEl, 'b-t?',[0,-10]); + if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) { + //normal display... or moved up/down. + this.el.setXY(offset); + var xy = this.alignEl.getAnchorXY('t', false); + xy[1]-=10; // << fix me + this.arrowEl.setXY(xy); + return true; + } + // fall through + return this.updatePosition('bottom', false); + + case 'bottom': + var exact = this.el.getAlignToXY(this.alignEl, 't-b', [0,10]); + var offset = this.el.getAlignToXY(this.alignEl, 't-b?',[0,10]); + if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) { + //normal display... or moved up/down. + this.el.setXY(offset); + var xy = this.alignEl.getAnchorXY('b', false); + xy[1]+=2; // << fix me + this.arrowEl.setXY(xy); + return true; + } + // fall through + return this.updatePosition('top', false); + } - - // 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 false; }, hide : function()