Skip to content

Commit 2e901f7

Browse files
committed
merge
2 parents f4886a0 + e559f92 commit 2e901f7

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

select2.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ Version: @@ver@@ Timestamp: @@timestamp@@
236236
background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
237237
background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
238238
background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
239-
background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%);
239+
background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
240240
}
241241

242242
.select2-drop.select2-drop-above .select2-search input {
@@ -248,7 +248,7 @@ Version: @@ver@@ Timestamp: @@timestamp@@
248248
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));
249249
background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
250250
background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
251-
background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%);
251+
background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
252252
}
253253

254254
.select2-container-active .select2-choice,
@@ -628,7 +628,7 @@ html[dir="rtl"] .select2-search-choice-close {
628628

629629
/* Retina-ize icons */
630630

631-
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2ppx) {
631+
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2dppx) {
632632
.select2-search input,
633633
.select2-search-choice-close,
634634
.select2-container .select2-choice abbr,

select2.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ the specific language governing permissions and limitations under the Apache Lic
272272

273273
/* make sure el received focus so we do not error out when trying to manipulate the caret.
274274
sometimes modals or others listeners may steal it after its set */
275-
if ($el.is(":visible") && el === document.activeElement) {
275+
var isVisible = (el.offsetWidth > 0 || el.offsetHeight > 0);
276+
if (isVisible && el === document.activeElement) {
276277

277278
/* after the focus is set move the caret to the end, necessary when we val()
278279
just before setting focus */
@@ -1454,7 +1455,7 @@ the specific language governing permissions and limitations under the Apache Lic
14541455

14551456
// abstract
14561457
findHighlightableChoices: function() {
1457-
return this.results.find(".select2-result-selectable:not(.select2-disabled, .select2-selected)");
1458+
return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)");
14581459
},
14591460

14601461
// abstract
@@ -2258,21 +2259,29 @@ the specific language governing permissions and limitations under the Apache Lic
22582259

22592260
// single
22602261
postprocessResults: function (data, initial, noHighlightUpdate) {
2261-
var selected = 0, self = this, showSearchInput = true;
2262+
var selected = 0, selectedElm = null, self = this, showSearchInput = true;
22622263

22632264
// find the selected element in the result list
22642265

22652266
this.findHighlightableChoices().each2(function (i, elm) {
22662267
if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
22672268
selected = i;
2269+
selectedElm = elm;
22682270
return false;
22692271
}
22702272
});
22712273

22722274
// and highlight it
22732275
if (noHighlightUpdate !== false) {
22742276
if (initial === true && selected >= 0) {
2275-
this.highlight(selected);
2277+
// By default, the selected item is displayed inside the result list from a single select
2278+
// User can provide an implementation for 'hideSelectionFromResult' and hide it
2279+
if(this.opts.hideSelectionFromResult !== undefined && selectedElm !== null) {
2280+
if(this.opts.hideSelectionFromResult(selectedElm))
2281+
selectedElm.addClass("select2-selected");
2282+
}
2283+
else
2284+
this.highlight(selected);
22762285
} else {
22772286
this.highlight(0);
22782287
}
@@ -2996,9 +3005,14 @@ the specific language governing permissions and limitations under the Apache Lic
29963005
choices.each2(function (i, choice) {
29973006
var id = self.id(choice.data("select2-data"));
29983007
if (indexOf(id, val) >= 0) {
2999-
choice.addClass("select2-selected");
3000-
// mark all children of the selected parent as selected
3001-
choice.find(".select2-result-selectable").addClass("select2-selected");
3008+
// By default, the selected item is hidden from the result list inside a multi select
3009+
// User can provide an implementation for 'hideSelectionFromResult' and allow the same
3010+
// element to be selected multiple times.
3011+
if(self.opts.hideSelectionFromResult === undefined || self.opts.hideSelectionFromResult(choice)) {
3012+
choice.addClass("select2-selected");
3013+
// mark all children of the selected parent as selected
3014+
choice.find(".select2-result-selectable").addClass("select2-selected");
3015+
}
30023016
}
30033017
});
30043018

@@ -3315,7 +3329,11 @@ the specific language governing permissions and limitations under the Apache Lic
33153329
adaptContainerCssClass: function(c) { return c; },
33163330
adaptDropdownCssClass: function(c) { return null; },
33173331
nextSearchTerm: function(selectedObject, currentSearchTerm) { return undefined; },
3332+
<<<<<<< HEAD
33183333
searchInputPlaceholder: ''
3334+
=======
3335+
hideSelectionFromResult: function(selectedObject) { return undefined; }
3336+
>>>>>>> master
33193337
};
33203338

33213339
$.fn.select2.ajaxDefaults = {

0 commit comments

Comments
 (0)