<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[16479] trunk: Internal linking cleanups.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16479">16479</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-11-19 05:31:07 +0000 (Fri, 19 Nov 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Internal linking cleanups. Fix combination of pagination and searching. Add a margin of error (ha, get it?) to triggering the river. props koopersmith, see <a href="http://trac.wordpress.org/ticket/11420">#11420</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminajaxphp">trunk/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunkwpadminincludesinternallinkingphp">trunk/wp-admin/includes/internal-linking.php</a></li>
<li><a href="#trunkwpincludesjstinymcepluginswplinkcsswplinkcss">trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.css</a></li>
<li><a href="#trunkwpincludesjstinymcepluginswplinkcsswplinkdevcss">trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css</a></li>
<li><a href="#trunkwpincludesjstinymcepluginswplinkjswplinkdevjs">trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js</a></li>
<li><a href="#trunkwpincludesjstinymcepluginswplinkjswplinkjs">trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.js</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-ajax.php (16478 => 16479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-ajax.php        2010-11-19 05:06:48 UTC (rev 16478)
+++ trunk/wp-admin/admin-ajax.php        2010-11-19 05:31:07 UTC (rev 16479)
</span><span class="lines">@@ -1078,8 +1078,8 @@
</span><span class="cx">
</span><span class="cx">         $args = array();
</span><span class="cx">
</span><del>-        if ( isset( $_POST['title'] ) )
-                $args['s'] = stripslashes( $_POST['title'] );
</del><ins>+        if ( isset( $_POST['search'] ) )
+                $args['s'] = stripslashes( $_POST['search'] );
</ins><span class="cx">         $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
</span><span class="cx">
</span><span class="cx">         $results = wp_link_query( $args );
</span></span></pre></div>
<a id="trunkwpadminincludesinternallinkingphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/internal-linking.php (16478 => 16479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/internal-linking.php        2010-11-19 05:06:48 UTC (rev 16478)
+++ trunk/wp-admin/includes/internal-linking.php        2010-11-19 05:31:07 UTC (rev 16479)
</span><span class="lines">@@ -94,29 +94,14 @@
</span><span class="cx">                         </label>
</span><span class="cx">                 </div>
</span><span class="cx">                 <div id="search-results" class="query-results">
</span><del>-                        <ul>
-                                <li class="loading-results unselectable"><em><?php _e( 'Loading...' ); ?></em></li>
-                        </ul>
</del><ins>+                        <ul></ul>
</ins><span class="cx">                         <div class="river-waiting">
</span><span class="cx">                                 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
</span><span class="cx">                         </div>
</span><span class="cx">                 </div>
</span><del>-                <?php $most_recent = wp_link_query(); ?>
</del><span class="cx">                 <div id="most-recent-results" class="query-results">
</span><del>-                        <ul>
-                                <li class="unselectable"><em><?php _e( 'No search term specified. Showing recent items.' ); ?></em></li>
-                                <?php
-                                $alt = true;
-                                foreach ( $most_recent as $item ) : ?>
-                                        <li<?php if ( $alt ) echo ' class="alternate"'; ?>>
-                                                <input type="hidden" class="item-permalink" value="<?php echo esc_url( $item['permalink'] ); ?>" />
-                                                <span class="item-title"><?php echo $item['title']; ?></span>
-                                                <span class="item-info"><?php echo esc_html( $item['info'] ); ?></span>
-                                        </li>
-                                <?php
-                                $alt = ! $alt;
-                                endforeach; ?>
-                        </ul>
</del><ins>+                        <div class="query-notice"><em><?php _e( 'No search term specified. Showing recent items.' ); ?></em></div>
+                        <ul></ul>
</ins><span class="cx">                         <div class="river-waiting">
</span><span class="cx">                                 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
</span><span class="cx">                         </div>
</span></span></pre></div>
<a id="trunkwpincludesjstinymcepluginswplinkcsswplinkcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.css (16478 => 16479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.css        2010-11-19 05:06:48 UTC (rev 16478)
+++ trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.css        2010-11-19 05:31:07 UTC (rev 16479)
</span><span class="lines">@@ -1 +1 @@
</span><del>-#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;}#open-in-new-tab{display:inline-block;padding:3px 0 0;margin:0 0 0 87px;}#open-in-new-tab span{width:auto;margin-left:6px;font-size:11px;}.query-results{border:1px #dfdfdf solid;margin:0 5px 5px;background:#fff;height:185px;overflow:auto;}.query-results li{margin-bottom:0;border-bottom:1px solid #f1f1f1;color:#555;padding:4px 6px;cursor:pointer;}.query-results li:hover{background:#eaf2fa;color:#333;}#wp-link .query-results li.unselectable:hover{background:#fff;cursor:auto;color:#555;}#wp-link .query-results li.unselectable{border-bottom:1px solid #dfdfdf;}#wp-link .query-results li.selected{background:#f1f1f1;color:#333;}#wp-link .query-results li.selected .item-title{font-weight:bold;}#wp-link .item-info{text-transform:uppercase;color:#aaa;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 5px 0;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;}
</del><span class="cx">\ No newline at end of file
</span><ins>+#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;}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjstinymcepluginswplinkcsswplinkdevcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css (16478 => 16479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css        2010-11-19 05:06:48 UTC (rev 16478)
+++ trunk/wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css        2010-11-19 05:31:07 UTC (rev 16479)
</span><span class="lines">@@ -47,7 +47,8 @@
</span><span class="cx">         height: 185px;
</span><span class="cx">         overflow: auto;
</span><span class="cx"> }
</span><del>-#wp-link li {
</del><ins>+#wp-link li,
+#wp-link .query-notice {
</ins><span class="cx">         margin-bottom: 0;
</span><span class="cx">         border-bottom: 1px solid #f1f1f1;
</span><span class="cx">         color: #333;
</span><span class="lines">@@ -66,7 +67,7 @@
</span><span class="cx">         cursor: auto;
</span><span class="cx">         color: #333;
</span><span class="cx"> }
</span><del>-#wp-link li.selected {
</del><ins>+#wp-link li.selected {
</ins><span class="cx">         background: #ddd;
</span><span class="cx">         color: #333;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpincludesjstinymcepluginswplinkjswplinkdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js (16478 => 16479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js        2010-11-19 05:06:48 UTC (rev 16478)
+++ trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js        2010-11-19 05:31:07 UTC (rev 16479)
</span><span class="lines">@@ -1,16 +1,13 @@
</span><ins>+var wpLink;
+
</ins><span class="cx"> (function($){
</span><del>-        var inputs = {}, results = {}, ed,
</del><ins>+        var inputs = {}, rivers = {}, ed, River, Query;
+        
</ins><span class="cx">         wpLink = {
</span><span class="cx">                 timeToTriggerRiver: 150,
</span><span class="cx">                 minRiverAJAXDuration: 200,
</span><ins>+                riverBottomThreshold: 5,
</ins><span class="cx">                 lastSearch: '',
</span><del>-                riverDefaults: function() {
-                        return {
-                                page : 2,
-                                allLoaded: false,
-                                active: false
-                        };
-                },
</del><span class="cx">                 init : function() {
</span><span class="cx">                         inputs.dialog = $('#wp-link');
</span><span class="cx">                         // URL
</span><span class="lines">@@ -20,19 +17,16 @@
</span><span class="cx">                         // Advanced Options
</span><span class="cx">                         inputs.openInNewTab = $('#link-target-checkbox');
</span><span class="cx">                         inputs.search = $('#search-field');
</span><del>-                        // Result lists
-                        results.search = $('#search-results');
-                        results.recent = $('#most-recent-results');
-                        results.search.data('river', wpLink.riverDefaults() );
-                        results.recent.data('river', wpLink.riverDefaults() );
-                        results.group = $('.query-results', inputs.dialog);
</del><ins>+                        // Build Rivers
+                        rivers.search = new River( $('#search-results') );
+                        rivers.recent = new River( $('#most-recent-results') );
+                        rivers.elements = $('.query-results', inputs.dialog);
</ins><span class="cx">
</span><span class="cx">                         // Bind event handlers
</span><span class="cx">                         $('#wp-link-update').click( wpLink.update );
</span><span class="cx">                         $('#wp-link-cancel').click( function() { tinyMCEPopup.close(); } );
</span><span class="cx">                         
</span><del>-                        results.group.delegate('li', 'click', wpLink.selectInternalLink )
-                        results.group.scroll( wpLink.maybeLoadRiver );
</del><ins>+                        rivers.elements.delegate('li', 'click', wpLink.selectInternalLink )
</ins><span class="cx">                         
</span><span class="cx">                         inputs.search.keyup( wpLink.searchInternalLinks );
</span><span class="cx">                         
</span><span class="lines">@@ -55,9 +49,12 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         // Clear previously selected links
</span><del>-                        results.group.find('.selected').removeClass('selected');
</del><ins>+                        rivers.elements.find('.selected').removeClass('selected');
</ins><span class="cx">                         // Focus the URL field
</span><span class="cx">                         inputs.url.focus();
</span><ins>+                        // Load the most recent results if this is the first time opening the panel.
+                        if ( ! rivers.recent.ul.children().length )
+                                rivers.recent.ajax();
</ins><span class="cx">                 },
</span><span class="cx">
</span><span class="cx">                 update : function() {
</span><span class="lines">@@ -137,86 +134,90 @@
</span><span class="cx">                         inputs.title.val( t.children('.item-title').text() );
</span><span class="cx">                 },
</span><span class="cx">
</span><del>-                maybeLoadRiver : function() {
-                        var t = $(this),
-                                ul = t.children('ul'),
-                                river = t.data('river'),
-                                bottom = t.scrollTop() + t.height();
-
-                        if ( bottom != ul.height() || river.active || river.allLoaded )
-                                return;
-
-                        setTimeout(function() {
-                                var newTop = t.scrollTop(),
-                                        newBottom = newTop + t.height(),
-                                        waiting = t.find('.river-waiting');
-
-                                if ( bottom != newBottom || newBottom != ul.height() || river.active || river.allLoaded )
-                                        return;
-
-                                river.active = true;
-                                waiting.show();
-                                t.scrollTop( newTop + waiting.outerHeight() );
-
-                                wpLink.linkAJAX( t, { page : river.page }, function(r) {
-                                        river.page++;
-                                        river.active = false;
-                                        river.allLoaded = !r;
-                                        waiting.hide();
-                                }, {
-                                        append : true,
-                                        delay : wpLink.minRiverAJAXDuration
-                                });
-                        }, wpLink.timeToTriggerRiver );
-                },
</del><span class="cx">                 searchInternalLinks : function() {
</span><span class="cx">                         var t = $(this), waiting,
</span><del>-                                title = t.val();
</del><ins>+                                search = t.val();
</ins><span class="cx">
</span><del>-                        if ( title.length > 2 ) {
-                                results.recent.hide();
-                                results.search.show();
</del><ins>+                        if ( search.length > 2 ) {
+                                rivers.recent.element.hide();
+                                rivers.search.element.show();
</ins><span class="cx">
</span><span class="cx">                                 // Don't search if the keypress didn't change the title.
</span><del>-                                if ( wpLink.lastSearch == title )
</del><ins>+                                if ( wpLink.lastSearch == search )
</ins><span class="cx">                                         return;
</span><span class="cx">
</span><del>-                                wpLink.lastSearch = title;
</del><ins>+                                wpLink.lastSearch = search;
</ins><span class="cx">                                 waiting = t.siblings('img.waiting').show();
</span><span class="cx">
</span><del>-                                results.search.data('river', wpLink.riverDefaults() );
-                                results.search.scrollTop(0);
-                                wpLink.linkAJAX( results.search, { title : title }, function(){ waiting.hide(); });
</del><ins>+                                rivers.search.change( search );
+                                rivers.search.ajax( function(){ waiting.hide(); });
</ins><span class="cx">                         } else {
</span><del>-                                results.search.hide();
-                                results.recent.show();
</del><ins>+                                rivers.search.element.hide();
+                                rivers.recent.element.show();
</ins><span class="cx">                         }
</span><span class="cx">                 },
</span><span class="cx">
</span><del>-                linkAJAX : function( $panel, params, callback, opts ) {
-                        var response;
-                        opts = opts || {};
</del><ins>+                delayedCallback : function( func, delay ) {
+                        var timeoutTriggered, funcTriggered, funcArgs, funcContext;
</ins><span class="cx">
</span><del>-                        if ( ! $panel.hasClass('query-results') )
-                                $panel = $panel.parents('.query-results');
</del><ins>+                        if ( ! delay )
+                                return func;
</ins><span class="cx">
</span><del>-                        if ( ! $panel.length )
-                                return;
</del><ins>+                        setTimeout( function() {
+                                if ( funcTriggered )
+                                        return func.apply( funcContext, funcArgs );
+                                // Otherwise, wait.
+                                timeoutTriggered = true;
+                        }, delay);
</ins><span class="cx">
</span><del>-                        response = wpLink.delayedCallback( function( results ) {
-                                wpLink.processAJAXResponse( $panel, results, callback, opts );
-                        }, opts.delay );
-
-                        $.post( ajaxurl, $.extend({
-                                action : 'wp-link-ajax'
-                        }, params ), response, "json" );
</del><ins>+                        return function() {
+                                if ( timeoutTriggered )
+                                        return func.apply( this, arguments );
+                                // Otherwise, wait.
+                                funcArgs = arguments;
+                                funcContext = this;
+                                funcTriggered = true;
+                        };
+                }
+        }
+        
+        River = function( element, search ) {
+                var self = this;
+                this.element = element;
+                this.ul = element.children('ul');
+                this.waiting = element.find('.river-waiting');
+                
+                this.change( search );
+                
+                element.scroll( function(){ self.maybeLoad(); });
+        };
+        
+        $.extend( River.prototype, {
+                ajax: function( callback ) {
+                        var self = this,
+                                delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration,
+                                response = wpLink.delayedCallback( function( results, params ) {
+                                        self.process( results, params );
+                                        if ( callback )
+                                                callback( results, params );
+                                }, delay );
+                        
+                        this.query.ajax( response );
</ins><span class="cx">                 },
</span><ins>+                change: function( search ) {
+                        if ( this.query && this._search == search )
+                                return;
+                        
+                        this._search = search;
+                        this.query = new Query( search );
+                        this.element.scrollTop(0);
+                },
+                process: function( results, params ) {
+                        var list = '', alt = true,
+                                firstPage = params.page == 1;
</ins><span class="cx">
</span><del>-                processAJAXResponse: function( $panel, results, callback, opts ) {
-                        var list = '', alt = true;
-
</del><span class="cx">                         if ( !results ) {
</span><del>-                                if ( !opts.append ) {
</del><ins>+                                if ( firstPage ) {
</ins><span class="cx">                                         list += '<li class="unselectable"><span class="item-title"><em>'
</span><span class="cx">                                         + wpLinkL10n.noMatchesFound
</span><span class="cx">                                         + '</em></span></li>';
</span><span class="lines">@@ -232,37 +233,62 @@
</span><span class="cx">                                 });
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        // Set results
-                        $panel.children('ul')[ opts.append ? 'append' : 'html' ]( list );
-
-                        // Run callback
-                        if ( callback )
-                                callback( results );
</del><ins>+                        this.ul[ firstPage ? 'html' : 'append' ]( list );
</ins><span class="cx">                 },
</span><ins>+                maybeLoad: function() {
+                        var self = this,
+                                el = this.element,
+                                bottom = el.scrollTop() + el.height();
</ins><span class="cx">
</span><del>-                delayedCallback : function( func, delay ) {
-                        var timeoutTriggered, funcTriggered, funcArgs, funcContext;
</del><ins>+                        if ( ! this.query.ready() || bottom < this.ul.height() - wpLink.riverBottomThreshold )
+                                return;
</ins><span class="cx">
</span><del>-                        if ( ! delay )
-                                return func;
</del><ins>+                        setTimeout(function() {
+                                var newTop = el.scrollTop(),
+                                        newBottom = newTop + el.height();
</ins><span class="cx">
</span><del>-                        setTimeout( function() {
-                                if ( funcTriggered )
-                                        return func.apply( funcContext, funcArgs );
-                                // Otherwise, wait.
-                                timeoutTriggered = true;
-                        }, delay);
</del><ins>+                                if ( ! self.query.ready() || newBottom < self.ul.height() - wpLink.riverBottomThreshold )
+                                        return;
</ins><span class="cx">
</span><del>-                        return function() {
-                                if ( timeoutTriggered )
-                                        return func.apply( this, arguments );
-                                // Otherwise, wait.
-                                funcArgs = arguments;
-                                funcContext = this;
-                                funcTriggered = true;
-                        };
</del><ins>+                                self.waiting.show();
+                                el.scrollTop( newTop + self.waiting.outerHeight() );
+
+                                self.ajax( function() { self.waiting.hide(); });
+                        }, wpLink.timeToTriggerRiver );
</ins><span class="cx">                 }
</span><del>-        }
</del><ins>+        });
+        
+        Query = function( search ) {
+                this.page = 1;
+                this.allLoaded = false;
+                this.querying = false;
+                this.search = search;
+        };
+        
+        $.extend( Query.prototype, {
+                ready: function() {
+                        return !( this.querying || this.allLoaded );
+                },
+                ajax: function( callback ) {
+                        var self = this,
+                                query = {
+                                        action : 'wp-link-ajax',
+                                        page : this.page
+                                };
</ins><span class="cx">
</span><ins>+                        if ( this.search )
+                                query.search = this.search;
+
+                        this.querying = true;
+                        
+                        $.post( ajaxurl, query, function(r) {
+                                self.page++;
+                                self.querying = false;
+                                self.allLoaded = !r;
+                                callback( r, query );
+                        }, "json" );
+                }
+        });
+
</ins><span class="cx">         $(document).ready( wpLink.init );
</span><span class="cx"> })(jQuery);
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjstinymcepluginswplinkjswplinkjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.js (16478 => 16479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.js        2010-11-19 05:06:48 UTC (rev 16478)
+++ trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.js        2010-11-19 05:31:07 UTC (rev 16479)
</span><span class="lines">@@ -1 +1 @@
</span><del>-(function(d){var a={},c={},b,e={timeToTriggerRiver:150,minRiverAJAXDuration:200,lastSearch:"",riverDefaults:function(){return{page:2,allLoaded:false,active:false}},init:function(){a.dialog=d("#wp-link");a.url=d("#url-field");a.title=d("#link-title-field");a.openInNewTab=d("#link-target-checkbox");a.search=d("#search-field");c.search=d("#search-results");c.recent=d("#most-recent-results");c.search.data("river",e.riverDefaults());c.recent.data("river",e.riverDefaults());c.group=d(".query-results",a.dialog);d("#wp-link-update").click(e.update);d("#wp-link-cancel").click(function(){tinyMCEPopup.close()});c.group.delegate("li","click",e.selectInternalLink);c.group.scroll(e.maybeLoadRiver);a.search.keyup(e.searchInternalLinks);a.dialog.bind("dialogopen",e.refresh)},refresh:function(){var f;b=tinyMCEPopup.editor;if(f=b.dom.getParent(b.selection.getNode(),"A")){a.url.val(f.href);a.title.val(b.dom.getAttrib(f,"title"));if("_blank"==b.dom.getAttrib(f,"target")){a.openInNewTab.attr("checked","checked")}}c.group.find(".selected").removeClass("selected");a.url.focus()},update:function(){var j,g=tinyMCEPopup.editor,h={href:a.url.val(),title:a.title.val(),target:a.openInNewTab.attr("checked")?"_blank":""},k,f,i=h.title?h.title:h.href;tinyMCEPopup.restoreSelection();k=g.dom.getParent(g.selection.getNode(),"A");if(!h.href){if(g.selection.isCollapsed()){tinyMCEPopup.close();return}else{if(k){tinyMCEPopup.execCommand("mceBeginUndoLevel");f=g.selection.getBookmark();g.dom.remove(k,1);g.selection.moveToBookmark(f);tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close();return}}}tinyMCEPopup.execCommand("mceBeginUndoLevel");if(k==null){g.getDoc().execCommand("unlink",false,null);if(g.selection.isCollapsed()){j=g.dom.create("a",{href:"#mce_temp_url#"},i);g.selection.setNode(j)}else{tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1})}tinymce.each(g.dom.select("a"),function(l){if(g.dom.getAttrib(l,"href")=="#mce_temp_url#"){k=l;g.dom.setAttribs(k,h)}})}else{g.dom.setAttribs(k,h)}if(k.childNodes.length!=1||k.firstChild.nodeName!="IMG"){g.focus();g.selection.select(k);g.selection.collapse(0);tinyMCEPopup.storeSelection()}tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close()},selectInternalLink:function(){var f=d(this);if(f.hasClass("unselectable")){return}f.siblings(".selected").removeClass("selected");f.addClass("selected");a.url.val(f.children(".item-permalink").val());a.title.val(f.children(".item-title").text())},maybeLoadRiver:function(){var h=d(this),g=h.children("ul"),i=h.data("river"),f=h.scrollTop()+h.height();if(f!=g.height()||i.active||i.allLoaded){return}setTimeout(function(){var j=h.scrollTop(),k=j+h.height(),l=h.find(".river-waiting");if(f!=k||k!=g.height()||i.active||i.allLoaded){return}i.active=true;l.show();h.scrollTop(j+l.outerHeight());e.linkAJAX(h,{page:i.page},function(m){i.page++;i.active=false;i.allLoaded=!m;l.hide()},{append:true,delay:e.minRiverAJAXDuration})},e.timeToTriggerRiver)},searchInternalLinks:function(){var f=d(this),h,g=f.val();if(g.length>2){c.recent.hide();c.search.show();if(e.lastSearch==g){return}e.lastSearch=g;h=f.siblings("img.waiting").show();c.search.data("river",e.riverDefaults());c.search.scrollTop(0);e.linkAJAX(c.search,{title:g},function(){h.hide()})}else{c.search.hide();c.recent.show()}},linkAJAX:function(i,h,j,g){var f;g=g||{};if(!i.hasClass("query-results")){i=i.parents(".query-results")}if(!i.length){return}f=e.delayedCallback(function(k){e.processAJAXResponse(i,k,j,g)},g.delay);d.post(ajaxurl,d.extend({action:"wp-link-ajax"},h),f,"json")},processAJAXResponse:function(j,f,k,g){var h="",i=true;if(!f){if(!g.append){h+='<li class="unselectable"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"}}else{d.each(f,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})}j.children("ul")[g.append?"append":"html"](h);if(k){k(f)}},delayedCallback:function(h,f){var k,j,i,g;if(!f){return h}setTimeout(function(){if(j){return h.apply(g,i)}k=true},f);return function(){if(k){return h.apply(this,arguments)}i=arguments;g=this;j=true}}};d(document).ready(e.init)})(jQuery);
</del><span class="cx">\ No newline at end of file
</span><ins>+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.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);f("#wp-link-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;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")}}e.elements.find(".selected").removeClass("selected");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){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)}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);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (16478 => 16479)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2010-11-19 05:06:48 UTC (rev 16478)
+++ trunk/wp-includes/script-loader.php        2010-11-19 05:31:07 UTC (rev 16479)
</span><span class="lines">@@ -269,7 +269,7 @@
</span><span class="cx">                 'noShortlink' => __( 'No shortlink available for this page.' ),
</span><span class="cx">         ) );
</span><span class="cx">
</span><del>-        $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array('jquery'), '20101117' );
</del><ins>+        $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array('jquery'), '20101119' );
</ins><span class="cx">         $scripts->localize( 'wplink', 'wpLinkL10n', array(
</span><span class="cx">                 'untitled' => __('Untitled'),
</span><span class="cx">                 'noMatchesFound' => __('No matches found.'),
</span><span class="lines">@@ -511,7 +511,7 @@
</span><span class="cx">         $styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100907' );
</span><span class="cx">         $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20101117' );
</span><span class="cx">         $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array(), '20101118' );
</span><del>-        $styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101118' );
</del><ins>+        $styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101119' );
</ins><span class="cx">
</span><span class="cx">         foreach ( $rtl_styles as $rtl_style ) {
</span><span class="cx">                 $styles->add_data( $rtl_style, 'rtl', true );
</span></span></pre>
</div>
</div>
</body>
</html>