Add autosubmit feature to textcomplete based autocompleter
This commit is contained in:
parent
fcc9131fb9
commit
d7a3d9f606
@ -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); });
|
||||
};
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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?
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user