Forráskód Böngészése

Move positioning into the components

The main container should not need to position the individual
components. This makes it easier for components to override where
they should be placed, such as adding the dropdown outside of the
container.
Kevin Brown 11 éve
szülő
commit
31c09315c8

+ 21 - 25
dist/js/select2.amd.full.js

@@ -230,6 +230,11 @@ define('select2/results',[
     this.$results.append($options);
     this.$results.append($options);
   };
   };
 
 
+  Results.prototype.position = function ($results, $container) {
+    var $resultsContainer = $container.find('.select2-results');
+    $resultsContainer.append($results);
+  };
+
   Results.prototype.sort = function (data) {
   Results.prototype.sort = function (data) {
     return data;
     return data;
   };
   };
@@ -724,6 +729,11 @@ define('select2/selection/base',[
     $(document.body).off('mousedown.select2.' + container.id);
     $(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 () {
   BaseSelection.prototype.destroy = function () {
     // Unbind the dropdown click handler if it exists
     // Unbind the dropdown click handler if it exists
     $(document.body).off('.select2.' + this.container.id);
     $(document.body).off('.select2.' + this.container.id);
@@ -2575,6 +2585,11 @@ define('select2/dropdown',[
     return $dropdown;
     return $dropdown;
   };
   };
 
 
+  Dropdown.prototype.position = function ($dropdown, $container) {
+    var $dropdownContainer = $container.find('.dropdown-wrapper');
+    $dropdownContainer.append($dropdown);
+  };
+
   Dropdown.prototype.destroy = function () {
   Dropdown.prototype.destroy = function () {
     // Remove the dropdown from the DOM
     // Remove the dropdown from the DOM
     this.$dropdown.remove();
     this.$dropdown.remove();
@@ -3135,24 +3150,22 @@ define('select2/core',[
 
 
     var SelectionAdapter = this.options.get('selectionAdapter');
     var SelectionAdapter = this.options.get('selectionAdapter');
     this.selection = new SelectionAdapter($element, this.options);
     this.selection = new SelectionAdapter($element, this.options);
+    this.$selection = this.selection.render();
 
 
-    var $selection = this.selection.render();
-
-    this._placeSelection($selection);
+    this.selection.position(this.$selection, $container);
 
 
     var DropdownAdapter = this.options.get('dropdownAdapter');
     var DropdownAdapter = this.options.get('dropdownAdapter');
     this.dropdown = new DropdownAdapter($element, this.options);
     this.dropdown = new DropdownAdapter($element, this.options);
+    this.$dropdown = this.dropdown.render();
 
 
-    var $dropdown = this.dropdown.render();
-
-    this._placeDropdown($dropdown);
+    this.dropdown.position(this.$dropdown, $container);
 
 
     var ResultsAdapter = this.options.get('resultsAdapter');
     var ResultsAdapter = this.options.get('resultsAdapter');
     this.results = new ResultsAdapter($element, this.options, this.data);
     this.results = new ResultsAdapter($element, this.options, this.data);
 
 
-    var $results = this.results.render();
+    this.$results = this.results.render();
 
 
-    this._placeResults($results);
+    this.results.position(this.$results, $container);
 
 
     // Bind events
     // Bind events
 
 
@@ -3213,23 +3226,6 @@ define('select2/core',[
     $container.width(this.$element.outerWidth(false));
     $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('.select2-results');
-    $resultsContainer.append($results);
-  };
-
   Select2.prototype._bindAdapters = function () {
   Select2.prototype._bindAdapters = function () {
     this.data.bind(this, this.$container);
     this.data.bind(this, this.$container);
     this.selection.bind(this, this.$container);
     this.selection.bind(this, this.$container);

+ 21 - 25
dist/js/select2.amd.js

@@ -230,6 +230,11 @@ define('select2/results',[
     this.$results.append($options);
     this.$results.append($options);
   };
   };
 
 
+  Results.prototype.position = function ($results, $container) {
+    var $resultsContainer = $container.find('.select2-results');
+    $resultsContainer.append($results);
+  };
+
   Results.prototype.sort = function (data) {
   Results.prototype.sort = function (data) {
     return data;
     return data;
   };
   };
@@ -724,6 +729,11 @@ define('select2/selection/base',[
     $(document.body).off('mousedown.select2.' + container.id);
     $(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 () {
   BaseSelection.prototype.destroy = function () {
     // Unbind the dropdown click handler if it exists
     // Unbind the dropdown click handler if it exists
     $(document.body).off('.select2.' + this.container.id);
     $(document.body).off('.select2.' + this.container.id);
@@ -2575,6 +2585,11 @@ define('select2/dropdown',[
     return $dropdown;
     return $dropdown;
   };
   };
 
 
+  Dropdown.prototype.position = function ($dropdown, $container) {
+    var $dropdownContainer = $container.find('.dropdown-wrapper');
+    $dropdownContainer.append($dropdown);
+  };
+
   Dropdown.prototype.destroy = function () {
   Dropdown.prototype.destroy = function () {
     // Remove the dropdown from the DOM
     // Remove the dropdown from the DOM
     this.$dropdown.remove();
     this.$dropdown.remove();
@@ -3135,24 +3150,22 @@ define('select2/core',[
 
 
     var SelectionAdapter = this.options.get('selectionAdapter');
     var SelectionAdapter = this.options.get('selectionAdapter');
     this.selection = new SelectionAdapter($element, this.options);
     this.selection = new SelectionAdapter($element, this.options);
+    this.$selection = this.selection.render();
 
 
-    var $selection = this.selection.render();
-
-    this._placeSelection($selection);
+    this.selection.position(this.$selection, $container);
 
 
     var DropdownAdapter = this.options.get('dropdownAdapter');
     var DropdownAdapter = this.options.get('dropdownAdapter');
     this.dropdown = new DropdownAdapter($element, this.options);
     this.dropdown = new DropdownAdapter($element, this.options);
+    this.$dropdown = this.dropdown.render();
 
 
-    var $dropdown = this.dropdown.render();
-
-    this._placeDropdown($dropdown);
+    this.dropdown.position(this.$dropdown, $container);
 
 
     var ResultsAdapter = this.options.get('resultsAdapter');
     var ResultsAdapter = this.options.get('resultsAdapter');
     this.results = new ResultsAdapter($element, this.options, this.data);
     this.results = new ResultsAdapter($element, this.options, this.data);
 
 
-    var $results = this.results.render();
+    this.$results = this.results.render();
 
 
-    this._placeResults($results);
+    this.results.position(this.$results, $container);
 
 
     // Bind events
     // Bind events
 
 
@@ -3213,23 +3226,6 @@ define('select2/core',[
     $container.width(this.$element.outerWidth(false));
     $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('.select2-results');
-    $resultsContainer.append($results);
-  };
-
   Select2.prototype._bindAdapters = function () {
   Select2.prototype._bindAdapters = function () {
     this.data.bind(this, this.$container);
     this.data.bind(this, this.$container);
     this.selection.bind(this, this.$container);
     this.selection.bind(this, this.$container);

+ 21 - 25
dist/js/select2.full.js

@@ -9765,6 +9765,11 @@ define('select2/results',[
     this.$results.append($options);
     this.$results.append($options);
   };
   };
 
 
+  Results.prototype.position = function ($results, $container) {
+    var $resultsContainer = $container.find('.select2-results');
+    $resultsContainer.append($results);
+  };
+
   Results.prototype.sort = function (data) {
   Results.prototype.sort = function (data) {
     return data;
     return data;
   };
   };
@@ -10259,6 +10264,11 @@ define('select2/selection/base',[
     $(document.body).off('mousedown.select2.' + container.id);
     $(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 () {
   BaseSelection.prototype.destroy = function () {
     // Unbind the dropdown click handler if it exists
     // Unbind the dropdown click handler if it exists
     $(document.body).off('.select2.' + this.container.id);
     $(document.body).off('.select2.' + this.container.id);
@@ -12110,6 +12120,11 @@ define('select2/dropdown',[
     return $dropdown;
     return $dropdown;
   };
   };
 
 
+  Dropdown.prototype.position = function ($dropdown, $container) {
+    var $dropdownContainer = $container.find('.dropdown-wrapper');
+    $dropdownContainer.append($dropdown);
+  };
+
   Dropdown.prototype.destroy = function () {
   Dropdown.prototype.destroy = function () {
     // Remove the dropdown from the DOM
     // Remove the dropdown from the DOM
     this.$dropdown.remove();
     this.$dropdown.remove();
@@ -12670,24 +12685,22 @@ define('select2/core',[
 
 
     var SelectionAdapter = this.options.get('selectionAdapter');
     var SelectionAdapter = this.options.get('selectionAdapter');
     this.selection = new SelectionAdapter($element, this.options);
     this.selection = new SelectionAdapter($element, this.options);
+    this.$selection = this.selection.render();
 
 
-    var $selection = this.selection.render();
-
-    this._placeSelection($selection);
+    this.selection.position(this.$selection, $container);
 
 
     var DropdownAdapter = this.options.get('dropdownAdapter');
     var DropdownAdapter = this.options.get('dropdownAdapter');
     this.dropdown = new DropdownAdapter($element, this.options);
     this.dropdown = new DropdownAdapter($element, this.options);
+    this.$dropdown = this.dropdown.render();
 
 
-    var $dropdown = this.dropdown.render();
-
-    this._placeDropdown($dropdown);
+    this.dropdown.position(this.$dropdown, $container);
 
 
     var ResultsAdapter = this.options.get('resultsAdapter');
     var ResultsAdapter = this.options.get('resultsAdapter');
     this.results = new ResultsAdapter($element, this.options, this.data);
     this.results = new ResultsAdapter($element, this.options, this.data);
 
 
-    var $results = this.results.render();
+    this.$results = this.results.render();
 
 
-    this._placeResults($results);
+    this.results.position(this.$results, $container);
 
 
     // Bind events
     // Bind events
 
 
@@ -12748,23 +12761,6 @@ define('select2/core',[
     $container.width(this.$element.outerWidth(false));
     $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('.select2-results');
-    $resultsContainer.append($results);
-  };
-
   Select2.prototype._bindAdapters = function () {
   Select2.prototype._bindAdapters = function () {
     this.data.bind(this, this.$container);
     this.data.bind(this, this.$container);
     this.selection.bind(this, this.$container);
     this.selection.bind(this, this.$container);

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/js/select2.full.min.js


+ 21 - 25
dist/js/select2.js

@@ -658,6 +658,11 @@ define('select2/results',[
     this.$results.append($options);
     this.$results.append($options);
   };
   };
 
 
+  Results.prototype.position = function ($results, $container) {
+    var $resultsContainer = $container.find('.select2-results');
+    $resultsContainer.append($results);
+  };
+
   Results.prototype.sort = function (data) {
   Results.prototype.sort = function (data) {
     return data;
     return data;
   };
   };
@@ -1152,6 +1157,11 @@ define('select2/selection/base',[
     $(document.body).off('mousedown.select2.' + container.id);
     $(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 () {
   BaseSelection.prototype.destroy = function () {
     // Unbind the dropdown click handler if it exists
     // Unbind the dropdown click handler if it exists
     $(document.body).off('.select2.' + this.container.id);
     $(document.body).off('.select2.' + this.container.id);
@@ -3003,6 +3013,11 @@ define('select2/dropdown',[
     return $dropdown;
     return $dropdown;
   };
   };
 
 
+  Dropdown.prototype.position = function ($dropdown, $container) {
+    var $dropdownContainer = $container.find('.dropdown-wrapper');
+    $dropdownContainer.append($dropdown);
+  };
+
   Dropdown.prototype.destroy = function () {
   Dropdown.prototype.destroy = function () {
     // Remove the dropdown from the DOM
     // Remove the dropdown from the DOM
     this.$dropdown.remove();
     this.$dropdown.remove();
@@ -3563,24 +3578,22 @@ define('select2/core',[
 
 
     var SelectionAdapter = this.options.get('selectionAdapter');
     var SelectionAdapter = this.options.get('selectionAdapter');
     this.selection = new SelectionAdapter($element, this.options);
     this.selection = new SelectionAdapter($element, this.options);
+    this.$selection = this.selection.render();
 
 
-    var $selection = this.selection.render();
-
-    this._placeSelection($selection);
+    this.selection.position(this.$selection, $container);
 
 
     var DropdownAdapter = this.options.get('dropdownAdapter');
     var DropdownAdapter = this.options.get('dropdownAdapter');
     this.dropdown = new DropdownAdapter($element, this.options);
     this.dropdown = new DropdownAdapter($element, this.options);
+    this.$dropdown = this.dropdown.render();
 
 
-    var $dropdown = this.dropdown.render();
-
-    this._placeDropdown($dropdown);
+    this.dropdown.position(this.$dropdown, $container);
 
 
     var ResultsAdapter = this.options.get('resultsAdapter');
     var ResultsAdapter = this.options.get('resultsAdapter');
     this.results = new ResultsAdapter($element, this.options, this.data);
     this.results = new ResultsAdapter($element, this.options, this.data);
 
 
-    var $results = this.results.render();
+    this.$results = this.results.render();
 
 
-    this._placeResults($results);
+    this.results.position(this.$results, $container);
 
 
     // Bind events
     // Bind events
 
 
@@ -3641,23 +3654,6 @@ define('select2/core',[
     $container.width(this.$element.outerWidth(false));
     $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('.select2-results');
-    $resultsContainer.append($results);
-  };
-
   Select2.prototype._bindAdapters = function () {
   Select2.prototype._bindAdapters = function () {
     this.data.bind(this, this.$container);
     this.data.bind(this, this.$container);
     this.selection.bind(this, this.$container);
     this.selection.bind(this, this.$container);

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/js/select2.min.js


+ 6 - 26
src/js/select2/core.js

@@ -30,24 +30,21 @@ define([
 
 
     var SelectionAdapter = this.options.get('selectionAdapter');
     var SelectionAdapter = this.options.get('selectionAdapter');
     this.selection = new SelectionAdapter($element, this.options);
     this.selection = new SelectionAdapter($element, this.options);
+    this.$selection = this.selection.render();
 
 
-    var $selection = this.selection.render();
-
-    this._placeSelection($selection);
+    this.selection.position(this.$selection, $container);
 
 
     var DropdownAdapter = this.options.get('dropdownAdapter');
     var DropdownAdapter = this.options.get('dropdownAdapter');
     this.dropdown = new DropdownAdapter($element, this.options);
     this.dropdown = new DropdownAdapter($element, this.options);
+    this.$dropdown = this.dropdown.render();
 
 
-    var $dropdown = this.dropdown.render();
-
-    this._placeDropdown($dropdown);
+    this.dropdown.position(this.$dropdown, $container);
 
 
     var ResultsAdapter = this.options.get('resultsAdapter');
     var ResultsAdapter = this.options.get('resultsAdapter');
     this.results = new ResultsAdapter($element, this.options, this.data);
     this.results = new ResultsAdapter($element, this.options, this.data);
+    this.$results = this.results.render();
 
 
-    var $results = this.results.render();
-
-    this._placeResults($results);
+    this.results.position(this.$results, $container);
 
 
     // Bind events
     // Bind events
 
 
@@ -108,23 +105,6 @@ define([
     $container.width(this.$element.outerWidth(false));
     $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('.select2-results');
-    $resultsContainer.append($results);
-  };
-
   Select2.prototype._bindAdapters = function () {
   Select2.prototype._bindAdapters = function () {
     this.data.bind(this, this.$container);
     this.data.bind(this, this.$container);
     this.selection.bind(this, this.$container);
     this.selection.bind(this, this.$container);

+ 5 - 0
src/js/select2/dropdown.js

@@ -19,6 +19,11 @@ define([
     return $dropdown;
     return $dropdown;
   };
   };
 
 
+  Dropdown.prototype.position = function ($dropdown, $container) {
+    var $dropdownContainer = $container.find('.dropdown-wrapper');
+    $dropdownContainer.append($dropdown);
+  };
+
   Dropdown.prototype.destroy = function () {
   Dropdown.prototype.destroy = function () {
     // Remove the dropdown from the DOM
     // Remove the dropdown from the DOM
     this.$dropdown.remove();
     this.$dropdown.remove();

+ 5 - 0
src/js/select2/results.js

@@ -72,6 +72,11 @@ define([
     this.$results.append($options);
     this.$results.append($options);
   };
   };
 
 
+  Results.prototype.position = function ($results, $container) {
+    var $resultsContainer = $container.find('.select2-results');
+    $resultsContainer.append($results);
+  };
+
   Results.prototype.sort = function (data) {
   Results.prototype.sort = function (data) {
     return data;
     return data;
   };
   };

+ 5 - 0
src/js/select2/selection/base.js

@@ -85,6 +85,11 @@ define([
     $(document.body).off('mousedown.select2.' + container.id);
     $(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 () {
   BaseSelection.prototype.destroy = function () {
     // Unbind the dropdown click handler if it exists
     // Unbind the dropdown click handler if it exists
     $(document.body).off('.select2.' + this.container.id);
     $(document.body).off('.select2.' + this.container.id);

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott