aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/autocomplete.js
diff options
context:
space:
mode:
Diffstat (limited to 'view/js/autocomplete.js')
-rw-r--r--view/js/autocomplete.js43
1 files changed, 39 insertions, 4 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 01def9900..be632a07e 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -60,7 +60,7 @@ 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} 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);
+ 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, typeof(item.link) !== 'undefined' ? item.link : desc.replace('(','').replace(')',''));
}
else
return "<div>" + item.text + "</div>";
@@ -74,6 +74,10 @@ function bbco_format(item) {
return "<div class='dropdown-item'>" + item + "</div>";
}
+function tag_format(item) {
+ return "<div class='dropdown-item'>" + '#' + item.text + "</div>";
+}
+
function editor_replace(item) {
if(typeof item.replace !== 'undefined') {
return '$1$2' + item.replace;
@@ -194,7 +198,7 @@ function string2bb(element) {
// Autocomplete forums
forums = {
- match: /(^|\s)(\!)([^ \n]+)$/,
+ match: /(^|\s)(\!\!*)([^ \n]+)$/,
index: 3,
search: function(term, callback) { contact_search(term, callback, backend_url, 'f', extra_channels, spinelement=false); },
replace: editor_replace,
@@ -202,6 +206,17 @@ function string2bb(element) {
};
+ // Autocomplete hashtags
+ tags = {
+ match: /(^|\s)(\#)([^ \n]{2,})$/,
+ index: 3,
+ search: function(term, callback) { $.getJSON('/hashtags/' + '$f=&t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.toLowerCase().indexOf(term.toLowerCase()) === 0 ? entry : null; })); }); },
+ replace: function(item) { return "$1$2" + item.text + ' '; },
+ context: function(text) { return text.toLowerCase(); },
+ template: tag_format
+ };
+
+
smilies = {
match: /(^|\s)(:[a-z_:]{2,})$/,
index: 2,
@@ -211,7 +226,7 @@ function string2bb(element) {
template: smiley_format
};
this.attr('autocomplete','off');
- this.textcomplete([contacts,forums,smilies], {className:'acpopup', zIndex:1020});
+ this.textcomplete([contacts,forums,smilies,tags], {className:'acpopup', zIndex:1020});
};
})( jQuery );
@@ -228,8 +243,28 @@ function string2bb(element) {
replace: basic_replace,
template: contact_format,
};
+
+ // Autocomplete forums
+ forums = {
+ match: /(^\!)([^\n]{3,})$/,
+ index: 2,
+ search: function(term, callback) { contact_search(term, callback, backend_url, 'f', [], spinelement='#nav-search-spinner'); },
+ replace: basic_replace,
+ template: contact_format
+ };
+
+ // Autocomplete hashtags
+ tags = {
+ match: /(^\#)([^ \n]{3,})$/,
+ index: 2,
+ search: function(term, callback) { $.getJSON('/hashtags/' + '$f=&t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.toLowerCase().indexOf(term.toLowerCase()) === 0 ? entry : null; })); }); },
+ replace: function(item) { return "$1" + item.text + ' '; },
+ context: function(text) { return text.toLowerCase(); },
+ template: tag_format
+ };
+
this.attr('autocomplete', 'off');
- var a = this.textcomplete([contacts], {className:'acpopup', maxCount:100, zIndex: 1020, appendTo:'nav'});
+ var a = this.textcomplete([contacts,forums,tags], {className:'acpopup', maxCount:100, zIndex: 1020, appendTo:'nav'});
a.on('textComplete:select', function(e, value, strategy) { submit_form(this); });
};
})( jQuery );