Changeset 29336
- Timestamp:
- 08/01/2014 02:42:30 AM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/edit.css
r29292 r29336 356 356 background: transparent url(../images/resize.gif) no-repeat scroll right bottom; 357 357 width: 12px; 358 cursor: row-resize; 358 359 } 359 360 360 361 .rtl #content-resize-handle { 361 362 background: transparent url(../images/resize-rtl.gif) no-repeat scroll left bottom; 363 } 364 365 .wp-editor-expand #content-resize-handle { 366 display: none; 367 } 368 369 #postdivrich #content { 370 resize: none; 362 371 } 363 372 -
trunk/src/wp-admin/edit-form-advanced.php
r29180 r29336 491 491 if ( post_type_supports($post_type, 'editor') ) { 492 492 ?> 493 <div id="postdivrich" class="postarea edit-form-section ">493 <div id="postdivrich" class="postarea edit-form-section<?php if ( get_user_setting( 'editor_expand', 'on' ) === 'on' ) { echo ' wp-editor-expand'; } ?>"> 494 494 495 495 <?php wp_editor( $post->post_content, 'content', array( … … 500 500 'tinymce' => array( 501 501 'resize' => false, 502 'wp_autoresize_on' => ! empty( $_wp_autoresize_on),502 'wp_autoresize_on' => ( ! empty( $_wp_autoresize_on ) && get_user_setting( 'editor_expand', 'on' ) === 'on' ), 503 503 'add_unload_trigger' => false, 504 504 ), -
trunk/src/wp-admin/includes/screen.php
r29280 r29336 1111 1111 endfor; ?> 1112 1112 </div> 1113 <div class="editor-expand hidden"> 1114 <label for="editor-expand-toggle"> 1115 <input type="checkbox" id="editor-expand-toggle" <?php checked( get_user_setting( 'editor_expand', 'on' ) === 'on' ); ?> /> 1116 <?php _e( 'Expand the editor to match the window height.' ); ?></label> 1117 </div> 1113 1118 <?php 1114 1119 } -
trunk/src/wp-admin/js/editor-expand.js
r29302 r29336 7 7 $document = $( document ), 8 8 $adminBar = $( '#wpadminbar' ), 9 $wrap = $( '#postdivrich' ), 9 10 $contentWrap = $( '#wp-content-wrap' ), 10 11 $tools = $( '#wp-content-editor-tools' ), … … 16 17 $bottom = $( '#post-status-info' ), 17 18 $statusBar, 18 buffer = 200,19 19 fullscreen = window.wp.editor && window.wp.editor.fullscreen, 20 editorInstance, 20 mceEditor, 21 mceBind = function(){}, 22 mceUnbind = function(){}, 21 23 fixedTop = false, 22 24 fixedBottom = false; 23 25 24 26 $textEditorClone.insertAfter( $textEditor ); 25 26 // use to enable/disable27 $contentWrap.addClass( 'wp-editor-expand' );28 $( '#content-resize-handle' ).hide();29 27 30 28 $textEditorClone.css( { … … 38 36 } ); 39 37 40 $textEditor.on( 'focus input propertychange', function() { 41 textEditorResize(); 42 } ); 43 44 $textEditor.on( 'keyup', function( event ) { 38 function textEditorKeyup( event ) { 45 39 var VK = jQuery.ui.keyCode, 46 40 key = event.keyCode, … … 79 73 window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom ); 80 74 } 81 } );75 } 82 76 83 77 function textEditorResize() { 84 if ( editorInstance && ! editorInstance.isHidden() ) {78 if ( mceEditor && ! mceEditor.isHidden() ) { 85 79 return; 86 80 } … … 115 109 116 110 // Copy the editor instance. 117 editorInstance= editor;111 mceEditor = editor; 118 112 119 113 // Set the minimum height to the initial viewport height. … … 125 119 $statusBar = $contentWrap.find( '.mce-statusbar' ).filter( ':visible' ); 126 120 127 function getCursorOffset() {121 function mceGetCursorOffset() { 128 122 var node = editor.selection.getNode(), 129 123 view, offset; … … 144 138 // Some browsers will scroll to the middle, 145 139 // others to the top/bottom of the *window* when moving the cursor out of the viewport. 146 editor.on( 'keyup', function( event ) {140 function mceKeyup( event ) { 147 141 var VK = tinymce.util.VK, 148 142 key = event.keyCode, 149 offset = getCursorOffset(),143 offset = mceGetCursorOffset(), 150 144 windowHeight = $window.height(), 151 145 buffer = 10, … … 173 167 window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom ); 174 168 } 175 } );169 } 176 170 177 171 // Adjust when switching editor modes. 178 editor.on( 'show', function() {172 function mceShow() { 179 173 setTimeout( function() { 180 174 editor.execCommand( 'wpAutoResize' ); 181 175 adjust(); 182 176 }, 300 ); 183 } );184 185 editor.on( 'hide', function() {177 } 178 179 function mceHide() { 186 180 textEditorResize(); 187 181 adjust(); 188 } ); 189 190 // Adjust when the editor resizes. 191 editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', function() { 192 adjust(); 193 } ); 194 195 // And adjust "immediately". 196 // Allow some time to load CSS etc. 197 initialResize( adjust ); 182 } 183 184 mceBind = function() { 185 editor.on( 'keyup', mceKeyup ); 186 editor.on( 'show', mceShow ); 187 editor.on( 'hide', mceHide ); 188 // Adjust when the editor resizes. 189 editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', adjust ); 190 }; 191 192 mceUnbind = function() { 193 editor.off( 'keyup', mceKeyup ); 194 editor.off( 'show', mceShow ); 195 editor.off( 'hide', mceHide ); 196 editor.off( 'setcontent wp-autoresize wp-toolbar-toggle', adjust ); 197 }; 198 199 if ( $wrap.hasClass( 'wp-editor-expand' ) ) { 200 // Adjust "immediately" 201 mceBind(); 202 initialResize( adjust ); 203 } 198 204 } ); 199 205 … … 211 217 adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0, 212 218 resize = type !== 'scroll', 213 visual = ( editorInstance && ! editorInstance.isHidden() ), 219 visual = ( mceEditor && ! mceEditor.isHidden() ), 220 buffer = 200, 214 221 $top, $editor, 215 222 toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight; … … 328 335 } 329 336 337 function fullscreenHide() { 338 textEditorResize(); 339 adjust(); 340 } 341 330 342 function initialResize( callback ) { 331 343 for ( var i = 1; i < 6; i++ ) { … … 334 346 } 335 347 336 // Adjust when the window is scrolled or resized. 337 $window.on( 'scroll.editor-expand resize.editor-expand', function( event ) { 338 adjust( event.type ); 339 } ); 340 341 // Adjust when entering/exiting fullscreen mode. 342 fullscreen && fullscreen.pubsub.subscribe( 'hidden', function() { 343 textEditorResize(); 348 function on() { 349 // Scroll to the top when triggering this from JS. 350 // Ensures toolbars are pinned properly. 351 if ( window.pageYOffset && window.pageYOffset > 130 ) { 352 window.scrollTo( window.pageXOffset, 0 ); 353 } 354 355 $wrap.addClass( 'wp-editor-expand' ); 356 357 // Adjust when the window is scrolled or resized. 358 $window.on( 'scroll.editor-expand resize.editor-expand', function( event ) { 359 adjust( event.type ); 360 } ); 361 362 // Adjust when collapsing the menu, changing the columns, changing the body class. 363 $document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ); 364 365 $textEditor.on( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize ); 366 $textEditor.on( 'keyup.editor-expand', textEditorKeyup ); 367 mceBind(); 368 369 // Adjust when entering/exiting fullscreen mode. 370 fullscreen && fullscreen.pubsub.subscribe( 'hidden', fullscreenHide ); 371 372 if ( mceEditor ) { 373 mceEditor.settings.wp_autoresize_on = true; 374 mceEditor.execCommand( 'wpAutoResizeOn' ); 375 376 if ( ! mceEditor.isHidden() ) { 377 mceEditor.execCommand( 'wpAutoResize' ); 378 } 379 } 380 381 if ( ! mceEditor || mceEditor.isHidden() ) { 382 textEditorResize(); 383 } 384 344 385 adjust(); 345 } ); 346 347 // Adjust when collapsing the menu, changing the columns, changing the body class. 348 $document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ); 349 350 // Ideally we need to resize just after CSS has fully loaded and QuickTags is ready. 351 if ( $contentWrap.hasClass( 'html-active' ) ) { 352 initialResize( function() { 353 adjust(); 354 textEditorResize(); 355 } ); 356 } 386 } 387 388 function off() { 389 var height = window.getUserSetting('ed_size'); 390 391 // Scroll to the top when triggering this from JS. 392 // Ensures toolbars are reset properly. 393 if ( window.pageYOffset && window.pageYOffset > 130 ) { 394 window.scrollTo( window.pageXOffset, 0 ); 395 } 396 397 $wrap.removeClass( 'wp-editor-expand' ); 398 399 // Adjust when the window is scrolled or resized. 400 $window.off( 'scroll.editor-expand resize.editor-expand' ); 401 402 // Adjust when collapsing the menu, changing the columns, changing the body class. 403 $document.off( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ); 404 405 $textEditor.off( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize ); 406 $textEditor.off( 'keyup.editor-expand', textEditorKeyup ); 407 mceUnbind(); 408 409 // Adjust when entering/exiting fullscreen mode. 410 fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide ); 411 412 // Reset all css 413 $.each( [ $visualTop, $textTop, $tools, $bottom, $contentWrap, $visualEditor, $textEditor ], function( i, element ) { 414 element && element.attr( 'style', '' ); 415 }); 416 417 if ( mceEditor ) { 418 mceEditor.settings.wp_autoresize_on = false; 419 mceEditor.execCommand( 'wpAutoResizeOff' ); 420 421 if ( ! mceEditor.isHidden() ) { 422 $textEditor.hide(); 423 424 if ( height ) { 425 mceEditor.theme.resizeTo( null, height ); 426 } 427 } 428 } 429 430 if ( height ) { 431 $textEditor.height( height ); 432 } 433 } 434 435 // Start on load 436 if ( $wrap.hasClass( 'wp-editor-expand' ) ) { 437 on(); 438 439 // Ideally we need to resize just after CSS has fully loaded and QuickTags is ready. 440 if ( $contentWrap.hasClass( 'html-active' ) ) { 441 initialResize( function() { 442 adjust(); 443 textEditorResize(); 444 } ); 445 } 446 } 447 448 // Show the on/off checkbox 449 $( '#adv-settings .editor-expand' ).show(); 450 $( '#editor-expand-toggle' ).on( 'change.editor-expand', function() { 451 if ( $(this).prop( 'checked' ) ) { 452 on(); 453 window.setUserSetting( 'editor_expand', 'on' ); 454 } else { 455 off(); 456 window.setUserSetting( 'editor_expand', 'off' ); 457 } 458 }); 459 460 // Expose on() and off() 461 window.editorExpand = { 462 on: on, 463 off: off 464 }; 357 465 }); -
trunk/src/wp-admin/js/post.js
r29117 r29336 1006 1006 $textarea = $('textarea#content'), 1007 1007 $handle = $('#post-status-info'), 1008 $ contentWrap = $('#wp-content-wrap');1008 $postdivrich = $('#postdivrich'); 1009 1009 1010 1010 // No point for touch devices … … 1016 1016 1017 1017 function dragging( event ) { 1018 if ( $ contentWrap.hasClass( 'wp-editor-expand' ) ) {1018 if ( $postdivrich.hasClass( 'wp-editor-expand' ) ) { 1019 1019 return; 1020 1020 } … … 1032 1032 var height, toolbarHeight; 1033 1033 1034 if ( $ contentWrap.hasClass( 'wp-editor-expand' ) ) {1034 if ( $postdivrich.hasClass( 'wp-editor-expand' ) ) { 1035 1035 return; 1036 1036 } … … 1057 1057 } 1058 1058 } 1059 1060 $textarea.css( 'resize', 'none' );1061 1059 1062 1060 $handle.on( 'mousedown.wp-editor-resize', function( event ) { -
trunk/src/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js
r29279 r29336 22 22 */ 23 23 tinymce.PluginManager.add( 'wpautoresize', function( editor ) { 24 var settings = editor.settings, oldSize = 0; 24 var settings = editor.settings, 25 oldSize = 0, 26 isActive = false; 25 27 26 28 function isFullscreen() { … … 38 40 var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight, marginTop, marginBottom; 39 41 42 if ( ! isActive ) { 43 return; 44 } 45 40 46 doc = editor.getDoc(); 41 if ( !doc) {47 if ( ! doc ) { 42 48 return; 43 49 } … … 129 135 function on() { 130 136 if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) { 137 isActive = true; 131 138 editor.dom.addClass( editor.getBody(), 'wp-autoresize' ); 132 139 // Add appropriate listeners for resizing the content area … … 141 148 // Don't turn off if the setting is 'on' 142 149 if ( ! settings.wp_autoresize_on ) { 150 isActive = false; 143 151 doc = editor.getDoc(); 144 152 editor.dom.removeClass( editor.getBody(), 'wp-autoresize' ); … … 152 160 if ( settings.wp_autoresize_on ) { 153 161 // Turn resizing on when the editor loads 162 isActive = true; 163 154 164 editor.on( 'init', function() { 155 165 editor.dom.addClass( editor.getBody(), 'wp-autoresize' ); … … 164 174 if ( editor.getParam( 'autoresize_on_init', true ) ) { 165 175 editor.on( 'init', function() { 166 // Hit it 20 times in 100 ms intervals176 // Hit it 10 times in 200 ms intervals 167 177 wait( 10, 200, function() { 168 178 // Hit it 5 times in 1 sec intervals
Note: See TracChangeset
for help on using the changeset viewer.