1
0
mirror of synced 2025-02-04 06:09:23 +03:00

Added support for css class for selected elements

This commit is contained in:
James Ramsay 2013-05-16 15:31:53 +10:00
parent 06440a6bf8
commit 856dc0b526

View File

@ -2087,7 +2087,7 @@ the specific language governing permissions and limitations under the Apache Lic
// single
updateSelection: function (data) {
var container=this.selection.find("span"), formatted;
var container=this.selection.find("span"), formatted, cssClass;
this.selection.data("select2-data", data);
@ -2096,6 +2096,10 @@ the specific language governing permissions and limitations under the Apache Lic
if (formatted !== undefined) {
container.append(this.opts.escapeMarkup(formatted));
}
cssClass=this.opts.formatSelectionCssClass(data, container);
if (cssClass !== undefined) {
container.addClass(cssClass);
}
this.selection.removeClass("select2-default");
@ -2632,12 +2636,17 @@ the specific language governing permissions and limitations under the Apache Lic
var choice = enableChoice ? enabledItem : disabledItem,
id = this.id(data),
val = this.getVal(),
formatted;
formatted,
cssClass;
formatted=this.opts.formatSelection(data, choice.find("div"));
if (formatted != undefined) {
choice.find("div").replaceWith("<div title='"+this.opts.escapeMarkup(formatted)+"'>"+this.opts.escapeMarkup(formatted)+"</div>");
}
cssClass=this.opts.formatSelectionCssClass(data, choice.find("div"));
if (cssClass != undefined) {
choice.addClass(cssClass);
}
if(enableChoice){
choice.find(".select2-search-choice-close")
@ -2988,6 +2997,7 @@ the specific language governing permissions and limitations under the Apache Lic
return results;
},
formatResultCssClass: function(data) {return undefined;},
formatSelectionCssClass: function(data, container) {return undefined;},
formatNoMatches: function () { return "No matches found"; },
formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " more character" + (n == 1? "" : "s"); },
formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1? "" : "s"); },