From b0cf16ace44b8ffa302870d248c31a5342b0e938 Mon Sep 17 00:00:00 2001 From: Nicolas B Date: Tue, 30 Jul 2019 23:10:07 +0200 Subject: [PATCH] Add files via upload Fixes a regression of plugin contact-group-excel-paste since an update of rainloop that modified CSS classes and JavaScript of autocomplete fields --- .../js/excel_contact_group.js | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/plugins/contact-group-excel-paste/js/excel_contact_group.js b/plugins/contact-group-excel-paste/js/excel_contact_group.js index e29a9f293b..c8f3209f1f 100644 --- a/plugins/contact-group-excel-paste/js/excel_contact_group.js +++ b/plugins/contact-group-excel-paste/js/excel_contact_group.js @@ -1,20 +1,29 @@ (function(window, $) { $(function() { - $(window.document).on('paste', '.RL-PopupsContacts .contactValueInput', function() { - // trigger the process on click and paste - var $this = $(this); - + function replaceGroup() { + $('li[data-inputosaurus][title*=","]').each(function (index, elem) { + var $elem = $(elem) + var title = $(elem).attr('title') + var cut = title.indexOf('<') + title = title.substr(cut + 1, title.length - cut - 2) + $elem.parents('ul').find('.ui-autocomplete-input').val(title) + $('.ui-autocomplete-input').trigger('blur') + }) setTimeout(function () { - $this.trigger('keyup'); - }); - }).on('keyup', '.RL-PopupsContacts .contactValueInput', function() { - var $this = $(this), - value = $this.val(), - match = value && value.match(/@/ig); + $('li[data-inputosaurus][title*=","]').find('a').trigger('click') + }) + } + + $('body').on('click', '.ui-autocomplete a', function () { + replaceGroup() + }) - if (match && match.length > 1) { - $this.val($this.val().replace(/\n| /ig, ',')); - } - }); - }); -}(window, $)); + $(document).on('keydown', function (e) { + if (e.which === 13) { + setTimeout(function () { + replaceGroup() + }) + } + }) + }) +}(window, $))