Ticket #25914: 25914.2.diff
| File 25914.2.diff, 5.6 KB (added by , 12 years ago) |
|---|
-
wp-includes/js/wplink.js
1 /* global ajaxurl, tinymce, wpLinkL10n, tinyMCEPopup, setUserSetting, wpActiveEditor */ 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 + html 206 + textarea.value.substring( end, textarea.value.length ); 205 textarea.value = textarea.value.substring( 0, begin ) + html + 206 textarea.value.substring( end, textarea.value.length ); 207 207 208 208 // Update cursor position 209 209 textarea.selectionStart = textarea.selectionEnd = cursor; … … 227 227 b = ed.selection.getBookmark(); 228 228 ed.dom.remove(e, 1); 229 229 ed.selection.moveToBookmark(b); 230 tinyMCEPopup.execCommand( "mceEndUndoLevel");230 tinyMCEPopup.execCommand('mceEndUndoLevel'); 231 231 wpLink.close(); 232 232 } 233 233 return; … … 234 234 } 235 235 236 236 if (e == null) { 237 ed.getDoc().execCommand( "unlink", false, null);238 tinyMCEPopup.execCommand( "mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});237 ed.getDoc().execCommand('unlink', false, null); 238 tinyMCEPopup.execCommand('mceInsertLink', false, '#mce_temp_url#', {skip_undo : 1}); 239 239 240 tinymce.each(ed.dom.select( "a"), function(n) {240 tinymce.each(ed.dom.select('a'), function(n) { 241 241 if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') { 242 242 e = n; 243 243 ed.dom.setAttribs(e, attrs); … … 262 262 tinyMCEPopup.storeSelection(); 263 263 } 264 264 265 ed.execCommand( "mceEndUndoLevel");265 ed.execCommand('mceEndUndoLevel'); 266 266 wpLink.close(); 267 267 ed.focus(); 268 268 }, … … 270 270 updateFields : function( e, li, originalEvent ) { 271 271 inputs.url.val( li.children('.item-permalink').val() ); 272 272 inputs.title.val( li.hasClass('no-title') ? '' : li.children('.item-title').text() ); 273 if ( originalEvent && originalEvent.type == "click")273 if ( originalEvent && originalEvent.type == 'click' ) 274 274 inputs.url.focus(); 275 275 }, 276 276 setDefaultValues : function() { … … 318 318 keydown : function( event ) { 319 319 var fn, key = $.ui.keyCode; 320 320 321 switch( event.which ) { 322 case key.UP: 323 fn = 'prev'; 324 case key.DOWN: 325 fn = fn || 'next'; 326 clearInterval( wpLink.keyInterval ); 327 wpLink[ fn ](); 328 wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity ); 329 break; 330 default: 331 return; 321 if ( event.which !== key.UP && event.which !== key.DOWN ) { 322 return; 332 323 } 324 325 fn = event.which === key.UP ? 'prev' : 'next'; 326 clearInterval( wpLink.keyInterval ); 327 wpLink[ fn ](); 328 wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity ); 333 329 event.preventDefault(); 334 330 }, 331 335 332 keyup: function( event ) { 336 333 var key = $.ui.keyCode; 337 334 338 switch( event.which ) { 339 case key.ESCAPE: 340 event.stopImmediatePropagation(); 341 if ( ! $(document).triggerHandler( 'wp_CloseOnEscape', [{ event: event, what: 'wplink', cb: wpLink.close }] ) ) 342 wpLink.close(); 335 if ( event.which === key.ESCAPE ) { 336 event.stopImmediatePropagation(); 337 if ( ! $(document).triggerHandler( 'wp_CloseOnEscape', [{ event: event, what: 'wplink', cb: wpLink.close }] ) ) 338 wpLink.close(); 339 return false; 340 } 343 341 344 return false; 345 break; 346 case key.UP: 347 case key.DOWN: 348 clearInterval( wpLink.keyInterval ); 349 break; 350 default: 351 return; 342 if ( event.which === key.UP || event.which === key.DOWN ) { 343 clearInterval( wpLink.keyInterval ); 344 event.preventDefault(); 352 345 } 353 event.preventDefault();354 346 }, 355 347 356 348 delayedCallback : function( func, delay ) { … … 507 499 508 500 if ( !results ) { 509 501 if ( firstPage ) { 510 list += '<li class="unselectable"><span class="item-title"><em>' 511 + wpLinkL10n.noMatchesFound512 +'</em></span></li>';502 list += '<li class="unselectable"><span class="item-title"><em>' + 503 wpLinkL10n.noMatchesFound + 504 '</em></span></li>'; 513 505 } 514 506 } else { 515 507 $.each( results, function() { 516 508 classes = alt ? 'alternate' : ''; 517 classes += this ['title']? '' : ' no-title';509 classes += this.title ? '' : ' no-title'; 518 510 list += classes ? '<li class="' + classes + '">' : '<li>'; 519 list += '<input type="hidden" class="item-permalink" value="' + this ['permalink']+ '" />';511 list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />'; 520 512 list += '<span class="item-title">'; 521 list += this ['title'] ? this['title']: wpLinkL10n.noTitle;522 list += '</span><span class="item-info">' + this ['info']+ '</span></li>';513 list += this.title ? this.title : wpLinkL10n.noTitle; 514 list += '</span><span class="item-info">' + this.info + '</span></li>'; 523 515 alt = ! alt; 524 516 }); 525 517 } … … 578 570 self.querying = false; 579 571 self.allLoaded = !r; 580 572 callback( r, query ); 581 }, "json");573 }, 'json' ); 582 574 } 583 575 }); 584 576