<!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" />
<title>[37154] trunk/src/wp-includes: Editor, wpLink:</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/37154">37154</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/37154","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-04-01 21:12:18 +0000 (Fri, 01 Apr 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Editor, wpLink:
- Restore the bottom half of the modal.
- Make it always expanded and remove the toggle. It is used as advanced link options now, no need to have simple mode.
Props iseulde, adamsilverstein, azaozz.
Fixes <a href="https://core.trac.wordpress.org/ticket/36359">#36359</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpeditorphp">trunk/src/wp-includes/class-wp-editor.php</a></li>
<li><a href="#trunksrcwpincludescsseditorcss">trunk/src/wp-includes/css/editor.css</a></li>
<li><a href="#trunksrcwpincludesjswplinkjs">trunk/src/wp-includes/js/wplink.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpeditorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-editor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-editor.php 2016-03-30 21:54:45 UTC (rev 37153)
+++ trunk/src/wp-includes/class-wp-editor.php 2016-04-01 21:12:18 UTC (rev 37154)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1412,9 +1412,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="link-selector">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="link-options">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <p class="howto"><?php _e( 'Enter the destination URL' ); ?></p>
</ins><span class="cx" style="display: block; padding: 0 10px"> <div>
</span><span class="cx" style="display: block; padding: 0 10px"> <label><span><?php _e( 'URL' ); ?></span>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <input id="wp-link-url" type="text" role="combobox" aria-autocomplete="list" aria-expanded="false" placeholder="<?php _e( 'Paste URL or type to search' ); ?>" /></label>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <input id="wp-link-url" type="text" /></label>
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="wp-link-text-field">
</span><span class="cx" style="display: block; padding: 0 10px"> <label><span><?php _e( 'Link Text' ); ?></span>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1425,6 +1426,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="checkbox" id="wp-link-target" /> <?php _e( 'Open link in a new tab' ); ?></label>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <p class="howto"><?php _e( 'Or link to existing content' ); ?></p>
+ <div id="search-panel">
+ <div class="link-search-wrapper">
+ <label>
+ <span class="search-label"><?php _e( 'Search' ); ?></span>
+ <input type="search" id="wp-link-search" class="link-search-field" autocomplete="off" />
+ <span class="spinner"></span>
+ </label>
+ </div>
+ <div id="search-results" class="query-results" tabindex="0">
+ <ul></ul>
+ <div class="river-waiting">
+ <span class="spinner"></span>
+ </div>
+ </div>
+ <div id="most-recent-results" class="query-results" tabindex="0">
+ <div class="query-notice" id="query-notice-message">
+ <em class="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em>
+ <em class="query-notice-hint screen-reader-text"><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em>
+ </div>
+ <ul></ul>
+ <div class="river-waiting">
+ <span class="spinner"></span>
+ </div>
+ </div>
+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="submitbox">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="wp-link-cancel">
</span></span></pre></div>
<a id="trunksrcwpincludescsseditorcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/css/editor.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/css/editor.css 2016-03-30 21:54:45 UTC (rev 37153)
+++ trunk/src/wp-includes/css/editor.css 2016-04-01 21:12:18 UTC (rev 37154)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -95,7 +95,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .mce-textbox,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.mce-checkbox i.mce-i-checkbox {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.mce-checkbox i.mce-i-checkbox,
+#wp-link .query-results {
</ins><span class="cx" style="display: block; padding: 0 10px"> border: 1px solid #ddd;
</span><span class="cx" style="display: block; padding: 0 10px"> -webkit-border-radius: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> border-radius: 0;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1374,6 +1375,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> height: 100%;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#wp-link-wrap {
+ height: 500px;
+ margin-top: -250px;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #wp-link-wrap .wp-link-text-field {
</span><span class="cx" style="display: block; padding: 0 10px"> display: none;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1433,8 +1439,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 0 0 2px 1px rgba(30, 140, 190, .8);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#link-selector {
- padding: 0 16px 50px;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#wp-link-wrap #link-selector {
+ -webkit-overflow-scrolling: touch;
+ padding: 0 16px;
+ position: absolute;
+ top: 37px;
+ left: 0;
+ right: 0;
+ bottom: 44px;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> #wp-link ol,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1464,11 +1476,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> #wp-link label input[type="text"] {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- margin: 8px 0 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ margin-top: 5px;
</ins><span class="cx" style="display: block; padding: 0 10px"> width: 70%;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#wp-link #link-options label span {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#wp-link #link-options label span,
+#wp-link #search-panel label span.search-label {
</ins><span class="cx" style="display: block; padding: 0 10px"> display: inline-block;
</span><span class="cx" style="display: block; padding: 0 10px"> width: 80px;
</span><span class="cx" style="display: block; padding: 0 10px"> text-align: right;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1478,6 +1491,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> word-wrap: break-word;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#wp-link .link-search-field {
+ float: left;
+ width: 250px;
+ max-width: 70%;
+}
+
+#wp-link .link-search-wrapper {
+ margin: 5px 0 9px;
+ display: block;
+ overflow: hidden;
+}
+
+#wp-link .link-search-wrapper span {
+ float: left;
+ margin-top: 4px;
+}
+
+#wp-link .link-search-wrapper .spinner {
+ margin-top: 5px;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #wp-link .link-target {
</span><span class="cx" style="display: block; padding: 0 10px"> padding: 3px 0 0;
</span><span class="cx" style="display: block; padding: 0 10px"> white-space: nowrap;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1489,6 +1523,112 @@
</span><span class="cx" style="display: block; padding: 0 10px"> max-width: 70%;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#wp-link .query-results {
+ border: 1px #dfdfdf solid;
+ margin: 0 0 12px;
+ background: #fff;
+ overflow: auto;
+ position: absolute;
+ left: 16px;
+ right: 16px;
+ bottom: 0;
+ top: 166px;
+}
+
+.has-text-field #wp-link .query-results {
+ top: 200px;
+}
+
+#wp-link li {
+ clear: both;
+ margin-bottom: 0;
+ border-bottom: 1px solid #f1f1f1;
+ color: #32373c;
+ padding: 4px 6px 4px 10px;
+ cursor: pointer;
+ position: relative;
+}
+
+#wp-link .query-notice {
+ padding: 0;
+ border-bottom: 1px solid #dfdfdf;
+ background-color: #f7fcfe;
+ color: #000;
+}
+
+#wp-link .query-notice .query-notice-default,
+#wp-link .query-notice .query-notice-hint {
+ display: block;
+ padding: 6px;
+ border-left: 4px solid #00a0d2;
+}
+
+#wp-link .unselectable.no-matches-found {
+ padding: 0;
+ border-bottom: 1px solid #dfdfdf;
+ background-color: #fef7f1;
+}
+
+#wp-link .no-matches-found .item-title {
+ display: block;
+ padding: 6px;
+ border-left: 4px solid #d54e21;
+}
+
+#wp-link .query-results em {
+ font-style: normal;
+}
+
+#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: #32373c;
+}
+
+#wp-link li.selected {
+ background: #ddd;
+ color: #32373c;
+}
+
+#wp-link li.selected .item-title {
+ font-weight: bold;
+}
+
+#wp-link li:last-child {
+ border: none;
+}
+
+#wp-link .item-title {
+ display: inline-block;
+ width: 80%;
+ width: -webkit-calc(100% - 68px);
+ width: calc(100% - 68px);
+ word-wrap: break-word;
+}
+
+#wp-link .item-info {
+ text-transform: uppercase;
+ color: #666;
+ font-size: 11px;
+ position: absolute;
+ right: 5px;
+ top: 5px;
+}
+
+#wp-link .river-waiting {
+ display: none;
+ padding: 10px 0;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #wp-link .submitbox {
</span><span class="cx" style="display: block; padding: 0 10px"> padding: 8px 16px;
</span><span class="cx" style="display: block; padding: 0 10px"> background: #fcfcfc;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1518,10 +1658,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> margin-top: -140px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ #wp-link-wrap .query-results {
+ top: 195px;
+ }
+
+ #wp-link-wrap.has-text-field .query-results {
+ top: 235px;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #link-selector {
</span><span class="cx" style="display: block; padding: 0 10px"> padding: 0 16px 60px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ #wp-link-wrap #link-selector {
+ bottom: 52px;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #wp-link-cancel {
</span><span class="cx" style="display: block; padding: 0 10px"> line-height: 32px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1549,7 +1701,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> #wp-link-wrap {
</span><span class="cx" style="display: block; padding: 0 10px"> -webkit-transition: none;
</span><span class="cx" style="display: block; padding: 0 10px"> transition: none;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ height: auto;
+ margin-top: 0;
+ top: 10px;
+ bottom: 10px;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ #link-selector {
+ overflow: auto;
+ }
+
+ #search-panel .query-results {
+ position: static;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> @media screen and ( max-height: 290px ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1566,6 +1730,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> height: calc(100% - 92px);
</span><span class="cx" style="display: block; padding: 0 10px"> padding-bottom: 2px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ #search-panel .query-results {
+ position: static;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> div.wp-link-preview {
</span></span></pre></div>
<a id="trunksrcwpincludesjswplinkjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/wplink.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/wplink.js 2016-03-30 21:54:45 UTC (rev 37153)
+++ trunk/src/wp-includes/js/wplink.js 2016-04-01 21:12:18 UTC (rev 37154)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,9 +1,11 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> var wpLink;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ( function( $, wpLinkL10n, wp ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var editor, correctedURL, linkNode,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var editor, searchTimer, River, Query, correctedURL, linkNode,
+ emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
+ urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i,
</ins><span class="cx" style="display: block; padding: 0 10px"> inputs = {},
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ rivers = {},
</ins><span class="cx" style="display: block; padding: 0 10px"> isTouch = ( 'ontouchend' in document );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function getLink() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,6 +13,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wpLink = {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ timeToTriggerRiver: 150,
+ minRiverAJAXDuration: 200,
+ riverBottomThreshold: 5,
+ keySensitivity: 100,
+ lastSearch: '',
</ins><span class="cx" style="display: block; padding: 0 10px"> textarea: '',
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> init: function() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,14 +30,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Input
</span><span class="cx" style="display: block; padding: 0 10px"> inputs.text = $( '#wp-link-text' );
</span><span class="cx" style="display: block; padding: 0 10px"> inputs.url = $( '#wp-link-url' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ inputs.nonce = $( '#_ajax_linking_nonce' );
</ins><span class="cx" style="display: block; padding: 0 10px"> inputs.openInNewTab = $( '#wp-link-target' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ inputs.search = $( '#wp-link-search' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $.ui && $.ui.autocomplete ) {
- wpLink.setAutocomplete();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Build Rivers
+ rivers.search = new River( $( '#search-results' ) );
+ rivers.recent = new River( $( '#most-recent-results' ) );
+ rivers.elements = inputs.dialog.find( '.query-results' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- inputs.dialog.on( 'keydown', wpLink.keydown );
- inputs.submit.on( 'click', function( event ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Get search notice text
+ inputs.queryNotice = $( '#query-notice-message' );
+ inputs.queryNoticeTextDefault = inputs.queryNotice.find( '.query-notice-default' );
+ inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' );
+
+ // Bind event handlers
+ inputs.dialog.keydown( wpLink.keydown );
+ inputs.dialog.keyup( wpLink.keyup );
+ inputs.submit.click( function( event ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> event.preventDefault();
</span><span class="cx" style="display: block; padding: 0 10px"> wpLink.update();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,105 +57,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wpLink.close();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ rivers.elements.on( 'river-select', wpLink.updateFields );
+
+ // Display 'hint' message when search field or 'query-results' box are focused
+ inputs.search.on( 'focus.wplink', function() {
+ inputs.queryNoticeTextDefault.hide();
+ inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show();
+ } ).on( 'blur.wplink', function() {
+ inputs.queryNoticeTextDefault.show();
+ inputs.queryNoticeTextHint.addClass( 'screen-reader-text' ).hide();
+ } );
+
+ inputs.search.on( 'keyup input', function() {
+ window.clearTimeout( searchTimer );
+ searchTimer = window.setTimeout( function() {
+ wpLink.searchInternalLinks();
+ }, 500 );
+ });
+
</ins><span class="cx" style="display: block; padding: 0 10px"> inputs.url.on( 'paste', function() {
</span><span class="cx" style="display: block; padding: 0 10px"> setTimeout( wpLink.correctURL, 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- },
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- setAutocomplete: function() {
- var $input = inputs.url,
- cache, last;
-
- $input.on( 'keydown', function() {
- $input.removeAttr( 'aria-activedescendant' );
- } ).autocomplete( {
- source: function( request, response ) {
- if ( last === request.term ) {
- response( cache );
- return;
- }
-
- if ( /^https?:/.test( request.term ) || request.term.indexOf( '.' ) !== -1 ) {
- return response();
- }
-
- $.post( window.ajaxurl, {
- action: 'wp-link-ajax',
- page: 1,
- search: request.term,
- _ajax_linking_nonce: $( '#_ajax_linking_nonce' ).val()
- }, function( data ) {
- cache = data;
- response( data );
- }, 'json' );
-
- last = request.term;
- },
- focus: function( event, ui ) {
- $input.attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID );
- /*
- * Don't empty the URL input field, when using the arrow keys to
- * highlight items. See api.jqueryui.com/autocomplete/#event-focus
- */
- event.preventDefault();
- },
- select: function( event, ui ) {
- $input.val( ui.item.permalink );
-
- if ( inputs.wrap.hasClass( 'has-text-field' ) && $.trim( inputs.text.val() ) === '' ) {
- inputs.text.val( ui.item.title );
- }
-
- // Audible confirmation message when a link has been selected.
- wp.a11y.speak( wpLinkL10n.linkSelected );
-
- return false;
- },
- open: function() {
- $input.attr( 'aria-expanded', 'true' );
- },
- close: function() {
- $input.attr( 'aria-expanded', 'false' );
- },
- minLength: 2,
- position: {
- my: 'left top+2'
- },
- messages: {
- noResults: ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.noResults : '',
- results: function( number ) {
- if ( typeof window.uiAutocompleteL10n !== 'undefined' ) {
- if ( number > 1 ) {
- return window.uiAutocompleteL10n.manyResults.replace( '%d', number );
- }
-
- return window.uiAutocompleteL10n.oneResult;
- }
- }
- }
- } ).autocomplete( 'instance' )._renderItem = function( ul, item ) {
- return $( '<li role="option" id="mce-wp-autocomplete-' + item.ID + '">' )
- .append( '<span class="item-title">' + item.title + '</span> <span class="item-date alignright">' + item.info + '</span>' )
- .appendTo( ul );
- };
-
- $input.attr( {
- 'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' )
- } )
- .on( 'focus', function() {
- var inputValue = $input.val();
- /*
- * Don't trigger a search if the URL field already has a link or is empty.
- * Also, avoids screen readers announce `No search results`.
- */
- if ( inputValue && ! /^https?:/.test( inputValue ) ) {
- $input.autocomplete( 'search' );
- }
- } )
- .autocomplete( 'widget' )
- .addClass( 'wplink-autocomplete' )
- .attr( 'role', 'listbox' )
- .removeAttr( 'tabindex' ); // Remove the `tabindex=0` attribute added by jQuery UI.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ inputs.url.on( 'blur', wpLink.correctURL );
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -208,6 +149,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> refresh: function( url, text ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var linkText = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Refresh rivers (clear links, check visibility)
+ rivers.search.refresh();
+ rivers.recent.refresh();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( wpLink.isMCE() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wpLink.mceRefresh( url, text );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -237,10 +182,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // If this is moved above the selection changes,
</span><span class="cx" style="display: block; padding: 0 10px"> // IE will show a flashing cursor over the dialog.
</span><span class="cx" style="display: block; padding: 0 10px"> window.setTimeout( function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- inputs.url.focus()[0].select();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ inputs.url[0].select();
+ inputs.url.focus();
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // 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" style="display: block; padding: 0 10px"> correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -271,27 +222,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- mceRefresh: function( url, text ) {
- var linkText,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ mceRefresh: function( searchStr, text ) {
+ var linkText, href,
</ins><span class="cx" style="display: block; padding: 0 10px"> linkNode = getLink(),
</span><span class="cx" style="display: block; padding: 0 10px"> onlyText = this.hasSelectedText( linkNode );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( linkNode ) {
</span><span class="cx" style="display: block; padding: 0 10px"> linkText = linkNode.innerText || linkNode.textContent;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ href = editor.dom.getAttrib( linkNode, 'href' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $.trim( linkText ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> linkText = text || '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- url = url || editor.dom.getAttrib( linkNode, 'href' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( searchStr && ( urlRegexp.test( searchStr ) || emailRegexp.test( searchStr ) ) ) {
+ href = searchStr;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( url !== '_wp_link_placeholder' ) {
- inputs.url.val( url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( href !== '_wp_link_placeholder' ) {
+ inputs.url.val( href );
</ins><span class="cx" style="display: block; padding: 0 10px"> inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> inputs.submit.val( wpLinkL10n.update );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> this.setDefaultValues( linkText );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( searchStr && searchStr !== href ) {
+ // The user has typed something in the inline dialog. Trigger a search with it.
+ inputs.search.val( searchStr );
+ } else {
+ inputs.search.val( '' );
+ }
+
+ // Always reset the search
+ window.setTimeout( function() {
+ wpLink.searchInternalLinks();
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> linkText = editor.selection.getContent({ format: 'text' }) || text || '';
</span><span class="cx" style="display: block; padding: 0 10px"> this.setDefaultValues( linkText );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -424,8 +390,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var attrs = wpLink.getAttrs(),
</span><span class="cx" style="display: block; padding: 0 10px"> link, text;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- editor.focus();
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( window.tinymce.isIE && editor.windowManager.wplinkBookmark ) {
</span><span class="cx" style="display: block; padding: 0 10px"> editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
</span><span class="cx" style="display: block; padding: 0 10px"> editor.windowManager.wplinkBookmark = null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -471,33 +435,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp.a11y.speak( wpLinkL10n.linkInserted );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- keydown: function( event ) {
- var id;
-
- // Escape key.
- if ( 27 === event.keyCode ) {
- wpLink.close();
- event.stopImmediatePropagation();
- // Tab key.
- } else if ( 9 === event.keyCode ) {
- id = event.target.id;
-
- // wp-link-submit must always be the last focusable element in the dialog.
- // following focusable elements will be skipped on keyboard navigation.
- if ( id === 'wp-link-submit' && ! event.shiftKey ) {
- inputs.close.focus();
- event.preventDefault();
- } else if ( id === 'wp-link-close' && event.shiftKey ) {
- inputs.submit.focus();
- event.preventDefault();
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ updateFields: function( e, li ) {
+ inputs.url.val( li.children( '.item-permalink' ).val() );
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> getUrlFromSelection: function( selection ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
- urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! selection ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( this.isMCE() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> selection = editor.selection.getContent({ format: 'text' });
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -524,10 +466,302 @@
</span><span class="cx" style="display: block; padding: 0 10px"> setDefaultValues: function( selection ) {
</span><span class="cx" style="display: block; padding: 0 10px"> inputs.url.val( this.getUrlFromSelection( selection ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Empty the search field and swap the "rivers".
+ inputs.search.val('');
+ wpLink.searchInternalLinks();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Update save prompt.
</span><span class="cx" style="display: block; padding: 0 10px"> inputs.submit.val( wpLinkL10n.save );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ },
+
+ searchInternalLinks: function() {
+ var waiting,
+ search = inputs.search.val() || '';
+
+ if ( search.length > 2 ) {
+ rivers.recent.hide();
+ rivers.search.show();
+
+ // Don't search if the keypress didn't change the title.
+ if ( wpLink.lastSearch == search )
+ return;
+
+ wpLink.lastSearch = search;
+ waiting = inputs.search.parent().find( '.spinner' ).addClass( 'is-active' );
+
+ rivers.search.change( search );
+ rivers.search.ajax( function() {
+ waiting.removeClass( 'is-active' );
+ });
+ } else {
+ rivers.search.hide();
+ rivers.recent.show();
+ }
+ },
+
+ next: function() {
+ rivers.search.next();
+ rivers.recent.next();
+ },
+
+ prev: function() {
+ rivers.search.prev();
+ rivers.recent.prev();
+ },
+
+ keydown: function( event ) {
+ var fn, id;
+
+ // Escape key.
+ if ( 27 === event.keyCode ) {
+ wpLink.close();
+ event.stopImmediatePropagation();
+ // Tab key.
+ } else if ( 9 === event.keyCode ) {
+ id = event.target.id;
+
+ // wp-link-submit must always be the last focusable element in the dialog.
+ // following focusable elements will be skipped on keyboard navigation.
+ if ( id === 'wp-link-submit' && ! event.shiftKey ) {
+ inputs.close.focus();
+ event.preventDefault();
+ } else if ( id === 'wp-link-close' && event.shiftKey ) {
+ inputs.submit.focus();
+ event.preventDefault();
+ }
+ }
+
+ // Up Arrow and Down Arrow keys.
+ if ( 38 !== event.keyCode && 40 !== event.keyCode ) {
+ return;
+ }
+
+ if ( document.activeElement &&
+ ( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) {
+ return;
+ }
+
+ // Up Arrow key.
+ fn = 38 === event.keyCode ? 'prev' : 'next';
+ clearInterval( wpLink.keyInterval );
+ wpLink[ fn ]();
+ wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
+ event.preventDefault();
+ },
+
+ keyup: function( event ) {
+ // Up Arrow and Down Arrow keys.
+ if ( 38 === event.keyCode || 40 === event.keyCode ) {
+ clearInterval( wpLink.keyInterval );
+ event.preventDefault();
+ }
+ },
+
+ delayedCallback: function( func, delay ) {
+ var timeoutTriggered, funcTriggered, funcArgs, funcContext;
+
+ if ( ! delay )
+ return func;
+
+ setTimeout( function() {
+ if ( funcTriggered )
+ return func.apply( funcContext, funcArgs );
+ // Otherwise, wait.
+ timeoutTriggered = true;
+ }, delay );
+
+ return function() {
+ if ( timeoutTriggered )
+ return func.apply( this, arguments );
+ // Otherwise, wait.
+ funcArgs = arguments;
+ funcContext = this;
+ funcTriggered = true;
+ };
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ River = function( element, search ) {
+ var self = this;
+ this.element = element;
+ this.ul = element.children( 'ul' );
+ this.contentHeight = element.children( '#link-selector-height' );
+ this.waiting = element.find('.river-waiting');
+
+ this.change( search );
+ this.refresh();
+
+ $( '#wp-link .query-results, #wp-link #link-selector' ).scroll( function() {
+ self.maybeLoad();
+ });
+ element.on( 'click', 'li', function( event ) {
+ self.select( $( this ), event );
+ });
+ };
+
+ $.extend( River.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;
+ },
+ // Selects a list item and triggers the river-select event.
+ select: function( li, event ) {
+ var liHeight, elHeight, liTop, elTop;
+
+ if ( li.hasClass( 'unselectable' ) || li == this.selected )
+ return;
+
+ this.deselect();
+ this.selected = li.addClass( 'selected' );
+ // Make sure the element is visible
+ liHeight = li.outerHeight();
+ elHeight = this.element.height();
+ liTop = li.position().top;
+ elTop = this.element.scrollTop();
+
+ if ( liTop < 0 ) // Make first visible element
+ this.element.scrollTop( elTop + liTop );
+ else if ( liTop + liHeight > elHeight ) // Make last visible element
+ this.element.scrollTop( elTop + liTop - elHeight + liHeight );
+
+ // Trigger the river-select event
+ this.element.trigger( 'river-select', [ li, event, this ] );
+ },
+ deselect: function() {
+ if ( this.selected )
+ this.selected.removeClass( 'selected' );
+ this.selected = false;
+ },
+ prev: function() {
+ if ( ! this.visible )
+ return;
+
+ var to;
+ if ( this.selected ) {
+ to = this.selected.prev( 'li' );
+ if ( to.length )
+ this.select( to );
+ }
+ },
+ next: function() {
+ if ( ! this.visible )
+ return;
+
+ var to = this.selected ? this.selected.next( 'li' ) : $( 'li:not(.unselectable):first', this.element );
+ if ( to.length )
+ this.select( to );
+ },
+ 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 );
+ },
+ 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, classes = '',
+ firstPage = params.page == 1;
+
+ if ( ! results ) {
+ if ( firstPage ) {
+ list += '<li class="unselectable no-matches-found"><span class="item-title"><em>' +
+ wpLinkL10n.noMatchesFound + '</em></span></li>';
+ }
+ } else {
+ $.each( results, function() {
+ classes = alt ? 'alternate' : '';
+ classes += this.title ? '' : ' no-title';
+ list += classes ? '<li class="' + classes + '">' : '<li>';
+ list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />';
+ list += '<span class="item-title">';
+ list += this.title ? this.title : wpLinkL10n.noTitle;
+ list += '</span><span class="item-info">' + this.info + '</span></li>';
+ alt = ! alt;
+ });
+ }
+
+ this.ul[ firstPage ? 'html' : 'append' ]( list );
+ },
+ maybeLoad: function() {
+ var self = this,
+ el = this.element,
+ bottom = el.scrollTop() + el.height();
+
+ if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold )
+ return;
+
+ setTimeout(function() {
+ var newTop = el.scrollTop(),
+ newBottom = newTop + el.height();
+
+ if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold )
+ return;
+
+ self.waiting.addClass( 'is-active' );
+ el.scrollTop( newTop + self.waiting.outerHeight() );
+
+ self.ajax( function() {
+ self.waiting.removeClass( 'is-active' );
+ });
+ }, wpLink.timeToTriggerRiver );
+ }
+ });
+
+ 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,
+ '_ajax_linking_nonce' : inputs.nonce.val()
+ };
+
+ if ( this.search )
+ query.search = this.search;
+
+ this.querying = true;
+
+ $.post( window.ajaxurl, query, function( r ) {
+ self.page++;
+ self.querying = false;
+ self.allLoaded = ! r;
+ callback( r, query );
+ }, 'json' );
+ }
+ });
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $( document ).ready( wpLink.init );
</span><span class="cx" style="display: block; padding: 0 10px"> })( jQuery, window.wpLinkL10n, window.wp );
</span></span></pre>
</div>
</div>
</body>
</html>