Lines Matching defs:opts

593      * opts.tokenSeparators array and uses opts.createSearchChoice to create the choice object. Both of those
599 * @param opts select2's opts
602 function defaultTokenizer(input, selection, selectCallback, opts) {
610 if (!opts.createSearchChoice || !opts.tokenSeparators || opts.tokenSeparators.length < 1) return undefined;
615 for (i = 0, l = opts.tokenSeparators.length; i < l; i++) {
616 separator = opts.tokenSeparators[i];
627 token = opts.createSearchChoice.call(this, token, selection);
628 if (token !== undefined && token !== null && opts.id(token) !== undefined && opts.id(token) !== null) {
631 if (equal(opts.id(token), opts.id(selection[i]))) {
670 init: function (opts) {
674 this.opts = opts = this.prepareOpts(opts);
676 this.id=opts.id;
679 if (opts.element.data("select2") !== undefined &&
680 opts.element.data("select2") !== null) {
681 opts.element.data("select2").destroy();
693 this.containerId="s2id_"+(opts.element.attr("id") || "autogen"+nextUid()).replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
698 this.body = thunk(function() { return opts.element.closest("body"); });
700 syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
702 this.container.attr("style", opts.element.attr("style"));
703 this.container.css(evaluate(opts.containerCss));
704 this.container.addClass(evaluate(opts.containerCssClass));
706 this.elementTabIndex = this.opts.element.attr("tabindex");
709 this.opts.element
719 syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
721 this.dropdown.addClass(evaluate(opts.dropdownCssClass));
784 if ($.isFunction(this.opts.initSelection)) {
793 if (opts.maximumInputLength !== null) {
794 this.search.attr("maxlength", opts.maximumInputLength);
797 var disabled = opts.element.prop("disabled");
801 var readonly = opts.element.prop("readonly");
808 this.autofocus = opts.element.prop("autofocus");
809 opts.element.prop("autofocus", false);
812 this.search.attr("placeholder", opts.searchInputPlaceholder);
817 var element=this.opts.element, select2 = element.data("select2");
863 prepareOpts: function (opts) {
866 element = opts.element;
869 this.select = select = opts.element;
875 if (this in opts) {
881 opts = $.extend({}, {
883 var populate, id=this.opts.id, liveRegion=this.liveRegion;
889 results = opts.sortResults(results, container, query);
906 node.addClass(self.opts.formatResultCssClass(result));
914 formatted=opts.formatResult(result, label, query, self.opts.escapeMarkup);
933 liveRegion.text(opts.formatMatches(results.length));
938 }, $.fn.select2.defaults, opts);
940 if (typeof(opts.id) !== "function") {
941 idKey = opts.id;
942 opts.id = function (e) { return e[idKey]; };
945 if ($.isArray(opts.element.data("select2Tags"))) {
946 if ("tags" in opts) {
947 throw "tags specified as both an attribute 'data-select2-tags' and in options of Select2 " + opts.element.attr("id");
949 opts.tags=opts.element.data("select2Tags");
953 opts.query = this.bind(function (query) {
988 opts.id=function(e) { return e.id; };
990 if (!("query" in opts)) {
992 if ("ajax" in opts) {
993 ajaxUrl = opts.element.data("ajax-url");
995 opts.ajax.url = ajaxUrl;
997 opts.query = ajax.call(opts.element, opts.ajax);
998 } else if ("data" in opts) {
999 opts.query = local(opts.data);
1000 } else if ("tags" in opts) {
1001 opts.query = tags(opts.tags);
1002 if (opts.createSearchChoice === undefined) {
1003 opts.createSearchChoice = function (term) { return {id: $.trim(term), text: $.trim(term)}; };
1005 if (opts.initSelection === undefined) {
1006 opts.initSelection = function (element, callback) {
1008 $(splitVal(element.val(), opts.separator)).each(function () {
1010 tags = opts.tags;
1022 if (typeof(opts.query) !== "function") {
1023 throw "query function not defined for Select2 " + opts.element.attr("id");
1026 if (opts.createSearchChoicePosition === 'top') {
1027 opts.createSearchChoicePosition = function(list, item) { list.unshift(item); };
1029 else if (opts.createSearchChoicePosition === 'bottom') {
1030 opts.createSearchChoicePosition = function(list, item) { list.push(item); };
1032 else if (typeof(opts.createSearchChoicePosition) !== "function") {
1036 return opts;
1044 var el = this.opts.element, sync, observer;
1047 if (this.opts.element.data("select2-change-triggered") !== true) {
1063 syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
1064 this.container.addClass(evaluate(this.opts.containerCssClass));
1066 syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
1067 this.dropdown.addClass(evaluate(this.opts.dropdownCssClass));
1093 this.opts.element.trigger(evt);
1106 this.opts.element.data("select2-change-triggered", true);
1107 this.opts.element.trigger(details);
1108 this.opts.element.data("select2-change-triggered", false);
1112 this.opts.element.click();
1116 if (this.opts.blurOnChange)
1117 this.opts.element.blur();
1146 this.opts.element.prop("disabled", !enabled);
1161 this.opts.element.prop("readonly", enabled);
1226 if (this.opts.dropdownAutoWidth) {
1270 css = $.extend(css, evaluate(this.opts.dropdownCss));
1284 this.opts.element.trigger(event);
1344 if (self.opts.selectOnBlur) {
1407 this.opts.element.trigger($.Event("select2-close"));
1427 return evaluate(this.opts.maximumSelectionSize);
1521 this.opts.element.trigger({ type: "select2-highlight", val: this.id(data), choice: data });
1567 if (below <= this.opts.loadMorePadding) {
1569 this.opts.query({
1570 element: this.opts.element,
1574 matcher: this.opts.matcher,
1581 self.opts.populateResults.call(this, results, data.results, {term: term, page: page, context:context});
1585 more.detach().appendTo(results).text(evaluate(self.opts.formatLoadMore, page+1));
1593 this.opts.element.trigger({ type: "select2-loaded", items: data });
1612 opts = this.opts,
1638 self.liveRegion.text(self.opts.formatMatches(results.find('.select2-result-selectable').length));
1652 if ($.isArray(data) && data.length >= maxSelSize && checkFormatter(opts.formatSelectionTooBig, "formatSelectionTooBig")) {
1653 render("<li class='select2-selection-limit'>" + evaluate(opts.formatSelectionTooBig, maxSelSize) + "</li>");
1658 if (search.val().length < opts.minimumInputLength) {
1659 if (checkFormatter(opts.formatInputTooShort, "formatInputTooShort")) {
1660 render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooShort, search.val(), opts.minimumInputLength) + "</li>");
1668 if (opts.maximumInputLength && search.val().length > opts.maximumInputLength) {
1669 if (checkFormatter(opts.formatInputTooLong, "formatInputTooLong")) {
1670 render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooLong, search.val(), opts.maximumInputLength) + "</li>");
1677 if (opts.formatSearching && this.findHighlightableChoices().length === 0) {
1678 render("<li class='select2-searching'>" + evaluate(opts.formatSearching) + "</li>");
1693 opts.query({
1694 element: opts.element,
1698 matcher: opts.matcher,
1716 if (this.opts.createSearchChoice && search.val() !== "") {
1717 def = this.opts.createSearchChoice.call(self, search.val(), data.results);
1723 this.opts.createSearchChoicePosition(data.results, def);
1728 if (data.results.length === 0 && checkFormatter(opts.formatNoMatches, "formatNoMatches")) {
1729 render("<li class='select2-no-results'>" + evaluate(opts.formatNoMatches, search.val()) + "</li>");
1734 self.opts.populateResults.call(this, results, data.results, {term: search.val(), page: this.resultsPage, context:null});
1736 if (data.more === true && checkFormatter(opts.formatLoadMore, "formatLoadMore")) {
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 });
1757 if (this.opts.selectOnBlur)
1794 return this.opts.element.attr("placeholder") ||
1795 this.opts.element.attr("data-placeholder") || // jquery 1.4 compat
1796 this.opts.element.data("placeholder") ||
1797 this.opts.placeholder ||
1805 if (this.opts.placeholderOption !== undefined ) {
1807 return (this.opts.placeholderOption === "first" && firstOption) ||
1808 (typeof this.opts.placeholderOption === "function" && this.opts.placeholderOption(this.select));
1827 if (this.opts.width === "off") {
1829 } else if (this.opts.width === "element"){
1830 return this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px';
1831 } else if (this.opts.width === "copy" || this.opts.width === "resolve") {
1833 style = this.opts.element.attr('style');
1844 if (this.opts.width === "resolve") {
1847 style = this.opts.element.css('width');
1851 return (this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px');
1855 } else if ($.isFunction(this.opts.width)) {
1856 return this.opts.width();
1858 return this.opts.width;
1906 if (this.opts.minimumResultsForSearch >= 0) {
1942 this.opts.element.trigger($.Event("select2-open"));
1952 if (this.opts.shouldFocusInput(this)) {
1963 if (this.opts.shouldFocusInput(this)) {
1979 if (this.opts.shouldFocusInput(this)) {
1987 .attr('for', this.opts.element.attr("id"));
2000 if (this.opts.minimumResultsForSearch < 0) {
2019 elementLabel = $("label[for='" + this.opts.element.attr("id") + "']");
2026 var originalTitle = this.opts.element.attr("title");
2027 this.opts.element.attr("title", (originalTitle || elementLabel.text()));
2086 if (this.opts.openOnEnter === false && e.which === KEY.ENTER) {
2092 || (e.which == KEY.ENTER && this.opts.openOnEnter)) {
2102 if (this.opts.allowClear) {
2113 if (this.opts.minimumResultsForSearch >= 0) {
2133 this.opts.element.trigger($.Event("select2-focus"));
2153 this.opts.element.trigger($.Event("select2-focus"));
2159 this.opts.element.trigger($.Event("select2-blur"));
2164 this.opts.element.trigger($.Event("select2-focus"));
2170 this.opts.element.addClass("select2-offscreen");
2180 this.opts.element.trigger(evt);
2185 this.opts.element.val(placeholderOption ? placeholderOption.val() : "");
2191 this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
2209 this.opts.initSelection.call(null, this.opts.element, function(selected){
2214 self.nextSearchTerm = self.opts.nextSearchTerm(selected, self.search.val());
2224 || (this.opts.element.val() === "")
2225 || (this.opts.element.val() === undefined)
2226 || (this.opts.element.val() === null);
2231 var opts = this.parent.prepareOpts.apply(this, arguments),
2234 if (opts.element.get(0).tagName.toLowerCase() === "select") {
2236 opts.initSelection = function (element, callback) {
2241 } else if ("data" in opts) {
2243 opts.initSelection = opts.initSelection || function (element, callback) {
2247 opts.query({
2249 var is_match = equal(id, opts.id(el));
2262 return opts;
2286 this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(placeholder));
2301 if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
2319 var min = this.opts.minimumResultsForSearch;
2343 var old = this.opts.element.val(),
2346 this.opts.element.val(this.id(data));
2349 this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data });
2351 this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
2354 if ((!options || !options.noFocus) && this.opts.shouldFocusInput(this)) {
2372 formatted=this.opts.formatSelection(data, container, this.opts.escapeMarkup);
2377 cssClass=this.opts.formatSelectionCssClass(data, container);
2384 if (this.opts.allowClear && this.getPlaceholder() !== undefined) {
2398 return this.opts.element.val();
2425 if (this.opts.initSelection === undefined) {
2428 this.opts.element.val(val);
2429 this.opts.initSelection(this.opts.element, function(data){
2430 self.opts.element.val(!data ? "" : self.id(data));
2463 this.opts.element.val(!value ? "" : this.id(value));
2495 var opts = this.parent.prepareOpts.apply(this, arguments),
2500 if (opts.element.get(0).tagName.toLowerCase() === "select") {
2502 opts.initSelection = function (element, callback) {
2511 } else if ("data" in opts) {
2513 opts.initSelection = opts.initSelection || function (element, callback) {
2514 var ids = splitVal(element.val(), opts.separator);
2517 opts.query({
2520 return equal(id, opts.id(el));
2535 if (equal(id, opts.id(match))) {
2548 return opts;
2559 this.opts.element.trigger("choice-deselected", selected);
2565 this.opts.element.trigger("choice-selected", choice);
2573 .attr('for', this.opts.element.attr("id"));
2596 .text($("label[for='" + this.opts.element.attr("id") + "']").text())
2685 if (this.opts.openOnEnter === false) {
2718 this.opts.element.trigger($.Event("select2-blur"));
2730 this.opts.element.trigger($.Event("select2-focus"));
2740 this.opts.element.trigger($.Event("select2-focus"));
2748 this.opts.element.addClass("select2-offscreen");
2764 if (this.opts.element.val() === "" && this.opts.element.text() === "") {
2770 if (this.select || this.opts.element.val() !== "") {
2772 this.opts.initSelection.call(null, this.opts.element, function(data){
2825 this.opts.element.trigger($.Event("select2-open"));
2868 input = this.opts.tokenizer.call(this, input, this.data(), this.bind(this.onSelect), this.opts);
2885 this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
2888 this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
2893 if (this.select || !this.opts.closeOnSelect) this.postprocessResults(data, false, this.opts.closeOnSelect===true);
2895 if (this.opts.closeOnSelect) {
2953 formatted=this.opts.formatSelection(data, choice.find("div"), this.opts.escapeMarkup);
2957 cssClass=this.opts.formatSelectionCssClass(data, choice.find("div"));
3009 this.opts.element.trigger(evt);
3023 this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
3058 if(!this.opts.createSearchChoice && !choices.filter('.select2-result:not(.select2-selected)').length > 0){
3060 if (checkFormatter(self.opts.formatNoMatches, "formatNoMatches")) {
3061 this.results.append("<li class='select2-no-results'>" + evaluate(self.opts.formatNoMatches, self.search.val()) + "</li>");
3109 val = this.opts.element.val();
3110 return splitVal(val, this.opts.separator);
3125 this.opts.element.val(unique.length === 0 ? "" : unique.join(this.opts.separator));
3137 if (equal(this.opts.id(current[i]), this.opts.id(old[j]))) {
3165 this.opts.element.val("");
3178 this.opts.initSelection(this.select, this.bind(this.updateSelection));
3183 if (this.opts.initSelection === undefined) {
3187 this.opts.initSelection(this.opts.element, function(data){
3226 val.push(self.opts.id($(this).data("select2-data")));
3243 ids = $.map(values, function(e) { return self.opts.id(e); });
3257 opts,
3267 opts = args.length === 0 ? {} : $.extend({}, args[0]);
3268 opts.element = $(this);
3270 if (opts.element.get(0).tagName.toLowerCase() === "select") {
3271 multiple = opts.element.prop("multiple");
3273 multiple = opts.multiple || false;
3274 if ("tags" in opts) {opts.multiple = multiple = true;}
3278 select2.init(opts);
3362 if (instance.opts.minimumResultsForSearch < 0) {