PageSourceSearch

https://laixebacha.com/sites/all/themes/bootstrap/js/modules/ctools/js/modal.js?tbzjzs

js laixebacha.com collected 2026-10-05 07:36:45 UTC 5,113 bytes, 150 lines download raw bytes

1/**
2 * @file
3 *
4 * Overrides for ctools modal.
5 *
6 */
7
8(function ($) {
9  /**
10   * Override CTools modal show function so it can recognize the Bootstrap modal classes correctly
11   */
12  Drupal.CTools.Modal.show = function(choice) {
13    var opts = {};
14
15    if (choice && typeof choice === 'string' && Drupal.settings[choice]) {
16      // This notation guarantees we are actually copying it.
17      $.extend(true, opts, Drupal.settings[choice]);
18    }
19    else if (choice) {
20      $.extend(true, opts, choice);
21    }
22
23    var defaults = {
24      modalTheme: 'CToolsModalDialog',
25      throbberTheme: 'CToolsModalThrobber',
26      animation: 'show',
27      animationSpeed: 'fast',
28      modalSize: {
29        type: 'scale',
30        width: 0.8,
31        height: 0.8,
32        addWidth: 0,
33        addHeight: 0,
34        // How much to remove from the inner content to make space for the
35        // theming.
36        contentRight: 25,
37        contentBottom: 45
38      },
39      modalOptions: {
40        opacity: 0.55,
41        background: '#fff'
42      },
43      modalClass: 'default'
44    };
45
46    var settings = {};
47    $.extend(true, settings, defaults, Drupal.settings.CToolsModal, opts);
48
49    if (Drupal.CTools.Modal.currentSettings && Drupal.CTools.Modal.currentSettings !== settings) {
50      Drupal.CTools.Modal.modal.remove();
51      Drupal.CTools.Modal.modal = null;
52    }
53
54    Drupal.CTools.Modal.currentSettings = settings;
55
56    var resize = function(e) {
57      // When creating the modal, it actually exists only in a theoretical
58      // place that is not in the DOM. But once the modal exists, it is in the
59      // DOM so the context must be set appropriately.
60      var context = e ? document : Drupal.CTools.Modal.modal;
61      var width = 0;
62      var height = 0;
63
64      //  Handle fixed navbars. Grab the body top offset in pixels.
65      var topOffset = parseInt($('body').css("padding-top"), 10);
66
67      if (Drupal.CTools.Modal.currentSettings.modalSize.type === 'scale') {
68        width = $(window).width() * Drupal.CTools.Modal.currentSettings.modalSize.width;
69        height = ($(window).height() - topOffset) * Drupal.CTools.Modal.currentSettings.modalSize.height;
70      }
71      else {
72        width = Drupal.CTools.Modal.currentSettings.modalSize.width;
73        height = Drupal.CTools.Modal.currentSettings.modalSize.height;
74      }
75
76      // Add padding for the offset.
77      $('#modalContent').css('padding-top', topOffset + 'px');
78
79      // Use the additionol pixels for creating the width and height.
80      $('div.ctools-modal-dialog', context).css({
81        'width': width + Drupal.CTools.Modal.currentSettings.modalSize.addWidth + 'px',
82        'height': height + Drupal.CTools.Modal.currentSettings.modalSize.addHeight + 'px'
83      });
84
85      $('div.ctools-modal-dialog .modal-body', context).css({
86        'width': (width - Drupal.CTools.Modal.currentSettings.modalSize.contentRight) + 'px',
87        'max-height': (height - Drupal.CTools.Modal.currentSettings.modalSize.contentBottom) + 'px'
88      });
89    };
90
91    if (!Drupal.CTools.Modal.modal) {
92      Drupal.CTools.Modal.modal = $(Drupal.theme(settings.modalTheme));
93      if (settings.modalSize.type === 'scale') {
94        $(window).bind('resize', resize);
95      }
96    }
97
98    $('body').addClass('modal-open');
99
100    resize();
101
102    $('.modal-title', Drupal.CTools.Modal.modal).html(Drupal.CTools.Modal.currentSettings.loadingText);
103    Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, settings.modalOptions, settings.animation, settings.animationSpeed, settings.modalClass);
104    $('#modalContent .modal-body').html(Drupal.theme(settings.throbberTheme)).addClass('ctools-modal-loading');
105  };
106
107  /**
108   * Remove modal class from body when closing modal.
109   */
110  $(document).on('CToolsDetachBehaviors', function() {
111    $('body').removeClass('modal-open');
112  });
113
114  /**
115   * Provide the HTML to create the modal dialog in the Bootstrap style.
116   */
117  Drupal.theme.prototype.CToolsModalDialog = function () {
118    var html = '';
119    html += '<div id="ctools-modal">';
120    html += '  <div class="ctools-modal-dialog modal-dialog">';
121    html += '    <div class="modal-content">';
122    html += '      <div class="modal-header">';
123    html += '        <button type="button" class="close ctools-close-modal" aria-hidden="true">&times;</button>';
124    html += '        <h4 id="modal-title" class="modal-title">&nbsp;</h4>';
125    html += '      </div>';
126    html += '      <div id="modal-content" class="modal-body">';
127    html += '      </div>';
128    html += '    </div>';
129    html += '  </div>';
130    html += '</div>';
131
132    return html;
133  };
134
135  /**
136   * Provide the HTML to create a nice looking loading progress bar.
137   */
138  Drupal.theme.prototype.CToolsModalThrobber = function () {
139    var html = '';
140    html += '<div class="loading-spinner" style="width: 200px; margin: -20px 0 0 -100px; position: absolute; top: 45%; left: 50%">';
141    html += '  <div class="progress progress-striped active">';
142    html += '    <div class="progress-bar" style="width: 100%;"></div>';
143    html += '  </div>';
144    html += '</div>';
145
146    return html;
147  };
148
149
150})(jQuery);

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.