|
@@ -9765,8 +9765,8 @@ define('select2/results',[
|
|
|
this.$results.append($options);
|
|
|
};
|
|
|
|
|
|
- Results.prototype.position = function ($results, $container) {
|
|
|
- var $resultsContainer = $container.find('.select2-results');
|
|
|
+ Results.prototype.position = function ($results, $dropdown) {
|
|
|
+ var $resultsContainer = $dropdown.find('.select2-results');
|
|
|
$resultsContainer.append($results);
|
|
|
};
|
|
|
|
|
@@ -12347,6 +12347,79 @@ define('select2/dropdown/infiniteScroll',[
|
|
|
return InfiniteScroll;
|
|
|
});
|
|
|
|
|
|
+define('select2/dropdown/attachBody',[
|
|
|
+
|
|
|
+], function () {
|
|
|
+ function AttachBody (decorated, $element, options) {
|
|
|
+ decorated.call(this, $element, options);
|
|
|
+ }
|
|
|
+
|
|
|
+ AttachBody.prototype.bind = function (decorated, container, $container) {
|
|
|
+ var self = this;
|
|
|
+
|
|
|
+ decorated.call(this, container, $container);
|
|
|
+
|
|
|
+ container.on('open', function () {
|
|
|
+ self._showDropdown();
|
|
|
+ });
|
|
|
+
|
|
|
+ container.on('close', function () {
|
|
|
+ self._hideDropdown();
|
|
|
+ });
|
|
|
+
|
|
|
+ this.$dropdownContainer.on('mousedown', function (evt) {
|
|
|
+ evt.stopPropagation();
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ AttachBody.prototype.position = function (decorated, $dropdown, $container) {
|
|
|
+ // Clone all of the container classes
|
|
|
+ $dropdown.attr('class', $container.attr('class'));
|
|
|
+
|
|
|
+ $dropdown.removeClass('select2');
|
|
|
+ $dropdown.addClass('select2-container--open');
|
|
|
+
|
|
|
+ $dropdown.css({
|
|
|
+ position: 'absolute'
|
|
|
+ });
|
|
|
+
|
|
|
+ $dropdown.width($container.outerWidth(false));
|
|
|
+
|
|
|
+ this.$container = $container;
|
|
|
+ };
|
|
|
+
|
|
|
+ AttachBody.prototype.render = function (decorated) {
|
|
|
+ var $container = $('<span></span>');
|
|
|
+
|
|
|
+ var $dropdown = decorated.call(this);
|
|
|
+ $container.append($dropdown);
|
|
|
+
|
|
|
+ this.$dropdownContainer = $container;
|
|
|
+
|
|
|
+ return $container;
|
|
|
+ };
|
|
|
+
|
|
|
+ AttachBody.prototype._hideDropdown = function (decorated) {
|
|
|
+ this.$dropdownContainer.detach();
|
|
|
+ };
|
|
|
+
|
|
|
+ AttachBody.prototype._positionDropdown = function () {
|
|
|
+ var css = this.$container.offset();
|
|
|
+
|
|
|
+ css.top += this.$container.outerHeight(true);
|
|
|
+
|
|
|
+ this.$dropdownContainer.css(css);
|
|
|
+ };
|
|
|
+
|
|
|
+ AttachBody.prototype._showDropdown = function (decorated) {
|
|
|
+ this.$dropdownContainer.appendTo(document.body);
|
|
|
+
|
|
|
+ this._positionDropdown();
|
|
|
+ };
|
|
|
+
|
|
|
+ return AttachBody;
|
|
|
+});
|
|
|
+
|
|
|
define('select2/i18n/en',[],function () {
|
|
|
return {
|
|
|
errorLoading: function () {
|
|
@@ -12419,6 +12492,7 @@ define('select2/defaults',[
|
|
|
'./dropdown/search',
|
|
|
'./dropdown/hidePlaceholder',
|
|
|
'./dropdown/infiniteScroll',
|
|
|
+ './dropdown/attachBody',
|
|
|
|
|
|
'./i18n/en'
|
|
|
], function ($, ResultsList,
|
|
@@ -12427,6 +12501,7 @@ define('select2/defaults',[
|
|
|
Utils, Translation, DIACRITICS,
|
|
|
SelectData, ArrayData, AjaxData, Tags, MinimumInputLength,
|
|
|
Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
|
|
|
+ AttachBody,
|
|
|
EnglishTranslation) {
|
|
|
function Defaults () {
|
|
|
this.reset();
|
|
@@ -12483,6 +12558,11 @@ define('select2/defaults',[
|
|
|
|
|
|
options.dropdownAdapter = SearchableDropdown;
|
|
|
}
|
|
|
+
|
|
|
+ options.dropdownAdapter = Utils.Decorate(
|
|
|
+ options.dropdownAdapter,
|
|
|
+ AttachBody
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
if (options.selectionAdapter == null) {
|
|
@@ -12697,10 +12777,9 @@ define('select2/core',[
|
|
|
|
|
|
var ResultsAdapter = this.options.get('resultsAdapter');
|
|
|
this.results = new ResultsAdapter($element, this.options, this.data);
|
|
|
-
|
|
|
this.$results = this.results.render();
|
|
|
|
|
|
- this.results.position(this.$results, $container);
|
|
|
+ this.results.position(this.$results, this.$dropdown);
|
|
|
|
|
|
// Bind events
|
|
|
|