From c28fff3b6525299dccea979bb27ab836c87c6d61 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 2 Apr 2014 02:26:12 +0000 Subject: [PATCH] wpLink: fix spinners selectors and add some throttling when searching with AJAX while the user is typing, fixes #27615 git-svn-id: https://develop.svn.wordpress.org/trunk@27900 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/css/editor.css | 1 + src/wp-includes/js/wplink.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/css/editor.css b/src/wp-includes/css/editor.css index 60c5ef4a8e..f033e7b949 100644 --- a/src/wp-includes/css/editor.css +++ b/src/wp-includes/css/editor.css @@ -1212,6 +1212,7 @@ i.mce-i-hr:before { #wp-link .river-waiting .spinner { margin: 0 auto; display: block; + float: none; } #wp-link .submitbox { diff --git a/src/wp-includes/js/wplink.js b/src/wp-includes/js/wplink.js index 5de8f3b01f..7d1c6774e8 100644 --- a/src/wp-includes/js/wplink.js +++ b/src/wp-includes/js/wplink.js @@ -2,7 +2,7 @@ var wpLink; ( function( $ ) { - var inputs = {}, rivers = {}, editor, River, Query; + var inputs = {}, rivers = {}, editor, searchTimer, River, Query; wpLink = { timeToTriggerRiver: 150, @@ -47,7 +47,14 @@ var wpLink; rivers.elements.on( 'river-select', wpLink.updateFields ); - inputs.search.keyup( wpLink.searchInternalLinks ); + inputs.search.keyup( function() { + var self = this; + + window.clearTimeout( searchTimer ); + searchTimer = window.setTimeout( function() { + wpLink.searchInternalLinks.call( self ); + }, 500 ); + }); }, open: function( editorId ) { @@ -283,7 +290,7 @@ var wpLink; return; wpLink.lastSearch = search; - waiting = $( '#river-waiting' ).show(); + waiting = t.parent().find('.spinner').show(); rivers.search.change( search ); rivers.search.ajax( function() { @@ -381,7 +388,7 @@ var wpLink; this.element = element; this.ul = element.children( 'ul' ); this.contentHeight = element.children( '#link-selector-height' ); - this.waiting = $( '#river-waiting' ); + this.waiting = element.find('.river-waiting'); this.change( search ); this.refresh();