Merge "Add container option to popup widgets"

This commit is contained in:
jenkins-bot 2013-07-03 01:32:41 +00:00 committed by Gerrit Code Review
commit e32f19ce36
2 changed files with 4 additions and 3 deletions

View file

@ -29,7 +29,7 @@ ve.ui.Context = function VeUiContext( surface, config ) {
this.embedded = false;
this.selection = null;
this.toolbar = null;
this.popup = new ve.ui.PopupWidget( { '$$': this.$$, surface: this.surface } );
this.popup = new ve.ui.PopupWidget( { '$$': this.$$, '$container': this.surface.getView().$ } );
this.$menu = this.$$( '<div>' );
this.inspectors = new ve.ui.WindowSet( surface, ve.ui.inspectorFactory );

View file

@ -13,6 +13,7 @@
*
* @constructor
* @param {Object} [config] Config options
* @cfg {jQuery} [$container] Container to make popup positioned relative to
* @cfg {boolean} [autoClose=false] Popup auto-closes when it loses focus
*/
ve.ui.PopupWidget = function VeUiPopupWidget( config ) {
@ -25,8 +26,8 @@ ve.ui.PopupWidget = function VeUiPopupWidget( config ) {
// Properties
this.visible = false;
this.$callout = this.$$( '<div>' );
this.$container = config.$container || this.$$( 'body' );
this.$body = this.$$( '<div>' );
this.surface = config.surface;
this.transitionTimeout = null;
this.align = config.align || 'center';
this.autoClose = !!config.autoClose;
@ -153,7 +154,7 @@ ve.ui.PopupWidget.prototype.display = function ( x, y, width, height, transition
}
// Prevent viewport clipping, using padding between body and popup edges
overlapRight = this.surface.view.$.outerWidth( true ) - ( x + ( width + left + ( padding * 2 ) ) );
overlapRight = this.$container.outerWidth( true ) - ( x + ( width + left + ( padding * 2 ) ) );
overlapLeft = x + ( left - ( padding * 2 ) );
if ( overlapRight < 0 ) {
overlapOffset = overlapRight;