[REF] web: update select2 to v3.5.4
This commit is contained in:
committed by
Aaron Bohy
parent
c8bab2ddb3
commit
154c3dcda4
@@ -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.
|
||||
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
|
||||
---------
|
||||
@@ -24,17 +24,17 @@ Browser compatibility
|
||||
* Firefox 10+
|
||||
* Safari 3+
|
||||
* Opera 10.6+
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
You can source Select2 directly from a [CDN like JSDliver](http://www.jsdelivr.com/#!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
|
||||
------------
|
||||
|
||||
* [Wicket-Select2](https://github.com/ivaynberg/wicket-select2) (Java / [Apache Wicket](http://wicket.apache.org))
|
||||
* [select2-rails](https://github.com/argerim/select2-rails) (Ruby on Rails)
|
||||
* [AngularUI](http://angular-ui.github.com/#directives-select2) ([AngularJS](angularjs.org))
|
||||
* [AngularUI](http://angular-ui.github.io/#ui-select) ([AngularJS](https://angularjs.org/))
|
||||
* [Django](https://github.com/applegrew/django-select2)
|
||||
* [Symfony](https://github.com/19Gerhard85/sfSelect2WidgetsPlugin)
|
||||
* [Symfony2](https://github.com/avocode/FormExtensions)
|
||||
@@ -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
|
||||
|
||||
@@ -61,15 +62,21 @@ file (`select2_locale_it.js`, `select2_locale_nl.js`, etc.) after `select2.js`.
|
||||
Missing a language? Just copy `select2_locale_en.js.template`, translate
|
||||
it, and make a pull request back to Select2 here on GitHub.
|
||||
|
||||
Bug tracker
|
||||
-----------
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
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
|
||||
---------
|
||||
|
||||
### Bug tracker
|
||||
|
||||
Have a bug? Please create an issue here on GitHub!
|
||||
|
||||
https://github.com/ivaynberg/select2/issues
|
||||
|
||||
Mailing list
|
||||
------------
|
||||
### Mailing list
|
||||
|
||||
Have a question? Ask on our mailing list!
|
||||
|
||||
@@ -77,11 +84,20 @@ select2@googlegroups.com
|
||||
|
||||
https://groups.google.com/d/forum/select2
|
||||
|
||||
### IRC channel
|
||||
|
||||
Need help implementing Select2 in your project? Ask in our IRC channel!
|
||||
|
||||
**Network:** [Freenode](https://freenode.net/) (`chat.freenode.net`)
|
||||
|
||||
**Channel:** `#select2`
|
||||
|
||||
**Web access:** https://webchat.freenode.net/?channels=select2
|
||||
|
||||
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
|
||||
@@ -96,4 +112,4 @@ 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 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.
|
||||
permissions and limitations under the Apache License and the GPL License.
|
||||
|
||||
@@ -6,8 +6,8 @@ echo -n "Enter the version for this release: "
|
||||
read ver
|
||||
|
||||
if [ ! $ver ]; then
|
||||
echo "Invalid version."
|
||||
exit
|
||||
echo "Invalid version."
|
||||
exit
|
||||
fi
|
||||
|
||||
name="select2"
|
||||
@@ -20,7 +20,7 @@ branch="build-$ver"
|
||||
curbranch=`git branch | grep "*" | sed "s/* //"`
|
||||
timestamp=$(date)
|
||||
tokens="s/@@ver@@/$ver/g;s/\@@timestamp@@/$timestamp/g"
|
||||
remote="github"
|
||||
remote="origin"
|
||||
|
||||
echo "Pulling from origin"
|
||||
|
||||
@@ -59,9 +59,9 @@ cat LICENSE | sed "$tokens" >> "$mini"
|
||||
echo "*/" >> "$mini"
|
||||
|
||||
curl -s \
|
||||
--data-urlencode "js_code@$js" \
|
||||
http://marijnhaverbeke.nl/uglifyjs \
|
||||
>> "$mini"
|
||||
--data-urlencode "js_code@$js" \
|
||||
http://marijnhaverbeke.nl/uglifyjs \
|
||||
>> "$mini"
|
||||
|
||||
git add "$mini"
|
||||
|
||||
@@ -76,4 +76,4 @@ echo "Cleaning Up..."
|
||||
git checkout "$curbranch"
|
||||
git branch -D "$branch"
|
||||
|
||||
echo "Done"
|
||||
echo "Done"
|
||||
|
||||
+4
-16
@@ -1,13 +1,10 @@
|
||||
/*
|
||||
Version: 3.5.1 Timestamp: Tue Jul 22 18:58:56 EDT 2014
|
||||
Version: 3.5.4 Timestamp: Sun Aug 30 13:30:32 EDT 2015
|
||||
*/
|
||||
.select2-container {
|
||||
margin: 0;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
/* inline-block for ie7 */
|
||||
zoom: 1;
|
||||
*display: inline;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
@@ -180,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;
|
||||
@@ -230,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;
|
||||
@@ -273,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));
|
||||
@@ -586,7 +574,7 @@ html[dir="rtl"] .select2-container-multi .select2-choices li
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
|
||||
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
||||
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
||||
background-image: linear-gradient(to top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
||||
background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
||||
}
|
||||
html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice
|
||||
{
|
||||
@@ -701,4 +689,4 @@ html[dir="rtl"] .select2-container-multi .select2-search-choice-close {
|
||||
.select2-search input {
|
||||
background-position: 100% -21px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+325
-104
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Copyright 2012 Igor Vaynberg
|
||||
|
||||
Version: 3.5.1 Timestamp: Tue Jul 22 18:58:56 EDT 2014
|
||||
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
|
||||
@@ -46,7 +46,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
return;
|
||||
}
|
||||
|
||||
var KEY, AbstractSelect2, SingleSelect2, MultiSelect2, nextUid, sizer,
|
||||
var AbstractSelect2, SingleSelect2, MultiSelect2, nextUid, sizer,
|
||||
lastMousePosition={x:0,y:0}, $document, scrollBarDimensions,
|
||||
|
||||
KEY = {
|
||||
@@ -132,7 +132,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
|
||||
function measureScrollbar () {
|
||||
var $template = $( MEASURE_SCROLLBAR_TEMPLATE );
|
||||
$template.appendTo('body');
|
||||
$template.appendTo(document.body);
|
||||
|
||||
var dim = {
|
||||
width: $template.width() - $template[0].clientWidth,
|
||||
@@ -160,16 +160,16 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the string into an array of values, trimming each value. An empty array is returned for nulls or empty
|
||||
* Splits the string into an array of values, transforming each value. An empty array is returned for nulls or empty
|
||||
* strings
|
||||
* @param string
|
||||
* @param separator
|
||||
*/
|
||||
function splitVal(string, separator) {
|
||||
function splitVal(string, separator, transform) {
|
||||
var val, i, l;
|
||||
if (string === null || string.length < 1) return [];
|
||||
val = string.split(separator);
|
||||
for (i = 0, l = val.length; i < l; i = i + 1) val[i] = $.trim(val[i]);
|
||||
for (i = 0, l = val.length; i < l; i = i + 1) val[i] = transform(val[i]);
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
whiteSpace: "nowrap"
|
||||
});
|
||||
sizer.attr("class","select2-sizer");
|
||||
$("body").append(sizer);
|
||||
$(document.body).append(sizer);
|
||||
}
|
||||
sizer.text(e.val());
|
||||
return sizer.width();
|
||||
@@ -450,7 +450,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
hasError: true,
|
||||
jqXHR: jqXHR,
|
||||
textStatus: textStatus,
|
||||
errorThrown: errorThrown,
|
||||
errorThrown: errorThrown
|
||||
};
|
||||
|
||||
query.callback(results);
|
||||
@@ -699,12 +699,15 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
|
||||
this.container = this.createContainer();
|
||||
|
||||
this.liveRegion = $("<span>", {
|
||||
role: "status",
|
||||
"aria-live": "polite"
|
||||
})
|
||||
.addClass("select2-hidden-accessible")
|
||||
.appendTo(document.body);
|
||||
this.liveRegion = $('.select2-hidden-accessible');
|
||||
if (this.liveRegion.length == 0) {
|
||||
this.liveRegion = $("<span>", {
|
||||
role: "status",
|
||||
"aria-live": "polite"
|
||||
})
|
||||
.addClass("select2-hidden-accessible")
|
||||
.appendTo(document.body);
|
||||
}
|
||||
|
||||
this.containerId="s2id_"+(opts.element.attr("id") || "autogen"+nextUid());
|
||||
this.containerEventName= this.containerId
|
||||
@@ -714,7 +717,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
|
||||
this.container.attr("title", opts.element.attr("title"));
|
||||
|
||||
this.body = $("body");
|
||||
this.body = $(document.body);
|
||||
|
||||
syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
|
||||
|
||||
@@ -811,7 +814,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
// focusin can cause focus wars between modals and select2 since the dropdown is outside the modal.
|
||||
this.dropdown.on("click mouseup mousedown touchstart touchend focusin", function (e) { e.stopPropagation(); });
|
||||
|
||||
this.nextSearchTerm = undefined;
|
||||
this.lastSearchTerm = undefined;
|
||||
|
||||
if ($.isFunction(this.opts.initSelection)) {
|
||||
// initialize selection based on the current value of the source element
|
||||
@@ -850,9 +853,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
|
||||
this.close();
|
||||
|
||||
if (element.length && element[0].detachEvent) {
|
||||
if (element.length && element[0].detachEvent && self._sync) {
|
||||
element.each(function () {
|
||||
this.detachEvent("onpropertychange", self._sync);
|
||||
if (self._sync) {
|
||||
this.detachEvent("onpropertychange", self._sync);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.propertyObserver) {
|
||||
@@ -865,17 +870,21 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
select2.container.remove();
|
||||
select2.liveRegion.remove();
|
||||
select2.dropdown.remove();
|
||||
element
|
||||
.removeClass("select2-offscreen")
|
||||
.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,
|
||||
@@ -927,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;
|
||||
@@ -970,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);
|
||||
@@ -1041,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) {
|
||||
@@ -1058,7 +1214,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
if (opts.initSelection === undefined) {
|
||||
opts.initSelection = function (element, callback) {
|
||||
var data = [];
|
||||
$(splitVal(element.val(), opts.separator)).each(function () {
|
||||
$(splitVal(element.val(), opts.separator, opts.transformVal)).each(function () {
|
||||
var obj = { id: this, text: this },
|
||||
tags = opts.tags;
|
||||
if ($.isFunction(tags)) tags=tags();
|
||||
@@ -1113,11 +1269,15 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
if (readonly === undefined) readonly = false;
|
||||
this.readonly(readonly);
|
||||
|
||||
syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
|
||||
this.container.addClass(evaluate(this.opts.containerCssClass, this.opts.element));
|
||||
if (this.container) {
|
||||
syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
|
||||
this.container.addClass(evaluate(this.opts.containerCssClass, this.opts.element));
|
||||
}
|
||||
|
||||
syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
|
||||
this.dropdown.addClass(evaluate(this.opts.dropdownCssClass, this.opts.element));
|
||||
if (this.dropdown) {
|
||||
syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
|
||||
this.dropdown.addClass(evaluate(this.opts.dropdownCssClass, this.opts.element));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -1222,9 +1382,10 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
// abstract
|
||||
positionDropdown: function() {
|
||||
var $dropdown = this.dropdown,
|
||||
offset = this.container.offset(),
|
||||
height = this.container.outerHeight(false),
|
||||
width = this.container.outerWidth(false),
|
||||
container = this.container,
|
||||
offset = container.offset(),
|
||||
height = container.outerHeight(false),
|
||||
width = container.outerWidth(false),
|
||||
dropHeight = $dropdown.outerHeight(false),
|
||||
$window = $(window),
|
||||
windowWidth = $window.width(),
|
||||
@@ -1236,7 +1397,12 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
|
||||
enoughRoomAbove = (offset.top - dropHeight) >= $window.scrollTop(),
|
||||
dropWidth = $dropdown.outerWidth(false),
|
||||
enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight,
|
||||
enoughRoomOnRight = function() {
|
||||
return dropLeft + dropWidth <= viewPortRight;
|
||||
},
|
||||
enoughRoomOnLeft = function() {
|
||||
return offset.left + viewPortRight + container.outerWidth(false) > dropWidth;
|
||||
},
|
||||
aboveNow = $dropdown.hasClass("select2-drop-above"),
|
||||
bodyOffset,
|
||||
above,
|
||||
@@ -1271,7 +1437,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
dropTop = offset.top + height;
|
||||
dropLeft = offset.left;
|
||||
dropWidth = $dropdown.outerWidth(false);
|
||||
enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight;
|
||||
$dropdown.show();
|
||||
|
||||
// fix so the cursor does not move to the left within the search-textbox in IE
|
||||
@@ -1286,7 +1451,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
dropWidth = $dropdown.outerWidth(false) + (resultsListNode.scrollHeight === resultsListNode.clientHeight ? 0 : scrollBarDimensions.width);
|
||||
dropWidth > width ? width = dropWidth : dropWidth = width;
|
||||
dropHeight = $dropdown.outerHeight(false);
|
||||
enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight;
|
||||
}
|
||||
else {
|
||||
this.container.removeClass('select2-drop-auto-width');
|
||||
@@ -1302,7 +1466,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
dropLeft -= bodyOffset.left;
|
||||
}
|
||||
|
||||
if (!enoughRoomOnRight) {
|
||||
if (!enoughRoomOnRight() && enoughRoomOnLeft()) {
|
||||
dropLeft = offset.left + this.container.outerWidth(false) - dropWidth;
|
||||
}
|
||||
|
||||
@@ -1312,10 +1476,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
};
|
||||
|
||||
if (above) {
|
||||
css.top = offset.top - dropHeight;
|
||||
css.bottom = 'auto';
|
||||
this.container.addClass("select2-drop-above");
|
||||
$dropdown.addClass("select2-drop-above");
|
||||
dropHeight = $dropdown.outerHeight(false);
|
||||
css.top = offset.top - dropHeight;
|
||||
css.bottom = 'auto';
|
||||
}
|
||||
else {
|
||||
css.top = dropTop;
|
||||
@@ -1391,7 +1556,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
|
||||
// create the dropdown mask if doesn't already exist
|
||||
mask = $("#select2-drop-mask");
|
||||
if (mask.length == 0) {
|
||||
if (mask.length === 0) {
|
||||
mask = $(document.createElement("div"));
|
||||
mask.attr("id","select2-drop-mask").attr("class","select2-drop-mask");
|
||||
mask.hide();
|
||||
@@ -1468,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"));
|
||||
},
|
||||
|
||||
@@ -1486,6 +1654,27 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Boolean} Whether or not search value was changed.
|
||||
* @private
|
||||
*/
|
||||
prefillNextSearchTerm: function () {
|
||||
// initializes search's value with nextSearchTerm (if defined by user)
|
||||
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
|
||||
if(this.search.val() !== "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
var nextSearchTerm = this.opts.nextSearchTerm(this.data(), this.lastSearchTerm);
|
||||
if(nextSearchTerm !== undefined){
|
||||
this.search.val(nextSearchTerm);
|
||||
this.search.select();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
//abstract
|
||||
getMaximumSelectionSize: function() {
|
||||
return evaluate(this.opts.maximumSelectionSize, this.opts.element);
|
||||
@@ -1525,7 +1714,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}
|
||||
}
|
||||
|
||||
rb = results.offset().top + results.outerHeight(true);
|
||||
rb = results.offset().top + results.outerHeight(false);
|
||||
if (hb > rb) {
|
||||
results.scrollTop(results.scrollTop() + (hb - rb));
|
||||
}
|
||||
@@ -1648,7 +1837,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
self.postprocessResults(data, false, false);
|
||||
|
||||
if (data.more===true) {
|
||||
more.detach().appendTo(results).text(evaluate(self.opts.formatLoadMore, self.opts.element, page+1));
|
||||
more.detach().appendTo(results).html(self.opts.escapeMarkup(evaluate(self.opts.formatLoadMore, self.opts.element, page+1)));
|
||||
window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10);
|
||||
} else {
|
||||
more.remove();
|
||||
@@ -1701,7 +1890,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
self.liveRegion.text(results.text());
|
||||
}
|
||||
else {
|
||||
self.liveRegion.text(self.opts.formatMatches(results.find('.select2-result-selectable').length));
|
||||
self.liveRegion.text(self.opts.formatMatches(results.find('.select2-result-selectable:not(".select2-selected")').length));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1799,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;
|
||||
}
|
||||
|
||||
@@ -1903,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, '');
|
||||
@@ -2002,14 +2194,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}
|
||||
}
|
||||
|
||||
// initializes search's value with nextSearchTerm (if defined by user)
|
||||
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
|
||||
if(this.search.val() === "") {
|
||||
if(this.nextSearchTerm != undefined){
|
||||
this.search.val(this.nextSearchTerm);
|
||||
this.search.select();
|
||||
}
|
||||
}
|
||||
this.prefillNextSearchTerm();
|
||||
|
||||
this.focusser.prop("disabled", true).val("");
|
||||
this.updateResults(true);
|
||||
@@ -2096,6 +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.on('focus.select2', this.bind(function () { this.focus(); }));
|
||||
|
||||
this.focusser.prev()
|
||||
.text(elementLabel.text())
|
||||
@@ -2151,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);
|
||||
@@ -2200,11 +2386,17 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}));
|
||||
|
||||
selection.on("mousedown touchstart", "abbr", this.bind(function (e) {
|
||||
if (!this.isInterfaceEnabled()) return;
|
||||
if (!this.isInterfaceEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.clear();
|
||||
killEventImmediately(e);
|
||||
this.close();
|
||||
this.selection.focus();
|
||||
|
||||
if (this.selection) {
|
||||
this.selection.focus();
|
||||
}
|
||||
}));
|
||||
|
||||
selection.on("mousedown touchstart", this.bind(function (e) {
|
||||
@@ -2253,7 +2445,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}));
|
||||
|
||||
this.initContainerWidth();
|
||||
this.opts.element.addClass("select2-offscreen");
|
||||
this.opts.element.hide();
|
||||
this.setPlaceholder();
|
||||
|
||||
},
|
||||
@@ -2297,7 +2489,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
self.updateSelection(selected);
|
||||
self.close();
|
||||
self.setPlaceholder();
|
||||
self.nextSearchTerm = self.opts.nextSearchTerm(selected, self.search.val());
|
||||
self.lastSearchTerm = self.search.val();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2434,7 +2626,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
|
||||
this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data });
|
||||
|
||||
this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
|
||||
this.lastSearchTerm = this.search.val();
|
||||
this.close();
|
||||
|
||||
if ((!options || !options.noFocus) && this.opts.shouldFocusInput(this)) {
|
||||
@@ -2488,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) {
|
||||
@@ -2539,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];
|
||||
}
|
||||
@@ -2582,7 +2795,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
self=this;
|
||||
|
||||
// TODO validate placeholder is a string if specified
|
||||
|
||||
if (opts.element.get(0).tagName.toLowerCase() === "select") {
|
||||
// install the selection initializer
|
||||
opts.initSelection = function (element, callback) {
|
||||
@@ -2597,7 +2809,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
} else if ("data" in opts) {
|
||||
// install default initSelection when applied to hidden input and data is local
|
||||
opts.initSelection = opts.initSelection || function (element, callback) {
|
||||
var ids = splitVal(element.val(), opts.separator);
|
||||
var ids = splitVal(element.val(), opts.separator, opts.transformVal);
|
||||
//search in data by array of ids, storing matching items in a list
|
||||
var matches = [];
|
||||
opts.query({
|
||||
@@ -2674,8 +2886,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
this.selection = selection = this.container.find(selector);
|
||||
|
||||
var _this = this;
|
||||
this.selection.on("click", ".select2-search-choice:not(.select2-locked)", function (e) {
|
||||
//killEvent(e);
|
||||
this.selection.on("click", ".select2-container:not(.select2-container-disabled) .select2-search-choice:not(.select2-locked)", function (e) {
|
||||
_this.search[0].focus();
|
||||
_this.selectChoice($(this));
|
||||
});
|
||||
@@ -2686,6 +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.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;
|
||||
@@ -2837,7 +3049,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}));
|
||||
|
||||
this.initContainerWidth();
|
||||
this.opts.element.addClass("select2-offscreen");
|
||||
this.opts.element.hide();
|
||||
|
||||
// set the placeholder if necessary
|
||||
this.clearSearch();
|
||||
@@ -2903,16 +3115,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
|
||||
this.focusSearch();
|
||||
|
||||
// initializes search's value with nextSearchTerm (if defined by user)
|
||||
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
|
||||
if(this.search.val() === "") {
|
||||
if(this.nextSearchTerm != undefined){
|
||||
this.search.val(this.nextSearchTerm);
|
||||
this.search.select();
|
||||
}
|
||||
}
|
||||
|
||||
this.prefillNextSearchTerm();
|
||||
this.updateResults(true);
|
||||
|
||||
if (this.opts.shouldFocusInput(this)) {
|
||||
this.search.focus();
|
||||
}
|
||||
@@ -2938,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();
|
||||
},
|
||||
|
||||
@@ -2979,7 +3181,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
|
||||
|
||||
// keep track of the search's value before it gets cleared
|
||||
this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
|
||||
this.lastSearchTerm = this.search.val();
|
||||
|
||||
this.clearSearch();
|
||||
this.updateResults();
|
||||
@@ -2999,10 +3201,8 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
this.updateResults(true);
|
||||
} else {
|
||||
// initializes search's value with nextSearchTerm and update search result
|
||||
if(this.nextSearchTerm != undefined){
|
||||
this.search.val(this.nextSearchTerm);
|
||||
if (this.prefillNextSearchTerm()) {
|
||||
this.updateResults();
|
||||
this.search.select();
|
||||
}
|
||||
}
|
||||
this.positionDropdown();
|
||||
@@ -3028,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'>" +
|
||||
@@ -3040,13 +3248,12 @@ 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;
|
||||
|
||||
formatted=this.opts.formatSelection(data, choice.find("div"), this.opts.escapeMarkup);
|
||||
if (formatted != undefined) {
|
||||
choice.find("div").replaceWith("<div>"+formatted+"</div>");
|
||||
choice.find("div").replaceWith($("<div></div>").html(formatted));
|
||||
}
|
||||
cssClass=this.opts.formatSelectionCssClass(data, choice.find("div"));
|
||||
if (cssClass != undefined) {
|
||||
@@ -3074,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
|
||||
@@ -3144,7 +3350,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}
|
||||
});
|
||||
|
||||
if (this.highlight() == -1 && noHighlightUpdate !== false){
|
||||
if (this.highlight() == -1 && noHighlightUpdate !== false && this.opts.closeOnSelect === true){
|
||||
self.highlight(0);
|
||||
}
|
||||
|
||||
@@ -3201,20 +3407,22 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
return val === null ? [] : val;
|
||||
} else {
|
||||
val = this.opts.element.val();
|
||||
return splitVal(val, this.opts.separator);
|
||||
return splitVal(val, this.opts.separator, this.opts.transformVal);
|
||||
}
|
||||
},
|
||||
|
||||
// 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));
|
||||
}
|
||||
@@ -3230,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3404,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,
|
||||
@@ -3414,11 +3621,14 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
dropdownCssClass: "",
|
||||
formatResult: function(result, container, query, escapeMarkup) {
|
||||
var markup=[];
|
||||
markMatch(result.text, query.term, markup, escapeMarkup);
|
||||
markMatch(this.text(result), query.term, markup, escapeMarkup);
|
||||
return markup.join("");
|
||||
},
|
||||
transformVal: function(val) {
|
||||
return $.trim(val);
|
||||
},
|
||||
formatSelection: function (data, container, escapeMarkup) {
|
||||
return data ? escapeMarkup(data.text) : undefined;
|
||||
return data ? escapeMarkup(this.text(data)) : undefined;
|
||||
},
|
||||
sortResults: function (results, container, query) {
|
||||
return results;
|
||||
@@ -3430,6 +3640,17 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
maximumInputLength: null,
|
||||
maximumSelectionSize: 0,
|
||||
id: function (e) { return e == undefined ? null : e.id; },
|
||||
text: function (e) {
|
||||
if (e && this.data && this.data.text) {
|
||||
if ($.isFunction(this.data.text)) {
|
||||
return this.data.text(e);
|
||||
} else {
|
||||
return e[this.data.text];
|
||||
}
|
||||
} else {
|
||||
return e.text;
|
||||
}
|
||||
},
|
||||
matcher: function(term, text) {
|
||||
return stripDiacritics(''+text).toUpperCase().indexOf(stripDiacritics(''+term).toUpperCase()) >= 0;
|
||||
},
|
||||
@@ -3473,7 +3694,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1 ? "" : "s"); },
|
||||
formatSelectionTooBig: function (limit) { return "You can only select " + limit + " item" + (limit == 1 ? "" : "s"); },
|
||||
formatLoadMore: function (pageNumber) { return "Loading more results…"; },
|
||||
formatSearching: function () { return "Searching…"; },
|
||||
formatSearching: function () { return "Searching…"; }
|
||||
};
|
||||
|
||||
$.extend($.fn.select2.defaults, $.fn.select2.locales['en']);
|
||||
@@ -3505,4 +3726,4 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}
|
||||
};
|
||||
|
||||
}(jQuery));
|
||||
}(jQuery));
|
||||
|
||||
Reference in New Issue
Block a user