r104528 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104527‎ | r104528 | r104529 >
Date:01:13, 29 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Use spacer element for floating toolbar instead of relaying on padding-top of next sibiling.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/views/es.ToolbarView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/views/es.ToolbarView.js
@@ -19,32 +19,29 @@
2020
2121 this.$ = $container;
2222 this.surfaceView = surfaceView;
 23+ this.$spacer = $('<div>');
 24+ this.$.after( this.$spacer );
2325
2426 /*
2527 * This code is responsible for switching toolbar into floating mode when scrolling (with
26 - * keyboard or mouse). It assumes that original padding-top of next sibiling element is 0
27 - * (if that will be a problem in future we may introduce spacer element and set it height,
28 - * since even remembering original padding-top is not a solution because it may be set in em
29 - * instead of px).
 28+ * keyboard or mouse).
3029 */
3130 $window.scroll( function() {
3231 if ( _this.surfaceView.dimensions.scrollTop >= _this.surfaceView.dimensions.toolbarTop ) {
3332 if ( ! _this.$.hasClass( 'float' ) ) {
3433 var left = _this.$.offset().left,
3534 right = $window.width() - _this.$.outerWidth() - left;
36 -
3735 _this.$.css( 'right', right );
3836 _this.$.css( 'left', left );
39 -
4037 _this.$.addClass( 'float' );
41 - _this.$.next().css( 'padding-top', _this.$.height() );
 38+ _this.$spacer.height( _this.$.height() );
4239 }
4340 } else {
4441 if ( _this.$.hasClass( 'float' ) ) {
4542 _this.$.css( 'right', 0 );
4643 _this.$.css( 'left', 0 );
4744 _this.$.removeClass( 'float' );
48 - _this.$.next().css( 'padding-top', 0 );
 45+ _this.$spacer.height(0);
4946 }
5047 }
5148 } );

Status & tagging log