Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

780 lignes
20 KiB

  1. var wpLink;
  2. ( function( $, wpLinkL10n, wp ) {
  3. var editor, searchTimer, River, Query, correctedURL, linkNode,
  4. emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}$/i,
  5. urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,63}[^ "]*$/i,
  6. inputs = {},
  7. rivers = {},
  8. isTouch = ( 'ontouchend' in document );
  9. function getLink() {
  10. return linkNode || editor.dom.getParent( editor.selection.getNode(), 'a[href]' );
  11. }
  12. wpLink = {
  13. timeToTriggerRiver: 150,
  14. minRiverAJAXDuration: 200,
  15. riverBottomThreshold: 5,
  16. keySensitivity: 100,
  17. lastSearch: '',
  18. textarea: '',
  19. modalOpen: false,
  20. init: function() {
  21. inputs.wrap = $('#wp-link-wrap');
  22. inputs.dialog = $( '#wp-link' );
  23. inputs.backdrop = $( '#wp-link-backdrop' );
  24. inputs.submit = $( '#wp-link-submit' );
  25. inputs.close = $( '#wp-link-close' );
  26. // Input
  27. inputs.text = $( '#wp-link-text' );
  28. inputs.url = $( '#wp-link-url' );
  29. inputs.nonce = $( '#_ajax_linking_nonce' );
  30. inputs.openInNewTab = $( '#wp-link-target' );
  31. inputs.search = $( '#wp-link-search' );
  32. // Build Rivers
  33. rivers.search = new River( $( '#search-results' ) );
  34. rivers.recent = new River( $( '#most-recent-results' ) );
  35. rivers.elements = inputs.dialog.find( '.query-results' );
  36. // Get search notice text
  37. inputs.queryNotice = $( '#query-notice-message' );
  38. inputs.queryNoticeTextDefault = inputs.queryNotice.find( '.query-notice-default' );
  39. inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' );
  40. // Bind event handlers
  41. inputs.dialog.keydown( wpLink.keydown );
  42. inputs.dialog.keyup( wpLink.keyup );
  43. inputs.submit.click( function( event ) {
  44. event.preventDefault();
  45. wpLink.update();
  46. });
  47. inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel button' ).click( function( event ) {
  48. event.preventDefault();
  49. wpLink.close();
  50. });
  51. rivers.elements.on( 'river-select', wpLink.updateFields );
  52. // Display 'hint' message when search field or 'query-results' box are focused
  53. inputs.search.on( 'focus.wplink', function() {
  54. inputs.queryNoticeTextDefault.hide();
  55. inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show();
  56. } ).on( 'blur.wplink', function() {
  57. inputs.queryNoticeTextDefault.show();
  58. inputs.queryNoticeTextHint.addClass( 'screen-reader-text' ).hide();
  59. } );
  60. inputs.search.on( 'keyup input', function() {
  61. window.clearTimeout( searchTimer );
  62. searchTimer = window.setTimeout( function() {
  63. wpLink.searchInternalLinks();
  64. }, 500 );
  65. });
  66. inputs.url.on( 'paste', function() {
  67. setTimeout( wpLink.correctURL, 0 );
  68. } );
  69. inputs.url.on( 'blur', wpLink.correctURL );
  70. },
  71. // If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://
  72. correctURL: function () {
  73. var url = $.trim( inputs.url.val() );
  74. if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
  75. inputs.url.val( 'http://' + url );
  76. correctedURL = url;
  77. }
  78. },
  79. open: function( editorId, url, text, node ) {
  80. var ed,
  81. $body = $( document.body );
  82. $body.addClass( 'modal-open' );
  83. wpLink.modalOpen = true;
  84. linkNode = node;
  85. wpLink.range = null;
  86. if ( editorId ) {
  87. window.wpActiveEditor = editorId;
  88. }
  89. if ( ! window.wpActiveEditor ) {
  90. return;
  91. }
  92. this.textarea = $( '#' + window.wpActiveEditor ).get( 0 );
  93. if ( typeof window.tinymce !== 'undefined' ) {
  94. // Make sure the link wrapper is the last element in the body,
  95. // or the inline editor toolbar may show above the backdrop.
  96. $body.append( inputs.backdrop, inputs.wrap );
  97. ed = window.tinymce.get( window.wpActiveEditor );
  98. if ( ed && ! ed.isHidden() ) {
  99. editor = ed;
  100. } else {
  101. editor = null;
  102. }
  103. }
  104. if ( ! wpLink.isMCE() && document.selection ) {
  105. this.textarea.focus();
  106. this.range = document.selection.createRange();
  107. }
  108. inputs.wrap.show();
  109. inputs.backdrop.show();
  110. wpLink.refresh( url, text );
  111. $( document ).trigger( 'wplink-open', inputs.wrap );
  112. },
  113. isMCE: function() {
  114. return editor && ! editor.isHidden();
  115. },
  116. refresh: function( url, text ) {
  117. var linkText = '';
  118. // Refresh rivers (clear links, check visibility)
  119. rivers.search.refresh();
  120. rivers.recent.refresh();
  121. if ( wpLink.isMCE() ) {
  122. wpLink.mceRefresh( url, text );
  123. } else {
  124. // For the Text editor the "Link text" field is always shown
  125. if ( ! inputs.wrap.hasClass( 'has-text-field' ) ) {
  126. inputs.wrap.addClass( 'has-text-field' );
  127. }
  128. if ( document.selection ) {
  129. // Old IE
  130. linkText = document.selection.createRange().text || text || '';
  131. } else if ( typeof this.textarea.selectionStart !== 'undefined' &&
  132. ( this.textarea.selectionStart !== this.textarea.selectionEnd ) ) {
  133. // W3C
  134. text = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd ) || text || '';
  135. }
  136. inputs.text.val( text );
  137. wpLink.setDefaultValues();
  138. }
  139. if ( isTouch ) {
  140. // Close the onscreen keyboard
  141. inputs.url.focus().blur();
  142. } else {
  143. // Focus the URL field and highlight its contents.
  144. // If this is moved above the selection changes,
  145. // IE will show a flashing cursor over the dialog.
  146. window.setTimeout( function() {
  147. inputs.url[0].select();
  148. inputs.url.focus();
  149. } );
  150. }
  151. // Load the most recent results if this is the first time opening the panel.
  152. if ( ! rivers.recent.ul.children().length ) {
  153. rivers.recent.ajax();
  154. }
  155. correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
  156. },
  157. hasSelectedText: function( linkNode ) {
  158. var node, nodes, i, html = editor.selection.getContent();
  159. // Partial html and not a fully selected anchor element
  160. if ( /</.test( html ) && ( ! /^<a [^>]+>[^<]+<\/a>$/.test( html ) || html.indexOf('href=') === -1 ) ) {
  161. return false;
  162. }
  163. if ( linkNode ) {
  164. nodes = linkNode.childNodes;
  165. if ( nodes.length === 0 ) {
  166. return false;
  167. }
  168. for ( i = nodes.length - 1; i >= 0; i-- ) {
  169. node = nodes[i];
  170. if ( node.nodeType != 3 && ! window.tinymce.dom.BookmarkManager.isBookmarkNode( node ) ) {
  171. return false;
  172. }
  173. }
  174. }
  175. return true;
  176. },
  177. mceRefresh: function( searchStr, text ) {
  178. var linkText, href,
  179. linkNode = getLink(),
  180. onlyText = this.hasSelectedText( linkNode );
  181. if ( linkNode ) {
  182. linkText = linkNode.textContent || linkNode.innerText;
  183. href = editor.dom.getAttrib( linkNode, 'href' );
  184. if ( ! $.trim( linkText ) ) {
  185. linkText = text || '';
  186. }
  187. if ( searchStr && ( urlRegexp.test( searchStr ) || emailRegexp.test( searchStr ) ) ) {
  188. href = searchStr;
  189. }
  190. if ( href !== '_wp_link_placeholder' ) {
  191. inputs.url.val( href );
  192. inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) );
  193. inputs.submit.val( wpLinkL10n.update );
  194. } else {
  195. this.setDefaultValues( linkText );
  196. }
  197. if ( searchStr && searchStr !== href ) {
  198. // The user has typed something in the inline dialog. Trigger a search with it.
  199. inputs.search.val( searchStr );
  200. } else {
  201. inputs.search.val( '' );
  202. }
  203. // Always reset the search
  204. window.setTimeout( function() {
  205. wpLink.searchInternalLinks();
  206. } );
  207. } else {
  208. linkText = editor.selection.getContent({ format: 'text' }) || text || '';
  209. this.setDefaultValues( linkText );
  210. }
  211. if ( onlyText ) {
  212. inputs.text.val( linkText );
  213. inputs.wrap.addClass( 'has-text-field' );
  214. } else {
  215. inputs.text.val( '' );
  216. inputs.wrap.removeClass( 'has-text-field' );
  217. }
  218. },
  219. close: function( reset ) {
  220. $( document.body ).removeClass( 'modal-open' );
  221. wpLink.modalOpen = false;
  222. if ( reset !== 'noReset' ) {
  223. if ( ! wpLink.isMCE() ) {
  224. wpLink.textarea.focus();
  225. if ( wpLink.range ) {
  226. wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
  227. wpLink.range.select();
  228. }
  229. } else {
  230. if ( editor.plugins.wplink ) {
  231. editor.plugins.wplink.close();
  232. }
  233. editor.focus();
  234. }
  235. }
  236. inputs.backdrop.hide();
  237. inputs.wrap.hide();
  238. correctedURL = false;
  239. $( document ).trigger( 'wplink-close', inputs.wrap );
  240. },
  241. getAttrs: function() {
  242. wpLink.correctURL();
  243. return {
  244. href: $.trim( inputs.url.val() ),
  245. target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : null
  246. };
  247. },
  248. buildHtml: function(attrs) {
  249. var html = '<a href="' + attrs.href + '"';
  250. if ( attrs.target ) {
  251. html += ' target="' + attrs.target + '"';
  252. }
  253. return html + '>';
  254. },
  255. update: function() {
  256. if ( wpLink.isMCE() ) {
  257. wpLink.mceUpdate();
  258. } else {
  259. wpLink.htmlUpdate();
  260. }
  261. },
  262. htmlUpdate: function() {
  263. var attrs, text, html, begin, end, cursor, selection,
  264. textarea = wpLink.textarea;
  265. if ( ! textarea ) {
  266. return;
  267. }
  268. attrs = wpLink.getAttrs();
  269. text = inputs.text.val();
  270. // If there's no href, return.
  271. if ( ! attrs.href ) {
  272. return;
  273. }
  274. html = wpLink.buildHtml(attrs);
  275. // Insert HTML
  276. if ( document.selection && wpLink.range ) {
  277. // IE
  278. // Note: If no text is selected, IE will not place the cursor
  279. // inside the closing tag.
  280. textarea.focus();
  281. wpLink.range.text = html + ( text || wpLink.range.text ) + '</a>';
  282. wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
  283. wpLink.range.select();
  284. wpLink.range = null;
  285. } else if ( typeof textarea.selectionStart !== 'undefined' ) {
  286. // W3C
  287. begin = textarea.selectionStart;
  288. end = textarea.selectionEnd;
  289. selection = text || textarea.value.substring( begin, end );
  290. html = html + selection + '</a>';
  291. cursor = begin + html.length;
  292. // If no text is selected, place the cursor inside the closing tag.
  293. if ( begin === end && ! selection ) {
  294. cursor -= 4;
  295. }
  296. textarea.value = (
  297. textarea.value.substring( 0, begin ) +
  298. html +
  299. textarea.value.substring( end, textarea.value.length )
  300. );
  301. // Update cursor position
  302. textarea.selectionStart = textarea.selectionEnd = cursor;
  303. }
  304. wpLink.close();
  305. textarea.focus();
  306. // Audible confirmation message when a link has been inserted in the Editor.
  307. wp.a11y.speak( wpLinkL10n.linkInserted );
  308. },
  309. mceUpdate: function() {
  310. var attrs = wpLink.getAttrs(),
  311. $link, text, hasText, $mceCaret;
  312. if ( ! attrs.href ) {
  313. editor.execCommand( 'unlink' );
  314. wpLink.close();
  315. return;
  316. }
  317. $link = editor.$( getLink() );
  318. editor.undoManager.transact( function() {
  319. if ( ! $link.length ) {
  320. editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder', 'data-wp-temp-link': 1 } );
  321. $link = editor.$( 'a[data-wp-temp-link="1"]' ).removeAttr( 'data-wp-temp-link' );
  322. hasText = $.trim( $link.text() );
  323. }
  324. if ( ! $link.length ) {
  325. editor.execCommand( 'unlink' );
  326. } else {
  327. if ( inputs.wrap.hasClass( 'has-text-field' ) ) {
  328. text = inputs.text.val();
  329. if ( text ) {
  330. $link.text( text );
  331. } else if ( ! hasText ) {
  332. $link.text( attrs.href );
  333. }
  334. }
  335. attrs['data-wplink-edit'] = null;
  336. attrs['data-mce-href'] = null; // attrs.href
  337. $link.attr( attrs );
  338. }
  339. } );
  340. wpLink.close( 'noReset' );
  341. editor.focus();
  342. if ( $link.length ) {
  343. $mceCaret = $link.parent( '#_mce_caret' );
  344. if ( $mceCaret.length ) {
  345. $mceCaret.before( $link.removeAttr( 'data-mce-bogus' ) );
  346. }
  347. editor.selection.select( $link[0] );
  348. editor.selection.collapse();
  349. if ( editor.plugins.wplink ) {
  350. editor.plugins.wplink.checkLink( $link[0] );
  351. }
  352. }
  353. editor.nodeChanged();
  354. // Audible confirmation message when a link has been inserted in the Editor.
  355. wp.a11y.speak( wpLinkL10n.linkInserted );
  356. },
  357. updateFields: function( e, li ) {
  358. inputs.url.val( li.children( '.item-permalink' ).val() );
  359. },
  360. getUrlFromSelection: function( selection ) {
  361. if ( ! selection ) {
  362. if ( this.isMCE() ) {
  363. selection = editor.selection.getContent({ format: 'text' });
  364. } else if ( document.selection && wpLink.range ) {
  365. selection = wpLink.range.text;
  366. } else if ( typeof this.textarea.selectionStart !== 'undefined' ) {
  367. selection = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd );
  368. }
  369. }
  370. selection = $.trim( selection );
  371. if ( selection && emailRegexp.test( selection ) ) {
  372. // Selection is email address
  373. return 'mailto:' + selection;
  374. } else if ( selection && urlRegexp.test( selection ) ) {
  375. // Selection is URL
  376. return selection.replace( /&amp;|&#0?38;/gi, '&' );
  377. }
  378. return '';
  379. },
  380. setDefaultValues: function( selection ) {
  381. inputs.url.val( this.getUrlFromSelection( selection ) );
  382. // Empty the search field and swap the "rivers".
  383. inputs.search.val('');
  384. wpLink.searchInternalLinks();
  385. // Update save prompt.
  386. inputs.submit.val( wpLinkL10n.save );
  387. },
  388. searchInternalLinks: function() {
  389. var waiting,
  390. search = inputs.search.val() || '';
  391. if ( search.length > 2 ) {
  392. rivers.recent.hide();
  393. rivers.search.show();
  394. // Don't search if the keypress didn't change the title.
  395. if ( wpLink.lastSearch == search )
  396. return;
  397. wpLink.lastSearch = search;
  398. waiting = inputs.search.parent().find( '.spinner' ).addClass( 'is-active' );
  399. rivers.search.change( search );
  400. rivers.search.ajax( function() {
  401. waiting.removeClass( 'is-active' );
  402. });
  403. } else {
  404. rivers.search.hide();
  405. rivers.recent.show();
  406. }
  407. },
  408. next: function() {
  409. rivers.search.next();
  410. rivers.recent.next();
  411. },
  412. prev: function() {
  413. rivers.search.prev();
  414. rivers.recent.prev();
  415. },
  416. keydown: function( event ) {
  417. var fn, id;
  418. // Escape key.
  419. if ( 27 === event.keyCode ) {
  420. wpLink.close();
  421. event.stopImmediatePropagation();
  422. // Tab key.
  423. } else if ( 9 === event.keyCode ) {
  424. id = event.target.id;
  425. // wp-link-submit must always be the last focusable element in the dialog.
  426. // following focusable elements will be skipped on keyboard navigation.
  427. if ( id === 'wp-link-submit' && ! event.shiftKey ) {
  428. inputs.close.focus();
  429. event.preventDefault();
  430. } else if ( id === 'wp-link-close' && event.shiftKey ) {
  431. inputs.submit.focus();
  432. event.preventDefault();
  433. }
  434. }
  435. // Up Arrow and Down Arrow keys.
  436. if ( 38 !== event.keyCode && 40 !== event.keyCode ) {
  437. return;
  438. }
  439. if ( document.activeElement &&
  440. ( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) {
  441. return;
  442. }
  443. // Up Arrow key.
  444. fn = 38 === event.keyCode ? 'prev' : 'next';
  445. clearInterval( wpLink.keyInterval );
  446. wpLink[ fn ]();
  447. wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
  448. event.preventDefault();
  449. },
  450. keyup: function( event ) {
  451. // Up Arrow and Down Arrow keys.
  452. if ( 38 === event.keyCode || 40 === event.keyCode ) {
  453. clearInterval( wpLink.keyInterval );
  454. event.preventDefault();
  455. }
  456. },
  457. delayedCallback: function( func, delay ) {
  458. var timeoutTriggered, funcTriggered, funcArgs, funcContext;
  459. if ( ! delay )
  460. return func;
  461. setTimeout( function() {
  462. if ( funcTriggered )
  463. return func.apply( funcContext, funcArgs );
  464. // Otherwise, wait.
  465. timeoutTriggered = true;
  466. }, delay );
  467. return function() {
  468. if ( timeoutTriggered )
  469. return func.apply( this, arguments );
  470. // Otherwise, wait.
  471. funcArgs = arguments;
  472. funcContext = this;
  473. funcTriggered = true;
  474. };
  475. }
  476. };
  477. River = function( element, search ) {
  478. var self = this;
  479. this.element = element;
  480. this.ul = element.children( 'ul' );
  481. this.contentHeight = element.children( '#link-selector-height' );
  482. this.waiting = element.find('.river-waiting');
  483. this.change( search );
  484. this.refresh();
  485. $( '#wp-link .query-results, #wp-link #link-selector' ).scroll( function() {
  486. self.maybeLoad();
  487. });
  488. element.on( 'click', 'li', function( event ) {
  489. self.select( $( this ), event );
  490. });
  491. };
  492. $.extend( River.prototype, {
  493. refresh: function() {
  494. this.deselect();
  495. this.visible = this.element.is( ':visible' );
  496. },
  497. show: function() {
  498. if ( ! this.visible ) {
  499. this.deselect();
  500. this.element.show();
  501. this.visible = true;
  502. }
  503. },
  504. hide: function() {
  505. this.element.hide();
  506. this.visible = false;
  507. },
  508. // Selects a list item and triggers the river-select event.
  509. select: function( li, event ) {
  510. var liHeight, elHeight, liTop, elTop;
  511. if ( li.hasClass( 'unselectable' ) || li == this.selected )
  512. return;
  513. this.deselect();
  514. this.selected = li.addClass( 'selected' );
  515. // Make sure the element is visible
  516. liHeight = li.outerHeight();
  517. elHeight = this.element.height();
  518. liTop = li.position().top;
  519. elTop = this.element.scrollTop();
  520. if ( liTop < 0 ) // Make first visible element
  521. this.element.scrollTop( elTop + liTop );
  522. else if ( liTop + liHeight > elHeight ) // Make last visible element
  523. this.element.scrollTop( elTop + liTop - elHeight + liHeight );
  524. // Trigger the river-select event
  525. this.element.trigger( 'river-select', [ li, event, this ] );
  526. },
  527. deselect: function() {
  528. if ( this.selected )
  529. this.selected.removeClass( 'selected' );
  530. this.selected = false;
  531. },
  532. prev: function() {
  533. if ( ! this.visible )
  534. return;
  535. var to;
  536. if ( this.selected ) {
  537. to = this.selected.prev( 'li' );
  538. if ( to.length )
  539. this.select( to );
  540. }
  541. },
  542. next: function() {
  543. if ( ! this.visible )
  544. return;
  545. var to = this.selected ? this.selected.next( 'li' ) : $( 'li:not(.unselectable):first', this.element );
  546. if ( to.length )
  547. this.select( to );
  548. },
  549. ajax: function( callback ) {
  550. var self = this,
  551. delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration,
  552. response = wpLink.delayedCallback( function( results, params ) {
  553. self.process( results, params );
  554. if ( callback )
  555. callback( results, params );
  556. }, delay );
  557. this.query.ajax( response );
  558. },
  559. change: function( search ) {
  560. if ( this.query && this._search == search )
  561. return;
  562. this._search = search;
  563. this.query = new Query( search );
  564. this.element.scrollTop( 0 );
  565. },
  566. process: function( results, params ) {
  567. var list = '', alt = true, classes = '',
  568. firstPage = params.page == 1;
  569. if ( ! results ) {
  570. if ( firstPage ) {
  571. list += '<li class="unselectable no-matches-found"><span class="item-title"><em>' +
  572. wpLinkL10n.noMatchesFound + '</em></span></li>';
  573. }
  574. } else {
  575. $.each( results, function() {
  576. classes = alt ? 'alternate' : '';
  577. classes += this.title ? '' : ' no-title';
  578. list += classes ? '<li class="' + classes + '">' : '<li>';
  579. list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />';
  580. list += '<span class="item-title">';
  581. list += this.title ? this.title : wpLinkL10n.noTitle;
  582. list += '</span><span class="item-info">' + this.info + '</span></li>';
  583. alt = ! alt;
  584. });
  585. }
  586. this.ul[ firstPage ? 'html' : 'append' ]( list );
  587. },
  588. maybeLoad: function() {
  589. var self = this,
  590. el = this.element,
  591. bottom = el.scrollTop() + el.height();
  592. if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold )
  593. return;
  594. setTimeout(function() {
  595. var newTop = el.scrollTop(),
  596. newBottom = newTop + el.height();
  597. if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold )
  598. return;
  599. self.waiting.addClass( 'is-active' );
  600. el.scrollTop( newTop + self.waiting.outerHeight() );
  601. self.ajax( function() {
  602. self.waiting.removeClass( 'is-active' );
  603. });
  604. }, wpLink.timeToTriggerRiver );
  605. }
  606. });
  607. Query = function( search ) {
  608. this.page = 1;
  609. this.allLoaded = false;
  610. this.querying = false;
  611. this.search = search;
  612. };
  613. $.extend( Query.prototype, {
  614. ready: function() {
  615. return ! ( this.querying || this.allLoaded );
  616. },
  617. ajax: function( callback ) {
  618. var self = this,
  619. query = {
  620. action : 'wp-link-ajax',
  621. page : this.page,
  622. '_ajax_linking_nonce' : inputs.nonce.val()
  623. };
  624. if ( this.search )
  625. query.search = this.search;
  626. this.querying = true;
  627. $.post( window.ajaxurl, query, function( r ) {
  628. self.page++;
  629. self.querying = false;
  630. self.allLoaded = ! r;
  631. callback( r, query );
  632. }, 'json' );
  633. }
  634. });
  635. $( document ).ready( wpLink.init );
  636. })( jQuery, window.wpLinkL10n, window.wp );