From cf9f85dc8121a359d550ffa3b735fb48859eee88 Mon Sep 17 00:00:00 2001 From: donncha Date: Thu, 24 Apr 2008 11:45:39 +0000 Subject: Merged with WP 2.5, revision 7806 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1260 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-admin/js/editor.js | 33 ++++++++++++++++++++++++--------- wp-admin/js/post.js | 9 +++++++-- wp-admin/js/widgets.js | 4 ++-- 3 files changed, 33 insertions(+), 13 deletions(-) (limited to 'wp-admin/js') diff --git a/wp-admin/js/editor.js b/wp-admin/js/editor.js index 757fd30..50955c7 100644 --- a/wp-admin/js/editor.js +++ b/wp-admin/js/editor.js @@ -13,7 +13,7 @@ wpEditorInit = function() { switchEditors = { saveCallback : function(el, content, body) { - + document.getElementById(el).style.color = '#fff'; if ( tinyMCE.activeEditor.isHidden() ) content = document.getElementById(el).value; @@ -26,8 +26,14 @@ switchEditors = { pre_wpautop : function(content) { // We have a TON of cleanup to do. Line breaks are already stripped. + // Protect pre|script tags + content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { + a = a.replace(/
[\r\n]*/g, ''); + return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, ''); + }); + // Pretty it up for the source editor - var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|pre|p'; + var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p'; content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>'); @@ -46,7 +52,7 @@ switchEditors = { // Fix some block element newline issues content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); - + var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); @@ -65,6 +71,9 @@ switchEditors = { content = content.replace(new RegExp('^\\s*', ''), ''); content = content.replace(new RegExp('\\s*$', ''), ''); + // put back the line breaks in pre|script + content = content.replace(//g, '\n'); + // Hope. return content; }, @@ -109,7 +118,7 @@ switchEditors = { ec.style.padding = '6px'; } - ta.style.color = ''; + ta.style.color = ''; this.wpSetDefaultEditor('html'); } }, @@ -148,15 +157,21 @@ switchEditors = { pee = pee.replace(new RegExp('

\\s*?

', 'gi'), ''); pee = pee.replace(new RegExp('

\\s*(]*>)\\s*

', 'gi'), "$1"); pee = pee.replace(new RegExp("

(", 'gi'), "$1"); - pee = pee.replace(new RegExp('

]*)>', 'gi'), "

"); - pee = pee.replace(new RegExp('

', 'gi'), '

'); + pee = pee.replace(new RegExp('

\\s*]*)>', 'gi'), "

"); + pee = pee.replace(new RegExp('\\s*

', 'gi'), '

'); pee = pee.replace(new RegExp('

\\s*(]*>)', 'gi'), "$1"); pee = pee.replace(new RegExp('(]*>)\\s*

', 'gi'), "$1"); pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "
\n"); pee = pee.replace(new RegExp('(]*>)\\s*
', 'gi'), "$1"); pee = pee.replace(new RegExp('
(\\s*)', 'gi'), '$1'); - pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); - //pee = pee.replace(new RegExp('()(.*?)!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '' "); // Hmm... - return pee; + // pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); + + // Fix the pre|script tags + pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { + a = a.replace(/
[\r\n]*/g, '\n'); + return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n'); + }); + + return pee; } } diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 78b22ed..c938af3 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -118,6 +118,10 @@ jQuery(document).ready( function() { jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); noSyncChecks = false; }; + var catAddBefore = function( s ) { + s.data += '&' + jQuery( '#categorychecklist :checked' ).serialize(); + return s; + }; var catAddAfter = function( r, s ) { if ( !newCatParent ) newCatParent = jQuery('#newcat_parent'); if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' ); @@ -127,7 +131,7 @@ jQuery(document).ready( function() { var th = jQuery(this); var val = th.find('input').val(); var id = th.find('input')[0].id - jQuery('#' + id).change( syncChecks ); + jQuery('#' + id).change( syncChecks ).change(); if ( newCatParent.find( 'option[value=' + val + ']' ).size() ) return; var name = jQuery.trim( th.text() ); @@ -140,6 +144,7 @@ jQuery(document).ready( function() { jQuery('#categorychecklist').wpList( { alt: '', response: 'category-ajax-response', + addBefore: catAddBefore, addAfter: catAddAfter } ); jQuery('#category-add-toggle').click( function() { @@ -148,7 +153,7 @@ jQuery(document).ready( function() { jQuery('#newcat').focus(); return false; } ); - jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); + jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change(); jQuery('.edit-timestamp').click(function () { if (jQuery('#timestampdiv').is(":hidden")) { diff --git a/wp-admin/js/widgets.js b/wp-admin/js/widgets.js index 2802f9b..4eb37ee 100644 --- a/wp-admin/js/widgets.js +++ b/wp-admin/js/widgets.js @@ -11,7 +11,7 @@ jQuery(function($) { var widgetAnim = $.browser.msie ? function() { var t = $(this); if ( t.is(':visible') ) { - if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } + if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } li.css( 'marginLeft', 0 ); t.siblings('h4').children('a').text( widgetsL10n.edit ); } else { @@ -25,7 +25,7 @@ jQuery(function($) { var t = $(this); if ( t.is(':visible') ) { - if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } + if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } if ( width > 250 ) li.animate( { marginLeft: 0 } ); t.siblings('h4').children('a').text( widgetsL10n.edit ); -- cgit