[ticket/10737] Adding delayed keyup and removing target_blank.

PHPBB3-10737
This commit is contained in:
Suhaib Khan 2014-03-10 19:06:42 +05:30 committed by Cesar G
parent 6ef4e4e790
commit a60d9a7f86
3 changed files with 39 additions and 28 deletions

View file

@ -513,8 +513,17 @@ phpbb.timezonePreselectSelect = function(forceSelector) {
}; };
// Listen live search box events // Listen live search box events
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
$('.live-search-input').keyup(function() { $('.live-search-input').keyup(function() {
var str = this.value; var str = this.value;
delay(function(){
if (str.length < 3) { if (str.length < 3) {
return; return;
} }
@ -536,14 +545,16 @@ $('.live-search-input').keyup(function() {
}); });
} }
}); });
}, 2000 );
}); });
$('.live-search-input').blur(function() { $(document).click(function(event) {
setTimeout(function () { var target = $( event.target );
if(!target.is("#livesearch, #livesearch *, .live-search-input")) {
var clone = $("#user-search-row-tpl").clone(); var clone = $("#user-search-row-tpl").clone();
$("#livesearch").html(""); $("#livesearch").html("");
clone.appendTo("#livesearch"); clone.appendTo("#livesearch");
}, 500); }
}); });
// Toggle notification list // Toggle notification list

View file

@ -12,7 +12,7 @@
<dd><input type="text" name="username" id="username" value="{USERNAME}" class="inputbox live-search-input" autocomplete="off" /> <dd><input type="text" name="username" id="username" value="{USERNAME}" class="inputbox live-search-input" autocomplete="off" />
<table class="table1 zebra-list" id="livesearch"> <table class="table1 zebra-list" id="livesearch">
<tr id="user-search-row-tpl" style="display: none;"> <tr id="user-search-row-tpl" style="display: none;">
<td><a class="user-search-link user-search-name" target="_blank"></a></td> <td><a class="user-search-link user-search-name" ></a></td>
</tr> </tr>
</table> </table>
</dd> </dd>

View file

@ -79,7 +79,7 @@
<input class="post live-search-input" type="text" name="username" value="{USERNAME}" autocomplete="off" /> <input class="post live-search-input" type="text" name="username" value="{USERNAME}" autocomplete="off" />
<table class="tablebg" id="livesearch"> <table class="tablebg" id="livesearch">
<tr id="user-search-row-tpl" style="display: none;"> <tr id="user-search-row-tpl" style="display: none;">
<td><a class="user-search-link user-search-name" target="_blank"></a></td> <td><a class="user-search-link user-search-name" ></a></td>
</tr> </tr>
</table> </table>
</td> </td>