当超过设置最大选择长度时,自动关闭下拉框
This commit is contained in:
@@ -862,17 +862,24 @@ S2.define('select2/results',[
|
|||||||
|
|
||||||
var $selected = $options.filter('[aria-selected=true]');
|
var $selected = $options.filter('[aria-selected=true]');
|
||||||
|
|
||||||
// Check if there are any selected options
|
// // Check if there are any selected options
|
||||||
if ($selected.length > 0) {
|
// if ($selected.length > 0) {
|
||||||
// If there are selected options, highlight the first
|
// // If there are selected options, highlight the first
|
||||||
$selected.first().trigger('mouseenter');
|
// $selected.first().trigger('mouseenter');
|
||||||
} else {
|
// } else {
|
||||||
// If there are no selected options, highlight the first option
|
// // If there are no selected options, highlight the first option
|
||||||
// in the dropdown
|
// // in the dropdown
|
||||||
$options.first().trigger('mouseenter');
|
// $options.first().trigger('mouseenter');
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// this.ensureHighlightVisible();
|
||||||
|
// ThinkGem 禁用 First Item 高亮
|
||||||
|
|
||||||
this.ensureHighlightVisible();
|
// ThinkGem 当超过设置最大选择长度时,自动关闭下拉框
|
||||||
|
var msl = this.options.get('maximumSelectionLength');
|
||||||
|
if (msl > 0 && $selected.length >= msl) {
|
||||||
|
this.trigger('close', {});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Results.prototype.setClasses = function () {
|
Results.prototype.setClasses = function () {
|
||||||
@@ -4492,9 +4499,9 @@ S2.define('select2/i18n/en',[],function () {
|
|||||||
maximumSelected: function (args) {
|
maximumSelected: function (args) {
|
||||||
var message = '最多只能选择 ' + args.maximum + ' 个项目';
|
var message = '最多只能选择 ' + args.maximum + ' 个项目';
|
||||||
|
|
||||||
if (args.maximum != 1) {
|
//if (args.maximum != 1) { // ThinkGem 删除多余的复数
|
||||||
message += 's';
|
// message += 's';
|
||||||
}
|
//}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
@@ -5376,7 +5383,10 @@ S2.define('select2/core',[
|
|||||||
} else {
|
} else {
|
||||||
if (/*key === KEYS.ENTER || */key === KEYS.SPACE || // ThinkGem 去掉回车后打开下拉框,解决jqgrid回车获取下一个输入框按键冲突
|
if (/*key === KEYS.ENTER || */key === KEYS.SPACE || // ThinkGem 去掉回车后打开下拉框,解决jqgrid回车获取下一个输入框按键冲突
|
||||||
(key === KEYS.DOWN && evt.altKey)) {
|
(key === KEYS.DOWN && evt.altKey)) {
|
||||||
self.open();
|
|
||||||
|
if (!this.options.get('disabled')){ // 修正禁用的时候,按空格可弹窗下拉框问题
|
||||||
|
self.open();
|
||||||
|
}
|
||||||
|
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -857,11 +857,11 @@ S2.define('select2/results',[
|
|||||||
};
|
};
|
||||||
|
|
||||||
Results.prototype.highlightFirstItem = function () {
|
Results.prototype.highlightFirstItem = function () {
|
||||||
// var $options = this.$results
|
var $options = this.$results
|
||||||
// .find('.select2-results__option[aria-selected]');
|
.find('.select2-results__option[aria-selected]');
|
||||||
//
|
|
||||||
// var $selected = $options.filter('[aria-selected=true]');
|
var $selected = $options.filter('[aria-selected=true]');
|
||||||
//
|
|
||||||
// // Check if there are any selected options
|
// // Check if there are any selected options
|
||||||
// if ($selected.length > 0) {
|
// if ($selected.length > 0) {
|
||||||
// // If there are selected options, highlight the first
|
// // If there are selected options, highlight the first
|
||||||
@@ -874,6 +874,12 @@ S2.define('select2/results',[
|
|||||||
//
|
//
|
||||||
// this.ensureHighlightVisible();
|
// this.ensureHighlightVisible();
|
||||||
// ThinkGem 禁用 First Item 高亮
|
// ThinkGem 禁用 First Item 高亮
|
||||||
|
|
||||||
|
// ThinkGem 当超过设置最大选择长度时,自动关闭下拉框
|
||||||
|
var msl = this.options.get('maximumSelectionLength');
|
||||||
|
if (msl > 0 && $selected.length >= msl) {
|
||||||
|
this.trigger('close', {});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Results.prototype.setClasses = function () {
|
Results.prototype.setClasses = function () {
|
||||||
@@ -4462,7 +4468,7 @@ S2.define('select2/dropdown/closeOnSelect',[
|
|||||||
return CloseOnSelect;
|
return CloseOnSelect;
|
||||||
});
|
});
|
||||||
|
|
||||||
//ThinkGem 默认为中文
|
// ThinkGem 默认为中文
|
||||||
S2.define('select2/i18n/en',[],function () {
|
S2.define('select2/i18n/en',[],function () {
|
||||||
// English
|
// English
|
||||||
return {
|
return {
|
||||||
@@ -4493,9 +4499,9 @@ S2.define('select2/i18n/en',[],function () {
|
|||||||
maximumSelected: function (args) {
|
maximumSelected: function (args) {
|
||||||
var message = '最多只能选择 ' + args.maximum + ' 个项目';
|
var message = '最多只能选择 ' + args.maximum + ' 个项目';
|
||||||
|
|
||||||
if (args.maximum != 1) {
|
//if (args.maximum != 1) { // ThinkGem 删除多余的复数
|
||||||
message += 's';
|
// message += 's';
|
||||||
}
|
//}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user