PageSourceSearch

https://amcham.co.za/themes/EventBank/js/select2.multi-checkboxes.js?tkgx89

js amcham.co.za collected 2026-09-28 10:07:09 UTC 2,102 bytes, 69 lines download raw bytes

1/**
2 * jQuery Select2 Multi checkboxes
3 * - allow to select multi values via normal dropdown control
4 * 
5 * author      : wasikuss
6 * repo        : https://github.com/wasikuss/select2-multi-checkboxes
7 * inspired by : https://github.com/select2/select2/issues/411
8 * License     : MIT
9 */
10(function($) {
11  var S2MultiCheckboxes = function(options, element) {
12    var self = this;
13    self.options = options;
14    self.$element = $(element);
15	var values = self.$element.val();
16    self.$element.removeAttr('multiple');
17    self.select2 = self.$element.select2({
18      allowClear: true,
19      minimumResultsForSearch: -1,
20      placeholder: options.placeholder,
21      closeOnSelect: false,
22      templateSelection: function() {
23        return self.options.templateSelection(self.$element.val() || [], $('option', self.$element).length);
24      },
25      templateResult: function(result) {
26        if (result.loading !== undefined)
27          return result.text;
28        return $('<div>').text(result.text).addClass(self.options.wrapClass);
29      }
30    }).data('select2');
31    self.select2.$results.off("mouseup").on("mouseup", ".select2-results__option[aria-selected]", (function(self) {
32      return function(evt) {
33        var $this = $(this);
34
35        var data = $this.data('data');
36
37        if ($this.attr('aria-selected') === 'true') {
38          self.trigger('unselect', {
39            originalEvent: evt,
40            data: data
41          });
42          return;
43        }
44
45        self.trigger('select', {
46          originalEvent: evt,
47          data: data
48        });
49      }
50    })(self.select2));
51    self.$element.attr('multiple', 'multiple').val(values).trigger('change.select2');
52  }
53
54  $.fn.extend({
55    select2MultiCheckboxes: function() {
56      var options = $.extend({
57        placeholder: 'Choose elements',
58        templateSelection: function(selected, total) {
59          return selected.length + ' > ' + total + ' total';
60        },
61        wrapClass: 'wrap'
62      }, arguments[0]);
63
64      this.each(function() {
65        new S2MultiCheckboxes(options, this);
66      });
67    }
68  });
69})(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.