make escapeMarkup configurable. closes #355
This commit is contained in:
parent
55cc11f9b7
commit
7baa3b9e93
32
select2.js
32
select2.js
@ -702,7 +702,7 @@
|
||||
|
||||
formatted=opts.formatResult(result, label, query);
|
||||
if (formatted!==undefined) {
|
||||
label.html(self.escapeMarkup(formatted));
|
||||
label.html(self.opts.escapeMarkup(formatted));
|
||||
}
|
||||
|
||||
node.append(label);
|
||||
@ -801,15 +801,6 @@
|
||||
return opts;
|
||||
},
|
||||
|
||||
escapeMarkup: function (markup) {
|
||||
if (this.opts.doEscapeMarkup) {
|
||||
if (markup && typeof(markup) === "string") {
|
||||
return markup.replace(/&/g, "&");
|
||||
}
|
||||
}
|
||||
return markup;
|
||||
},
|
||||
|
||||
/**
|
||||
* Monitor the original element for changes and update select2 accordingly
|
||||
*/
|
||||
@ -1181,7 +1172,7 @@
|
||||
}
|
||||
|
||||
function render(html) {
|
||||
results.html(self.escapeMarkup(html));
|
||||
results.html(self.opts.escapeMarkup(html));
|
||||
postRender();
|
||||
}
|
||||
|
||||
@ -1244,7 +1235,7 @@
|
||||
self.opts.populateResults.call(this, results, data.results, {term: search.val(), page: this.resultsPage, context:null});
|
||||
|
||||
if (data.more === true && checkFormatter(opts.formatLoadMore, "formatLoadMore")) {
|
||||
results.append("<li class='select2-more-results'>" + self.escapeMarkup(opts.formatLoadMore(this.resultsPage)) + "</li>");
|
||||
results.append("<li class='select2-more-results'>" + self.opts.escapeMarkup(opts.formatLoadMore(this.resultsPage)) + "</li>");
|
||||
window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10);
|
||||
}
|
||||
|
||||
@ -1628,7 +1619,7 @@
|
||||
// check for a first blank option if attached to a select
|
||||
if (this.select && this.select.find("option:first").text() !== "") return;
|
||||
|
||||
this.selection.find("span").html(this.escapeMarkup(placeholder));
|
||||
this.selection.find("span").html(this.opts.escapeMarkup(placeholder));
|
||||
|
||||
this.selection.addClass("select2-default");
|
||||
|
||||
@ -1687,7 +1678,7 @@
|
||||
container.empty();
|
||||
formatted=this.opts.formatSelection(data, container);
|
||||
if (formatted !== undefined) {
|
||||
container.append(this.escapeMarkup(formatted));
|
||||
container.append(this.opts.escapeMarkup(formatted));
|
||||
}
|
||||
|
||||
this.selection.removeClass("select2-default");
|
||||
@ -2064,7 +2055,7 @@
|
||||
formatted;
|
||||
|
||||
formatted=this.opts.formatSelection(data, choice);
|
||||
choice.find("div").replaceWith("<div>"+this.escapeMarkup(formatted)+"</div>");
|
||||
choice.find("div").replaceWith("<div>"+this.opts.escapeMarkup(formatted)+"</div>");
|
||||
choice.find(".select2-search-choice-close")
|
||||
.bind("mousedown", killEvent)
|
||||
.bind("click dblclick", this.bind(function (e) {
|
||||
@ -2339,7 +2330,6 @@
|
||||
closeOnSelect: true,
|
||||
openOnEnter: true,
|
||||
containerCss: {},
|
||||
doEscapeMarkup: true,
|
||||
dropdownCss: {},
|
||||
containerCssClass: "",
|
||||
dropdownCssClass: "",
|
||||
@ -2356,7 +2346,7 @@
|
||||
formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; },
|
||||
formatSelectionTooBig: function (limit) { return "You can only select " + limit + " items"; },
|
||||
formatLoadMore: function (pageNumber) { return "Loading more results..."; },
|
||||
formatSearching: function () { return "Searching..."; },
|
||||
formatSearching: function () { return "Searching..."; },
|
||||
minimumResultsForSearch: 0,
|
||||
minimumInputLength: 0,
|
||||
maximumSelectionSize: 0,
|
||||
@ -2366,7 +2356,13 @@
|
||||
},
|
||||
separator: ",",
|
||||
tokenSeparators: [],
|
||||
tokenizer: defaultTokenizer
|
||||
tokenizer: defaultTokenizer,
|
||||
escapeMarkup: function (markup) {
|
||||
if (markup && typeof(markup) === "string") {
|
||||
return markup.replace(/&/g, "&");
|
||||
}
|
||||
return markup;
|
||||
}
|
||||
};
|
||||
|
||||
// exports
|
||||
|
Loading…
Reference in New Issue
Block a user