|
702 | 702 |
|
703 | 703 | formatted=opts.formatResult(result, label, query); |
704 | 704 | if (formatted!==undefined) { |
705 | | - label.html(self.escapeMarkup(formatted)); |
| 705 | + label.html(self.opts.escapeMarkup(formatted)); |
706 | 706 | } |
707 | 707 |
|
708 | 708 | node.append(label); |
|
801 | 801 | return opts; |
802 | 802 | }, |
803 | 803 |
|
804 | | - escapeMarkup: function (markup) { |
805 | | - if (this.opts.doEscapeMarkup) { |
806 | | - if (markup && typeof(markup) === "string") { |
807 | | - return markup.replace(/&/g, "&"); |
808 | | - } |
809 | | - } |
810 | | - return markup; |
811 | | - }, |
812 | | - |
813 | 804 | /** |
814 | 805 | * Monitor the original element for changes and update select2 accordingly |
815 | 806 | */ |
|
1181 | 1172 | } |
1182 | 1173 |
|
1183 | 1174 | function render(html) { |
1184 | | - results.html(self.escapeMarkup(html)); |
| 1175 | + results.html(self.opts.escapeMarkup(html)); |
1185 | 1176 | postRender(); |
1186 | 1177 | } |
1187 | 1178 |
|
|
1244 | 1235 | self.opts.populateResults.call(this, results, data.results, {term: search.val(), page: this.resultsPage, context:null}); |
1245 | 1236 |
|
1246 | 1237 | if (data.more === true && checkFormatter(opts.formatLoadMore, "formatLoadMore")) { |
1247 | | - results.append("<li class='select2-more-results'>" + self.escapeMarkup(opts.formatLoadMore(this.resultsPage)) + "</li>"); |
| 1238 | + results.append("<li class='select2-more-results'>" + self.opts.escapeMarkup(opts.formatLoadMore(this.resultsPage)) + "</li>"); |
1248 | 1239 | window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10); |
1249 | 1240 | } |
1250 | 1241 |
|
|
1628 | 1619 | // check for a first blank option if attached to a select |
1629 | 1620 | if (this.select && this.select.find("option:first").text() !== "") return; |
1630 | 1621 |
|
1631 | | - this.selection.find("span").html(this.escapeMarkup(placeholder)); |
| 1622 | + this.selection.find("span").html(this.opts.escapeMarkup(placeholder)); |
1632 | 1623 |
|
1633 | 1624 | this.selection.addClass("select2-default"); |
1634 | 1625 |
|
|
1687 | 1678 | container.empty(); |
1688 | 1679 | formatted=this.opts.formatSelection(data, container); |
1689 | 1680 | if (formatted !== undefined) { |
1690 | | - container.append(this.escapeMarkup(formatted)); |
| 1681 | + container.append(this.opts.escapeMarkup(formatted)); |
1691 | 1682 | } |
1692 | 1683 |
|
1693 | 1684 | this.selection.removeClass("select2-default"); |
|
2064 | 2055 | formatted; |
2065 | 2056 |
|
2066 | 2057 | formatted=this.opts.formatSelection(data, choice); |
2067 | | - choice.find("div").replaceWith("<div>"+this.escapeMarkup(formatted)+"</div>"); |
| 2058 | + choice.find("div").replaceWith("<div>"+this.opts.escapeMarkup(formatted)+"</div>"); |
2068 | 2059 | choice.find(".select2-search-choice-close") |
2069 | 2060 | .bind("mousedown", killEvent) |
2070 | 2061 | .bind("click dblclick", this.bind(function (e) { |
|
2339 | 2330 | closeOnSelect: true, |
2340 | 2331 | openOnEnter: true, |
2341 | 2332 | containerCss: {}, |
2342 | | - doEscapeMarkup: true, |
2343 | 2333 | dropdownCss: {}, |
2344 | 2334 | containerCssClass: "", |
2345 | 2335 | dropdownCssClass: "", |
|
2356 | 2346 | formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; }, |
2357 | 2347 | formatSelectionTooBig: function (limit) { return "You can only select " + limit + " items"; }, |
2358 | 2348 | formatLoadMore: function (pageNumber) { return "Loading more results..."; }, |
2359 | | - formatSearching: function () { return "Searching..."; }, |
| 2349 | + formatSearching: function () { return "Searching..."; }, |
2360 | 2350 | minimumResultsForSearch: 0, |
2361 | 2351 | minimumInputLength: 0, |
2362 | 2352 | maximumSelectionSize: 0, |
|
2366 | 2356 | }, |
2367 | 2357 | separator: ",", |
2368 | 2358 | tokenSeparators: [], |
2369 | | - tokenizer: defaultTokenizer |
| 2359 | + tokenizer: defaultTokenizer, |
| 2360 | + escapeMarkup: function (markup) { |
| 2361 | + if (markup && typeof(markup) === "string") { |
| 2362 | + return markup.replace(/&/g, "&"); |
| 2363 | + } |
| 2364 | + return markup; |
| 2365 | + } |
2370 | 2366 | }; |
2371 | 2367 |
|
2372 | 2368 | // exports |
|
0 commit comments