Ticket #15544: 15544.diff
File 15544.diff, 7.9 KB (added by , 14 years ago) |
---|
-
wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css
46 46 background: #fff; 47 47 height: 185px; 48 48 overflow: auto; 49 position: relative; 49 50 } 50 51 #wp-link li, 51 52 #wp-link .query-notice { … … 104 105 #wp-link-update { 105 106 line-height: 23px; 106 107 float: right; 107 }108 #wp-link-update a {109 display: inline-block;110 108 } 111 No newline at end of file -
wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js
7 7 timeToTriggerRiver: 150, 8 8 minRiverAJAXDuration: 200, 9 9 riverBottomThreshold: 5, 10 keySensitivity: 100, 10 11 lastSearch: '', 11 12 init : function() { 12 13 inputs.dialog = $('#wp-link'); 13 inputs. update = $('#wp-link-update a');14 inputs.submit = $('#wp-link-submit'); 14 15 // URL 15 16 inputs.url = $('#url-field'); 16 17 // Secondary options … … 24 25 rivers.elements = $('.query-results', inputs.dialog); 25 26 26 27 // Bind event handlers 27 inputs.update.click( wpLink.update ); 28 inputs.dialog.keydown( wpLink.keydown ); 29 inputs.dialog.keyup( wpLink.keyup ); 30 inputs.submit.click( wpLink.update ); 28 31 $('#wp-link-cancel').click( function() { tinyMCEPopup.close(); } ); 29 32 30 rivers.elements.delegate('li', 'click', wpLink.selectInternalLink ) 33 // rivers.elements.delegate('li', 'click', wpLink.selectInternalLink ); 34 rivers.elements.bind('river-select', wpLink.updateFields ); 31 35 32 36 inputs.search.keyup( wpLink.searchInternalLinks ); 33 37 … … 38 42 var e; 39 43 ed = tinyMCEPopup.editor; 40 44 41 // Clear previously selected links 42 rivers.elements.find('.selected').removeClass('selected'); 45 // Refresh rivers (clear links, check visibility) 46 rivers.search.refresh(); 47 rivers.recent.refresh(); 43 48 44 49 tinyMCEPopup.restoreSelection(); 45 50 … … 52 57 if ( "_blank" == ed.dom.getAttrib(e, 'target') ) 53 58 inputs.openInNewTab.attr('checked','checked'); 54 59 // Update save prompt. 55 inputs. update.text( wpLinkL10n.update );60 inputs.submit.val( wpLinkL10n.update ); 56 61 57 62 // If there's no link, set the default values. 58 63 } else { 59 // Set URL and description to defaults. 60 // Leave the new tab setting as-is. 61 inputs.url.val('http://'); 62 inputs.title.val(''); 64 wpLink.setDefaultValues(); 63 65 // Update save prompt. 64 inputs. update.text( wpLinkL10n.save );66 inputs.submit.val( wpLinkL10n.save ); 65 67 } 66 68 67 69 tinyMCEPopup.storeSelection(); … … 141 143 tinyMCEPopup.close(); 142 144 }, 143 145 144 selectInternalLink : function() { 145 var t = $(this); 146 if ( t.hasClass('unselectable') ) 147 return; 148 t.siblings('.selected').removeClass('selected'); 149 t.addClass('selected'); 150 inputs.url.val( t.children('.item-permalink').val() ); 151 inputs.title.val( t.children('.item-title').text() ); 146 updateFields : function( e, li ) { 147 inputs.url.val( li.children('.item-permalink').val() ); 148 inputs.title.val( li.children('.item-title').text() ); 152 149 }, 150 setDefaultValues : function() { 151 // Set URL and description to defaults. 152 // Leave the new tab setting as-is. 153 inputs.url.val('http://'); 154 inputs.title.val(''); 155 }, 153 156 154 157 searchInternalLinks : function() { 155 158 var t = $(this), waiting, 156 159 search = t.val(); 157 160 158 161 if ( search.length > 2 ) { 159 rivers.recent. element.hide();160 rivers.search. element.show();162 rivers.recent.hide(); 163 rivers.search.show(); 161 164 162 165 // Don't search if the keypress didn't change the title. 163 166 if ( wpLink.lastSearch == search ) 164 167 return; 165 168 166 169 wpLink.lastSearch = search; 167 170 waiting = t.siblings('img.waiting').show(); 168 171 169 172 rivers.search.change( search ); 170 173 rivers.search.ajax( function(){ waiting.hide(); }); 171 174 } else { 172 rivers.search. element.hide();173 rivers.recent. element.show();175 rivers.search.hide(); 176 rivers.recent.show(); 174 177 } 175 178 }, 179 180 next : function() { 181 rivers.search.next(); 182 rivers.recent.next(); 183 }, 184 prev : function() { 185 rivers.search.prev(); 186 rivers.recent.prev(); 187 }, 188 189 keydown : function( event ) { 190 var fn, key = $.ui.keyCode; 191 192 switch( event.which ) { 193 case key.UP: 194 fn = 'prev'; 195 case key.DOWN: 196 fn = fn || 'next'; 197 clearInterval( wpLink.keyInterval ); 198 wpLink[ fn ](); 199 wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity ); 200 break; 201 default: 202 return; 203 } 204 event.preventDefault(); 205 }, 206 207 keyup: function( event ) { 208 var key = $.ui.keyCode; 209 210 switch( event.which ) { 211 case key.ENTER: 212 wpLink.update(); 213 break; 214 case key.UP: 215 case key.DOWN: 216 clearInterval( wpLink.keyInterval ); 217 break; 218 default: 219 return; 220 } 221 event.preventDefault(); 222 }, 176 223 177 224 delayedCallback : function( func, delay ) { 178 225 var timeoutTriggered, funcTriggered, funcArgs, funcContext; … … 205 252 this.waiting = element.find('.river-waiting'); 206 253 207 254 this.change( search ); 255 this.refresh(); 208 256 209 257 element.scroll( function(){ self.maybeLoad(); }); 258 element.delegate('li', 'click', function(){ self.select( $(this) ); }); 210 259 }; 211 260 212 261 $.extend( River.prototype, { 262 refresh: function() { 263 this.deselect(); 264 this.visible = this.element.is(':visible'); 265 }, 266 show: function() { 267 if ( ! this.visible ) { 268 this.deselect(); 269 this.element.show(); 270 this.visible = true; 271 } 272 }, 273 hide: function() { 274 this.element.hide(); 275 this.visible = false; 276 }, 277 // Selects a list item and triggers the river-select event. 278 select: function( li ) { 279 var liHeight, elHeight, liTop, elTop; 280 281 if ( li.hasClass('unselectable') || li == this.selected ) 282 return; 283 284 this.deselect(); 285 this.selected = li.addClass('selected'); 286 // Make sure the element is visible 287 liHeight = li.outerHeight(); 288 elHeight = this.element.height(); 289 liTop = li.position().top; 290 elTop = this.element.scrollTop(); 291 292 if ( liTop < 0 ) // Make first visible element 293 this.element.scrollTop( elTop + liTop ); 294 else if ( liTop + liHeight > elHeight ) // Make last visible element 295 this.element.scrollTop( elTop + liTop - elHeight + liHeight ); 296 297 // Trigger the river-select event 298 this.element.trigger('river-select', [ li, this ]); 299 }, 300 deselect: function() { 301 if ( this.selected ) 302 this.selected.removeClass('selected'); 303 this.selected = false; 304 }, 305 prev: function() { 306 if ( ! this.visible ) 307 return; 308 309 var to; 310 if ( this.selected ) { 311 to = this.selected.prev('li'); 312 if ( to.length ) 313 this.select( to ); 314 } 315 }, 316 next: function() { 317 if ( ! this.visible ) 318 return; 319 320 var to = this.selected ? this.selected.next('li') : $('li:not(.unselectable):first', this.element); 321 if ( to.length ) 322 this.select( to ); 323 }, 213 324 ajax: function( callback ) { 214 325 var self = this, 215 326 delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration, -
wp-admin/includes/internal-linking.php
70 70 */ 71 71 function wp_link_dialog() { 72 72 ?> 73 <div id="wp-link" >73 <div id="wp-link" tabindex="-1"> 74 74 <div id="link-selector"> 75 75 <div id="link-options"> 76 76 <p class="howto"><?php _e( 'Enter the destination URL:' ); ?></p> … … 113 113 <a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a> 114 114 </div> 115 115 <div id="wp-link-update"> 116 < a class="button-primary" href="#"></a>116 <?php submit_button( __('Update'), 'primary', 'wp-link-submit', false, array('tabindex' => 100)); ?> 117 117 </div> 118 118 </div> 119 119 </div>