-
+ 24CC6E70BBCA8677C39551E12424E8A47CF686A81C70FCC3EEDBA3633F9C5D0AD06F4C946B244110156CF15FD413C513C725EAC936D570396BE7256A73146E3Cmp-wp/wp-admin/js/editor.js(0 . 0)(1 . 172)
49297
49298 switchEditors = {
49299
49300 mode : '',
49301
49302 I : function(e) {
49303 return document.getElementById(e);
49304 },
49305
49306 edInit : function() {
49307 var h = tinymce.util.Cookie.getHash("TinyMCE_content_size"), H = this.I('edButtonHTML'), P = this.I('edButtonPreview');
49308
49309 // Activate TinyMCE if it's the user's default editor
49310 if ( getUserSetting( 'editor' ) == 'html' ) {
49311 if ( h )
49312 try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){};
49313 } else {
49314 try {
49315 this.I("quicktags").style.display = "none";
49316 } catch(e){};
49317 tinyMCE.execCommand("mceAddControl", false, "content");
49318 }
49319 },
49320
49321 saveCallback : function(el, content, body) {
49322
49323 if ( tinyMCE.activeEditor.isHidden() )
49324 content = this.I(el).value;
49325 else
49326 content = this.pre_wpautop(content);
49327
49328 return content;
49329 },
49330
49331 pre_wpautop : function(content) {
49332 // We have a TON of cleanup to do. Line breaks are already stripped.
49333
49334 // Protect pre|script tags
49335 content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
49336 a = a.replace(/<br ?\/?>[\r\n]*/g, '<wp_temp>');
49337 return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '<wp_temp>');
49338 });
49339
49340 // Pretty it up for the source editor
49341 var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p';
49342 content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n');
49343 content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>');
49344
49345 // Mark </p> if it has any attributes.
49346 content = content.replace(new RegExp('(<p [^>]+>.*?)</p>', 'mg'), '$1</p#>');
49347
49348 // Sepatate <div> containing <p>
49349 content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n');
49350
49351 // Remove <p> and <br />
49352 content = content.replace(new RegExp('\\s*<p>', 'mgi'), '');
49353 content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n');
49354 content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n');
49355 content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
49356
49357 // Fix some block element newline issues
49358 content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
49359 content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
49360 content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n');
49361 content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption');
49362
49363 var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
49364 content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
49365 content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n');
49366 content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>');
49367
49368 if ( content.indexOf('<object') != -1 ) {
49369 content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>");
49370 content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>');
49371 }
49372
49373 // Unmark special paragraph closing tags
49374 content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
49375 content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1');
49376
49377 // Trim whitespace
49378 content = content.replace(new RegExp('^\\s*', ''), '');
49379 content = content.replace(new RegExp('[\\s\\u00a0]*$', ''), '');
49380
49381 // put back the line breaks in pre|script
49382 content = content.replace(/<wp_temp>/g, '\n');
49383
49384 // Hope.
49385 return content;
49386 },
49387
49388 go : function(id, mode) {
49389 id = id || 'content';
49390 mode = mode || this.mode || '';
49391
49392 var ed = tinyMCE.get(id) || false;
49393 var qt = this.I('quicktags');
49394 var H = this.I('edButtonHTML');
49395 var P = this.I('edButtonPreview');
49396 var ta = this.I(id);
49397
49398 if ( 'tinymce' == mode ) {
49399
49400 if ( ed && ! ed.isHidden() )
49401 return false;
49402
49403 this.mode = 'html';
49404 ta.style.color = '#fff';
49405
49406 P.className = 'active';
49407 H.className = '';
49408 edCloseAllTags(); // :-(
49409
49410 qt.style.display = 'none';
49411
49412 ta.value = this.wpautop(ta.value);
49413
49414 if ( ed ) ed.show();
49415 else tinyMCE.execCommand("mceAddControl", false, id);
49416
49417 setUserSetting( 'editor', 'tinymce' );
49418 } else {
49419 if ( ! ed || ed.isHidden() )
49420 return false;
49421
49422 this.mode = 'tinymce';
49423 H.className = 'active';
49424 P.className = '';
49425
49426 ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px';
49427
49428 ed.hide();
49429 qt.style.display = 'block';
49430
49431 ta.style.color = '';
49432 setUserSetting( 'editor', 'html' );
49433 }
49434 return false;
49435 },
49436
49437 wpautop : function(pee) {
49438 var blocklist = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]';
49439
49440 pee = pee + "\n\n";
49441 pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\n\n");
49442 pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1");
49443 pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', 'gi'), "$1\n\n");
49444 pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
49445 pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
49446 pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n");
49447 pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
49448 pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
49449 pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
49450 pee = pee.replace(new RegExp('<p>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
49451 pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>');
49452 pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)', 'gi'), "$1");
49453 pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
49454 pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
49455 pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
49456 pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
49457 pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
49458 // pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 ');
49459
49460 // Fix the pre|script tags
49461 pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
49462 a = a.replace(/<br ?\/?>[\r\n]*/g, '\n');
49463 return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n');
49464 });
49465
49466 return pee;
49467 }
49468 }