1(function (document) { 2 "use strict"; 3 4 // Wait for jQuery to be available 5 function init() { 6 var $ = Granite.$; 7 if (typeof $ === 'undefined' || typeof $.fn === 'undefined') { 8 setTimeout(init, 100); 9 return; 10 } 11 12 $(document).on("foundation-contentloaded", function (e) { 13 Coral.commons.ready(function () { 14 showHideHandler($(".cq-dialog-dropdown-showhide", e.target)); 15 }); 16 }); 17 18 // Handle create wizard events and page property tab changes 19 $(document).on("coral-overlay:open foundation-wizard-stepchange coral-tabview:change", function () { 20 setTimeout(function() { 21 Coral.commons.ready(function () { 22 showHideHandler($(".cq-dialog-dropdown-showhide")); 23 }); 24 }, 300); 25 }); 26 27 // Handle dropdown changes 28 $(document).on("change coral-select:change", ".cq-dialog-dropdown-showhide", function () { 29 showHideHandler($(this)); 30 }); 31 32 function showHideHandler(el) { 33 el.each(function () { 34 var element = this; 35 if ($(element).is("coral-select")) { 36 Coral.commons.ready(element, function (component) { 37 multiSelectShowHide(element); 38 component.off("change.showhide"); 39 component.on("change.showhide", function () { 40 multiSelectShowHide(element); 41 }); 42 }); 43 } else if ($(element).is("[role='radiogroup']")) { 44 multiSelectShowHide(element); 45 $(element).find("coral-radio").off("change.showhide").on("change.showhide", function () { 46 multiSelectShowHide(element); 47 }); 48 } 49 }); 50 } 51 52 function multiSelectShowHide(element) { 53 let target = $(element).data("cqDialogDropdownShowhideTarget"); 54 if (!target) return; 55 56 // Find targets in context (works for both dialog and wizard) 57 let $multifieldItem = $(element).closest('coral-multifield-item'); 58 59 let $target; 60 61 if ($multifieldItem.length > 0) { 62 // Scope only within current multifield item 63 $target = $multifieldItem.find(target); 64 } else { 65 // Normal dialog behavior 66 let $container = $(element).closest('.cq-dialog-content-page, coral-dialog-content, .foundation-wizard-content'); 67 $target = $container.find(target); 68 69 if ($target.length === 0) { 70 $target = $(target); 71 } 72 } 73 74 if ($target.length > 0) { 75 // Get selected values 76 let selectedValues = []; 77 if (element.values && element.values.length > 0) { 78 selectedValues = element.values; 79 } else if (element.value) { 80 selectedValues = [element.value]; 81 } else if (element.selectedItem && element.selectedItem.value) { 82 selectedValues = [element.selectedItem.value]; 83 } 84 85 // Fallback for radio groups (rendered as div, no .value property) 86 if (selectedValues.length === 0) { 87 var $checkedRadio = $(element).find('input[type="radio"]:checked'); 88 if ($checkedRadio.length > 0) { 89 selectedValues = [$checkedRadio.val()]; 90 } else { 91 // No radio checked â default to first radio's value 92 var $firstRadio = $(element).find('input[type="radio"]:first'); 93 if ($firstRadio.length > 0) { 94 $firstRadio.prop("checked", true); 95 selectedValues = [$firstRadio.val()]; 96 } 97 } 98 } 99 100 // Show/hide targets based on their data attribute 101 $target.each(function () {
102 let $this = $(this); 103 let targetValueList = $this.data('showhidetargetvalue'); 104 if (typeof targetValueList !== "undefined") { 105 let shouldShow = false; 106 let targetValues = targetValueList.toString().replace(/ /g, '').split(','); 107 targetValues.forEach(function(targetValue) { 108 if (selectedValues.indexOf(targetValue) !== -1) { 109 shouldShow = true; 110 } 111 }); 112 113 if (shouldShow) { 114 $this.removeClass('hide'); 115 } else { 116 $this.addClass('hide'); 117 } 118 } 119 }); 120 } 121 } 122 } 123 124 // Start initialization 125 var isCision = window.location.href.includes("/content/cision/us"); 126 var projectMeta = document.querySelector('meta[name="project-name-revamp"]'); 127 if (isCision === true || projectMeta != null) { 128 init(); 129 } 130 131})(document); 132(function (document) { 133 "use strict"; 134 135 // Wait for jQuery to be available 136 function init() { 137 var $ = Granite.$; 138 if (typeof $ === 'undefined' || typeof $.fn === 'undefined') { 139 setTimeout(init, 100); 140 return; 141 } 142 143 // When dialog gets injected 144 $(document).on("foundation-contentloaded", function (e) { 145 // If there is already an initial value make sure the target element visibility is correct 146 checkboxInvertedShowHideHandler($(".cq-dialog-checkbox-showhide-inverted", e.target)); 147 }); 148 149 $(document).on("change", ".cq-dialog-checkbox-showhide-inverted", function (e) { 150 checkboxInvertedShowHideHandler($(this)); 151 }); 152 153 function checkboxInvertedShowHideHandler(el) { 154 el.each(function (i, element) { 155 if($(element).is("coral-checkbox")) { 156 // Handle Coral3 checkbox 157 Coral.commons.ready(element, function (component) { 158 showHideInverted(component, element); 159 component.on("change", function () { 160 showHideInverted(component, element); 161 }); 162 }); 163 } else { 164 // Handle Coral2 checkbox 165 var component = $(element).data("checkbox"); 166 if (component) { 167 showHideInverted(component, element); 168 } 169 } 170 }) 171 } 172 173 function showHideInverted(component, element) { 174 // Get the selector to find the target elements from data attribute 175 var target = $(element).data("cqDialogCheckboxShowhideTarget"); 176 177 if (!target) { 178 return; 179 } 180 181 // Find targets in context (works for both dialog and wizard, searches across tabs) 182 var $container = $(element).closest('.cq-dialog-content-page, coral-dialog-content, .foundation-wizard-content'); 183 var $target = $container.find(target); 184 if ($target.length === 0) { 185 $target = $(target); 186 } 187 188 if ($target.length > 0) { 189 $target.each(function() { 190 var $field = $(this); 191 // Find the parent field wrapper to hide label + field together 192 var $fieldWrapper = $field.closest('.coral-Form-fieldwrapper'); 193 194 // INVERTED LOGIC: checked = hide, unchecked = show 195 if (component.checked) { 196 $field.addClass("hide"); 197 if ($fieldWrapper.length > 0) { 198 $fieldWrapper.addClass("hide"); 199 } 200 } else { 201 $field.removeClass("hide"); 202 if ($fieldWrapper.length > 0) { 203 $fieldWrapper.removeClass("hide"); 204 } 205 } 206 }); 207 } 208 } 209 } 210 211 // Start initialization 212 var isCision = window.location.href.includes("/content/cision/us"); 213 var projectMeta = document.querySelector('meta[name="project-name-revamp"]'); 214 if (isCision === true || projectMeta != null) { 215 init(); 216 } 217 218})(document); 219 220(function (document) { 221 "use strict"; 222 223 // Wait for jQuery to be available
224 function init() { 225 var $ = Granite.$; 226 if (typeof $ === 'undefined' || typeof $.fn === 'undefined') { 227 setTimeout(init, 100); 228 return; 229 } 230 231 // When dialog or wizard gets injected 232 $(document).on("foundation-contentloaded", function (e) { 233 // If there is already an initial value make sure the target element visibility is correct 234 checkboxShowHideHandler($(".cq-dialog-checkbox-showhide", e.target)); 235 }); 236 237 // Also listen on coral-overlay:open for wizard panels and page property tab changes 238 $(document).on("coral-overlay:open coral-tabview:change", function (e) { 239 setTimeout(function() { 240 checkboxShowHideHandler($(".cq-dialog-checkbox-showhide")); 241 }, 100); 242 }); 243 244 $(document).on("change", ".cq-dialog-checkbox-showhide", function (e) { 245 checkboxShowHideHandler($(this)); 246 }); 247 248 function checkboxShowHideHandler(el) { 249 el.each(function (i, element) { 250 if($(element).is("coral-checkbox")) { 251 // Handle Coral3 checkbox 252 Coral.commons.ready(element, function (component) { 253 showHide(component, element); 254 component.off("change.showhide"); 255 component.on("change.showhide", function () { 256 showHide(component, element); 257 }); 258 }); 259 } else { 260 // Handle Coral2 checkbox 261 var component = $(element).data("checkbox"); 262 if (component) { 263 showHide(component, element); 264 } 265 } 266 }) 267 } 268 269 function showHide(component, element) { 270 // Get the selector to find the target elements from data attribute 271 var target = $(element).data("cqDialogCheckboxShowhideTarget"); 272 273 if (!target) { 274 return; 275 } 276 277 // Find targets in context (works for dialog, wizard, and page properties) 278 var $container = $(element).closest( 279 '.cq-dialog-content-page, coral-dialog-content, .foundation-wizard-content, ' + 280 '.cq-siteadmin-admin-properties, coral-panel, .coral3-Panel, form' 281 ); 282 283 var $target = $container.find(target); 284 285 // If not found in container, try document-wide search 286 if ($target.length === 0) { 287 $target = $(target); 288 } 289 290 if ($target.length > 0) { 291 $target.each(function() { 292 var $field = $(this); 293 // Find the parent field wrapper to hide label + field together 294 var $fieldWrapper = $field.closest('.coral-Form-fieldwrapper'); 295 296 // REGULAR LOGIC: checked = show, unchecked = hide 297 if (component.checked) { 298 $field.removeClass("hide"); 299 if ($fieldWrapper.length > 0) { 300 $fieldWrapper.removeClass("hide"); 301 } 302 } else { 303 $field.addClass("hide"); 304 if ($fieldWrapper.length > 0) { 305 $fieldWrapper.addClass("hide"); 306 } 307 } 308 }); 309 } 310 } 311 } 312 313 // Start initialization 314 var isCision = window.location.href.includes("/content/cision/us"); 315 var projectMeta = document.querySelector('meta[name="project-name-revamp"]'); 316 if (isCision === true || projectMeta != null) { 317 init(); 318 } 319 320})(document); 321 322(function (document) { 323 "use strict"; 324 325 var SHOWHIDE_SELECTOR = ".cq-dialog-radio-showhide"; 326 var TARGET_DATA_KEY = "cqDialogRadioShowhideTarget"; 327 var TARGET_VALUE_KEY = "showhidetargetvalue"; 328 329 function init() { 330 var $ = Granite.$; 331 if (typeof $ === 'undefined' || typeof $.fn === 'undefined') { 332 setTimeout(init, 100); 333 return; 334 } 335 336 // Initial visibility when dialog/wizard gets injected 337 $(document).on("foundation-contentloaded", function (e) { 338 radioShowHideHandler($(SHOWHIDE_SELECTOR, e.target)); 339 }); 340 341 // Re-evaluate when wizard panels or property tabs open 342 $(document).on("coral-overlay:open coral-tabview:change", function () { 343 setTimeout(function () { 344 radioShowHideHandler($(SHOWHIDE_SELECTOR)); 345 }, 100); 346 }); 347 348 // React to radio selection changes 349 $(document).on("change", SHOWHIDE_SELECTOR, function () { 350 radioShowHideHandler($(this)); 351 }); 352 353 function radioShowHideHandler(el) { 354 var $ = Granite.$; 355 el.each(function (i, element) { 356 Coral.commons.ready(element, function () { 357 showHide($(element)); 358 }); 359 }); 360 } 361 362 function showHide($element) { 363 var $ = Granite.$; 364 365 var target = $element.data(TARGET_DATA_KEY); 366 if (!target) { 367 return; 368 } 369 370 var selectedValue = getSelectedValue($element); 371 372 var $container = $element.closest( 373 '.cq-dialog-content-page, coral-dialog-content, .foundation-wizard-content, ' + 374 '.cq-siteadmin-admin-properties, coral-panel, .coral3-Panel, form' 375 ); 376 377 var $targets = $container.find(target); 378 if ($targets.length === 0) { 379 $targets = $(target); 380 } 381 382 $targets.each(function () { 383 var $field = $(this); 384 var expectedValue = String($field.data(TARGET_VALUE_KEY)); 385 var $fieldWrapper = $field.closest('.coral-Form-fieldwrapper'); 386 var match = expectedValue === String(selectedValue); 387 388 if (match) { 389 $field.removeClass("hide"); 390 if ($fieldWrapper.length > 0) { 391 $fieldWrapper.removeClass("hide"); 392 } 393 } else { 394 $field.addClass("hide"); 395 if ($fieldWrapper.length > 0) { 396 $fieldWrapper.addClass("hide"); 397 } 398 } 399 }); 400 } 401 402 function getSelectedValue($element) { 403 var $ = Granite.$; 404 var raw = $element.get(0); 405 406 // Coral3 radiogroup exposes the selected value directly 407 if (raw && typeof raw.value !== "undefined" && raw.value !== null && raw.value !== "") { 408 return raw.value; 409 } 410 411 var $checked = $element.find('coral-radio[checked], input[type="radio"]:checked').first(); 412 if ($checked.length > 0) { 413 return $checked.val(); 414 } 415 return ""; 416 } 417 } 418 419 var isCision = window.location.href.includes("/content/cision/us"); 420 var projectMeta = document.querySelector('meta[name="project-name-revamp"]'); 421 if (isCision === true || projectMeta != null) { 422 init(); 423 } 424 425})(document); 426 427// Multi-city Event Configuration: Force horizontal layout for eventDateType radios 428// and date range fields in both page properties dialog and Create Page wizard 429function applyEventDateHorizontalLayout() { 430 // 1. Make Event date radio buttons horizontal 431 var radios = document.querySelectorAll('coral-radio[name="./eventDateType"]'); 432 if (radios && radios.length > 0) { 433 radios.forEach(function(radio) { 434 radio.style.display = 'inline-block'; 435 radio.style.marginRight = '24px'; 436 radio.style.verticalAlign = 'middle'; 437 }); 438 } 439 440 // 2. Make Start date / End date fields horizontal (side-by-side) 441 var dateRangeContainers = document.querySelectorAll('.event-date-range-inline'); 442 if (dateRangeContainers && dateRangeContainers.length > 0) {
443 dateRangeContainers.forEach(function(container) { 444 container.style.display = 'flex'; 445 container.style.flexWrap = 'wrap'; 446 container.style.gap = '24px'; 447 448 // Target the field wrappers inside 449 var fieldWrappers = container.querySelectorAll('.coral-Form-fieldwrapper'); 450 fieldWrappers.forEach(function(wrapper) { 451 wrapper.style.flex = '1 1 200px'; 452 wrapper.style.margin = '0'; 453 }); 454 }); 455 } 456} 457 458// Apply on various dialog/wizard load events 459$(document).on("foundation-contentloaded coral-overlay:open coral-tabview:change", function() { 460 setTimeout(applyEventDateHorizontalLayout, 150); 461}); 462applyEventDateHorizontalLayout(); 463 464 // Multi-city Event Configuration: Force horizontal layout for eventDateType radios 465 // in both page properties dialog and Create Page wizard 466 function applyEventDateHorizontalLayout() { 467 var radios = document.querySelectorAll('coral-radio[name="./eventDateType"]'); 468 if (radios && radios.length > 0) { 469 radios.forEach(function(radio) { 470 radio.style.display = 'inline-block'; 471 radio.style.marginRight = '24px'; 472 radio.style.verticalAlign = 'middle'; 473 }); 474 } 475 } 476 477 // Apply on various dialog/wizard load events 478 $(document).on("foundation-contentloaded coral-overlay:open coral-tabview:change", function() { 479 setTimeout(applyEventDateHorizontalLayout, 150); 480 }); 481 applyEventDateHorizontalLayout(); 482/** 483 * Disables returnUrl field when form is used on Event Gate or Report Gate page templates. 484 * On event gate pages, the redirect is determined by event state. 485 * On report gate pages, the form always redirects to /thank-you/resource-download. 486 */ 487(function (document) { 488 "use strict"; 489 490 var EVENT_GATE_TEMPLATE = "/conf/cision-revamp/settings/wcm/templates/event-gate-page-template"; 491 var REPORT_GATE_TEMPLATE = "/conf/cision-revamp/settings/wcm/templates/report-gate-page-template"; 492 var TIPSHEET_GATE_TEMPLATE = "/conf/cision-revamp/settings/wcm/templates/tipsheet-gate-page-template"; 493 var MULTICITY_GATE_TEMPLATE = "/conf/cision-revamp/settings/wcm/templates/multi-city-event-gate-page-template"; 494 var MULTISESSION_GATE_TEMPLATE = "/conf/cision-revamp/settings/wcm/templates/multi-session-event-gate-page-template"; 495 var EXPANDED_EVENT_GATE_TEMPLATE = "/conf/cision-revamp/settings/wcm/templates/expanded-event-gate-page-template"; 496 497 // Templates where returnUrl should be disabled 498 var GATE_TEMPLATES = [EVENT_GATE_TEMPLATE, REPORT_GATE_TEMPLATE, TIPSHEET_GATE_TEMPLATE, MULTICITY_GATE_TEMPLATE, MULTISESSION_GATE_TEMPLATE, EXPANDED_EVENT_GATE_TEMPLATE]; 499 500 // Wait for jQuery to be available 501 function init() { 502 var $ = Granite.$; 503 if (typeof $ === 'undefined' || typeof $.fn === 'undefined') { 504 setTimeout(init, 100); 505 return; 506 } 507 508 // Listen for dialog load 509 $(document).on("foundation-contentloaded", function (e) { 510 checkAndDisableReturnUrl($(e.target)); 511 }); 512 513 // Also listen for coral dialog open 514 $(document).on("coral-overlay:open", function(e) { 515 setTimeout(function() { 516 checkAndDisableReturnUrl($(e.target)); 517 }, 300); 518 }); 519 } 520 521 function checkAndDisableReturnUrl($dialog) { 522 var $ = Granite.$; 523 524 // Check if this dialog has returnUrl field (form component dialogs) 525 var $returnUrlField = $dialog.find('[name="./returnUrl"]'); 526 if ($returnUrlField.length === 0) { 527 return; 528 } 529 530 // Get the component path from Granite.author 531 if (typeof Granite.author === 'undefined') { 532 return; 533 } 534 535 var editable = Granite.author.editables && Granite.author.DialogFrame && Granite.author.DialogFrame.currentDialog; 536 if (!editable || !editable.editable) { 537 return; 538 } 539 540 var componentPath = editable.editable.path; 541 var pagePath = componentPath.split('/jcr:content')[0]; 542 543 // Fetch page properties to check template 544 $.ajax({ 545 url: pagePath + '/jcr:content.json', 546 type: 'GET', 547 async: false, 548 success: function(pageData) { 549 if (pageData && pageData['cq:template']) { 550 var template = pageData['cq:template']; 551 if (GATE_TEMPLATES.indexOf(template) !== -1) { 552 disableReturnUrlField($dialog, template, pageData); 553 } 554 } 555 } 556 }); 557 } 558 559 /** 560 * Returns the contextual message for Multi-City / Multi-Session 561 * templates based on the selected session status. 562 */ 563 function getMultiTemplateStatusMessage(status) { 564 var normalizedStatus = String(status || "").trim().toLowerCase(); 565 566 switch (normalizedStatus) { 567 case "open for registrations": 568 return 'The form redirects to ' + 569 '<strong>/thank-you/session-registration</strong>.'; 570 571 case "waitlist only": 572 return 'The form redirects to ' + 573 '<strong>/thank-you/dynamic-waitlist</strong>.'; 574 575 case "on-demand": 576 return 'The form redirects to the ' + 577 '<strong>Ungated page URL</strong> field below.'; 578 579 default: 580 return ""; 581 } 582 } 583 584 /** 585 * Gets the currently selected Session Status. 586 * Supports both Coral Select and native select rendering. 587 */ 588 function getSessionStatus($container) { 589 var $ = Granite.$; 590 var $statusField = $container.find('[name="./sessionStatus"]').first(); 591 592 if ($statusField.length === 0) { 593 return ""; 594 } 595 596 // Coral select 597 if ($statusField[0].selectedItem && 598 $statusField[0].selectedItem.value) { 599 return $statusField[0].selectedItem.value; 600 } 601 602 // Normal select/input 603 if ($statusField.val()) { 604 return $statusField.val(); 605 } 606 607 return ""; 608 } 609 610 /** 611 * Creates/updates the contextual information box. 612 *
613 * This styling is intentionally kept inside this JS so the 614 * existing form-returnurl behavior does not require changes 615 * elsewhere. 616 */ 617 function updateMultiTemplateStatusInfo($container) { 618 var $ = Granite.$; 619 var status = getSessionStatus($container); 620 var message = getMultiTemplateStatusMessage(status); 621 622 /* 623 * If dialog.js has already created the Session Card 624 * status description, use that instead of creating 625 * another information box. 626 */ 627 var $existingStatusInfo = $container.find( 628 '.sessioncard-status-info' 629 ).first(); 630 631 if ($existingStatusInfo.length > 0) { 632 if (message) { 633 $existingStatusInfo.html( 634 '<coral-icon icon="infoCircle" size="S"></coral-icon>' + 635 '<span>' + message + '</span>' 636 ); 637 638 $existingStatusInfo.css({ 639 "display": "flex", 640 "align-items": "flex-start", 641 "gap": "8px", 642 "padding": "10px", 643 "background": "#e6f3ff", 644 "border-radius": "4px", 645 "margin-top": "8px", 646 "margin-bottom": "15px", 647 "color": "#0054B6", 648 "line-height": "1.4" 649 }); 650 651 $existingStatusInfo.find("coral-icon").css({ 652 "flex": "0 0 auto", 653 "margin-top": "2px" 654 }); 655 656 $existingStatusInfo.find("span").css({ 657 "color": "#0054B6" 658 }); 659 660 $existingStatusInfo.removeClass("hide"); 661 } else { 662 $existingStatusInfo.hide(); 663 } 664 665 return; 666 } 667 668 /* 669 * No existing Session Card status message was found, 670 * so create the information box used by this file. 671 */ 672 var $infoMessage = $container.find( 673 '.gate-returnurl-info' 674 ).first(); 675 676 if ($infoMessage.length === 0) { 677 $infoMessage = $( 678 '<div class="gate-returnurl-info">' + 679 '<coral-icon icon="infoCircle" size="S"></coral-icon>' + 680 '<span></span>' + 681 '</div>' 682 ); 683 684 var $statusField = $container 685 .find('[name="./sessionStatus"]') 686 .first(); 687 688 if ($statusField.length > 0) { 689 var $statusWrapper = $statusField.closest( 690 ".coral-Form-fieldwrapper" 691 ); 692 693 if ($statusWrapper.length === 0) { 694 $statusWrapper = $statusField.parent(); 695 } 696 697 $statusWrapper.after($infoMessage); 698 } else { 699 var $returnUrlField = $container 700 .find('[name="./returnUrl"]') 701 .first(); 702 703 var $returnUrlWrapper = $returnUrlField.closest( 704 ".coral-Form-fieldwrapper" 705 ); 706 707 if ($returnUrlWrapper.length === 0) { 708 $returnUrlWrapper = $returnUrlField.parent(); 709 } 710 711 $returnUrlWrapper.before($infoMessage); 712 } 713 } 714 715 $infoMessage.css({ 716 "display": message ? "flex" : "none", 717 "align-items": "center", 718 "gap": "8px", 719 "padding": "10px", 720 "background": "#e6f3ff", 721 "border-radius": "4px", 722 "margin-top": "8px", 723 "margin-bottom": "15px", 724 "color": "#0054B6", 725 "line-height": "1.4" 726 }); 727 728 $infoMessage.find("coral-icon").css({ 729 "flex": "0 0 auto", 730 "margin-top": "2px" 731 }); 732 733 $infoMessage.find("span").css({ 734 "color": "#0054B6" 735 }); 736 737 $infoMessage.find("span").html(message); 738 } 739 740 /** 741 * Bind Session Status change only for Multi-City / 742 * Multi-Session templates. 743 */ 744 function bindMultiTemplateStatusChange($container) { 745 var $ = Granite.$; 746 747 var $statusField = $container.find( 748 '[name="./sessionStatus"]' 749 ).first(); 750 751 if ($statusField.length === 0) { 752 return; 753 } 754 755 /* 756 * Prevent duplicate handlers when AEM fires 757 * foundation-contentloaded multiple times. 758 */ 759 $statusField.off( 760 "change.gateReturnUrlStatus" 761 ); 762 763 $statusField.on( 764 "change.gateReturnUrlStatus", 765 function () { 766 updateMultiTemplateStatusInfo($container); 767 } 768 ); 769 770 /* 771 * Initial state. 772 */ 773 updateMultiTemplateStatusInfo($container); 774 } 775 776 function disableReturnUrlField($container, template, pageData) { 777 var $ = Granite.$; 778 var $returnUrlField = $container.find('[name="./returnUrl"]'); 779 780 if ($returnUrlField.length === 0) { 781 return; 782 } 783 784 // Find the field wrapper 785 var $fieldWrapper = $returnUrlField.closest(".coral-Form-fieldwrapper"); 786 if ($fieldWrapper.length === 0) { 787 $fieldWrapper = $returnUrlField.parent(); 788 } 789 790 // Also find the external link checkbox related to returnUrl 791 var $externalLinkCheckbox = $container.find('[name="./returnurlnewtab"]'); 792 var $externalLinkWrapper = $externalLinkCheckbox.closest(".coral-Form-fieldwrapper"); 793 if ($externalLinkWrapper.length === 0) { 794 $externalLinkWrapper = $externalLinkCheckbox.parent(); 795 } 796 797 // Hide the fields 798 $fieldWrapper.hide(); 799 $externalLinkWrapper.hide(); 800 801 // Remove required attribute to prevent validation errors 802 $returnUrlField.removeAttr("required"); 803 $returnUrlField.removeAttr("aria-required"); 804 $returnUrlField.closest("foundation-autocomplete").removeAttr("required"); 805 806 // Add info message based on template type 807 if ($container.find('.gate-returnurl-info').length === 0) { 808 var message; 809 if (template === REPORT_GATE_TEMPLATE || template === EXPANDED_EVENT_GATE_TEMPLATE || template === EVENT_GATE_TEMPLATE) { 810 if (pageData && pageData.postSubmitAction === 'redirect') { 811 message = 'After form submission, the user will be redirected to the <strong>Ungated report page path</strong> specified in Page Properties. The return URL is managed automatically for Report & Guide gate pages.'; 812 } else { 813 message = 'The form redirects to <strong>/thank-you/resource-download?ref=...</strong> which resolves the resource properties from this page. The return URL is managed automatically for Report & Guide gate pages.'; 814 } 815 } else if (template === TIPSHEET_GATE_TEMPLATE) { 816 if (pageData && pageData.postSubmitAction === 'redirect') { 817 message = 'After form submission, the user will be redirected to the <strong>Ungated resource page path</strong> specified in Page Properties. The return URL is managed automatically for Tipsheet gate pages.'; 818 } else { 819 message = 'The form redirects to <strong>/thank-you/resource-download?ref=...</strong> which resolves the resource properties from this page. The return URL is managed automatically for Tipsheet gate pages.'; 820 } 821 } else if (template === MULTICITY_GATE_TEMPLATE || template === MULTISESSION_GATE_TEMPLATE) { 822 bindMultiTemplateStatusChange($container); 823 return; 824 } else { 825 message = 'Before the start date, the form redirects to <strong>/thank-you/session-registration</strong>. After the start date, it redirects to the <strong>Ungated page URL</strong> in Page Properties.'; 826 } 827 828 var $infoMessage = $('<div class="gate-returnurl-info" style="padding: 10px; background: #e6f3ff; border-radius: 4px; margin-bottom: 15px;">' + 829 '<coral-icon icon="info" size="S"></coral-icon> ' + 830 '<span style="color: #0054B6;">' + message + '</span>' + 831 '</div>'); 832 $fieldWrapper.before($infoMessage); 833 } 834 } 835 836 // Start initialization 837 var isCision = window.location.href.includes("/content/cision/us"); 838 var projectMeta = document.querySelector('meta[name="project-name-revamp"]'); 839 if (isCision === true || projectMeta != null) { 840 init(); 841 } 842 843})(document); 844 845/** 846 * Comparison Block Dialog 847 * - Keeps comparison item labels numbered dynamically 848 * - Auto-creates comparison values to match the number of comparison items 849 * - Explicitly toggles Icon vs Label fields for each comparison value row 850 * - Updates the highlighted comparison dropdown to stay in sync 851 */ 852(function (document) { 853 "use strict"; 854
855 function init() { 856 857 var $ = Granite.$; 858 if (!$ || !$.fn || typeof Coral === "undefined" || !Coral.commons) { 859 setTimeout(init, 100); 860 return; 861 } 862 863 var setupTimer = null; 864 var syncTimer = null; 865 var initialHighlightedValue = null; 866 var highlightedResourceValue = null; 867 var highlightedResourceFetchDone = false; 868 var highlightedResourceFetchInProgress = false; 869 var debugEnabled = isDebugEnabled(); 870 var comparisonDialogActive = false; 871 var comparisonItemsLimit = 5; 872 var enforcingComparisonLimit = false; 873 874 $(document).off(".comparisonBlockDialog"); 875 876 function hasComparisonDialog(context) { 877 var $context = $(context || document); 878 if ($context.hasClass("comparison-block-dialog")) { 879 return true; 880 } 881 882 if ($context.find(".comparison-block-dialog").length) { 883 return true; 884 } 885 886 // Fallback for overlay events where target can be the dialog shell. 887 return $("coral-dialog.is-open .comparison-block-dialog").length > 0; 888 } 889 890 // âââ EVENT DELEGATION: most reliable way to catch Type dropdown changes âââ 891 // Works for both existing and dynamically added items 892 $(document).on("change.comparisonBlockDialog", 893 ".comparison-block-dialog coral-select[name*='valueType']", 894 function () { 895 syncValueTypeState($(this).closest("coral-multifield-item")); 896 } 897 ); 898 899 $(document).on("click.comparisonBlockDialog", ".comparison-block-dialog .comparison-items-multifield [coral-multifield-add]", function (e) { 900 var $comparisonItemsMF = $(this).closest(".comparison-items-multifield"); 901 var currentCount = getComparisonItemsCount($comparisonItemsMF); 902 903 if (currentCount >= comparisonItemsLimit) { 904 e.preventDefault(); 905 e.stopImmediatePropagation(); 906 showComparisonLimitMessage(); 907 setTimeout(function () { 908 enforceComparisonItemLimit(getDialogContext($comparisonItemsMF), false); 909 }, 0); 910 } 911 }); 912 913 914 $(document).on("foundation-contentloaded.comparisonBlockDialog", function (e) { 915 if (!comparisonDialogActive && !hasComparisonDialog(e.target)) { 916 return; 917 } 918 scheduleSetup(e.target); 919 }); 920 921 $(document).on("coral-overlay:open.comparisonBlockDialog", function (e) { 922 if (!hasComparisonDialog(e.target) && !hasComparisonDialog(document)) { 923 return; 924 } 925 926 comparisonDialogActive = true; 927 scheduleSetup(e.target || document); 928 }); 929 930 function scheduleSetup(context) { 931 clearTimeout(setupTimer); 932 setupTimer = setTimeout(function () { 933 debug("scheduleSetup", { 934 contextType: context && context.nodeName ? context.nodeName : typeof context 935 }); 936 Coral.commons.ready(function () { 937 setup(context || document); 938 }); 939 }, 50); 940 } 941 942 function setup(context) { 943 var $context = getDialogContext(context); 944 var $compItems = $(".comparison-items-multifield", $context); 945 if (!$compItems.length) { 946 comparisonDialogActive = false; 947 return; 948 } 949 950 comparisonDialogActive = true; 951 952 debug("setup", { 953 comparisonItems: $compItems.find("coral-multifield-item").length 954 }); 955 956 // Reset per dialog open; prevents stale value leaking between components. 957 initialHighlightedValue = null; 958 highlightedResourceValue = null; 959 highlightedResourceFetchDone = false; 960 highlightedResourceFetchInProgress = false; 961 962 bindComparisonItemsObserver($context); 963 bindFeaturesObserver($context); 964 bindDialogSubmitPersistence($context); 965 loadPersistedHighlightedValue($context); 966 enforceComparisonItemLimit($context, false); 967 968 syncAll($context);
969 // Retry after Coral loads saved JCR values into selects 970 setTimeout(function () { syncAll($context); }, 400); 971 setTimeout(function () { syncAll($context); }, 900); 972 } 973 974 // âââ HELPERS: navigate to the actual coral-multifield element âââââââââââââ 975 function getCoralMF(wrapper) { 976 var $w = $(wrapper); 977 return $w.is("coral-multifield") ? $w : $w.find("coral-multifield").first(); 978 } 979 980 // âââ OBSERVERS ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 981 982 function bindComparisonItemsObserver($context) { 983 var el = $(".comparison-items-multifield", $context)[0]; 984 if (!el || el._cvItemObserverBound) return; 985 el._cvItemObserverBound = true; 986 987 Coral.commons.ready(el, function () { 988 var target = getCoralMF(el)[0] || el; 989 var mo = new MutationObserver(function () { 990 enforceComparisonItemLimit($context, false); 991 debounceSync($context); 992 }); 993 mo.observe(target, { childList: true }); 994 el._cvItemObserver = mo; 995 }); 996 } 997 998 function bindFeaturesObserver($context) { 999 var featuresMFEl = $(".features-multifield", $context)[0]; 1000 if (!featuresMFEl || featuresMFEl._cvFeatureObserverBound) return; 1001 featuresMFEl._cvFeatureObserverBound = true; 1002 1003 Coral.commons.ready(featuresMFEl, function () { 1004 // CRITICAL: observe the coral-multifield, not the wrapper div 1005 var target = getCoralMF(featuresMFEl)[0] || featuresMFEl; 1006 1007 var mo = new MutationObserver(function (mutations) { 1008 mutations.forEach(function (mut) { 1009 Array.prototype.slice.call(mut.addedNodes).forEach(function (node) { 1010 if (!node.tagName || node.tagName.toLowerCase() !== "coral-multifield-item") return; 1011 1012 Coral.commons.ready(node, function () { 1013 setTimeout(function () { 1014 var count = itemCount($(".comparison-items-multifield", $context)); 1015 bindComparisonValueObservers(node); 1016 ensureFeatureItemCounts(node, count); 1017 syncValueTypeStates(node); 1018 updateCVLabels($(node).find(".comparison-values-multifield").first()); 1019 refreshFeatureRowLabels($(".features-multifield", $context)); 1020 }, 200); 1021 }); 1022 }); 1023 }); 1024 debounceSync($context); 1025 }); 1026 1027 mo.observe(target, { childList: true }); 1028 featuresMFEl._cvFeatureObserver = mo; 1029 }); 1030 } 1031 1032 function bindComparisonValueObservers(scope) { 1033 $(scope).find(".comparison-values-multifield").each(function () { 1034 var el = this; 1035 if (el._cvValuesBound) return; 1036 el._cvValuesBound = true; 1037 1038 Coral.commons.ready(el, function () { 1039 // CRITICAL: observe the coral-multifield, not the wrapper div 1040 var target = getCoralMF(el)[0] || el; 1041 var mo = new MutationObserver(function () { 1042 debounceSync(scope); 1043 }); 1044 mo.observe(target, { childList: true }); 1045 el._cvValuesObserver = mo; 1046 }); 1047 }); 1048 } 1049 1050 function debounceSync(context) { 1051 clearTimeout(syncTimer); 1052 syncTimer = setTimeout(function () { 1053 syncAll($(context || document)); 1054 }, 120); 1055 } 1056 1057 // âââ SYNC âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 1058 1059 function syncAll($context) { 1060 $context = getDialogContext($context); 1061 1062 var $compItems = $(".comparison-items-multifield", $context).first(); 1063 if (!$compItems.length) return; 1064 1065 var count = itemCount($compItems); 1066 debug("syncAll", { 1067 count: count 1068 }); 1069 refreshComparisonLabels($compItems); 1070 refreshHighlighted($(".highlighted-comparison-select", $context).first(), count); 1071 refreshFeatureRowLabels($(".features-multifield", $context).first()); 1072 1073 // CRITICAL: use .children() on coral-multifield to get ONLY direct feature 1074 // items â avoids processing nested comparison-value items too 1075 var $coralFeaturesMF = getCoralMF($(".features-multifield", $context).first()); 1076 $coralFeaturesMF.children("coral-multifield-item").each(function () { 1077 var $cvMF = $(this).find(".comparison-values-multifield").first(); 1078 if (!$cvMF.length) return; 1079 1080 bindComparisonValueObservers(this); 1081 ensureFeatureItemCounts(this, count); 1082 updateCVLabels($cvMF);
1083 syncValueTypeStates($cvMF); 1084 }); 1085 } 1086 1087 function syncValueTypeStates(scope) { 1088 $(scope).find("coral-multifield-item").each(function () { 1089 syncValueTypeState(this); 1090 }); 1091 } 1092 1093 // âââ SHOW / HIDE ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 1094 1095 function syncValueTypeState(item) { 1096 var $item = $(item); 1097 var selectEl = $item.find("coral-select[name*='valueType']")[0]; 1098 if (!selectEl) return; 1099 1100 // Try both Coral properties for maximum compatibility 1101 var value = (selectEl.selectedItem && selectEl.selectedItem.value) 1102 || selectEl.value 1103 || "icon"; 1104 1105 var isLabel = (value === "label"); 1106 var $row = $item.find(".comparison-value-row").first(); 1107 if (!$row.length) return; 1108 1109 if (isLabel) { 1110 $row.addClass("show-label").removeClass("show-icon"); 1111 } else { 1112 $row.addClass("show-icon").removeClass("show-label"); 1113 } 1114 } 1115 1116 // âââ ENSURE COUNTS ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 1117 1118 function ensureFeatureItemCounts(featureItem, target) { 1119 var $featureItem = $(featureItem); 1120 var $cvMF = $featureItem.find(".comparison-values-multifield").first(); 1121 if (!$cvMF.length) return; 1122 1123 var have = $cvMF.find("coral-multifield-item").length; 1124 if (have >= target) return; 1125 1126 var btn = $cvMF.find("button[coral-multifield-add]").first()[0]; 1127 if (!btn) return; 1128 1129 btn.click(); 1130 setTimeout(function () { 1131 ensureFeatureItemCounts(featureItem, target); 1132 }, 180); 1133 1134 if (have + 1 >= target) { 1135 setTimeout(function () { 1136 updateCVLabels($cvMF); 1137 syncValueTypeStates($cvMF); 1138 }, 300); 1139 } 1140 } 1141 1142 // âââ LABEL UPDATES ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 1143 1144 function updateCVLabels($cvMF) { 1145 if (!$cvMF.length) return; 1146 // CRITICAL: navigate to coral-multifield to get direct item children only 1147 var $coralMF = getCoralMF($cvMF); 1148 $coralMF.children("coral-multifield-item").each(function (i) { 1149 var newText = "Comparison " + (i + 1) + " value"; 1150 // Update legend (bold section header of the composite multifield item) 1151 var $legend = $(this).find("legend").first(); 1152 if ($legend.length) { 1153 $legend.text(newText); 1154 } 1155 // Fallback: update fieldLabel if legend not found 1156 if (!$legend.length) { 1157 var $fl = $(this).find(".coral-Form-fieldlabel").first(); 1158 if ($fl.length) $fl.text(newText); 1159 } 1160 }); 1161 } 1162 1163 function refreshComparisonLabels($mf) { 1164 $mf.find("coral-multifield-item").each(function (i) { 1165 var $label = $(this).find(".coral-Form-fieldlabel, label").first(); 1166 if ($label.length) { 1167 $label.text("Comparison " + (i + 1)); 1168 } 1169 }); 1170 } 1171function refreshFeatureRowLabels($mf) { 1172 1173 var $coralMF = getCoralMF($mf); 1174 1175 $coralMF.children("coral-multifield-item").each(function(index){ 1176 1177 var legend = $(this) 1178 .find("> coral-multifield-item-content > section > h2.coral-Form-fieldset-legend") 1179 .first(); 1180 1181 if (legend.length) { 1182 1183 var label = "Row " + (index + 1); 1184 1185 legend.text(label); 1186 1187 } 1188 }); 1189} 1190 1191 // âââ HIGHLIGHTED SELECT âââââââââââââââââââââââââââââââââââââââââââââââââââ 1192 1193function refreshHighlighted($wrapper, count) { 1194 1195 if (!$wrapper.length) { 1196 return; 1197 } 1198 1199 var select = $wrapper.find("coral-select")[0] || $wrapper[0]; 1200 1201 if (!select) { 1202 return; 1203 } 1204 1205 Coral.commons.ready(select, function (sel) { 1206 bindHighlightedChangePersistence(sel); 1207 1208 if (initialHighlightedValue === null || initialHighlightedValue === "none") { 1209 initialHighlightedValue = getInitialHighlightedValue(sel); 1210 } 1211 1212 // Preserve currently loaded value before rebuilding dynamic options. 1213 // On dialog reopen, Coral may already know the value even when options are rebuilt. 1214 var savedValue = normalizeHighlightedValue(getHighlightedValue(sel, initialHighlightedValue)); 1215 var currentValue = normalizeHighlightedValue(sel.value || (sel.selectedItem && sel.selectedItem.value) || "none");
1216 if (savedValue === "none" && currentValue !== "none") { 1217 savedValue = currentValue; 1218 } 1219 1220 debug("refreshHighlighted:start", { 1221 count: count, 1222 initialHighlightedValue: initialHighlightedValue, 1223 highlightedResourceValue: highlightedResourceValue, 1224 selectValue: sel.value, 1225 savedValue: savedValue, 1226 optionsCount: sel.items && sel.items.getAll ? sel.items.getAll().length : -1 1227 }); 1228 1229 // Do not write a fallback value too early while multifield items are still loading. 1230 if (count < 1) { 1231 debug("refreshHighlighted:skip_count", { 1232 count: count 1233 }); 1234 return; 1235 } 1236 1237 // Wait until persisted value lookup completes before defaulting to none. 1238 if (savedValue === "none" && !highlightedResourceFetchDone) { 1239 debug("refreshHighlighted:wait_resource", { 1240 highlightedResourceFetchDone: highlightedResourceFetchDone, 1241 highlightedResourceFetchInProgress: highlightedResourceFetchInProgress 1242 }); 1243 return; 1244 } 1245 1246 // Remove existing dynamic options 1247 if (sel.items && sel.items.getAll) { 1248 1249 sel.items.getAll().forEach(function (item) { 1250 1251 if (item.value !== "none") { 1252 sel.items.remove(item); 1253 } 1254 1255 }); 1256 1257 } 1258 1259 // Add options 1260 for (var i = 1; i <= count; i++) { 1261 1262 var option = new Coral.Select.Item(); 1263 1264 option.content.textContent = i.toString(); 1265 option.value = i.toString(); 1266 1267 sel.items.add(option); 1268 } 1269 1270 // If saved value is currently out of range, wait for next sync pass instead of forcing "none". 1271 var savedNum = parseInt(savedValue, 10); 1272 if (savedValue !== "none" && !isNaN(savedNum) && savedNum > count) { 1273 debug("refreshHighlighted:skip_out_of_range", { 1274 savedValue: savedValue, 1275 savedNum: savedNum, 1276 count: count 1277 }); 1278 return; 1279 } 1280 1281 // Restore saved value 1282 if ( 1283 savedValue !== "none" && 1284 !isNaN(savedNum) && 1285 savedNum <= count 1286 ) { 1287 applyHighlightedValue(sel, savedValue); 1288 debug("refreshHighlighted:restored", { 1289 assigned: savedValue, 1290 finalValue: sel.value 1291 }); 1292 1293 } else { 1294 // Keep a valid current value if available; avoid forcing a premature none. 1295 var currentNum = parseInt(currentValue, 10);
1296 if (currentValue !== "none" && !isNaN(currentNum) && currentNum <= count) { 1297 applyHighlightedValue(sel, currentValue); 1298 } 1299 debug("refreshHighlighted:preserve_current", { 1300 savedValue: savedValue, 1301 savedNum: savedNum, 1302 count: count, 1303 currentValue: currentValue 1304 }); 1305 } 1306 1307 }); 1308 1309} 1310 1311function getInitialHighlightedValue(sel) { 1312 return normalizeHighlightedValue(getHighlightedValue(sel, "none")); 1313} 1314 1315function getHighlightedValue(sel, cachedValue) { 1316 var valueFromSelect = normalizeHighlightedValue( 1317 sel.value || (sel.selectedItem && sel.selectedItem.value) || "" 1318 ); 1319 1320 if (valueFromSelect && valueFromSelect !== "none") { 1321 return valueFromSelect; 1322 } 1323 1324 if (cachedValue && cachedValue !== "none") { 1325 return cachedValue; 1326 } 1327 1328 var valueAttr = sel.getAttribute && sel.getAttribute("value"); 1329 if (valueAttr && valueAttr !== "none") { 1330 return normalizeHighlightedValue(valueAttr); 1331 } 1332 1333 if (highlightedResourceValue && highlightedResourceValue !== "none") { 1334 return highlightedResourceValue; 1335 } 1336 1337 var fieldApi = $(sel).adaptTo && $(sel).adaptTo("foundation-field"); 1338 if (fieldApi && fieldApi.getValue) { 1339 var valueFromField = fieldApi.getValue(); 1340 if (valueFromField && valueFromField !== "none") { 1341 return normalizeHighlightedValue(valueFromField); 1342 } 1343 } 1344 1345 var $hidden = getHighlightedHiddenInput(sel); 1346 var hiddenValue = $hidden.length ? $hidden.val() : ""; 1347 return normalizeHighlightedValue(hiddenValue); 1348} 1349 1350function normalizeHighlightedValue(value) { 1351 var normalized = (value === undefined || value === null ? "" : value.toString()).trim(); 1352 if (!normalized || normalized === "none") { 1353 return "none"; 1354 } 1355 1356 var number = parseInt(normalized, 10); 1357 if (!isNaN(number) && number > 0) { 1358 return number.toString(); 1359 } 1360 1361 return "none"; 1362} 1363 1364function applyHighlightedValue(sel, value) { 1365 var normalized = normalizeHighlightedValue(value); 1366 sel.value = normalized; 1367 1368 if (sel.items && sel.items.getAll) { 1369 sel.items.getAll().forEach(function (item) { 1370 item.selected = (item.value === normalized); 1371 }); 1372 } 1373 1374 persistHighlightedSelection(sel); 1375 1376 // Coral can re-evaluate selected item after async rendering; enforce once more. 1377 setTimeout(function () { 1378 sel.value = normalized; 1379 persistHighlightedSelection(sel); 1380 }, 80); 1381} 1382 1383function getHighlightedHiddenInput(sel) { 1384 var $sel = $(sel); 1385 var $wrapper = $sel.closest(".highlighted-comparison-select"); 1386 var $hidden = $wrapper.find("input[type='hidden'][name='./highlightedComparisonItem']").last(); 1387 1388 if (!$hidden.length) { 1389 var $fieldWrapper = $sel.closest(".coral-Form-fieldwrapper"); 1390 $hidden = $fieldWrapper.find("input[type='hidden'][name='./highlightedComparisonItem']").last(); 1391 } 1392 1393 if (!$hidden.length) { 1394 var $form = $sel.closest("form.foundation-form"); 1395 $hidden = $form.find("input[type='hidden'][name='./highlightedComparisonItem']").last(); 1396 } 1397 1398 if (!$hidden.length) { 1399 $hidden = $("input[type='hidden'][name='./highlightedComparisonItem']").last(); 1400 } 1401 1402 return $hidden; 1403} 1404 1405function getDialogContext(context) { 1406 var $context = $(context || document); 1407 1408 var $dialog = $context.closest("coral-dialog"); 1409 if (!$dialog.length) { 1410 $dialog = $context.find("coral-dialog.is-open").last(); 1411 } 1412 if (!$dialog.length) { 1413 $dialog = $("coral-dialog.is-open").last(); 1414 } 1415 1416 return $dialog.length ? $dialog : $context; 1417} 1418 1419function loadPersistedHighlightedValue(context) { 1420 if (highlightedResourceFetchDone || highlightedResourceFetchInProgress) { 1421 return; 1422 } 1423 1424 var $context = getDialogContext(context); 1425 var $form = $context.find("form.foundation-form").first(); 1426 var action = ($form.attr("action") || "").split("?")[0]; 1427 1428 if (!action) { 1429 highlightedResourceFetchDone = true; 1430 return; 1431 } 1432 1433 var jsonUrl = action.replace(/\/$/, "") + ".json"; 1434 highlightedResourceFetchInProgress = true; 1435 1436 debug("loadPersistedHighlightedValue:request", { 1437 action: action, 1438 jsonUrl: jsonUrl 1439 }); 1440 1441 $.ajax({ 1442 url: jsonUrl, 1443 type: "GET", 1444 dataType: "json", 1445 cache: false 1446 }).done(function (data) { 1447 var persisted = data && data.highlightedComparisonItem; 1448 debug("loadPersistedHighlightedValue:response", { 1449 persisted: persisted 1450 }); 1451 if (persisted !== undefined && persisted !== null && persisted !== "" && persisted !== "none") { 1452 highlightedResourceValue = persisted.toString(); 1453 initialHighlightedValue = highlightedResourceValue; 1454 } 1455 }).always(function () { 1456 highlightedResourceFetchInProgress = false;
1457 highlightedResourceFetchDone = true; 1458 debug("loadPersistedHighlightedValue:done", { 1459 highlightedResourceValue: highlightedResourceValue, 1460 highlightedResourceFetchDone: highlightedResourceFetchDone 1461 }); 1462 debounceSync($context); 1463 }); 1464} 1465 1466function bindHighlightedChangePersistence(sel) { 1467 if (!sel || sel._cbHighlightedPersistBound) { 1468 return; 1469 } 1470 1471 sel._cbHighlightedPersistBound = true; 1472 1473 $(sel).on("change.comparisonBlockDialog", function () { 1474 persistHighlightedSelection(sel); 1475 initialHighlightedValue = sel.value || "none"; 1476 debug("highlighted:change", { 1477 value: sel.value 1478 }); 1479 }); 1480} 1481 1482function bindDialogSubmitPersistence(context) { 1483 var $context = getDialogContext(context); 1484 var $form = $context.find("form.foundation-form").first(); 1485 1486 if (!$form.length || $form.data("cbSubmitPersistBound")) { 1487 return; 1488 } 1489 1490 $form.data("cbSubmitPersistBound", true); 1491 1492 $form.on("submit.comparisonBlockDialog", function () { 1493 enforceComparisonItemLimit($context, false); 1494 var $sel = $context.find(".highlighted-comparison-select coral-select").first(); 1495 if ($sel.length) { 1496 persistHighlightedSelection($sel[0]); 1497 debug("highlighted:submit", { 1498 value: $sel[0].value 1499 }); 1500 } 1501 }); 1502} 1503 1504function persistHighlightedSelection(sel) { 1505 if (!sel) { 1506 return; 1507 } 1508 1509 var value = (sel.value || "none").toString(); 1510 var fieldApi = $(sel).adaptTo && $(sel).adaptTo("foundation-field"); 1511 1512 if (fieldApi && fieldApi.setValue) { 1513 fieldApi.setValue(value); 1514 } 1515 1516 sel.setAttribute("value", value); 1517 1518 var $hidden = getHighlightedHiddenInput(sel); 1519 if ($hidden.length) { 1520 $hidden.val(value); 1521 } 1522} 1523 1524function isDebugEnabled() { 1525 try { 1526 var search = window.location && window.location.search ? window.location.search : ""; 1527 return search.indexOf("cbdebug=1") !== -1 || window.localStorage.getItem("comparisonBlockDebug") === "1"; 1528 } catch (e) { 1529 return false; 1530 } 1531} 1532 1533function debug(step, data) { 1534 if (!debugEnabled || !window.console || !console.log) { 1535 return; 1536 } 1537 1538 console.log("[comparison-block-dialog] " + step, data || {}); 1539} 1540 1541 function itemCount($mf) { 1542 return $mf.find("coral-multifield-item").length; 1543 } 1544 1545 function getComparisonItemsCount($mfWrapper) { 1546 var $coralMF = getCoralMF($mfWrapper); 1547 if (!$coralMF.length) { 1548 return 0; 1549 } 1550 1551 return $coralMF.children("coral-multifield-item").length; 1552 } 1553 1554 function enforceComparisonItemLimit(context, showWarning) { 1555 if (enforcingComparisonLimit) { 1556 return; 1557 } 1558 1559 var $context = getDialogContext(context || document); 1560 var $comparisonItemsMF = $(".comparison-items-multifield", $context).first(); 1561 var $coralMF; 1562 var $items; 1563 1564 if (!$comparisonItemsMF.length) { 1565 return; 1566 } 1567 1568 $coralMF = getCoralMF($comparisonItemsMF); 1569 if (!$coralMF.length) { 1570 return; 1571 } 1572 1573 $items = $coralMF.children("coral-multifield-item"); 1574 if ($items.length <= comparisonItemsLimit) { 1575 return; 1576 } 1577 1578 enforcingComparisonLimit = true; 1579 try { 1580 while ($items.length > comparisonItemsLimit) { 1581 $items.last().remove(); 1582 $items = $coralMF.children("coral-multifield-item"); 1583 } 1584 1585 refreshComparisonLabels($comparisonItemsMF); 1586 1587 if (showWarning) { 1588 showComparisonLimitMessage(); 1589 } 1590 } finally { 1591 enforcingComparisonLimit = false; 1592 } 1593 } 1594 1595 function showComparisonLimitMessage() { 1596 var ui = $(window).adaptTo && $(window).adaptTo("foundation-ui"); 1597 if (!ui || !ui.alert) { 1598 return; 1599 } 1600 1601 ui.alert("Warning", "Maximum 5 Comparison items are allowed!", "notice"); 1602 } 1603 1604 } 1605 1606 if (typeof Granite !== "undefined") { 1607 // Start initialization 1608 var isCision = window.location.href.includes("/content/cision/us"); 1609 var projectMeta = document.querySelector('meta[name="project-name-revamp"]'); 1610 if (isCision === true || projectMeta != null) { 1611 init(); 1612 } 1613 1614 } else { 1615 document.addEventListener("DOMContentLoaded", init); 1616 } 1617 1618})(document); 1619 1620 1621/** 1622 * Fix for multiCity Event Configuration radio buttons to display horizontally 1623 * in both page properties dialog and Create Page wizard. 1624 * 1625 * Create Page wizard doesn't load dialog-specific clientlibs, so this fix 1626 * must be in a globally-loaded clientlib like clientlib-showhide. 1627 */ 1628(function(document) { 1629 "use strict"; 1630 1631 function applyHorizontalLayoutToEventDateRadios() { 1632 var radios = document.querySelectorAll('coral-radio[name="./eventDateType"]'); 1633 1634 if (radios && radios.length > 0) { 1635 radios.forEach(function(radio) { 1636 radio.style.display = 'inline-block'; 1637 radio.style.marginRight = '24px'; 1638 radio.style.verticalAlign = 'middle'; 1639 }); 1640 } 1641 } 1642
1643 function init() { 1644 // Only run in AEM authoring environment where Coral is available 1645 if (typeof Coral === 'undefined') { 1646 return; 1647 } 1648 1649 // Apply on initial load 1650 applyHorizontalLayoutToEventDateRadios(); 1651 1652 // Apply when tabs/panels change (for multi-tab dialogs) 1653 document.addEventListener('coral-tab-panel:change', function() { 1654 setTimeout(applyHorizontalLayoutToEventDateRadios, 100); 1655 }); 1656 1657 // Apply when Coral components are attached (lazy-loaded dialogs) 1658 document.addEventListener('coral-component:attached', function(event) { 1659 if (event.detail && event.detail.tagName === 'CORAL-RADIO') { 1660 var radio = event.detail; 1661 if (radio.getAttribute('name') === './eventDateType') { 1662 radio.style.display = 'inline-block'; 1663 radio.style.marginRight = '24px'; 1664 radio.style.verticalAlign = 'middle'; 1665 } 1666 } 1667 }); 1668 } 1669 1670 if (typeof Granite !== "undefined") { 1671 // Start initialization 1672 var isCision = window.location.href.includes("/content/cision/us"); 1673 var projectMeta = document.querySelector('meta[name="project-name-revamp"]'); 1674 if (isCision === true || projectMeta != null) { 1675 init(); 1676 } 1677 } else { 1678 document.addEventListener("DOMContentLoaded", init); 1679 } 1680 1681})(document); 1682
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.