Make sure TinyMCE is not disabled before adding the size saving functions, see #21718

git-svn-id: http://core.svn.wordpress.org/trunk@22017 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2012-09-26 19:35:36 +00:00
parent ad572d63a1
commit 50be456284
1 changed files with 37 additions and 36 deletions

View File

@ -700,50 +700,51 @@ jQuery(document).ready( function($) {
}); });
})(); })();
tinymce.onAddEditor.add(function(mce, ed){ if ( typeof(tinymce) != 'undefined' ) {
if ( ed.id != 'content' ) tinymce.onAddEditor.add(function(mce, ed){
return; if ( ed.id != 'content' )
return;
// resize TinyMCE to match the textarea height when switching Text -> Visual // resize TinyMCE to match the textarea height when switching Text -> Visual
ed.onLoadContent.add( function(ed, o) { ed.onLoadContent.add( function(ed, o) {
var ifr_height, height = parseInt( $('#content').css('height'), 10 ), var ifr_height, height = parseInt( $('#content').css('height'), 10 ),
tb_height = $('#content_tbl tr.mceFirst').height(); tb_height = $('#content_tbl tr.mceFirst').height();
if ( height && !isNaN(height) && tb_height ) { if ( height && !isNaN(height) && tb_height ) {
ifr_height = (height - tb_height) + 12; // compensate for padding in the textarea ifr_height = (height - tb_height) + 12; // compensate for padding in the textarea
$('#content_tbl').css('height', '' ); $('#content_tbl').css('height', '' );
$('#content_ifr').css('height', ifr_height + 'px' ); $('#content_ifr').css('height', ifr_height + 'px' );
setUserSetting( 'ed_size', height ); setUserSetting( 'ed_size', height );
} }
}); });
// resize the textarea to match TinyMCE's height when switching Visual -> Text // resize the textarea to match TinyMCE's height when switching Visual -> Text
ed.onSaveContent.add( function(ed, o) { ed.onSaveContent.add( function(ed, o) {
var height = $('#content_tbl').height(); var height = $('#content_tbl').height();
if ( height && height > 83 ) {
height -= 33;
$('#content').css( 'height', height + 'px' );
setUserSetting( 'ed_size', height );
}
});
// save on resizing TinyMCE
ed.onPostRender.add(function() {
$('#content_resize').on('mousedown.wp-mce-resize', function(e){
$(document).on('mouseup.wp-mce-resize', function(e){
var height = $('#wp-content-editor-container').height();
if ( height && height > 83 ) {
height -= 33; height -= 33;
if ( height > 50 && height != getUserSetting( 'ed_size' ) )
setUserSetting( 'ed_size', height );
$(document).off('mouseup.wp-mce-resize'); $('#content').css( 'height', height + 'px' );
setUserSetting( 'ed_size', height );
}
});
// save on resizing TinyMCE
ed.onPostRender.add(function() {
$('#content_resize').on('mousedown.wp-mce-resize', function(e){
$(document).on('mouseup.wp-mce-resize', function(e){
var height = $('#wp-content-editor-container').height();
height -= 33;
if ( height > 50 && height != getUserSetting( 'ed_size' ) )
setUserSetting( 'ed_size', height );
$(document).off('mouseup.wp-mce-resize');
});
}); });
}); });
}); });
}); }
}); });