aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/autocomplete.js
diff options
context:
space:
mode:
authorStefan Parviainen <saparvia@caterva.eu>2015-01-07 19:39:50 +0100
committerStefan Parviainen <saparvia@caterva.eu>2015-01-07 19:39:50 +0100
commit34ecbcceea9ae6399f50c6e8718a9f84345136b9 (patch)
tree7feb27f38da9964cb836f7f604cb1dea05fb5aad /view/js/autocomplete.js
parent4e3aadc38a671ebd37d3619ea64f278f5a06f6dc (diff)
downloadvolse-hubzilla-34ecbcceea9ae6399f50c6e8718a9f84345136b9.tar.gz
volse-hubzilla-34ecbcceea9ae6399f50c6e8718a9f84345136b9.tar.bz2
volse-hubzilla-34ecbcceea9ae6399f50c6e8718a9f84345136b9.zip
Make nav search use textcomplete
Diffstat (limited to 'view/js/autocomplete.js')
-rw-r--r--view/js/autocomplete.js30
1 files changed, 26 insertions, 4 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 1fa20cc3b..1fad1903b 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -3,15 +3,15 @@
*
* require jQuery, jquery.textcomplete
*/
-function contact_search(term, callback, backend_url, extra_channels) {
+function contact_search(term, callback, backend_url, type, extra_channels) {
var postdata = {
start:0,
count:100,
search:term,
- type:'c',
+ type:type,
}
- if(extra_channels)
+ if(typeof extra_channels !== 'undefined' && extra_channels)
postdata['extra_channels[]'] = extra_channels;
$.ajax({
@@ -39,6 +39,10 @@ function editor_replace(item) {
return '$1$2'+item.nick.replace(' ','') + '+' + id;
}
+function basic_replace(item) {
+ return '$1$2'+item.nick;
+}
+
/**
* jQuery plugin 'editor_autocomplete'
*/
@@ -50,7 +54,7 @@ function editor_replace(item) {
contacts = {
match: /(^|\s)(@\!*)([^ \n]+)$/,
index: 3,
- search: function(term, callback) { contact_search(term, callback, backend_url, extra_channels); },
+ search: function(term, callback) { contact_search(term, callback, backend_url, 'c', extra_channels); },
replace: editor_replace,
template: contact_format,
}
@@ -65,3 +69,21 @@ function editor_replace(item) {
this.textcomplete([contacts,smilies],{className:'acpopup'});
};
})( jQuery );
+
+/**
+ * jQuery plugin 'search_autocomplete'
+ */
+(function( $ ){
+ $.fn.search_autocomplete = function(backend_url) {
+
+ // Autocomplete contacts
+ contacts = {
+ match: /(^)(@)([^\n]+)$/,
+ index: 3,
+ search: function(term, callback) { contact_search(term, callback, backend_url, 'x',[]); },
+ replace: basic_replace,
+ template: contact_format,
+ }
+ this.textcomplete([contacts],{className:'acpopup'});
+ };
+})( jQuery );