Merge "(bug 25830) fix JS preview causing the page to "jump""
authorKaldari <rkaldari@wikimedia.org>
Fri, 31 Aug 2012 23:53:21 +0000 (23:53 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 31 Aug 2012 23:53:21 +0000 (23:53 +0000)
1  2 
skins/common/preview.js

@@@ -7,15 -9,32 +9,32 @@@
  
                $( mw ).trigger( 'LivePreviewPrepare' );
  
+               var $wikiPreview = $( '#wikiPreview' );
+               $( '#mw-content-text' ).css( 'position', 'relative' );
+               if ( $wikiPreview.is( ':visible' ) ) {
+                       previewShowing = true;
+               }
+               // show #wikiPreview if it's hidden (if it is hidden, it's also empty, so nothing changes in the rendering)
+               // to be able to scroll to it
+               $wikiPreview.show();
+               // Jump to where the preview will appear
+               $wikiPreview[0].scrollIntoView();
                var postData = $('#editform').formToArray();
 -              postData.push( { 'name' : 'wpPreview', 'value' : '1' } );
 +              postData.push( { 'name' : e.target.name, 'value' : '1' } );
  
                // Hide active diff, used templates, old preview if shown
 -              var copyElements = ['#wikiPreview', '.templatesUsed', '.hiddencats',
 -                                                      '#catlinks'];
 +              var copyElements = ['#wikiPreview', '#wikiDiff', '.templatesUsed', '.hiddencats',
 +                                                      '#catlinks', '#p-lang', '.mw-summary-preview'];
                var copySelector = copyElements.join(',');
  
-               $.each( copyElements, function(k,v) { $(v).fadeOut('fast'); } );
+               $.each( copyElements, function( k, v ) {
+                       $( v ).fadeTo( 'fast', 0.4 );
+               } );
  
                // Display a loading graphic
                var loadSpinner = $('<div class="mw-ajax-loader"/>');