]> git.mxchange.org Git - friendica.git/blobdiff - js/autocomplete.js
API: add docs to `api_item_get_user()`
[friendica.git] / js / autocomplete.js
index 8e64648e98686f2433093846898a27120601a980..d0c770cc4bcd313d237fa554732105c78e9e2d08 100644 (file)
@@ -41,7 +41,7 @@ function contact_search(term, callback, backend_url, type, mode) {
                postdata['conversation'] = conv_id[0];
 
        if(mode !== null)
-               postdata['mode'] = mode;
+               postdata['smode'] = mode;
 
 
        $.ajax({
@@ -104,6 +104,13 @@ function basic_replace(item) {
        return '$1'+item.name+' ';
 }
 
+function webbie_replace(item) {
+       if(typeof item.replace !== 'undefined')
+               return '$1'+item.replace;
+
+       return '$1'+item.nick+' ';
+}
+
 function trim_replace(item) {
        if(typeof item.replace !== 'undefined')
                return '$1'+item.replace;
@@ -163,6 +170,9 @@ function listNewLineAutocomplete(id) {
                setCaretPosition(text, caretPos + 5);
                return true;
        }
+       else {
+               return false;
+       }
 }
 
 function string2bb(element) {
@@ -213,7 +223,7 @@ function string2bb(element) {
                        match: /(^@)([^\n]{2,})$/,
                        index: 2,
                        search: function(term, callback) { contact_search(term, callback, backend_url, 'x', 'contact'); },
-                       replace: basic_replace,
+                       replace: webbie_replace,
                        template: contact_format,
                };
 
@@ -222,7 +232,7 @@ function string2bb(element) {
                        match: /(^!)([^\n]{2,})$/,
                        index: 2,
                        search: function(term, callback) { contact_search(term, callback, backend_url, 'x', 'community'); },
-                       replace: basic_replace,
+                       replace: webbie_replace,
                        template: contact_format,
                };
                this.attr('autocomplete', 'off');
@@ -325,11 +335,12 @@ function string2bb(element) {
                a.on('textComplete:select', function(e, value, strategy) { value; });
 
                a.keypress(function(e){
-                       e.stopImmediatePropagation();
                        if (e.keyCode == 13) {
                                var x = listNewLineAutocomplete(this.id);
-                               if(x)
+                               if(x) {
+                                       e.stopImmediatePropagation();
                                        e.preventDefault();
+                               }
                        }
                });
        };