MediaWiki:Common.js/BootstrapMultiselect.js

From CODECS Dev

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
//https://www.simplegov.com/bootstrap-multiselect.js

// Bootstrap multiselect
function setupBootstrapMultiselect() {

	if ($('select.multiselect')[0]) {
		$.getScript("/dev/custom/js/bootstrap4-multiselect.js").done(function() {

		if ($('select.multiselect')[0]) {
			$('select.multiselect').each(function(index) {

			var buttonClass = $(this).attr("data-buttonclass");
			var nonSelectedText = $(this).attr("data-nonselectedtext");
			var numberDisplayed = $(this).attr("data-numberdisplayed");
			var filterPlaceholder = $(this).attr("data-filterplaceholder");
			//var iconClass = $(this).attr("data-iconclass");

			$(this).multiselect({
			  enableFiltering: true,
			  enableCaseInsensitiveFiltering: true,
			  filterPlaceholder: filterPlaceholder,
			  includeSelectAllOption: true,
			  buttonClass: buttonClass,
			  nonSelectedText: nonSelectedText,
			  maxHeight: 400,
			  buttonWidth: '100%',
			  numberDisplayed: numberDisplayed,
			  enableHTML: true,
			  optionLabel: function(element) {
			    return $(element).html();
			  },
			  enableCollapsibleOptGroups: true
			});
        });
      }
    });
  }
  
}