PageSourceSearch

https://www.abracadacraft.com/assets/www.abracadacraft.com/sites/all/modules/views/js/dependent-2e7d2c03a9.js

js abracadacraft.com collected 2026-10-03 21:22:04 UTC 7,958 bytes, 227 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opener = _____WB$wombat$assign$function_____("opener");
10/**
11 * @file dependent.js
12 *
13 * Written by dmitrig01 (Dmitri Gaskin) for Views; this provides dependent
14 * visibility for form items in Views' ajax forms.
15 *
16 * To your $form item definition add:
17 * - '#process' => array('views_process_dependency'),
18 * - Add '#dependency' => array('id-of-form-item' => array(list, of, values, that,
19     make, this, item, show),
20 *
21 * Special considerations:
22 * - radios are harder. Because Drupal doesn't give radio groups individual ids,
23 *   use 'radio:name-of-radio'
24 *
25 * - Checkboxes don't have their own id, so you need to add one in a div
26 *   around the checkboxes via #prefix and #suffix. You actually need to add TWO
27 *   divs because it's the parent that gets hidden. Also be sure to retain the
28 *   'expand_checkboxes' in the #process array, because the views process will
29 *   override it.
30 */
31
32Drupal.Views = Drupal.Views || {};
33
34Drupal.Views.dependent = { bindings: {}, activeBindings: {}, activeTriggers: [] };
35
36Drupal.Views.dependent.inArray = function(array, search_term) {
37  var i = array.length;
38  if (i > 0) {
39   do {
40    if (array[i] == search_term) {
41       return true;
42    }
43   } while (i--);
44  }
45  return false;
46}
47
48
49Drupal.Views.dependent.autoAttach = function() {
50  // Clear active bindings and triggers.
51  for (i in Drupal.Views.dependent.activeTriggers) {
52    jQuery(Drupal.Views.dependent.activeTriggers[i]).unbind('change');
53  }
54  Drupal.Views.dependent.activeTriggers = [];
55  Drupal.Views.dependent.activeBindings = {};
56  Drupal.Views.dependent.bindings = {};
57
58  if (!Drupal.settings.viewsAjax) {
59    return;
60  }
61
62  // Iterate through all relationships
63  for (id in Drupal.settings.viewsAjax.formRelationships) {
64
65    // Drupal.Views.dependent.activeBindings[id] is a boolean,
66    // whether the binding is active or not.  Defaults to no.
67    Drupal.Views.dependent.activeBindings[id] = 0;
68    // Iterate through all possible values
69    for(bind_id in Drupal.settings.viewsAjax.formRelationships[id].values) {
70      // This creates a backward relationship.  The bind_id is the ID
71      // of the element which needs to change in order for the id to hide or become shown.
72      // The id is the ID of the item which will be conditionally hidden or shown.
73      // Here we're setting the bindings for the bind
74      // id to be an empty array if it doesn't already have bindings to it
75      if (!Drupal.Views.dependent.bindings[bind_id]) {
76        Drupal.Views.dependent.bindings[bind_id] = [];
77      }
78      // Add this ID
79      Drupal.Views.dependent.bindings[bind_id].push(id);
80      // Big long if statement.
81      // Drupal.settings.viewsAjax.formRelationships[id].values[bind_id] holds the possible values
82
83      if (bind_id.substring(0, 6) == 'radio:') {
84        var trigger_id = "input[name='" + bind_id.substring(6) + "']";
85      }
86      else {
87        var trigger_id = '#' + bind_id;
88      }
89
90      Drupal.Views.dependent.activeTriggers.push(trigger_id);
91
92      if (jQuery(trigger_id).attr('type') == 'checkbox') {
93        $(trigger_id).parent().addClass('hidden-options');
94      }
95
96      var getValue = function(item, trigger) {
97        if (item.substring(0, 6) == 'radio:') {
98          var val = jQuery(trigger + ':checked').val();
99        }
100        else {
101          switch (jQuery(trigger).attr('type')) {
102            case 'checkbox':
103              var val = jQuery(trigger).attr('checked') || 0;
104
105              if (val) {
106                $(trigger).parent().removeClass('hidden-options').addClass('expanded-options');
107              }
108              else {
109                $(trigger).parent().removeClass('expanded-options').addClass('hidden-options');
110              }
111
112              break;
113            default:
114              var val = jQuery(trigger).val();
115          }
116        }
117        return val;
118      }
119
120      var setChangeTrigger = function(trigger_id, bind_id) {
121        // Triggered when change() is clicked.
122        var changeTrigger = function() {
123          var val = getValue(bind_id, trigger_id);
124
125          for (i in Drupal.Views.dependent.bindings[bind_id]) {
126            var id = Drupal.Views.dependent.bindings[bind_id][i];
127
128            // Fix numerous errors
129            if (typeof id != 'string') {
130              continue;
131            }
132
133            // This bit had to be rewritten a bit because two properties on the
134            // same set caused the counter to go up and up and up.
135            if (!Drupal.Views.dependent.activeBindings[id]) {
136              Drupal.Views.dependent.activeBindings[id] = {};
137            }
138
139            if (Drupal.Views.dependent.inArray(Drupal.settings.viewsAjax.formRelationships[id].values[bind_id], val)) {
140              Drupal.Views.dependent.activeBindings[id][bind_id] = 'bind';
141            }
142            else {
143              delete Drupal.Views.dependent.activeBindings[id][bind_id];
144            }
145
146            var len = 0;
147            for (i in Drupal.Views.dependent.activeBindings[id]) {
148              len++;
149            }
150
151            var object = jQuery('#' + id + '-wrapper');
152            if (!object.size()) {
153              object = jQuery('#' + id).parent();
154            }
155
156            var rel_num = Drupal.settings.viewsAjax.formRelationships[id].num;
157            if (typeof rel_num === 'object') {
158              rel_num = Drupal.settings.viewsAjax.formRelationships[id].num[0];
159            }
160
161            if (rel_num <= len) {
162              // Show if the element if criteria is matched
163              object.show(0);
164              object.addClass('dependent-options');
165            }
166            else {
167              // Otherwise hide
168              object.hide(0);
169            }
170          }
171        }
172
173        jQuery(trigger_id).change(function() {
174          // Trigger the internal change function
175          // the attr('id') is used because closures are more confusing
176          changeTrigger(trigger_id, bind_id);
177        });
178        // Trigger initial reaction
179        changeTrigger(trigger_id, bind_id);
180      }
181      setChangeTrigger(trigger_id, bind_id);
182    }
183  }
184}
185
186Drupal.behaviors.viewsDependent = function (context) {
187  Drupal.Views.dependent.autoAttach();
188
189  // Really large sets of fields are too slow with the above method, so this
190  // is a sort of hacked one that's faster but much less flexible.
191  $("select.views-master-dependent:not(.views-processed)")
192    .addClass('views-processed')
193    .change(function() {
194      var val = $(this).val();
195      if (val == 'all') {
196        $('.views-dependent-all').show(0);
197      }
198      else {
199        $('.views-dependent-all').hide(0);
200        $('.views-dependent-' + val).show(0);
201      }
202    })
203    .trigger('change');
204}
205
206}
207
208/*
209     FILE ARCHIVED ON 19:50:28 Sep 27, 2018 AND RETRIEVED FROM THE
210     INTERNET ARCHIVE ON 06:12:51 Sep 02, 2026.
211     JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
212
213     ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
214     SECTION 108(a)(3)).
215*/
216/*
217playback timings (ms):
218  captures_list: 0.44
219  exclusion.robots: 0.052
220  exclusion.robots.policy: 0.043
221  esindex: 0.005
222  cdx.remote: 29.836
223  LoadShardBlock: 253.338 (3)
224  PetaboxLoader3.datanode: 106.636 (4)
225  PetaboxLoader3.resolve: 144.954 (2)
226  load_resource: 260.856
227*/

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.