update select2 to 3.4.4
This commit is contained in:
src/inputs/select2/lib
150
src/inputs/select2/lib/select2-bootstrap.css
vendored
150
src/inputs/select2/lib/select2-bootstrap.css
vendored
@ -1,113 +1,87 @@
|
|||||||
/**
|
.form-control .select2-choice {
|
||||||
* Select2 Bootstrap CSS 1.0
|
border: 0;
|
||||||
* Compatible with select2 3.3.2 and bootstrap 2.3.1
|
border-radius: 2px;
|
||||||
* MIT License
|
|
||||||
*/
|
|
||||||
.select2-container {
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.select2-container.input-mini {
|
|
||||||
width: 60px;
|
|
||||||
}
|
|
||||||
.select2-container.input-small {
|
|
||||||
width: 90px;
|
|
||||||
}
|
|
||||||
.select2-container.input-medium {
|
|
||||||
width: 150px;
|
|
||||||
}
|
|
||||||
.select2-container.input-large {
|
|
||||||
width: 210px;
|
|
||||||
}
|
|
||||||
.select2-container.input-xlarge {
|
|
||||||
width: 270px;
|
|
||||||
}
|
|
||||||
.select2-container.input-xxlarge {
|
|
||||||
width: 530px;
|
|
||||||
}
|
|
||||||
.select2-container.input-default {
|
|
||||||
width: 220px;
|
|
||||||
}
|
|
||||||
.select2-container[class*="span"] {
|
|
||||||
float: none;
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container .select2-choice,
|
.form-control .select2-choice .select2-arrow {
|
||||||
.select2-container-multi .select2-choices {
|
border-radius: 0 2px 2px 0;
|
||||||
height: 28px;
|
|
||||||
line-height: 29px;
|
|
||||||
border: 1px solid #cccccc;
|
|
||||||
-webkit-border-radius: 4px;
|
|
||||||
-moz-border-radius: 4px;
|
|
||||||
border-radius: 4px;
|
|
||||||
background: none;
|
|
||||||
background-color: white;
|
|
||||||
filter: none;
|
|
||||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
|
||||||
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
|
||||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container .select2-choice div, .select2-container .select2-choice .select2-arrow,
|
.form-control.select2-container {
|
||||||
.select2-container.select2-container-disabled .select2-choice div,
|
height: auto !important;
|
||||||
.select2-container.select2-container-disabled .select2-choice .select2-arrow {
|
padding: 0px;
|
||||||
border-left: none;
|
|
||||||
background: none;
|
|
||||||
filter: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.control-group.error [class^="select2-choice"] {
|
.form-control.select2-container.select2-dropdown-open {
|
||||||
border-color: #b94a48;
|
border-color: #5897FB;
|
||||||
|
border-radius: 3px 3px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container-multi .select2-choices .select2-search-field {
|
.form-control .select2-container.select2-dropdown-open .select2-choices {
|
||||||
height: 28px;
|
border-radius: 3px 3px 0 0;
|
||||||
line-height: 27px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container-active .select2-choice,
|
.form-control.select2-container .select2-choices {
|
||||||
.select2-container-multi.select2-container-active .select2-choices {
|
border: 0 !important;
|
||||||
border-color: rgba(82, 168, 236, 0.8);
|
border-radius: 3px;
|
||||||
outline: none;
|
|
||||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
|
||||||
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
|
||||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[class^="input-"] .select2-container {
|
.control-group.warning .select2-container .select2-choice,
|
||||||
font-size: 14px;
|
.control-group.warning .select2-container .select2-choices,
|
||||||
|
.control-group.warning .select2-container-active .select2-choice,
|
||||||
|
.control-group.warning .select2-container-active .select2-choices,
|
||||||
|
.control-group.warning .select2-dropdown-open.select2-drop-above .select2-choice,
|
||||||
|
.control-group.warning .select2-dropdown-open.select2-drop-above .select2-choices,
|
||||||
|
.control-group.warning .select2-container-multi.select2-container-active .select2-choices {
|
||||||
|
border: 1px solid #C09853 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-prepend [class^="select2-choice"] {
|
.control-group.warning .select2-container .select2-choice div {
|
||||||
border-top-left-radius: 0;
|
border-left: 1px solid #C09853 !important;
|
||||||
border-bottom-left-radius: 0;
|
background: #FCF8E3 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-append [class^="select2-choice"] {
|
.control-group.error .select2-container .select2-choice,
|
||||||
border-top-right-radius: 0;
|
.control-group.error .select2-container .select2-choices,
|
||||||
border-bottom-right-radius: 0;
|
.control-group.error .select2-container-active .select2-choice,
|
||||||
|
.control-group.error .select2-container-active .select2-choices,
|
||||||
|
.control-group.error .select2-dropdown-open.select2-drop-above .select2-choice,
|
||||||
|
.control-group.error .select2-dropdown-open.select2-drop-above .select2-choices,
|
||||||
|
.control-group.error .select2-container-multi.select2-container-active .select2-choices {
|
||||||
|
border: 1px solid #B94A48 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-dropdown-open [class^="select2-choice"] {
|
.control-group.error .select2-container .select2-choice div {
|
||||||
border-bottom-left-radius: 0;
|
border-left: 1px solid #B94A48 !important;
|
||||||
border-bottom-right-radius: 0;
|
background: #F2DEDE !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-dropdown-open.select2-drop-above [class^="select2-choice"] {
|
.control-group.info .select2-container .select2-choice,
|
||||||
border-top-left-radius: 0;
|
.control-group.info .select2-container .select2-choices,
|
||||||
border-top-right-radius: 0;
|
.control-group.info .select2-container-active .select2-choice,
|
||||||
|
.control-group.info .select2-container-active .select2-choices,
|
||||||
|
.control-group.info .select2-dropdown-open.select2-drop-above .select2-choice,
|
||||||
|
.control-group.info .select2-dropdown-open.select2-drop-above .select2-choices,
|
||||||
|
.control-group.info .select2-container-multi.select2-container-active .select2-choices {
|
||||||
|
border: 1px solid #3A87AD !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
[class^="input-"] .select2-offscreen {
|
.control-group.info .select2-container .select2-choice div {
|
||||||
position: absolute;
|
border-left: 1px solid #3A87AD !important;
|
||||||
|
background: #D9EDF7 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
.control-group.success .select2-container .select2-choice,
|
||||||
* This stops the quick flash when a native selectbox is shown and
|
.control-group.success .select2-container .select2-choices,
|
||||||
* then replaced by a select2 input when javascript kicks in. This can be
|
.control-group.success .select2-container-active .select2-choice,
|
||||||
* removed if javascript is not present
|
.control-group.success .select2-container-active .select2-choices,
|
||||||
*/
|
.control-group.success .select2-dropdown-open.select2-drop-above .select2-choice,
|
||||||
select.select2 {
|
.control-group.success .select2-dropdown-open.select2-drop-above .select2-choices,
|
||||||
height: 28px;
|
.control-group.success .select2-container-multi.select2-container-active .select2-choices {
|
||||||
visibility: hidden;
|
border: 1px solid #468847 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-group.success .select2-container .select2-choice div {
|
||||||
|
border-left: 1px solid #468847 !important;
|
||||||
|
background: #DFF0D8 !important;
|
||||||
}
|
}
|
||||||
|
2
src/inputs/select2/lib/select2.css
vendored
2
src/inputs/select2/lib/select2.css
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Version: 3.4.3 Timestamp: Tue Sep 17 06:47:14 PDT 2013
|
Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
|
||||||
*/
|
*/
|
||||||
.select2-container {
|
.select2-container {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
130
src/inputs/select2/lib/select2.js
vendored
130
src/inputs/select2/lib/select2.js
vendored
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2012 Igor Vaynberg
|
Copyright 2012 Igor Vaynberg
|
||||||
|
|
||||||
Version: 3.4.3 Timestamp: Tue Sep 17 06:47:14 PDT 2013
|
Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
|
||||||
|
|
||||||
This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
|
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
|
General Public License version 2 (the "GPL License"). You may choose either license to govern your
|
||||||
@ -349,7 +349,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
if (this.indexOf("select2-") !== 0) {
|
if (this.indexOf("select2-") !== 0) {
|
||||||
adapted = adapter(this);
|
adapted = adapter(this);
|
||||||
if (adapted) {
|
if (adapted) {
|
||||||
replacements.push(this);
|
replacements.push(adapted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -654,7 +654,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
// abstract
|
// abstract
|
||||||
init: function (opts) {
|
init: function (opts) {
|
||||||
var results, search, resultsSelector = ".select2-results", disabled, readonly;
|
var results, search, resultsSelector = ".select2-results";
|
||||||
|
|
||||||
// prepare options
|
// prepare options
|
||||||
this.opts = opts = this.prepareOpts(opts);
|
this.opts = opts = this.prepareOpts(opts);
|
||||||
@ -726,7 +726,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
// if jquery.mousewheel plugin is installed we can prevent out-of-bounds scrolling of results via mousewheel
|
// if jquery.mousewheel plugin is installed we can prevent out-of-bounds scrolling of results via mousewheel
|
||||||
if ($.fn.mousewheel) {
|
if ($.fn.mousewheel) {
|
||||||
results.mousewheel(function (e, delta, deltaX, deltaY) {
|
results.mousewheel(function (e, delta, deltaX, deltaY) {
|
||||||
var top = results.scrollTop(), height;
|
var top = results.scrollTop();
|
||||||
if (deltaY > 0 && top - deltaY <= 0) {
|
if (deltaY > 0 && top - deltaY <= 0) {
|
||||||
results.scrollTop(0);
|
results.scrollTop(0);
|
||||||
killEvent(e);
|
killEvent(e);
|
||||||
@ -852,7 +852,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
opts = $.extend({}, {
|
opts = $.extend({}, {
|
||||||
populateResults: function(container, results, query) {
|
populateResults: function(container, results, query) {
|
||||||
var populate, data, result, children, id=this.opts.id;
|
var populate, id=this.opts.id;
|
||||||
|
|
||||||
populate=function(results, container, depth) {
|
populate=function(results, container, depth) {
|
||||||
|
|
||||||
@ -999,7 +999,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
*/
|
*/
|
||||||
// abstract
|
// abstract
|
||||||
monitorSource: function () {
|
monitorSource: function () {
|
||||||
var el = this.opts.element, sync;
|
var el = this.opts.element, sync, observer;
|
||||||
|
|
||||||
el.on("change.select2", this.bind(function (e) {
|
el.on("change.select2", this.bind(function (e) {
|
||||||
if (this.opts.element.data("select2-change-triggered") !== true) {
|
if (this.opts.element.data("select2-change-triggered") !== true) {
|
||||||
@ -1009,8 +1009,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
sync = this.bind(function () {
|
sync = this.bind(function () {
|
||||||
|
|
||||||
var enabled, readonly, self = this;
|
|
||||||
|
|
||||||
// sync enabled state
|
// sync enabled state
|
||||||
var disabled = el.prop("disabled");
|
var disabled = el.prop("disabled");
|
||||||
if (disabled === undefined) disabled = false;
|
if (disabled === undefined) disabled = false;
|
||||||
@ -1028,9 +1026,8 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// mozilla and IE
|
// IE8-10
|
||||||
el.on("propertychange.select2 DOMAttrModified.select2", sync);
|
el.on("propertychange.select2", sync);
|
||||||
|
|
||||||
|
|
||||||
// hold onto a reference of the callback to work around a chromium bug
|
// hold onto a reference of the callback to work around a chromium bug
|
||||||
if (this.mutationCallback === undefined) {
|
if (this.mutationCallback === undefined) {
|
||||||
@ -1039,10 +1036,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// safari and chrome
|
// safari, chrome, firefox, IE11
|
||||||
if (typeof WebKitMutationObserver !== "undefined") {
|
observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver;
|
||||||
|
if (observer !== undefined) {
|
||||||
if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
|
if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
|
||||||
this.propertyObserver = new WebKitMutationObserver(this.mutationCallback);
|
this.propertyObserver = new observer(this.mutationCallback);
|
||||||
this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
|
this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1135,8 +1133,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
height = this.container.outerHeight(false),
|
height = this.container.outerHeight(false),
|
||||||
width = this.container.outerWidth(false),
|
width = this.container.outerWidth(false),
|
||||||
dropHeight = $dropdown.outerHeight(false),
|
dropHeight = $dropdown.outerHeight(false),
|
||||||
viewPortRight = $(window).scrollLeft() + $(window).width(),
|
$window = $(window),
|
||||||
viewportBottom = $(window).scrollTop() + $(window).height(),
|
windowWidth = $window.width(),
|
||||||
|
windowHeight = $window.height(),
|
||||||
|
viewPortRight = $window.scrollLeft() + windowWidth,
|
||||||
|
viewportBottom = $window.scrollTop() + windowHeight,
|
||||||
dropTop = offset.top + height,
|
dropTop = offset.top + height,
|
||||||
dropLeft = offset.left,
|
dropLeft = offset.left,
|
||||||
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
|
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
|
||||||
@ -1146,9 +1147,41 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
aboveNow = $dropdown.hasClass("select2-drop-above"),
|
aboveNow = $dropdown.hasClass("select2-drop-above"),
|
||||||
bodyOffset,
|
bodyOffset,
|
||||||
above,
|
above,
|
||||||
|
changeDirection,
|
||||||
css,
|
css,
|
||||||
resultsListNode;
|
resultsListNode;
|
||||||
|
|
||||||
|
// always prefer the current above/below alignment, unless there is not enough room
|
||||||
|
if (aboveNow) {
|
||||||
|
above = true;
|
||||||
|
if (!enoughRoomAbove && enoughRoomBelow) {
|
||||||
|
changeDirection = true;
|
||||||
|
above = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
above = false;
|
||||||
|
if (!enoughRoomBelow && enoughRoomAbove) {
|
||||||
|
changeDirection = true;
|
||||||
|
above = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if we are changing direction we need to get positions when dropdown is hidden;
|
||||||
|
if (changeDirection) {
|
||||||
|
$dropdown.hide();
|
||||||
|
offset = this.container.offset();
|
||||||
|
height = this.container.outerHeight(false);
|
||||||
|
width = this.container.outerWidth(false);
|
||||||
|
dropHeight = $dropdown.outerHeight(false);
|
||||||
|
viewPortRight = $window.scrollLeft() + windowWidth;
|
||||||
|
viewportBottom = $window.scrollTop() + windowHeight;
|
||||||
|
dropTop = offset.top + height;
|
||||||
|
dropLeft = offset.left;
|
||||||
|
dropWidth = $dropdown.outerWidth(false);
|
||||||
|
enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight;
|
||||||
|
$dropdown.show();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.opts.dropdownAutoWidth) {
|
if (this.opts.dropdownAutoWidth) {
|
||||||
resultsListNode = $('.select2-results', $dropdown)[0];
|
resultsListNode = $('.select2-results', $dropdown)[0];
|
||||||
$dropdown.addClass('select2-drop-auto-width');
|
$dropdown.addClass('select2-drop-auto-width');
|
||||||
@ -1172,34 +1205,28 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
dropLeft -= bodyOffset.left;
|
dropLeft -= bodyOffset.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
// always prefer the current above/below alignment, unless there is not enough room
|
|
||||||
if (aboveNow) {
|
|
||||||
above = true;
|
|
||||||
if (!enoughRoomAbove && enoughRoomBelow) above = false;
|
|
||||||
} else {
|
|
||||||
above = false;
|
|
||||||
if (!enoughRoomBelow && enoughRoomAbove) above = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!enoughRoomOnRight) {
|
if (!enoughRoomOnRight) {
|
||||||
dropLeft = offset.left + width - dropWidth;
|
dropLeft = offset.left + width - dropWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
css = {
|
||||||
|
left: dropLeft,
|
||||||
|
width: width
|
||||||
|
};
|
||||||
|
|
||||||
if (above) {
|
if (above) {
|
||||||
dropTop = offset.top - dropHeight;
|
css.bottom = windowHeight - offset.top;
|
||||||
|
css.top = 'auto';
|
||||||
this.container.addClass("select2-drop-above");
|
this.container.addClass("select2-drop-above");
|
||||||
$dropdown.addClass("select2-drop-above");
|
$dropdown.addClass("select2-drop-above");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
css.top = dropTop;
|
||||||
|
css.bottom = 'auto';
|
||||||
this.container.removeClass("select2-drop-above");
|
this.container.removeClass("select2-drop-above");
|
||||||
$dropdown.removeClass("select2-drop-above");
|
$dropdown.removeClass("select2-drop-above");
|
||||||
}
|
}
|
||||||
|
css = $.extend(css, evaluate(this.opts.dropdownCss));
|
||||||
css = $.extend({
|
|
||||||
top: dropTop,
|
|
||||||
left: dropLeft,
|
|
||||||
width: width
|
|
||||||
}, evaluate(this.opts.dropdownCss));
|
|
||||||
|
|
||||||
$dropdown.css(css);
|
$dropdown.css(css);
|
||||||
},
|
},
|
||||||
@ -1249,7 +1276,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
scroll = "scroll." + cid,
|
scroll = "scroll." + cid,
|
||||||
resize = "resize."+cid,
|
resize = "resize."+cid,
|
||||||
orient = "orientationchange."+cid,
|
orient = "orientationchange."+cid,
|
||||||
mask, maskCss;
|
mask;
|
||||||
|
|
||||||
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
|
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
|
||||||
|
|
||||||
@ -1273,7 +1300,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
if (self.opts.selectOnBlur) {
|
if (self.opts.selectOnBlur) {
|
||||||
self.selectHighlighted({noFocus: true});
|
self.selectHighlighted({noFocus: true});
|
||||||
}
|
}
|
||||||
self.close({focus:false});
|
self.close({focus:true});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
@ -1402,7 +1429,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
// abstract
|
// abstract
|
||||||
findHighlightableChoices: function() {
|
findHighlightableChoices: function() {
|
||||||
return this.results.find(".select2-result-selectable:not(.select2-disabled)");
|
return this.results.find(".select2-result-selectable:not(.select2-disabled, .select2-selected)");
|
||||||
},
|
},
|
||||||
|
|
||||||
// abstract
|
// abstract
|
||||||
@ -1472,7 +1499,6 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
var results = this.results,
|
var results = this.results,
|
||||||
more = results.find("li.select2-more-results"),
|
more = results.find("li.select2-more-results"),
|
||||||
below, // pixels the element is below the scroll fold, below==0 is when the element is starting to be visible
|
below, // pixels the element is below the scroll fold, below==0 is when the element is starting to be visible
|
||||||
offset = -1, // index of first element without data
|
|
||||||
page = this.resultsPage + 1,
|
page = this.resultsPage + 1,
|
||||||
self=this,
|
self=this,
|
||||||
term=this.search.val(),
|
term=this.search.val(),
|
||||||
@ -1708,7 +1734,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
// abstract
|
// abstract
|
||||||
getPlaceholderOption: function() {
|
getPlaceholderOption: function() {
|
||||||
if (this.select) {
|
if (this.select) {
|
||||||
var firstOption = this.select.children().first();
|
var firstOption = this.select.children('option').first();
|
||||||
if (this.opts.placeholderOption !== undefined ) {
|
if (this.opts.placeholderOption !== undefined ) {
|
||||||
//Determine the placeholder option based on the specified placeholderOption setting
|
//Determine the placeholder option based on the specified placeholderOption setting
|
||||||
return (this.opts.placeholderOption === "first" && firstOption) ||
|
return (this.opts.placeholderOption === "first" && firstOption) ||
|
||||||
@ -1729,7 +1755,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
// abstract
|
// abstract
|
||||||
initContainerWidth: function () {
|
initContainerWidth: function () {
|
||||||
function resolveContainerWidth() {
|
function resolveContainerWidth() {
|
||||||
var style, attrs, matches, i, l;
|
var style, attrs, matches, i, l, attr;
|
||||||
|
|
||||||
if (this.opts.width === "off") {
|
if (this.opts.width === "off") {
|
||||||
return null;
|
return null;
|
||||||
@ -1741,8 +1767,8 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
if (style !== undefined) {
|
if (style !== undefined) {
|
||||||
attrs = style.split(';');
|
attrs = style.split(';');
|
||||||
for (i = 0, l = attrs.length; i < l; i = i + 1) {
|
for (i = 0, l = attrs.length; i < l; i = i + 1) {
|
||||||
matches = attrs[i].replace(/\s/g, '')
|
attr = attrs[i].replace(/\s/g, '');
|
||||||
.match(/[^-]width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);
|
matches = attr.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);
|
||||||
if (matches !== null && matches.length >= 1)
|
if (matches !== null && matches.length >= 1)
|
||||||
return matches[1];
|
return matches[1];
|
||||||
}
|
}
|
||||||
@ -2093,7 +2119,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
isPlaceholderOptionSelected: function() {
|
isPlaceholderOptionSelected: function() {
|
||||||
var placeholderOption;
|
var placeholderOption;
|
||||||
if (!this.getPlaceholder()) return false; // no placeholder specified so no option should be considered
|
if (!this.getPlaceholder()) return false; // no placeholder specified so no option should be considered
|
||||||
return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.is(':selected'))
|
return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.prop("selected"))
|
||||||
|| (this.opts.element.val() === "")
|
|| (this.opts.element.val() === "")
|
||||||
|| (this.opts.element.val() === undefined)
|
|| (this.opts.element.val() === undefined)
|
||||||
|| (this.opts.element.val() === null);
|
|| (this.opts.element.val() === null);
|
||||||
@ -2107,7 +2133,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
if (opts.element.get(0).tagName.toLowerCase() === "select") {
|
if (opts.element.get(0).tagName.toLowerCase() === "select") {
|
||||||
// install the selection initializer
|
// install the selection initializer
|
||||||
opts.initSelection = function (element, callback) {
|
opts.initSelection = function (element, callback) {
|
||||||
var selected = element.find(":selected");
|
var selected = element.find("option").filter(function() { return this.selected });
|
||||||
// a single select box always has a value, no need to null check 'selected'
|
// a single select box always has a value, no need to null check 'selected'
|
||||||
callback(self.optionToData(selected));
|
callback(self.optionToData(selected));
|
||||||
};
|
};
|
||||||
@ -2277,7 +2303,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
if (this.select) {
|
if (this.select) {
|
||||||
this.select
|
this.select
|
||||||
.val(val)
|
.val(val)
|
||||||
.find(":selected").each2(function (i, elm) {
|
.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
|
||||||
data = self.optionToData(elm);
|
data = self.optionToData(elm);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -2372,7 +2398,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
var data = [];
|
var data = [];
|
||||||
|
|
||||||
element.find(":selected").each2(function (i, elm) {
|
element.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
|
||||||
data.push(self.optionToData(elm));
|
data.push(self.optionToData(elm));
|
||||||
});
|
});
|
||||||
callback(data);
|
callback(data);
|
||||||
@ -2853,9 +2879,17 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
this.setVal(val);
|
this.setVal(val);
|
||||||
if (this.select) this.postprocessResults();
|
if (this.select) this.postprocessResults();
|
||||||
}
|
}
|
||||||
selected.remove();
|
|
||||||
|
|
||||||
this.opts.element.trigger({ type: "removed", val: this.id(data), choice: data });
|
var evt = $.Event("select2-removing");
|
||||||
|
evt.val = this.id(data);
|
||||||
|
evt.choice = data;
|
||||||
|
this.opts.element.trigger(evt);
|
||||||
|
|
||||||
|
if (evt.isDefaultPrevented()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
|
||||||
this.triggerChange({ removed: data });
|
this.triggerChange({ removed: data });
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2982,7 +3016,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
// multi
|
// multi
|
||||||
val: function (val, triggerChange) {
|
val: function (val, triggerChange) {
|
||||||
var oldData, self=this, changeDetails;
|
var oldData, self=this;
|
||||||
|
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0) {
|
||||||
return this.getVal();
|
return this.getVal();
|
||||||
@ -3021,7 +3055,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
self.updateSelection(data);
|
self.updateSelection(data);
|
||||||
self.clearSearch();
|
self.clearSearch();
|
||||||
if (triggerChange) {
|
if (triggerChange) {
|
||||||
self.triggerChange(self.buildChangeDetails(oldData, this.data()));
|
self.triggerChange(self.buildChangeDetails(oldData, self.data()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
6
src/inputs/select2/lib/select2.min.js
vendored
6
src/inputs/select2/lib/select2.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user