|
@@ -11201,11 +11201,85 @@ define('select2/core',[
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
- this.data.bind(this, $container);
|
|
|
- this.selection.bind(this, $container);
|
|
|
+ // Bind the container to all of the adapters
|
|
|
+ this._bindAdapters();
|
|
|
|
|
|
- this.dropdown.bind(this, $container);
|
|
|
- this.results.bind(this, $container);
|
|
|
+ // Register any DOM event handler
|
|
|
+ this._registerDomEvents();
|
|
|
+
|
|
|
+ // Register any internal event handlers
|
|
|
+ this._registerSelectionEvents();
|
|
|
+ this._registerResultsEvents();
|
|
|
+ this._registerEvents();
|
|
|
+
|
|
|
+ // Set the initial state
|
|
|
+
|
|
|
+ this.data.current(function (initialData) {
|
|
|
+ self.trigger('selection:update', {
|
|
|
+ data: initialData
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ this.trigger('query', {});
|
|
|
+
|
|
|
+ // Hide the original select
|
|
|
+
|
|
|
+ $element.hide();
|
|
|
+ $element.attr('tabindex', '-1');
|
|
|
+
|
|
|
+ $element.data('select2', this);
|
|
|
+ };
|
|
|
+
|
|
|
+ Utils.Extend(Select2, Utils.Observable);
|
|
|
+
|
|
|
+ Select2.prototype._generateId = function ($element) {
|
|
|
+ var id = '';
|
|
|
+
|
|
|
+ if ($element.attr('id') != null) {
|
|
|
+ id = $element.attr('id');
|
|
|
+ } else if ($element.attr('name') != null) {
|
|
|
+ id = $element.attr('name') + '-' + Utils.generateChars(2);
|
|
|
+ } else {
|
|
|
+ id = Utils.generateChars(4);
|
|
|
+ }
|
|
|
+
|
|
|
+ id = 'select2-' + id;
|
|
|
+
|
|
|
+ return id;
|
|
|
+ };
|
|
|
+
|
|
|
+ Select2.prototype._placeContainer = function ($container) {
|
|
|
+ $container.insertAfter(this.$element);
|
|
|
+ $container.width(this.$element.outerWidth(false));
|
|
|
+ };
|
|
|
+
|
|
|
+ Select2.prototype._placeSelection = function ($selection) {
|
|
|
+ var $selectionContainer = this.$container.find('.selection');
|
|
|
+ $selectionContainer.append($selection);
|
|
|
+ };
|
|
|
+
|
|
|
+ Select2.prototype._placeDropdown = function ($dropdown) {
|
|
|
+ this.$dropdown = $dropdown;
|
|
|
+
|
|
|
+ var $dropdownContainer = this.$container.find('.dropdown-wrapper');
|
|
|
+ $dropdownContainer.append($dropdown);
|
|
|
+ };
|
|
|
+
|
|
|
+ Select2.prototype._placeResults = function ($results) {
|
|
|
+ var $resultsContainer = this.$dropdown.find('.results');
|
|
|
+ $resultsContainer.append($results);
|
|
|
+ };
|
|
|
+
|
|
|
+ Select2.prototype._bindAdapters = function () {
|
|
|
+ this.data.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', function () {
|
|
|
self.data.current(function (data) {
|
|
@@ -11214,6 +11288,10 @@ define('select2/core',[
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
+ };
|
|
|
+
|
|
|
+ Select2.prototype._registerSelectionEvents = function () {
|
|
|
+ var self = this;
|
|
|
|
|
|
this.selection.on('open', function () {
|
|
|
self.open();
|
|
@@ -11240,6 +11318,10 @@ define('select2/core',[
|
|
|
|
|
|
self.close();
|
|
|
});
|
|
|
+ };
|
|
|
+
|
|
|
+ Select2.prototype._registerResultsEvents = function () {
|
|
|
+ var self = this;
|
|
|
|
|
|
this.results.on('selected', function (params) {
|
|
|
self.trigger('select', params);
|
|
@@ -11256,21 +11338,17 @@ define('select2/core',[
|
|
|
this.results.on('results:focus', function (params) {
|
|
|
self.trigger('results:focus', params);
|
|
|
});
|
|
|
+ };
|
|
|
+
|
|
|
+ Select2.prototype._registerEvents = function () {
|
|
|
+ var self = this;
|
|
|
|
|
|
this.on('open', function () {
|
|
|
- $container.addClass('open');
|
|
|
+ self.$container.addClass('open');
|
|
|
});
|
|
|
|
|
|
this.on('close', function () {
|
|
|
- $container.removeClass('open');
|
|
|
- });
|
|
|
-
|
|
|
- // Set the initial state
|
|
|
-
|
|
|
- this.data.current(function (initialData) {
|
|
|
- self.trigger('selection:update', {
|
|
|
- data: initialData
|
|
|
- });
|
|
|
+ self.$container.removeClass('open');
|
|
|
});
|
|
|
|
|
|
this.on('query', function (params) {
|
|
@@ -11281,55 +11359,6 @@ define('select2/core',[
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
- this.trigger('query', {});
|
|
|
-
|
|
|
- // Hide the original select
|
|
|
-
|
|
|
- $element.hide();
|
|
|
- $element.attr('tabindex', '-1');
|
|
|
-
|
|
|
- $element.data('select2', this);
|
|
|
- };
|
|
|
-
|
|
|
- Utils.Extend(Select2, Utils.Observable);
|
|
|
-
|
|
|
- Select2.prototype._generateId = function ($element) {
|
|
|
- var id = '';
|
|
|
-
|
|
|
- if ($element.attr('id') != null) {
|
|
|
- id = $element.attr('id');
|
|
|
- } else if ($element.attr('name') != null) {
|
|
|
- id = $element.attr('name') + '-' + Utils.generateChars(2);
|
|
|
- } else {
|
|
|
- id = Utils.generateChars(4);
|
|
|
- }
|
|
|
-
|
|
|
- id = 'select2-' + id;
|
|
|
-
|
|
|
- return id;
|
|
|
- };
|
|
|
-
|
|
|
- Select2.prototype._placeContainer = function ($container) {
|
|
|
- $container.insertAfter(this.$element);
|
|
|
- $container.width(this.$element.outerWidth(false));
|
|
|
- };
|
|
|
-
|
|
|
- Select2.prototype._placeSelection = function ($selection) {
|
|
|
- var $selectionContainer = this.$container.find('.selection');
|
|
|
- $selectionContainer.append($selection);
|
|
|
- };
|
|
|
-
|
|
|
- Select2.prototype._placeDropdown = function ($dropdown) {
|
|
|
- this.$dropdown = $dropdown;
|
|
|
-
|
|
|
- var $dropdownContainer = this.$container.find('.dropdown-wrapper');
|
|
|
- $dropdownContainer.append($dropdown);
|
|
|
- };
|
|
|
-
|
|
|
- Select2.prototype._placeResults = function ($results) {
|
|
|
- var $resultsContainer = this.$dropdown.find('.results');
|
|
|
- $resultsContainer.append($results);
|
|
|
};
|
|
|
|
|
|
Select2.prototype.toggleDropdown = function () {
|