Created
October 15, 2014 15:40
-
-
Save jessepearson/1801878b5d5fd4ab23da to your computer and use it in GitHub Desktop.
Turn WordPress editor resizing on and off based on page template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery( document ).ready( function( $ ) { | |
| // our variables | |
| var page_template = $( '#page_template' ), // Page - page template select box | |
| main_editor_container = $( '#postdivrich' ), // All - main editor | |
| editor_expand_toggle = $( '#editor-expand-toggle' ); // All - the checkbox to turn autoresizing of the editor on and off. | |
| // function that flips the switch to turn the auto resize of the MCE editor on and off | |
| // basically, it gets it to reinitialize itself once we've shown it after hiding it, fixing layout issues | |
| function expand_toggle(){ | |
| if( editor_expand_toggle.prop( 'checked' ) ) { | |
| setTimeout( function () { | |
| window.editorExpand.off(); | |
| window.editorExpand.on(); | |
| }, 401 ); | |
| } | |
| } | |
| // listen for a template change | |
| page_template.change( function() { | |
| switch( $( this ).val() ) { | |
| case 'template-sectional.php': | |
| main_editor_container.slideUp(); | |
| break; | |
| case 'template-big-head.php': | |
| main_editor_container.slideDown(); | |
| break; | |
| default: | |
| main_editor_container.slideDown(); | |
| } | |
| // flip the switch | |
| expand_toggle(); | |
| } ).change(); | |
| } ); |
Author
@shivapoudel I never got an email with your comment, if you're still having an issue let me know.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On chrome I have set the mobile devices. How to get this fix ;)