Fix autosave and word count for DFW HTML editor, always update word count on autosave, see #17136
git-svn-id: https://develop.svn.wordpress.org/trunk@17936 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
39c79bac22
commit
89b108095f
File diff suppressed because one or more lines are too long
@ -619,7 +619,7 @@ form.upgrade .hint {
|
||||
}
|
||||
|
||||
#wp-fullscreen-container {
|
||||
padding: 4px 10px;
|
||||
padding: 4px 10px 50px;
|
||||
}
|
||||
|
||||
#wp-fullscreen-title,
|
||||
|
@ -270,7 +270,7 @@ wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
|
||||
<?php the_editor($post->post_content); ?>
|
||||
|
||||
<table id="post-status-info" cellspacing="0"><tbody><tr>
|
||||
<td id="wp-word-count"></td>
|
||||
<td id="wp-word-count"><?php _e('Word count:'); ?> <span class="word-count">0</span></td>
|
||||
<td class="autosave-info">
|
||||
<span id="autosave"> </span>
|
||||
<?php
|
||||
|
@ -242,7 +242,7 @@ WPRemoveThumbnail = function(nonce){
|
||||
})(jQuery);
|
||||
|
||||
jQuery(document).ready( function($) {
|
||||
var stamp, visibility, sticky = '';
|
||||
var stamp, visibility, sticky = '', last = 0, co = $('#content');
|
||||
|
||||
postboxes.add_postbox_toggles(pagenow);
|
||||
|
||||
@ -600,6 +600,24 @@ jQuery(document).ready( function($) {
|
||||
makeSlugeditClickable();
|
||||
}
|
||||
|
||||
// word count
|
||||
if ( typeof(wpWordCount) != 'undefined' ) {
|
||||
$(document).triggerHandler('wpcountwords', [ co.val() ]);
|
||||
|
||||
co.keyup( function(e) {
|
||||
var k = e.keyCode || e.charCode;
|
||||
|
||||
if ( k == last )
|
||||
return true;
|
||||
|
||||
if ( 13 == k || 8 == last || 46 == last )
|
||||
$(document).triggerHandler('wpcountwords', [ co.val() ]);
|
||||
|
||||
last = k;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
wptitlehint = function(id) {
|
||||
id = id || 'title';
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,32 +1,28 @@
|
||||
// Word count
|
||||
|
||||
(function($) {
|
||||
wpWordCount = {
|
||||
|
||||
init : function() {
|
||||
var t = this, last = 0, co = $('#content');
|
||||
|
||||
$('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '<span class="word-count">0</span>' ) );
|
||||
t.block = 0;
|
||||
t.wc(co.val());
|
||||
co.keyup( function(e) {
|
||||
if ( e.keyCode == last ) return true;
|
||||
if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val());
|
||||
last = e.keyCode;
|
||||
return true;
|
||||
});
|
||||
settings : {
|
||||
strip : /<[a-zA-Z\/][^<>]*>/g, // strip HTML tags
|
||||
clean : /[0-9.(),;:!?%#$¿'"_+=\\/-]+/g, // regexp to remove punctuation, etc.
|
||||
count : /\S\s+/g // counting regexp
|
||||
},
|
||||
|
||||
block : 0,
|
||||
|
||||
wc : function(tx) {
|
||||
var t = this, w = $('.word-count'), tc = 0;
|
||||
|
||||
if ( t.block ) return;
|
||||
if ( t.block )
|
||||
return;
|
||||
|
||||
t.block = 1;
|
||||
|
||||
setTimeout( function() {
|
||||
if ( tx ) {
|
||||
tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( / | /gi, ' ' );
|
||||
tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' );
|
||||
tx.replace( /\S\s+/g, function(){tc++;} );
|
||||
tx = tx.replace( t.settings.strip, ' ' ).replace( / | /gi, ' ' );
|
||||
tx = tx.replace( t.settings.clean, '' );
|
||||
tx.replace( t.settings.count, function(){tc++;} );
|
||||
}
|
||||
w.html(tc.toString());
|
||||
|
||||
@ -35,5 +31,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready( function(){ wpWordCount.init(); } );
|
||||
$(document).bind( 'wpcountwords', function(e, txt) {
|
||||
wpWordCount.wc(txt);
|
||||
});
|
||||
}(jQuery));
|
||||
|
@ -1 +1 @@
|
||||
(function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'<span class="word-count">0</span>'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a(".word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));
|
||||
(function(a){wpWordCount={settings:{strip:/<[a-zA-Z\/][^<>]*>/g,clean:/[0-9.(),;:!?%#$¿'"_+=\\/-]+/g,count:/\S\s+/g},block:0,wc:function(d){var e=this,c=a(".word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(e.settings.strip," ").replace(/ | /gi," ");d=d.replace(e.settings.clean,"");d.replace(e.settings.count,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).bind("wpcountwords",function(c,b){wpWordCount.wc(b)})}(jQuery));
|
@ -213,9 +213,7 @@ PubSub.prototype.publish = function( topic, args ) {
|
||||
}
|
||||
|
||||
$('#' + s.editor_id).val( content );
|
||||
|
||||
if ( 'undefined' != wpWordCount )
|
||||
wpWordCount.wc( content );
|
||||
$(document).triggerHandler('wpcountwords', [ content ]);
|
||||
}
|
||||
|
||||
set_title_hint = function( title ) {
|
||||
@ -466,10 +464,10 @@ PubSub.prototype.publish = function( topic, args ) {
|
||||
*/
|
||||
api.ui = {
|
||||
init: function() {
|
||||
var topbar = $('#fullscreen-topbar');
|
||||
var topbar = $('#fullscreen-topbar'), txtarea = $('#wp_mce_fullscreen'), last = 0;
|
||||
s.toolbars = topbar.add( $('#wp-fullscreen-status') );
|
||||
s.element = $('#fullscreen-fader');
|
||||
s.textarea_obj = document.getElementById('wp_mce_fullscreen');
|
||||
s.textarea_obj = txtarea[0];
|
||||
s.has_tinymce = typeof(tinyMCE) != 'undefined';
|
||||
|
||||
if ( !s.has_tinymce )
|
||||
@ -479,7 +477,7 @@ PubSub.prototype.publish = function( topic, args ) {
|
||||
wptitlehint('wp-fullscreen-title');
|
||||
|
||||
$(document).keyup(function(e){
|
||||
var c = e.charCode || e.keyCode, a;
|
||||
var c = e.keyCode || e.charCode, a;
|
||||
|
||||
if ( !fullscreen.settings.visible )
|
||||
return true;
|
||||
@ -504,6 +502,23 @@ PubSub.prototype.publish = function( topic, args ) {
|
||||
return true;
|
||||
});
|
||||
|
||||
// word count in HTML mode
|
||||
if ( typeof(wpWordCount) != 'undefined' ) {
|
||||
|
||||
txtarea.keyup( function(e) {
|
||||
var k = e.keyCode || e.charCode;
|
||||
|
||||
if ( k == last )
|
||||
return true;
|
||||
|
||||
if ( 13 == k || 8 == last || 46 == last )
|
||||
$(document).triggerHandler('wpcountwords', [ txtarea.val() ]);
|
||||
|
||||
last = k;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
topbar.mouseenter(function(e){
|
||||
s.toolbars.addClass('fullscreen-make-sticky');
|
||||
$( document ).unbind( '.fullscreen' );
|
||||
|
File diff suppressed because one or more lines are too long
@ -34,7 +34,7 @@ jQuery(document).ready( function($) {
|
||||
if ( mce.isDirty() )
|
||||
return autosaveL10n.saveAlert;
|
||||
} else {
|
||||
if ( fullscreen && fullscreen.visible ) {
|
||||
if ( fullscreen && fullscreen.settings.visible ) {
|
||||
title = $('#wp-fullscreen-title').val();
|
||||
content = $("#wp_mce_fullscreen").val();
|
||||
} else {
|
||||
@ -164,7 +164,7 @@ function autosave_update_slug(post_id) {
|
||||
jQuery.post( ajaxurl, {
|
||||
action: 'sample-permalink',
|
||||
post_id: post_id,
|
||||
new_title: fullscreen && fullscreen.visible ? jQuery('#wp-fullscreen-title').val() : jQuery('#title').val(),
|
||||
new_title: fullscreen && fullscreen.settings.visible ? jQuery('#wp-fullscreen-title').val() : jQuery('#title').val(),
|
||||
samplepermalinknonce: jQuery('#samplepermalinknonce').val()
|
||||
},
|
||||
function(data) {
|
||||
@ -244,7 +244,7 @@ autosave = function() {
|
||||
}
|
||||
}
|
||||
|
||||
if ( fullscreen && fullscreen.visible ) {
|
||||
if ( fullscreen && fullscreen.settings.visible ) {
|
||||
post_data["post_title"] = jQuery('#wp-fullscreen-title').val();
|
||||
post_data["content"] = jQuery("#wp_mce_fullscreen").val();
|
||||
} else {
|
||||
@ -284,6 +284,7 @@ autosave = function() {
|
||||
|
||||
if ( doAutoSave ) {
|
||||
autosaveLast = post_data["post_title"] + post_data["content"];
|
||||
jQuery(document).triggerHandler('wpcountwords', [ post_data["content"] ]);
|
||||
} else {
|
||||
post_data['autosave'] = 0;
|
||||
}
|
||||
@ -299,7 +300,7 @@ autosave = function() {
|
||||
data: post_data,
|
||||
beforeSend: doAutoSave ? autosave_loading : null,
|
||||
type: "POST",
|
||||
url: autosaveL10n.requestFile,
|
||||
url: ajaxurl,
|
||||
success: successCallback
|
||||
});
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -195,12 +195,18 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Word count if script is loaded
|
||||
if ( 'undefined' != typeof wpWordCount ) {
|
||||
// Word count
|
||||
if ( 'undefined' != typeof(jQuery) ) {
|
||||
ed.onKeyUp.add(function(ed, e) {
|
||||
if ( e.keyCode == last ) return;
|
||||
if ( 13 == e.keyCode || 8 == last || 46 == last ) wpWordCount.wc( ed.getContent({format : 'raw'}) );
|
||||
last = e.keyCode;
|
||||
var k = e.keyCode || e.charCode;
|
||||
|
||||
if ( k == last )
|
||||
return;
|
||||
|
||||
if ( 13 == k || 8 == last || 46 == last )
|
||||
jQuery(document).triggerHandler('wpcountwords', [ ed.getContent({format : 'raw'}) ]);
|
||||
|
||||
last = k;
|
||||
});
|
||||
};
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -96,7 +96,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110411' );
|
||||
$scripts->add_data( 'editor', 'group', 1 );
|
||||
|
||||
$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110514' );
|
||||
$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110515' );
|
||||
$scripts->add_data( 'wp-fullscreen', 'group', 1 );
|
||||
|
||||
$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6.1');
|
||||
@ -109,7 +109,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'
|
||||
) );
|
||||
|
||||
$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110514' );
|
||||
$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110515' );
|
||||
$scripts->add_data( 'autosave', 'group', 1 );
|
||||
|
||||
$scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20110504' );
|
||||
@ -327,7 +327,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20110511' );
|
||||
$scripts->add_data( 'postbox', 'group', 1 );
|
||||
|
||||
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110512' );
|
||||
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110515' );
|
||||
$scripts->add_data( 'post', 'group', 1 );
|
||||
$scripts->localize( 'post', 'postL10n', array(
|
||||
'tagsUsed' => __('Tags used on this post:'),
|
||||
@ -376,12 +376,8 @@ function wp_default_scripts( &$scripts ) {
|
||||
$scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), '20110506' );
|
||||
$scripts->add_data( 'admin-widgets', 'group', 1 );
|
||||
|
||||
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20110424' );
|
||||
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20110515' );
|
||||
$scripts->add_data( 'word-count', 'group', 1 );
|
||||
$scripts->localize( 'word-count', 'wordCountL10n', array(
|
||||
'count' => __('Word count: %d'),
|
||||
'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};'
|
||||
));
|
||||
|
||||
$scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'thickbox' ), '20110118' );
|
||||
$scripts->add_data( 'theme', 'group', 1 );
|
||||
@ -486,7 +482,7 @@ function wp_default_styles( &$styles ) {
|
||||
// Any rtl stylesheets that don't have a .dev version for ltr
|
||||
$no_suffix = array( 'farbtastic' );
|
||||
|
||||
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110512b' );
|
||||
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110515' );
|
||||
|
||||
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20101102' );
|
||||
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
|
||||
@ -564,9 +560,6 @@ function wp_just_in_time_script_localization() {
|
||||
|
||||
wp_localize_script( 'autosave', 'autosaveL10n', array(
|
||||
'autosaveInterval' => AUTOSAVE_INTERVAL,
|
||||
'previewPageText' => __('Preview this Page'),
|
||||
'previewPostText' => __('Preview this Post'),
|
||||
'requestFile' => admin_url('admin-ajax.php'),
|
||||
'savingText' => __('Saving Draft…'),
|
||||
'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
|
||||
'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};'
|
||||
|
@ -36,7 +36,7 @@ $wp_db_version = 17517;
|
||||
*
|
||||
* @global string $tinymce_version
|
||||
*/
|
||||
$tinymce_version = '342-20110510';
|
||||
$tinymce_version = '342-20110515';
|
||||
|
||||
/**
|
||||
* Holds the cache manifest version
|
||||
|
Loading…
Reference in New Issue
Block a user