diff options
Diffstat (limited to 'view/js/autocomplete.js')
-rw-r--r-- | view/js/autocomplete.js | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 5a616b6fc..08cf97173 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -5,7 +5,7 @@ */ function contact_search(term, callback, backend_url, type, extra_channels, spinelement) { if(spinelement) { - $(spinelement).spin('tiny'); + $(spinelement).show(); } // 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; @@ -14,7 +14,7 @@ function contact_search(term, callback, backend_url, type, extra_channels, spine var lterm = term.toLowerCase(); // Ignore case for(var 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); + $(spinelement).hide(); // 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}); @@ -47,7 +47,7 @@ function contact_search(term, callback, backend_url, type, extra_channels, spine var items = data.items.slice(0); items.unshift({taggable:false, text: term, replace: term}); callback(items); - $(spinelement).spin(false); + $(spinelement).hide(); }, }).fail(function () {callback([]); }); // Callback must be invoked even if something went wrong. } @@ -60,12 +60,20 @@ function contact_format(item) { var desc = ((item.label) ? item.nick + ' ' + item.label : item.nick); if(typeof desc === 'undefined') desc = ''; if(desc) desc = ' ('+desc+')'; - return "<div class='{0}' title='{4}'><img class='dropdown-menu-img-sm' src='{1}'><span class='contactname'>{2}</span><span class='dropdown-sub-text'>{3}</span><div class='clear'></div></div>".format(item.taggable, item.photo, item.name, desc, item.link); + return "<div class='{0} dropdown-item dropdown-notification clearfix' title='{4}'><img class='menu-img-2' src='{1}'><span class='contactname'>{2}</span><span class='dropdown-sub-text'>{3}</span></div>".format(item.taggable, item.photo, item.name, desc, item.link); } else return "<div>" + item.text + "</div>"; } +function smiley_format(item) { + return "<div class='dropdown-item'>" + item.icon + ' ' + item.text + "</div>"; +} + +function bbco_format(item) { + return "<div class='dropdown-item'>" + item + "</div>"; +} + function editor_replace(item) { if(typeof item.replace !== 'undefined') { return '$1$2' + item.replace; @@ -181,18 +189,29 @@ function string2bb(element) { index: 3, search: function(term, callback) { contact_search(term, callback, backend_url, 'c', extra_channels, spinelement=false); }, replace: editor_replace, - template: contact_format, + template: contact_format + }; + + // Autocomplete forums + forums = { + match: /(^|\s)(\!)([^ \n]+)$/, + index: 3, + search: function(term, callback) { contact_search(term, callback, backend_url, 'f', extra_channels, spinelement=false); }, + replace: editor_replace, + template: contact_format }; + smilies = { match: /(^|\s)(:[a-z_:]{2,})$/, index: 2, search: function(term, callback) { $.getJSON('/smilies/json').done(function(data) { callback($.map(data, function(entry) { return entry.text.indexOf(term) === 0 ? entry : null; })); }); }, - template: function(item) { return item.icon + item.text; }, + //template: function(item) { return item.icon + item.text; }, replace: function(item) { return "$1" + item.text + ' '; }, + template: smiley_format }; this.attr('autocomplete','off'); - this.textcomplete([contacts,smilies], {className:'acpopup', zIndex:1020}); + this.textcomplete([contacts,forums,smilies], {className:'acpopup', zIndex:1020}); }; })( jQuery ); @@ -321,7 +340,8 @@ function string2bb(element) { else { return '\[' + element + '\] '; } - } + }, + template: bbco_format }; this.attr('autocomplete','off'); |