Added back dropdownAutoWidth
option
This adds back the `dropdownAutoWidth` option, so the dropdown can have a width that is automatically determined by the browser. This works best for smaller dropdowns that contain options with large amounts of text. This closes https://github.com/select2/select2/issues/3103. This closes https://github.com/select2/select2/pull/3113. Signed-off-by: Kevin Brown <kevin@kevin-brown.com>
This commit is contained in:
parent
86bf6dc272
commit
e416e47356
2
dist/js/i18n/ru.js
vendored
2
dist/js/i18n/ru.js
vendored
@ -1,3 +1,3 @@
|
|||||||
/*! Select2 4.0.0-rc.2 | https://github.com/select2/select2/blob/master/LICENSE.md */
|
/*! Select2 4.0.0-rc.2 | https://github.com/select2/select2/blob/master/LICENSE.md */
|
||||||
|
|
||||||
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/ru",[],function(){function e(e,t,n,r){return e%10<5&&e%10>0&&e%100<5||e%100>20?e%10>1?n:t:r}return{inputTooLong:function(t){var n=t.input.length-t.maximum,r="Пожалуйста, введите на "+n+" символ";return r+=e(n,"","a","ов"),r+=" меньше",r},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Пожалуйста, введите еще хотя бы "+n+" символ";return r+=e(n,"","a","ов"),r},loadingMore:function(){return"Загрузка данных…"},maximumSelected:function(t){var n="Вы можете выбрать не более "+t.maximum+" элемент";return n+=e(t.maximum,"","a","ов"),n},noResults:function(){return"Совпадений не найдено"},searching:function(){return"Поиск…"}}}),{define:e.define,require:e.require}})();
|
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/ru",[],function(){function e(e,t,n,r){return e%10<5&&e%10>0&&e%100<5||e%100>20?e%10>1?n:t:r}return{errorLoading:function(){return"Невозможно загрузить результаты"},inputTooLong:function(t){var n=t.input.length-t.maximum,r="Пожалуйста, введите на "+n+" символ";return r+=e(n,"","a","ов"),r+=" меньше",r},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Пожалуйста, введите еще хотя бы "+n+" символ";return r+=e(n,"","a","ов"),r},loadingMore:function(){return"Загрузка данных…"},maximumSelected:function(t){var n="Вы можете выбрать не более "+t.maximum+" элемент";return n+=e(t.maximum,"","a","ов"),n},noResults:function(){return"Совпадений не найдено"},searching:function(){return"Поиск…"}}}),{define:e.define,require:e.require}})();
|
12
dist/js/select2.full.js
vendored
12
dist/js/select2.full.js
vendored
@ -4098,9 +4098,16 @@ S2.define('select2/dropdown/attachBody',[
|
|||||||
AttachBody.prototype._resizeDropdown = function () {
|
AttachBody.prototype._resizeDropdown = function () {
|
||||||
this.$dropdownContainer.width();
|
this.$dropdownContainer.width();
|
||||||
|
|
||||||
this.$dropdown.css({
|
var css = {
|
||||||
width: this.$container.outerWidth(false) + 'px'
|
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) {
|
AttachBody.prototype._showDropdown = function (decorated) {
|
||||||
@ -4619,6 +4626,7 @@ S2.define('select2/defaults',[
|
|||||||
amdLanguageBase: './i18n/',
|
amdLanguageBase: './i18n/',
|
||||||
closeOnSelect: true,
|
closeOnSelect: true,
|
||||||
debug: false,
|
debug: false,
|
||||||
|
dropdownAutoWidth: false,
|
||||||
escapeMarkup: Utils.escapeMarkup,
|
escapeMarkup: Utils.escapeMarkup,
|
||||||
language: EnglishTranslation,
|
language: EnglishTranslation,
|
||||||
matcher: matcher,
|
matcher: matcher,
|
||||||
|
4
dist/js/select2.full.min.js
vendored
4
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
12
dist/js/select2.js
vendored
12
dist/js/select2.js
vendored
@ -4098,9 +4098,16 @@ S2.define('select2/dropdown/attachBody',[
|
|||||||
AttachBody.prototype._resizeDropdown = function () {
|
AttachBody.prototype._resizeDropdown = function () {
|
||||||
this.$dropdownContainer.width();
|
this.$dropdownContainer.width();
|
||||||
|
|
||||||
this.$dropdown.css({
|
var css = {
|
||||||
width: this.$container.outerWidth(false) + 'px'
|
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) {
|
AttachBody.prototype._showDropdown = function (decorated) {
|
||||||
@ -4619,6 +4626,7 @@ S2.define('select2/defaults',[
|
|||||||
amdLanguageBase: './i18n/',
|
amdLanguageBase: './i18n/',
|
||||||
closeOnSelect: true,
|
closeOnSelect: true,
|
||||||
debug: false,
|
debug: false,
|
||||||
|
dropdownAutoWidth: false,
|
||||||
escapeMarkup: Utils.escapeMarkup,
|
escapeMarkup: Utils.escapeMarkup,
|
||||||
language: EnglishTranslation,
|
language: EnglishTranslation,
|
||||||
matcher: matcher,
|
matcher: matcher,
|
||||||
|
2
dist/js/select2.min.js
vendored
2
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
1
src/js/select2/defaults.js
vendored
1
src/js/select2/defaults.js
vendored
@ -356,6 +356,7 @@ define([
|
|||||||
amdLanguageBase: './i18n/',
|
amdLanguageBase: './i18n/',
|
||||||
closeOnSelect: true,
|
closeOnSelect: true,
|
||||||
debug: false,
|
debug: false,
|
||||||
|
dropdownAutoWidth: false,
|
||||||
escapeMarkup: Utils.escapeMarkup,
|
escapeMarkup: Utils.escapeMarkup,
|
||||||
language: EnglishTranslation,
|
language: EnglishTranslation,
|
||||||
matcher: matcher,
|
matcher: matcher,
|
||||||
|
11
src/js/select2/dropdown/attachBody.js
vendored
11
src/js/select2/dropdown/attachBody.js
vendored
@ -179,9 +179,16 @@ define([
|
|||||||
AttachBody.prototype._resizeDropdown = function () {
|
AttachBody.prototype._resizeDropdown = function () {
|
||||||
this.$dropdownContainer.width();
|
this.$dropdownContainer.width();
|
||||||
|
|
||||||
this.$dropdown.css({
|
var css = {
|
||||||
width: this.$container.outerWidth(false) + 'px'
|
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) {
|
AttachBody.prototype._showDropdown = function (decorated) {
|
||||||
|
Loading…
Reference in New Issue
Block a user