update select2 to 3.4.4

This commit is contained in:
vitalets 2013-11-02 22:21:23 +04:00
parent 88fa8dfe4c
commit 50cb33f721
4 changed files with 148 additions and 140 deletions

@ -1,113 +1,87 @@
/**
* Select2 Bootstrap CSS 1.0
* Compatible with select2 3.3.2 and bootstrap 2.3.1
* 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;
.form-control .select2-choice {
border: 0;
border-radius: 2px;
}
.select2-container .select2-choice,
.select2-container-multi .select2-choices {
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);
.form-control .select2-choice .select2-arrow {
border-radius: 0 2px 2px 0;
}
.select2-container .select2-choice div, .select2-container .select2-choice .select2-arrow,
.select2-container.select2-container-disabled .select2-choice div,
.select2-container.select2-container-disabled .select2-choice .select2-arrow {
border-left: none;
background: none;
filter: none;
.form-control.select2-container {
height: auto !important;
padding: 0px;
}
.control-group.error [class^="select2-choice"] {
border-color: #b94a48;
.form-control.select2-container.select2-dropdown-open {
border-color: #5897FB;
border-radius: 3px 3px 0 0;
}
.select2-container-multi .select2-choices .select2-search-field {
height: 28px;
line-height: 27px;
.form-control .select2-container.select2-dropdown-open .select2-choices {
border-radius: 3px 3px 0 0;
}
.select2-container-active .select2-choice,
.select2-container-multi.select2-container-active .select2-choices {
border-color: rgba(82, 168, 236, 0.8);
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);
.form-control.select2-container .select2-choices {
border: 0 !important;
border-radius: 3px;
}
[class^="input-"] .select2-container {
font-size: 14px;
.control-group.warning .select2-container .select2-choice,
.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"] {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
.control-group.warning .select2-container .select2-choice div {
border-left: 1px solid #C09853 !important;
background: #FCF8E3 !important;
}
.input-append [class^="select2-choice"] {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
.control-group.error .select2-container .select2-choice,
.control-group.error .select2-container .select2-choices,
.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"] {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
.control-group.error .select2-container .select2-choice div {
border-left: 1px solid #B94A48 !important;
background: #F2DEDE !important;
}
.select2-dropdown-open.select2-drop-above [class^="select2-choice"] {
border-top-left-radius: 0;
border-top-right-radius: 0;
.control-group.info .select2-container .select2-choice,
.control-group.info .select2-container .select2-choices,
.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 {
position: absolute;
.control-group.info .select2-container .select2-choice div {
border-left: 1px solid #3A87AD !important;
background: #D9EDF7 !important;
}
/**
* This stops the quick flash when a native selectbox is shown and
* then replaced by a select2 input when javascript kicks in. This can be
* removed if javascript is not present
*/
select.select2 {
height: 28px;
visibility: hidden;
.control-group.success .select2-container .select2-choice,
.control-group.success .select2-container .select2-choices,
.control-group.success .select2-container-active .select2-choice,
.control-group.success .select2-container-active .select2-choices,
.control-group.success .select2-dropdown-open.select2-drop-above .select2-choice,
.control-group.success .select2-dropdown-open.select2-drop-above .select2-choices,
.control-group.success .select2-container-multi.select2-container-active .select2-choices {
border: 1px solid #468847 !important;
}
.control-group.success .select2-container .select2-choice div {
border-left: 1px solid #468847 !important;
background: #DFF0D8 !important;
}

@ -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 {
margin: 0;

@ -1,7 +1,7 @@
/*
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
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) {
adapted = adapter(this);
if (adapted) {
replacements.push(this);
replacements.push(adapted);
}
}
});
@ -654,7 +654,7 @@ the specific language governing permissions and limitations under the Apache Lic
// abstract
init: function (opts) {
var results, search, resultsSelector = ".select2-results", disabled, readonly;
var results, search, resultsSelector = ".select2-results";
// prepare options
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 ($.fn.mousewheel) {
results.mousewheel(function (e, delta, deltaX, deltaY) {
var top = results.scrollTop(), height;
var top = results.scrollTop();
if (deltaY > 0 && top - deltaY <= 0) {
results.scrollTop(0);
killEvent(e);
@ -852,7 +852,7 @@ the specific language governing permissions and limitations under the Apache Lic
opts = $.extend({}, {
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) {
@ -999,7 +999,7 @@ the specific language governing permissions and limitations under the Apache Lic
*/
// abstract
monitorSource: function () {
var el = this.opts.element, sync;
var el = this.opts.element, sync, observer;
el.on("change.select2", this.bind(function (e) {
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 () {
var enabled, readonly, self = this;
// sync enabled state
var disabled = el.prop("disabled");
if (disabled === undefined) disabled = false;
@ -1028,9 +1026,8 @@ the specific language governing permissions and limitations under the Apache Lic
});
// mozilla and IE
el.on("propertychange.select2 DOMAttrModified.select2", sync);
// IE8-10
el.on("propertychange.select2", sync);
// hold onto a reference of the callback to work around a chromium bug
if (this.mutationCallback === undefined) {
@ -1039,10 +1036,11 @@ the specific language governing permissions and limitations under the Apache Lic
}
}
// safari and chrome
if (typeof WebKitMutationObserver !== "undefined") {
// safari, chrome, firefox, IE11
observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver;
if (observer !== undefined) {
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 });
}
},
@ -1135,8 +1133,11 @@ the specific language governing permissions and limitations under the Apache Lic
height = this.container.outerHeight(false),
width = this.container.outerWidth(false),
dropHeight = $dropdown.outerHeight(false),
viewPortRight = $(window).scrollLeft() + $(window).width(),
viewportBottom = $(window).scrollTop() + $(window).height(),
$window = $(window),
windowWidth = $window.width(),
windowHeight = $window.height(),
viewPortRight = $window.scrollLeft() + windowWidth,
viewportBottom = $window.scrollTop() + windowHeight,
dropTop = offset.top + height,
dropLeft = offset.left,
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"),
bodyOffset,
above,
changeDirection,
css,
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) {
resultsListNode = $('.select2-results', $dropdown)[0];
$dropdown.addClass('select2-drop-auto-width');
@ -1172,34 +1205,28 @@ the specific language governing permissions and limitations under the Apache Lic
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) {
dropLeft = offset.left + width - dropWidth;
}
css = {
left: dropLeft,
width: width
};
if (above) {
dropTop = offset.top - dropHeight;
css.bottom = windowHeight - offset.top;
css.top = 'auto';
this.container.addClass("select2-drop-above");
$dropdown.addClass("select2-drop-above");
}
else {
css.top = dropTop;
css.bottom = 'auto';
this.container.removeClass("select2-drop-above");
$dropdown.removeClass("select2-drop-above");
}
css = $.extend({
top: dropTop,
left: dropLeft,
width: width
}, evaluate(this.opts.dropdownCss));
css = $.extend(css, evaluate(this.opts.dropdownCss));
$dropdown.css(css);
},
@ -1249,7 +1276,7 @@ the specific language governing permissions and limitations under the Apache Lic
scroll = "scroll." + cid,
resize = "resize."+cid,
orient = "orientationchange."+cid,
mask, maskCss;
mask;
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) {
self.selectHighlighted({noFocus: true});
}
self.close({focus:false});
self.close({focus:true});
e.preventDefault();
e.stopPropagation();
}
@ -1402,7 +1429,7 @@ the specific language governing permissions and limitations under the Apache Lic
// abstract
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
@ -1472,7 +1499,6 @@ the specific language governing permissions and limitations under the Apache Lic
var results = this.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
offset = -1, // index of first element without data
page = this.resultsPage + 1,
self=this,
term=this.search.val(),
@ -1708,7 +1734,7 @@ the specific language governing permissions and limitations under the Apache Lic
// abstract
getPlaceholderOption: function() {
if (this.select) {
var firstOption = this.select.children().first();
var firstOption = this.select.children('option').first();
if (this.opts.placeholderOption !== undefined ) {
//Determine the placeholder option based on the specified placeholderOption setting
return (this.opts.placeholderOption === "first" && firstOption) ||
@ -1729,7 +1755,7 @@ the specific language governing permissions and limitations under the Apache Lic
// abstract
initContainerWidth: function () {
function resolveContainerWidth() {
var style, attrs, matches, i, l;
var style, attrs, matches, i, l, attr;
if (this.opts.width === "off") {
return null;
@ -1741,8 +1767,8 @@ the specific language governing permissions and limitations under the Apache Lic
if (style !== undefined) {
attrs = style.split(';');
for (i = 0, l = attrs.length; i < l; i = i + 1) {
matches = attrs[i].replace(/\s/g, '')
.match(/[^-]width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);
attr = attrs[i].replace(/\s/g, '');
matches = attr.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);
if (matches !== null && matches.length >= 1)
return matches[1];
}
@ -2093,7 +2119,7 @@ the specific language governing permissions and limitations under the Apache Lic
isPlaceholderOptionSelected: function() {
var placeholderOption;
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() === undefined)
|| (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") {
// install the selection initializer
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'
callback(self.optionToData(selected));
};
@ -2277,7 +2303,7 @@ the specific language governing permissions and limitations under the Apache Lic
if (this.select) {
this.select
.val(val)
.find(":selected").each2(function (i, elm) {
.find("option").filter(function() { return this.selected }).each2(function (i, elm) {
data = self.optionToData(elm);
return false;
});
@ -2372,7 +2398,7 @@ the specific language governing permissions and limitations under the Apache Lic
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));
});
callback(data);
@ -2853,9 +2879,17 @@ the specific language governing permissions and limitations under the Apache Lic
this.setVal(val);
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 });
},
@ -2982,7 +3016,7 @@ the specific language governing permissions and limitations under the Apache Lic
// multi
val: function (val, triggerChange) {
var oldData, self=this, changeDetails;
var oldData, self=this;
if (arguments.length === 0) {
return this.getVal();
@ -3021,7 +3055,7 @@ the specific language governing permissions and limitations under the Apache Lic
self.updateSelection(data);
self.clearSearch();
if (triggerChange) {
self.triggerChange(self.buildChangeDetails(oldData, this.data()));
self.triggerChange(self.buildChangeDetails(oldData, self.data()));
}
});
}

File diff suppressed because one or more lines are too long