Ticket #25914: wplink.diff
| File wplink.diff, 4.8 KB (added by , 12 years ago) |
|---|
-
.jshintrc
1 1 { 2 2 "boss": true, 3 "curly": true,4 "eqeqeq": true,3 "curly": false, 4 "eqeqeq": false, 5 5 "eqnull": true, 6 6 "es3": true, 7 7 "expr": true, -
src/wp-includes/js/wplink.js
1 /* global ajaxurl:true, tinymce: true, wpLinkL10n:true, tinyMCEPopup:true, setUserSetting:true, wpActiveEditor: true */ 1 2 var wpLink; 2 3 3 4 (function($){ … … 113 114 inputs.url.val( ed.dom.getAttrib(e, 'href') ); 114 115 inputs.title.val( ed.dom.getAttrib(e, 'title') ); 115 116 // Set open in new tab. 116 inputs.openInNewTab.prop('checked', ( "_blank"== ed.dom.getAttrib( e, 'target' ) ) );117 inputs.openInNewTab.prop('checked', ( '_blank' == ed.dom.getAttrib( e, 'target' ) ) ); 117 118 // Update save prompt. 118 119 inputs.submit.val( wpLinkL10n.update ); 119 120 … … 156 157 }, 157 158 158 159 htmlUpdate : function() { 159 var attrs, html, begin, end, cursor, 160 var attrs, html, begin, end, cursor, selection, 160 161 textarea = wpLink.textarea; 161 162 162 163 if ( ! textarea ) … … 201 202 if ( begin == end ) 202 203 cursor -= '</a>'.length; 203 204 204 textarea.value = textarea.value.substring( 0, begin ) 205 + html206 +textarea.value.substring( end, textarea.value.length );205 textarea.value = textarea.value.substring( 0, begin ) + 206 html + 207 textarea.value.substring( end, textarea.value.length ); 207 208 208 209 // Update cursor position 209 210 textarea.selectionStart = textarea.selectionEnd = cursor; … … 227 228 b = ed.selection.getBookmark(); 228 229 ed.dom.remove(e, 1); 229 230 ed.selection.moveToBookmark(b); 230 tinyMCEPopup.execCommand( "mceEndUndoLevel");231 tinyMCEPopup.execCommand('mceEndUndoLevel'); 231 232 wpLink.close(); 232 233 } 233 234 return; 234 235 } 235 236 236 237 if (e == null) { 237 ed.getDoc().execCommand( "unlink", false, null);238 tinyMCEPopup.execCommand( "mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});238 ed.getDoc().execCommand('unlink', false, null); 239 tinyMCEPopup.execCommand('mceInsertLink', false, '#mce_temp_url#', {skip_undo : 1}); 239 240 240 tinymce.each(ed.dom.select( "a"), function(n) {241 tinymce.each(ed.dom.select('a'), function(n) { 241 242 if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') { 242 243 e = n; 243 244 ed.dom.setAttribs(e, attrs); … … 262 263 tinyMCEPopup.storeSelection(); 263 264 } 264 265 265 ed.execCommand( "mceEndUndoLevel");266 ed.execCommand('mceEndUndoLevel'); 266 267 wpLink.close(); 267 268 ed.focus(); 268 269 }, … … 270 271 updateFields : function( e, li, originalEvent ) { 271 272 inputs.url.val( li.children('.item-permalink').val() ); 272 273 inputs.title.val( li.hasClass('no-title') ? '' : li.children('.item-title').text() ); 273 if ( originalEvent && originalEvent.type == "click")274 if ( originalEvent && originalEvent.type == 'click' ) 274 275 inputs.url.focus(); 275 276 }, 276 277 setDefaultValues : function() { … … 320 321 321 322 switch( event.which ) { 322 323 case key.UP: 323 fn = 'prev';324 324 case key.DOWN: 325 fn = fn ||'next';325 fn = key.UP ? 'prev' : 'next'; 326 326 clearInterval( wpLink.keyInterval ); 327 327 wpLink[ fn ](); 328 328 wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity ); … … 342 342 wpLink.close(); 343 343 344 344 return false; 345 break;346 345 case key.UP: 347 346 case key.DOWN: 348 347 clearInterval( wpLink.keyInterval ); … … 507 506 508 507 if ( !results ) { 509 508 if ( firstPage ) { 510 list += '<li class="unselectable"><span class="item-title"><em>' 511 + wpLinkL10n.noMatchesFound512 +'</em></span></li>';509 list += '<li class="unselectable"><span class="item-title"><em>' + 510 wpLinkL10n.noMatchesFound + 511 '</em></span></li>'; 513 512 } 514 513 } else { 515 514 $.each( results, function() { 516 515 classes = alt ? 'alternate' : ''; 517 classes += this ['title']? '' : ' no-title';516 classes += this.title ? '' : ' no-title'; 518 517 list += classes ? '<li class="' + classes + '">' : '<li>'; 519 list += '<input type="hidden" class="item-permalink" value="' + this ['permalink']+ '" />';518 list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />'; 520 519 list += '<span class="item-title">'; 521 list += this ['title'] ? this['title']: wpLinkL10n.noTitle;522 list += '</span><span class="item-info">' + this ['info']+ '</span></li>';520 list += this.title ? this.title : wpLinkL10n.noTitle; 521 list += '</span><span class="item-info">' + this.info + '</span></li>'; 523 522 alt = ! alt; 524 523 }); 525 524 } … … 578 577 self.querying = false; 579 578 self.allLoaded = !r; 580 579 callback( r, query ); 581 }, "json");580 }, 'json' ); 582 581 } 583 582 }); 584 583