1
0
mirror of synced 2024-11-26 06:46:04 +03:00

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:
nath 2015-04-26 16:52:22 -04:00 committed by Kevin Brown
parent 86bf6dc272
commit e416e47356
7 changed files with 34 additions and 10 deletions

2
dist/js/i18n/ru.js vendored
View File

@ -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}})();

View File

@ -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,

File diff suppressed because one or more lines are too long

12
dist/js/select2.js vendored
View File

@ -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,

File diff suppressed because one or more lines are too long

View File

@ -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,

View File

@ -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) {