r104526 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104525‎ | r104526 | r104527 >
Date:00:58, 29 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Make toolbar float nicely in demo and in MediaWiki sandbox special page.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/views/es.ToolbarView.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/sandbox/sandbox.css (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
@@ -119,15 +119,7 @@
120120 }
121121 } );
122122 $window.scroll( function() {
123 - // FIXME: Is this code in the right place?
124123 _this.dimensions.scrollTop = $window.scrollTop();
125 - if ( _this.dimensions.scrollTop >= _this.dimensions.toolbarTop ) {
126 - $( '#es-toolbar' ).addClass( 'float' );
127 - $( '#es-panes' ).css( 'padding-top', _this.dimensions.toolbarHeight );
128 - } else {
129 - $( '#es-toolbar' ).removeClass( 'float' );
130 - $( '#es-panes' ).css( 'padding-top', 0 );
131 - }
132124 } );
133125
134126 // Configuration
Index: trunk/extensions/VisualEditor/modules/es/views/es.ToolbarView.js
@@ -13,12 +13,42 @@
1414 };
1515
1616 es.ToolbarView = function( $container, surfaceView ) {
17 - // Reference for use in closures
18 - var _this = this;
19 -
 17+ // References for use in closures
 18+ var _this = this,
 19+ $window = $( window );
 20+
2021 this.$ = $container;
2122 this.surfaceView = surfaceView;
 23+
 24+ /*
 25+ * 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).
 30+ */
 31+ $window.scroll( function() {
 32+ if ( _this.surfaceView.dimensions.scrollTop >= _this.surfaceView.dimensions.toolbarTop ) {
 33+ if ( ! _this.$.hasClass( 'float' ) ) {
 34+ var left = _this.$.offset().left,
 35+ right = $window.width() - _this.$.outerWidth() - left;
2236
 37+ _this.$.css( 'right', right );
 38+ _this.$.css( 'left', left );
 39+
 40+ _this.$.addClass( 'float' );
 41+ _this.$.next().css( 'padding-top', _this.$.height() );
 42+ }
 43+ } else {
 44+ if ( _this.$.hasClass( 'float' ) ) {
 45+ _this.$.css( 'right', 0 );
 46+ _this.$.css( 'left', 0 );
 47+ _this.$.removeClass( 'float' );
 48+ _this.$.next().css( 'padding-top', 0 );
 49+ }
 50+ }
 51+ } );
 52+
2353 this.tools = [
2454 {
2555 name: 'text',
Index: trunk/extensions/VisualEditor/modules/sandbox/sandbox.css
@@ -10,8 +10,6 @@
1111 background-repeat: repeat-x;
1212 }
1313 #es-toolbar.float {
14 - left: 0;
15 - right: 0;
1614 top: 0;
1715 position: fixed;
1816 -webkit-border-radius: 0;

Status & tagging log