Press This:

- When saving, replace emoji images with chars in the title text.
- Clean up the title text on paste.
See #31768.
Built from https://develop.svn.wordpress.org/trunk@31919


git-svn-id: http://core.svn.wordpress.org/trunk@31898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-03-29 03:14:28 +00:00
parent 96b88a391b
commit 71f48f45e0
3 changed files with 31 additions and 9 deletions

View File

@ -117,6 +117,20 @@
} );
}
/**
* Replace emoji images with chars and sanitize the text content.
*/
function getTitleText() {
var $element = $( '#title-container' );
$element.find( 'img.emoji' ).each( function() {
var $image = $( this );
$image.replaceWith( $( '<span>' ).text( $image.attr( 'alt' ) ) );
});
return sanitizeText( $element.text() );
}
/**
* Prepare the form data for saving.
*/
@ -126,7 +140,7 @@
editor && editor.save();
$( '#post_title' ).val( sanitizeText( $( '#title-container' ).text() ) );
$( '#post_title' ).val( getTitleText() );
// Make sure to flush out the tags with tagBox before saving
if ( window.tagBox ) {
@ -502,18 +516,26 @@
* Interactive behavior for the post title's field placeholder
*/
function monitorPlaceholder() {
var $titleField = $( '#title-container'),
$placeholder = $('.post-title-placeholder');
var $titleField = $( '#title-container' ),
$placeholder = $( '.post-title-placeholder' );
$titleField.on( 'focus', function() {
$placeholder.addClass('is-hidden');
$placeholder.addClass( 'is-hidden' );
}).on( 'blur', function() {
if ( ! $titleField.text() ) {
$placeholder.removeClass('is-hidden');
if ( ! $titleField.text() && ! $titleField.html() ) {
$placeholder.removeClass( 'is-hidden' );
}
}).on( 'keyup', function() {
saveAlert = true;
}).on( 'paste', function() {
saveAlert = true;
setTimeout( function() {
$titleField.text( getTitleText() );
}, 100 );
});
if ( $titleField.text() ) {
if ( $titleField.text() || $titleField.html() ) {
$placeholder.addClass('is-hidden');
}
}

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta3-31918';
$wp_version = '4.2-beta3-31919';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.