Changeset 29050
- Timestamp:
- 07/09/2014 10:42:28 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/editor-expand.js
r29049 r29050 1 /* global tinymce */ 1 2 2 3 window.wp = window.wp || {}; … … 16 17 $statusBar, 17 18 buffer = 200, 18 adjust,19 19 fullscreen = window.wp.editor && window.wp.editor.fullscreen, 20 20 editorInstance, … … 23 23 24 24 $textEditorClone.insertAfter( $textEditor ); 25 25 26 26 // use to enable/disable 27 27 $contentWrap.addClass( 'wp-editor-expand' ); … … 307 307 width: $editor.parent().width() - ( $top.outerWidth() - $top.width() ) 308 308 } ); 309 309 310 310 $tools.css( { 311 311 position: 'absolute', … … 323 323 borderTop: 'none' 324 324 } ); 325 325 326 326 $tools.css( { 327 327 position: 'absolute', … … 330 330 width: $contentWrap.width() 331 331 } ); 332 } 332 } 333 333 } 334 334 -
trunk/src/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js
r29049 r29050 21 21 * it's initialized. 22 22 */ 23 tinymce.PluginManager.add( 'wpautoresize', function(editor) {23 tinymce.PluginManager.add( 'wpautoresize', function( editor ) { 24 24 var settings = editor.settings, oldSize = 0; 25 25 … … 28 28 } 29 29 30 if ( editor.settings.inline) {30 if ( editor.settings.inline ) { 31 31 return; 32 32 } … … 35 35 * This method gets executed each time the editor needs to resize. 36 36 */ 37 function resize( e) {37 function resize( e ) { 38 38 var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight, marginTop, marginBottom; 39 39 … … 47 47 resizeHeight = settings.autoresize_min_height; 48 48 49 if ( !body || (e && e.type === "setcontent" && e.initial) || isFullscreen()) {50 if ( body && docElm) {51 body.style.overflowY = "auto";52 docElm.style.overflowY = "auto"; // Old IE49 if ( ! body || ( e && e.type === 'setcontent' && e.initial ) || isFullscreen() ) { 50 if ( body && docElm ) { 51 body.style.overflowY = 'auto'; 52 docElm.style.overflowY = 'auto'; // Old IE 53 53 } 54 54 … … 57 57 58 58 // Calculate outer height of the body element using CSS styles 59 marginTop = editor.dom.getStyle( body, 'margin-top', true);60 marginBottom = editor.dom.getStyle( body, 'margin-bottom', true);61 myHeight = body.offsetHeight + parseInt( marginTop, 10) + parseInt(marginBottom, 10);59 marginTop = editor.dom.getStyle( body, 'margin-top', true ); 60 marginBottom = editor.dom.getStyle( body, 'margin-bottom', true ); 61 myHeight = body.offsetHeight + parseInt( marginTop, 10 ) + parseInt( marginBottom, 10 ); 62 62 63 63 // Make sure we have a valid height 64 if ( isNaN(myHeight) || myHeight <= 0) {64 if ( isNaN( myHeight ) || myHeight <= 0 ) { 65 65 // Get height differently depending on the browser used 66 myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight);66 myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight ); 67 67 } 68 68 69 69 // Don't make it smaller than the minimum height 70 if ( myHeight > settings.autoresize_min_height) {70 if ( myHeight > settings.autoresize_min_height ) { 71 71 resizeHeight = myHeight; 72 72 } 73 73 74 74 // If a maximum height has been defined don't exceed this height 75 if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height) {75 if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height ) { 76 76 resizeHeight = settings.autoresize_max_height; 77 body.style.overflowY = "auto";78 docElm.style.overflowY = "auto"; // Old IE77 body.style.overflowY = 'auto'; 78 docElm.style.overflowY = 'auto'; // Old IE 79 79 } else { 80 body.style.overflowY = "hidden";81 docElm.style.overflowY = "hidden"; // Old IE80 body.style.overflowY = 'hidden'; 81 docElm.style.overflowY = 'hidden'; // Old IE 82 82 body.scrollTop = 0; 83 83 } … … 86 86 if (resizeHeight !== oldSize) { 87 87 deltaSize = resizeHeight - oldSize; 88 DOM.setStyle( DOM.get(editor.id + '_ifr'), 'height', resizeHeight + 'px');88 DOM.setStyle( DOM.get( editor.id + '_ifr'), 'height', resizeHeight + 'px' ); 89 89 oldSize = resizeHeight; 90 90 91 91 // WebKit doesn't decrease the size of the body element until the iframe gets resized 92 92 // So we need to continue to resize the iframe down until the size gets fixed 93 if ( tinymce.isWebKit && deltaSize < 0) {94 resize( e);93 if ( tinymce.isWebKit && deltaSize < 0 ) { 94 resize( e ); 95 95 } 96 96 } … … 114 114 115 115 // Define minimum height 116 settings.autoresize_min_height = parseInt(editor.getParam( 'autoresize_min_height', editor.getElement().offsetHeight), 10);116 settings.autoresize_min_height = parseInt(editor.getParam( 'autoresize_min_height', editor.getElement().offsetHeight), 10 ); 117 117 118 118 // Define maximum height 119 settings.autoresize_max_height = parseInt(editor.getParam( 'autoresize_max_height', 0), 10);119 settings.autoresize_max_height = parseInt(editor.getParam( 'autoresize_max_height', 0), 10 ); 120 120 121 121 function on() { … … 162 162 editor.addCommand( 'wpAutoResizeOff', off ); 163 163 }); 164 /**165 * plugin.js166 *167 * Copyright, Moxiecode Systems AB168 * Released under LGPL License.169 *170 * License: http://www.tinymce.com/license171 * Contributing: http://www.tinymce.com/contributing172 */173 174 // Forked for WordPress so it can be turned on/off after loading.175 176 /*global tinymce:true */177 /*eslint no-nested-ternary:0 */178 179 /**180 * Auto Resize181 *182 * This plugin automatically resizes the content area to fit its content height.183 * It will retain a minimum height, which is the height of the content area when184 * it's initialized.185 */186 tinymce.PluginManager.add('wpautoresize', function(editor) {187 var settings = editor.settings, oldSize = 0;188 189 function isFullscreen() {190 return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();191 }192 193 if (editor.settings.inline) {194 return;195 }196 197 /**198 * This method gets executed each time the editor needs to resize.199 */200 function resize(e) {201 var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight, marginTop, marginBottom;202 203 doc = editor.getDoc();204 if (!doc) {205 return;206 }207 208 body = doc.body;209 docElm = doc.documentElement;210 resizeHeight = settings.autoresize_min_height;211 212 if (!body || (e && e.type === "setcontent" && e.initial) || isFullscreen()) {213 if (body && docElm) {214 body.style.overflowY = "auto";215 docElm.style.overflowY = "auto"; // Old IE216 }217 218 return;219 }220 221 // Calculate outer height of the body element using CSS styles222 marginTop = editor.dom.getStyle(body, 'margin-top', true);223 marginBottom = editor.dom.getStyle(body, 'margin-bottom', true);224 myHeight = body.offsetHeight + parseInt(marginTop, 10) + parseInt(marginBottom, 10);225 226 // Make sure we have a valid height227 if (isNaN(myHeight) || myHeight <= 0) {228 // Get height differently depending on the browser used229 myHeight = tinymce.Env.ie ? body.scrollHeight : (tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight);230 }231 232 // Don't make it smaller than the minimum height233 if (myHeight > settings.autoresize_min_height) {234 resizeHeight = myHeight;235 }236 237 // If a maximum height has been defined don't exceed this height238 if (settings.autoresize_max_height && myHeight > settings.autoresize_max_height) {239 resizeHeight = settings.autoresize_max_height;240 body.style.overflowY = "auto";241 docElm.style.overflowY = "auto"; // Old IE242 } else {243 body.style.overflowY = "hidden";244 docElm.style.overflowY = "hidden"; // Old IE245 body.scrollTop = 0;246 }247 248 // Resize content element249 if (resizeHeight !== oldSize) {250 deltaSize = resizeHeight - oldSize;251 DOM.setStyle(DOM.get(editor.id + '_ifr'), 'height', resizeHeight + 'px');252 oldSize = resizeHeight;253 254 // WebKit doesn't decrease the size of the body element until the iframe gets resized255 // So we need to continue to resize the iframe down until the size gets fixed256 if (tinymce.isWebKit && deltaSize < 0) {257 resize(e);258 }259 }260 }261 262 /**263 * Calls the resize x times in 100ms intervals. We can't wait for load events since264 * the CSS files might load async.265 */266 function wait( times, interval, callback ) {267 setTimeout( function() {268 resize({});269 270 if ( times-- ) {271 wait( times, interval, callback );272 } else if ( callback ) {273 callback();274 }275 }, interval );276 }277 278 // Define minimum height279 settings.autoresize_min_height = parseInt(editor.getParam('autoresize_min_height', editor.getElement().offsetHeight), 10);280 281 // Define maximum height282 settings.autoresize_max_height = parseInt(editor.getParam('autoresize_max_height', 0), 10);283 284 function on() {285 if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) {286 editor.dom.addClass( editor.getBody(), 'wp-autoresize' );287 // Add appropriate listeners for resizing the content area288 editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );289 }290 }291 292 function off() {293 // Don't turn off if the setting is 'on'294 if ( ! settings.wp_autoresize_on ) {295 editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );296 editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );297 oldSize = 0;298 }299 }300 301 if ( settings.wp_autoresize_on ) {302 // Turn resizing on when the editor loads303 editor.on( 'init', function() {304 editor.dom.addClass( editor.getBody(), 'wp-autoresize' );305 });306 307 editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );308 309 if ( editor.getParam( 'autoresize_on_init', true ) ) {310 editor.on( 'init', function() {311 // Hit it 20 times in 100 ms intervals312 wait( 10, 200, function() {313 // Hit it 5 times in 1 sec intervals314 wait( 5, 1000 );315 });316 });317 }318 }319 320 // Register the command321 editor.addCommand( 'wpAutoResize', resize );322 323 // On/off324 editor.addCommand( 'wpAutoResizeOn', on );325 editor.addCommand( 'wpAutoResizeOff', off );326 });
Note: See TracChangeset
for help on using the changeset viewer.