X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/3f5685912e89eb3b0534acd85aa0946b1ca2bbe3..refs/tags/wordpress-3.3:/wp-admin/js/editor.dev.js
diff --git a/wp-admin/js/editor.dev.js b/wp-admin/js/editor.dev.js
index ce6f835d..37c79278 100644
--- a/wp-admin/js/editor.dev.js
+++ b/wp-admin/js/editor.dev.js
@@ -1,46 +1,87 @@
-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 {
- if ( typeof tinyMCE != 'object' ) {
- $('#content').css('color', '#000');
- } else {
- $('#quicktags').hide();
+var switchEditors = {
+
+ switchto: function(el) {
+ var aid = el.id, l = aid.length, id = aid.substr(0, l - 5), mode = aid.substr(l - 4);
+
+ this.go(id, mode);
+ },
+
+ go: function(id, mode) { // mode can be 'html', 'tmce', or 'toggle'
+ id = id || 'content';
+ mode = mode || 'toggle';
+
+ var t = this, ed = tinyMCE.get(id), wrap_id, txtarea_el, dom = tinymce.DOM;
+
+ wrap_id = 'wp-'+id+'-wrap';
+ txtarea_el = dom.get(id);
+
+ if ( 'toggle' == mode ) {
+ if ( ed && !ed.isHidden() )
+ mode = 'html';
+ else
+ mode = 'tmce';
}
- }
-});
-var switchEditors = {
+ if ( 'tmce' == mode || 'tinymce' == mode ) {
+ if ( ed && ! ed.isHidden() )
+ return false;
+
+ if ( typeof(QTags) != 'undefined' )
+ QTags.closeAllTags(id);
- mode : '',
+ if ( tinyMCEPreInit.mceInit[id] && tinyMCEPreInit.mceInit[id].wpautop )
+ txtarea_el.value = t.wpautop( txtarea_el.value );
- I : function(e) {
- return document.getElementById(e);
+ if ( ed ) {
+ ed.show();
+ } else {
+ ed = new tinymce.Editor(id, tinyMCEPreInit.mceInit[id]);
+ ed.render();
+ }
+
+ dom.removeClass(wrap_id, 'html-active');
+ dom.addClass(wrap_id, 'tmce-active');
+ setUserSetting('editor', 'tinymce');
+
+ } else if ( 'html' == mode ) {
+
+ if ( ed && ed.isHidden() )
+ return false;
+
+ if ( ed ) {
+ txtarea_el.style.height = ed.getContentAreaContainer().offsetHeight + 20 + 'px';
+ ed.hide();
+ }
+
+ dom.removeClass(wrap_id, 'tmce-active');
+ dom.addClass(wrap_id, 'html-active');
+ setUserSetting('editor', 'html');
+ }
+ return false;
},
_wp_Nop : function(content) {
var blocklist1, blocklist2;
// Protect pre|script tags
- content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
- a = a.replace(/
[\r\n]*/g, ']*>[\s\S]+?<\/\1>/g, function(a) {
+ a = a.replace(/
(\r\n|\n)?/g, '
]+>.*?)<\/p>/g, '$1
'); // Sepatate- content = content.replace(/
/gi, '
/gi, '
and
content = content.replace(/\s*
/gi, ''); @@ -55,10 +96,14 @@ var switchEditors = { content = content.replace(/caption\]\n\n+\[caption/g, 'caption]\n\n[caption'); blocklist2 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset'; - content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'g'), '\n<$1>'); + content = content.replace(new RegExp('\\s*<((?:'+blocklist2+')(?: [^>]*)?)\\s*>', 'g'), '\n<$1>'); content = content.replace(new RegExp('\\s*('+blocklist2+')>\\s*', 'g'), '$1>\n'); content = content.replace(/