From a373b9f1d4d0ee6781927c3fcf05e0e301a80b6e Mon Sep 17 00:00:00 2001 From: marijus Date: Wed, 7 Jan 2015 13:04:50 +0100 Subject: also style the collapse link --- view/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/js/main.js b/view/js/main.js index 974f5f971..4d55c5d31 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -604,7 +604,7 @@ function updateConvItems(mode,data) { $(this).readmore({ collapsedHeight: divmore_height, moreLink: ''+aStr['divgrowmore']+'', - lessLink: ''+aStr['divgrowless']+'' + lessLink: ''+aStr['divgrowless']+'' }); $(this).addClass('divmore'); } -- cgit v1.2.3 From e3d064ff22a69766226766557ff2a5b094c74e27 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 18:42:57 +0100 Subject: Allow textcomplete to work on inputs (PR also filed upstream) --- library/jquery-textcomplete/jquery.textcomplete.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/jquery-textcomplete/jquery.textcomplete.js b/library/jquery-textcomplete/jquery.textcomplete.js index 1e61683ea..c8303eaa0 100644 --- a/library/jquery-textcomplete/jquery.textcomplete.js +++ b/library/jquery-textcomplete/jquery.textcomplete.js @@ -124,8 +124,9 @@ if (typeof jQuery === 'undefined') { this.views = []; this.option = $.extend({}, Completer._getDefaults(), option); - if (!this.$el.is('textarea') && !element.isContentEditable && element.contentEditable != 'true') { - throw new Error('textcomplete must be called on a Textarea or a ContentEditable.'); + + if (!this.$el.is('input[type=text]') && !this.$el.is('textarea') && !element.isContentEditable && element.contentEditable != 'true') { + throw new Error('textcomplete must be called on a input[type=text], Textarea or a ContentEditable.'); } if (element === document.activeElement) { @@ -171,7 +172,7 @@ if (typeof jQuery === 'undefined') { if (this.option.adapter) { Adapter = this.option.adapter; } else { - if (this.$el.is('textarea')) { + if (this.$el.is('textarea') || this.$el.is('input[type=text]')) { viewName = typeof element.selectionEnd === 'number' ? 'Textarea' : 'IETextarea'; } else { viewName = 'ContentEditable'; -- cgit v1.2.3 From 4e3aadc38a671ebd37d3619ea64f278f5a06f6dc Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 18:57:16 +0100 Subject: Rename some stuff related to autocomplete --- view/js/autocomplete.js | 16 ++++++++-------- view/js/main.js | 2 +- view/tpl/display-head.tpl | 4 ++-- view/tpl/jot-header.tpl | 4 ++-- view/tpl/msg-header.tpl | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index e68356057..1fa20cc3b 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -3,7 +3,7 @@ * * require jQuery, jquery.textcomplete */ -function mysearch(term, callback, backend_url, extra_channels) { +function contact_search(term, callback, backend_url, extra_channels) { var postdata = { start:0, count:100, @@ -25,11 +25,11 @@ function mysearch(term, callback, backend_url, extra_channels) { }).fail(function () {callback([]); }); // Callback must be invoked even if something went wrong. } -function format(item) { +function contact_format(item) { return "
{2} ({3})
".format(item.taggable, item.photo, item.name, ((item.label) ? item.nick + ' ' + item.label : item.nick), item.link ) } -function replace(item) { +function editor_replace(item) { // $2 ensures that prefix (@,@!) is preserved var id = item.id; // 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way. @@ -40,19 +40,19 @@ function replace(item) { } /** - * jQuery plugin 'contact_autocomplete' + * jQuery plugin 'editor_autocomplete' */ (function( $ ){ - $.fn.contact_autocomplete = function(backend_url, extra_channels) { + $.fn.editor_autocomplete = function(backend_url, extra_channels) { if (typeof extra_channels === 'undefined') extra_channels = false; // Autocomplete contacts contacts = { match: /(^|\s)(@\!*)([^ \n]+)$/, index: 3, - search: function(term, callback) { mysearch(term, callback, backend_url, extra_channels); }, - replace: replace, - template: format, + search: function(term, callback) { contact_search(term, callback, backend_url, extra_channels); }, + replace: editor_replace, + template: contact_format, } smilies = { diff --git a/view/js/main.js b/view/js/main.js index 85aea9875..5e3fb2bff 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -574,7 +574,7 @@ function updateConvItems(mode,data) { } /* autocomplete @nicknames */ - $(".comment-edit-form textarea").contact_autocomplete(baseurl+"/acl?f=&n=1"); + $(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1"); var bimgs = $(".wall-item-body img").not(function() { return this.complete; }); var bimgcount = bimgs.length; diff --git a/view/tpl/display-head.tpl b/view/tpl/display-head.tpl index 007d33fe8..913784d98 100755 --- a/view/tpl/display-head.tpl +++ b/view/tpl/display-head.tpl @@ -1,8 +1,8 @@ diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 8d26fc653..678d16a71 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -11,9 +11,9 @@ function initEditor(cb){ $("#profile-jot-text-loading").spin(false).hide(); $("#profile-jot-text").css({ 'height': 200, 'color': '#000' }); if(typeof channelId === 'undefined') - $("#profile-jot-text").contact_autocomplete(baseurl+"/acl"); + $("#profile-jot-text").editor_autocomplete(baseurl+"/acl"); else - $("#profile-jot-text").contact_autocomplete(baseurl+"/acl",[channelId]); // Also gives suggestions from current channel's connections + $("#profile-jot-text").editor_autocomplete(baseurl+"/acl",[channelId]); // Also gives suggestions from current channel's connections editor = true; $("a#jot-perms-icon").colorbox({ 'inline' : true, diff --git a/view/tpl/msg-header.tpl b/view/tpl/msg-header.tpl index 85fa51b0a..e1d1c6d23 100755 --- a/view/tpl/msg-header.tpl +++ b/view/tpl/msg-header.tpl @@ -41,7 +41,7 @@ if(plaintext != 'none') { }); } else - $("#prvmail-text").contact_autocomplete(baseurl+"/acl"); + $("#prvmail-text").editor_autocomplete(baseurl+"/acl"); -- cgit v1.2.3 From 34ecbcceea9ae6399f50c6e8718a9f84345136b9 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 19:39:50 +0100 Subject: Make nav search use textcomplete --- include/nav.php | 10 +--------- mod/acl.php | 28 ++++++++++++++-------------- view/js/autocomplete.js | 30 ++++++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/include/nav.php b/include/nav.php index a9bff4b29..a567f83c5 100644 --- a/include/nav.php +++ b/include/nav.php @@ -15,15 +15,7 @@ function nav(&$a) { $a->page['htmlhead'] .= <<< EOT diff --git a/mod/acl.php b/mod/acl.php index e6733351b..d263569ce 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -182,25 +182,25 @@ function acl_init(&$a){ ); } elseif($type == 'x') { - $r = navbar_complete($a); - $x = array(); - $x['query'] = $search; - $x['photos'] = array(); - $x['links'] = array(); - $x['suggestions'] = array(); - $x['data'] = array(); + $contacts = array(); if($r) { foreach($r as $g) { - $x['photos'][] = $g['photo']; - $x['links'][] = $g['url']; - $x['suggestions'][] = '@' . $g['name']; - $x['data'][] = $g['name']; + $contacts[] = array( + "photo" => $g['photo'], + "name" => $g['name'], + "nick" => $g['address'], + ); } } - echo json_encode($x); - killme(); + $o = array( + 'start' => $start, + 'count' => $count, + 'items' => $contacts, + ); + echo json_encode($o); + killme(); } else $r = array(); @@ -284,7 +284,7 @@ function navbar_complete(&$a) { } $dirmode = intval(get_config('system','directory_mode')); - $search = ((x($_REQUEST,'query')) ? htmlentities($_REQUEST['query'],ENT_COMPAT,'UTF-8',false) : ''); + $search = ((x($_REQUEST,'search')) ? htmlentities($_REQUEST['search'],ENT_COMPAT,'UTF-8',false) : ''); if(! $search || mb_strlen($search) < 2) return array(); 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 ); -- cgit v1.2.3 From 0cf016b0b049a32dd053e680f21237d039959252 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 20:03:05 +0100 Subject: Make mod_poke use textcomplete --- view/js/autocomplete.js | 26 +++++++++++++++++++++++--- view/js/mod_poke.js | 13 ++----------- 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' }}); - }); -- cgit v1.2.3 From e025fd9de218b49f15cc710c7a3a6bbad29fc42c Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 20:06:06 +0100 Subject: Make mail use textcomplete --- view/js/mod_mail.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/view/js/mod_mail.js b/view/js/mod_mail.js index 82f60f46f..9c4597866 100644 --- a/view/js/mod_mail.js +++ b/view/js/mod_mail.js @@ -1,13 +1,6 @@ $(document).ready(function() { - var a; - a = $("#recip").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'recip-ac', - onSelect: function(value,data) { - $("#recip-complete").val(data); - }, + $("#recip").contact_autocomplete(baseurl + '/acl', function(data) { + $("#recip-complete").val(data.xid); }); }); -- cgit v1.2.3 From f157122c351bdff3cf23520d791925f0f6463f3c Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 20:25:29 +0100 Subject: Make searchbox use textcomplete --- view/js/mod_network.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/view/js/mod_network.js b/view/js/mod_network.js index 8f1e5132d..1b7ccdc0a 100644 --- a/view/js/mod_network.js +++ b/view/js/mod_network.js @@ -1,10 +1,5 @@ $(document).ready(function() { - var a; - a = $("#search-text").autocomplete({ - serviceUrl: baseurl + '/search_ac', - minChars: 2, - id: 'search-text-ac', - }); + $("#search-text").contact_autocomplete(baseurl + '/acl'); $('.jslider-scale ins').addClass('hidden-xs'); }); -- cgit v1.2.3 From 9f8ce331f3661463573dac9d1bd0bf68eb15a322 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 20:29:38 +0100 Subject: Disable browser-based autocomplete when using the textcomplete based one --- view/js/autocomplete.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 8966c675d..66d8cf90c 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -66,6 +66,7 @@ function basic_replace(item) { template: function(item) { return item['icon'] + item['text'] }, replace: function(item) { return "$1"+item['text'] + ' '; }, } + this.attr('autocomplete','off'); this.textcomplete([contacts,smilies],{className:'acpopup'}); }; })( jQuery ); @@ -84,6 +85,7 @@ function basic_replace(item) { replace: basic_replace, template: contact_format, } + this.attr('autocomplete','off'); this.textcomplete([contacts],{className:'acpopup'}); }; })( jQuery ); @@ -100,6 +102,7 @@ function basic_replace(item) { template: contact_format, } + this.attr('autocomplete','off'); var a = this.textcomplete([contacts],{className:'acpopup'}); if(typeof onselect !== 'undefined') -- cgit v1.2.3 From c9b15bbab530264c4d5e1a648fc62153843b0618 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 20:38:56 +0100 Subject: Allow passing autocomplete type to contact_autocomplete --- view/js/autocomplete.js | 6 ++++-- view/js/mod_mail.js | 2 +- view/js/mod_poke.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 66d8cf90c..26d3f6211 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -91,13 +91,15 @@ function basic_replace(item) { })( jQuery ); (function( $ ){ - $.fn.contact_autocomplete = function(backend_url, onselect) { + $.fn.contact_autocomplete = function(backend_url, typ, onselect) { + + if(typeof typ === 'undefined') typ = ''; // Autocomplete contacts contacts = { match: /(^)([^\n]+)$/, index: 2, - search: function(term, callback) { contact_search(term, callback, backend_url, '',[]); }, + search: function(term, callback) { contact_search(term, callback, backend_url, typ,[]); }, replace: basic_replace, template: contact_format, } diff --git a/view/js/mod_mail.js b/view/js/mod_mail.js index 9c4597866..2cbc924f4 100644 --- a/view/js/mod_mail.js +++ b/view/js/mod_mail.js @@ -1,5 +1,5 @@ $(document).ready(function() { - $("#recip").contact_autocomplete(baseurl + '/acl', function(data) { + $("#recip").contact_autocomplete(baseurl + '/acl', '', function(data) { $("#recip-complete").val(data.xid); }); diff --git a/view/js/mod_poke.js b/view/js/mod_poke.js index c5ca5399c..3c07fcef7 100644 --- a/view/js/mod_poke.js +++ b/view/js/mod_poke.js @@ -1,5 +1,5 @@ $(document).ready(function() { - $("#poke-recip").contact_autocomplete(baseurl + '/acl', function(data) { + $("#poke-recip").contact_autocomplete(baseurl + '/acl', 'a', function(data) { $("#poke-recip-complete").val(data.id); }); }); -- cgit v1.2.3 From f2e648308c9f949899991275b77a49d9743aa14b Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 20:45:00 +0100 Subject: Return results from acl.php in standard form --- mod/acl.php | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/mod/acl.php b/mod/acl.php index d263569ce..f575db55b 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -205,26 +205,6 @@ function acl_init(&$a){ else $r = array(); - - if($type == 'm' || $type == 'a' || $type == 'p') { - $x = array(); - $x['query'] = $search; - $x['photos'] = array(); - $x['links'] = array(); - $x['suggestions'] = array(); - $x['data'] = array(); - if(count($r)) { - foreach($r as $g) { - $x['photos'][] = $g['micro']; - $x['links'][] = $g['url']; - $x['suggestions'][] = $g['name']; - $x['data'][] = (($type === 'p') ? '@' . str_replace(' ','_',$g['name']) : $g['id']); - } - } - echo json_encode($x); - killme(); - } - if(count($r)) { foreach($r as $g){ -- cgit v1.2.3 From 8e4d66dd7b232f487e11fab249ca30336cbb3a6f Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 20:57:10 +0100 Subject: Make mod_connections search use textcomplete --- view/js/mod_connections.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js index 8a8f2fee6..6393630b3 100644 --- a/view/js/mod_connections.js +++ b/view/js/mod_connections.js @@ -1,13 +1,5 @@ $(document).ready(function() { - var a; - a = $("#contacts-search").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'contact-search-ac', - }); - a.setOptions({ autoSubmit: true, params: { type: 'a' }}); - + $("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a'); }); $("#contacts-search").keyup(function(event){ -- cgit v1.2.3 From b098d5d901d529b48461811c414c6043c991e92a Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 20:57:30 +0100 Subject: Make photos tag autocomplete use textcomplete --- view/js/mod_photos.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/view/js/mod_photos.js b/view/js/mod_photos.js index 0a64f8102..676f5e8ef 100644 --- a/view/js/mod_photos.js +++ b/view/js/mod_photos.js @@ -2,19 +2,11 @@ var ispublic = aStr['everybody']; $(document).ready(function() { - - var a; - a = $("#photo-edit-newtag").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'newtag-ac', - onSelect: function(value,data) { - $("#photo-edit-newtag").val(data); - }, - }); - a.setOptions({ params: { type: 'p' }}); - + $(document).ready(function() { + $("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'p', function(data) { + $("#photo-edit-newtag").val('@' + data.name.replace(' ','_'); // Is the underscore replacement still needed? + }); + }); $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() { var selstr; -- cgit v1.2.3 From fcc9131fb9b1a0c115823c42a0828ce25670b215 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 21:01:36 +0100 Subject: Make mod_sources autocomplete use textcomplete --- view/js/mod_sources.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/view/js/mod_sources.js b/view/js/mod_sources.js index 49880b38f..add8ac15e 100644 --- a/view/js/mod_sources.js +++ b/view/js/mod_sources.js @@ -1,15 +1,7 @@ $(document).ready(function() { - var a; - a = $("#id_name").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'id-name-ac', - onSelect: function(value,data) { - $("#id_abook").val(data); - } - }); - - a.setOptions({ params: { type: 'a' }}); - + $(document).ready(function() { + $("#id_name").contact_autocomplete(baseurl + '/acl', 'a', function(data) { + $("#id_abook").val(data.id); + }); + }); }); -- cgit v1.2.3 From d7a3d9f60654a721cb00d78dd653fd56e4e9fb53 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 21:32:17 +0100 Subject: Add autosubmit feature to textcomplete based autocompleter --- view/js/autocomplete.js | 15 +++++++++++++-- view/js/mod_connections.js | 2 +- view/js/mod_mail.js | 2 +- view/js/mod_photos.js | 2 +- view/js/mod_poke.js | 2 +- view/js/mod_sources.js | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 26d3f6211..afdf9c230 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -43,6 +43,10 @@ function basic_replace(item) { return '$1'+item.name+' '; } +function submit_form(e) { + $(e).parents('form').submit(); +} + /** * jQuery plugin 'editor_autocomplete' */ @@ -86,14 +90,18 @@ function basic_replace(item) { template: contact_format, } this.attr('autocomplete','off'); - this.textcomplete([contacts],{className:'acpopup'}); + var a = this.textcomplete([contacts],{className:'acpopup'}); + + a.on('textComplete:select', function(e,value,strategy) { submit_form(this); }); + }; })( jQuery ); (function( $ ){ - $.fn.contact_autocomplete = function(backend_url, typ, onselect) { + $.fn.contact_autocomplete = function(backend_url, typ, autosubmit, onselect) { if(typeof typ === 'undefined') typ = ''; + if(typeof autosubmit === 'undefined') autosubmit = false; // Autocomplete contacts contacts = { @@ -107,6 +115,9 @@ function basic_replace(item) { this.attr('autocomplete','off'); var a = this.textcomplete([contacts],{className:'acpopup'}); + if(autosubmit) + a.on('textComplete:select', function(e,value,strategy) { submit_form(this); }); + if(typeof onselect !== 'undefined') a.on('textComplete:select',function(e,value,strategy) { onselect(value); }); }; diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js index 6393630b3..f29d96729 100644 --- a/view/js/mod_connections.js +++ b/view/js/mod_connections.js @@ -1,5 +1,5 @@ $(document).ready(function() { - $("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a'); + $("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true); }); $("#contacts-search").keyup(function(event){ diff --git a/view/js/mod_mail.js b/view/js/mod_mail.js index 2cbc924f4..16e06e6f5 100644 --- a/view/js/mod_mail.js +++ b/view/js/mod_mail.js @@ -1,5 +1,5 @@ $(document).ready(function() { - $("#recip").contact_autocomplete(baseurl + '/acl', '', function(data) { + $("#recip").contact_autocomplete(baseurl + '/acl', '', false, function(data) { $("#recip-complete").val(data.xid); }); diff --git a/view/js/mod_photos.js b/view/js/mod_photos.js index 676f5e8ef..5f19e5f7f 100644 --- a/view/js/mod_photos.js +++ b/view/js/mod_photos.js @@ -3,7 +3,7 @@ var ispublic = aStr['everybody']; $(document).ready(function() { $(document).ready(function() { - $("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'p', function(data) { + $("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'p', false, function(data) { $("#photo-edit-newtag").val('@' + data.name.replace(' ','_'); // Is the underscore replacement still needed? }); }); diff --git a/view/js/mod_poke.js b/view/js/mod_poke.js index 3c07fcef7..58e50588f 100644 --- a/view/js/mod_poke.js +++ b/view/js/mod_poke.js @@ -1,5 +1,5 @@ $(document).ready(function() { - $("#poke-recip").contact_autocomplete(baseurl + '/acl', 'a', function(data) { + $("#poke-recip").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) { $("#poke-recip-complete").val(data.id); }); }); diff --git a/view/js/mod_sources.js b/view/js/mod_sources.js index add8ac15e..1bbf89765 100644 --- a/view/js/mod_sources.js +++ b/view/js/mod_sources.js @@ -1,6 +1,6 @@ $(document).ready(function() { $(document).ready(function() { - $("#id_name").contact_autocomplete(baseurl + '/acl', 'a', function(data) { + $("#id_name").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) { $("#id_abook").val(data.id); }); }); -- cgit v1.2.3 From 885bcb4b2a811c2f18d96b440f9fdc0e223307a0 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 21:33:22 +0100 Subject: Remove out-of-date mod_message.js --- view/js/mod_message.js | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 view/js/mod_message.js diff --git a/view/js/mod_message.js b/view/js/mod_message.js deleted file mode 100644 index 82f60f46f..000000000 --- a/view/js/mod_message.js +++ /dev/null @@ -1,13 +0,0 @@ -$(document).ready(function() { - var a; - a = $("#recip").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'recip-ac', - onSelect: function(value,data) { - $("#recip-complete").val(data); - }, - }); - -}); -- cgit v1.2.3 From f3cd29f829ab66fe1f9fac306dcc6fa20858ad52 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Wed, 7 Jan 2015 21:38:12 +0100 Subject: Typo + comment --- view/js/mod_photos.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/js/mod_photos.js b/view/js/mod_photos.js index 5f19e5f7f..4c724c5e1 100644 --- a/view/js/mod_photos.js +++ b/view/js/mod_photos.js @@ -4,7 +4,7 @@ var ispublic = aStr['everybody']; $(document).ready(function() { $(document).ready(function() { $("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'p', false, function(data) { - $("#photo-edit-newtag").val('@' + data.name.replace(' ','_'); // Is the underscore replacement still needed? + $("#photo-edit-newtag").val('@' + data.name.replace(' ','_')); // TODO: Get rid of underscore }); }); -- cgit v1.2.3