PageSourceSearch

https://ashmolean.org/sites/all/modules/contrib/chosen/chosen.js?v=1.1.0

js ashmolean.org collected 2026-09-24 08:37:26 UTC 2,609 bytes, 71 lines download raw bytes

1/**
2 * @file
3 * Attaches behaviors for the Chosen module.
4 */
5
6(function($) {
7  Drupal.behaviors.chosen = {
8    attach: function(context, settings) {
9      settings.chosen = settings.chosen || Drupal.settings.chosen;
10
11      // Prepare selector and add unwantend selectors.
12      var selector = settings.chosen.selector;
13
14      // Function to prepare all the options together for the chosen() call.
15      var getElementOptions = function (element) {
16        var options = $.extend({}, settings.chosen.options);
17
18        // The width default option is considered the minimum width, so this
19        // must be evaluated for every option.
20        if (settings.chosen.minimum_width > 0) {
21          if ($(element).width() < settings.chosen.minimum_width) {
22            options.width = settings.chosen.minimum_width + 'px';
23          }
24          else {
25            options.width = $(element).width() + 'px';
26          }
27        }
28
29        // Some field widgets have cardinality, so we must respect that.
30        // @see chosen_pre_render_select()
31        if ($(element).attr('multiple') && $(element).data('cardinality')) {
32          options.max_selected_options = $(element).data('cardinality');
33        }
34
35        return options;
36      };
37
38      // Process elements that have opted-in for Chosen.
39      // @todo Remove support for the deprecated chosen-widget class.
40      $('select.chosen-enable, select.chosen-widget', context).once('chosen', function() {
41        options = getElementOptions(this);
42        $(this).chosen(options);
43      });
44
45      $(selector, context)
46        // Disabled on:
47        // - Field UI
48        // - WYSIWYG elements
49        // - Tabledrag weights
50        // - Elements that have opted-out of Chosen
51        // - Elements already processed by Chosen.
52        .not('#field-ui-field-overview-form select, #field-ui-display-overview-form select, .wysiwyg, .draggable select[name$="[weight]"], .draggable select[name$="[position]"], .chosen-disable, .chosen-processed')
53        .filter(function() {
54          // Filter out select widgets that do not meet the minimum number of
55          // options.
56          var minOptions = $(this).attr('multiple') ? settings.chosen.minimum_multiple : settings.chosen.minimum_single;
57          if (!minOptions) {
58            // Zero value means no minimum.
59            return true;
60          }
61          else {
62            return $(this).find('option').length >= minOptions;
63          }
64        })
65        .once('chosen', function() {
66          options = getElementOptions(this);
67          $(this).chosen(options);
68        });
69    }
70  };
71})(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.