PageSourceSearch

https://www.cusquena.com/sites/g/files/seuoyk771/files/js/optimize…VPIPImhhsaHYgGvqcOsZdx-xxQGLtw.js?v=10.5.10

js cusquena.com collected 2026-09-26 10:04:37 UTC 3,746 bytes, 100 lines download raw bytes

1/* Source and licensing information for the line(s) below can be found at https://www.cusquena.com/modules/contrib/webform/js/webform.dialog.js. */
2/**
3 * @file
4 * JavaScript behaviors for webform dialogs.
5 */
6
7(function ($, Drupal, drupalSettings, once) {
8
9  'use strict';
10
11  // @see http://api.jqueryui.com/dialog/
12  Drupal.webform = Drupal.webform || {};
13  Drupal.webform.dialog = Drupal.webform.dialog || {};
14  Drupal.webform.dialog.options = Drupal.webform.dialog.options || {};
15
16  /**
17   * Programmatically open a webform (or page) in a dialog.
18   *
19   * @param {string} url
20   *   Webform URL.
21   * @param {string} type
22   *   Webform dialog type defined via /admin/structure/webform/config.
23   */
24  Drupal.webformOpenDialog = function (url, type) {
25    // Create a div with link but don't attach it to the page.
26    var $div = $('<div><a href="' + url + '" class="webform-dialog ' + type + '"></a></div>');
27    // Init the webform dialog behavior.
28    Drupal.behaviors.webformDialog.attach($div.get(0));
29    // Trigger the link.
30    $div.find('a').trigger('click');
31  };
32
33  /**
34   * Open webform dialog using preset options.
35   *
36   * @type {Drupal~behavior}
37   */
38  Drupal.behaviors.webformDialog = {
39    attach: function (context) {
40      $(once('webform-dialog', 'a.webform-dialog', context)).each(function () {
41        var $a = $(this);
42
43        // Get default options.
44        var options = $.extend({}, Drupal.webform.dialog.options);
45
46        // Get preset dialog options.
47        if ($a.attr('class').match(/webform-dialog-([a-z0-9_]+)/)) {
48          var dialogOptionsName = RegExp.$1;
49          if (drupalSettings.webform.dialog.options[dialogOptionsName]) {
50            options = drupalSettings.webform.dialog.options[dialogOptionsName];
51
52            // Unset title.
53            delete options.title;
54          }
55        }
56
57        // Get custom dialog options.
58        if ($(this).data('dialog-options')) {
59          $.extend(options, $(this).data('dialog-options'));
60        }
61
62        var href = $a.attr('href');
63
64        // Replace ENTITY_TYPE and ENTITY_ID placeholders and update the href.
65        // @see webform_page_attachments()
66        if (href.indexOf('?source_entity_type=ENTITY_TYPE&source_entity_id=ENTITY_ID') !== -1) {
67          if (drupalSettings.webform.dialog.entity_type && drupalSettings.webform.dialog.entity_id) {
68            href = href.replace('ENTITY_TYPE', encodeURIComponent(drupalSettings.webform.dialog.entity_type));
69            href = href.replace('ENTITY_ID', encodeURIComponent(drupalSettings.webform.dialog.entity_id));
70          }
71          else {
72            href = href.replace('?source_entity_type=ENTITY_TYPE&source_entity_id=ENTITY_ID', '');
73          }
74          $a.attr('href', href);
75        }
76
77        // Append _webform_dialog=1 to href to trigger Ajax support.
78        // @see \Drupal\webform\WebformSubmissionForm::setEntity
79        href += (href.indexOf('?') === -1 ? '?' : '&') + '_webform_dialog=1';
80
81        var element_settings = {};
82        element_settings.progress = {type: 'fullscreen'};
83        element_settings.url = href;
84        element_settings.event = 'touchstart click';
85        element_settings.dialogType = $a.data('dialog-type') || 'modal';
86        element_settings.dialog = options;
87        element_settings.element = this;
88        element_settings.error = function error(xmlhttp, uri) {
89          if (xmlhttp.status === 403) {
90            window.location.replace(href.split('?')[0]);
91          }
92        };
93        Drupal.ajax(element_settings);
94      });
95    }
96  };
97
98})(jQuery, Drupal, drupalSettings, once);
99
100/* Source and licensing information for the above line(s) can be found at https://www.cusquena.com/modules/contrib/webform/js/webform.dialog.js. */

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.