show the spinner sooner after searching, lint compliance

pull/1/head
ansuz 4 years ago
parent f3f1fd1c81
commit c3a9503809

@ -3228,6 +3228,8 @@ define([
$searchIcon.clone().appendTo($div); $searchIcon.clone().appendTo($div);
var $spinnerContainer = $(h('div.cp-app-drive-search-spinner'));
var spinner = UI.makeSpinner($spinnerContainer);
var $input = APP.Search.$input = $('<input>', { var $input = APP.Search.$input = $('<input>', {
id: 'cp-app-drive-search-input', id: 'cp-app-drive-search-input',
placeholder: Messages.fm_searchName, placeholder: Messages.fm_searchName,
@ -3235,12 +3237,17 @@ define([
draggable: false, draggable: false,
tabindex: 1, tabindex: 1,
}).keyup(function (e) { }).keyup(function (e) {
var lastValue = search.value;
search.value = $input.val().trim();
if (lastValue === search.value) { return; }
if (search.to) { window.clearTimeout(search.to); } if (search.to) { window.clearTimeout(search.to); }
if ($input.val().trim() === "") { if (search.value === "") {
search.cursor = 0; search.cursor = 0;
APP.displayDirectory([SEARCH]); APP.displayDirectory([SEARCH]);
return; return;
} }
spinner.spin();
if (e.which === 13) { if (e.which === 13) {
var newLocation = [SEARCH, $input.val()]; var newLocation = [SEARCH, $input.val()];
search.cursor = $input[0].selectionStart; search.cursor = $input[0].selectionStart;
@ -3285,14 +3292,12 @@ define([
$div.append(cancel); $div.append(cancel);
$list.append($div); $list.append($div);
$spinnerContainer.appendTo($list);
setTimeout(function () { setTimeout(function () {
$input.focus(); $input.focus();
}); });
var $spinnerContainer = $(h('div.cp-app-drive-search-spinner')).appendTo($list); if (typeof(value) === "string" && value.trim()) {
var spinner = UI.makeSpinner($spinnerContainer);
if (typeof(value) == "string" && value.trim()) {
spinner.spin(); spinner.spin();
} else { } else {
return; return;

Loading…
Cancel
Save