Lines Matching defs:select2

99     MEASURE_SCROLLBAR_TEMPLATE = "<div class='select2-measure-scrollbar'></div>",
335 sizer.attr("class","select2-sizer");
349 if (this.indexOf("select2-") === 0) {
358 if (this.indexOf("select2-") !== 0) {
380 markup.push("<span class='select2-match'>");
430 transport = options.transport || $.fn.select2.ajaxDefaults.transport,
438 params = $.extend({}, $.fn.select2.ajaxDefaults.params, deprecated);
599 * @param opts select2's opts
671 var results, search, resultsSelector = ".select2-results";
679 if (opts.element.data("select2") !== undefined &&
680 opts.element.data("select2") !== null) {
681 opts.element.data("select2").destroy();
690 .addClass("select2-hidden-accessible")
710 .data("select2", this)
713 .on("click.select2", killEvent); // do not leak click events
715 this.container.data("select2", this);
717 this.dropdown = this.container.find(".select2-drop");
722 this.dropdown.data("select2", this);
726 this.search = search = this.container.find("input.select2-input");
747 $(this.container).on("change", ".select2-input", function(e) {e.stopPropagation();});
748 $(this.dropdown).on("change", ".select2-input", function(e) {e.stopPropagation();});
766 search.on("focus", function () { search.addClass("select2-focused"); });
767 search.on("blur", function () { search.removeClass("select2-focused");});
770 if ($(e.target).closest(".select2-result-selectable").length > 0) {
777 // for mouse events outside of itself so it can close itself. since the dropdown is now outside the select2's
779 // focusin can cause focus wars between modals and select2 since the dropdown is outside the modal.
817 var element=this.opts.element, select2 = element.data("select2");
823 if (select2 !== undefined) {
824 select2.container.remove();
825 select2.liveRegion.remove();
826 select2.dropdown.remove();
828 .removeClass("select2-offscreen")
829 .removeData("select2")
830 .off(".select2")
901 node.addClass("select2-results-dept-"+depth);
902 node.addClass("select2-result");
903 node.addClass(selectable ? "select2-result-selectable" : "select2-result-unselectable");
904 if (disabled) { node.addClass("select2-disabled"); }
905 if (compound) { node.addClass("select2-result-with-children"); }
910 label.addClass("select2-result-label");
911 label.attr("id", "select2-result-label-" + nextUid());
924 innerContainer.addClass("select2-result-sub");
929 node.data("select2-data", result);
938 }, $.fn.select2.defaults, opts);
947 throw "tags specified as both an attribute 'data-select2-tags' and in options of Select2 " + opts.element.attr("id");
1040 * Monitor the original element for changes and update select2 accordingly
1046 el.on("change.select2", this.bind(function (e) {
1047 if (this.opts.element.data("select2-change-triggered") !== true) {
1072 el.on("propertychange.select2", sync);
1092 var evt = $.Event("select2-selecting", { val: this.id(data), object: data });
1106 this.opts.element.data("select2-change-triggered", true);
1108 this.opts.element.data("select2-change-triggered", false);
1133 this.container.toggleClass("select2-container-disabled", disabled);
1167 return this.container.hasClass("select2-dropdown-open");
1188 aboveNow = $dropdown.hasClass("select2-drop-above"),
1227 resultsListNode = $('.select2-results', $dropdown)[0];
1228 $dropdown.addClass('select2-drop-auto-width');
1236 this.container.removeClass('select2-drop-auto-width');
1261 this.container.addClass("select2-drop-above");
1262 $dropdown.addClass("select2-drop-above");
1267 this.container.removeClass("select2-drop-above");
1268 $dropdown.removeClass("select2-drop-above");
1283 event = $.Event("select2-opening");
1291 this.container.removeClass("select2-drop-above");
1292 this.dropdown.removeClass("select2-drop-above");
1322 this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
1331 mask = $("#select2-drop-mask");
1334 mask.attr("id","select2-drop-mask").attr("class","select2-drop-mask");
1341 var dropdown = $("#select2-drop"), self;
1343 self=dropdown.data("select2");
1360 $("#select2-drop").removeAttr("id");
1361 this.dropdown.attr("id", "select2-drop");
1370 this.dropdown.addClass("select2-drop-active");
1398 $("#select2-drop-mask").hide();
1399 this.dropdown.removeAttr("id"); // only the active dropdown has the select2-drop id
1401 this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");
1406 this.search.removeClass("select2-active");
1407 this.opts.element.trigger($.Event("select2-close"));
1448 children = this.findHighlightableChoices().find('.select2-result-label');
1454 // if this is the last child lets also make sure select2-more-results is visible
1456 more = results.find("li.select2-more-results");
1476 return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)");
1487 if (choice.hasClass("select2-result-selectable") && !choice.hasClass("select2-disabled") && !choice.hasClass("select2-selected")) {
1501 return indexOf(choices.filter(".select2-highlighted")[0], choices.get());
1510 choice.addClass("select2-highlighted");
1513 this.search.attr("aria-activedescendant", choice.find(".select2-result-label").attr("id"));
1519 data = choice.data("select2-data");
1521 this.opts.element.trigger({ type: "select2-highlight", val: this.id(data), choice: data });
1526 this.results.find(".select2-highlighted").removeClass("select2-highlighted");
1544 var el = $(event.target).closest(".select2-result-selectable");
1545 if (el.length > 0 && !el.is(".select2-highlighted")) {
1557 more = results.find("li.select2-more-results"),
1568 more.addClass("select2-active");
1577 // ignore a response if the select2 has been closed before it was received
1593 this.opts.element.trigger({ type: "select2-loaded", items: data });
1617 lastTerm = $.data(this.container, "select2-last-term"),
1624 $.data(this.container, "select2-last-term", term);
1632 search.removeClass("select2-active");
1634 if (results.find('.select2-no-results,.select2-selection-limit,.select2-searching').length) {
1638 self.liveRegion.text(self.opts.formatMatches(results.find('.select2-result-selectable').length));
1653 render("<li class='select2-selection-limit'>" + evaluate(opts.formatSelectionTooBig, maxSelSize) + "</li>");
1660 render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooShort, search.val(), opts.minimumInputLength) + "</li>");
1670 render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooLong, search.val(), opts.maximumInputLength) + "</li>");
1678 render("<li class='select2-searching'>" + evaluate(opts.formatSearching) + "</li>");
1681 search.addClass("select2-active");
1707 // ignore a response if the select2 has been closed before it was received
1709 this.search.removeClass("select2-active");
1729 render("<li class='select2-no-results'>" + evaluate(opts.formatNoMatches, search.val()) + "</li>");
1737 results.append("<li class='select2-more-results'>" + self.opts.escapeMarkup(evaluate(opts.formatLoadMore, this.resultsPage)) + "</li>");
1745 this.opts.element.trigger({ type: "select2-loaded", items: data });
1761 this.container.removeClass("select2-container-active");
1765 this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
1780 highlighted=this.results.find(".select2-highlighted"),
1781 data = highlighted.closest('.select2-result').data("select2-data");
1818 * derived first from option `width` passed to select2, then
1875 "class": "select2-container"
1877 "<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>",
1878 " <span class='select2-chosen'>&nbsp;</span><abbr class='select2-search-choice-close'></abbr>",
1879 " <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>",
1881 "<label for='' class='select2-offscreen'></label>",
1882 "<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />",
1883 "<div class='select2-drop select2-display-none'>",
1884 " <div class='select2-search'>",
1885 " <label for='' class='select2-offscreen'></label>",
1886 " <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'",
1889 " <ul class='select2-results' role='listbox'>",
1942 this.opts.element.trigger($.Event("select2-open"));
1971 return this.container.hasClass("select2-container-active");
2006 this.selection = selection = container.find(".select2-choice");
2008 this.focusser = container.find(".select2-focusser");
2011 selection.find(".select2-chosen").attr("id", "select2-chosen-"+idSuffix);
2012 this.focusser.attr("aria-labelledby", "select2-chosen-"+idSuffix);
2013 this.results.attr("id", "select2-results-"+idSuffix);
2014 this.search.attr("aria-owns", "select2-results-"+idSuffix);
2132 if (!this.container.hasClass("select2-container-active")) {
2133 this.opts.element.trigger($.Event("select2-focus"));
2152 if (!this.container.hasClass("select2-container-active")) {
2153 this.opts.element.trigger($.Event("select2-focus"));
2155 this.container.addClass("select2-container-active");
2158 this.container.removeClass("select2-container-active");
2159 this.opts.element.trigger($.Event("select2-blur"));
2163 if (!this.container.hasClass("select2-container-active")) {
2164 this.opts.element.trigger($.Event("select2-focus"));
2166 this.container.addClass("select2-container-active");
2170 this.opts.element.addClass("select2-offscreen");
2177 var data=this.selection.data("select2-data");
2179 var evt = $.Event("select2-clearing");
2186 this.selection.find(".select2-chosen").empty();
2187 this.selection.removeData("select2-data");
2191 this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
2286 this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(placeholder));
2288 this.selection.addClass("select2-default");
2290 this.container.removeClass("select2-allowclear");
2301 if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
2332 this.dropdown.find(".select2-search").toggleClass("select2-search-hidden", !showSearchInput);
2333 this.dropdown.find(".select2-search").toggleClass("select2-offscreen", !showSearchInput);
2334 //add "select2-with-searchbox" to the container if search box is shown
2335 $(this.dropdown, this.container).toggleClass("select2-with-searchbox", showSearchInput);
2349 this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data });
2366 var container=this.selection.find(".select2-chosen"), formatted, cssClass;
2368 this.selection.data("select2-data", data);
2382 this.selection.removeClass("select2-default");
2385 this.container.addClass("select2-allowclear");
2452 data = this.selection.data("select2-data");
2478 "class": "select2-container select2-container-multi"
2480 "<ul class='select2-choices'>",
2481 " <li class='select2-search-field'>",
2482 " <label for='' class='select2-offscreen'></label>",
2483 " <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>",
2486 "<div class='select2-drop select2-drop-multi select2-display-none'>",
2487 " <ul class='select2-results'>",
2554 var selected = this.container.find(".select2-search-choice-focus");
2561 selected.removeClass("select2-search-choice-focus");
2564 choice.addClass("select2-search-choice-focus");
2580 var selector = ".select2-choices", selection;
2582 this.searchContainer = this.container.find(".select2-search-field");
2586 this.selection.on("click", ".select2-search-choice:not(.select2-locked)", function (e) {
2613 var selected = selection.find(".select2-search-choice-focus");
2614 var prev = selected.prev(".select2-search-choice:not(.select2-locked)");
2615 var next = selected.next(".select2-search-choice:not(.select2-locked)");
2650 this.selectChoice(selection.find(".select2-search-choice:not(.select2-locked)").last());
2713 this.container.removeClass("select2-container-active");
2714 this.search.removeClass("select2-focused");
2718 this.opts.element.trigger($.Event("select2-blur"));
2723 if ($(e.target).closest(".select2-search-choice").length > 0) {
2724 // clicked inside a select2 search choice, do not open
2729 if (!this.container.hasClass("select2-container-active")) {
2730 this.opts.element.trigger($.Event("select2-focus"));
2739 if (!this.container.hasClass("select2-container-active")) {
2740 this.opts.element.trigger($.Event("select2-focus"));
2742 this.container.addClass("select2-container-active");
2743 this.dropdown.addClass("select2-drop-active");
2748 this.opts.element.addClass("select2-offscreen");
2788 if (placeholder !== undefined && this.getVal().length === 0 && this.search.hasClass("select2-focused") === false) {
2789 this.search.val(placeholder).addClass("select2-default");
2800 if (this.search.hasClass("select2-default")) {
2801 this.search.val("").removeClass("select2-default");
2825 this.opts.element.trigger($.Event("select2-open"));
2842 return this.search.hasClass("select2-focused");
2858 this.selection.find(".select2-search-choice").remove();
2939 "<li class='select2-search-choice'>" +
2941 " <a href='#' class='select2-search-choice-close' tabindex='-1'></a>" +
2944 "<li class='select2-search-choice select2-locked'>" +
2963 choice.find(".select2-search-choice-close")
2969 this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
2975 this.container.addClass("select2-container-active");
2976 this.dropdown.addClass("select2-drop-active");
2980 choice.data("select2-data", data);
2992 selected = selected.closest(".select2-search-choice");
2995 throw "Invalid argument: " + selected + ". Must be .select2-search-choice";
2998 data = selected.data("select2-data");
3006 var evt = $.Event("select2-removing");
3023 this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
3032 choices = this.results.find(".select2-result"),
3033 compound = this.results.find(".select2-result-with-children"),
3037 var id = self.id(choice.data("select2-data"));
3039 choice.addClass("select2-selected");
3041 choice.find(".select2-result-selectable").addClass("select2-selected");
3047 if (!choice.is('.select2-result-selectable')
3048 && choice.find(".select2-result-selectable:not(.select2-selected)").length === 0) {
3049 choice.addClass("select2-selected");
3058 if(!this.opts.createSearchChoice && !choices.filter('.select2-result:not(.select2-selected)').length > 0){
3059 if(!data || data && !data.more && this.results.find(".select2-no-results").length === 0) {
3061 this.results.append("<li class='select2-no-results'>" + evaluate(self.opts.formatNoMatches, self.search.val()) + "</li>");
3225 this.selection.find(".select2-search-choice").each(function() {
3226 val.push(self.opts.id($(this).data("select2-data")));
3237 .children(".select2-search-choice")
3238 .map(function() { return $(this).data("select2-data"); })
3254 $.fn.select2 = function () {
3258 select2,
3277 select2 = multiple ? new window.Select2["class"].multi() : new window.Select2["class"].single();
3278 select2.init(opts);
3286 select2 = $(this).data("select2");
3287 if (select2 === undefined) return;
3292 value = select2.container;
3294 value = select2.dropdown;
3298 value = select2[method].apply(select2, args.slice(1));
3305 throw "Invalid arguments to select2 plugin: " + args;
3312 $.fn.select2.defaults = {
3370 $.fn.select2.ajaxDefaults = {