Ticket #29492: 29492.patch
File 29492.patch, 3.6 KB (added by , 9 years ago) |
---|
-
src/wp-admin/js/editor-expand.js
161 161 return; 162 162 } 163 163 164 editor.show = function() { 165 this.fire( 'beforeShow' ); 166 Object.getPrototypeOf( editor ).show.apply( this, arguments ); 167 }; 168 169 editor.hide = function() { 170 this.fire( 'beforeHide' ); 171 Object.getPrototypeOf( editor ).hide.apply( this, arguments ); 172 }; 173 164 174 // Copy the editor instance. 165 175 mceEditor = editor; 166 176 … … 248 258 } 249 259 } 250 260 251 // Adjust when switching editor modes. 252 function mceShow() { 253 $window.on( 'scroll.mce-float-panels', hideFloatPanels ); 261 function mceBeforeShow() { 262 var height = $textEditor.height(), 263 scrollTop = $window.scrollTop(), 264 scrollEditorTop = scrollTop - $textEditor.offset().top + 265 heights.adminBarHeight + heights.toolsHeight + heights.textTopHeight, 266 percentageScrolled = scrollEditorTop / height; 267 268 editor.once( 'show', function() { 269 setTimeout( function() { 270 editor.execCommand( 'wpAutoResize' ); 271 adjust(); 254 272 255 setTimeout( function() { 256 editor.execCommand( 'wpAutoResize' ); 257 adjust(); 258 }, 300 ); 273 if ( percentageScrolled > 0 ) { 274 height = $visualEditor.height(), 275 scrollEditorTop = Math.round( height * percentageScrolled ); 276 scrollTop = scrollEditorTop + $visualEditor.offset().top - 277 ( heights.adminBarHeight + heights.toolsHeight ); 278 279 $window.scrollTop( scrollTop ); 280 } 281 }, 300 ); 282 } ); 259 283 } 260 284 261 function mceHide() { 262 $window.off( 'scroll.mce-float-panels' ); 285 function mceBeforeHide() { 286 var height = $visualEditor.height(), 287 scrollTop = $window.scrollTop(), 288 scrollEditorTop = scrollTop - $visualEditor.offset().top + 289 heights.adminBarHeight + heights.toolsHeight, 290 percentageScrolled = scrollEditorTop / height; 263 291 264 setTimeout( function() { 265 var top = $contentWrap.offset().top; 292 editor.once( 'hide', function() { 293 setTimeout( function() { 294 textEditorResize(); 295 adjust(); 266 296 267 if ( window.pageYOffset > top ) { 268 window.scrollTo( window.pageXOffset, top - heights.adminBarHeight ); 269 } 297 if ( percentageScrolled > 0 ) { 298 height = $textEditor.height(), 299 scrollEditorTop = Math.round( height * percentageScrolled ); 300 scrollTop = scrollEditorTop + $textEditor.offset().top - 301 ( heights.adminBarHeight + heights.toolsHeight + heights.textTopHeight ); 270 302 271 textEditorResize();272 adjust();273 }, 100 );303 $window.scrollTop( scrollTop ); 304 } 305 }, 100 ); 274 306 275 adjust(); 307 adjust(); 308 } ); 276 309 } 277 310 278 311 function toggleAdvanced() { … … 281 314 282 315 mceBind = function() { 283 316 editor.on( 'keyup', mceKeyup ); 284 editor.on( ' show', mceShow );285 editor.on( ' hide', mceHide );317 editor.on( 'beforeShow', mceBeforeShow ); 318 editor.on( 'beforeHide', mceBeforeHide ); 286 319 editor.on( 'wp-toolbar-toggle', toggleAdvanced ); 287 320 // Adjust when the editor resizes. 288 321 editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', adjust ); … … 296 329 297 330 mceUnbind = function() { 298 331 editor.off( 'keyup', mceKeyup ); 299 editor.off( ' show', mceShow );300 editor.off( ' hide', mceHide );332 editor.off( 'beforeShow', mceBeforeShow ); 333 editor.off( 'beforeHide', mceBeforeHide ); 301 334 editor.off( 'wp-toolbar-toggle', toggleAdvanced ); 302 335 editor.off( 'setcontent wp-autoresize wp-toolbar-toggle', adjust ); 303 336 editor.off( 'undo redo', mceScroll );