{"version":3,"file":"bootstrap-select.min.js","sources":["https:\/\/udl.id\/theme\/remui\/amd\/src\/bootstrap-select.js"],"sourcesContent":["\/* eslint-disable *\/\n\/\/ This file is part of Moodle - http:\/\/moodle.org\/\n\/\/\n\/\/ Moodle is free software: you can redistribute it and\/or modify\n\/\/ it under the terms of the GNU General Public License as published by\n\/\/ the Free Software Foundation, either version 3 of the License, or\n\/\/ (at your option) any later version.\n\/\/\n\/\/ Moodle is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU General Public License\n\/\/ along with Moodle. If not, see .\n\/*!\n * Bootstrap-select v1.12.4 (http:\/\/silviomoreto.github.io\/bootstrap-select)\n *\n * Copyright 2013-2017 bootstrap-select\n * Licensed under MIT (https:\/\/github.com\/silviomoreto\/bootstrap-select\/blob\/master\/LICENSE)\n *\/\n\"use strict\";\ndefine([\"jquery\"], function(jQuery) {\n (function($) {\n 'use strict';\n if (!String.prototype.includes) {\n (function() {\n 'use strict'; \/\/ Needed to support `apply`\/`call` with `undefined`\/`null`.\n var toString = {}.toString;\n var defineProperty = (function() {\n \/\/ IE 8 only supports `Object.defineProperty` on DOM elements.\n try {\n var object = {};\n var $defineProperty = Object.defineProperty;\n var result = $defineProperty(object, object, object) && $defineProperty;\n } catch (error) {}\n return result;\n }());\n var indexOf = ''.indexOf;\n var includes = function(search) {\n if (this == null) {\n throw new TypeError();\n }\n var string = String(this);\n if (search && toString.call(search) == '[object RegExp]') {\n throw new TypeError();\n }\n var stringLength = string.length;\n var searchString = String(search);\n var searchLength = searchString.length;\n var position = arguments.length > 1 ? arguments[1] : undefined;\n \/\/ To Integer.\n var pos = position ? Number(position) : 0;\n if (pos != pos) { \/\/ Better `isNaN`.\n pos = 0;\n }\n var start = Math.min(Math.max(pos, 0), stringLength);\n \/\/ Avoid the `indexOf` call if no match is possible.\n if (searchLength + start > stringLength) {\n return false;\n }\n return indexOf.call(string, searchString, pos) != -1;\n };\n if (defineProperty) {\n defineProperty(String.prototype, 'includes', {\n 'value': includes,\n 'configurable': true,\n 'writable': true\n });\n } else {\n String.prototype.includes = includes;\n }\n }());\n }\n if (!String.prototype.startsWith) {\n (function() {\n 'use strict'; \/\/ Needed to support `apply`\/`call` with `undefined`\/`null`.\n var defineProperty = (function() {\n \/\/ IE 8 only supports `Object.defineProperty` on DOM elements.\n try {\n var object = {};\n var $defineProperty = Object.defineProperty;\n var result = $defineProperty(object, object, object) && $defineProperty;\n } catch (error) {}\n return result;\n }());\n var toString = {}.toString;\n var startsWith = function(search) {\n if (this == null) {\n throw new TypeError();\n }\n var string = String(this);\n if (search && toString.call(search) == '[object RegExp]') {\n throw new TypeError();\n }\n var stringLength = string.length;\n var searchString = String(search);\n var searchLength = searchString.length;\n var position = arguments.length > 1 ? arguments[1] : undefined;\n \/\/ To integer.\n var pos = position ? Number(position) : 0;\n if (pos != pos) { \/\/ Better `isNaN`.\n pos = 0;\n }\n var start = Math.min(Math.max(pos, 0), stringLength);\n \/\/ Avoid the `indexOf` call if no match is possible.\n if (searchLength + start > stringLength) {\n return false;\n }\n var index = -1;\n while (++index < searchLength) {\n if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {\n return false;\n }\n }\n return true;\n };\n if (defineProperty) {\n defineProperty(String.prototype, 'startsWith', {\n 'value': startsWith,\n 'configurable': true,\n 'writable': true\n });\n } else {\n String.prototype.startsWith = startsWith;\n }\n }());\n }\n if (!Object.keys) {\n Object.keys = function(\n o, \/\/ Object.\n k, \/\/ Key.\n r \/\/ Result array.\n ) {\n \/\/ Initialize object and result.\n r = [];\n \/\/ Iterate over object keys.\n for (k in o) {\n \/\/ Fill result array with non-prototypical keys.\n r.hasOwnProperty.call(o, k) && r.push(k);\n }\n \/\/ Return result.\n return r;\n };\n }\n \/\/ Set data-selected on select element if the value has been programmatically selected.\n \/\/ Prior to initialization of bootstrap-select.\n \/\/ Consider removing or replacing an alternative method.\n var valHooks = {\n useDefault: false,\n _set: $.valHooks.select.set\n };\n $.valHooks.select.set = function(elem, value) {\n if (value && !valHooks.useDefault) {\n $(elem).data('selected', true);\n }\n return valHooks._set.apply(this, arguments);\n };\n var changed_arguments = null;\n var EventIsSupported = (function() {\n try {\n new Event('change');\n return true;\n } catch (e) {\n return false;\n }\n })();\n $.fn.triggerNative = function(eventName) {\n var el = this[0],\n event;\n if (el.dispatchEvent) { \/\/ For modern browsers & IE9+.\n if (EventIsSupported) {\n \/\/ For modern browsers.\n event = new Event(eventName, {\n bubbles: true\n });\n } else {\n \/\/ For IE since it doesn't support Event constructor.\n event = document.createEvent('Event');\n event.initEvent(eventName, true, false);\n }\n el.dispatchEvent(event);\n } else if (el.fireEvent) { \/\/ For IE8.\n event = document.createEventObject();\n event.eventType = eventName;\n el.fireEvent('on' + eventName, event);\n } else {\n \/\/ Fall back to jQuery.trigger.\n this.trigger(eventName);\n }\n };\n \/\/ Case insensitive contains search.\n $.expr.pseudos.icontains = function(obj, index, meta) {\n var $obj = $(obj).find('a');\n var haystack = ($obj.data('tokens') || $obj.text()).toString().toUpperCase();\n return haystack.includes(meta[3].toUpperCase());\n };\n \/\/ Case insensitive begins search.\n $.expr.pseudos.ibegins = function(obj, index, meta) {\n var $obj = $(obj).find('a');\n var haystack = ($obj.data('tokens') || $obj.text()).toString().toUpperCase();\n return haystack.startsWith(meta[3].toUpperCase());\n };\n \/\/ Case and accent insensitive contains search.\n $.expr.pseudos.aicontains = function(obj, index, meta) {\n var $obj = $(obj).find('a');\n var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toString().toUpperCase();\n return haystack.includes(meta[3].toUpperCase());\n };\n \/\/ Case and accent insensitive begins search.\n $.expr.pseudos.aibegins = function(obj, index, meta) {\n var $obj = $(obj).find('a');\n var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toString().toUpperCase();\n return haystack.startsWith(meta[3].toUpperCase());\n };\n \/**\n * Remove all diatrics from the given text.\n * @access private\n * @param {String} text\n * @returns {String}\n *\/\n function normalizeToBase(text) {\n var rExps = [{\n re: \/[\\xC0-\\xC6]\/g,\n ch: \"A\"\n }, {\n re: \/[\\xE0-\\xE6]\/g,\n ch: \"a\"\n }, {\n re: \/[\\xC8-\\xCB]\/g,\n ch: \"E\"\n }, {\n re: \/[\\xE8-\\xEB]\/g,\n ch: \"e\"\n }, {\n re: \/[\\xCC-\\xCF]\/g,\n ch: \"I\"\n }, {\n re: \/[\\xEC-\\xEF]\/g,\n ch: \"i\"\n }, {\n re: \/[\\xD2-\\xD6]\/g,\n ch: \"O\"\n }, {\n re: \/[\\xF2-\\xF6]\/g,\n ch: \"o\"\n }, {\n re: \/[\\xD9-\\xDC]\/g,\n ch: \"U\"\n }, {\n re: \/[\\xF9-\\xFC]\/g,\n ch: \"u\"\n }, {\n re: \/[\\xC7-\\xE7]\/g,\n ch: \"c\"\n }, {\n re: \/[\\xD1]\/g,\n ch: \"N\"\n }, {\n re: \/[\\xF1]\/g,\n ch: \"n\"\n }];\n $.each(rExps, function() {\n text = text ? text.replace(this.re, this.ch) : '';\n });\n return text;\n }\n \/\/ List of HTML entities for escaping.\n var escapeMap = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n '`': '`'\n };\n var unescapeMap = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\",\n '`': '`'\n };\n \/\/ Functions for escaping and unescaping strings to\/from HTML interpolation.\n var createEscaper = function(map) {\n var escaper = function(match) {\n return map[match];\n };\n \/\/ Regexes for identifying a key that needs to be escaped.\n var source = '(?:' + Object.keys(map).join('|') + ')';\n var testRegexp = RegExp(source);\n var replaceRegexp = RegExp(source, 'g');\n return function(string) {\n string = string == null ? '' : '' + string;\n return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;\n };\n };\n var htmlEscape = createEscaper(escapeMap);\n var htmlUnescape = createEscaper(unescapeMap);\n var Selectpicker = function(element, options) {\n \/\/ Bootstrap-select has been initialized - revert valHooks.select.set back to its original function.\n if (!valHooks.useDefault) {\n $.valHooks.select.set = valHooks._set;\n valHooks.useDefault = true;\n }\n this.$element = $(element);\n this.$newElement = null;\n this.$button = null;\n this.$menu = null;\n this.$lis = null;\n this.options = options;\n \/\/ If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a data-attribute).\n if (this.options.title === null) {\n this.options.title = this.$element.attr('title');\n }\n \/\/ Format window padding.\n var winPad = this.options.windowPadding;\n if (typeof winPad === 'number') {\n this.options.windowPadding = [winPad, winPad, winPad, winPad];\n }\n \/\/ Expose public methods.\n this.val = Selectpicker.prototype.val;\n this.render = Selectpicker.prototype.render;\n this.refresh = Selectpicker.prototype.refresh;\n this.setStyle = Selectpicker.prototype.setStyle;\n this.selectAll = Selectpicker.prototype.selectAll;\n this.deselectAll = Selectpicker.prototype.deselectAll;\n this.destroy = Selectpicker.prototype.destroy;\n this.remove = Selectpicker.prototype.remove;\n this.show = Selectpicker.prototype.show;\n this.hide = Selectpicker.prototype.hide;\n this.init();\n };\n Selectpicker.VERSION = '1.12.4';\n \/\/ Part of this is duplicated in i18n\/defaults-en_US.js. Make sure to update both.\n Selectpicker.DEFAULTS = {\n noneSelectedText: 'Nothing selected',\n noneResultsText: 'No results matched {0}',\n countSelectedText: function(numSelected, numTotal) {\n return (numSelected == 1) ? \"{0} item selected\" : \"{0} items selected\";\n },\n maxOptionsText: function(numAll, numGroup) {\n return [\n (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)',\n (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)'\n ];\n },\n selectAllText: 'Select All',\n deselectAllText: 'Deselect All',\n doneButton: false,\n doneButtonText: 'Close',\n multipleSeparator: ', ',\n styleBase: 'btn',\n style: 'btn-default',\n size: 'auto',\n title: null,\n selectedTextFormat: 'values',\n width: false,\n container: false,\n hideDisabled: false,\n showSubtext: false,\n showIcon: true,\n showContent: true,\n dropupAuto: true,\n header: false,\n liveSearch: false,\n liveSearchPlaceholder: null,\n liveSearchNormalize: false,\n liveSearchStyle: 'contains',\n actionsBox: false,\n iconBase: 'glyphicon',\n tickIcon: 'glyphicon-ok',\n showTick: false,\n template: {\n caret: '<\/span>'\n },\n maxOptions: false,\n mobile: false,\n selectOnTab: false,\n dropdownAlignRight: false,\n windowPadding: 0\n };\n Selectpicker.prototype = {\n constructor: Selectpicker,\n init: function() {\n var that = this,\n id = this.$element.attr('id');\n this.$element.addClass('bs-select-hidden');\n \/\/ Store originalIndex (key) and newIndex (value) in this.liObj for fast accessibility.\n \/\/ Allows us to do this.$lis.eq(that.liObj[index]) instead of this.$lis.filter('[data-original-index=\"' + index + '\"]').\n this.liObj = {};\n this.multiple = this.$element.prop('multiple');\n this.autofocus = this.$element.prop('autofocus');\n this.$newElement = this.createView();\n this.$element\n .after(this.$newElement)\n .appendTo(this.$newElement);\n this.$button = this.$newElement.children('button');\n this.$menu = this.$newElement.children('.dropdown-menu');\n this.$menuInner = this.$menu.children('.inner');\n this.$searchbox = this.$menu.find('input');\n this.$element.removeClass('bs-select-hidden');\n if (this.options.dropdownAlignRight === true) {\n this.$menu.addClass('dropdown-menu-right');\n }\n if (typeof id !== 'undefined') {\n this.$button.attr('data-id', id);\n $('label[for=\"' + id + '\"]').click(function(e) {\n e.preventDefault();\n that.$button.focus();\n });\n }\n this.checkDisabled();\n this.clickListener();\n if (this.options.liveSearch) {\n this.liveSearchListener();\n }\n this.render();\n this.setStyle();\n this.setWidth();\n if (this.options.container) {\n this.selectPosition();\n }\n this.$menu.data('this', this);\n this.$newElement.data('this', this);\n if (this.options.mobile) {\n this.mobile();\n }\n this.$newElement.on({\n 'hide.bs.dropdown': function(e) {\n that.$menuInner.attr('aria-expanded', false);\n that.$element.trigger('hide.bs.select', e);\n },\n 'hidden.bs.dropdown': function(e) {\n that.$element.trigger('hidden.bs.select', e);\n },\n 'show.bs.dropdown': function(e) {\n that.$menuInner.attr('aria-expanded', true);\n that.$element.trigger('show.bs.select', e);\n },\n 'shown.bs.dropdown': function(e) {\n that.$element.trigger('shown.bs.select', e);\n }\n });\n if (that.$element[0].hasAttribute('required')) {\n this.$element.on('invalid', function() {\n that.$button.addClass('bs-invalid');\n that.$element.on({\n 'focus.bs.select': function() {\n that.$button.focus();\n that.$element.off('focus.bs.select');\n },\n 'shown.bs.select': function() {\n that.$element\n \/\/ Set the value to hide the validation message in Chrome when menu is opened.\n .val(that.$element.val())\n .off('shown.bs.select');\n },\n 'rendered.bs.select': function() {\n \/\/ If select is no longer invalid, remove the bs-invalid class.\n if (this.validity.valid) {\n that.$button.removeClass('bs-invalid');\n }\n that.$element.off('rendered.bs.select');\n }\n });\n that.$button.on('blur.bs.select', function() {\n that.$element.focus().blur();\n that.$button.off('blur.bs.select');\n });\n });\n }\n setTimeout(function() {\n that.$element.trigger('loaded.bs.select');\n });\n },\n createDropdown: function() {\n \/\/ Options.\n \/\/ If we are multiple or showTick option is set, then add the show-tick class.\n var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '',\n inputGroup = this.$element.parent().hasClass('input-group') ? ' input-group-btn' : '',\n autofocus = this.autofocus ? ' autofocus' : '';\n \/\/ Elements.\n var header = this.options.header ? '