Compare commits
41 commits
Author | SHA1 | Date | |
---|---|---|---|
|
95a977f674 | ||
|
cb5a30d32c | ||
|
a7e8f2bfad | ||
|
2b8cbde7eb | ||
|
3be19d8e62 | ||
|
a2e2257840 | ||
|
68e9159b3c | ||
|
61316a1351 | ||
|
2caa45ba98 | ||
|
95e6f80619 | ||
|
2eea4a486a | ||
|
1afc8d9f27 | ||
|
3a10bd997a | ||
|
89b2e3fa81 | ||
|
19c0d3c0b5 | ||
|
da4789c61b | ||
|
03c4499752 | ||
|
a343ed9962 | ||
|
72bb1898d3 | ||
|
7f2a723651 | ||
|
ff292d7a66 | ||
|
db1d18fc5d | ||
|
086ce8c712 | ||
|
e524a85ad0 | ||
|
874390d5ab | ||
|
09d3e94ada | ||
|
8651dac4af | ||
|
620cbc2b94 | ||
|
2689b21286 | ||
|
a11cfdd11c | ||
|
5c9e81053e | ||
|
2ee7fadfce | ||
|
a732063f1b | ||
|
3acc0c4e58 | ||
|
39394e2ee8 | ||
|
f32a94f6b6 | ||
|
085f62e96f | ||
|
48ae56a2b6 | ||
|
285abff24d | ||
|
9a689a51a0 | ||
|
a35188cb00 |
11 changed files with 255 additions and 58 deletions
2
LICENSE
2
LICENSE
|
@ -13,6 +13,6 @@ http://www.apache.org/licenses/LICENSE-2.0
|
|||
http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed under the Apache License
|
||||
or the GPL Licesnse is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
or the GPL License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
either express or implied. See the Apache License and the GPL License for the specific language governing
|
||||
permissions and limitations under the Apache License and the GPL License.
|
||||
|
|
|
@ -3,7 +3,7 @@ Select2
|
|||
|
||||
Select2 is a jQuery-based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.
|
||||
|
||||
To get started, checkout examples and documentation at http://ivaynberg.github.com/select2
|
||||
To get started, checkout examples and documentation at http://select2.github.io/select2/
|
||||
|
||||
Use cases
|
||||
---------
|
||||
|
@ -27,7 +27,7 @@ Browser compatibility
|
|||
|
||||
Usage
|
||||
-----
|
||||
You can source Select2 directly from a CDN like [JSDliver](http://www.jsdelivr.com/#!select2) or [CDNJS](http://www.cdnjs.com/libraries/select2), [download it from this GitHub repo](https://github.com/ivaynberg/select2/tags), or use one of the integrations below.
|
||||
You can source Select2 directly from a CDN like [jsDelivr](http://www.jsdelivr.com/#!select2) or [CDNJS](http://www.cdnjs.com/libraries/select2), [download it from this GitHub repo](https://github.com/select2/select2/tags), or use one of the integrations below.
|
||||
|
||||
Integrations
|
||||
------------
|
||||
|
@ -44,6 +44,7 @@ Integrations
|
|||
* [Yii 2.x](http://demos.krajee.com/widgets#select2)
|
||||
* [Yii 1.x](https://github.com/tonybolzan/yii-select2)
|
||||
* [AtmosphereJS](https://atmospherejs.com/package/jquery-select2)
|
||||
* [EmberJS](https://github.com/iStefo/ember-select-2)
|
||||
|
||||
### Example Integrations
|
||||
|
||||
|
@ -64,7 +65,7 @@ it, and make a pull request back to Select2 here on GitHub.
|
|||
Documentation
|
||||
-------------
|
||||
|
||||
The documentation for Select2 is available [through GitHub Pages](https://ivaynberg.github.io/select2/) and is located within this repository in the [`gh-pages` branch](https://github.com/ivaynberg/select2/tree/gh-pages).
|
||||
The documentation for Select2 is available [through GitHub Pages](http://select2.github.io/select2/) and is located within this repository in the [`gh-pages` branch](https://github.com/ivaynberg/select2/tree/gh-pages).
|
||||
|
||||
Community
|
||||
---------
|
||||
|
@ -96,7 +97,7 @@ Need help implementing Select2 in your project? Ask in our IRC channel!
|
|||
Copyright and license
|
||||
---------------------
|
||||
|
||||
Copyright 2012 Igor Vaynberg
|
||||
Copyright 2015 Igor Vaynberg
|
||||
|
||||
This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
|
||||
General Public License version 2 (the "GPL License"). You may choose either license to govern your
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "select2",
|
||||
"version": "3.5.2",
|
||||
"version": "3.5.4",
|
||||
"main": ["select2.js", "select2.css", "select2.png", "select2x2.png", "select2-spinner.gif"],
|
||||
"dependencies": {
|
||||
"jquery": ">= 1.7.1"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "select2",
|
||||
"repo": "ivaynberg/select2",
|
||||
"description": "Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.",
|
||||
"version": "3.5.2",
|
||||
"version": "3.5.4",
|
||||
"demo": "http://ivaynberg.github.io/select2/",
|
||||
"keywords": [
|
||||
"jquery"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name":
|
||||
"ivaynberg/select2",
|
||||
"description": "Select2 is a jQuery based replacement for select boxes.",
|
||||
"version": "3.5.2",
|
||||
"version": "3.5.4",
|
||||
"type": "component",
|
||||
"homepage": "http://ivaynberg.github.io/select2/",
|
||||
"license": "Apache-2.0",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"author": "Igor Vaynberg",
|
||||
"repository": {"type": "git", "url": "git://github.com/ivaynberg/select2.git"},
|
||||
"main": "select2.js",
|
||||
"version": "3.5.2",
|
||||
"version": "3.5.4",
|
||||
"jspm": {
|
||||
"main": "select2",
|
||||
"files": ["select2.js", "select2.png", "select2.css", "select2-spinner.gif"],
|
||||
|
|
13
select2.css
13
select2.css
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Version: @@ver@@ Timestamp: @@timestamp@@
|
||||
Version: 3.5.4 Timestamp: Sun Aug 30 13:30:32 EDT 2015
|
||||
*/
|
||||
.select2-container {
|
||||
margin: 0;
|
||||
|
@ -177,10 +177,6 @@ html[dir="rtl"] .select2-container .select2-choice > .select2-chosen {
|
|||
width: auto;
|
||||
}
|
||||
|
||||
.select2-drop-auto-width .select2-search {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.select2-container .select2-choice .select2-arrow {
|
||||
display: inline-block;
|
||||
width: 18px;
|
||||
|
@ -227,8 +223,7 @@ html[dir="rtl"] .select2-container .select2-choice .select2-arrow b {
|
|||
width: 100%;
|
||||
min-height: 26px;
|
||||
margin: 0;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
padding: 4px 4px 0 4px;
|
||||
|
||||
position: relative;
|
||||
z-index: 10000;
|
||||
|
@ -270,10 +265,6 @@ html[dir="rtl"] .select2-search input {
|
|||
background: url('select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
|
||||
}
|
||||
|
||||
.select2-drop.select2-drop-above .select2-search input {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.select2-search input.select2-active {
|
||||
background: #fff url('select2-spinner.gif') no-repeat 100%;
|
||||
background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"tag",
|
||||
"tagging"
|
||||
],
|
||||
"version": "3.5.2",
|
||||
"version": "3.5.4",
|
||||
"author": {
|
||||
"name": "Igor Vaynberg",
|
||||
"url": "https://github.com/ivaynberg"
|
||||
|
|
248
select2.js
248
select2.js
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright 2012 Igor Vaynberg
|
||||
|
||||
Version: @@ver@@ Timestamp: @@timestamp@@
|
||||
Version: 3.5.4 Timestamp: Sun Aug 30 13:30:32 EDT 2015
|
||||
|
||||
This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
|
||||
General Public License version 2 (the "GPL License"). You may choose either license to govern your
|
||||
|
@ -870,17 +870,21 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
select2.container.remove();
|
||||
select2.liveRegion.remove();
|
||||
select2.dropdown.remove();
|
||||
element
|
||||
.show()
|
||||
.removeData("select2")
|
||||
.off(".select2")
|
||||
.prop("autofocus", this.autofocus || false);
|
||||
if (this.elementTabIndex) {
|
||||
element.attr({tabindex: this.elementTabIndex});
|
||||
element.removeData("select2")
|
||||
.off(".select2");
|
||||
if (!element.is("input[type='hidden']")) {
|
||||
element
|
||||
.show()
|
||||
.prop("autofocus", this.autofocus || false);
|
||||
if (this.elementTabIndex) {
|
||||
element.attr({tabindex: this.elementTabIndex});
|
||||
} else {
|
||||
element.removeAttr("tabindex");
|
||||
}
|
||||
element.show();
|
||||
} else {
|
||||
element.removeAttr("tabindex");
|
||||
element.css("display", "");
|
||||
}
|
||||
element.show();
|
||||
}
|
||||
|
||||
cleanupJQueryElements.call(this,
|
||||
|
@ -932,6 +936,155 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
});
|
||||
}
|
||||
|
||||
opts.debug = opts.debug || $.fn.select2.defaults.debug;
|
||||
|
||||
// Warnings for options renamed/removed in Select2 4.0.0
|
||||
// Only when it's enabled through debug mode
|
||||
if (opts.debug && console && console.warn) {
|
||||
// id was removed
|
||||
if (opts.id != null) {
|
||||
console.warn(
|
||||
'Select2: The `id` option has been removed in Select2 4.0.0, ' +
|
||||
'consider renaming your `id` property or mapping the property before your data makes it to Select2. ' +
|
||||
'You can read more at https://select2.github.io/announcements-4.0.html#changed-id'
|
||||
);
|
||||
}
|
||||
|
||||
// text was removed
|
||||
if (opts.text != null) {
|
||||
console.warn(
|
||||
'Select2: The `text` option has been removed in Select2 4.0.0, ' +
|
||||
'consider renaming your `text` property or mapping the property before your data makes it to Select2. ' +
|
||||
'You can read more at https://select2.github.io/announcements-4.0.html#changed-id'
|
||||
);
|
||||
}
|
||||
|
||||
// sortResults was renamed to results
|
||||
if (opts.sortResults != null) {
|
||||
console.warn(
|
||||
'Select2: the `sortResults` option has been renamed to `sorter` in Select2 4.0.0. '
|
||||
);
|
||||
}
|
||||
|
||||
// selectOnBlur was renamed to selectOnClose
|
||||
if (opts.selectOnBlur != null) {
|
||||
console.warn(
|
||||
'Select2: The `selectOnBlur` option has been renamed to `selectOnClose` in Select2 4.0.0.'
|
||||
);
|
||||
}
|
||||
|
||||
// ajax.results was renamed to ajax.processResults
|
||||
if (opts.ajax != null && opts.ajax.results != null) {
|
||||
console.warn(
|
||||
'Select2: The `ajax.results` option has been renamed to `ajax.processResults` in Select2 4.0.0.'
|
||||
);
|
||||
}
|
||||
|
||||
// format* options were renamed to language.*
|
||||
if (opts.formatNoResults != null) {
|
||||
console.warn(
|
||||
'Select2: The `formatNoResults` option has been renamed to `language.noResults` in Select2 4.0.0.'
|
||||
);
|
||||
}
|
||||
if (opts.formatSearching != null) {
|
||||
console.warn(
|
||||
'Select2: The `formatSearching` option has been renamed to `language.searching` in Select2 4.0.0.'
|
||||
);
|
||||
}
|
||||
if (opts.formatInputTooShort != null) {
|
||||
console.warn(
|
||||
'Select2: The `formatInputTooShort` option has been renamed to `language.inputTooShort` in Select2 4.0.0.'
|
||||
);
|
||||
}
|
||||
if (opts.formatInputTooLong != null) {
|
||||
console.warn(
|
||||
'Select2: The `formatInputTooLong` option has been renamed to `language.inputTooLong` in Select2 4.0.0.'
|
||||
);
|
||||
}
|
||||
if (opts.formatLoading != null) {
|
||||
console.warn(
|
||||
'Select2: The `formatLoading` option has been renamed to `language.loadingMore` in Select2 4.0.0.'
|
||||
);
|
||||
}
|
||||
if (opts.formatSelectionTooBig != null) {
|
||||
console.warn(
|
||||
'Select2: The `formatSelectionTooBig` option has been renamed to `language.maximumSelected` in Select2 4.0.0.'
|
||||
);
|
||||
}
|
||||
|
||||
if (opts.element.data('select2Tags')) {
|
||||
console.warn(
|
||||
'Select2: The `data-select2-tags` attribute has been renamed to `data-tags` in Select2 4.0.0.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Aliasing options renamed in Select2 4.0.0
|
||||
|
||||
// data-select2-tags -> data-tags
|
||||
if (opts.element.data('tags') != null) {
|
||||
var elemTags = opts.element.data('tags');
|
||||
|
||||
// data-tags should actually be a boolean
|
||||
if (!$.isArray(elemTags)) {
|
||||
elemTags = [];
|
||||
}
|
||||
|
||||
opts.element.data('select2Tags', elemTags);
|
||||
}
|
||||
|
||||
// sortResults -> sorter
|
||||
if (opts.sorter != null) {
|
||||
opts.sortResults = opts.sorter;
|
||||
}
|
||||
|
||||
// selectOnBlur -> selectOnClose
|
||||
if (opts.selectOnClose != null) {
|
||||
opts.selectOnBlur = opts.selectOnClose;
|
||||
}
|
||||
|
||||
// ajax.results -> ajax.processResults
|
||||
if (opts.ajax != null) {
|
||||
if ($.isFunction(opts.ajax.processResults)) {
|
||||
opts.ajax.results = opts.ajax.processResults;
|
||||
}
|
||||
}
|
||||
|
||||
// Formatters/language options
|
||||
if (opts.language != null) {
|
||||
var lang = opts.language;
|
||||
|
||||
// formatNoMatches -> language.noMatches
|
||||
if ($.isFunction(lang.noMatches)) {
|
||||
opts.formatNoMatches = lang.noMatches;
|
||||
}
|
||||
|
||||
// formatSearching -> language.searching
|
||||
if ($.isFunction(lang.searching)) {
|
||||
opts.formatSearching = lang.searching;
|
||||
}
|
||||
|
||||
// formatInputTooShort -> language.inputTooShort
|
||||
if ($.isFunction(lang.inputTooShort)) {
|
||||
opts.formatInputTooShort = lang.inputTooShort;
|
||||
}
|
||||
|
||||
// formatInputTooLong -> language.inputTooLong
|
||||
if ($.isFunction(lang.inputTooLong)) {
|
||||
opts.formatInputTooLong = lang.inputTooLong;
|
||||
}
|
||||
|
||||
// formatLoading -> language.loadingMore
|
||||
if ($.isFunction(lang.loadingMore)) {
|
||||
opts.formatLoading = lang.loadingMore;
|
||||
}
|
||||
|
||||
// formatSelectionTooBig -> language.maximumSelected
|
||||
if ($.isFunction(lang.maximumSelected)) {
|
||||
opts.formatSelectionTooBig = lang.maximumSelected;
|
||||
}
|
||||
}
|
||||
|
||||
opts = $.extend({}, {
|
||||
populateResults: function(container, results, query) {
|
||||
var populate, id=this.opts.id, liveRegion=this.liveRegion;
|
||||
|
@ -975,7 +1128,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
|
||||
|
||||
if (compound) {
|
||||
|
||||
innerContainer=$("<ul></ul>");
|
||||
innerContainer.addClass("select2-result-sub");
|
||||
populate(result.children, innerContainer, depth+1);
|
||||
|
@ -1046,7 +1198,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
opts.id=function(e) { return e.id; };
|
||||
} else {
|
||||
if (!("query" in opts)) {
|
||||
|
||||
if ("ajax" in opts) {
|
||||
ajaxUrl = opts.element.data("ajax-url");
|
||||
if (ajaxUrl && ajaxUrl.length > 0) {
|
||||
|
@ -1482,6 +1633,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
|
||||
this.clearSearch();
|
||||
this.search.removeClass("select2-active");
|
||||
|
||||
// Remove the aria active descendant for highlighted element
|
||||
this.search.removeAttr("aria-activedescendant");
|
||||
this.opts.element.trigger($.Event("select2-close"));
|
||||
},
|
||||
|
||||
|
@ -1834,6 +1988,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
|
||||
if (data.results.length === 0 && checkFormatter(opts.formatNoMatches, "formatNoMatches")) {
|
||||
render("<li class='select2-no-results'>" + evaluate(opts.formatNoMatches, opts.element, search.val()) + "</li>");
|
||||
if(this.showSearch){
|
||||
this.showSearch(search.val());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1938,7 +2095,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
} else if (this.opts.width === "copy" || this.opts.width === "resolve") {
|
||||
// check if there is inline style on the element that contains width
|
||||
style = this.opts.element.attr('style');
|
||||
if (style !== undefined) {
|
||||
if (typeof(style) === "string") {
|
||||
attrs = style.split(';');
|
||||
for (i = 0, l = attrs.length; i < l; i = i + 1) {
|
||||
attr = attrs[i].replace(/\s/g, '');
|
||||
|
@ -2124,7 +2281,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
this.focusser.attr("id", "s2id_autogen"+idSuffix);
|
||||
|
||||
elementLabel = $("label[for='" + this.opts.element.attr("id") + "']");
|
||||
this.opts.element.focus(this.bind(function () { this.focus(); }));
|
||||
this.opts.element.on('focus.select2', this.bind(function () { this.focus(); }));
|
||||
|
||||
this.focusser.prev()
|
||||
.text(elementLabel.text())
|
||||
|
@ -2180,7 +2337,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
// without this the search field loses focus which is annoying
|
||||
if (document.activeElement === this.body.get(0)) {
|
||||
window.setTimeout(this.bind(function() {
|
||||
if (this.opened()) {
|
||||
if (this.opened() && this.results && this.results.length > 1) {
|
||||
this.search.focus();
|
||||
}
|
||||
}), 0);
|
||||
|
@ -2523,9 +2680,23 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
|
||||
if (arguments.length > 1) {
|
||||
triggerChange = arguments[1];
|
||||
|
||||
if (this.opts.debug && console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: The second option to `select2("val")` is not supported in Select2 4.0.0. ' +
|
||||
'The `change` event will always be triggered in 4.0.0.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.select) {
|
||||
if (this.opts.debug && console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: Setting the value on a <select> using `select2("val")` is no longer supported in 4.0.0. ' +
|
||||
'You can use the `.val(newValue).trigger("change")` method provided by jQuery instead.'
|
||||
);
|
||||
}
|
||||
|
||||
this.select
|
||||
.val(val)
|
||||
.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
|
||||
|
@ -2574,6 +2745,13 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
if (data == undefined) data = null;
|
||||
return data;
|
||||
} else {
|
||||
if (this.opts.debug && console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: The `select2("data")` method can no longer set selected values in 4.0.0, ' +
|
||||
'consider using the `.val()` method instead.'
|
||||
);
|
||||
}
|
||||
|
||||
if (arguments.length > 1) {
|
||||
triggerChange = arguments[1];
|
||||
}
|
||||
|
@ -2719,7 +2897,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
this.search.prev()
|
||||
.text($("label[for='" + this.opts.element.attr("id") + "']").text())
|
||||
.attr('for', this.search.attr('id'));
|
||||
this.opts.element.focus(this.bind(function () { this.focus(); }));
|
||||
this.opts.element.on('focus.select2', this.bind(function () { this.focus(); }));
|
||||
|
||||
this.search.on("input paste", this.bind(function() {
|
||||
if (this.search.attr('placeholder') && this.search.val().length == 0) return;
|
||||
|
@ -2965,21 +3143,18 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
|
||||
// multi
|
||||
updateSelection: function (data) {
|
||||
var ids = [], filtered = [], self = this;
|
||||
var ids = {}, filtered = [], self = this;
|
||||
|
||||
// filter out duplicates
|
||||
$(data).each(function () {
|
||||
if (indexOf(self.id(this), ids) < 0) {
|
||||
ids.push(self.id(this));
|
||||
if (!(self.id(this) in ids)) {
|
||||
ids[self.id(this)] = 0;
|
||||
filtered.push(this);
|
||||
}
|
||||
});
|
||||
data = filtered;
|
||||
|
||||
this.selection.find(".select2-search-choice").remove();
|
||||
$(data).each(function () {
|
||||
self.addSelectedChoice(this);
|
||||
});
|
||||
this.addSelectedChoice(filtered);
|
||||
self.postprocessResults();
|
||||
},
|
||||
|
||||
|
@ -3053,6 +3228,14 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
},
|
||||
|
||||
addSelectedChoice: function (data) {
|
||||
var val = this.getVal(), self = this;
|
||||
$(data).each(function () {
|
||||
val.push(self.createChoice(this));
|
||||
});
|
||||
this.setVal(val);
|
||||
},
|
||||
|
||||
createChoice: function (data) {
|
||||
var enableChoice = !data.locked,
|
||||
enabledItem = $(
|
||||
"<li class='select2-search-choice'>" +
|
||||
|
@ -3065,7 +3248,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
"</li>");
|
||||
var choice = enableChoice ? enabledItem : disabledItem,
|
||||
id = this.id(data),
|
||||
val = this.getVal(),
|
||||
formatted,
|
||||
cssClass;
|
||||
|
||||
|
@ -3099,8 +3281,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
choice.data("select2-data", data);
|
||||
choice.insertBefore(this.searchContainer);
|
||||
|
||||
val.push(id);
|
||||
this.setVal(val);
|
||||
return id;
|
||||
},
|
||||
|
||||
// multi
|
||||
|
@ -3232,14 +3413,16 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
|
||||
// multi
|
||||
setVal: function (val) {
|
||||
var unique;
|
||||
if (this.select) {
|
||||
this.select.val(val);
|
||||
} else {
|
||||
unique = [];
|
||||
var unique = [], valMap = {};
|
||||
// filter out duplicates
|
||||
$(val).each(function () {
|
||||
if (indexOf(this, unique) < 0) unique.push(this);
|
||||
if (!(this in valMap)) {
|
||||
unique.push(this);
|
||||
valMap[this] = 0;
|
||||
}
|
||||
});
|
||||
this.opts.element.val(unique.length === 0 ? "" : unique.join(this.opts.separator));
|
||||
}
|
||||
|
@ -3255,11 +3438,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
for (var j = 0; j < old.length; j++) {
|
||||
if (equal(this.opts.id(current[i]), this.opts.id(old[j]))) {
|
||||
current.splice(i, 1);
|
||||
if(i>0){
|
||||
i--;
|
||||
}
|
||||
i--;
|
||||
old.splice(j, 1);
|
||||
j--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3429,6 +3610,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||
|
||||
// plugin defaults, accessible to users
|
||||
$.fn.select2.defaults = {
|
||||
debug: false,
|
||||
width: "copy",
|
||||
loadMorePadding: 0,
|
||||
closeOnSelect: true,
|
||||
|
|
23
select2.min.js
vendored
Normal file
23
select2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,16 +1,16 @@
|
|||
/**
|
||||
* Select2 Vietnamese translation.
|
||||
*
|
||||
* Author: Long Nguyen <olragon@gmail.com>
|
||||
* Author: Long Nguyen <olragon@gmail.com>, Nguyen Chien Cong
|
||||
*/
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
$.fn.select2.locales['vi'] = {
|
||||
formatNoMatches: function () { return "Không tìm thấy kết quả"; },
|
||||
formatInputTooShort: function (input, min) { var n = min - input.length; return "Vui lòng nhập nhiều hơn " + n + " ký tự" + (n == 1 ? "" : "s"); },
|
||||
formatInputTooLong: function (input, max) { var n = input.length - max; return "Vui lòng nhập ít hơn " + n + " ký tự" + (n == 1? "" : "s"); },
|
||||
formatSelectionTooBig: function (limit) { return "Chỉ có thể chọn được " + limit + " tùy chọn" + (limit == 1 ? "" : "s"); },
|
||||
formatInputTooShort: function (input, min) { var n = min - input.length; return "Vui lòng nhập nhiều hơn " + n + " ký tự"; },
|
||||
formatInputTooLong: function (input, max) { var n = input.length - max; return "Vui lòng nhập ít hơn " + n + " ký tự"; },
|
||||
formatSelectionTooBig: function (limit) { return "Chỉ có thể chọn được " + limit + " lựa chọn"; },
|
||||
formatLoadMore: function (pageNumber) { return "Đang lấy thêm kết quả…"; },
|
||||
formatSearching: function () { return "Đang tìm…"; }
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue