Make WordPress Core

Ticket #15544: 15544.diff

File 15544.diff, 7.9 KB (added by koopersmith, 13 years ago)
  • wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css

     
    4646        background: #fff;
    4747        height: 185px;
    4848        overflow: auto;
     49        position: relative;
    4950}
    5051#wp-link li,
    5152#wp-link .query-notice {
     
    104105#wp-link-update {
    105106        line-height: 23px;
    106107        float: right;
    107 }
    108 #wp-link-update a {
    109         display: inline-block;
    110108}
    111  No newline at end of file
  • wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js

     
    77                timeToTriggerRiver: 150,
    88                minRiverAJAXDuration: 200,
    99                riverBottomThreshold: 5,
     10                keySensitivity: 100,
    1011                lastSearch: '',
    1112                init : function() {
    1213                        inputs.dialog = $('#wp-link');
    13                         inputs.update = $('#wp-link-update a');
     14                        inputs.submit = $('#wp-link-submit');
    1415                        // URL
    1516                        inputs.url = $('#url-field');
    1617                        // Secondary options
     
    2425                        rivers.elements = $('.query-results', inputs.dialog);
    2526
    2627                        // 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 );
    2831                        $('#wp-link-cancel').click( function() { tinyMCEPopup.close(); } );
    2932                       
    30                         rivers.elements.delegate('li', 'click', wpLink.selectInternalLink )
     33                        // rivers.elements.delegate('li', 'click', wpLink.selectInternalLink );
     34                        rivers.elements.bind('river-select', wpLink.updateFields );
    3135                       
    3236                        inputs.search.keyup( wpLink.searchInternalLinks );
    3337                       
     
    3842                        var e;
    3943                        ed = tinyMCEPopup.editor;
    4044                       
    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();
    4348                       
    4449                        tinyMCEPopup.restoreSelection();
    4550
     
    5257                                if ( "_blank" == ed.dom.getAttrib(e, 'target') )
    5358                                        inputs.openInNewTab.attr('checked','checked');
    5459                                // Update save prompt.
    55                                 inputs.update.text( wpLinkL10n.update );
     60                                inputs.submit.val( wpLinkL10n.update );
    5661
    5762                        // If there's no link, set the default values.
    5863                        } 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();
    6365                                // Update save prompt.
    64                                 inputs.update.text( wpLinkL10n.save );
     66                                inputs.submit.val( wpLinkL10n.save );
    6567                        }
    6668
    6769                        tinyMCEPopup.storeSelection();
     
    141143                        tinyMCEPopup.close();
    142144                },
    143145
    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() );
    152149                },
     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                },
    153156
    154157                searchInternalLinks : function() {
    155158                        var t = $(this), waiting,
    156159                                search = t.val();
    157160
    158161                        if ( search.length > 2 ) {
    159                                 rivers.recent.element.hide();
    160                                 rivers.search.element.show();
     162                                rivers.recent.hide();
     163                                rivers.search.show();
    161164
    162165                                // Don't search if the keypress didn't change the title.
    163166                                if ( wpLink.lastSearch == search )
    164167                                        return;
    165 
     168                               
    166169                                wpLink.lastSearch = search;
    167170                                waiting = t.siblings('img.waiting').show();
    168171
    169172                                rivers.search.change( search );
    170173                                rivers.search.ajax( function(){ waiting.hide(); });
    171174                        } else {
    172                                 rivers.search.element.hide();
    173                                 rivers.recent.element.show();
     175                                rivers.search.hide();
     176                                rivers.recent.show();
    174177                        }
    175178                },
     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                },
    176223
    177224                delayedCallback : function( func, delay ) {
    178225                        var timeoutTriggered, funcTriggered, funcArgs, funcContext;
     
    205252                this.waiting = element.find('.river-waiting');
    206253               
    207254                this.change( search );
     255                this.refresh();
    208256               
    209257                element.scroll( function(){ self.maybeLoad(); });
     258                element.delegate('li', 'click', function(){ self.select( $(this) ); });
    210259        };
    211260       
    212261        $.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                },
    213324                ajax: function( callback ) {
    214325                        var self = this,
    215326                                delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration,
  • wp-admin/includes/internal-linking.php

     
    7070 */
    7171function wp_link_dialog() {
    7272?>
    73 <div id="wp-link">
     73<div id="wp-link" tabindex="-1">
    7474<div id="link-selector">
    7575        <div id="link-options">
    7676                <p class="howto"><?php _e( 'Enter the destination URL:' ); ?></p>
     
    113113                <a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a>
    114114        </div>
    115115        <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)); ?>
    117117        </div>
    118118</div>
    119119</div>