: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
options.dataAdapter = Utils.Decorate(
options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
if (options.tokenSeparators != null || options.tokenizer != null) {
options.dataAdapter = Utils.Decorate(
if (options.query != null) {
var Query = require(options.amdBase + 'compat/query');
options.dataAdapter = Utils.Decorate(
if (options.initSelection != null) {
var InitSelection = require(options.amdBase + 'compat/initSelection');
options.dataAdapter = Utils.Decorate(
if (options.resultsAdapter == null) {
options.resultsAdapter = ResultsList;
if (options.ajax != null) {
options.resultsAdapter = Utils.Decorate(
if (options.placeholder != null) {
options.resultsAdapter = Utils.Decorate(
if (options.selectOnClose) {
options.resultsAdapter = Utils.Decorate(
if (options.dropdownAdapter == null) {
options.dropdownAdapter = Dropdown;
var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
options.dropdownAdapter = SearchableDropdown;
if (options.minimumResultsForSearch !== 0) {
options.dropdownAdapter = Utils.Decorate(
if (options.closeOnSelect) {
options.dropdownAdapter = Utils.Decorate(
options.dropdownCssClass != null ||
options.dropdownCss != null ||
options.adaptDropdownCssClass != null
var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter = Utils.Decorate(
if (options.selectionAdapter == null) {
options.selectionAdapter = MultipleSelection;
options.selectionAdapter = SingleSelection;
// Add the placeholder mixin if a placeholder was specified
if (options.placeholder != null) {
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
if (options.allowClear) {
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
options.containerCssClass != null ||
options.containerCss != null ||
options.adaptContainerCssClass != null
var ContainerCSS = require(options.amdBase + 'compat/containerCss');
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
if (typeof options.language === 'string') {
// Check if the language is specified with a region
if (options.language.indexOf('-') > 0) {
// Extract the region information if it is included
var languageParts = options.language.split('-');
var baseLanguage = languageParts[0];
options.language = [options.language, baseLanguage];
options.language = [options.language];
if ($.isArray(options.language)) {
var languages = new Translation();
options.language.push('en');
var languageNames = options.language;
for (var l = 0; l < languageNames.length; l++) {
var name = languageNames[l];
// Try to load it with the original name
language = Translation.loadPath(name);
// If we couldn't load it, check if it wasn't the full path
name = this.defaults.amdLanguageBase + name;
language = Translation.loadPath(name);
// The translation could not be loaded at all. Sometimes this is
// because of a configuration problem, other times this can be
// because of how Select2 helps load all possible translation files.
if (options.debug && window.console && console.warn) {
'Select2: The language file for "' + name + '" could not be ' +
'automatically loaded. A fallback will be used instead.'
languages.extend(language);
options.translations = languages;
var baseTranslation = Translation.loadPath(
this.defaults.amdLanguageBase + 'en'
var customTranslation = new Translation(options.language);
customTranslation.extend(baseTranslation);
options.translations = customTranslation;
Defaults.prototype.reset = function () {
function stripDiacritics (text) {
// Used 'uni range + named function' from http://jsperf.com/diacritics/18
return DIACRITICS[a] || a;
return text.replace(/[^\u0000-\u007E]/g, match);
function matcher (params, data) {
// Always return the object if there is nothing to compare
if ($.trim(params.term) === '') {
// Do a recursive check for options with children
if (data.children && data.children.length > 0) {
// Clone the data object if there are children
// This is required as we modify the object to remove any non-matches
var match = $.extend(true, {}, data);
// Check each child of the option
for (var c = data.children.length - 1; c >= 0; c--) {
var child = data.children[c];
var matches = matcher(params, child);
// If there wasn't a match, remove the object in the array
match.children.splice(c, 1);
// If any children matched, return the new object
if (match.children.length > 0) {
// If there were no matching children, check just the plain object
return matcher(params, match);
var original = stripDiacritics(data.text).toUpperCase();
var term = stripDiacritics(params.term).toUpperCase();
// Check if the text contains the term
if (original.indexOf(term) > -1) {
// If it doesn't contain the term, don't return anything
amdLanguageBase: './i18n/',
dropdownAutoWidth: false,
escapeMarkup: Utils.escapeMarkup,
language: EnglishTranslation,
maximumSelectionLength: 0,
minimumResultsForSearch: 0,
sorter: function (data) {
templateResult: function (result) {
templateSelection: function (selection) {
Defaults.prototype.set = function (key, value) {
var camelKey = $.camelCase(key);
var convertedData = Utils._convertData(data);
$.extend(this.defaults, convertedData);
var defaults = new Defaults();
S2.define('pumselect2/options',[
], function (require, $, Defaults, Utils) {
function Options (options, $element) {
this.fromElement($element);
this.options = Defaults.apply(this.options);
if ($element && $element.is('input')) {
var InputCompat = require(this.get('amdBase') + 'compat/inputData');
this.options.dataAdapter = Utils.Decorate(
this.options.dataAdapter,
Options.prototype.fromElement = function ($e) {
var excludedData = ['pumselect2'];
if (this.options.multiple == null) {
this.options.multiple = $e.prop('multiple');
if (this.options.disabled == null) {
this.options.disabled = $e.prop('disabled');
if (this.options.language == null) {
this.options.language = $e.prop('lang').toLowerCase();
} else if ($e.closest('[lang]').prop('lang')) {
this.options.language = $e.closest('[lang]').prop('lang');
if (this.options.dir == null) {
this.options.dir = $e.prop('dir');
} else if ($e.closest('[dir]').prop('dir')) {
this.options.dir = $e.closest('[dir]').prop('dir');
this.options.dir = 'ltr';
$e.prop('disabled', this.options.disabled);
$e.prop('multiple', this.options.multiple);
if ($e.data('pumselect2Tags')) {
if (this.options.debug && window.console && console.warn) {
'Select2: The `data-pumselect2-tags` attribute has been changed to ' +
'use the `data-data` and `data-tags="true"` attributes and will be ' +
'removed in future versions of Select2.'
$e.data('data', $e.data('pumselect2Tags'));
if ($e.data('ajaxUrl')) {
if (this.options.debug && window.console && console.warn) {
'Select2: The `data-ajax-url` attribute has been changed to ' +
'`data-ajax--url` and support for the old attribute will be removed' +
' in future versions of Select2.'
$e.attr('ajax--url', $e.data('ajaxUrl'));
$e.data('ajax--url', $e.data('ajaxUrl'));
// Prefer the element's `dataset` attribute if it exists
// jQuery 1.x does not correctly handle data attributes with multiple dashes
if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
dataset = $.extend(true, {}, $e[0].dataset, $e.data());
var data = $.extend(true, {}, dataset);
data = Utils._convertData(data);
if ($.inArray(key, excludedData) > -1) {
if ($.isPlainObject(this.options[key])) {
$.extend(this.options[key], data[key]);
this.options[key] = data[key];
Options.prototype.get = function (key) {
return this.options[key];
Options.prototype.set = function (key, val) {
S2.define('pumselect2/core',[
], function ($, Options, Utils, KEYS) {
var Select2 = function ($element, options) {
if ($element.data('pumselect2') != null) {
$element.data('pumselect2').destroy();
this.$element = $element;
this.id = this._generateId($element);
this.options = new Options(options, $element);
Select2.__super__.constructor.call(this);
var tabindex = $element.attr('tabindex') || 0;
$element.data('old-tabindex', tabindex);
$element.attr('tabindex', '-1');
// Set up containers and adapters
var DataAdapter = this.options.get('dataAdapter');
this.dataAdapter = new DataAdapter($element, this.options);
var $container = this.render();
this._placeContainer($container);
var SelectionAdapter = this.options.get('selectionAdapter');
this.selection = new SelectionAdapter($element, this.options);
this.$selection = this.selection.render();
this.selection.position(this.$selection, $container);
var DropdownAdapter = this.options.get('dropdownAdapter');
this.dropdown = new DropdownAdapter($element, this.options);
this.$dropdown = this.dropdown.render();
this.dropdown.position(this.$dropdown, $container);
var ResultsAdapter = this.options.get('resultsAdapter');
this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
this.$results = this.results.render();
this.results.position(this.$results, this.$dropdown);
// Bind the container to all of the adapters
// Register any DOM event handlers
this._registerDomEvents();