Add emoji URL support, and Twemoji fallback for displaying slugs in wp-admin, when the browser doesn't natively support emoji.

Props pento, SergeyBiryukov and boonebgorges.

Fixes #31328



git-svn-id: https://develop.svn.wordpress.org/trunk@31734 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2015-03-11 22:54:49 +00:00
parent ae391ec226
commit 1357e7fc2e
12 changed files with 81 additions and 48 deletions
+13 -3
View File
@@ -117,7 +117,7 @@ inlineEditPost = {
},
edit : function(id) {
var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, cur_format, f;
var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, cur_format, f, val;
t.revert();
if ( typeof(id) === 'object' ) {
@@ -155,7 +155,11 @@ inlineEditPost = {
});
for ( f = 0; f < fields.length; f++ ) {
$(':input[name="' + fields[f] + '"]', editRow).val( $('.'+fields[f], rowData).text() );
val = $('.'+fields[f], rowData);
// Deal with Twemoji
val.find( 'img' ).replaceWith( function() { return this.alt; } );
val = val.text();
$(':input[name="' + fields[f] + '"]', editRow).val( val );
}
if ( $( '.comment_status', rowData ).text() === 'open' ) {
@@ -181,11 +185,14 @@ inlineEditPost = {
//flat taxonomies
$('.tags_input', rowData).each(function(){
var terms = $(this).text(),
var terms = $(this),
taxname = $(this).attr('id').replace('_' + id, ''),
textarea = $('textarea.tax_input_' + taxname, editRow),
comma = inlineEditL10n.comma;
terms.find( 'img' ).replaceWith( function() { return this.alt; } );
terms = terms.text();
if ( terms ) {
if ( ',' !== comma ) {
terms = terms.replace(/,/g, comma);
@@ -265,6 +272,9 @@ inlineEditPost = {
if ( -1 !== r.indexOf( '<tr' ) ) {
$(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove();
$('#edit-'+id).before(r).remove();
if ( WPEmoji ) {
WPEmoji.parse( $( inlineEditPost.what + id ).get( 0 ) );
}
$(inlineEditPost.what+id).hide().fadeIn();
} else {
r = r.replace( /<.[^<>]*?>/g, '' );
+14 -3
View File
@@ -45,7 +45,7 @@ inlineEditTax = {
},
edit : function(id) {
var editRow, rowData,
var editRow, rowData, val,
t = this;
t.revert();
@@ -58,8 +58,15 @@ inlineEditTax = {
$(t.what+id).hide().before(editRow).before('<tr class="hidden"></tr>');
$(':input[name="name"]', editRow).val( $('.name', rowData).text() );
$(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
val = $('.name', rowData);
val.find( 'img' ).replaceWith( function() { return this.alt; } );
val = val.text();
$(':input[name="name"]', editRow).val( val );
val = $('.slug', rowData);
val.find( 'img' ).replaceWith( function() { return this.alt; } );
val = val.text();
$(':input[name="slug"]', editRow).val( val );
$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
$('.ptitle', editRow).eq(0).focus();
@@ -110,6 +117,10 @@ inlineEditTax = {
// Update the value in the Parent dropdown.
$( '#parent' ).find( 'option[value=' + option_value + ']' ).text( row.find( '.row-title' ).text() );
if ( WPEmoji ) {
WPEmoji.parse( row.get( 0 ) );
}
row.hide().fadeIn();
} else {
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
+10 -1
View File
@@ -712,7 +712,11 @@ jQuery(document).ready( function($) {
revert_slug = real_slug.val(),
b = $('#edit-slug-buttons'),
revert_b = b.html(),
full = $('#editable-post-name-full').html();
full = $('#editable-post-name-full');
// Deal with Twemoji in the post-name
full.find( 'img' ).replaceWith( function() { return this.alt; } );
full = full.html();
$('#view-post-btn').hide();
b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>');
@@ -736,6 +740,11 @@ jQuery(document).ready( function($) {
box.removeClass('hidden');
});
}
if ( WPEmoji ) {
WPEmoji.parse( box.get( 0 ) );
}
b.html(revert_b);
real_slug.val(new_slug);
$('#view-post-btn').show();
+4
View File
@@ -49,6 +49,10 @@ jQuery(document).ready(function($) {
else
$( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm
if ( WPEmoji ) {
WPEmoji.parse( $( '.tags' ).get( 0 ) );
}
$('.tags .no-items').remove();
if ( form.find('select#parent') ) {