aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorStefan Parviainen <saparvia@caterva.eu>2015-01-07 20:03:05 +0100
committerStefan Parviainen <saparvia@caterva.eu>2015-01-07 20:03:05 +0100
commit0cf016b0b049a32dd053e680f21237d039959252 (patch)
tree5b3a1c4e8a8a300446a4c53480245c4fc91405b3 /view/js
parent34ecbcceea9ae6399f50c6e8718a9f84345136b9 (diff)
downloadvolse-hubzilla-0cf016b0b049a32dd053e680f21237d039959252.tar.gz
volse-hubzilla-0cf016b0b049a32dd053e680f21237d039959252.tar.bz2
volse-hubzilla-0cf016b0b049a32dd053e680f21237d039959252.zip
Make mod_poke use textcomplete
Diffstat (limited to 'view/js')
-rw-r--r--view/js/autocomplete.js26
-rw-r--r--view/js/mod_poke.js13
2 files changed, 25 insertions, 14 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 1fad1903b..8966c675d 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -40,7 +40,7 @@ function editor_replace(item) {
}
function basic_replace(item) {
- return '$1$2'+item.nick;
+ return '$1'+item.name+' ';
}
/**
@@ -78,8 +78,8 @@ function basic_replace(item) {
// Autocomplete contacts
contacts = {
- match: /(^)(@)([^\n]+)$/,
- index: 3,
+ match: /(^@)([^\n]+)$/,
+ index: 2,
search: function(term, callback) { contact_search(term, callback, backend_url, 'x',[]); },
replace: basic_replace,
template: contact_format,
@@ -87,3 +87,23 @@ function basic_replace(item) {
this.textcomplete([contacts],{className:'acpopup'});
};
})( jQuery );
+
+(function( $ ){
+ $.fn.contact_autocomplete = function(backend_url, onselect) {
+
+ // Autocomplete contacts
+ contacts = {
+ match: /(^)([^\n]+)$/,
+ index: 2,
+ search: function(term, callback) { contact_search(term, callback, backend_url, '',[]); },
+ replace: basic_replace,
+ template: contact_format,
+ }
+
+ var a = this.textcomplete([contacts],{className:'acpopup'});
+
+ if(typeof onselect !== 'undefined')
+ a.on('textComplete:select',function(e,value,strategy) { onselect(value); });
+ };
+})( jQuery );
+
diff --git a/view/js/mod_poke.js b/view/js/mod_poke.js
index 78972888f..c5ca5399c 100644
--- a/view/js/mod_poke.js
+++ b/view/js/mod_poke.js
@@ -1,14 +1,5 @@
$(document).ready(function() {
- var a;
- a = $("#poke-recip").autocomplete({
- serviceUrl: baseurl + '/acl',
- minChars: 2,
- width: 250,
- id: 'poke-recip-ac',
- onSelect: function(value,data) {
- $("#poke-recip-complete").val(data);
- }
+ $("#poke-recip").contact_autocomplete(baseurl + '/acl', function(data) {
+ $("#poke-recip-complete").val(data.id);
});
- a.setOptions({ params: { type: 'a' }});
-
});