Ticket #25914: 25914.diff
| File 25914.diff, 5.0 KB (added by , 12 years ago) |
|---|
-
src/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 + 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 ); … … 333 333 event.preventDefault(); 334 334 }, 335 335 keyup: function( event ) { 336 var key = $.ui.keyCode; 336 var key = $.ui.keyCode, 337 returnStatus; 337 338 338 339 switch( event.which ) { 339 340 case key.ESCAPE: 340 341 event.stopImmediatePropagation(); 341 342 if ( ! $(document).triggerHandler( 'wp_CloseOnEscape', [{ event: event, what: 'wplink', cb: wpLink.close }] ) ) 342 343 wpLink.close(); 343 344 return false; 344 returnStatus = false; 345 345 break; 346 346 case key.UP: 347 347 case key.DOWN: … … 350 350 default: 351 351 return; 352 352 } 353 if (typeof(returnStatus) !== 'undefined') 354 return returnStatus; 353 355 event.preventDefault(); 354 356 }, 355 357 … … 507 509 508 510 if ( !results ) { 509 511 if ( firstPage ) { 510 list += '<li class="unselectable"><span class="item-title"><em>' 511 + wpLinkL10n.noMatchesFound512 +'</em></span></li>';512 list += '<li class="unselectable"><span class="item-title"><em>' + 513 wpLinkL10n.noMatchesFound + 514 '</em></span></li>'; 513 515 } 514 516 } else { 515 517 $.each( results, function() { 516 518 classes = alt ? 'alternate' : ''; 517 classes += this ['title']? '' : ' no-title';519 classes += this.title ? '' : ' no-title'; 518 520 list += classes ? '<li class="' + classes + '">' : '<li>'; 519 list += '<input type="hidden" class="item-permalink" value="' + this ['permalink']+ '" />';521 list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />'; 520 522 list += '<span class="item-title">'; 521 list += this ['title'] ? this['title']: wpLinkL10n.noTitle;522 list += '</span><span class="item-info">' + this ['info']+ '</span></li>';523 list += this.title ? this.title : wpLinkL10n.noTitle; 524 list += '</span><span class="item-info">' + this.info + '</span></li>'; 523 525 alt = ! alt; 524 526 }); 525 527 } … … 578 580 self.querying = false; 579 581 self.allLoaded = !r; 580 582 callback( r, query ); 581 }, "json");583 }, 'json' ); 582 584 } 583 585 }); 584 586