diff --git a/modules/system/assets/ui/js/foundation.element.js b/modules/system/assets/ui/js/foundation.element.js index 60a4cfc81..20b28465f 100644 --- a/modules/system/assets/ui/js/foundation.element.js +++ b/modules/system/assets/ui/js/foundation.element.js @@ -48,6 +48,27 @@ el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' '); }, + toggleClass: function(el, className, add) { + if (add === undefined) { + if (this.hasClass(el, className)) { + this.removeClass(el, className) + } + else { + this.addClass(el, className) + } + } + + if (add && !this.hasClass(el, className)) { + this.addClass(el, className) + return + } + + if (!add && this.hasClass(el, className)) { + this.removeClass(el, className) + return + } + }, + /* * Returns element absolution position. * If the second parameter value is false, the scrolling diff --git a/modules/system/assets/ui/js/inspector.editor.checkbox.js b/modules/system/assets/ui/js/inspector.editor.checkbox.js new file mode 100644 index 000000000..0590c1f18 --- /dev/null +++ b/modules/system/assets/ui/js/inspector.editor.checkbox.js @@ -0,0 +1,88 @@ +/* + * Inspector checkbox editor class. + */ ++function ($) { "use strict"; + + var Base = $.oc.inspector.propertyEditors.base, + BaseProto = Base.prototype + + var CheckboxEditor = function(inspector, propertyDefinition, containerCell) { + Base.call(this, inspector, propertyDefinition, containerCell) + } + + CheckboxEditor.prototype = Object.create(BaseProto) + CheckboxEditor.prototype.constructor = Base + + CheckboxEditor.prototype.dispose = function() { + this.unregisterHandlers() + + BaseProto.dispose.call(this) + } + + CheckboxEditor.prototype.build = function() { + var editor = document.createElement('input'), + container = document.createElement('div'), + value = this.inspector.getPropertyValue(this.propertyDefinition.property), + label = document.createElement('label'), + isChecked = false, + id = this.inspector.generateSequencedId() + + container.setAttribute('tabindex', 0) + container.setAttribute('class', 'custom-checkbox nolabel') + + editor.setAttribute('type', 'checkbox') + editor.setAttribute('value', '1') + editor.setAttribute('placeholder', 'placeholder') + editor.setAttribute('id', id) + + label.setAttribute('for', id) + label.textContent = this.propertyDefinition.title + + container.appendChild(editor) + container.appendChild(label) + + if (value === undefined) { + if (this.propertyDefinition.default !== undefined) { + isChecked = this.normalizeCheckedValue(this.propertyDefinition.default) + } + } + else { + isChecked = this.normalizeCheckedValue(value) + } + + editor.checked = isChecked + + this.containerCell.appendChild(container) + } + + CheckboxEditor.prototype.normalizeCheckedValue = function(value) { + if (value == '0' || value == 'false') + return false + + return value + } + + CheckboxEditor.prototype.getInput = function() { + return this.containerCell.querySelector('input') + } + + CheckboxEditor.prototype.registerHandlers = function() { + var input = this.getInput() + + input.addEventListener('change', this.proxy(this.onInputChange)) + } + + CheckboxEditor.prototype.unregisterHandlers = function() { + var input = this.getInput() + + input.removeEventListener('change', this.proxy(this.onInputChange)) + } + + CheckboxEditor.prototype.onInputChange = function() { + var isChecked = this.getInput().checked + + this.inspector.setPropertyValue(this.propertyDefinition.property, isChecked ? 1 : 0) + } + + $.oc.inspector.propertyEditors.checkbox = CheckboxEditor +}(window.jQuery); \ No newline at end of file diff --git a/modules/system/assets/ui/js/inspector.editor.dropdown.js b/modules/system/assets/ui/js/inspector.editor.dropdown.js new file mode 100644 index 000000000..8bcaa8257 --- /dev/null +++ b/modules/system/assets/ui/js/inspector.editor.dropdown.js @@ -0,0 +1,278 @@ +/* + * Inspector checkbox dropdown class. + */ ++function ($) { "use strict"; + + var Base = $.oc.inspector.propertyEditors.base, + BaseProto = Base.prototype + + var DropdownEditor = function(inspector, propertyDefinition, containerCell) { + this.indicatorContainer = null + + Base.call(this, inspector, propertyDefinition, containerCell) + } + + DropdownEditor.prototype = Object.create(BaseProto) + DropdownEditor.prototype.constructor = Base + + DropdownEditor.prototype.init = function() { + this.dynamicOptions = this.propertyDefinition.options ? false : true + this.initialization = false + + BaseProto.init.call(this) + } + + DropdownEditor.prototype.dispose = function() { + this.unregisterHandlers() + this.destroyCustomSelect() + + this.indicatorContainer = null + + BaseProto.dispose.call(this) + } + + // + // Building + // + + DropdownEditor.prototype.build = function() { + var select = document.createElement('select') + + $.oc.foundation.element.addClass(this.containerCell, 'dropdown') + $.oc.foundation.element.addClass(select, 'custom-select') + + if (!this.dynamicOptions) { + this.loadStaticOptions(select) + } + + this.containerCell.appendChild(select) + + this.initCustomSelect() + + if (this.dynamicOptions) { + this.loadDynamicOptions(true) + } + } + + DropdownEditor.prototype.createOption = function(select, title, value) { + var option = document.createElement('option') + + if (title !== null) { + option.textContent = title + } + + if (value !== null) { + option.value = value + } + + select.appendChild(option) + } + + DropdownEditor.prototype.createOptions = function(select, options) { + for (var value in options) { + this.createOption(select, options[value], value) + } + } + + DropdownEditor.prototype.initCustomSelect = function() { + var select = this.getSelect() + + if (Modernizr.touch) { + return + } + + var options = { + dropdownCssClass: 'ocInspectorDropdown' + } + + if (this.propertyDefinition.placeholder !== undefined) { + options.placeholder = this.propertyDefinition.placeholder + } + + $(select).select2(options) + + if (!Modernizr.touch) { + this.indicatorContainer = $('.select2-container', this.containerCell) + this.indicatorContainer.addClass('loading-indicator-container size-small') + } + } + + DropdownEditor.prototype.createPlaceholder = function(select) { + var placeholder = this.propertyDefinition.placeholder + + if (placeholder !== undefined && !Modernizr.touch) { + this.createOption(select, null, null) + } + + if (placeholder !== undefined && Modernizr.touch) { + this.createOption(select, placeholder, null) + } + } + + // + // Helpers + // + + DropdownEditor.prototype.getSelect = function() { + return this.containerCell.querySelector('select') + } + + DropdownEditor.prototype.clearOptions = function(select) { + while (select.firstChild) { + select.removeChild(select.firstChild) + } + } + + DropdownEditor.prototype.hasOptionValue = function(select, value) { + var options = select.children + + for (var i = 0, len = options.length; i < len; i++) { + if (options[i].value == value) { + return true + } + } + + return false + } + + // + // Event handlers + // + + DropdownEditor.prototype.registerHandlers = function() { + var select = this.getSelect() + + $(select).on('change', this.proxy(this.onSelectionChange)) + } + + DropdownEditor.prototype.onSelectionChange = function() { + var select = this.getSelect() + + this.inspector.setPropertyValue(this.propertyDefinition.property, select.value, this.initialization) + } + + // + // Disposing + // + + DropdownEditor.prototype.destroyCustomSelect = function() { + var select = this.getSelect() + + $(select).select2('destroy') + } + + DropdownEditor.prototype.unregisterHandlers = function() { + var select = this.getSelect() + + $(select).off('change', this.proxy(this.onSelectionChange)) + } + + // + // Static options + // + + DropdownEditor.prototype.loadStaticOptions = function(select) { + var value = this.inspector.getPropertyValue(this.propertyDefinition.property) + + this.createPlaceholder(select) + + this.createOptions(select, this.propertyDefinition.options) + + if (value === undefined) { + value = this.propertyDefinition.default + } + + select.value = value + } + + // + // Dynamic options + // + + DropdownEditor.prototype.loadDynamicOptions = function(initialization) { + var currentValue = this.inspector.getPropertyValue(this.propertyDefinition.property), + data = this.inspector.getValues(), + self = this, + $form = $(this.getSelect()).closest('form') + + if (currentValue === undefined) { + currentValue = this.propertyDefinition.default + } + + if (this.propertyDefinition.depends) { + this.saveDependencyValues() + } + + data['inspectorProperty'] = this.propertyDefinition.property + data['inspectorClassName'] = this.inspector.options.inspectorClass + + this.showLoadingIndicator() + + $form.request('onInspectableGetOptions', { + data: data, + }).done(function optionsRequestDoneClosure(data) { + self.optionsRequestDone(data, currentValue, true) + }).always( + this.proxy(this.hideLoadingIndicator) + ) + } + + DropdownEditor.prototype.saveDependencyValues = function() { + this.prevDependencyValues = this.getDependencyValues() + } + + DropdownEditor.prototype.getDependencyValues = function() { + var result = '' + + for (var property in this.propertyDefinition.depends) { + var value = this.inspector.getPropertyValue(property) + + if (value === undefined) { + value = ''; + } + + result += property + ':' + value + '-' + } + + return result + } + + DropdownEditor.prototype.showLoadingIndicator = function() { + if (!Modernizr.touch) { + this.indicatorContainer.loadIndicator() + } + } + + DropdownEditor.prototype.hideLoadingIndicator = function() { + if (!Modernizr.touch) { + this.indicatorContainer.loadIndicator('hide') + } + } + + DropdownEditor.prototype.optionsRequestDone = function(data, currentValue, initialization) { + var select = this.getSelect() + + this.clearOptions(select) + + this.createPlaceholder(select) + + if (data.options) { + for (var i = 0, len = data.options.length; i < len; i++) { + this.createOption(select, data.options[i].title, data.options[i].value) + } + } + + if (this.hasOptionValue(select, currentValue)) { + select.value = currentValue + } + else { + select.selectedIndex = this.propertyDefinition.placeholder === undefined ? 0 : -1 + } + + this.initialization = initialization + $(select).trigger('change') + this.initialization = false + } + + $.oc.inspector.propertyEditors.dropdown = DropdownEditor +}(window.jQuery); \ No newline at end of file diff --git a/modules/system/assets/ui/js/inspector.editor.string.js b/modules/system/assets/ui/js/inspector.editor.string.js index 33cf0e897..43be4cf41 100644 --- a/modules/system/assets/ui/js/inspector.editor.string.js +++ b/modules/system/assets/ui/js/inspector.editor.string.js @@ -47,22 +47,24 @@ var input = this.getInput() input.addEventListener('focus', this.proxy(this.onInputFocus)) - input.addEventListener('change', this.proxy(this.onInputChange)) + input.addEventListener('keyup', this.proxy(this.onInputKeyUp)) } StringEditor.prototype.unregisterHandlers = function() { var input = this.getInput() input.removeEventListener('focus', this.proxy(this.onInputFocus)) - input.removeEventListener('change', this.proxy(this.onInputChange)) + input.removeEventListener('keyup', this.proxy(this.onInputKeyUp)) } StringEditor.prototype.onInputFocus = function(ev) { this.inspector.makeCellActive(this.containerCell) } - StringEditor.prototype.onInputChange = function() { + StringEditor.prototype.onInputKeyUp = function() { + var value = this.getInput().value + this.inspector.setPropertyValue(this.propertyDefinition.property, value) } $.oc.inspector.propertyEditors.string = StringEditor diff --git a/modules/system/assets/ui/js/inspector.engine.js b/modules/system/assets/ui/js/inspector.engine.js index b97aedd5e..155bdcec5 100644 --- a/modules/system/assets/ui/js/inspector.engine.js +++ b/modules/system/assets/ui/js/inspector.engine.js @@ -24,7 +24,7 @@ for (var i = 0, len = properties.length; i < len; i++) { var property = properties[i] - if (property.itemType !== undefined && property.itemType == 'group' && item.title == group) { + if (property.itemType !== undefined && property.itemType == 'group' && property.title == group) { return property } } @@ -50,7 +50,7 @@ fields.push(property) } else { - var group = findGroup(property.group) + var group = findGroup(property.group, fields) if (!group) { group = { @@ -69,8 +69,8 @@ } } - for (var i = 0, len = properties.length; i < len; i++) { - var property = properties[i] + for (var i = 0, len = fields.length; i < len; i++) { + var property = fields[i] result.properties.push(property) diff --git a/modules/system/assets/ui/js/inspector.surface.js b/modules/system/assets/ui/js/inspector.surface.js index 95302198e..b6213284e 100644 --- a/modules/system/assets/ui/js/inspector.surface.js +++ b/modules/system/assets/ui/js/inspector.surface.js @@ -36,12 +36,18 @@ * related to an element in the document DOM. */ var Surface = function(containerElement, properties, values, inspectorUniqueId, options) { + if (inspectorUniqueId === undefined) { + throw new Error('Inspector surface unique ID should be defined.') + } + this.options = $.extend({}, Surface.DEFAULTS, typeof option == 'object' && option) this.rawProperties = properties this.parsedProperties = $.oc.inspector.engine.processPropertyGroups(properties) this.container = containerElement this.inspectorUniqueId = inspectorUniqueId this.values = values + this.originalValues = $.extend(true, {}, values) // Clone the values hash + this.idCounter = 1 this.editors = [] this.tableContainer = null @@ -55,6 +61,7 @@ Surface.prototype.constructor = Surface Surface.prototype.dispose = function() { + this.unregisterHandlers() this.removeElements() this.disposeEditors() @@ -64,6 +71,7 @@ this.parsedProperties = null this.editors = null this.values = null + this.originalValues = null BaseProto.dispose.call(this) } @@ -73,6 +81,20 @@ Surface.prototype.init = function() { this.build() + + $.oc.foundation.controlUtils.markDisposable(this.tableContainer) + + this.registerHandlers() + } + + Surface.prototype.registerHandlers = function() { + $(this.tableContainer).one('dispose-control', this.proxy(this.dispose)) + $(this.tableContainer).on('click', 'tr.group', this.proxy(this.onGroupClick)) + } + + Surface.prototype.unregisterHandlers = function() { + $(this.tableContainer).off('dispose-control', this.proxy(this.dispose)) + $(this.tableContainer).off('click', 'tr.group', this.proxy(this.onGroupClick)) } // @@ -125,7 +147,10 @@ // Table row // - row.setAttribute('data-property', property.property) + if (property.property) { + row.setAttribute('data-property', property.property) + } + this.applyGroupIndexAttribute(property, row) $.oc.foundation.element.addClass(row, this.getRowCssClass(property)) @@ -242,6 +267,14 @@ return {} } + Surface.prototype.writeGroupStatuses = function(updatedStatuses) { + var statuses = this.getInspectorGroupStatuses() + + statuses[this.inspectorUniqueId] = updatedStatuses + + this.setInspectorGroupStatuses(statuses) + } + Surface.prototype.getInspectorGroupStatuses = function() { var statuses = document.body.getAttribute('data-inspector-group-statuses') @@ -252,6 +285,48 @@ return {} } + Surface.prototype.setInspectorGroupStatuses = function(statuses) { + document.body.setAttribute('data-inspector-group-statuses', JSON.stringify(statuses)) + } + + Surface.prototype.toggleGroup = function(row) { + var link = row.querySelector('a'), + groupIndex = link.getAttribute('data-group-index'), + propertyRows = this.tableContainer.querySelectorAll('tr[data-group-index="'+groupIndex+'"]'), + collapse = true, + statuses = this.loadGroupStatuses(), + title = row.querySelector('span.title-element').getAttribute('title'), + duration = Math.round(50 / propertyRows.length), + rowsArray = Array.prototype.slice.call(propertyRows) + + if ($.oc.foundation.element.hasClass(link, 'expanded')) { + $.oc.foundation.element.removeClass(link, 'expanded') + statuses[title] = false + } else { + $.oc.foundation.element.addClass(link, 'expanded') + collapse = false + statuses[title] = true + } + + this.expandOrCollapseRows(rowsArray, collapse, duration) + + this.writeGroupStatuses(statuses) + } + + Surface.prototype.expandOrCollapseRows = function(rows, collapse, duration) { + var row = rows.pop(), + self = this + + if (row) { + setTimeout(function toggleRow() { + $.oc.foundation.element.toggleClass(row, 'collapsed', collapse) + $.oc.foundation.element.toggleClass(row, 'expanded', !collapse) + + self.expandOrCollapseRows(rows, collapse, duration) + }, duration) + } + } + // // Editors // @@ -265,7 +340,7 @@ throw new Error('The Inspector editor class "' + property.type + '" is not defined in the $.oc.inspector.propertyEditors namespace.') - var cell = document.createElement('td'), + var cell = document.createElement('td'), editor = new $.oc.inspector.propertyEditors[property.type](this, property, cell) this.editors.push(editor) @@ -273,6 +348,12 @@ row.appendChild(cell) } + Surface.prototype.generateSequencedId = function() { + this.idCounter ++ + + return this.inspectorUniqueId + '-' + this.idCounter + } + // // Internal API for the editors // @@ -281,6 +362,45 @@ return this.values[property] } + Surface.prototype.getValues = function() { + var result = {} + + for (var i=0, len = this.parsedProperties.properties.length; i < len; i++) { + var property = this.parsedProperties.properties[i] + + if (property.itemType !== 'property') { + continue + } + + var value = this.getPropertyValue(property.property) + + if (value === undefined) { + value = property.default + } + + result[property.property] = value + } + + return result + } + + Surface.prototype.setPropertyValue = function(property, value, supressChangeEvents) { + this.values[property] = value + + if (!supressChangeEvents) { + if (this.originalValues[property] === undefined || this.originalValues[property] != value) { + this.markPropertyChanged(property, true) + } + else { + this.markPropertyChanged(property, false) + } + +// TODO: here we should force dependent editors to update + } + + return value + } + Surface.prototype.makeCellActive = function(cell) { var tbody = cell.parentNode.parentNode.parentNode, // cell / row / tbody cells = tbody.querySelectorAll('tr td') @@ -292,6 +412,17 @@ $.oc.foundation.element.addClass(cell, 'active') } + Surface.prototype.markPropertyChanged = function(property, changed) { + var row = this.tableContainer.querySelector('tr[data-property="'+property+'"]') + + if (changed) { + $.oc.foundation.element.addClass(row, 'changed') + } + else { + $.oc.foundation.element.removeClass(row, 'changed') + } + } + // // Disposing // @@ -318,6 +449,15 @@ return div.innerHTML } + // EVENT HANDLERS + // + + Surface.prototype.onGroupClick = function(ev) { + var row = ev.currentTarget + + this.toggleGroup(row) + } + // DEFAULT OPTIONS // ============================ diff --git a/modules/system/assets/ui/storm-min.js b/modules/system/assets/ui/storm-min.js index 460429edc..13ea7676f 100644 --- a/modules/system/assets/ui/storm-min.js +++ b/modules/system/assets/ui/storm-min.js @@ -27,7 +27,12 @@ if(el.classList) el.classList.add(currentClass);else el.className+=' '+currentClass;}},removeClass:function(el,className){if(el.classList) el.classList.remove(className);else -el.className=el.className.replace(new RegExp('(^|\\b)'+className.split(' ').join('|')+'(\\b|$)','gi'),' ');},absolutePosition:function(element,ignoreScrolling){var top=ignoreScrolling===true?0:document.body.scrollTop,left=0 +el.className=el.className.replace(new RegExp('(^|\\b)'+className.split(' ').join('|')+'(\\b|$)','gi'),' ');},toggleClass:function(el,className,add){if(add===undefined){if(this.hasClass(el,className)){this.removeClass(el,className)} +else{this.addClass(el,className)}} +if(add&&!this.hasClass(el,className)){this.addClass(el,className) +return} +if(!add&&this.hasClass(el,className)){this.removeClass(el,className) +return}},absolutePosition:function(element,ignoreScrolling){var top=ignoreScrolling===true?0:document.body.scrollTop,left=0 do{top+=element.offsetTop||0;if(ignoreScrolling!==true) top-=element.scrollTop||0 left+=element.offsetLeft||0 @@ -575,14 +580,13 @@ return;} self.trigger('select',{originalEvent:evt,data:data});});this.$results.on('mouseenter','.select2-results__option[aria-selected]',function(evt){var data=$(this).data('data');self.getHighlightedResults().removeClass('select2-results__option--highlighted');self.trigger('results:focus',{data:data,element:$(this)});});};Results.prototype.getHighlightedResults=function(){var $highlighted=this.$results.find('.select2-results__option--highlighted');return $highlighted;};Results.prototype.destroy=function(){this.$results.remove();};Results.prototype.ensureHighlightVisible=function(){var $highlighted=this.getHighlightedResults();if($highlighted.length===0){return;} var $options=this.$results.find('[aria-selected]');var currentIndex=$options.index($highlighted);var currentOffset=this.$results.offset().top;var nextTop=$highlighted.offset().top;var nextOffset=this.$results.scrollTop()+(nextTop-currentOffset);var offsetDelta=nextTop-currentOffset;nextOffset-=$highlighted.outerHeight(false)*2;if(currentIndex<=2){this.$results.scrollTop(0);}else if(offsetDelta>this.$results.outerHeight()||offsetDelta<0){this.$results.scrollTop(nextOffset);}};Results.prototype.template=function(result,container){var template=this.options.get('templateResult');var escapeMarkup=this.options.get('escapeMarkup');var content=template(result);if(content==null){container.style.display='none';}else if(typeof content==='string'){container.innerHTML=escapeMarkup(content);}else{$(container).append(content);}};return Results;});S2.define('select2/keys',[],function(){var KEYS={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return KEYS;});S2.define('select2/selection/base',['jquery','../utils','../keys'],function($,Utils,KEYS){function BaseSelection($element,options){this.$element=$element;this.options=options;BaseSelection.__super__.constructor.call(this);} Utils.Extend(BaseSelection,Utils.Observable);BaseSelection.prototype.render=function(){var $selection=$('');this._tabindex=0;if(this.$element.data('old-tabindex')!=null){this._tabindex=this.$element.data('old-tabindex');}else if(this.$element.attr('tabindex')!=null){this._tabindex=this.$element.attr('tabindex');} -$selection.attr('title',this.$element.attr('title'));$selection.attr('tabindex',this._tabindex);this.$selection=$selection;return $selection;};BaseSelection.prototype.bind=function(container,$container){var self=this;var id=container.id+'-container';var resultsId=container.id+'-results';this.container=container;this.$selection.on('focus',function(evt){self.trigger('focus',evt);});this.$selection.on('blur',function(evt){self._handleBlur(evt);});this.$selection.on('keydown',function(evt){self.trigger('keypress',evt);if(evt.which===KEYS.SPACE){evt.preventDefault();}});container.on('results:focus',function(params){self.$selection.attr('aria-activedescendant',params.data._resultId);});container.on('selection:update',function(params){self.update(params.data);});container.on('open',function(){self.$selection.attr('aria-expanded','true');self.$selection.attr('aria-owns',resultsId);self._attachCloseHandler(container);});container.on('close',function(){self.$selection.attr('aria-expanded','false');self.$selection.removeAttr('aria-activedescendant');self.$selection.removeAttr('aria-owns');self.$selection.focus();self._detachCloseHandler(container);});container.on('enable',function(){self.$selection.attr('tabindex',self._tabindex);});container.on('disable',function(){self.$selection.attr('tabindex','-1');});};BaseSelection.prototype._handleBlur=function(evt){var self=this;window.setTimeout(function(){if((document.activeElement==self.$selection[0])||($.contains(self.$selection[0],document.activeElement))){return;} -self.trigger('blur',evt);},1);};BaseSelection.prototype._attachCloseHandler=function(container){var self=this;$(document.body).on('mousedown.select2.'+container.id,function(e){var $target=$(e.target);var $select=$target.closest('.select2');var $all=$('.select2.select2-container--open');$all.each(function(){var $this=$(this);if(this==$select[0]){return;} +$selection.attr('title',this.$element.attr('title'));$selection.attr('tabindex',this._tabindex);this.$selection=$selection;return $selection;};BaseSelection.prototype.bind=function(container,$container){var self=this;var id=container.id+'-container';var resultsId=container.id+'-results';this.container=container;this.$selection.on('focus',function(evt){self.trigger('focus',evt);});this.$selection.on('blur',function(evt){self.trigger('blur',evt);});this.$selection.on('keydown',function(evt){self.trigger('keypress',evt);if(evt.which===KEYS.SPACE){evt.preventDefault();}});container.on('results:focus',function(params){self.$selection.attr('aria-activedescendant',params.data._resultId);});container.on('selection:update',function(params){self.update(params.data);});container.on('open',function(){self.$selection.attr('aria-expanded','true');self.$selection.attr('aria-owns',resultsId);self._attachCloseHandler(container);});container.on('close',function(){self.$selection.attr('aria-expanded','false');self.$selection.removeAttr('aria-activedescendant');self.$selection.removeAttr('aria-owns');self.$selection.focus();self._detachCloseHandler(container);});container.on('enable',function(){self.$selection.attr('tabindex',self._tabindex);});container.on('disable',function(){self.$selection.attr('tabindex','-1');});};BaseSelection.prototype._attachCloseHandler=function(container){var self=this;$(document.body).on('mousedown.select2.'+container.id,function(e){var $target=$(e.target);var $select=$target.closest('.select2');var $all=$('.select2.select2-container--open');$all.each(function(){var $this=$(this);if(this==$select[0]){return;} var $element=$this.data('element');$element.select2('close');});});};BaseSelection.prototype._detachCloseHandler=function(container){$(document.body).off('mousedown.select2.'+container.id);};BaseSelection.prototype.position=function($selection,$container){var $selectionContainer=$container.find('.selection');$selectionContainer.append($selection);};BaseSelection.prototype.destroy=function(){this._detachCloseHandler(this.container);};BaseSelection.prototype.update=function(data){throw new Error('The `update` method must be defined in child classes.');};return BaseSelection;});S2.define('select2/selection/single',['jquery','./base','../utils','../keys'],function($,BaseSelection,Utils,KEYS){function SingleSelection(){SingleSelection.__super__.constructor.apply(this,arguments);} Utils.Extend(SingleSelection,BaseSelection);SingleSelection.prototype.render=function(){var $selection=SingleSelection.__super__.render.call(this);$selection.addClass('select2-selection--single');$selection.html(''+''+''+'');return $selection;};SingleSelection.prototype.bind=function(container,$container){var self=this;SingleSelection.__super__.bind.apply(this,arguments);var id=container.id+'-container';this.$selection.find('.select2-selection__rendered').attr('id',id);this.$selection.attr('aria-labelledby',id);this.$selection.on('mousedown',function(evt){if(evt.which!==1){return;} -self.trigger('toggle',{originalEvent:evt});});this.$selection.on('focus',function(evt){});this.$selection.on('blur',function(evt){});container.on('selection:update',function(params){self.update(params.data);});};SingleSelection.prototype.clear=function(){this.$selection.find('.select2-selection__rendered').empty();};SingleSelection.prototype.display=function(data,container){var template=this.options.get('templateSelection');var escapeMarkup=this.options.get('escapeMarkup');return escapeMarkup(template(data,container));};SingleSelection.prototype.selectionContainer=function(){return $('');};SingleSelection.prototype.update=function(data){if(data.length===0){this.clear();return;} -var selection=data[0];var $rendered=this.$selection.find('.select2-selection__rendered');var formatted=this.display(selection,$rendered);$rendered.empty().append(formatted);$rendered.prop('title',selection.title||selection.text);};return SingleSelection;});S2.define('select2/selection/multiple',['jquery','./base','../utils'],function($,BaseSelection,Utils){function MultipleSelection($element,options){MultipleSelection.__super__.constructor.apply(this,arguments);} -Utils.Extend(MultipleSelection,BaseSelection);MultipleSelection.prototype.render=function(){var $selection=MultipleSelection.__super__.render.call(this);$selection.addClass('select2-selection--multiple');$selection.html('');return $selection;};MultipleSelection.prototype.bind=function(container,$container){var self=this;MultipleSelection.__super__.bind.apply(this,arguments);this.$selection.on('click',function(evt){self.trigger('toggle',{originalEvent:evt});});this.$selection.on('click','.select2-selection__choice__remove',function(evt){var $remove=$(this);var $selection=$remove.parent();var data=$selection.data('data');self.trigger('unselect',{originalEvent:evt,data:data});});};MultipleSelection.prototype.clear=function(){this.$selection.find('.select2-selection__rendered').empty();};MultipleSelection.prototype.display=function(data,container){var template=this.options.get('templateSelection');var escapeMarkup=this.options.get('escapeMarkup');return escapeMarkup(template(data,container));};MultipleSelection.prototype.selectionContainer=function(){var $container=$('
  • '+''+'×'+''+'
  • ');return $container;};MultipleSelection.prototype.update=function(data){this.clear();if(data.length===0){return;} -var $selections=[];for(var d=0;d');};SingleSelection.prototype.update=function(data){if(data.length===0){this.clear();return;} +var selection=data[0];var formatted=this.display(selection);var $rendered=this.$selection.find('.select2-selection__rendered');$rendered.empty().append(formatted);$rendered.prop('title',selection.title||selection.text);};return SingleSelection;});S2.define('select2/selection/multiple',['jquery','./base','../utils'],function($,BaseSelection,Utils){function MultipleSelection($element,options){MultipleSelection.__super__.constructor.apply(this,arguments);} +Utils.Extend(MultipleSelection,BaseSelection);MultipleSelection.prototype.render=function(){var $selection=MultipleSelection.__super__.render.call(this);$selection.addClass('select2-selection--multiple');$selection.html('');return $selection;};MultipleSelection.prototype.bind=function(container,$container){var self=this;MultipleSelection.__super__.bind.apply(this,arguments);this.$selection.on('click',function(evt){self.trigger('toggle',{originalEvent:evt});});this.$selection.on('click','.select2-selection__choice__remove',function(evt){var $remove=$(this);var $selection=$remove.parent();var data=$selection.data('data');self.trigger('unselect',{originalEvent:evt,data:data});});};MultipleSelection.prototype.clear=function(){this.$selection.find('.select2-selection__rendered').empty();};MultipleSelection.prototype.display=function(data){var template=this.options.get('templateSelection');var escapeMarkup=this.options.get('escapeMarkup');return escapeMarkup(template(data));};MultipleSelection.prototype.selectionContainer=function(){var $container=$('
  • '+''+'×'+''+'
  • ');return $container;};MultipleSelection.prototype.update=function(data){this.clear();if(data.length===0){return;} +var $selections=[];for(var d=0;d1;if(multipleSelections||singlePlaceholder){return decorated.call(this,data);} @@ -594,14 +598,12 @@ evt.stopPropagation();var data=$clear.data('data');for(var d=0;d0||data.length===0){return;} var $remove=$(''+'×'+'');$remove.data('data',data);this.$selection.find('.select2-selection__rendered').prepend($remove);};return AllowClear;});S2.define('select2/selection/search',['jquery','../utils','../keys'],function($,Utils,KEYS){function Search(decorated,$element,options){decorated.call(this,$element,options);} -Search.prototype.render=function(decorated){var $search=$('');this.$searchContainer=$search;this.$search=$search.find('input');var $rendered=decorated.call(this);this._transferTabIndex();return $rendered;};Search.prototype.bind=function(decorated,container,$container){var self=this;decorated.call(this,container,$container);container.on('open',function(){self.$search.trigger('focus');});container.on('close',function(){self.$search.val('');self.$search.trigger('focus');});container.on('enable',function(){self.$search.prop('disabled',false);self._transferTabIndex();});container.on('disable',function(){self.$search.prop('disabled',true);});container.on('focus',function(evt){self.$search.trigger('focus');});this.$selection.on('focusin','.select2-search--inline',function(evt){self.trigger('focus',evt);});this.$selection.on('focusout','.select2-search--inline',function(evt){self._handleBlur(evt);});this.$selection.on('keydown','.select2-search--inline',function(evt){evt.stopPropagation();self.trigger('keypress',evt);self._keyUpPrevented=false;var key=evt.which;if(key===KEYS.BACKSPACE&&self.$search.val()===''){var $previousChoice=self.$searchContainer.prev('.select2-selection__choice');if($previousChoice.length>0){var item=$previousChoice.data('data');self.searchRemoveChoice(item);evt.preventDefault();}}});this.$selection.on('input','.select2-search--inline',function(evt){self.$selection.off('keyup.search');});this.$selection.on('keyup.search input','.select2-search--inline',function(evt){var key=evt.which;if(key==KEYS.SHIFT||key==KEYS.CTRL||key==KEYS.ALT){return;} -if(key==KEYS.TAB){return;} -self.handleSearch(evt);});};Search.prototype._transferTabIndex=function(decorated){this.$search.attr('tabindex',this.$selection.attr('tabindex'));this.$selection.attr('tabindex','-1');};Search.prototype.createPlaceholder=function(decorated,placeholder){this.$search.attr('placeholder',placeholder.text);};Search.prototype.update=function(decorated,data){var searchHadFocus=this.$search[0]==document.activeElement;this.$search.attr('placeholder','');decorated.call(this,data);this.$selection.find('.select2-selection__rendered').append(this.$searchContainer);this.resizeSearch();if(searchHadFocus){this.$search.focus();}};Search.prototype.handleSearch=function(){this.resizeSearch();if(!this._keyUpPrevented){var input=this.$search.val();this.trigger('query',{term:input});} +Search.prototype.render=function(decorated){var $search=$('');this.$searchContainer=$search;this.$search=$search.find('input');var $rendered=decorated.call(this);return $rendered;};Search.prototype.bind=function(decorated,container,$container){var self=this;decorated.call(this,container,$container);container.on('open',function(){self.$search.attr('tabindex',0);self.$search.focus();});container.on('close',function(){self.$search.attr('tabindex',-1);self.$search.val('');self.$search.focus();});container.on('enable',function(){self.$search.prop('disabled',false);});container.on('disable',function(){self.$search.prop('disabled',true);});this.$selection.on('focusin','.select2-search--inline',function(evt){self.trigger('focus',evt);});this.$selection.on('focusout','.select2-search--inline',function(evt){self.trigger('blur',evt);});this.$selection.on('keydown','.select2-search--inline',function(evt){evt.stopPropagation();self.trigger('keypress',evt);self._keyUpPrevented=evt.isDefaultPrevented();var key=evt.which;if(key===KEYS.BACKSPACE&&self.$search.val()===''){var $previousChoice=self.$searchContainer.prev('.select2-selection__choice');if($previousChoice.length>0){var item=$previousChoice.data('data');self.searchRemoveChoice(item);evt.preventDefault();}}});this.$selection.on('input','.select2-search--inline',function(evt){self.$selection.off('keyup.search');});this.$selection.on('keyup.search input','.select2-search--inline',function(evt){self.handleSearch(evt);});};Search.prototype.createPlaceholder=function(decorated,placeholder){this.$search.attr('placeholder',placeholder.text);};Search.prototype.update=function(decorated,data){this.$search.attr('placeholder','');decorated.call(this,data);this.$selection.find('.select2-selection__rendered').append(this.$searchContainer);this.resizeSearch();};Search.prototype.handleSearch=function(){this.resizeSearch();if(!this._keyUpPrevented){var input=this.$search.val();this.trigger('query',{term:input});} this._keyUpPrevented=false;};Search.prototype.searchRemoveChoice=function(decorated,item){this.trigger('unselect',{data:item});this.trigger('open');this.$search.val(item.text+' ');};Search.prototype.resizeSearch=function(){this.$search.css('width','25px');var width='';if(this.$search.attr('placeholder')!==''){width=this.$selection.find('.select2-selection__rendered').innerWidth();}else{var minimumWidth=this.$search.val().length+1;width=(minimumWidth*0.75)+'em';} this.$search.css('width',width);};return Search;});S2.define('select2/selection/eventRelay',['jquery'],function($){function EventRelay(){} EventRelay.prototype.bind=function(decorated,container,$container){var self=this;var relayEvents=['open','opening','close','closing','select','selecting','unselect','unselecting'];var preventableEvents=['opening','closing','selecting','unselecting'];decorated.call(this,container,$container);container.on('*',function(name,params){if($.inArray(name,relayEvents)===-1){return;} params=params||{};var evt=$.Event('select2:'+name,{params:params});self.$element.trigger(evt);if($.inArray(name,preventableEvents)===-1){return;} -params.prevented=false;});};return EventRelay;});S2.define('select2/translation',['jquery','require'],function($,require){function Translation(dict){this.dict=dict||{};} +params.prevented=evt.isDefaultPrevented();});};return EventRelay;});S2.define('select2/translation',['jquery','require'],function($,require){function Translation(dict){this.dict=dict||{};} Translation.prototype.all=function(){return this.dict;};Translation.prototype.get=function(key){return this.dict[key];};Translation.prototype.extend=function(translation){this.dict=$.extend({},translation.all(),this.dict);};Translation._cache={};Translation.loadPath=function(path){if(!(path in Translation._cache)){var translations=require(path);Translation._cache[path]=translations;} return new Translation(Translation._cache[path]);};return Translation;});S2.define('select2/diacritics',[],function(){var diacritics={'\u24B6':'A','\uFF21':'A','\u00C0':'A','\u00C1':'A','\u00C2':'A','\u1EA6':'A','\u1EA4':'A','\u1EAA':'A','\u1EA8':'A','\u00C3':'A','\u0100':'A','\u0102':'A','\u1EB0':'A','\u1EAE':'A','\u1EB4':'A','\u1EB2':'A','\u0226':'A','\u01E0':'A','\u00C4':'A','\u01DE':'A','\u1EA2':'A','\u00C5':'A','\u01FA':'A','\u01CD':'A','\u0200':'A','\u0202':'A','\u1EA0':'A','\u1EAC':'A','\u1EB6':'A','\u1E00':'A','\u0104':'A','\u023A':'A','\u2C6F':'A','\uA732':'AA','\u00C6':'AE','\u01FC':'AE','\u01E2':'AE','\uA734':'AO','\uA736':'AU','\uA738':'AV','\uA73A':'AV','\uA73C':'AY','\u24B7':'B','\uFF22':'B','\u1E02':'B','\u1E04':'B','\u1E06':'B','\u0243':'B','\u0182':'B','\u0181':'B','\u24B8':'C','\uFF23':'C','\u0106':'C','\u0108':'C','\u010A':'C','\u010C':'C','\u00C7':'C','\u1E08':'C','\u0187':'C','\u023B':'C','\uA73E':'C','\u24B9':'D','\uFF24':'D','\u1E0A':'D','\u010E':'D','\u1E0C':'D','\u1E10':'D','\u1E12':'D','\u1E0E':'D','\u0110':'D','\u018B':'D','\u018A':'D','\u0189':'D','\uA779':'D','\u01F1':'DZ','\u01C4':'DZ','\u01F2':'Dz','\u01C5':'Dz','\u24BA':'E','\uFF25':'E','\u00C8':'E','\u00C9':'E','\u00CA':'E','\u1EC0':'E','\u1EBE':'E','\u1EC4':'E','\u1EC2':'E','\u1EBC':'E','\u0112':'E','\u1E14':'E','\u1E16':'E','\u0114':'E','\u0116':'E','\u00CB':'E','\u1EBA':'E','\u011A':'E','\u0204':'E','\u0206':'E','\u1EB8':'E','\u1EC6':'E','\u0228':'E','\u1E1C':'E','\u0118':'E','\u1E18':'E','\u1E1A':'E','\u0190':'E','\u018E':'E','\u24BB':'F','\uFF26':'F','\u1E1E':'F','\u0191':'F','\uA77B':'F','\u24BC':'G','\uFF27':'G','\u01F4':'G','\u011C':'G','\u1E20':'G','\u011E':'G','\u0120':'G','\u01E6':'G','\u0122':'G','\u01E4':'G','\u0193':'G','\uA7A0':'G','\uA77D':'G','\uA77E':'G','\u24BD':'H','\uFF28':'H','\u0124':'H','\u1E22':'H','\u1E26':'H','\u021E':'H','\u1E24':'H','\u1E28':'H','\u1E2A':'H','\u0126':'H','\u2C67':'H','\u2C75':'H','\uA78D':'H','\u24BE':'I','\uFF29':'I','\u00CC':'I','\u00CD':'I','\u00CE':'I','\u0128':'I','\u012A':'I','\u012C':'I','\u0130':'I','\u00CF':'I','\u1E2E':'I','\u1EC8':'I','\u01CF':'I','\u0208':'I','\u020A':'I','\u1ECA':'I','\u012E':'I','\u1E2C':'I','\u0197':'I','\u24BF':'J','\uFF2A':'J','\u0134':'J','\u0248':'J','\u24C0':'K','\uFF2B':'K','\u1E30':'K','\u01E8':'K','\u1E32':'K','\u0136':'K','\u1E34':'K','\u0198':'K','\u2C69':'K','\uA740':'K','\uA742':'K','\uA744':'K','\uA7A2':'K','\u24C1':'L','\uFF2C':'L','\u013F':'L','\u0139':'L','\u013D':'L','\u1E36':'L','\u1E38':'L','\u013B':'L','\u1E3C':'L','\u1E3A':'L','\u0141':'L','\u023D':'L','\u2C62':'L','\u2C60':'L','\uA748':'L','\uA746':'L','\uA780':'L','\u01C7':'LJ','\u01C8':'Lj','\u24C2':'M','\uFF2D':'M','\u1E3E':'M','\u1E40':'M','\u1E42':'M','\u2C6E':'M','\u019C':'M','\u24C3':'N','\uFF2E':'N','\u01F8':'N','\u0143':'N','\u00D1':'N','\u1E44':'N','\u0147':'N','\u1E46':'N','\u0145':'N','\u1E4A':'N','\u1E48':'N','\u0220':'N','\u019D':'N','\uA790':'N','\uA7A4':'N','\u01CA':'NJ','\u01CB':'Nj','\u24C4':'O','\uFF2F':'O','\u00D2':'O','\u00D3':'O','\u00D4':'O','\u1ED2':'O','\u1ED0':'O','\u1ED6':'O','\u1ED4':'O','\u00D5':'O','\u1E4C':'O','\u022C':'O','\u1E4E':'O','\u014C':'O','\u1E50':'O','\u1E52':'O','\u014E':'O','\u022E':'O','\u0230':'O','\u00D6':'O','\u022A':'O','\u1ECE':'O','\u0150':'O','\u01D1':'O','\u020C':'O','\u020E':'O','\u01A0':'O','\u1EDC':'O','\u1EDA':'O','\u1EE0':'O','\u1EDE':'O','\u1EE2':'O','\u1ECC':'O','\u1ED8':'O','\u01EA':'O','\u01EC':'O','\u00D8':'O','\u01FE':'O','\u0186':'O','\u019F':'O','\uA74A':'O','\uA74C':'O','\u01A2':'OI','\uA74E':'OO','\u0222':'OU','\u24C5':'P','\uFF30':'P','\u1E54':'P','\u1E56':'P','\u01A4':'P','\u2C63':'P','\uA750':'P','\uA752':'P','\uA754':'P','\u24C6':'Q','\uFF31':'Q','\uA756':'Q','\uA758':'Q','\u024A':'Q','\u24C7':'R','\uFF32':'R','\u0154':'R','\u1E58':'R','\u0158':'R','\u0210':'R','\u0212':'R','\u1E5A':'R','\u1E5C':'R','\u0156':'R','\u1E5E':'R','\u024C':'R','\u2C64':'R','\uA75A':'R','\uA7A6':'R','\uA782':'R','\u24C8':'S','\uFF33':'S','\u1E9E':'S','\u015A':'S','\u1E64':'S','\u015C':'S','\u1E60':'S','\u0160':'S','\u1E66':'S','\u1E62':'S','\u1E68':'S','\u0218':'S','\u015E':'S','\u2C7E':'S','\uA7A8':'S','\uA784':'S','\u24C9':'T','\uFF34':'T','\u1E6A':'T','\u0164':'T','\u1E6C':'T','\u021A':'T','\u0162':'T','\u1E70':'T','\u1E6E':'T','\u0166':'T','\u01AC':'T','\u01AE':'T','\u023E':'T','\uA786':'T','\uA728':'TZ','\u24CA':'U','\uFF35':'U','\u00D9':'U','\u00DA':'U','\u00DB':'U','\u0168':'U','\u1E78':'U','\u016A':'U','\u1E7A':'U','\u016C':'U','\u00DC':'U','\u01DB':'U','\u01D7':'U','\u01D5':'U','\u01D9':'U','\u1EE6':'U','\u016E':'U','\u0170':'U','\u01D3':'U','\u0214':'U','\u0216':'U','\u01AF':'U','\u1EEA':'U','\u1EE8':'U','\u1EEE':'U','\u1EEC':'U','\u1EF0':'U','\u1EE4':'U','\u1E72':'U','\u0172':'U','\u1E76':'U','\u1E74':'U','\u0244':'U','\u24CB':'V','\uFF36':'V','\u1E7C':'V','\u1E7E':'V','\u01B2':'V','\uA75E':'V','\u0245':'V','\uA760':'VY','\u24CC':'W','\uFF37':'W','\u1E80':'W','\u1E82':'W','\u0174':'W','\u1E86':'W','\u1E84':'W','\u1E88':'W','\u2C72':'W','\u24CD':'X','\uFF38':'X','\u1E8A':'X','\u1E8C':'X','\u24CE':'Y','\uFF39':'Y','\u1EF2':'Y','\u00DD':'Y','\u0176':'Y','\u1EF8':'Y','\u0232':'Y','\u1E8E':'Y','\u0178':'Y','\u1EF6':'Y','\u1EF4':'Y','\u01B3':'Y','\u024E':'Y','\u1EFE':'Y','\u24CF':'Z','\uFF3A':'Z','\u0179':'Z','\u1E90':'Z','\u017B':'Z','\u017D':'Z','\u1E92':'Z','\u1E94':'Z','\u01B5':'Z','\u0224':'Z','\u2C7F':'Z','\u2C6B':'Z','\uA762':'Z','\u24D0':'a','\uFF41':'a','\u1E9A':'a','\u00E0':'a','\u00E1':'a','\u00E2':'a','\u1EA7':'a','\u1EA5':'a','\u1EAB':'a','\u1EA9':'a','\u00E3':'a','\u0101':'a','\u0103':'a','\u1EB1':'a','\u1EAF':'a','\u1EB5':'a','\u1EB3':'a','\u0227':'a','\u01E1':'a','\u00E4':'a','\u01DF':'a','\u1EA3':'a','\u00E5':'a','\u01FB':'a','\u01CE':'a','\u0201':'a','\u0203':'a','\u1EA1':'a','\u1EAD':'a','\u1EB7':'a','\u1E01':'a','\u0105':'a','\u2C65':'a','\u0250':'a','\uA733':'aa','\u00E6':'ae','\u01FD':'ae','\u01E3':'ae','\uA735':'ao','\uA737':'au','\uA739':'av','\uA73B':'av','\uA73D':'ay','\u24D1':'b','\uFF42':'b','\u1E03':'b','\u1E05':'b','\u1E07':'b','\u0180':'b','\u0183':'b','\u0253':'b','\u24D2':'c','\uFF43':'c','\u0107':'c','\u0109':'c','\u010B':'c','\u010D':'c','\u00E7':'c','\u1E09':'c','\u0188':'c','\u023C':'c','\uA73F':'c','\u2184':'c','\u24D3':'d','\uFF44':'d','\u1E0B':'d','\u010F':'d','\u1E0D':'d','\u1E11':'d','\u1E13':'d','\u1E0F':'d','\u0111':'d','\u018C':'d','\u0256':'d','\u0257':'d','\uA77A':'d','\u01F3':'dz','\u01C6':'dz','\u24D4':'e','\uFF45':'e','\u00E8':'e','\u00E9':'e','\u00EA':'e','\u1EC1':'e','\u1EBF':'e','\u1EC5':'e','\u1EC3':'e','\u1EBD':'e','\u0113':'e','\u1E15':'e','\u1E17':'e','\u0115':'e','\u0117':'e','\u00EB':'e','\u1EBB':'e','\u011B':'e','\u0205':'e','\u0207':'e','\u1EB9':'e','\u1EC7':'e','\u0229':'e','\u1E1D':'e','\u0119':'e','\u1E19':'e','\u1E1B':'e','\u0247':'e','\u025B':'e','\u01DD':'e','\u24D5':'f','\uFF46':'f','\u1E1F':'f','\u0192':'f','\uA77C':'f','\u24D6':'g','\uFF47':'g','\u01F5':'g','\u011D':'g','\u1E21':'g','\u011F':'g','\u0121':'g','\u01E7':'g','\u0123':'g','\u01E5':'g','\u0260':'g','\uA7A1':'g','\u1D79':'g','\uA77F':'g','\u24D7':'h','\uFF48':'h','\u0125':'h','\u1E23':'h','\u1E27':'h','\u021F':'h','\u1E25':'h','\u1E29':'h','\u1E2B':'h','\u1E96':'h','\u0127':'h','\u2C68':'h','\u2C76':'h','\u0265':'h','\u0195':'hv','\u24D8':'i','\uFF49':'i','\u00EC':'i','\u00ED':'i','\u00EE':'i','\u0129':'i','\u012B':'i','\u012D':'i','\u00EF':'i','\u1E2F':'i','\u1EC9':'i','\u01D0':'i','\u0209':'i','\u020B':'i','\u1ECB':'i','\u012F':'i','\u1E2D':'i','\u0268':'i','\u0131':'i','\u24D9':'j','\uFF4A':'j','\u0135':'j','\u01F0':'j','\u0249':'j','\u24DA':'k','\uFF4B':'k','\u1E31':'k','\u01E9':'k','\u1E33':'k','\u0137':'k','\u1E35':'k','\u0199':'k','\u2C6A':'k','\uA741':'k','\uA743':'k','\uA745':'k','\uA7A3':'k','\u24DB':'l','\uFF4C':'l','\u0140':'l','\u013A':'l','\u013E':'l','\u1E37':'l','\u1E39':'l','\u013C':'l','\u1E3D':'l','\u1E3B':'l','\u017F':'l','\u0142':'l','\u019A':'l','\u026B':'l','\u2C61':'l','\uA749':'l','\uA781':'l','\uA747':'l','\u01C9':'lj','\u24DC':'m','\uFF4D':'m','\u1E3F':'m','\u1E41':'m','\u1E43':'m','\u0271':'m','\u026F':'m','\u24DD':'n','\uFF4E':'n','\u01F9':'n','\u0144':'n','\u00F1':'n','\u1E45':'n','\u0148':'n','\u1E47':'n','\u0146':'n','\u1E4B':'n','\u1E49':'n','\u019E':'n','\u0272':'n','\u0149':'n','\uA791':'n','\uA7A5':'n','\u01CC':'nj','\u24DE':'o','\uFF4F':'o','\u00F2':'o','\u00F3':'o','\u00F4':'o','\u1ED3':'o','\u1ED1':'o','\u1ED7':'o','\u1ED5':'o','\u00F5':'o','\u1E4D':'o','\u022D':'o','\u1E4F':'o','\u014D':'o','\u1E51':'o','\u1E53':'o','\u014F':'o','\u022F':'o','\u0231':'o','\u00F6':'o','\u022B':'o','\u1ECF':'o','\u0151':'o','\u01D2':'o','\u020D':'o','\u020F':'o','\u01A1':'o','\u1EDD':'o','\u1EDB':'o','\u1EE1':'o','\u1EDF':'o','\u1EE3':'o','\u1ECD':'o','\u1ED9':'o','\u01EB':'o','\u01ED':'o','\u00F8':'o','\u01FF':'o','\u0254':'o','\uA74B':'o','\uA74D':'o','\u0275':'o','\u01A3':'oi','\u0223':'ou','\uA74F':'oo','\u24DF':'p','\uFF50':'p','\u1E55':'p','\u1E57':'p','\u01A5':'p','\u1D7D':'p','\uA751':'p','\uA753':'p','\uA755':'p','\u24E0':'q','\uFF51':'q','\u024B':'q','\uA757':'q','\uA759':'q','\u24E1':'r','\uFF52':'r','\u0155':'r','\u1E59':'r','\u0159':'r','\u0211':'r','\u0213':'r','\u1E5B':'r','\u1E5D':'r','\u0157':'r','\u1E5F':'r','\u024D':'r','\u027D':'r','\uA75B':'r','\uA7A7':'r','\uA783':'r','\u24E2':'s','\uFF53':'s','\u00DF':'s','\u015B':'s','\u1E65':'s','\u015D':'s','\u1E61':'s','\u0161':'s','\u1E67':'s','\u1E63':'s','\u1E69':'s','\u0219':'s','\u015F':'s','\u023F':'s','\uA7A9':'s','\uA785':'s','\u1E9B':'s','\u24E3':'t','\uFF54':'t','\u1E6B':'t','\u1E97':'t','\u0165':'t','\u1E6D':'t','\u021B':'t','\u0163':'t','\u1E71':'t','\u1E6F':'t','\u0167':'t','\u01AD':'t','\u0288':'t','\u2C66':'t','\uA787':'t','\uA729':'tz','\u24E4':'u','\uFF55':'u','\u00F9':'u','\u00FA':'u','\u00FB':'u','\u0169':'u','\u1E79':'u','\u016B':'u','\u1E7B':'u','\u016D':'u','\u00FC':'u','\u01DC':'u','\u01D8':'u','\u01D6':'u','\u01DA':'u','\u1EE7':'u','\u016F':'u','\u0171':'u','\u01D4':'u','\u0215':'u','\u0217':'u','\u01B0':'u','\u1EEB':'u','\u1EE9':'u','\u1EEF':'u','\u1EED':'u','\u1EF1':'u','\u1EE5':'u','\u1E73':'u','\u0173':'u','\u1E77':'u','\u1E75':'u','\u0289':'u','\u24E5':'v','\uFF56':'v','\u1E7D':'v','\u1E7F':'v','\u028B':'v','\uA75F':'v','\u028C':'v','\uA761':'vy','\u24E6':'w','\uFF57':'w','\u1E81':'w','\u1E83':'w','\u0175':'w','\u1E87':'w','\u1E85':'w','\u1E98':'w','\u1E89':'w','\u2C73':'w','\u24E7':'x','\uFF58':'x','\u1E8B':'x','\u1E8D':'x','\u24E8':'y','\uFF59':'y','\u1EF3':'y','\u00FD':'y','\u0177':'y','\u1EF9':'y','\u0233':'y','\u1E8F':'y','\u00FF':'y','\u1EF7':'y','\u1E99':'y','\u1EF5':'y','\u01B4':'y','\u024F':'y','\u1EFF':'y','\u24E9':'z','\uFF5A':'z','\u017A':'z','\u1E91':'z','\u017C':'z','\u017E':'z','\u1E93':'z','\u1E95':'z','\u01B6':'z','\u0225':'z','\u0240':'z','\u2C6C':'z','\uA763':'z','\u0386':'\u0391','\u0388':'\u0395','\u0389':'\u0397','\u038A':'\u0399','\u03AA':'\u0399','\u038C':'\u039F','\u038E':'\u03A5','\u03AB':'\u03A5','\u038F':'\u03A9','\u03AC':'\u03B1','\u03AD':'\u03B5','\u03AE':'\u03B7','\u03AF':'\u03B9','\u03CA':'\u03B9','\u0390':'\u03B9','\u03CC':'\u03BF','\u03CD':'\u03C5','\u03CB':'\u03C5','\u03B0':'\u03C5','\u03C9':'\u03C9','\u03C2':'\u03C3'};return diacritics;});S2.define('select2/data/base',['../utils'],function(Utils){function BaseAdapter($element,options){BaseAdapter.__super__.constructor.call(this);} Utils.Extend(BaseAdapter,Utils.Observable);BaseAdapter.prototype.current=function(callback){throw new Error('The `current` method must be defined in child classes.');};BaseAdapter.prototype.query=function(params,callback){throw new Error('The `query` method must be defined in child classes.');};BaseAdapter.prototype.bind=function(container,$container){};BaseAdapter.prototype.destroy=function(){};BaseAdapter.prototype.generateResultId=function(container,data){var id=container.id+'-result-';id+=Utils.generateChars(4);if(data.id!=null){id+='-'+data.id.toString();}else{id+='-'+Utils.generateChars(4);} @@ -631,7 +633,7 @@ for(var d=0;d0&&count>=self.maximumSelectionLength){self.trigger('results:message',{message:'maximumSelected',args:{maximum:self.maximumSelectionLength}});return;} decorated.call(self,params,callback);});};return MaximumSelectionLength;});S2.define('select2/dropdown',['jquery','./utils'],function($,Utils){function Dropdown($element,options){this.$element=$element;this.options=options;Dropdown.__super__.constructor.call(this);} Utils.Extend(Dropdown,Utils.Observable);Dropdown.prototype.render=function(){var $dropdown=$(''+''+'');$dropdown.attr('dir',this.options.get('dir'));this.$dropdown=$dropdown;return $dropdown;};Dropdown.prototype.position=function($dropdown,$container){};Dropdown.prototype.destroy=function(){this.$dropdown.remove();};return Dropdown;});S2.define('select2/dropdown/search',['jquery','../utils'],function($,Utils){function Search(){} -Search.prototype.render=function(decorated){var $rendered=decorated.call(this);var $search=$(''+''+'');this.$searchContainer=$search;this.$search=$search.find('input');$rendered.prepend($search);return $rendered;};Search.prototype.bind=function(decorated,container,$container){var self=this;decorated.call(this,container,$container);this.$search.on('keydown',function(evt){self.trigger('keypress',evt);self._keyUpPrevented=false;});this.$search.on('input',function(evt){$(this).off('keyup');});this.$search.on('keyup input',function(evt){self.handleSearch(evt);});container.on('open',function(){self.$search.attr('tabindex',0);self.$search.focus();window.setTimeout(function(){self.$search.focus();},0);});container.on('close',function(){self.$search.attr('tabindex',-1);self.$search.val('');});container.on('results:all',function(params){if(params.query.term==null||params.query.term===''){var showSearch=self.showSearch(params);if(showSearch){self.$searchContainer.removeClass('select2-search--hide');}else{self.$searchContainer.addClass('select2-search--hide');}}});};Search.prototype.handleSearch=function(evt){if(!this._keyUpPrevented){var input=this.$search.val();this.trigger('query',{term:input});} +Search.prototype.render=function(decorated){var $rendered=decorated.call(this);var $search=$(''+''+'');this.$searchContainer=$search;this.$search=$search.find('input');$rendered.prepend($search);return $rendered;};Search.prototype.bind=function(decorated,container,$container){var self=this;decorated.call(this,container,$container);this.$search.on('keydown',function(evt){self.trigger('keypress',evt);self._keyUpPrevented=evt.isDefaultPrevented();});this.$search.on('input',function(evt){$(this).off('keyup');});this.$search.on('keyup input',function(evt){self.handleSearch(evt);});container.on('open',function(){self.$search.attr('tabindex',0);self.$search.focus();window.setTimeout(function(){self.$search.focus();},0);});container.on('close',function(){self.$search.attr('tabindex',-1);self.$search.val('');});container.on('results:all',function(params){if(params.query.term==null||params.query.term===''){var showSearch=self.showSearch(params);if(showSearch){self.$searchContainer.removeClass('select2-search--hide');}else{self.$searchContainer.addClass('select2-search--hide');}}});};Search.prototype.handleSearch=function(evt){if(!this._keyUpPrevented){var input=this.$search.val();this.trigger('query',{term:input});} this._keyUpPrevented=false;};Search.prototype.showSearch=function(_,params){return true;};return Search;});S2.define('select2/dropdown/hidePlaceholder',[],function(){function HidePlaceholder(decorated,$element,options,dataAdapter){this.placeholder=this.normalizePlaceholder(options.get('placeholder'));decorated.call(this,$element,options,dataAdapter);} HidePlaceholder.prototype.append=function(decorated,data){data.results=this.removePlaceholder(data.results);decorated.call(this,data);};HidePlaceholder.prototype.normalizePlaceholder=function(_,placeholder){if(typeof placeholder==='string'){placeholder={id:'',text:placeholder};} return placeholder;};HidePlaceholder.prototype.removePlaceholder=function(_,data){var modifiedData=data.slice(0);for(var d=data.length-1;d>=0;d--){var item=data[d];if(this.placeholder.id===item.id){modifiedData.splice(d,1);}} @@ -673,12 +675,14 @@ InfiniteScroll.prototype.append=function(decorated,data){this.$loadingMore.remov var currentOffset=self.$results.offset().top+ self.$results.outerHeight(false);var loadingMoreOffset=self.$loadingMore.offset().top+ self.$loadingMore.outerHeight(false);if(currentOffset+50>=loadingMoreOffset){self.loadMore();}});};InfiniteScroll.prototype.loadMore=function(){this.loading=true;var params=$.extend({},{page:1},this.lastParams);params.page++;this.trigger('query:append',params);};InfiniteScroll.prototype.showLoadingMore=function(_,data){return data.pagination&&data.pagination.more;};InfiniteScroll.prototype.createLoadingMore=function(){var $option=$('
  • ');var message=this.options.get('translations').get('loadingMore');$option.html(message(this.lastParams));return $option;};return InfiniteScroll;});S2.define('select2/dropdown/attachBody',['jquery','../utils'],function($,Utils){function AttachBody(decorated,$element,options){this.$dropdownParent=options.get('dropdownParent')||document.body;decorated.call(this,$element,options);} -AttachBody.prototype.bind=function(decorated,container,$container){var self=this;var setupResultsEvents=false;decorated.call(this,container,$container);container.on('open',function(){self._showDropdown();self._attachPositioningHandler(container);if(!setupResultsEvents){setupResultsEvents=true;container.on('results:all',function(){self._positionDropdown();self._resizeDropdown();});container.on('results:append',function(){self._positionDropdown();self._resizeDropdown();});}});container.on('close',function(){self._hideDropdown();self._detachPositioningHandler(container);});this.$dropdownContainer.on('mousedown',function(evt){evt.stopPropagation();});};AttachBody.prototype.position=function(decorated,$dropdown,$container){$dropdown.attr('class',$container.attr('class'));$dropdown.removeClass('select2');$dropdown.addClass('select2-container--open');$dropdown.css({position:'absolute',top:-999999});this.$container=$container;};AttachBody.prototype.render=function(decorated){var $container=$('');var $dropdown=decorated.call(this);$container.append($dropdown);this.$dropdownContainer=$container;return $container;};AttachBody.prototype._hideDropdown=function(decorated){this.$dropdownContainer.detach();};AttachBody.prototype._attachPositioningHandler=function(container){var self=this;var scrollEvent='scroll.select2.'+container.id;var resizeEvent='resize.select2.'+container.id;var orientationEvent='orientationchange.select2.'+container.id;var $watchers=this.$container.parents().filter(Utils.hasScroll);$watchers.each(function(){$(this).data('select2-scroll-position',{x:$(this).scrollLeft(),y:$(this).scrollTop()});});$watchers.on(scrollEvent,function(ev){var position=$(this).data('select2-scroll-position');$(this).scrollTop(position.y);});$(window).on(scrollEvent+' '+resizeEvent+' '+orientationEvent,function(e){self._positionDropdown();self._resizeDropdown();});};AttachBody.prototype._detachPositioningHandler=function(container){var scrollEvent='scroll.select2.'+container.id;var resizeEvent='resize.select2.'+container.id;var orientationEvent='orientationchange.select2.'+container.id;var $watchers=this.$container.parents().filter(Utils.hasScroll);$watchers.off(scrollEvent);$(window).off(scrollEvent+' '+resizeEvent+' '+orientationEvent);};AttachBody.prototype._positionDropdown=function(){var $window=$(window);var isCurrentlyAbove=this.$dropdown.hasClass('select2-dropdown--above');var isCurrentlyBelow=this.$dropdown.hasClass('select2-dropdown--below');var newDirection=null;var position=this.$container.position();var offset=this.$container.offset();offset.bottom=offset.top+this.$container.outerHeight(false);var container={height:this.$container.outerHeight(false)};container.top=offset.top;container.bottom=offset.top+container.height;var dropdown={height:this.$dropdown.outerHeight(false)};var viewport={top:$window.scrollTop(),bottom:$window.scrollTop()+$window.height()};var enoughRoomAbove=viewport.top<(offset.top-dropdown.height);var enoughRoomBelow=viewport.bottom>(offset.bottom+dropdown.height);var css={left:offset.left,top:container.bottom};if(!isCurrentlyAbove&&!isCurrentlyBelow){newDirection='below';} +AttachBody.prototype.bind=function(decorated,container,$container){var self=this;var setupResultsEvents=false;decorated.call(this,container,$container);container.on('open',function(){self._showDropdown();self._attachPositioningHandler(container);if(!setupResultsEvents){setupResultsEvents=true;container.on('results:all',function(){self._positionDropdown();self._resizeDropdown();});container.on('results:append',function(){self._positionDropdown();self._resizeDropdown();});}});container.on('close',function(){self._hideDropdown();self._detachPositioningHandler(container);});this.$dropdownContainer.on('mousedown.select2',function(evt){evt.stopPropagation();});};AttachBody.prototype.position=function(decorated,$dropdown,$container){$dropdown.attr('class',$container.attr('class'));$dropdown.removeClass('select2');$dropdown.addClass('select2-container--open');$dropdown.css({position:'absolute',top:-999999});this.$container=$container;};AttachBody.prototype.render=function(decorated){var $container=$('');var $dropdown=decorated.call(this);$container.append($dropdown);this.$dropdownContainer=$container;return $container;};AttachBody.prototype._hideDropdown=function(decorated){this.$dropdownContainer.detach();};AttachBody.prototype._attachPositioningHandler=function(container){var self=this;var scrollEvent='scroll.select2.'+container.id;var resizeEvent='resize.select2.'+container.id;var orientationEvent='orientationchange.select2.'+container.id;var $watchers=this.$container.parents().filter(Utils.hasScroll);$watchers.each(function(){$(this).data('select2-scroll-position',{x:$(this).scrollLeft(),y:$(this).scrollTop()});});$watchers.on(scrollEvent,function(ev){var position=$(this).data('select2-scroll-position');$(this).scrollTop(position.y);});$(window).on(scrollEvent+' '+resizeEvent+' '+orientationEvent,function(e){self._positionDropdown();self._resizeDropdown();});};AttachBody.prototype._detachPositioningHandler=function(container){var scrollEvent='scroll.select2.'+container.id;var resizeEvent='resize.select2.'+container.id;var orientationEvent='orientationchange.select2.'+container.id;var $watchers=this.$container.parents().filter(Utils.hasScroll);$watchers.off(scrollEvent);$(window).off(scrollEvent+' '+resizeEvent+' '+orientationEvent);};AttachBody.prototype._positionDropdown=function(){var $window=$(window);var isCurrentlyAbove=this.$dropdown.hasClass('select2-dropdown--above');var isCurrentlyBelow=this.$dropdown.hasClass('select2-dropdown--below');var newDirection=null;var position=this.$container.position();var offset=this.$container.offset();offset.bottom=offset.top+this.$container.outerHeight(false);var container={height:this.$container.outerHeight(false)};container.top=offset.top;container.bottom=offset.top+container.height;var dropdown={height:this.$dropdown.outerHeight(false)};var viewport={top:$window.scrollTop(),bottom:$window.scrollTop()+$window.height()};var enoughRoomAbove=viewport.top<(offset.top-dropdown.height);var enoughRoomBelow=viewport.bottom>(offset.bottom+dropdown.height);var css={left:offset.left,top:container.bottom};if(!isCurrentlyAbove&&!isCurrentlyBelow){newDirection='below';} if(!enoughRoomBelow&&enoughRoomAbove&&!isCurrentlyAbove){newDirection='above';}else if(!enoughRoomAbove&&enoughRoomBelow&&isCurrentlyAbove){newDirection='below';} if(newDirection=='above'||(isCurrentlyAbove&&newDirection!=='below')){css.top=container.top-dropdown.height;} if(newDirection!=null){this.$dropdown.removeClass('select2-dropdown--below select2-dropdown--above').addClass('select2-dropdown--'+newDirection);this.$container.removeClass('select2-container--below select2-container--above').addClass('select2-container--'+newDirection);} this.$dropdownContainer.css(css);};AttachBody.prototype._resizeDropdown=function(){this.$dropdownContainer.width();var css={width:this.$container.outerWidth(false)+'px'};if(this.options.get('dropdownAutoWidth')){css.minWidth=css.width;css.width='auto';} -this.$dropdown.css(css);};AttachBody.prototype._showDropdown=function(decorated){this.$dropdownContainer.appendTo(this.$dropdownParent);this._positionDropdown();this._resizeDropdown();};return AttachBody;});S2.define('select2/dropdown/minimumResultsForSearch',[],function(){function countResults(data){var count=0;for(var d=0;d=1){return matches[1];}} return null;} return method;};Select2.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container);this.selection.bind(this,this.$container);this.dropdown.bind(this,this.$container);this.results.bind(this,this.$container);};Select2.prototype._registerDomEvents=function(){var self=this;this.$element.on('change.select2',function(){self.dataAdapter.current(function(data){self.trigger('selection:update',{data:data});});});this._sync=Utils.bind(this._syncAttributes,this);if(this.$element[0].attachEvent){this.$element[0].attachEvent('onpropertychange',this._sync);} -var observer=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;if(observer!=null){this._observer=new observer(function(mutations){$.each(mutations,self._sync);});this._observer.observe(this.$element[0],{attributes:true,subtree:false});}else if(this.$element[0].addEventListener){this.$element[0].addEventListener('DOMAttrModified',self._sync,false);}};Select2.prototype._registerDataEvents=function(){var self=this;this.dataAdapter.on('*',function(name,params){self.trigger(name,params);});};Select2.prototype._registerSelectionEvents=function(){var self=this;var nonRelayEvents=['toggle','focus'];this.selection.on('toggle',function(){self.toggleDropdown();});this.selection.on('focus',function(params){self.focus(params);});this.selection.on('*',function(name,params){if($.inArray(name,nonRelayEvents)!==-1){return;} -self.trigger(name,params);});};Select2.prototype._registerDropdownEvents=function(){var self=this;this.dropdown.on('*',function(name,params){self.trigger(name,params);});};Select2.prototype._registerResultsEvents=function(){var self=this;this.results.on('*',function(name,params){self.trigger(name,params);});};Select2.prototype._registerEvents=function(){var self=this;this.on('open',function(){self.$container.addClass('select2-container--open');});this.on('close',function(){self.$container.removeClass('select2-container--open');});this.on('enable',function(){self.$container.removeClass('select2-container--disabled');});this.on('disable',function(){self.$container.addClass('select2-container--disabled');});this.on('blur',function(){self.$container.removeClass('select2-container--focus');});this.on('query',function(params){if(!self.isOpen()){self.trigger('open');} -this.dataAdapter.query(params,function(data){self.trigger('results:all',{data:data,query:params});});});this.on('query:append',function(params){this.dataAdapter.query(params,function(data){self.trigger('results:append',{data:data,query:params});});});this.on('keypress',function(evt){var key=evt.which;if(self.isOpen()){if(key===KEYS.ESC||key===KEYS.TAB||(key===KEYS.UP&&evt.altKey)){self.close();evt.preventDefault();}else if(key===KEYS.ENTER){self.trigger('results:select');evt.preventDefault();}else if((key===KEYS.SPACE&&evt.ctrlKey)){self.trigger('results:toggle');evt.preventDefault();}else if(key===KEYS.UP){self.trigger('results:previous');evt.preventDefault();}else if(key===KEYS.DOWN){self.trigger('results:next');evt.preventDefault();}}else{if(key===KEYS.ENTER||key===KEYS.SPACE||(key===KEYS.DOWN&&evt.altKey)){self.open();evt.preventDefault();}}});};Select2.prototype._syncAttributes=function(){this.options.set('disabled',this.$element.prop('disabled'));if(this.options.get('disabled')){if(this.isOpen()){this.close();} +var observer=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;if(observer!=null){this._observer=new observer(function(mutations){$.each(mutations,self._sync);});this._observer.observe(this.$element[0],{attributes:true,subtree:false});}else if(this.$element[0].addEventListener){this.$element[0].addEventListener('DOMAttrModified',self._sync,false);}};Select2.prototype._registerDataEvents=function(){var self=this;this.dataAdapter.on('*',function(name,params){self.trigger(name,params);});};Select2.prototype._registerSelectionEvents=function(){var self=this;var nonRelayEvents=['toggle'];this.selection.on('toggle',function(){self.toggleDropdown();});this.selection.on('*',function(name,params){if($.inArray(name,nonRelayEvents)!==-1){return;} +self.trigger(name,params);});};Select2.prototype._registerDropdownEvents=function(){var self=this;this.dropdown.on('*',function(name,params){self.trigger(name,params);});};Select2.prototype._registerResultsEvents=function(){var self=this;this.results.on('*',function(name,params){self.trigger(name,params);});};Select2.prototype._registerEvents=function(){var self=this;this.on('open',function(){self.$container.addClass('select2-container--open');});this.on('close',function(){self.$container.removeClass('select2-container--open');});this.on('enable',function(){self.$container.removeClass('select2-container--disabled');});this.on('disable',function(){self.$container.addClass('select2-container--disabled');});this.on('focus',function(){self.$container.addClass('select2-container--focus');});this.on('blur',function(){self.$container.removeClass('select2-container--focus');});this.on('query',function(params){if(!self.isOpen()){self.trigger('open');} +this.dataAdapter.query(params,function(data){self.trigger('results:all',{data:data,query:params});});});this.on('query:append',function(params){this.dataAdapter.query(params,function(data){self.trigger('results:append',{data:data,query:params});});});this.on('keypress',function(evt){var key=evt.which;if(self.isOpen()){if(key===KEYS.ENTER){self.trigger('results:select');evt.preventDefault();}else if((key===KEYS.SPACE&&evt.ctrlKey)){self.trigger('results:toggle');evt.preventDefault();}else if(key===KEYS.UP){self.trigger('results:previous');evt.preventDefault();}else if(key===KEYS.DOWN){self.trigger('results:next');evt.preventDefault();}else if(key===KEYS.ESC||key===KEYS.TAB){self.close();evt.preventDefault();}}else{if(key===KEYS.ENTER||key===KEYS.SPACE||((key===KEYS.DOWN||key===KEYS.UP)&&evt.altKey)){self.open();evt.preventDefault();}}});};Select2.prototype._syncAttributes=function(){this.options.set('disabled',this.$element.prop('disabled'));if(this.options.get('disabled')){if(this.isOpen()){this.close();} this.trigger('disable');}else{this.trigger('enable');}};Select2.prototype.trigger=function(name,args){var actualTrigger=Select2.__super__.trigger;var preTriggerMap={'open':'opening','close':'closing','select':'selecting','unselect':'unselecting'};if(name in preTriggerMap){var preTriggerName=preTriggerMap[name];var preTriggerArgs={prevented:false,name:name,args:args};actualTrigger.call(this,preTriggerName,preTriggerArgs);if(preTriggerArgs.prevented){args.prevented=true;return;}} actualTrigger.call(this,name,args);};Select2.prototype.toggleDropdown=function(){if(this.options.get('disabled')){return;} if(this.isOpen()){this.close();}else{this.open();}};Select2.prototype.open=function(){if(this.isOpen()){return;} this.trigger('query',{});this.trigger('open');};Select2.prototype.close=function(){if(!this.isOpen()){return;} -this.trigger('close');};Select2.prototype.isOpen=function(){return this.$container.hasClass('select2-container--open');};Select2.prototype.hasFocus=function(){return this.$container.hasClass('select2-container--focus');};Select2.prototype.focus=function(data){if(this.hasFocus()){return;} -this.$container.addClass('select2-container--focus');this.trigger('focus');};Select2.prototype.enable=function(args){if(this.options.get('debug')&&window.console&&console.warn){console.warn('Select2: The `select2("enable")` method has been deprecated and will'+' be removed in later Select2 versions. Use $element.prop("disabled")'+' instead.');} +this.trigger('close');};Select2.prototype.isOpen=function(){return this.$container.hasClass('select2-container--open');};Select2.prototype.enable=function(args){if(this.options.get('debug')&&window.console&&console.warn){console.warn('Select2: The `select2("enable")` method has been deprecated and will'+' be removed in later Select2 versions. Use $element.prop("disabled")'+' instead.');} if(args==null||args.length===0){args=[true];} var disabled=!args[0];this.$element.prop('disabled',disabled);};Select2.prototype.data=function(){if(this.options.get('debug')&&arguments.length>0&&window.console&&console.warn){console.warn('Select2: Data can no longer be set using `select2("data")`. You '+'should consider setting the value instead using `$element.val()`.');} var data=[];this.dataAdapter.current(function(currentData){data=currentData;});return data;};Select2.prototype.val=function(args){if(this.options.get('debug')&&window.console&&console.warn){console.warn('Select2: The `select2("val")` method has been deprecated and will be'+' removed in later Select2 versions. Use $element.val() instead.');} @@ -770,13 +773,13 @@ $dest.attr('class',replacements.join(' '));} return{syncCssClasses:syncCssClasses};});S2.define('select2/compat/containerCss',['jquery','./utils'],function($,CompatUtils){function _containerAdapter(clazz){return null;} function ContainerCSS(){} ContainerCSS.prototype.render=function(decorated){var $container=decorated.call(this);var containerCssClass=this.options.get('containerCssClass')||'';if($.isFunction(containerCssClass)){containerCssClass=containerCssClass(this.$element);} -var containerCssAdapter=this.options.get('adaptContainerCssClass');containerCssAdapter=containerCssAdapter||_containerAdapter;if(containerCssClass.indexOf(':all:')!==-1){containerCssClass=containerCssClass.replace(':all:','');var _cssAdapter=containerCssAdapter;containerCssAdapter=function(clazz){var adapted=_cssAdapter(clazz);if(adapted!=null){return adapted+' '+clazz;} +var containerCssAdapter=this.options.get('adaptContainerCssClass');containerCssAdapter=containerCssAdapter||_containerAdapter;if(containerCssClass.indexOf(':all:')!==-1){containerCssClass=containerCssClass.replace(':all','');var _cssAdapter=containerCssAdapter;containerCssAdapter=function(clazz){var adapted=_cssAdapter(clazz);if(adapted!=null){return adapted+' '+clazz;} return clazz;};} var containerCss=this.options.get('containerCss')||{};if($.isFunction(containerCss)){containerCss=containerCss(this.$element);} CompatUtils.syncCssClasses($container,this.$element,containerCssAdapter);$container.css(containerCss);$container.addClass(containerCssClass);return $container;};return ContainerCSS;});S2.define('select2/compat/dropdownCss',['jquery','./utils'],function($,CompatUtils){function _dropdownAdapter(clazz){return null;} function DropdownCSS(){} DropdownCSS.prototype.render=function(decorated){var $dropdown=decorated.call(this);var dropdownCssClass=this.options.get('dropdownCssClass')||'';if($.isFunction(dropdownCssClass)){dropdownCssClass=dropdownCssClass(this.$element);} -var dropdownCssAdapter=this.options.get('adaptDropdownCssClass');dropdownCssAdapter=dropdownCssAdapter||_dropdownAdapter;if(dropdownCssClass.indexOf(':all:')!==-1){dropdownCssClass=dropdownCssClass.replace(':all:','');var _cssAdapter=dropdownCssAdapter;dropdownCssAdapter=function(clazz){var adapted=_cssAdapter(clazz);if(adapted!=null){return adapted+' '+clazz;} +var dropdownCssAdapter=this.options.get('adaptDropdownCssClass');dropdownCssAdapter=dropdownCssAdapter||_dropdownAdapter;if(dropdownCssClass.indexOf(':all:')!==-1){dropdownCssClass=dropdownCssClass.replace(':all','');var _cssAdapter=dropdownCssAdapter;dropdownCssAdapter=function(clazz){var adapted=_cssAdapter(clazz);if(adapted!=null){return adapted+' '+clazz;} return clazz;};} var dropdownCss=this.options.get('dropdownCss')||{};if($.isFunction(dropdownCss)){dropdownCss=dropdownCss(this.$element);} CompatUtils.syncCssClasses($dropdown,this.$element,dropdownCssAdapter);$dropdown.css(dropdownCss);$dropdown.addClass(dropdownCssClass);return $dropdown;};return DropdownCSS;});S2.define('select2/compat/initSelection',['jquery'],function($){function InitSelection(decorated,$element,options){if(options.get('debug')&&window.console&&console.warn){console.warn('Select2: The `initSelection` option has been deprecated in favor'+' of a custom data adapter that overrides the `current` method. '+'This method is now called multiple times instead of a single '+'time when the instance is initialized. Support will be removed '+'for the `initSelection` option in future versions of Select2');} diff --git a/modules/system/assets/ui/vendor/select2/OCTOBER-README.md b/modules/system/assets/ui/vendor/select2/OCTOBER-README.md new file mode 100644 index 000000000..08deefa84 --- /dev/null +++ b/modules/system/assets/ui/vendor/select2/OCTOBER-README.md @@ -0,0 +1,18 @@ +There's a hack in select2.full.js. The hack prevents DOM element leakage through the event handler. Added/updated code: + +Line 3961, added .select2 namespace in the event handler registration: + + this.$dropdownContainer.on('mousedown.select2', function (evt) { + +Lines 4120-4124. Added new method: + +``` + AttachBody.prototype.destroy = function(decorated) { + this.$dropdownContainer.off('.select2') + + decorated.call(this); + } +``` + +Filed an issue: https://github.com/select2/select2/issues/3774 +The issue was closed by the developers - the problem is going to be fixed in the upcoming 4.0.1 release. \ No newline at end of file diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/az.js b/modules/system/assets/ui/vendor/select2/js/i18n/az.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/bg.js b/modules/system/assets/ui/vendor/select2/js/i18n/bg.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/ca.js b/modules/system/assets/ui/vendor/select2/js/i18n/ca.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/cs.js b/modules/system/assets/ui/vendor/select2/js/i18n/cs.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/da.js b/modules/system/assets/ui/vendor/select2/js/i18n/da.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/de.js b/modules/system/assets/ui/vendor/select2/js/i18n/de.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/en.js b/modules/system/assets/ui/vendor/select2/js/i18n/en.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/es.js b/modules/system/assets/ui/vendor/select2/js/i18n/es.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/et.js b/modules/system/assets/ui/vendor/select2/js/i18n/et.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/eu.js b/modules/system/assets/ui/vendor/select2/js/i18n/eu.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/fa.js b/modules/system/assets/ui/vendor/select2/js/i18n/fa.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/fi.js b/modules/system/assets/ui/vendor/select2/js/i18n/fi.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/fr.js b/modules/system/assets/ui/vendor/select2/js/i18n/fr.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/gl.js b/modules/system/assets/ui/vendor/select2/js/i18n/gl.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/he.js b/modules/system/assets/ui/vendor/select2/js/i18n/he.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/hi.js b/modules/system/assets/ui/vendor/select2/js/i18n/hi.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/hr.js b/modules/system/assets/ui/vendor/select2/js/i18n/hr.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/hu.js b/modules/system/assets/ui/vendor/select2/js/i18n/hu.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/id.js b/modules/system/assets/ui/vendor/select2/js/i18n/id.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/is.js b/modules/system/assets/ui/vendor/select2/js/i18n/is.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/it.js b/modules/system/assets/ui/vendor/select2/js/i18n/it.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/ko.js b/modules/system/assets/ui/vendor/select2/js/i18n/ko.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/lt.js b/modules/system/assets/ui/vendor/select2/js/i18n/lt.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/lv.js b/modules/system/assets/ui/vendor/select2/js/i18n/lv.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/mk.js b/modules/system/assets/ui/vendor/select2/js/i18n/mk.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/nb.js b/modules/system/assets/ui/vendor/select2/js/i18n/nb.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/nl.js b/modules/system/assets/ui/vendor/select2/js/i18n/nl.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/pl.js b/modules/system/assets/ui/vendor/select2/js/i18n/pl.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/pt-BR.js b/modules/system/assets/ui/vendor/select2/js/i18n/pt-BR.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/pt.js b/modules/system/assets/ui/vendor/select2/js/i18n/pt.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/ro.js b/modules/system/assets/ui/vendor/select2/js/i18n/ro.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/ru.js b/modules/system/assets/ui/vendor/select2/js/i18n/ru.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/sk.js b/modules/system/assets/ui/vendor/select2/js/i18n/sk.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/sr.js b/modules/system/assets/ui/vendor/select2/js/i18n/sr.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/sv.js b/modules/system/assets/ui/vendor/select2/js/i18n/sv.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/th.js b/modules/system/assets/ui/vendor/select2/js/i18n/th.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/tr.js b/modules/system/assets/ui/vendor/select2/js/i18n/tr.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/uk.js b/modules/system/assets/ui/vendor/select2/js/i18n/uk.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/vi.js b/modules/system/assets/ui/vendor/select2/js/i18n/vi.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/zh-CN.js b/modules/system/assets/ui/vendor/select2/js/i18n/zh-CN.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/i18n/zh-TW.js b/modules/system/assets/ui/vendor/select2/js/i18n/zh-TW.js old mode 100644 new mode 100755 diff --git a/modules/system/assets/ui/vendor/select2/js/select2.full.js b/modules/system/assets/ui/vendor/select2/js/select2.full.js index dd0e8bc74..9750960ef 100755 --- a/modules/system/assets/ui/vendor/select2/js/select2.full.js +++ b/modules/system/assets/ui/vendor/select2/js/select2.full.js @@ -3958,7 +3958,7 @@ S2.define('select2/dropdown/attachBody',[ self._detachPositioningHandler(container); }); - this.$dropdownContainer.on('mousedown', function (evt) { + this.$dropdownContainer.on('mousedown.select2', function (evt) { evt.stopPropagation(); }); }; @@ -4117,6 +4117,12 @@ S2.define('select2/dropdown/attachBody',[ this._resizeDropdown(); }; + AttachBody.prototype.destroy = function(decorated) { + this.$dropdownContainer.off('.select2') + + decorated.call(this); + } + return AttachBody; });