WordPress.org

Make WordPress Core

Changeset 16561


Ignore:
Timestamp:
11/24/2010 06:44:46 AM (8 years ago)
Author:
markjaquith
Message:

Make Linking and Internal Linking keyboard-friendly and URL-paste-friendly. props koopersmith. fixes #15544

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/internal-linking.php

    r16510 r16561  
    7171function wp_link_dialog() {
    7272?>
    73 <div id="wp-link">
     73<form 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>
    7777        <div>
    78             <label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" /></label>
     78            <label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" tabindex="10" autocomplete="off" /></label>
    7979        </div>
    8080        <div>
    81             <label><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" /></label>
     81            <label><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" tabindex="20" autocomplete="off" /></label>
    8282        </div>
    8383        <div class="link-target">
    84             <label><input type="checkbox" id="link-target-checkbox" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
     84            <label><input type="checkbox" id="link-target-checkbox" tabindex="30" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
    8585        </div>
    8686    </div>
     
    9090            <label for="search-field">
    9191                <span><?php _e( 'Search' ); ?></span>
    92                 <input type="text" id="search-field" class="link-search-field" />
     92                <input type="text" id="search-field" class="link-search-field" tabindex="60" autocomplete="off" />
    9393                <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
    9494            </label>
     
    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>
    119 </div>
     119</form>
    120120<?php
    121121}
  • trunk/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js

    r16532 r16561  
    3737        }
    3838    });
     39   
     40    $(document).ready(function() {
     41        $.widget("wp.wpdialog", $.ui.dialog, {
     42            open: function() {
     43                // Initialize tinyMCEPopup if it exists.
     44                if ( tinyMCEPopup )
     45                    tinyMCEPopup.init();
     46                // Open the dialog.
     47                $.ui.dialog.prototype.open.apply( this, arguments );
     48                // WebKit leaves focus in the TinyMCE editor unless we shift focus.
     49                this.element.focus();
     50                this._trigger('refresh');
     51            }
     52        });
     53    });
    3954
    4055    tinymce.create('tinymce.WPWindowManager:tinymce.InlineWindowManager', {
     
    6176           
    6277            // Store selection
    63             t.bookmark = t.editor.selection.getBookmark();
     78            t.bookmark = t.editor.selection.getBookmark(1);
    6479           
    65             if ( tinyMCEPopup )
    66                 tinyMCEPopup.init();
    67            
    68             element.dialog({
     80            element.wpdialog({
    6981                title: f.title,
    7082                width: f.width,
     
    7688        },
    7789        close : wpDialogFn(function() {
    78             this.element.dialog('close');
     90            this.element.wpdialog('close');
    7991        })
    8092    });
  • trunk/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js

    r16532 r16561  
    1 (function(b){var a=function(c){return function(){if(this.features.wpDialog){return c.apply(this,arguments)}else{return this.parent.apply(this,arguments)}}};tinymce.create("tinymce.plugins.WPDialogs",{init:function(c,d){c.onBeforeRenderUI.add(function(){c.windowManager=new tinymce.WPWindowManager(c)})},getInfo:function(){return{longname:"WPDialogs",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"0.1"}}});tinymce.create("tinymce.WPWindowManager:tinymce.InlineWindowManager",{WPWindowManager:function(c){this.parent(c)},open:function(e,g){var d=this,c;if(!e.wpDialog){return this.parent(e,g)}else{if(!e.id){return}}c=b("#"+e.id);if(!c.length){return}d.features=e;d.params=g;d.onOpen.dispatch(d,e,g);d.element=d.windows[e.id]=c;d.bookmark=d.editor.selection.getBookmark();if(tinyMCEPopup){tinyMCEPopup.init()}c.dialog({title:e.title,width:e.width,height:e.height,modal:true,dialogClass:"wp-dialog",zIndex:300000})},close:a(function(){this.element.dialog("close")})});tinymce.PluginManager.add("wpdialogs",tinymce.plugins.WPDialogs)})(jQuery);
     1(function(b){var a=function(c){return function(){if(this.features.wpDialog){return c.apply(this,arguments)}else{return this.parent.apply(this,arguments)}}};tinymce.create("tinymce.plugins.WPDialogs",{init:function(c,d){c.onBeforeRenderUI.add(function(){c.windowManager=new tinymce.WPWindowManager(c)})},getInfo:function(){return{longname:"WPDialogs",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"0.1"}}});b(document).ready(function(){b.widget("wp.wpdialog",b.ui.dialog,{open:function(){if(tinyMCEPopup){tinyMCEPopup.init()}b.ui.dialog.prototype.open.apply(this,arguments);this.element.focus();this._trigger("refresh")}})});tinymce.create("tinymce.WPWindowManager:tinymce.InlineWindowManager",{WPWindowManager:function(c){this.parent(c)},open:function(e,g){var d=this,c;if(!e.wpDialog){return this.parent(e,g)}else{if(!e.id){return}}c=b("#"+e.id);if(!c.length){return}d.features=e;d.params=g;d.onOpen.dispatch(d,e,g);d.element=d.windows[e.id]=c;d.bookmark=d.editor.selection.getBookmark(1);c.wpdialog({title:e.title,width:e.width,height:e.height,modal:true,dialogClass:"wp-dialog",zIndex:300000})},close:a(function(){this.element.wpdialog("close")})});tinymce.PluginManager.add("wpdialogs",tinymce.plugins.WPDialogs)})(jQuery);
  • trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.css

    r16479 r16561  
    1 #wp-link p.howto{margin:3px;}#link-options{padding:10px 0 14px;border-bottom:1px solid #dfdfdf;margin:0 6px 14px;}#wp-link label input[type="text"]{width:360px;margin-top:5px;}#wp-link label span{display:inline-block;width:80px;text-align:right;padding-right:5px;}#wp-link .link-search-wrapper{margin:5px 5px 9px;display:block;overflow:hidden;}#wp-link .link-search-wrapper span{float:left;margin-top:6px;}#wp-link .link-search-wrapper input[type="text"]{float:left;width:220px;}#wp-link .link-search-wrapper img.waiting{margin:8px 1px 0 4px;float:left;display:none;}#wp-link .link-target{width:auto;padding:3px 0 0;margin:0 0 0 87px;font-size:11px;}#wp-link .query-results{border:1px #dfdfdf solid;margin:0 5px 5px;background:#fff;height:185px;overflow:auto;}#wp-link li,#wp-link .query-notice{margin-bottom:0;border-bottom:1px solid #f1f1f1;color:#333;padding:4px 6px;cursor:pointer;}#wp-link li:hover{background:#eaf2fa;color:#151515;}#wp-link li.unselectable{border-bottom:1px solid #dfdfdf;}#wp-link li.unselectable:hover{background:#fff;cursor:auto;color:#333;}#wp-link li.selected{background:#ddd;color:#333;}#wp-link li.selected .item-title{font-weight:bold;}#wp-link .item-info{text-transform:uppercase;color:#666;font-size:11px;float:right;}#search-results{display:none;}#wp-link .river-waiting{display:none;padding:10px 0;}#wp-link .river-waiting img.waiting{margin:0 auto;display:block;}#wp-link .submitbox{padding:5px 10px;font-size:11px;overflow:auto;height:29px;}#wp-link-cancel{line-height:25px;float:left;}#wp-link-update{line-height:23px;float:right;}#wp-link-update a{display:inline-block;}
     1#wp-link p.howto{margin:3px;}#link-options{padding:10px 0 14px;border-bottom:1px solid #dfdfdf;margin:0 6px 14px;}#wp-link label input[type="text"]{width:360px;margin-top:5px;}#wp-link label span{display:inline-block;width:80px;text-align:right;padding-right:5px;}#wp-link .link-search-wrapper{margin:5px 5px 9px;display:block;overflow:hidden;}#wp-link .link-search-wrapper span{float:left;margin-top:6px;}#wp-link .link-search-wrapper input[type="text"]{float:left;width:220px;}#wp-link .link-search-wrapper img.waiting{margin:8px 1px 0 4px;float:left;display:none;}#wp-link .link-target{width:auto;padding:3px 0 0;margin:0 0 0 87px;font-size:11px;}#wp-link .query-results{border:1px #dfdfdf solid;margin:0 5px 5px;background:#fff;height:185px;overflow:auto;position:relative;}#wp-link li,#wp-link .query-notice{margin-bottom:0;border-bottom:1px solid #f1f1f1;color:#333;padding:4px 6px;cursor:pointer;}#wp-link li:hover{background:#eaf2fa;color:#151515;}#wp-link li.unselectable{border-bottom:1px solid #dfdfdf;}#wp-link li.unselectable:hover{background:#fff;cursor:auto;color:#333;}#wp-link li.selected{background:#ddd;color:#333;}#wp-link li.selected .item-title{font-weight:bold;}#wp-link .item-info{text-transform:uppercase;color:#666;font-size:11px;float:right;}#search-results{display:none;}#wp-link .river-waiting{display:none;padding:10px 0;}#wp-link .river-waiting img.waiting{margin:0 auto;display:block;}#wp-link .submitbox{padding:5px 10px;font-size:11px;overflow:auto;height:29px;}#wp-link-cancel{line-height:25px;float:left;}#wp-link-update{line-height:23px;float:right;}
  • trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css

    r16479 r16561  
    4747    height: 185px;
    4848    overflow: auto;
     49    position: relative;
    4950}
    5051#wp-link li,
     
    106107    float: right;
    107108}
    108 #wp-link-update a {
    109     display: inline-block;
    110 }
  • trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js

    r16457 r16561  
    1010         */
    1111        init : function(ed, url) {
     12            var disabled = true;
     13           
    1214            // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
    1315            ed.addCommand('WP_Link', function() {
     16                if ( disabled )
     17                    return;
    1418                ed.windowManager.open({
    1519                    id : 'wp-link',
     
    3034
    3135            ed.addShortcut('alt+shift+a', ed.getLang('advanced.link_desc'), 'WP_Link');
    32 
    33             // Add a node change handler, selects the button in the UI when a link is selected
    34             ed.onNodeChange.add(function(ed, cm, n) {
    35                 cm.setActive('wplink', n.nodeName == 'A');
     36           
     37            ed.onNodeChange.add(function(ed, cm, n, co) {
     38                disabled = co && n.nodeName != 'A';
    3639            });
    3740        },
  • trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.js

    r16457 r16561  
    1 (function(){tinymce.create("tinymce.plugins.wpLink",{init:function(a,b){a.addCommand("WP_Link",function(){a.windowManager.open({id:"wp-link",width:480,height:"auto",wpDialog:true,title:a.getLang("advlink.link_desc")},{plugin_url:b})});a.addButton("link",{title:a.getLang("advanced.link_desc"),cmd:"WP_Link"});a.addShortcut("alt+shift+a",a.getLang("advanced.link_desc"),"WP_Link");a.onNodeChange.add(function(d,c,e){c.setActive("wplink",e.nodeName=="A")})},getInfo:function(){return{longname:"WordPress Link Dialog",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wplink",tinymce.plugins.wpLink)})();
     1(function(){tinymce.create("tinymce.plugins.wpLink",{init:function(a,b){var c=true;a.addCommand("WP_Link",function(){if(c){return}a.windowManager.open({id:"wp-link",width:480,height:"auto",wpDialog:true,title:a.getLang("advlink.link_desc")},{plugin_url:b})});a.addButton("link",{title:a.getLang("advanced.link_desc"),cmd:"WP_Link"});a.addShortcut("alt+shift+a",a.getLang("advanced.link_desc"),"WP_Link");a.onNodeChange.add(function(e,d,g,f){c=f&&g.nodeName!="A"})},getInfo:function(){return{longname:"WordPress Link Dialog",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wplink",tinymce.plugins.wpLink)})();
  • trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js

    r16510 r16561  
    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');
     
    2526
    2627            // Bind event handlers
    27             inputs.update.click( wpLink.update );
    28             $('#wp-link-cancel').click( function() { tinyMCEPopup.close(); } );
    29            
    30             rivers.elements.delegate('li', 'click', wpLink.selectInternalLink )
     28            inputs.dialog.keydown( wpLink.keydown );
     29            inputs.dialog.keyup( wpLink.keyup );
     30            inputs.submit.click( function(e){
     31                wpLink.update();
     32                e.preventDefault();
     33            });
     34            $('#wp-link-cancel').click( wpLink.cancel );
     35           
     36            rivers.elements.bind('river-select', wpLink.updateFields );
    3137           
    3238            inputs.search.keyup( wpLink.searchInternalLinks );
    3339           
    34             inputs.dialog.bind('dialogopen', wpLink.refresh);
     40            inputs.dialog.bind('wpdialogrefresh', wpLink.refresh);
    3541        },
    3642
     
    3945            ed = tinyMCEPopup.editor;
    4046           
    41             // Clear previously selected links
    42             rivers.elements.find('.selected').removeClass('selected');
     47            // Refresh rivers (clear links, check visibility)
     48            rivers.search.refresh();
     49            rivers.recent.refresh();
    4350           
    4451            tinyMCEPopup.restoreSelection();
     
    5360                    inputs.openInNewTab.attr('checked','checked');
    5461                // Update save prompt.
    55                 inputs.update.text( wpLinkL10n.update );
     62                inputs.submit.val( wpLinkL10n.update );
    5663
    5764            // If there's no link, set the default values.
    5865            } 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('');
     66                wpLink.setDefaultValues();
    6367                // Update save prompt.
    64                 inputs.update.text( wpLinkL10n.save );
     68                inputs.submit.val( wpLinkL10n.save );
    6569            }
    6670
    6771            tinyMCEPopup.storeSelection();
    68             // If the focus is moved above the selection changes,
    69             // IE will show a flashing cursor over the dialog.
    70             inputs.url.focus();
     72            // Focus the URL field and highlight its contents.
     73            //     If this is moved above the selection changes,
     74            //     IE will show a flashing cursor over the dialog.
     75            inputs.url.focus()[0].select();
    7176            // Load the most recent results if this is the first time opening the panel.
    7277            if ( ! rivers.recent.ul.children().length )
    7378                rivers.recent.ajax();
    7479        },
     80       
     81        cancel : function() {
     82            tinyMCEPopup.close();
     83        },
    7584
    7685        update : function() {
    77             var el,
    78                 ed = tinyMCEPopup.editor,
     86            var ed = tinyMCEPopup.editor,
    7987                attrs = {
    8088                    href : inputs.url.val(),
    8189                    title : inputs.title.val(),
    8290                    target : inputs.openInNewTab.attr('checked') ? '_blank' : ''
    83                 }, e, b,
    84                 defaultContent = attrs.title ? attrs.title : attrs.href;
     91                }, e, b;
    8592
    8693            tinyMCEPopup.restoreSelection();
    8794            e = ed.dom.getParent(ed.selection.getNode(), 'A');
    8895
    89             // If the values are empty...
     96            // If the values are empty, unlink and return
    9097            if ( ! attrs.href || attrs.href == 'http://' ) {
    91                 // ...and nothing is selected, we should return
    92                 if ( ed.selection.isCollapsed() ) {
    93                     tinyMCEPopup.close();
    94                     return;
    95                 // ...and a link exists, we should unlink and return
    96                 } else if ( e ) {
     98                if ( e ) {
    9799                    tinyMCEPopup.execCommand("mceBeginUndoLevel");
    98100                    b = ed.selection.getBookmark();
     
    101103                    tinyMCEPopup.execCommand("mceEndUndoLevel");
    102104                    tinyMCEPopup.close();
    103                     return;
    104105                }
     106                return;
    105107            }
    106108
     
    109111            if (e == null) {
    110112                ed.getDoc().execCommand("unlink", false, null);
    111 
    112                 // If no selection exists, create a new link from scratch.
    113                 if ( ed.selection.isCollapsed() ) {
    114                     el = ed.dom.create('a', { href: "#mce_temp_url#" }, defaultContent);
    115                     ed.selection.setNode(el);
    116                 // If a selection exists, wrap it in a link.
    117                 } else {
    118                     tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
    119                 }
     113                tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
    120114
    121115                tinymce.each(ed.dom.select("a"), function(n) {
     
    125119                    }
    126120                });
     121               
     122                // Sometimes WebKit lets a user create a link where
     123                // they shouldn't be able to. In this case, CreateLink
     124                // injects "#mce_temp_url#" into their content. Fix it.
     125                if ( $(e).text() == '#mce_temp_url#' ) {
     126                    ed.dom.remove(e);
     127                    e = null;
     128                }
    127129            } else {
    128130                ed.dom.setAttribs(e, attrs);
    129131            }
    130132
    131             children = $(e).children();
    132133            // Don't move caret if selection was image
    133             if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') {
     134            if ( e && (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') ) {
    134135                ed.focus();
    135136                ed.selection.select(e);
     
    142143        },
    143144
    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() );
     145        updateFields : function( e, li, originalEvent ) {
     146            inputs.url.val( li.children('.item-permalink').val() );
     147            inputs.title.val( li.children('.item-title').text() );
     148            if ( originalEvent && originalEvent.type == "click" )
     149                inputs.url.focus();
     150        },
     151        setDefaultValues : function() {
     152            // Set URL and description to defaults.
     153            // Leave the new tab setting as-is.
     154            inputs.url.val('http://');
     155            inputs.title.val('');
    152156        },
    153157
     
    157161
    158162            if ( search.length > 2 ) {
    159                 rivers.recent.element.hide();
    160                 rivers.search.element.show();
     163                rivers.recent.hide();
     164                rivers.search.show();
    161165
    162166                // Don't search if the keypress didn't change the title.
     
    170174                rivers.search.ajax( function(){ waiting.hide(); });
    171175            } else {
    172                 rivers.search.element.hide();
    173                 rivers.recent.element.show();
    174             }
     176                rivers.search.hide();
     177                rivers.recent.show();
     178            }
     179        },
     180       
     181        next : function() {
     182            rivers.search.next();
     183            rivers.recent.next();
     184        },
     185        prev : function() {
     186            rivers.search.prev();
     187            rivers.recent.prev();
     188        },
     189       
     190        keydown : function( event ) {
     191            var fn, key = $.ui.keyCode;
     192           
     193            switch( event.which ) {
     194                case key.UP:
     195                    fn = 'prev';
     196                case key.DOWN:
     197                    fn = fn || 'next';
     198                    clearInterval( wpLink.keyInterval );
     199                    wpLink[ fn ]();
     200                    wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
     201                    break;
     202                default:
     203                    return;
     204            }
     205            event.preventDefault();
     206        },
     207        keyup: function( event ) {
     208            var key = $.ui.keyCode;
     209           
     210            switch( event.which ) {
     211                case key.ESCAPE:
     212                    wpLink.cancel();
     213                    break;
     214                case key.UP:
     215                case key.DOWN:
     216                    clearInterval( wpLink.keyInterval );
     217                    break;
     218                default:
     219                    return;
     220            }
     221            event.preventDefault();
    175222        },
    176223
     
    206253       
    207254        this.change( search );
     255        this.refresh();
    208256       
    209257        element.scroll( function(){ self.maybeLoad(); });
     258        element.delegate('li', 'click', function(e){ self.select( $(this), e ); });
    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, event ) {
     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, event, 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,
  • trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.js

    r16510 r16561  
    1 var wpLink;(function(f){var b={},e={},d,a,c;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,lastSearch:"",init:function(){b.dialog=f("#wp-link");b.update=f("#wp-link-update a");b.url=f("#url-field");b.title=f("#link-title-field");b.openInNewTab=f("#link-target-checkbox");b.search=f("#search-field");e.search=new a(f("#search-results"));e.recent=new a(f("#most-recent-results"));e.elements=f(".query-results",b.dialog);b.update.click(wpLink.update);f("#wp-link-cancel").click(function(){tinyMCEPopup.close()});e.elements.delegate("li","click",wpLink.selectInternalLink);b.search.keyup(wpLink.searchInternalLinks);b.dialog.bind("dialogopen",wpLink.refresh)},refresh:function(){var g;d=tinyMCEPopup.editor;e.elements.find(".selected").removeClass("selected");tinyMCEPopup.restoreSelection();if(g=d.dom.getParent(d.selection.getNode(),"A")){b.url.val(g.href);b.title.val(d.dom.getAttrib(g,"title"));if("_blank"==d.dom.getAttrib(g,"target")){b.openInNewTab.attr("checked","checked")}b.update.text(wpLinkL10n.update)}else{b.url.val("http://");b.title.val("");b.update.text(wpLinkL10n.save)}tinyMCEPopup.storeSelection();b.url.focus();if(!e.recent.ul.children().length){e.recent.ajax()}},update:function(){var k,h=tinyMCEPopup.editor,i={href:b.url.val(),title:b.title.val(),target:b.openInNewTab.attr("checked")?"_blank":""},l,g,j=i.title?i.title:i.href;tinyMCEPopup.restoreSelection();l=h.dom.getParent(h.selection.getNode(),"A");if(!i.href||i.href=="http://"){if(h.selection.isCollapsed()){tinyMCEPopup.close();return}else{if(l){tinyMCEPopup.execCommand("mceBeginUndoLevel");g=h.selection.getBookmark();h.dom.remove(l,1);h.selection.moveToBookmark(g);tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close();return}}}tinyMCEPopup.execCommand("mceBeginUndoLevel");if(l==null){h.getDoc().execCommand("unlink",false,null);if(h.selection.isCollapsed()){k=h.dom.create("a",{href:"#mce_temp_url#"},j);h.selection.setNode(k)}else{tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1})}tinymce.each(h.dom.select("a"),function(m){if(h.dom.getAttrib(m,"href")=="#mce_temp_url#"){l=m;h.dom.setAttribs(l,i)}})}else{h.dom.setAttribs(l,i)}children=f(l).children();if(l.childNodes.length!=1||l.firstChild.nodeName!="IMG"){h.focus();h.selection.select(l);h.selection.collapse(0);tinyMCEPopup.storeSelection()}tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close()},selectInternalLink:function(){var g=f(this);if(g.hasClass("unselectable")){return}g.siblings(".selected").removeClass("selected");g.addClass("selected");b.url.val(g.children(".item-permalink").val());b.title.val(g.children(".item-title").text())},searchInternalLinks:function(){var h=f(this),i,g=h.val();if(g.length>2){e.recent.element.hide();e.search.element.show();if(wpLink.lastSearch==g){return}wpLink.lastSearch=g;i=h.siblings("img.waiting").show();e.search.change(g);e.search.ajax(function(){i.hide()})}else{e.search.element.hide();e.recent.element.show()}},delayedCallback:function(i,g){var l,k,j,h;if(!g){return i}setTimeout(function(){if(k){return i.apply(h,j)}l=true},g);return function(){if(l){return i.apply(this,arguments)}j=arguments;h=this;k=true}}};a=function(i,h){var g=this;this.element=i;this.ul=i.children("ul");this.waiting=i.find(".river-waiting");this.change(h);i.scroll(function(){g.maybeLoad()})};f.extend(a.prototype,{ajax:function(j){var h=this,i=this.query.page==1?0:wpLink.minRiverAJAXDuration,g=wpLink.delayedCallback(function(k,l){h.process(k,l);if(j){j(k,l)}},i);this.query.ajax(g)},change:function(g){if(this.query&&this._search==g){return}this._search=g;this.query=new c(g);this.element.scrollTop(0)},process:function(g,k){var h="",i=true,j=k.page==1;if(!g){if(j){h+='<li class="unselectable"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"}}else{f.each(g,function(){h+=i?'<li class="alternate">':"<li>";h+='<input type="hidden" class="item-permalink" value="'+this["permalink"]+'" />';h+='<span class="item-title">';h+=this["title"]?this["title"]:"<em>"+wpLinkL10n.untitled+"</em>";h+='</span><span class="item-info">'+this["info"]+"</span></li>";i=!i})}this.ul[j?"html":"append"](h)},maybeLoad:function(){var h=this,i=this.element,g=i.scrollTop()+i.height();if(!this.query.ready()||g<this.ul.height()-wpLink.riverBottomThreshold){return}setTimeout(function(){var j=i.scrollTop(),k=j+i.height();if(!h.query.ready()||k<h.ul.height()-wpLink.riverBottomThreshold){return}h.waiting.show();i.scrollTop(j+h.waiting.outerHeight());h.ajax(function(){h.waiting.hide()})},wpLink.timeToTriggerRiver)}});c=function(g){this.page=1;this.allLoaded=false;this.querying=false;this.search=g};f.extend(c.prototype,{ready:function(){return !(this.querying||this.allLoaded)},ajax:function(i){var g=this,h={action:"wp-link-ajax",page:this.page};if(this.search){h.search=this.search}this.querying=true;f.post(ajaxurl,h,function(j){g.page++;g.querying=false;g.allLoaded=!j;i(j,h)},"json")}});f(document).ready(wpLink.init)})(jQuery);
     1var wpLink;(function(f){var b={},e={},d,a,c;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",init:function(){b.dialog=f("#wp-link");b.submit=f("#wp-link-submit");b.url=f("#url-field");b.title=f("#link-title-field");b.openInNewTab=f("#link-target-checkbox");b.search=f("#search-field");e.search=new a(f("#search-results"));e.recent=new a(f("#most-recent-results"));e.elements=f(".query-results",b.dialog);b.dialog.keydown(wpLink.keydown);b.dialog.keyup(wpLink.keyup);b.submit.click(function(g){wpLink.update();g.preventDefault()});f("#wp-link-cancel").click(wpLink.cancel);e.elements.bind("river-select",wpLink.updateFields);b.search.keyup(wpLink.searchInternalLinks);b.dialog.bind("wpdialogrefresh",wpLink.refresh)},refresh:function(){var g;d=tinyMCEPopup.editor;e.search.refresh();e.recent.refresh();tinyMCEPopup.restoreSelection();if(g=d.dom.getParent(d.selection.getNode(),"A")){b.url.val(g.href);b.title.val(d.dom.getAttrib(g,"title"));if("_blank"==d.dom.getAttrib(g,"target")){b.openInNewTab.attr("checked","checked")}b.submit.val(wpLinkL10n.update)}else{wpLink.setDefaultValues();b.submit.val(wpLinkL10n.save)}tinyMCEPopup.storeSelection();b.url.focus()[0].select();if(!e.recent.ul.children().length){e.recent.ajax()}},cancel:function(){tinyMCEPopup.close()},update:function(){var h=tinyMCEPopup.editor,i={href:b.url.val(),title:b.title.val(),target:b.openInNewTab.attr("checked")?"_blank":""},j,g;tinyMCEPopup.restoreSelection();j=h.dom.getParent(h.selection.getNode(),"A");if(!i.href||i.href=="http://"){if(j){tinyMCEPopup.execCommand("mceBeginUndoLevel");g=h.selection.getBookmark();h.dom.remove(j,1);h.selection.moveToBookmark(g);tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close()}return}tinyMCEPopup.execCommand("mceBeginUndoLevel");if(j==null){h.getDoc().execCommand("unlink",false,null);tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1});tinymce.each(h.dom.select("a"),function(k){if(h.dom.getAttrib(k,"href")=="#mce_temp_url#"){j=k;h.dom.setAttribs(j,i)}});if(f(j).text()=="#mce_temp_url#"){h.dom.remove(j);j=null}}else{h.dom.setAttribs(j,i)}if(j&&(j.childNodes.length!=1||j.firstChild.nodeName!="IMG")){h.focus();h.selection.select(j);h.selection.collapse(0);tinyMCEPopup.storeSelection()}tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close()},updateFields:function(i,h,g){b.url.val(h.children(".item-permalink").val());b.title.val(h.children(".item-title").text());if(g&&g.type=="click"){b.url.focus()}},setDefaultValues:function(){b.url.val("http://");b.title.val("")},searchInternalLinks:function(){var h=f(this),i,g=h.val();if(g.length>2){e.recent.hide();e.search.show();if(wpLink.lastSearch==g){return}wpLink.lastSearch=g;i=h.siblings("img.waiting").show();e.search.change(g);e.search.ajax(function(){i.hide()})}else{e.search.hide();e.recent.show()}},next:function(){e.search.next();e.recent.next()},prev:function(){e.search.prev();e.recent.prev()},keydown:function(i){var h,g=f.ui.keyCode;switch(i.which){case g.UP:h="prev";case g.DOWN:h=h||"next";clearInterval(wpLink.keyInterval);wpLink[h]();wpLink.keyInterval=setInterval(wpLink[h],wpLink.keySensitivity);break;default:return}i.preventDefault()},keyup:function(h){var g=f.ui.keyCode;switch(h.which){case g.ESCAPE:wpLink.cancel();break;case g.UP:case g.DOWN:clearInterval(wpLink.keyInterval);break;default:return}h.preventDefault()},delayedCallback:function(i,g){var l,k,j,h;if(!g){return i}setTimeout(function(){if(k){return i.apply(h,j)}l=true},g);return function(){if(l){return i.apply(this,arguments)}j=arguments;h=this;k=true}}};a=function(i,h){var g=this;this.element=i;this.ul=i.children("ul");this.waiting=i.find(".river-waiting");this.change(h);this.refresh();i.scroll(function(){g.maybeLoad()});i.delegate("li","click",function(j){g.select(f(this),j)})};f.extend(a.prototype,{refresh:function(){this.deselect();this.visible=this.element.is(":visible")},show:function(){if(!this.visible){this.deselect();this.element.show();this.visible=true}},hide:function(){this.element.hide();this.visible=false},select:function(h,k){var j,i,l,g;if(h.hasClass("unselectable")||h==this.selected){return}this.deselect();this.selected=h.addClass("selected");j=h.outerHeight();i=this.element.height();l=h.position().top;g=this.element.scrollTop();if(l<0){this.element.scrollTop(g+l)}else{if(l+j>i){this.element.scrollTop(g+l-i+j)}}this.element.trigger("river-select",[h,k,this])},deselect:function(){if(this.selected){this.selected.removeClass("selected")}this.selected=false},prev:function(){if(!this.visible){return}var g;if(this.selected){g=this.selected.prev("li");if(g.length){this.select(g)}}},next:function(){if(!this.visible){return}var g=this.selected?this.selected.next("li"):f("li:not(.unselectable):first",this.element);if(g.length){this.select(g)}},ajax:function(j){var h=this,i=this.query.page==1?0:wpLink.minRiverAJAXDuration,g=wpLink.delayedCallback(function(k,l){h.process(k,l);if(j){j(k,l)}},i);this.query.ajax(g)},change:function(g){if(this.query&&this._search==g){return}this._search=g;this.query=new c(g);this.element.scrollTop(0)},process:function(g,k){var h="",i=true,j=k.page==1;if(!g){if(j){h+='<li class="unselectable"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"}}else{f.each(g,function(){h+=i?'<li class="alternate">':"<li>";h+='<input type="hidden" class="item-permalink" value="'+this["permalink"]+'" />';h+='<span class="item-title">';h+=this["title"]?this["title"]:"<em>"+wpLinkL10n.untitled+"</em>";h+='</span><span class="item-info">'+this["info"]+"</span></li>";i=!i})}this.ul[j?"html":"append"](h)},maybeLoad:function(){var h=this,i=this.element,g=i.scrollTop()+i.height();if(!this.query.ready()||g<this.ul.height()-wpLink.riverBottomThreshold){return}setTimeout(function(){var j=i.scrollTop(),k=j+i.height();if(!h.query.ready()||k<h.ul.height()-wpLink.riverBottomThreshold){return}h.waiting.show();i.scrollTop(j+h.waiting.outerHeight());h.ajax(function(){h.waiting.hide()})},wpLink.timeToTriggerRiver)}});c=function(g){this.page=1;this.allLoaded=false;this.querying=false;this.search=g};f.extend(c.prototype,{ready:function(){return !(this.querying||this.allLoaded)},ajax:function(i){var g=this,h={action:"wp-link-ajax",page:this.page};if(this.search){h.search=this.search}this.querying=true;f.post(ajaxurl,h,function(j){g.page++;g.querying=false;g.allLoaded=!j;i(j,h)},"json")}});f(document).ready(wpLink.init)})(jQuery);
  • trunk/wp-includes/script-loader.php

    r16553 r16561  
    271271    ) );
    272272
    273     $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array('jquery'), '20101120' );
     273    $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array('jquery'), '20101123' );
    274274    $scripts->localize( 'wplink', 'wpLinkL10n', array(
    275275        'update' => __('Update'),
     
    519519    $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20101117' );
    520520    $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array(), '20101119' );
    521     $styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101119' );
     521    $styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101123' );
    522522
    523523    foreach ( $rtl_styles as $rtl_style ) {
Note: See TracChangeset for help on using the changeset viewer.