Hide text while editor is loading, show html editor on error
git-svn-id: http://svn.automattic.com/wordpress/trunk@11171 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cce77d198a
commit
bf88b244cd
|
@ -40,7 +40,7 @@ var pagenow = '<?php echo substr($pagenow, 0, -4); ?>';
|
|||
<?php
|
||||
|
||||
if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php', 'page-new.php') ) ) {
|
||||
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 5 );
|
||||
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
|
||||
wp_enqueue_script('quicktags');
|
||||
}
|
||||
|
||||
|
|
|
@ -1282,8 +1282,8 @@ function wp_tiny_mce( $teeny = false ) {
|
|||
|
||||
// TinyMCE init settings
|
||||
$initArray = array (
|
||||
'mode' => 'none',
|
||||
'onpageload' => 'switchEditors.edInit',
|
||||
'mode' => 'specific_textareas',
|
||||
'editor_selector' => 'theEditor',
|
||||
'width' => '100%',
|
||||
'theme' => 'advanced',
|
||||
'skin' => 'wp_theme',
|
||||
|
@ -1334,7 +1334,7 @@ function wp_tiny_mce( $teeny = false ) {
|
|||
|
||||
$language = $initArray['language'];
|
||||
$zip = $compress_scripts ? 1 : 0;
|
||||
$ver = apply_filters('tiny_mce_version', '3211');
|
||||
$ver = apply_filters('tiny_mce_version', '323');
|
||||
|
||||
if ( 'en' != $language )
|
||||
include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php');
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
|
||||
jQuery(document).ready(function($){
|
||||
var h = wpCookies.getHash('TinyMCE_content_size');
|
||||
|
||||
if ( getUserSetting( 'editor' ) == 'html' ) {
|
||||
if ( h )
|
||||
$('#content').css('height', h.ch - 15 + 'px');
|
||||
} else {
|
||||
$('#content').css('color', 'white');
|
||||
$('#quicktags').hide();
|
||||
}
|
||||
});
|
||||
|
||||
var switchEditors = {
|
||||
|
||||
mode : '',
|
||||
|
@ -8,18 +20,6 @@ var switchEditors = {
|
|||
},
|
||||
|
||||
edInit : function() {
|
||||
var h = tinymce.util.Cookie.getHash("TinyMCE_content_size");
|
||||
|
||||
// Activate TinyMCE if it's the user's default editor
|
||||
if ( getUserSetting( 'editor' ) == 'html' ) {
|
||||
if ( h )
|
||||
try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){};
|
||||
} else {
|
||||
try {
|
||||
this.I("quicktags").style.display = "none";
|
||||
} catch(e){};
|
||||
tinyMCE.execCommand("mceAddControl", false, "content");
|
||||
}
|
||||
},
|
||||
|
||||
saveCallback : function(el, content, body) {
|
||||
|
@ -94,43 +94,44 @@ var switchEditors = {
|
|||
id = id || 'content';
|
||||
mode = mode || this.mode || '';
|
||||
|
||||
var ed = tinyMCE.get(id) || false, qt = this.I('quicktags'), H = this.I('edButtonHTML'), P = this.I('edButtonPreview'), ta = this.I(id);
|
||||
var ed, qt = this.I('quicktags'), H = this.I('edButtonHTML'), P = this.I('edButtonPreview'), ta = this.I(id);
|
||||
|
||||
try { ed = tinyMCE.get(id); }
|
||||
catch(e) { ed = false; }
|
||||
|
||||
if ( 'tinymce' == mode ) {
|
||||
|
||||
if ( ed && ! ed.isHidden() )
|
||||
return false;
|
||||
|
||||
setUserSetting( 'editor', 'tinymce' );
|
||||
this.mode = 'html';
|
||||
ta.style.color = '#fff';
|
||||
|
||||
P.className = 'active';
|
||||
H.className = '';
|
||||
edCloseAllTags(); // :-(
|
||||
|
||||
qt.style.display = 'none';
|
||||
|
||||
ta.value = this.wpautop(ta.value);
|
||||
|
||||
if ( ed ) ed.show();
|
||||
else tinyMCE.execCommand("mceAddControl", false, id);
|
||||
|
||||
setUserSetting( 'editor', 'tinymce' );
|
||||
if ( ed ) {
|
||||
ed.show();
|
||||
} else {
|
||||
try{tinyMCE.execCommand("mceAddControl", false, id);}
|
||||
catch(e){}
|
||||
}
|
||||
} else {
|
||||
if ( ! ed || ed.isHidden() )
|
||||
return false;
|
||||
|
||||
setUserSetting( 'editor', 'html' );
|
||||
ta.style.color = '#000';
|
||||
this.mode = 'tinymce';
|
||||
H.className = 'active';
|
||||
P.className = '';
|
||||
|
||||
ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px';
|
||||
if ( ed && !ed.isHidden() ) {
|
||||
ta.style.height = ed.getContentAreaContainer().offsetHeight + 24 + 'px';
|
||||
ed.hide();
|
||||
}
|
||||
|
||||
ed.hide();
|
||||
qt.style.display = 'block';
|
||||
|
||||
ta.style.color = '';
|
||||
setUserSetting( 'editor', 'html' );
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
|
|
@ -1 +1 @@
|
|||
var switchEditors={mode:"",I:function(a){return document.getElementById(a)},edInit:function(){var a=tinymce.util.Cookie.getHash("TinyMCE_content_size");if(getUserSetting("editor")=="html"){if(a){try{this.I("content").style.height=a.ch-30+"px"}catch(b){}}}else{try{this.I("quicktags").style.display="none"}catch(b){}tinyMCE.execCommand("mceAddControl",false,"content")}},saveCallback:function(b,c,a){if(tinyMCE.activeEditor.isHidden()){c=this.I(b).value}else{c=this.pre_wpautop(c)}return c},pre_wpautop:function(b){var c,a;b=b.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(d){d=d.replace(/<br ?\/?>[\r\n]*/g,"<wp_temp>");return d.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"<wp_temp>")});c="blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p";b=b.replace(new RegExp("\\s*</("+c+")>\\s*","mg"),"</$1>\n");b=b.replace(new RegExp("\\s*<(("+c+")[^>]*)>","mg"),"\n<$1>");b=b.replace(new RegExp("(<p [^>]+>.*?)</p>","mg"),"$1</p#>");b=b.replace(new RegExp("<div([^>]*)>\\s*<p>","mgi"),"<div$1>\n\n");b=b.replace(new RegExp("\\s*<p>","mgi"),"");b=b.replace(new RegExp("\\s*</p>\\s*","mgi"),"\n\n");b=b.replace(new RegExp("\\n\\s*\\n","mgi"),"\n\n");b=b.replace(new RegExp("\\s*<br ?/?>\\s*","gi"),"\n");b=b.replace(new RegExp("\\s*<div","mg"),"\n<div");b=b.replace(new RegExp("</div>\\s*","mg"),"</div>\n");b=b.replace(new RegExp("\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*","gi"),"\n\n[caption$1[/caption]\n\n");b=b.replace(new RegExp("caption\\]\\n\\n+\\[caption","g"),"caption]\n\n[caption");a="blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre";b=b.replace(new RegExp("\\s*<(("+a+") ?[^>]*)\\s*>","mg"),"\n<$1>");b=b.replace(new RegExp("\\s*</("+a+")>\\s*","mg"),"</$1>\n");b=b.replace(new RegExp("<li([^>]*)>","g"),"\t<li$1>");if(b.indexOf("<object")!=-1){b=b.replace(/<object[\s\S]+?<\/object>/g,function(d){return d.replace(/[\r\n]+/g,"")})}b=b.replace(new RegExp("</p#>","g"),"</p>\n");b=b.replace(new RegExp("\\s*(<p [^>]+>.*</p>)","mg"),"\n$1");b=b.replace(new RegExp("^\\s*",""),"");b=b.replace(new RegExp("[\\s\\u00a0]*$",""),"");b=b.replace(/<wp_temp>/g,"\n");return b},go:function(g,e){g=g||"content";e=e||this.mode||"";var b=tinyMCE.get(g)||false,f=this.I("quicktags"),c=this.I("edButtonHTML"),d=this.I("edButtonPreview"),a=this.I(g);if("tinymce"==e){if(b&&!b.isHidden()){return false}this.mode="html";a.style.color="#fff";d.className="active";c.className="";edCloseAllTags();f.style.display="none";a.value=this.wpautop(a.value);if(b){b.show()}else{tinyMCE.execCommand("mceAddControl",false,g)}setUserSetting("editor","tinymce")}else{if(!b||b.isHidden()){return false}this.mode="tinymce";c.className="active";d.className="";a.style.height=b.getContentAreaContainer().offsetHeight+6+"px";b.hide();f.style.display="block";a.style.color="";setUserSetting("editor","html")}return false},wpautop:function(a){var b="table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]";if(a.indexOf("<object")!=-1){a=a.replace(/<object[\s\S]+?<\/object>/g,function(c){return c.replace(/[\r\n]+/g,"")})}a=a.replace(/<[^<>]+>/g,function(c){return c.replace(/[\r\n]+/g," ")});a=a+"\n\n";a=a.replace(new RegExp("<br />\\s*<br />","gi"),"\n\n");a=a.replace(new RegExp("(<(?:"+b+")[^>]*>)","gi"),"\n$1");a=a.replace(new RegExp("(</(?:"+b+")>)","gi"),"$1\n\n");a=a.replace(new RegExp("\\r\\n|\\r","g"),"\n");a=a.replace(new RegExp("\\n\\s*\\n+","g"),"\n\n");a=a.replace(new RegExp("([\\s\\S]+?)\\n\\n","mg"),"<p>$1</p>\n");a=a.replace(new RegExp("<p>\\s*?</p>","gi"),"");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")[^>]*>)\\s*</p>","gi"),"$1");a=a.replace(new RegExp("<p>(<li.+?)</p>","gi"),"$1");a=a.replace(new RegExp("<p>\\s*<blockquote([^>]*)>","gi"),"<blockquote$1><p>");a=a.replace(new RegExp("</blockquote>\\s*</p>","gi"),"</p></blockquote>");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")[^>]*>)","gi"),"$1");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*</p>","gi"),"$1");a=a.replace(new RegExp("\\s*\\n","gi"),"<br />\n");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*<br />","gi"),"$1");a=a.replace(new RegExp("<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)","gi"),"$1");a=a.replace(new RegExp("(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*","gi"),"[caption$1[/caption]");a=a.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(c){c=c.replace(/<br ?\/?>[\r\n]*/g,"\n");return c.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"\n")});return a}};
|
||||
jQuery(document).ready(function(b){var a=wpCookies.getHash("TinyMCE_content_size");if(getUserSetting("editor")=="html"){if(a){b("#content").css("height",a.ch-15+"px")}}else{b("#content").css("color","white");b("#quicktags").hide()}});var switchEditors={mode:"",I:function(a){return document.getElementById(a)},edInit:function(){},saveCallback:function(b,c,a){if(tinyMCE.activeEditor.isHidden()){c=this.I(b).value}else{c=this.pre_wpautop(c)}return c},pre_wpautop:function(b){var c,a;b=b.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(d){d=d.replace(/<br ?\/?>[\r\n]*/g,"<wp_temp>");return d.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"<wp_temp>")});c="blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p";b=b.replace(new RegExp("\\s*</("+c+")>\\s*","mg"),"</$1>\n");b=b.replace(new RegExp("\\s*<(("+c+")[^>]*)>","mg"),"\n<$1>");b=b.replace(new RegExp("(<p [^>]+>.*?)</p>","mg"),"$1</p#>");b=b.replace(new RegExp("<div([^>]*)>\\s*<p>","mgi"),"<div$1>\n\n");b=b.replace(new RegExp("\\s*<p>","mgi"),"");b=b.replace(new RegExp("\\s*</p>\\s*","mgi"),"\n\n");b=b.replace(new RegExp("\\n\\s*\\n","mgi"),"\n\n");b=b.replace(new RegExp("\\s*<br ?/?>\\s*","gi"),"\n");b=b.replace(new RegExp("\\s*<div","mg"),"\n<div");b=b.replace(new RegExp("</div>\\s*","mg"),"</div>\n");b=b.replace(new RegExp("\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*","gi"),"\n\n[caption$1[/caption]\n\n");b=b.replace(new RegExp("caption\\]\\n\\n+\\[caption","g"),"caption]\n\n[caption");a="blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre";b=b.replace(new RegExp("\\s*<(("+a+") ?[^>]*)\\s*>","mg"),"\n<$1>");b=b.replace(new RegExp("\\s*</("+a+")>\\s*","mg"),"</$1>\n");b=b.replace(new RegExp("<li([^>]*)>","g"),"\t<li$1>");if(b.indexOf("<object")!=-1){b=b.replace(/<object[\s\S]+?<\/object>/g,function(d){return d.replace(/[\r\n]+/g,"")})}b=b.replace(new RegExp("</p#>","g"),"</p>\n");b=b.replace(new RegExp("\\s*(<p [^>]+>.*</p>)","mg"),"\n$1");b=b.replace(new RegExp("^\\s*",""),"");b=b.replace(new RegExp("[\\s\\u00a0]*$",""),"");b=b.replace(/<wp_temp>/g,"\n");return b},go:function(i,g){i=i||"content";g=g||this.mode||"";var b,h=this.I("quicktags"),c=this.I("edButtonHTML"),d=this.I("edButtonPreview"),a=this.I(i);try{b=tinyMCE.get(i)}catch(f){b=false}if("tinymce"==g){if(b&&!b.isHidden()){return false}setUserSetting("editor","tinymce");this.mode="html";d.className="active";c.className="";edCloseAllTags();h.style.display="none";a.value=this.wpautop(a.value);if(b){b.show()}else{try{tinyMCE.execCommand("mceAddControl",false,i)}catch(f){}}}else{setUserSetting("editor","html");a.style.color="#000";this.mode="tinymce";c.className="active";d.className="";if(b&&!b.isHidden()){a.style.height=b.getContentAreaContainer().offsetHeight+24+"px";b.hide()}h.style.display="block"}return false},wpautop:function(a){var b="table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]";if(a.indexOf("<object")!=-1){a=a.replace(/<object[\s\S]+?<\/object>/g,function(c){return c.replace(/[\r\n]+/g,"")})}a=a.replace(/<[^<>]+>/g,function(c){return c.replace(/[\r\n]+/g," ")});a=a+"\n\n";a=a.replace(new RegExp("<br />\\s*<br />","gi"),"\n\n");a=a.replace(new RegExp("(<(?:"+b+")[^>]*>)","gi"),"\n$1");a=a.replace(new RegExp("(</(?:"+b+")>)","gi"),"$1\n\n");a=a.replace(new RegExp("\\r\\n|\\r","g"),"\n");a=a.replace(new RegExp("\\n\\s*\\n+","g"),"\n\n");a=a.replace(new RegExp("([\\s\\S]+?)\\n\\n","mg"),"<p>$1</p>\n");a=a.replace(new RegExp("<p>\\s*?</p>","gi"),"");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")[^>]*>)\\s*</p>","gi"),"$1");a=a.replace(new RegExp("<p>(<li.+?)</p>","gi"),"$1");a=a.replace(new RegExp("<p>\\s*<blockquote([^>]*)>","gi"),"<blockquote$1><p>");a=a.replace(new RegExp("</blockquote>\\s*</p>","gi"),"</p></blockquote>");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")[^>]*>)","gi"),"$1");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*</p>","gi"),"$1");a=a.replace(new RegExp("\\s*\\n","gi"),"<br />\n");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*<br />","gi"),"$1");a=a.replace(new RegExp("<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)","gi"),"$1");a=a.replace(new RegExp("(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*","gi"),"[caption$1[/caption]");a=a.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(c){c=c.replace(/<br ?\/?>[\r\n]*/g,"\n");return c.replace(/<\/?p( [^>]*)?>[\r\n]*/g,"\n")});return a}};
|
|
@ -1806,9 +1806,8 @@ input#link_url {
|
|||
border-style: none none solid;
|
||||
}
|
||||
|
||||
#poststuff #edButtonPreview,
|
||||
#poststuff #edButtonHTML {
|
||||
display: block;
|
||||
#edButtonPreview,
|
||||
#edButtonHTML {
|
||||
height: 18px;
|
||||
margin: 5px 5px 0 0;
|
||||
padding: 4px 5px 2px;
|
||||
|
@ -1825,6 +1824,10 @@ input#link_url {
|
|||
border-top-left-radius: 3px;
|
||||
}
|
||||
|
||||
.js .theEditor {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#poststuff #edButtonHTML {
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
|
|
@ -1619,49 +1619,52 @@ function the_editor($content, $id = 'content', $prev_id = 'title', $media_button
|
|||
$media_buttons = false;
|
||||
|
||||
$richedit = user_can_richedit();
|
||||
$rows = "rows='$rows'";
|
||||
$class = '';
|
||||
|
||||
if ( $richedit || $media_buttons ) { ?>
|
||||
<div id="editor-toolbar">
|
||||
<?php if ( $richedit ) {
|
||||
<?php
|
||||
if ( $richedit ) {
|
||||
$wp_default_editor = wp_default_editor(); ?>
|
||||
<div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
|
||||
<?php if ( 'html' == $wp_default_editor ) {
|
||||
<?php if ( 'html' == $wp_default_editor ) {
|
||||
add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
|
||||
<a id="edButtonHTML" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
|
||||
<a id="edButtonPreview" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
|
||||
<?php } else {
|
||||
<a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
|
||||
<a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
|
||||
<?php } else {
|
||||
$class = " class='theEditor'";
|
||||
add_filter('the_editor_content', 'wp_richedit_pre'); ?>
|
||||
<a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
|
||||
<a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
|
||||
<?php }
|
||||
}
|
||||
<a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
|
||||
<a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
|
||||
<?php }
|
||||
}
|
||||
|
||||
if ( $media_buttons ) { ?>
|
||||
<div id="media-buttons" class="hide-if-no-js">
|
||||
<?php do_action( 'media_buttons' ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
if ( $media_buttons ) { ?>
|
||||
<div id="media-buttons" class="hide-if-no-js">
|
||||
<?php do_action( 'media_buttons' ); ?>
|
||||
</div>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div id="quicktags">
|
||||
<?php wp_print_scripts( 'quicktags' ); ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div id="quicktags"><?php
|
||||
wp_print_scripts( 'quicktags' ); ?>
|
||||
<script type="text/javascript">edToolbar()</script>
|
||||
</div>
|
||||
|
||||
<?php $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea $rows cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
|
||||
<?php
|
||||
$the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
|
||||
$the_editor_content = apply_filters('the_editor_content', $content);
|
||||
|
||||
printf($the_editor, $the_editor_content);
|
||||
|
||||
?>
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
edCanvas = document.getElementById('<?php echo $id; ?>');
|
||||
/* ]]> */
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -88,7 +88,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
// Modify this version when tinyMCE plugins are changed.
|
||||
function mce_version() {
|
||||
return '20090424';
|
||||
return '20090503';
|
||||
}
|
||||
add_filter( 'tiny_mce_version', 'mce_version' );
|
||||
|
||||
|
|
Loading…
Reference in New Issue