r103886 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103885‎ | r103886 | r103887 >
Date:07:17, 22 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Make toolbar float when scrolling the page
Modified paths:
  • /trunk/extensions/VisualEditor/demo/es.css (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
@@ -113,7 +113,9 @@
114114 this.dimensions = {
115115 width: this.$.width(),
116116 height: this.$window.height(),
117 - scrollTop: this.$window.scrollTop()
 117+ scrollTop: this.$window.scrollTop(),
 118+ toolbarTop: $( '#es-toolbar' ).offset().top,
 119+ toolbarHeight: $( '#es-toolbar' ).height()
118120 };
119121
120122 // Re-render when resizing horizontally
@@ -131,6 +133,13 @@
132134
133135 this.$window.scroll( function() {
134136 _this.dimensions.scrollTop = _this.$window.scrollTop();
 137+ if ( _this.dimensions.scrollTop >= _this.dimensions.toolbarTop ) {
 138+ $( '#es-toolbar' ).addClass( 'float' );
 139+ $( '#es-panes' ).css( 'padding-top', _this.dimensions.toolbarHeight );
 140+ } else {
 141+ $( '#es-toolbar' ).removeClass( 'float' );
 142+ $( '#es-panes' ).css( 'padding-top', 0 );
 143+ }
135144 } );
136145 };
137146
@@ -680,8 +689,8 @@
681690 // Auto scroll to cursor
682691 var inputTop = this.$input.offset().top,
683692 inputBottom = inputTop + position.bottom - position.top;
684 - if ( inputTop < this.dimensions.scrollTop ) {
685 - this.$window.scrollTop( inputTop );
 693+ if ( inputTop - this.dimensions.toolbarHeight < this.dimensions.scrollTop ) {
 694+ this.$window.scrollTop( inputTop - this.dimensions.toolbarHeight );
686695 } else if ( inputBottom > ( this.dimensions.scrollTop + this.dimensions.height ) ) {
687696 this.$window.scrollTop( inputBottom - this.dimensions.height );
688697 }
Index: trunk/extensions/VisualEditor/demo/es.css
@@ -36,6 +36,22 @@
3737 background-position: bottom left;
3838 background-repeat: repeat-x;
3939 }
 40+#es-toolbar.float {
 41+ position: fixed;
 42+ left: 2em;
 43+ right: 2em;
 44+ top: 0;
 45+ z-index: 100;
 46+ border-top: none;
 47+ -webkit-border-top-right-radius: 0;
 48+ -moz-border-top-right-radius: 0;
 49+ -o-border-top-right-radius: 0;
 50+ border-top-right-radius: 0;
 51+ -webkit-border-top-left-radius: 0;
 52+ -moz-border-top-left-radius: 0;
 53+ -o-border-top-left-radius: 0;
 54+ border-top-left-radius: 0;
 55+}
4056 .es-showData #es-visual,
4157 .es-showData #es-previews {
4258 width: 50%;

Status & tagging log