|
92 | 92 |
|
93 | 93 | nextUid=(function() { var counter=1; return function() { return counter++; }; }()); |
94 | 94 |
|
95 | | - function escapeMarkup(markup) { |
96 | | - if (markup && typeof(markup) === "string") { |
97 | | - return markup.replace(/&/g, "&"); |
98 | | - } else { |
99 | | - return markup; |
100 | | - } |
101 | | - } |
102 | | - |
103 | 95 | function indexOf(value, array) { |
104 | 96 | var i = 0, l = array.length, v; |
105 | 97 |
|
|
710 | 702 |
|
711 | 703 | formatted=opts.formatResult(result, label, query); |
712 | 704 | if (formatted!==undefined) { |
713 | | - label.html(escapeMarkup(formatted)); |
| 705 | + label.html(self.escapeMarkup(formatted)); |
714 | 706 | } |
715 | 707 |
|
716 | 708 | node.append(label); |
|
809 | 801 | return opts; |
810 | 802 | }, |
811 | 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 | + |
812 | 813 | /** |
813 | 814 | * Monitor the original element for changes and update select2 accordingly |
814 | 815 | */ |
|
1180 | 1181 | } |
1181 | 1182 |
|
1182 | 1183 | function render(html) { |
1183 | | - results.html(escapeMarkup(html)); |
| 1184 | + results.html(self.escapeMarkup(html)); |
1184 | 1185 | postRender(); |
1185 | 1186 | } |
1186 | 1187 |
|
|
1243 | 1244 | self.opts.populateResults.call(this, results, data.results, {term: search.val(), page: this.resultsPage, context:null}); |
1244 | 1245 |
|
1245 | 1246 | if (data.more === true && checkFormatter(opts.formatLoadMore, "formatLoadMore")) { |
1246 | | - results.append("<li class='select2-more-results'>" + escapeMarkup(opts.formatLoadMore(this.resultsPage)) + "</li>"); |
| 1247 | + results.append("<li class='select2-more-results'>" + self.escapeMarkup(opts.formatLoadMore(this.resultsPage)) + "</li>"); |
1247 | 1248 | window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10); |
1248 | 1249 | } |
1249 | 1250 |
|
|
1627 | 1628 | // check for a first blank option if attached to a select |
1628 | 1629 | if (this.select && this.select.find("option:first").text() !== "") return; |
1629 | 1630 |
|
1630 | | - this.selection.find("span").html(escapeMarkup(placeholder)); |
| 1631 | + this.selection.find("span").html(this.escapeMarkup(placeholder)); |
1631 | 1632 |
|
1632 | 1633 | this.selection.addClass("select2-default"); |
1633 | 1634 |
|
|
1686 | 1687 | container.empty(); |
1687 | 1688 | formatted=this.opts.formatSelection(data, container); |
1688 | 1689 | if (formatted !== undefined) { |
1689 | | - container.append(escapeMarkup(formatted)); |
| 1690 | + container.append(this.escapeMarkup(formatted)); |
1690 | 1691 | } |
1691 | 1692 |
|
1692 | 1693 | this.selection.removeClass("select2-default"); |
|
2063 | 2064 | formatted; |
2064 | 2065 |
|
2065 | 2066 | formatted=this.opts.formatSelection(data, choice); |
2066 | | - choice.find("div").replaceWith("<div>"+escapeMarkup(formatted)+"</div>"); |
| 2067 | + console.log(" 7 " + this.escapeMarkup); |
| 2068 | + choice.find("div").replaceWith("<div>"+this.escapeMarkup(formatted)+"</div>"); |
2067 | 2069 | choice.find(".select2-search-choice-close") |
2068 | 2070 | .bind("mousedown", killEvent) |
2069 | 2071 | .bind("click dblclick", this.bind(function (e) { |
|
2338 | 2340 | closeOnSelect: true, |
2339 | 2341 | openOnEnter: true, |
2340 | 2342 | containerCss: {}, |
| 2343 | + doEscapeMarkup: true, |
2341 | 2344 | dropdownCss: {}, |
2342 | 2345 | containerCssClass: "", |
2343 | 2346 | dropdownCssClass: "", |
|
2354 | 2357 | formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; }, |
2355 | 2358 | formatSelectionTooBig: function (limit) { return "You can only select " + limit + " items"; }, |
2356 | 2359 | formatLoadMore: function (pageNumber) { return "Loading more results..."; }, |
2357 | | - formatSearching: function () { return "Searching..."; }, |
| 2360 | + formatSearching: function () { return "Searching..."; }, |
2358 | 2361 | minimumResultsForSearch: 0, |
2359 | 2362 | minimumInputLength: 0, |
2360 | 2363 | maximumSelectionSize: 0, |
|
0 commit comments