aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/autocomplete.js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-26 18:27:03 -0800
committerfriendica <info@friendica.com>2015-01-26 18:27:03 -0800
commitac594183c6fdc6cf4d5a2a29ade7478a17336397 (patch)
treed38f73727da4d8697b00d2102ae10b501d1909ce /view/js/autocomplete.js
parente6bfe3f2c10e851ed5ba49886ec8d0a9a9de2296 (diff)
parent9f5bfca28dde23893156ad36682e20ca2fc0dd45 (diff)
downloadvolse-hubzilla-ac594183c6fdc6cf4d5a2a29ade7478a17336397.tar.gz
volse-hubzilla-ac594183c6fdc6cf4d5a2a29ade7478a17336397.tar.bz2
volse-hubzilla-ac594183c6fdc6cf4d5a2a29ade7478a17336397.zip
Merge branch 'master' into tres and add some work on the item_deleted flag refactor
Conflicts: include/attach.php include/onedirsync.php include/zot.php mod/locs.php
Diffstat (limited to 'view/js/autocomplete.js')
-rw-r--r--view/js/autocomplete.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 1c524789d..86847cb35 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -3,15 +3,18 @@
*
* require jQuery, jquery.textcomplete
*/
-function contact_search(term, callback, backend_url, type, extra_channels) {
+function contact_search(term, callback, backend_url, type, extra_channels, spinelement) {
+ if(spinelement){
+ $(spinelement).spin('tiny');
+ }
// Check if there is a cached result that contains the same information we would get with a full server-side search
-
var bt = backend_url+type;
if(!(bt in contact_search.cache)) contact_search.cache[bt] = {};
var lterm = term.toLowerCase(); // Ignore case
for(t in contact_search.cache[bt]) {
if(lterm.indexOf(t) >= 0) { // A more broad search has been performed already, so use those results
+ $(spinelement).spin(false);
// Filter old results locally
var matching = contact_search.cache[bt][t].filter(function (x) { return (x.name.toLowerCase().indexOf(lterm) >= 0 || (typeof x.nick !== 'undefined' && x.nick.toLowerCase().indexOf(lterm) >= 0)); }); // Need to check that nick exists because groups don't have one
matching.unshift({taggable:false, text: term, replace: term});
@@ -44,6 +47,7 @@ function contact_search(term, callback, backend_url, type, extra_channels) {
var items = data.items.slice(0);
items.unshift({taggable:false, text: term, replace: term});
callback(items);
+ $(spinelement).spin(false);
},
}).fail(function () {callback([]); }); // Callback must be invoked even if something went wrong.
}
@@ -98,7 +102,7 @@ function submit_form(e) {
contacts = {
match: /(^|\s)(@\!*)([^ \n]+)$/,
index: 3,
- search: function(term, callback) { contact_search(term, callback, backend_url, 'c', extra_channels); },
+ search: function(term, callback) { contact_search(term, callback, backend_url, 'c', extra_channels, spinelement=false); },
replace: editor_replace,
template: contact_format,
}
@@ -125,7 +129,7 @@ function submit_form(e) {
contacts = {
match: /(^@)([^\n]{2,})$/,
index: 2,
- search: function(term, callback) { contact_search(term, callback, backend_url, 'x',[]); },
+ search: function(term, callback) { contact_search(term, callback, backend_url, 'x', [], spinelement='#nav-search-spinner'); },
replace: basic_replace,
template: contact_format,
}
@@ -147,7 +151,7 @@ function submit_form(e) {
contacts = {
match: /(^)([^\n]+)$/,
index: 2,
- search: function(term, callback) { contact_search(term, callback, backend_url, typ,[]); },
+ search: function(term, callback) { contact_search(term, callback, backend_url, typ,[], spinelement=false); },
replace: basic_replace,
template: contact_format,
}