PageSourceSearch

https://api.apic.org/Fonteva/js/Fonteva-updateFieldSets.js?v=09042025-00

js apic.org collected 2026-10-02 02:46:06 UTC 5,746 bytes, 125 lines download raw bytes

1/*** Function to add the info message ***/
2/*** Show info message on form load and on interaction for Preferred Email Type ***/
3function preferredEmailChangeMessage() {
4  const containerSel = '[data-name="OrderApi__Preferred_Email_Type__c-input"]';
5  const uniqueClass  = 'apic-email-note';
6  const msgHTML =
7    '<div class="info-message ' + uniqueClass + ' slds-form-element__help slds-m-top_xx-small" aria-live="polite">' +
8      '<strong>Please note:</strong> Changing your preferred email updates your account username and primary email used for password resets. ' +
9      'Your username updates immediately. For security, you will receive a verification email to confirm the new address. ' +
10      'The verification link expires in 72 hours.' +
11    '</div>';
12
13  function insertMessage($container) {
14    const $formEl = $container.closest('.slds-form-element');
15    if (!$formEl.length) return;
16
17    const $controlRow = $formEl.children('.slds-form-element__control.slds-m-bottom--small.slds-grid').first();
18
19    // Insert only once
20    if ($formEl.find('> .' + uniqueClass).length === 0) {
21      if ($controlRow.length) {
22        $controlRow.after(msgHTML);
23      } else {
24        $formEl.append(msgHTML);
25      }
26    }
27  }
28
29  // Try immediate insert if field is already present
30  const $present = $(containerSel).first();
31  if ($present.length) insertMessage($present);
32
33  // Light retry in case the field paints a moment later
34  if (!document.body.dataset.apicPrefEmailPrimed) {
35    let tries = 8; // ~1.2s total
36    (function prime() {
37      const $c = $(containerSel).first();
38      if ($c.length) insertMessage($c);
39      if (--tries > 0 && $c.length === 0) setTimeout(prime, 150);
40    })();
41    document.body.dataset.apicPrefEmailPrimed = 'true';
42  }
43
44  // Delegate interactions to ensure message shows even if user reaches the field first
45  if (!document.body.dataset.apicPrefEmailBound) {
46    $(document).on(
47      'focusin.apicPrefEmail mousedown.apicPrefEmail touchstart.apicPrefEmail change.apicPrefEmail click.apicPrefEmail keydown.apicPrefEmail',
48      function (e) {
49        const $container = $(e.target).closest(containerSel);
50        if ($container.length) insertMessage($container);
51      }
52    );
53    document.body.dataset.apicPrefEmailBound = 'true';
54  }
55}
56
57
58/*** Function to add the name warning, disable fields, and unlock on confirmation ***/
59function nameChangeWarningMessage() {
60  const firstSel = '[data-name="FirstName-input"] input.slds-input[type="text"]';
61  const lastSel  = '[data-name="LastName-input"] input.slds-input[type="text"]';
62  const lastContainerSel = '[data-name="LastName-input"]';
63  const msgSel = '.info-message.apic-name-lock';
64
65  const beforeMsgHTML =
66    '<div class="info-message apic-name-lock slds-form-element__help slds-text-color_error slds-m-top_xx-small" aria-live="polite">' +
67      '<strong>Important:</strong> For security reasons, your first and last name cannot be updated directly. ' +
68      'Names should only be changed in the case of a legal name change (for example, marriage or court order). ' +
69      'APIC does not allow transferring accounts from one person to another, as this creates technical and security issues. ' +
70      '<a href="#" class="apic-name-confirm slds-text-link">Confirm my name has legally changed</a>' +
71    '</div>';
72
73  const afterMsgHTML =
74    '<div class="info-message apic-name-lock slds-form-element__help slds-text-color_success slds-m-top_xx-small" aria-live="polite">' +
75      '<strong>Name fields unlocked.</strong> You may now update your name. ' +
76      'Please remember that APIC accounts are for individual use only and cannot be transferred to another person. ' +
77      'If this change is not related to a legal name change, please cancel or contact APIC Member Services for assistance.' +
78    '</div>';
79
80  // Anchor: the control row under Last Name
81  const $lastControlRow = $(lastContainerSel)
82    .closest('.slds-form-element')
83    .find('> .slds-form-element__control.slds-m-bottom--small.slds-grid')
84    .first();
85  if ($lastControlRow.length === 0) return;
86
87  // Insert BEFORE message once
88  if ($lastControlRow.next(msgSel).length === 0) {
89    $lastControlRow.after(beforeMsgHTML);
90  }
91
92  // Disable both fields once
93  const $firstNow = $(firstSel).first();
94  const $lastNow  = $(lastSel).first();
95  if ($lastNow.length && !$lastNow.data('apic-name-locked')) {
96    if ($firstNow.length) $firstNow.prop('disabled', true).attr('aria-disabled', 'true');
97    $lastNow.prop('disabled', true).attr('aria-disabled', 'true');
98    $lastNow.data('apic-name-locked', true);
99  }
100
101  // Bind click handler once;
101 re-query inputs globally on click
102  if (!document.body.dataset.apicNameConfirmBound) {
103    $(document).on('click.apicNameConfirm', '.apic-name-confirm', function (e) {
104      e.preventDefault();
105
106      const $first = $(firstSel).first(); // global lookup
107      const $last  = $(lastSel).first();  // global lookup
108
109      if ($first.length) $first.prop('disabled', false).removeAttr('aria-disabled');
110      if ($last.length)  $last.prop('disabled',  false).removeAttr('aria-disabled');
111
112      // Swap message to AFTER state next to Last Name
113      const $msgAnchor = $(lastContainerSel)
114        .closest('.slds-form-element')
115        .find('> .slds-form-element__control.slds-m-bottom--small.slds-grid')
116        .first()
117        .next(msgSel);
118      if ($msgAnchor.length) $msgAnchor.replaceWith(afterMsgHTML);
119
120      // Focus First, fallback to Last
121      if ($first.length) { $first.focus(); } else if ($last.length) { $last.focus(); }
122    });
123    document.body.dataset.apicNameConfirmBound = 'true';
124  }
125}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.