select2-rails 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/select2-rails/version.rb +1 -1
- data/vendor/assets/javascripts/select2.js +254 -91
- data/vendor/assets/stylesheets/select2.css.sass +224 -153
- metadata +10 -10
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
Copyright 2012 Igor Vaynberg
|
3
|
-
|
3
|
+
|
4
4
|
Version: @@ver@@ Timestamp: @@timestamp@@
|
5
5
|
|
6
6
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in
|
@@ -20,7 +20,7 @@
|
|
20
20
|
return;
|
21
21
|
}
|
22
22
|
|
23
|
-
var KEY, AbstractSelect2, SingleSelect2, MultiSelect2;
|
23
|
+
var KEY, AbstractSelect2, SingleSelect2, MultiSelect2, nextUid;
|
24
24
|
|
25
25
|
KEY = {
|
26
26
|
TAB: 9,
|
@@ -67,10 +67,12 @@
|
|
67
67
|
}
|
68
68
|
};
|
69
69
|
|
70
|
+
nextUid=(function() { var counter=1; return function() { return counter++; }; }());
|
71
|
+
|
70
72
|
function indexOf(value, array) {
|
71
73
|
var i = 0, l = array.length, v;
|
72
74
|
|
73
|
-
if (typeof value
|
75
|
+
if (typeof value === "undefined") {
|
74
76
|
return -1;
|
75
77
|
}
|
76
78
|
|
@@ -90,7 +92,7 @@
|
|
90
92
|
}
|
91
93
|
|
92
94
|
/**
|
93
|
-
* Compares equality of a and b taking into account that a and b may be strings, in which case
|
95
|
+
* Compares equality of a and b taking into account that a and b may be strings, in which case localeCompare is used
|
94
96
|
* @param a
|
95
97
|
* @param b
|
96
98
|
*/
|
@@ -206,7 +208,7 @@
|
|
206
208
|
* @param options object containing configuration paramters
|
207
209
|
* @param options.transport function that will be used to execute the ajax request. must be compatible with parameters supported by $.ajax
|
208
210
|
* @param options.url url for the data
|
209
|
-
* @param options.data a function(searchTerm, pageNumber) that should return an object containing query string parameters for the above url.
|
211
|
+
* @param options.data a function(searchTerm, pageNumber, context) that should return an object containing query string parameters for the above url.
|
210
212
|
* @param options.dataType request data type: ajax, jsonp, other datatatypes supported by jQuery's $.ajax function or the transport function if specified
|
211
213
|
* @param options.quietMillis (optional) milliseconds to wait before making the ajaxRequest, helps debounce the ajax function if invoked too often
|
212
214
|
* @param options.results a function(remoteData, pageNumber) that converts data returned form the remote request to the format expected by Select2.
|
@@ -229,7 +231,7 @@
|
|
229
231
|
data = options.data, // ajax data function
|
230
232
|
transport = options.transport || $.ajax;
|
231
233
|
|
232
|
-
data = data.call(this, query.term, query.page);
|
234
|
+
data = data.call(this, query.term, query.page, query.context);
|
233
235
|
|
234
236
|
if( null !== handler){
|
235
237
|
handler.abort();
|
@@ -243,7 +245,8 @@
|
|
243
245
|
return;
|
244
246
|
}
|
245
247
|
// TODO 3.0 - replace query.page with query so users have access to term, page, etc.
|
246
|
-
|
248
|
+
var results = options.results(data, query.page);
|
249
|
+
query.callback(results);
|
247
250
|
}
|
248
251
|
});
|
249
252
|
}, quietMillis);
|
@@ -266,23 +269,27 @@
|
|
266
269
|
*/
|
267
270
|
function local(options) {
|
268
271
|
var data = options, // data elements
|
272
|
+
dataText,
|
269
273
|
text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
|
270
274
|
|
271
275
|
if (!$.isArray(data)) {
|
272
276
|
text = data.text;
|
273
277
|
// if text is not a function we assume it to be a key name
|
274
|
-
if (!$.isFunction(text))
|
278
|
+
if (!$.isFunction(text)) {
|
279
|
+
dataText = data.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available
|
280
|
+
text = function (item) { return item[dataText]; };
|
281
|
+
}
|
275
282
|
data = data.results;
|
276
283
|
}
|
277
284
|
|
278
285
|
return function (query) {
|
279
|
-
var t = query.term
|
286
|
+
var t = query.term, filtered = {};
|
280
287
|
if (t === "") {
|
281
288
|
query.callback({results: data});
|
282
289
|
return;
|
283
290
|
}
|
284
291
|
filtered.results = $(data)
|
285
|
-
.filter(function () {return text(this)
|
292
|
+
.filter(function () {return query.matcher(t, text(this));})
|
286
293
|
.get();
|
287
294
|
query.callback(filtered);
|
288
295
|
};
|
@@ -299,11 +306,11 @@
|
|
299
306
|
// if not a function we assume it to be an array
|
300
307
|
|
301
308
|
return function (query) {
|
302
|
-
var t = query.term
|
309
|
+
var t = query.term, filtered = {results: []};
|
303
310
|
$(data).each(function () {
|
304
311
|
var isObject = this.text !== undefined,
|
305
312
|
text = isObject ? this.text : this;
|
306
|
-
if (t === "" ||
|
313
|
+
if (t === "" || query.matcher(t, text)) {
|
307
314
|
filtered.results.push(isObject ? this : {id: this, text: this});
|
308
315
|
}
|
309
316
|
});
|
@@ -315,11 +322,18 @@
|
|
315
322
|
* blurs any Select2 container that has focus when an element outside them was clicked or received focus
|
316
323
|
*/
|
317
324
|
$(document).ready(function () {
|
318
|
-
$(document).delegate("*", "mousedown focusin", function (e) {
|
325
|
+
$(document).delegate("*", "mousedown focusin touchend", function (e) {
|
319
326
|
var target = $(e.target).closest("div.select2-container").get(0);
|
320
|
-
|
321
|
-
|
322
|
-
|
327
|
+
if (target) {
|
328
|
+
$(document).find("div.select2-container-active").each(function () {
|
329
|
+
if (this !== target) $(this).data("select2").blur();
|
330
|
+
});
|
331
|
+
} else {
|
332
|
+
target = $(e.target).closest("div.select2-drop").get(0);
|
333
|
+
$(document).find("div.select2-drop-active").each(function () {
|
334
|
+
if (this !== target) $(this).data("select2").blur();
|
335
|
+
});
|
336
|
+
}
|
323
337
|
});
|
324
338
|
});
|
325
339
|
|
@@ -361,6 +375,7 @@
|
|
361
375
|
this.destroy();
|
362
376
|
}
|
363
377
|
|
378
|
+
this.enabled=true;
|
364
379
|
this.container = this.createContainer();
|
365
380
|
|
366
381
|
if (opts.element.attr("class") !== undefined) {
|
@@ -375,19 +390,22 @@
|
|
375
390
|
this.container.data("select2", this);
|
376
391
|
|
377
392
|
this.dropdown = this.container.find(".select2-drop");
|
393
|
+
this.dropdown.data("select2", this);
|
394
|
+
|
378
395
|
this.results = results = this.container.find(resultsSelector);
|
379
396
|
this.search = search = this.container.find("input[type=text]");
|
380
397
|
|
381
398
|
this.resultsPage = 0;
|
399
|
+
this.context = null;
|
382
400
|
|
383
401
|
// initialize the container
|
384
402
|
this.initContainer();
|
385
403
|
|
386
404
|
installFilteredMouseMove(this.results);
|
387
|
-
this.
|
405
|
+
this.dropdown.delegate(resultsSelector, "mousemove-filtered", this.bind(this.highlightUnderEvent));
|
388
406
|
|
389
407
|
installDebouncedScroll(80, this.results);
|
390
|
-
this.
|
408
|
+
this.dropdown.delegate(resultsSelector, "scroll-debounced", this.bind(this.loadMoreIfNeeded));
|
391
409
|
|
392
410
|
// if jquery.mousewheel plugin is installed we can prevent out-of-bounds scrolling of results via mousewheel
|
393
411
|
if ($.fn.mousewheel) {
|
@@ -408,7 +426,7 @@
|
|
408
426
|
search.bind("focus", function () { search.addClass("select2-focused");});
|
409
427
|
search.bind("blur", function () { search.removeClass("select2-focused");});
|
410
428
|
|
411
|
-
this.
|
429
|
+
this.dropdown.delegate(resultsSelector, "click", this.bind(function (e) {
|
412
430
|
if ($(e.target).closest(".select2-result:not(.select2-disabled)").length > 0) {
|
413
431
|
this.highlightUnderEvent(e);
|
414
432
|
this.selectHighlighted(e);
|
@@ -426,12 +444,15 @@
|
|
426
444
|
// we monitor the change event on the element and trigger it, allowing for two way synchronization
|
427
445
|
this.monitorSource();
|
428
446
|
}
|
447
|
+
|
448
|
+
if (opts.element.is(":disabled")) this.disable();
|
429
449
|
},
|
430
450
|
|
431
451
|
destroy: function () {
|
432
452
|
var select2 = this.opts.element.data("select2");
|
433
453
|
if (select2 !== undefined) {
|
434
454
|
select2.container.remove();
|
455
|
+
select2.dropdown.remove();
|
435
456
|
select2.opts.element
|
436
457
|
.removeData("select2")
|
437
458
|
.unbind(".select2")
|
@@ -458,13 +479,74 @@
|
|
458
479
|
}
|
459
480
|
|
460
481
|
opts = $.extend({}, {
|
461
|
-
|
462
|
-
|
482
|
+
populateResults: function(container, results) {
|
483
|
+
var uidToData={}, populate, markup=[], uid, data, result, children;
|
484
|
+
|
485
|
+
populate=function(results, depth) {
|
486
|
+
|
487
|
+
var i, l, uid, result, selectable, compound;
|
488
|
+
for (i = 0, l = results.length; i < l; i = i + 1) {
|
489
|
+
|
490
|
+
result=results[i];
|
491
|
+
selectable=("id" in result); // TODO switch to id() function
|
492
|
+
compound=("children" in result) && result.children.length > 0;
|
493
|
+
|
494
|
+
markup.push("<li class='select2-result-depth-"+depth);
|
495
|
+
if (!selectable) { markup.push(" select2-result-unselectable"); } else { markup.push(" select2-result");}
|
496
|
+
if (compound) { markup.push(" select2-result-with-children"); }
|
497
|
+
|
498
|
+
markup.push("'");
|
499
|
+
|
500
|
+
if (selectable) {
|
501
|
+
uid=nextUid();
|
502
|
+
markup.push(" id='select2-result-"+uid+"'");
|
503
|
+
uidToData[uid]=result;
|
504
|
+
}
|
505
|
+
|
506
|
+
markup.push("><div class='select2-result-label'>"+opts.formatResult(result)+"</div>");
|
507
|
+
|
508
|
+
if (compound) {
|
509
|
+
markup.push("<ul class='select2-result-sub'>");
|
510
|
+
populate(result.children, depth + 1);
|
511
|
+
markup.push("</ul>");
|
512
|
+
}
|
513
|
+
|
514
|
+
markup.push("</li>");
|
515
|
+
}
|
516
|
+
};
|
517
|
+
|
518
|
+
populate(results, 0);
|
519
|
+
|
520
|
+
children=container.children();
|
521
|
+
if (children.length===0) {
|
522
|
+
container.html(markup.join(""));
|
523
|
+
} else {
|
524
|
+
$(children[children.length-1]).append(markup.join(""));
|
525
|
+
}
|
526
|
+
|
527
|
+
for (uid in uidToData) {
|
528
|
+
$("#select2-result-"+uid).data("select2-data", uidToData[uid]);
|
529
|
+
}
|
530
|
+
|
531
|
+
},
|
532
|
+
formatResult: function(result) {
|
533
|
+
return result.text;
|
534
|
+
},
|
535
|
+
formatSelection: function (data) {
|
536
|
+
if (data.fullText) {
|
537
|
+
return data.fullText;
|
538
|
+
} else {
|
539
|
+
return data.text;
|
540
|
+
}
|
541
|
+
},
|
463
542
|
formatNoMatches: function () { return "No matches found"; },
|
464
543
|
formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; },
|
465
544
|
minimumResultsForSearch: 0,
|
466
545
|
minimumInputLength: 0,
|
467
|
-
id: function (e) { return e.id; }
|
546
|
+
id: function (e) { return e.id; },
|
547
|
+
matcher: function(term, text) {
|
548
|
+
return text.toUpperCase().indexOf(term.toUpperCase()) >= 0;
|
549
|
+
}
|
468
550
|
}, opts);
|
469
551
|
|
470
552
|
if (typeof(opts.id) !== "function") {
|
@@ -474,19 +556,27 @@
|
|
474
556
|
|
475
557
|
if (select) {
|
476
558
|
opts.query = this.bind(function (query) {
|
477
|
-
var data = {results: [], more: false},
|
478
|
-
term = query.term
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
559
|
+
var data = { results: [], more: false },
|
560
|
+
term = query.term,
|
561
|
+
process;
|
562
|
+
|
563
|
+
process=function(element, collection) {
|
564
|
+
var group;
|
565
|
+
if (element.is("option")) {
|
566
|
+
if (query.matcher(term, element.text())) {
|
567
|
+
collection.push({id:element.attr("value"), text:element.text()});
|
568
|
+
}
|
569
|
+
} else if (element.is("optgroup")) {
|
570
|
+
group={text:element.attr("label"), children:[]};
|
571
|
+
element.children().each(function() { process($(this), group.children); });
|
572
|
+
if (group.children.length>0) {
|
573
|
+
collection.push(group);
|
574
|
+
}
|
575
|
+
}
|
576
|
+
};
|
483
577
|
|
484
|
-
|
578
|
+
element.children().each(function() { process($(this), data.results); });
|
485
579
|
|
486
|
-
if (text.toUpperCase().indexOf(term) >= 0) {
|
487
|
-
data.results.push({id: e.attr("value"), text: text});
|
488
|
-
}
|
489
|
-
});
|
490
580
|
query.callback(data);
|
491
581
|
});
|
492
582
|
// this is needed because inside val() we construct choices from options and there id is hardcoded
|
@@ -538,14 +628,49 @@
|
|
538
628
|
this.opts.element.data("select2-change-triggered", false);
|
539
629
|
},
|
540
630
|
|
631
|
+
|
632
|
+
enable: function() {
|
633
|
+
if (this.enabled) return;
|
634
|
+
|
635
|
+
this.enabled=true;
|
636
|
+
this.container.removeClass("select2-container-disabled");
|
637
|
+
},
|
638
|
+
|
639
|
+
disable: function() {
|
640
|
+
if (!this.enabled) return;
|
641
|
+
|
642
|
+
this.close();
|
643
|
+
|
644
|
+
this.enabled=false;
|
645
|
+
this.container.addClass("select2-container-disabled");
|
646
|
+
},
|
647
|
+
|
541
648
|
opened: function () {
|
542
649
|
return this.container.hasClass("select2-dropdown-open");
|
543
650
|
},
|
544
651
|
|
652
|
+
positionDropdown: function() {
|
653
|
+
var offset = this.container.offset();
|
654
|
+
var height = this.container.outerHeight();
|
655
|
+
var width = this.container.outerWidth();
|
656
|
+
var css = {
|
657
|
+
top: offset.top + height,
|
658
|
+
left: offset.left,
|
659
|
+
width: width
|
660
|
+
}
|
661
|
+
if (this.opts.dropdownZIndex !== undefined) {
|
662
|
+
css["z-index"] = this.opts.dropdownZIndex;
|
663
|
+
}
|
664
|
+
this.dropdown.css(css);
|
665
|
+
},
|
666
|
+
|
545
667
|
open: function () {
|
546
668
|
if (this.opened()) return;
|
547
669
|
|
548
670
|
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
|
671
|
+
this.dropdown.detach().appendTo('body').addClass("select2-drop-active");
|
672
|
+
|
673
|
+
this.positionDropdown();
|
549
674
|
|
550
675
|
this.updateResults(true);
|
551
676
|
this.dropdown.show();
|
@@ -569,7 +694,7 @@
|
|
569
694
|
ensureHighlightVisible: function () {
|
570
695
|
var results = this.results, children, index, child, hb, rb, y, more;
|
571
696
|
|
572
|
-
children = results.
|
697
|
+
children = results.find(".select2-result");
|
573
698
|
index = this.highlight();
|
574
699
|
|
575
700
|
if (index < 0) return;
|
@@ -599,7 +724,7 @@
|
|
599
724
|
},
|
600
725
|
|
601
726
|
moveHighlight: function (delta) {
|
602
|
-
var choices = this.results.
|
727
|
+
var choices = this.results.find(".select2-result"),
|
603
728
|
index = this.highlight();
|
604
729
|
|
605
730
|
while (index > -1 && index < choices.length) {
|
@@ -612,17 +737,21 @@
|
|
612
737
|
},
|
613
738
|
|
614
739
|
highlight: function (index) {
|
615
|
-
var choices = this.results.
|
740
|
+
var choices = this.results.find(".select2-result .select2-result-label");
|
616
741
|
|
617
742
|
if (arguments.length === 0) {
|
618
743
|
return indexOf(choices.filter(".select2-highlighted")[0], choices.get());
|
619
744
|
}
|
620
745
|
|
621
|
-
choices.removeClass("select2-highlighted");
|
622
|
-
|
623
746
|
if (index >= choices.length) index = choices.length - 1;
|
624
747
|
if (index < 0) index = 0;
|
625
748
|
|
749
|
+
if ($(choices[index]).parent().is('.select2-result-unselectable')) {
|
750
|
+
return;
|
751
|
+
}
|
752
|
+
|
753
|
+
choices.removeClass("select2-highlighted");
|
754
|
+
|
626
755
|
$(choices[index]).addClass("select2-highlighted");
|
627
756
|
this.ensureHighlightVisible();
|
628
757
|
|
@@ -631,8 +760,9 @@
|
|
631
760
|
|
632
761
|
highlightUnderEvent: function (event) {
|
633
762
|
var el = $(event.target).closest(".select2-result");
|
763
|
+
var choices = this.results.find('.select2-result');
|
634
764
|
if (el.length > 0) {
|
635
|
-
this.highlight(
|
765
|
+
this.highlight(choices.index(el));
|
636
766
|
}
|
637
767
|
},
|
638
768
|
|
@@ -641,36 +771,32 @@
|
|
641
771
|
more = results.find("li.select2-more-results"),
|
642
772
|
below, // pixels the element is below the scroll fold, below==0 is when the element is starting to be visible
|
643
773
|
offset = -1, // index of first element without data
|
644
|
-
page = this.resultsPage + 1
|
774
|
+
page = this.resultsPage + 1,
|
775
|
+
self=this;
|
645
776
|
|
646
777
|
if (more.length === 0) return;
|
647
|
-
|
648
778
|
below = more.offset().top - results.offset().top - results.height();
|
649
779
|
|
650
780
|
if (below <= 0) {
|
651
781
|
more.addClass("select2-active");
|
652
|
-
this.opts.query({
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
e.data("select2-data", data.results[i - offset - 1]);
|
666
|
-
}
|
667
|
-
});
|
668
|
-
if (data.more) {
|
782
|
+
this.opts.query({
|
783
|
+
term: this.search.val(),
|
784
|
+
page: page,
|
785
|
+
context: this.context,
|
786
|
+
matcher: this.opts.matcher,
|
787
|
+
callback: this.bind(function (data) {
|
788
|
+
console.log("load more callback", data);
|
789
|
+
|
790
|
+
self.opts.populateResults(results, data.results);
|
791
|
+
|
792
|
+
if (data.more===true) {
|
793
|
+
more.detach();
|
794
|
+
results.children().filter(":last").append(more);
|
669
795
|
more.removeClass("select2-active");
|
670
796
|
} else {
|
671
797
|
more.remove();
|
672
798
|
}
|
673
|
-
|
799
|
+
self.resultsPage = page;
|
674
800
|
})});
|
675
801
|
}
|
676
802
|
},
|
@@ -681,23 +807,39 @@
|
|
681
807
|
updateResults: function (initial) {
|
682
808
|
var search = this.search, results = this.results, opts = this.opts, self=this;
|
683
809
|
|
810
|
+
// if the search is currently hidden we do not alter the results
|
811
|
+
if (initial !== true && this.showSearchInput === false) {
|
812
|
+
return;
|
813
|
+
}
|
814
|
+
|
684
815
|
search.addClass("select2-active");
|
685
816
|
|
686
|
-
function
|
687
|
-
results.html(html);
|
817
|
+
function postRender() {
|
688
818
|
results.scrollTop(0);
|
689
819
|
search.removeClass("select2-active");
|
690
820
|
}
|
691
821
|
|
822
|
+
function render(html) {
|
823
|
+
results.html(html);
|
824
|
+
postRender();
|
825
|
+
}
|
826
|
+
|
692
827
|
if (search.val().length < opts.minimumInputLength) {
|
693
828
|
render("<li class='select2-no-results'>" + opts.formatInputTooShort(search.val(), opts.minimumInputLength) + "</li>");
|
694
829
|
return;
|
695
830
|
}
|
696
831
|
|
697
832
|
this.resultsPage = 1;
|
698
|
-
opts.query({
|
699
|
-
|
700
|
-
|
833
|
+
opts.query({
|
834
|
+
term: search.val(),
|
835
|
+
page: this.resultsPage,
|
836
|
+
context: null,
|
837
|
+
matcher: opts.matcher,
|
838
|
+
callback: this.bind(function (data) {
|
839
|
+
var def; // default choice
|
840
|
+
|
841
|
+
// save context, if any
|
842
|
+
this.context = (data.context===undefined) ? null : data.context;
|
701
843
|
|
702
844
|
// create a default choice and prepend it to the list
|
703
845
|
if (this.opts.createSearchChoice && search.val() !== "") {
|
@@ -717,21 +859,14 @@
|
|
717
859
|
return;
|
718
860
|
}
|
719
861
|
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
parts.push("</li>");
|
724
|
-
});
|
862
|
+
results.empty();
|
863
|
+
self.opts.populateResults(results, data.results);
|
864
|
+
postRender();
|
725
865
|
|
726
866
|
if (data.more === true) {
|
727
|
-
|
867
|
+
results.children().filter(":last").append("<li class='select2-more-results'>Loading more results...</li>");
|
728
868
|
}
|
729
869
|
|
730
|
-
render(parts.join(""));
|
731
|
-
results.children(".select2-result").each(function (i) {
|
732
|
-
var d = data.results[i];
|
733
|
-
$(this).data("select2-data", d);
|
734
|
-
});
|
735
870
|
this.postprocessResults(data, initial);
|
736
871
|
})});
|
737
872
|
},
|
@@ -746,6 +881,7 @@
|
|
746
881
|
window.setTimeout(this.bind(function () {
|
747
882
|
this.close();
|
748
883
|
this.container.removeClass("select2-container-active");
|
884
|
+
this.dropdown.removeClass("select2-drop-active");
|
749
885
|
this.clearSearch();
|
750
886
|
this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
|
751
887
|
this.search.blur();
|
@@ -761,7 +897,7 @@
|
|
761
897
|
},
|
762
898
|
|
763
899
|
selectHighlighted: function () {
|
764
|
-
var data = this.results.find(".select2-highlighted
|
900
|
+
var data = this.results.find(".select2-highlighted").not(".select2-disabled").closest('.select2-result').not('.select2-result-unselectable').data("select2-data");
|
765
901
|
if (data) {
|
766
902
|
this.onSelect(data);
|
767
903
|
}
|
@@ -847,7 +983,11 @@
|
|
847
983
|
|
848
984
|
initContainer: function () {
|
849
985
|
|
850
|
-
var selection,
|
986
|
+
var selection,
|
987
|
+
container = this.container,
|
988
|
+
dropdown = this.dropdown,
|
989
|
+
containers = $([this.container.get(0), this.dropdown.get(0)]),
|
990
|
+
clickingInside = false,
|
851
991
|
selector = ".select2-choice";
|
852
992
|
|
853
993
|
this.selection = selection = container.find(selector);
|
@@ -871,21 +1011,21 @@
|
|
871
1011
|
}
|
872
1012
|
}));
|
873
1013
|
|
874
|
-
|
1014
|
+
containers.delegate(selector, "click", this.bind(function (e) {
|
875
1015
|
clickingInside = true;
|
876
1016
|
|
877
1017
|
if (this.opened()) {
|
878
1018
|
this.close();
|
879
1019
|
selection.focus();
|
880
|
-
} else {
|
1020
|
+
} else if (this.enabled) {
|
881
1021
|
this.open();
|
882
1022
|
}
|
883
1023
|
e.preventDefault();
|
884
1024
|
|
885
1025
|
clickingInside = false;
|
886
1026
|
}));
|
887
|
-
|
888
|
-
if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
|
1027
|
+
containers.delegate(selector, "keydown", this.bind(function (e) {
|
1028
|
+
if (!this.enabled || e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
|
889
1029
|
return;
|
890
1030
|
}
|
891
1031
|
this.open();
|
@@ -898,13 +1038,14 @@
|
|
898
1038
|
killEvent(e);
|
899
1039
|
}
|
900
1040
|
}));
|
901
|
-
|
902
|
-
|
1041
|
+
containers.delegate(selector, "focus", function () { if (this.enabled) { containers.addClass("select2-container-active"); dropdown.addClass("select2-drop-active"); }});
|
1042
|
+
containers.delegate(selector, "blur", this.bind(function () {
|
903
1043
|
if (clickingInside) return;
|
904
1044
|
if (!this.opened()) this.blur();
|
905
1045
|
}));
|
906
1046
|
|
907
1047
|
selection.delegate("abbr", "click", this.bind(function (e) {
|
1048
|
+
if (!this.enabled) return;
|
908
1049
|
this.val("");
|
909
1050
|
killEvent(e);
|
910
1051
|
this.close();
|
@@ -985,8 +1126,8 @@
|
|
985
1126
|
// hide the search box if this is the first we got the results and there are a few of them
|
986
1127
|
|
987
1128
|
if (initial === true) {
|
988
|
-
showSearchInput = data.results.length >= this.opts.minimumResultsForSearch;
|
989
|
-
this.
|
1129
|
+
showSearchInput = this.showSearchInput = data.results.length >= this.opts.minimumResultsForSearch;
|
1130
|
+
this.container.find(".select2-search")[showSearchInput ? "removeClass" : "addClass"]("select2-search-hidden");
|
990
1131
|
|
991
1132
|
//add "select2-with-searchbox" to the container if search box is shown
|
992
1133
|
this.container[showSearchInput ? "addClass" : "removeClass"]("select2-with-searchbox");
|
@@ -1062,7 +1203,7 @@
|
|
1062
1203
|
" <input type='text' autocomplete='off' style='width: 25px;'>" ,
|
1063
1204
|
" </li>" ,
|
1064
1205
|
"</ul>" ,
|
1065
|
-
"<div class='select2-drop' style='display:none;'>" ,
|
1206
|
+
"<div class='select2-drop select2-drop-multi' style='display:none;'>" ,
|
1066
1207
|
" <ul class='select2-results'>" ,
|
1067
1208
|
" </ul>" ,
|
1068
1209
|
"</div>"].join(""));
|
@@ -1099,6 +1240,8 @@
|
|
1099
1240
|
this.selection = selection = this.container.find(selector);
|
1100
1241
|
|
1101
1242
|
this.search.bind("keydown", this.bind(function (e) {
|
1243
|
+
if (!this.enabled) return;
|
1244
|
+
|
1102
1245
|
if (e.which === KEY.BACKSPACE && this.search.val() === "") {
|
1103
1246
|
this.close();
|
1104
1247
|
|
@@ -1153,13 +1296,16 @@
|
|
1153
1296
|
this.search.bind("keyup", this.bind(this.resizeSearch));
|
1154
1297
|
|
1155
1298
|
this.container.delegate(selector, "click", this.bind(function (e) {
|
1299
|
+
if (!this.enabled) return;
|
1156
1300
|
this.open();
|
1157
1301
|
this.focusSearch();
|
1158
1302
|
e.preventDefault();
|
1159
1303
|
}));
|
1160
1304
|
|
1161
1305
|
this.container.delegate(selector, "focus", this.bind(function () {
|
1306
|
+
if (!this.enabled) return;
|
1162
1307
|
this.container.addClass("select2-container-active");
|
1308
|
+
this.dropdown.addClass("select2-drop-active");
|
1163
1309
|
this.clearPlaceholder();
|
1164
1310
|
}));
|
1165
1311
|
|
@@ -1167,6 +1313,22 @@
|
|
1167
1313
|
this.clearSearch();
|
1168
1314
|
},
|
1169
1315
|
|
1316
|
+
enable: function() {
|
1317
|
+
if (this.enabled) return;
|
1318
|
+
|
1319
|
+
this.parent.enable.apply(this, arguments);
|
1320
|
+
|
1321
|
+
this.search.show();
|
1322
|
+
},
|
1323
|
+
|
1324
|
+
disable: function() {
|
1325
|
+
if (!this.enabled) return;
|
1326
|
+
|
1327
|
+
this.parent.disable.apply(this, arguments);
|
1328
|
+
|
1329
|
+
this.search.hide();
|
1330
|
+
},
|
1331
|
+
|
1170
1332
|
initSelection: function () {
|
1171
1333
|
var data;
|
1172
1334
|
if (this.opts.element.val() === "") {
|
@@ -1188,9 +1350,7 @@
|
|
1188
1350
|
clearSearch: function () {
|
1189
1351
|
var placeholder = this.getPlaceholder();
|
1190
1352
|
|
1191
|
-
if (placeholder !== undefined
|
1192
|
-
&& this.getVal().length === 0
|
1193
|
-
&& this.search.hasClass("select2-focused") === false) {
|
1353
|
+
if (placeholder !== undefined && this.getVal().length === 0 && this.search.hasClass("select2-focused") === false) {
|
1194
1354
|
|
1195
1355
|
this.search.val(placeholder).addClass("select2-default");
|
1196
1356
|
// stretch the search box to full width of the container so as much of the placeholder is visible as possible
|
@@ -1285,13 +1445,17 @@
|
|
1285
1445
|
choice = $(parts.join(""));
|
1286
1446
|
choice.find("a")
|
1287
1447
|
.bind("click dblclick", this.bind(function (e) {
|
1448
|
+
if (!this.enabled) return;
|
1449
|
+
|
1288
1450
|
this.unselect($(e.target));
|
1289
1451
|
this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
|
1290
1452
|
killEvent(e);
|
1291
1453
|
this.close();
|
1292
1454
|
this.focusSearch();
|
1293
1455
|
})).bind("focus", this.bind(function () {
|
1456
|
+
if (!this.enabled) return;
|
1294
1457
|
this.container.addClass("select2-container-active");
|
1458
|
+
this.dropdown.addClass("select2-drop-active");
|
1295
1459
|
}));
|
1296
1460
|
|
1297
1461
|
choice.data("select2-data", data);
|
@@ -1413,7 +1577,6 @@
|
|
1413
1577
|
val = (val === null) ? [] : val;
|
1414
1578
|
this.setVal(val);
|
1415
1579
|
// val is a list of objects
|
1416
|
-
|
1417
1580
|
$(val).each(function () { data.push(self.id(this)); });
|
1418
1581
|
this.setVal(data);
|
1419
1582
|
this.updateSelection(val);
|
@@ -1457,7 +1620,7 @@
|
|
1457
1620
|
var args = Array.prototype.slice.call(arguments, 0),
|
1458
1621
|
opts,
|
1459
1622
|
select2,
|
1460
|
-
value, multiple, allowedMethods = ["val", "destroy", "open", "close", "focus", "isFocused", "container", "onSortStart", "onSortEnd"];
|
1623
|
+
value, multiple, allowedMethods = ["val", "destroy", "open", "close", "focus", "isFocused", "container", "onSortStart", "onSortEnd", "enable", "disable", "positionDropdown"];
|
1461
1624
|
|
1462
1625
|
this.each(function () {
|
1463
1626
|
if (args.length === 0 || typeof(args[0]) === "object") {
|
@@ -7,11 +7,11 @@
|
|
7
7
|
/* inline-block for ie7
|
8
8
|
zoom: 1
|
9
9
|
*display: inline
|
10
|
-
/*
|
11
|
-
*Force border-box so that % widths fit the parent
|
12
|
-
*container without overlap because of margin/padding.
|
13
|
-
*
|
14
|
-
*More Info : http://www.quirksmode.org/css/box.html
|
10
|
+
/*
|
11
|
+
* Force border-box so that % widths fit the parent
|
12
|
+
* container without overlap because of margin/padding.
|
13
|
+
*
|
14
|
+
* More Info : http://www.quirksmode.org/css/box.html
|
15
15
|
-moz-box-sizing: border-box
|
16
16
|
/* firefox
|
17
17
|
-ms-box-sizing: border-box
|
@@ -23,12 +23,12 @@
|
|
23
23
|
box-sizing: border-box
|
24
24
|
/* css3
|
25
25
|
|
26
|
-
.select2-drop
|
27
|
-
/*
|
28
|
-
*Force border-box so that % widths fit the parent
|
29
|
-
*container without overlap because of margin/padding.
|
30
|
-
*
|
31
|
-
*More Info : http://www.quirksmode.org/css/box.html
|
26
|
+
.select2-drop
|
27
|
+
/*
|
28
|
+
* Force border-box so that % widths fit the parent
|
29
|
+
* container without overlap because of margin/padding.
|
30
|
+
*
|
31
|
+
* More Info : http://www.quirksmode.org/css/box.html
|
32
32
|
-moz-box-sizing: border-box
|
33
33
|
/* firefox
|
34
34
|
-ms-box-sizing: border-box
|
@@ -40,13 +40,28 @@
|
|
40
40
|
box-sizing: border-box
|
41
41
|
/* css3
|
42
42
|
|
43
|
-
.select2-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
.select2-search
|
44
|
+
/*
|
45
|
+
* Force border-box so that % widths fit the parent
|
46
|
+
* container without overlap because of margin/padding.
|
47
|
+
*
|
48
|
+
* More Info : http://www.quirksmode.org/css/box.html
|
49
|
+
-moz-box-sizing: border-box
|
50
|
+
/* firefox
|
51
|
+
-ms-box-sizing: border-box
|
52
|
+
/* ie
|
53
|
+
-webkit-box-sizing: border-box
|
54
|
+
/* webkit
|
55
|
+
-khtml-box-sizing: border-box
|
56
|
+
/* konqueror
|
57
|
+
box-sizing: border-box
|
58
|
+
/* css3
|
59
|
+
input
|
60
|
+
/*
|
61
|
+
* Force border-box so that % widths fit the parent
|
62
|
+
* container without overlap because of margin/padding.
|
63
|
+
*
|
64
|
+
* More Info : http://www.quirksmode.org/css/box.html
|
50
65
|
-moz-box-sizing: border-box
|
51
66
|
/* firefox
|
52
67
|
-ms-box-sizing: border-box
|
@@ -57,138 +72,148 @@
|
|
57
72
|
/* konqueror
|
58
73
|
box-sizing: border-box
|
59
74
|
/* css3
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
75
|
+
|
76
|
+
.select2-container .select2-choice
|
77
|
+
background-color: #fff
|
78
|
+
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.5, white))
|
79
|
+
background-image: -webkit-linear-gradient(center bottom, #eeeeee 0%, white 50%)
|
80
|
+
background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, white 50%)
|
81
|
+
background-image: -o-linear-gradient(bottom, #eeeeee 0%, white 50%)
|
82
|
+
background-image: -ms-linear-gradient(top, #eeeeee 0%, white 50%)
|
83
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#ffffff', GradientType = 0)
|
84
|
+
background-image: linear-gradient(top, #eeeeee 0%, white 50%)
|
85
|
+
-webkit-border-radius: 4px
|
86
|
+
-moz-border-radius: 4px
|
87
|
+
border-radius: 4px
|
88
|
+
-moz-background-clip: padding
|
89
|
+
-webkit-background-clip: padding-box
|
90
|
+
background-clip: padding-box
|
91
|
+
border: 1px solid #aaa
|
92
|
+
display: block
|
93
|
+
overflow: hidden
|
94
|
+
white-space: nowrap
|
95
|
+
position: relative
|
96
|
+
height: 26px
|
97
|
+
line-height: 26px
|
98
|
+
padding: 0 0 0 8px
|
99
|
+
color: #444
|
100
|
+
text-decoration: none
|
101
|
+
span
|
102
|
+
margin-right: 26px
|
76
103
|
display: block
|
77
104
|
overflow: hidden
|
78
105
|
white-space: nowrap
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
106
|
+
-o-text-overflow: ellipsis
|
107
|
+
-ms-text-overflow: ellipsis
|
108
|
+
text-overflow: ellipsis
|
109
|
+
abbr
|
110
|
+
display: block
|
111
|
+
position: absolute
|
112
|
+
right: 26px
|
113
|
+
top: 8px
|
114
|
+
width: 12px
|
115
|
+
height: 12px
|
116
|
+
font-size: 1px
|
117
|
+
background: image-url('select2.png') right top no-repeat
|
118
|
+
cursor: pointer
|
84
119
|
text-decoration: none
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
white-space: nowrap
|
90
|
-
-o-text-overflow: ellipsis
|
91
|
-
-ms-text-overflow: ellipsis
|
92
|
-
text-overflow: ellipsis
|
93
|
-
abbr
|
94
|
-
display: block
|
95
|
-
position: absolute
|
96
|
-
right: 26px
|
97
|
-
top: 8px
|
98
|
-
width: 12px
|
99
|
-
height: 12px
|
100
|
-
font-size: 1px
|
101
|
-
background: image-url('select2.png') right top no-repeat
|
120
|
+
border: 0
|
121
|
+
outline: 0
|
122
|
+
&:hover
|
123
|
+
background-position: right -11px
|
102
124
|
cursor: pointer
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
125
|
+
|
126
|
+
.select2-drop
|
127
|
+
background: #fff
|
128
|
+
border: 1px solid #aaa
|
129
|
+
border-top: 0
|
130
|
+
position: absolute
|
131
|
+
top: 100%
|
132
|
+
-webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15)
|
133
|
+
-moz-box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15)
|
134
|
+
-o-box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15)
|
135
|
+
box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15)
|
136
|
+
z-index: 999
|
137
|
+
width: 100%
|
138
|
+
margin-top: -1px
|
139
|
+
-webkit-border-radius: 0 0 4px 4px
|
140
|
+
-moz-border-radius: 0 0 4px 4px
|
141
|
+
border-radius: 0 0 4px 4px
|
142
|
+
|
143
|
+
.select2-container div
|
144
|
+
-webkit-border-radius: 0 4px 4px 0
|
145
|
+
-moz-border-radius: 0 4px 4px 0
|
146
|
+
border-radius: 0 4px 4px 0
|
147
|
+
-moz-background-clip: padding
|
148
|
+
-webkit-background-clip: padding-box
|
149
|
+
background-clip: padding-box
|
150
|
+
background: #ccc
|
151
|
+
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #cccccc), color-stop(0.6, #eeeeee))
|
152
|
+
background-image: -webkit-linear-gradient(center bottom, #cccccc 0%, #eeeeee 60%)
|
153
|
+
background-image: -moz-linear-gradient(center bottom, #cccccc 0%, #eeeeee 60%)
|
154
|
+
background-image: -o-linear-gradient(bottom, #cccccc 0%, #eeeeee 60%)
|
155
|
+
background-image: -ms-linear-gradient(top, #cccccc 0%, #eeeeee 60%)
|
156
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#cccccc', endColorstr = '#eeeeee', GradientType = 0)
|
157
|
+
background-image: linear-gradient(top, #cccccc 0%, #eeeeee 60%)
|
158
|
+
border-left: 1px solid #aaa
|
159
|
+
position: absolute
|
160
|
+
right: 0
|
161
|
+
top: 0
|
162
|
+
display: block
|
163
|
+
height: 100%
|
164
|
+
width: 18px
|
165
|
+
b
|
166
|
+
background: image-url('select2.png') no-repeat 0 1px
|
144
167
|
display: block
|
145
|
-
height: 100%
|
146
|
-
width: 18px
|
147
|
-
b
|
148
|
-
background: image-url('select2.png') no-repeat 0 1px
|
149
|
-
display: block
|
150
|
-
width: 100%
|
151
|
-
height: 100%
|
152
|
-
.select2-search
|
153
|
-
display: inline-block
|
154
|
-
white-space: nowrap
|
155
|
-
z-index: 1010
|
156
|
-
min-height: 26px
|
157
168
|
width: 100%
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
169
|
+
height: 100%
|
170
|
+
|
171
|
+
.select2-search
|
172
|
+
display: inline-block
|
173
|
+
white-space: nowrap
|
174
|
+
z-index: 1010
|
175
|
+
min-height: 26px
|
176
|
+
width: 100%
|
177
|
+
margin: 0
|
178
|
+
padding-left: 4px
|
179
|
+
padding-right: 4px
|
180
|
+
|
181
|
+
.select2-search-hidden
|
182
|
+
display: block
|
183
|
+
position: absolute
|
184
|
+
left: -10000px
|
185
|
+
|
186
|
+
.select2-search input
|
187
|
+
background: white image-url('select2.png') no-repeat 100% -22px
|
188
|
+
background: image-url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee))
|
189
|
+
background: image-url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%)
|
190
|
+
background: image-url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%)
|
191
|
+
background: image-url('select2.png') no-repeat 100% -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%)
|
192
|
+
background: image-url('select2.png') no-repeat 100% -22px, -ms-linear-gradient(top, white 85%, #eeeeee 99%)
|
193
|
+
background: image-url('select2.png') no-repeat 100% -22px, linear-gradient(top, white 85%, #eeeeee 99%)
|
194
|
+
padding: 4px 20px 4px 5px
|
195
|
+
outline: 0
|
196
|
+
border: 1px solid #aaa
|
197
|
+
font-family: sans-serif
|
198
|
+
font-size: 1em
|
199
|
+
width: 100%
|
200
|
+
margin: 0
|
201
|
+
height: auto !important
|
202
|
+
min-height: 26px
|
203
|
+
-webkit-box-shadow: none
|
204
|
+
-moz-box-shadow: none
|
205
|
+
box-shadow: none
|
206
|
+
border-radius: 0
|
207
|
+
-moz-border-radius: 0
|
208
|
+
-webkit-border-radius: 0
|
209
|
+
&.select2-active
|
210
|
+
background: white image-url('spinner.gif') no-repeat 100%
|
211
|
+
background: image-url('spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee))
|
212
|
+
background: image-url('spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%)
|
213
|
+
background: image-url('spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%)
|
214
|
+
background: image-url('spinner.gif') no-repeat 100%, -o-linear-gradient(bottom, white 85%, #eeeeee 99%)
|
215
|
+
background: image-url('spinner.gif') no-repeat 100%, -ms-linear-gradient(top, white 85%, #eeeeee 99%)
|
216
|
+
background: image-url('spinner.gif') no-repeat 100%, linear-gradient(top, white 85%, #eeeeee 99%)
|
192
217
|
|
193
218
|
.select2-container-active
|
194
219
|
.select2-choice, .select2-choices
|
@@ -228,20 +253,44 @@
|
|
228
253
|
|
229
254
|
/* results
|
230
255
|
|
231
|
-
.select2-
|
256
|
+
.select2-results
|
232
257
|
margin: 4px 4px 4px 0
|
233
258
|
padding: 0 0 0 4px
|
234
259
|
position: relative
|
235
260
|
overflow-x: hidden
|
236
261
|
overflow-y: auto
|
237
262
|
max-height: 200px
|
263
|
+
ul.select2-result-sub
|
264
|
+
margin: 0 0 0 0
|
265
|
+
> .select2-result-label
|
266
|
+
padding-left: 20px
|
267
|
+
ul.select2-result-sub
|
268
|
+
> .select2-result-label
|
269
|
+
padding-left: 40px
|
270
|
+
ul.select2-result-sub
|
271
|
+
> .select2-result-label
|
272
|
+
padding-left: 60px
|
273
|
+
ul.select2-result-sub
|
274
|
+
> .select2-result-label
|
275
|
+
padding-left: 80px
|
276
|
+
ul.select2-result-sub
|
277
|
+
> .select2-result-label
|
278
|
+
padding-left: 100px
|
279
|
+
ul.select2-result-sub
|
280
|
+
> .select2-result-label
|
281
|
+
padding-left: 110px
|
282
|
+
ul.select2-result-sub .select2-result-label
|
283
|
+
padding-left: 120px
|
238
284
|
li
|
285
|
+
list-style: none
|
286
|
+
display: list-item
|
287
|
+
&.select2-result-with-children .select2-result-label
|
288
|
+
font-weight: bold
|
289
|
+
.select2-result-label
|
239
290
|
line-height: 80%
|
240
291
|
padding: 7px 7px 8px
|
241
292
|
margin: 0
|
242
|
-
list-style: none
|
243
293
|
cursor: pointer
|
244
|
-
display: list-item
|
245
294
|
.select2-highlighted
|
246
295
|
background: #3875d7
|
247
296
|
color: #fff
|
@@ -258,13 +307,13 @@
|
|
258
307
|
|
259
308
|
/*
|
260
309
|
*disabled look for already selected choices in the results dropdown
|
261
|
-
*.select2-
|
310
|
+
*.select2-results .select2-disabled.select2-highlighted {
|
262
311
|
* color: #666;
|
263
312
|
* background: #f4f4f4;
|
264
313
|
* display: list-item;
|
265
314
|
* cursor: default;
|
266
315
|
*}
|
267
|
-
*.select2-
|
316
|
+
*.select2-results .select2-disabled {
|
268
317
|
* background: #f4f4f4;
|
269
318
|
* display: list-item;
|
270
319
|
* cursor: default;
|
@@ -276,6 +325,18 @@
|
|
276
325
|
background: #f4f4f4
|
277
326
|
display: list-item
|
278
327
|
|
328
|
+
/* disabled styles
|
329
|
+
|
330
|
+
.select2-container.select2-container-disabled .select2-choice
|
331
|
+
background-color: #f4f4f4
|
332
|
+
background-image: none
|
333
|
+
border: 1px solid #ddd
|
334
|
+
cursor: default
|
335
|
+
div
|
336
|
+
background-color: #f4f4f4
|
337
|
+
background-image: none
|
338
|
+
border-left: 0
|
339
|
+
|
279
340
|
/* multiselect
|
280
341
|
|
281
342
|
.select2-container-multi
|
@@ -295,8 +356,7 @@
|
|
295
356
|
height: auto !important
|
296
357
|
height: 1%
|
297
358
|
position: relative
|
298
|
-
|
299
|
-
margin-top: 0
|
359
|
+
min-height: 26px
|
300
360
|
&.select2-container-active .select2-choices
|
301
361
|
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3)
|
302
362
|
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3)
|
@@ -378,8 +438,19 @@
|
|
378
438
|
.select2-choices
|
379
439
|
.select2-search-choice .select2-search-choice-close:hover, .select2-search-choice-focus .select2-search-choice-close
|
380
440
|
background-position: right -11px
|
381
|
-
.select2-
|
382
|
-
|
383
|
-
|
441
|
+
&.select2-container-disabled .select2-choices
|
442
|
+
background-color: #f4f4f4
|
443
|
+
background-image: none
|
444
|
+
border: 1px solid #ddd
|
445
|
+
cursor: default
|
446
|
+
.select2-search-choice
|
447
|
+
background-image: none
|
448
|
+
background-color: #f4f4f4
|
449
|
+
border: 1px solid #ddd
|
450
|
+
padding: 3px 5px 3px 5px
|
451
|
+
.select2-search-choice-close
|
452
|
+
display: none
|
453
|
+
|
454
|
+
/* disabled styles
|
384
455
|
|
385
456
|
/* end multiselect
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: select2-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &87475570 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.14'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *87475570
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &87475320 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *87475320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &87475090 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *87475090
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sass
|
49
|
-
requirement: &
|
49
|
+
requirement: &87474860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '3.1'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *87474860
|
58
58
|
description: Select2 is a jQuery based replacement for select boxes. It supports searching,
|
59
59
|
remote data sets, and infinite scrolling of results. This gem integrates Select2
|
60
60
|
with Rails asset pipeline for easy of use.
|