Skip to content

Commit

Permalink
refs #41429. Refactor event search tokenInput init
Browse files Browse the repository at this point in the history
  • Loading branch information
poliphilochu committed Oct 9, 2024
1 parent 9530902 commit 229d03c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions templates/CRM/Event/Form/Search/Common.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,27 @@ var eventUrl = "{/literal}{$dataURLEvent}{literal}";
{/if}
{literal}

if (!cj(".crm-accordion-wrapper #event_id ~ .token-input-list-facebook").length) {
cj(".crm-accordion-wrapper #event_id").tokenInput( eventUrl, { prePopulate: eventPrepopulate, classes: tokenClass, hintText: hintText });
}
cj(".crm-accordion-wrapper").on("crmaccordion:open", function() {
if (!cj(".crm-accordion-wrapper #event_id ~ .token-input-list-facebook").length) {
cj(".crm-accordion-wrapper #event_id").tokenInput( eventUrl, { prePopulate: eventPrepopulate, classes: tokenClass, hintText: hintText });
function tokeninputInit() {
var $eventId = cj('#event_id');
var $accordions = $eventId.parents('.crm-accordion-wrapper');
var isAllOpen = $accordions.length > 0 && $accordions.length === $accordions.filter('.crm-accordion-open').length;
if (isAllOpen && !$eventId.next('.token-input-list-facebook').length) {
$eventId.tokenInput(eventUrl, {prePopulate: eventPrepopulate, classes: tokenClass, hintText: hintText});
}
}

cj(document).ready(function() {
tokeninputInit();
cj(".crm-accordion-wrapper").on("crmaccordion:open", function() {
tokeninputInit();
});
});

cj(document).ajaxSuccess(function(event, jqxhr, settings) {
if (jqxhr.responseText.indexOf('id="event_id"') != -1 && !cj("#event_id ~ .token-input-list-facebook").length) {
cj("#event_id").tokenInput( eventUrl, { prePopulate: eventPrepopulate, classes: tokenClass, hintText: hintText });
if (jqxhr.responseText.indexOf('id="event_id"') != -1) {
tokeninputInit();
}
});

Expand Down

0 comments on commit 229d03c

Please sign in to comment.