|
@@ -8,7 +8,7 @@ define([
|
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
- options.multiple = options.multiple || $element.prop("multiple");
|
|
|
+ options.multiple = options.multiple || $element.prop('multiple');
|
|
|
|
|
|
this.options = new Options(options);
|
|
|
|
|
@@ -27,21 +27,22 @@ define([
|
|
|
|
|
|
this.selection = new this.options.selectionAdapter($element, this.options);
|
|
|
|
|
|
- var $selectionContainer = $container.find(".selection");
|
|
|
+ var $selectionContainer = $container.find('.selection');
|
|
|
var $selection = this.selection.render();
|
|
|
|
|
|
$selectionContainer.append($selection);
|
|
|
|
|
|
this.dropdown = new this.options.dropdownAdapter($element, this.options);
|
|
|
|
|
|
- var $dropdownContainer = $container.find(".dropdown");
|
|
|
+ var $dropdownContainer = $container.find('.dropdown');
|
|
|
var $dropdown = this.dropdown.render();
|
|
|
|
|
|
$dropdownContainer.append($dropdown);
|
|
|
|
|
|
- this.results = new this.options.resultsAdapter($element, this.options, this.data);
|
|
|
+ this.results = new this.options.resultsAdapter(
|
|
|
+ $element, this.options, this.data);
|
|
|
|
|
|
- var $resultsContainer = $dropdown.find(".results");
|
|
|
+ var $resultsContainer = $dropdown.find('.results');
|
|
|
var $results = this.results.render();
|
|
|
|
|
|
$resultsContainer.append($results);
|
|
@@ -54,48 +55,48 @@ define([
|
|
|
this.selection.bind(this, $container);
|
|
|
this.results.bind(this, $container);
|
|
|
|
|
|
- this.$element.on("change", function () {
|
|
|
+ this.$element.on('change', function () {
|
|
|
self.data.current(function (data) {
|
|
|
- self.trigger("selection:update", {
|
|
|
+ self.trigger('selection:update', {
|
|
|
data: data
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- this.selection.on("toggle", function () {
|
|
|
+ this.selection.on('toggle', function () {
|
|
|
self.toggleDropdown();
|
|
|
});
|
|
|
|
|
|
- this.results.on("selected", function (params) {
|
|
|
- self.trigger("select", params);
|
|
|
+ this.results.on('selected', function (params) {
|
|
|
+ self.trigger('select', params);
|
|
|
|
|
|
- self.trigger("close");
|
|
|
+ self.trigger('close');
|
|
|
});
|
|
|
|
|
|
- this.results.on("unselected", function (params) {
|
|
|
- self.trigger("unselect", params);
|
|
|
+ this.results.on('unselected', function (params) {
|
|
|
+ self.trigger('unselect', params);
|
|
|
|
|
|
- self.trigger("close");
|
|
|
+ self.trigger('close');
|
|
|
});
|
|
|
|
|
|
- this.on("open", function () {
|
|
|
- $container.addClass("open");
|
|
|
+ this.on('open', function () {
|
|
|
+ $container.addClass('open');
|
|
|
});
|
|
|
|
|
|
- this.on("close", function () {
|
|
|
- $container.removeClass("open");
|
|
|
+ this.on('close', function () {
|
|
|
+ $container.removeClass('open');
|
|
|
});
|
|
|
|
|
|
// Set the initial state
|
|
|
|
|
|
this.data.current(function (initialData) {
|
|
|
- self.trigger("selection:update", {
|
|
|
+ self.trigger('selection:update', {
|
|
|
data: initialData
|
|
|
});
|
|
|
});
|
|
|
|
|
|
this.data.query({}, function (data) {
|
|
|
- self.results.trigger("results:all", data);
|
|
|
+ self.results.trigger('results:all', data);
|
|
|
});
|
|
|
|
|
|
// Hide the original select
|
|
@@ -106,12 +107,12 @@ define([
|
|
|
Utils.Extend(Select2, Utils.Observable);
|
|
|
|
|
|
Select2.prototype.toggleDropdown = function () {
|
|
|
- if (this.$container.hasClass("open")) {
|
|
|
- this.trigger("close");
|
|
|
+ if (this.$container.hasClass('open')) {
|
|
|
+ this.trigger('close');
|
|
|
} else {
|
|
|
- this.trigger("open");
|
|
|
+ this.trigger('open');
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
Select2.prototype.render = function () {
|
|
|
var $container = $(
|