Merge "LanguageSettings: Simplify positioning code"

This commit is contained in:
jenkins-bot
2016-08-16 11:49:44 +00:00
committed by Gerrit Code Review

View File

@@ -149,8 +149,7 @@
var $this = $( this ); var $this = $( this );
$this.data( 'module' ).render(); $this.data( 'module' ).render();
// Re-position the window and scroll in to view if required. languageSettings.$window.scrollIntoView();
languageSettings.position();
$settingsMenuItems.find( '.menu-section' ).removeClass( 'active' ); $settingsMenuItems.find( '.menu-section' ).removeClass( 'active' );
$this.addClass( 'active' ); $this.addClass( 'active' );
} ); } );
@@ -163,24 +162,12 @@
}, },
position: function () { position: function () {
var top, pos, left, this.top = this.top || this.$element.offset().top + this.$element.outerHeight();
languageSettings = this; this.left = this.left || '25%';
pos = $.extend( {}, this.$element.offset(), {
height: this.$element[ 0 ].offsetHeight
} );
top = this.top || pos.top + pos.height;
left = this.left || '25%';
this.$window.css( { this.$window.css( {
top: top, top: this.top,
left: left left: this.left
} ); } );
setTimeout( function () {
// Don't mess up height calculations with parallel css loading
// See: http://ejohn.org/blog/how-javascript-timers-work/
languageSettings.$window.scrollIntoView();
}, 0 );
}, },
i18n: function () { i18n: function () {
@@ -188,7 +175,7 @@
}, },
show: function () { show: function () {
var languageSettings = this; this.position();
if ( !this.initialized ) { if ( !this.initialized ) {
this.render(); this.render();
@@ -197,18 +184,14 @@
// Close other modal windows which listen to click events outside them // Close other modal windows which listen to click events outside them
$( 'html' ).click(); $( 'html' ).click();
this.i18n(); this.i18n();
this.shown = true;
this.$window.show();
// Every time we show this window, make sure the current // Every time we show this window, make sure the current
// settings panels is up-to-date. So just click on active menu item. // settings panels is up-to-date. So just click on active menu item.
this.$window.find( '.settings-menu-items > .active' ).click(); this.$window.find( '.settings-menu-items > .active' ).click();
this.position();
setTimeout( function () { this.shown = true;
// Don't mess up height calculations with parallel css loading this.$window.show();
// See: http://ejohn.org/blog/how-javascript-timers-work/ this.visible();
languageSettings.visible(); this.$window.scrollIntoView();
}, 0 );
}, },
/** /**