PageSourceSearch

https://www.aai.aero/sites/all/modules/contrib/jquery_ui_filter/dialog/jquery_ui_filter_dialog.js?tlt3ob

js aai.aero collected 2026-09-24 09:02:59 UTC 5,928 bytes, 182 lines download raw bytes

1(function ($) {
2
3Drupal.jQueryUiFilter = Drupal.jQueryUiFilter || {}
4Drupal.jQueryUiFilter.dialogOptions = Drupal.jQueryUiFilter.dialogOptions || {closeText : 'close'}
5
6// Set default dialog query parameter.
7var match = /dialogFeatures=([^&]+)/.exec(location.search);
8Drupal.jQueryUiFilter.dialogOptions.dialogFeatures = ((match) ? match[1] : {});
9
10/**
11 * Reload page with uuid to insure cache is cleared
12 */
13Drupal.jQueryUiFilter.dialogReloadPage = function() {
14  top.location.href = top.location.pathname +
15    ((top.location.search) ? top.location.search + '&' : '?') +
16    'no-cache=' + ((new Date().getTime()) * Math.random(10));
17
18  // Close dialog so that the user sees something has happened.
19  $('#jquery-ui-filter-dialog').dialog('destroy');
20}
21
22/**
23 * Convert dialogFeatures array to string.
24 */
25Drupal.jQueryUiFilter.dialogFeaturesToString = function(dialogFeatures) {
26  if (typeof dialogFeatures == 'string') {
27    return dialogFeatures;
28  }
29
30  dialogFeatures['protocol'] = location.protocol.replace(':', '');
31
32  var features = [];
33  for(var name in dialogFeatures) {
34    features[features.length] = name + '=' + dialogFeatures[name];
35  }
36  return features.join(',');
37}
38
39/**
40 * Append to dialogFeatures to URL query string via '?dialogFeatures=1' or '?dialogFeatures=form-onsubmit_close=1'.
41 */
42Drupal.jQueryUiFilter.dialogFeaturesAppendToURL = function(url, dialogFeatures) {
43  if (url.indexOf('dialogFeatures') !== -1) {
44    return url;
45  }
46
47  dialogFeatures = dialogFeatures || Drupal.jQueryUiFilter.dialogOptions.dialogFeatures;
48  dialogFeatures = Drupal.jQueryUiFilter.dialogFeaturesToString(dialogFeatures);
49
50  var query = ((url.indexOf('?') === -1) ? '?' : '&') + 'dialogFeatures=' + dialogFeatures;
51  if (url.indexOf('#') !== -1) {
52    return url.replace('#', query + '#');
53  }
54  else {
55    return url + query;
56  }
57}
58
59/**
60 * Open jQuery UI filter dialog. Allows other modules to re-use this functionality.
61 */
62Drupal.jQueryUiFilter.dialogOpen = function(url, options) {
63  // Check url against whitelist
64  if (url.indexOf('://') !== -1) {
65    var domain = url.match(/:\/\/(.[^/]+)/)[1];
66    var whitelist = Drupal.settings.jQueryUiFilter.dialogWhitelist.split(/\s+/);
67    whitelist[whitelist.length] = location.hostname; // Always add custom host
68    if (jQuery.inArray(domain, whitelist) == -1) {
69      window.location = url;
70      return;
71    }
72  }
73
74  // Initialize options with dialogFeatures.
75  options = jQuery.extend(
76    {dialogFeatures: {}},
77    $.ui.dialog.prototype.options,
78    options
79  );
80
81  // Destroy dialog when it is closed.
82  options['close'] = function(event, ui) {
83    $(this).dialog('destroy').remove();
84  }
85
86  // Automatically adjust iframe height based on window settings.
87  var windowHeight = $(window).height() - 50;
88  var windowWidth = $(window).width() - 50;
89  if (options['height'] == 'auto') {
90    options['height'] = options['maxHeight'] || windowHeight;
91  }
92  if (options['width'] == 'auto') {
93    options['width'] = options['maxWidth'] || windowWidth;
94  }
95
96  // Make sure dialog is not larger then the viewport.
97  if (options['height'] > windowHeight) {
98    options['height'] = windowHeight;
99  }
100  if (options['width'] > windowWidth) {
101    options['width'] = windowWidth;
102  }
103
104  // Add close button to dialog
105  if (options['closeButton']) {
106    options['buttons'][ Drupal.t(options['closeText'] || 'Close') ] = function() {
107      $(this).dialog('close');
108    }
109  }
110  delete options['closeButton'];
111
112  // Set iframe scrolling attribute.
113  options['scrolling'] = options['scrolling'] || 'auto';
114
115  // Set dialog URL with ?dialogFeature= parameters.
116  url = Drupal.jQueryUiFilter.dialogFeaturesAppendToURL(url, options['dialogFeatures']);
117
118  // Remove existing dialog and iframe, this allows us to reset the
119  // dialog's options and allow dialogs to open external domains.
120  $('#jquery-ui-filter-dialog').dialog('destroy').remove();
121
122  // Create iframe
123  $('body').append('<div id="jquery-ui-filter-dialog">'
124    + '<div id="jquery-ui-filter-dialog-container">'
125    + '<iframe id="jquery-ui-filter-dialog-iframe" name="jquery-ui-filter-dialog-iframe" width="100%" height="100%" marginWidth="0" marginHeight="0" frameBorder="0" scrolling="' + options['scrolling'] + '" src="' + url + '" />'
126    + '</div>'
127    + '</div>'
128  );
129
130  // Open dialog
131  $('#jquery-ui-filter-dialog').dialog(options);
132
133  // DEBUG:
134  // console.log(options);
135}
136
137/**
138 * jQuery UI filter dialog behavior
139 */
140Drupal.behaviors.jQueryUiFilterDialog = {attach: function(context) {
141  if (Drupal.settings.jQueryUiFilter.disabled) {
142    return;
143  }
144
145  // Append ?jquery_ui_filter_dialog=1 to all link and form action inside a dialog iframe with dialogFeatures.
146  if ((top != self) && (self.location.search.indexOf('dialogFeatures') !== -1)) {
147    $('a', context).once('jquery-ui-filter-dialog-link', function() {
148      if (this.tagName == 'A') {
149        this.href = Drupal.jQueryUiFilter.dialogFeaturesAppendToURL(this.href);
150      }
151      else if (this.tagName == 'FORM') {
152        this.action = Drupal.jQueryUiFilter.dialogFeaturesAppendToURL(this.action);
153      }
154    });
155
156    // Do not allow dialogs to be nested inside of dialogs.
157    return;
158  }
159
160  $('a.jquery-ui-filter-dialog', context).once('jquery-ui-filter-dialog', function () {
161    $(this).click(function() {
162      // Get hidden JSON string that has been cleaned up on the server using PHP.
163      // See _jquery_ui_filter_dialog_process_replacer().
164      var json  = $(this).attr('rel');
165      if (json) {
166        var options = Drupal.jQueryUiFilter.getOptions('dialog', JSON.parse(unescape(json)));
167      }
168      else {
169        var options = Drupal.jQueryUiFilter.getOptions('dialog', {});
170      }
171      // Customize dialog using the link's title.
172      if ($(this).attr('title')) {
173        options['title'] = $(this).attr('title');
174      }
175
176      Drupal.jQueryUiFilter.dialogOpen(this.href, options);
177      return false;
178    });
179  });
180}}
181
182})(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.