Ticket #31373: length-less.diff
File length-less.diff, 6.3 KB (added by , 10 years ago) |
---|
-
src/wp-admin/js/press-this.js
102 102 function getCanonicalLink() { 103 103 var link = ''; 104 104 105 if ( data._links ) { 106 if ( data._links.canonical && data._links.canonical.length ) { 107 link = data._links.canonical; 108 } 105 if ( data._links && data._links.canonical ) { 106 link = data._links.canonical; 109 107 } 110 108 111 if ( ! link .length&& data.u ) {109 if ( ! link && data.u ) { 112 110 link = data.u; 113 111 } 114 112 115 if ( ! link .length&& data._meta ) {116 if ( data._meta['twitter:url'] && data._meta['twitter:url'].length) {113 if ( ! link && data._meta ) { 114 if ( data._meta['twitter:url'] ) { 117 115 link = data._meta['twitter:url']; 118 } else if ( data._meta['og:url'] && data._meta['og:url'].length) {116 } else if ( data._meta['og:url'] ) { 119 117 link = data._meta['og:url']; 120 118 } 121 119 } … … 132 130 var name = ''; 133 131 134 132 if ( data._meta ) { 135 if ( data._meta['og:site_name'] && data._meta['og:site_name'].length) {133 if ( data._meta['og:site_name'] ) { 136 134 name = data._meta['og:site_name']; 137 } else if ( data._meta['application-name'] && data._meta['application-name'].length) {135 } else if ( data._meta['application-name'] ) { 138 136 name = data._meta['application-name']; 139 137 } 140 138 } … … 155 153 } 156 154 157 155 if ( ! title && data._meta ) { 158 if ( data._meta['twitter:title'] && data._meta['twitter:title'].length) {156 if ( data._meta['twitter:title'] ) { 159 157 title = data._meta['twitter:title']; 160 } else if ( data._meta['og:title'] && data._meta['og:title'].length) {158 } else if ( data._meta['og:title'] ) { 161 159 title = data._meta['og:title']; 162 } else if ( data._meta.title && data._meta.title.length) {160 } else if ( data._meta.title ) { 163 161 title = data._meta.title; 164 162 } 165 163 } … … 185 183 url = getCanonicalLink(), 186 184 siteName = getSourceSiteName(); 187 185 188 if ( data.s && data.s.length) {186 if ( data.s ) { 189 187 text = data.s; 190 188 } else if ( data._meta ) { 191 if ( data._meta['twitter:description'] && data._meta['twitter:description'].length) {189 if ( data._meta['twitter:description'] ) { 192 190 text = data._meta['twitter:description']; 193 } else if ( data._meta['og:description'] && data._meta['og:description'].length) {191 } else if ( data._meta['og:description'] ) { 194 192 text = data._meta['og:description']; 195 } else if ( data._meta.description && data._meta.description.length) {193 } else if ( data._meta.description ) { 196 194 text = data._meta.description; 197 195 } 198 196 } … … 220 218 interestingEmbeds = [], 221 219 alreadySelected = []; 222 220 223 if ( embeds .length) {221 if ( embeds ) { 224 222 $.each( embeds, function ( i, src ) { 225 if ( ! src || !src.length) {223 if ( ! src ) { 226 224 // Skip: no src value 227 225 return; 228 226 } … … 252 250 interestingImgs = [], 253 251 alreadySelected = []; 254 252 255 if ( imgs .length) {253 if ( imgs ) { 256 254 $.each( imgs, function ( i, src ) { 257 255 src = src.replace( /http:\/\/[\d]+\.gravatar\.com\//, 'https://secure.gravatar.com/' ); 258 256 src = checkUrl( src ); 259 257 260 if ( ! src || ! src.length) {258 if ( ! src ) { 261 259 // Skip: no src value 262 260 return; 263 261 } … … 369 367 link = checkUrl( link ); 370 368 371 369 if ( 'img' === type ) { 372 if ( ! link || ! link.length) {370 if ( ! link ) { 373 371 link = src; 374 372 } 375 373 … … 419 417 .append( $( '<input type="checkbox" name="post_category[]" checked>' ).attr( 'value', newCat.term_id ) ) ); 420 418 421 419 if ( newCat.parent ) { 422 if ( ! $ul || ! $ul.length) {420 if ( ! $ul ) { 423 421 $parent = $wrap.find( '#category-' + newCat.parent ); 424 422 $ul = $parent.find( 'ul.children:first' ); 425 423 426 if ( ! $ul .length) {424 if ( ! $ul ) { 427 425 $ul = $( '<ul class="children">' ).appendTo( $parent ); 428 426 } 429 427 } … … 480 478 */ 481 479 function renderStartupNotices() { 482 480 // Render errors sent in the data, if any 483 if ( data.errors && data.errors.length) {481 if ( data.errors ) { 484 482 $.each( data.errors, function( i, msg ) { 485 483 renderError( msg ); 486 484 } ); … … 521 519 * Render the suggested content, if any 522 520 */ 523 521 function renderSuggestedContent() { 524 if ( ! suggestedContentStr || ! suggestedContentStr.length) {522 if ( ! suggestedContentStr ) { 525 523 return; 526 524 } 527 525 … … 547 545 548 546 listContainer.empty(); 549 547 550 if ( ( interestingEmbeds && interestingEmbeds.length ) || ( interestingImages && interestingImages.length )) {548 if ( interestingEmbeds || interestingImages ) { 551 549 listContainer.append( '<h2 class="screen-reader-text">' + __( 'allMediaHeading' ) + '</h2><ul class="wppt-all-media-list"/>' ); 552 550 } 553 551 554 if ( interestingEmbeds && interestingEmbeds.length) {552 if ( interestingEmbeds ) { 555 553 $.each( interestingEmbeds, function ( i, src ) { 556 554 src = checkUrl( src ); 557 555 … … 580 578 'class': cssClass, 581 579 'tabindex': '0' 582 580 } ).css( { 583 'background-image': ( displaySrc .length) ? 'url(' + displaySrc + ')' : null581 'background-image': ( displaySrc ) ? 'url(' + displaySrc + ')' : null 584 582 } ).html( 585 583 '<span class="screen-reader-text">' + __( 'suggestedEmbedAlt' ).replace( '%d', i + 1 ) + '</span>' 586 584 ).on( 'click keypress', function ( e ) { … … 593 591 } ); 594 592 } 595 593 596 if ( interestingImages && interestingImages.length) {594 if ( interestingImages ) { 597 595 $.each( interestingImages, function ( i, src ) { 598 596 src = checkUrl( src ); 599 597 … … 748 746 } ); 749 747 750 748 $selector.on( 'blur', function() { 751 var textLength = $( this ).text().length; 752 753 if ( ! textLength ) { 749 if ( ! $( this ).text() ) { 754 750 $placeholder.removeClass('is-hidden'); 755 751 } 756 752 } ); … … 805 801 // Needs more work, doesn't detect when the other JS changes the value of #tax-input-post_tag 806 802 $( '#tax-input-post_tag' ).on( 'change', function() { 807 803 var val = $( this ).val(); 808 $( '#post-option-tags' ).text( ( val .length) ? val.replace( /,([^\s])/g, ', $1' ) : '' );804 $( '#post-option-tags' ).text( ( val ) ? val.replace( /,([^\s])/g, ', $1' ) : '' ); 809 805 } ); 810 806 811 807 $( window ).on( 'beforeunload.press-this', function() {