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

View File

@ -700,50 +700,51 @@ jQuery(document).ready( function($) {
});
})();
tinymce.onAddEditor.add(function(mce, ed){
if ( ed.id != 'content' )
return;
if ( typeof(tinymce) != 'undefined' ) {
tinymce.onAddEditor.add(function(mce, ed){
if ( ed.id != 'content' )
return;
// resize TinyMCE to match the textarea height when switching Text -> Visual
ed.onLoadContent.add( function(ed, o) {
var ifr_height, height = parseInt( $('#content').css('height'), 10 ),
tb_height = $('#content_tbl tr.mceFirst').height();
// resize TinyMCE to match the textarea height when switching Text -> Visual
ed.onLoadContent.add( function(ed, o) {
var ifr_height, height = parseInt( $('#content').css('height'), 10 ),
tb_height = $('#content_tbl tr.mceFirst').height();
if ( height && !isNaN(height) && tb_height ) {
ifr_height = (height - tb_height) + 12; // compensate for padding in the textarea
if ( height && !isNaN(height) && tb_height ) {
ifr_height = (height - tb_height) + 12; // compensate for padding in the textarea
$('#content_tbl').css('height', '' );
$('#content_ifr').css('height', ifr_height + 'px' );
setUserSetting( 'ed_size', height );
}
});
$('#content_tbl').css('height', '' );
$('#content_ifr').css('height', ifr_height + 'px' );
setUserSetting( 'ed_size', height );
}
});
// resize the textarea to match TinyMCE's height when switching Visual -> Text
ed.onSaveContent.add( function(ed, o) {
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();
// resize the textarea to match TinyMCE's height when switching Visual -> Text
ed.onSaveContent.add( function(ed, o) {
var height = $('#content_tbl').height();
if ( height && height > 83 ) {
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');
});
});
});
});
});
}
});