Changeset 31919
- Timestamp:
- 03/29/2015 03:13:45 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/press-this.js
r31868 r31919 119 119 120 120 /** 121 * Replace emoji images with chars and sanitize the text content. 122 */ 123 function getTitleText() { 124 var $element = $( '#title-container' ); 125 126 $element.find( 'img.emoji' ).each( function() { 127 var $image = $( this ); 128 $image.replaceWith( $( '<span>' ).text( $image.attr( 'alt' ) ) ); 129 }); 130 131 return sanitizeText( $element.text() ); 132 } 133 134 /** 121 135 * Prepare the form data for saving. 122 136 */ … … 127 141 editor && editor.save(); 128 142 129 $( '#post_title' ).val( sanitizeText( $( '#title-container' ).text()) );143 $( '#post_title' ).val( getTitleText() ); 130 144 131 145 // Make sure to flush out the tags with tagBox before saving … … 503 517 */ 504 518 function monitorPlaceholder() { 505 var $titleField = $( '#title-container' ),506 $placeholder = $( '.post-title-placeholder');519 var $titleField = $( '#title-container' ), 520 $placeholder = $( '.post-title-placeholder' ); 507 521 508 522 $titleField.on( 'focus', function() { 509 $placeholder.addClass( 'is-hidden');523 $placeholder.addClass( 'is-hidden' ); 510 524 }).on( 'blur', function() { 511 if ( ! $titleField.text() ) { 512 $placeholder.removeClass('is-hidden'); 513 } 525 if ( ! $titleField.text() && ! $titleField.html() ) { 526 $placeholder.removeClass( 'is-hidden' ); 527 } 528 }).on( 'keyup', function() { 529 saveAlert = true; 530 }).on( 'paste', function() { 531 saveAlert = true; 532 533 setTimeout( function() { 534 $titleField.text( getTitleText() ); 535 }, 100 ); 514 536 }); 515 537 516 if ( $titleField.text() ) {538 if ( $titleField.text() || $titleField.html() ) { 517 539 $placeholder.addClass('is-hidden'); 518 540 }
Note: See TracChangeset
for help on using the changeset viewer.