1
0
mirror of synced 2024-11-29 16:16:02 +03:00

Fix undefined variable, rebuild dist

This commit is contained in:
Kevin Brown 2014-09-21 16:43:44 -04:00
parent f0b819336a
commit 26986cacb6
5 changed files with 547 additions and 547 deletions

View File

@ -2,7 +2,7 @@ define('select2/utils',[], function () {
var Utils = {}; var Utils = {};
Utils.Extend = function (ChildClass, SuperClass) { Utils.Extend = function (ChildClass, SuperClass) {
var __hasProp = {}.hasOwnProperty var __hasProp = {}.hasOwnProperty;
function BaseConstructor () { function BaseConstructor () {
this.constructor = ChildClass; this.constructor = ChildClass;
@ -29,7 +29,7 @@ define('select2/utils',[], function () {
for (var methodName in proto) { for (var methodName in proto) {
var m = proto[methodName]; var m = proto[methodName];
if (typeof m !== "function") { if (typeof m !== 'function') {
continue; continue;
} }
@ -68,15 +68,13 @@ define('select2/utils',[], function () {
DecoratedClass.prototype = new ctr(); DecoratedClass.prototype = new ctr();
for (var m = 0; m < superMethods.length; m++) { for (var m = 0; m < superMethods.length; m++) {
var methodName = superMethods[m]; var superMethod = superMethods[m];
DecoratedClass.prototype[methodName] = SuperClass.prototype[methodName]; DecoratedClass.prototype[superMethod] =
SuperClass.prototype[superMethod];
} }
for (var m = 0; m < decoratedMethods.length; m++) { var calledMethod = function (methodName) {
var methodName = decoratedMethods[m];
function calledMethod (methodName) {
// Stub out the original method if it's not decorating an actual method // Stub out the original method if it's not decorating an actual method
var originalMethod = function () {}; var originalMethod = function () {};
@ -92,14 +90,17 @@ define('select2/utils',[], function () {
unshift.call(arguments, originalMethod); unshift.call(arguments, originalMethod);
return decoratedMethod.apply(this, arguments); return decoratedMethod.apply(this, arguments);
} };
} };
DecoratedClass.prototype[methodName] = calledMethod(methodName); for (var d = 0; d < decoratedMethods.length; d++) {
var decoratedMethod = decoratedMethods[d];
DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
} }
return DecoratedClass; return DecoratedClass;
} };
var Observable = function () { var Observable = function () {
this.listeners = {}; this.listeners = {};
@ -120,8 +121,8 @@ define('select2/utils',[], function () {
this.invoke(this.listeners[event], slice.call(arguments, 1)); this.invoke(this.listeners[event], slice.call(arguments, 1));
} }
if ("*" in this.listeners) { if ('*' in this.listeners) {
this.invoke(this.listeners["*"], arguments); this.invoke(this.listeners['*'], arguments);
} }
}; };
@ -146,12 +147,12 @@ define('select2/data/base',[
Utils.Extend(BaseAdapter, Utils.Observable); Utils.Extend(BaseAdapter, Utils.Observable);
BaseAdapter.prototype.current = function (callback) { BaseAdapter.prototype.current = function (callback) {
throw new Error("The `current` method must be defined in child classes."); throw new Error('The `current` method must be defined in child classes.');
} };
BaseAdapter.prototype.query = function (params, callback) { BaseAdapter.prototype.query = function (params, callback) {
throw new Error("The `query` method must be defined in child classes."); throw new Error('The `query` method must be defined in child classes.');
} };
return BaseAdapter; return BaseAdapter;
}); });
@ -173,7 +174,7 @@ define('select2/data/select',[
var data = []; var data = [];
var self = this; var self = this;
this.$element.find(":selected").each(function () { this.$element.find(':selected').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -187,7 +188,7 @@ define('select2/data/select',[
SelectAdapter.prototype.select = function (data) { SelectAdapter.prototype.select = function (data) {
var self = this; var self = this;
if (this.$element.prop("multiple")) { if (this.$element.prop('multiple')) {
this.current(function (currentData) { this.current(function (currentData) {
var val = []; var val = [];
@ -203,20 +204,20 @@ define('select2/data/select',[
} }
self.$element.val(val); self.$element.val(val);
self.$element.trigger("change"); self.$element.trigger('change');
}); });
} else { } else {
var val = data.id; var val = data.id;
this.$element.val(val); this.$element.val(val);
this.$element.trigger("change"); this.$element.trigger('change');
} }
}; };
SelectAdapter.prototype.unselect = function (data) { SelectAdapter.prototype.unselect = function (data) {
var self = this; var self = this;
if (!this.$element.prop("multiple")) { if (!this.$element.prop('multiple')) {
return; return;
} }
@ -232,27 +233,27 @@ define('select2/data/select',[
} }
self.$element.val(val); self.$element.val(val);
self.$element.trigger("change"); self.$element.trigger('change');
}); });
} };
SelectAdapter.prototype.bind = function (container, $container) { SelectAdapter.prototype.bind = function (container, $container) {
var self = this; var self = this;
container.on("select", function (params) { container.on('select', function (params) {
self.select(params.data); self.select(params.data);
}); });
container.on("unselect", function (params) { container.on('unselect', function (params) {
self.unselect(params.data); self.unselect(params.data);
}); });
} };
SelectAdapter.prototype.query = function (params, callback) { SelectAdapter.prototype.query = function (params, callback) {
var data = []; var data = [];
var self = this; var self = this;
this.$element.find("option").each(function () { this.$element.find('option').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -266,7 +267,7 @@ define('select2/data/select',[
}; };
SelectAdapter.prototype.item = function ($option) { SelectAdapter.prototype.item = function ($option) {
var data = $option.data("data"); var data = $option.data('data');
// If the data has already be generated, use it // If the data has already be generated, use it
if (data == null) { if (data == null) {
@ -275,14 +276,14 @@ define('select2/data/select',[
text: $option.html() text: $option.html()
}; };
$option.data("data", data); $option.data('data', data);
} }
return data; return data;
}; };
SelectAdapter.prototype.matches = function (params, data) { SelectAdapter.prototype.matches = function (params, data) {
if ($.trim(params.term) == "") { if ($.trim(params.term) === '') {
return true; return true;
} }
@ -291,7 +292,7 @@ define('select2/data/select',[
} }
return false; return false;
} };
return SelectAdapter; return SelectAdapter;
}); });
@ -342,16 +343,16 @@ define('select2/results',[
this.data.current(function (selected) { this.data.current(function (selected) {
selected = $.map(selected, function (s) { return s.id; }); selected = $.map(selected, function (s) { return s.id; });
self.$results.find(".option.selected").removeClass("selected"); self.$results.find('.option.selected').removeClass('selected');
var $options = self.$results.find(".option"); var $options = self.$results.find('.option');
$options.each(function () { $options.each(function () {
var $option = $(this); var $option = $(this);
var item = $option.data("data"); var item = $option.data('data');
if (selected.indexOf(item.id) > -1) { if (selected.indexOf(item.id) > -1) {
$option.addClass("selected"); $option.addClass('selected');
} }
}); });
}); });
@ -363,43 +364,43 @@ define('select2/results',[
); );
$option.html(data.text); $option.html(data.text);
$option.data("data", data); $option.data('data', data);
return $option; return $option;
} };
Results.prototype.bind = function (container, $container) { Results.prototype.bind = function (container, $container) {
var self = this; var self = this;
this.on("results:all", function (data) { this.on('results:all', function (data) {
self.clear(); self.clear();
self.append(data); self.append(data);
self.setClasses(); self.setClasses();
}); });
this.on("results:append", function (data) { this.on('results:append', function (data) {
self.append(data); self.append(data);
self.setClasses(); self.setClasses();
}) });
this.$results.on("mouseup", ".option", function (evt) { this.$results.on('mouseup', '.option', function (evt) {
var $this = $(this); var $this = $(this);
var data = $this.data("data"); var data = $this.data('data');
if ($this.hasClass("selected")) { if ($this.hasClass('selected')) {
self.trigger("unselected", { self.trigger('unselected', {
originalEvent: evt, originalEvent: evt,
data: data data: data
}) });
self.setClasses(); self.setClasses();
return; return;
} }
self.trigger("selected", { self.trigger('selected', {
originalEvent: evt, originalEvent: evt,
data: data data: data
}); });
@ -407,19 +408,19 @@ define('select2/results',[
self.setClasses(); self.setClasses();
}); });
this.$results.on("mouseenter", ".option", function (evt) { this.$results.on('mouseenter', '.option', function (evt) {
self.$results.find(".option.highlighted").removeClass("highlighted"); self.$results.find('.option.highlighted').removeClass('highlighted');
$(this).addClass("highlighted"); $(this).addClass('highlighted');
}); });
this.$results.on("mouseleave", ".option", function (evt) { this.$results.on('mouseleave', '.option', function (evt) {
$(this).removeClass("highlighted"); $(this).removeClass('highlighted');
}); });
}; };
return Results; return Results;
}) });
;
define('select2/dropdown',[ define('select2/dropdown',[
'./utils' './utils'
], function (Utils) { ], function (Utils) {
@ -437,11 +438,11 @@ define('select2/dropdown',[
); );
return $dropdown; return $dropdown;
} };
return Dropdown; return Dropdown;
}) });
;
define('select2/selection/single',[ define('select2/selection/single',[
'../utils' '../utils'
], function (Utils) { ], function (Utils) {
@ -464,7 +465,7 @@ define('select2/selection/single',[
this.$selection = $selection; this.$selection = $selection;
return $selection; return $selection;
} };
SingleSelection.prototype.bind = function (container, $container) { SingleSelection.prototype.bind = function (container, $container) {
var self = this; var self = this;
@ -475,26 +476,26 @@ define('select2/selection/single',[
return; return;
} }
self.trigger("toggle", { self.trigger('toggle', {
originalEvent: evt originalEvent: evt
}); });
}); });
container.on("selection:update", function (params) { container.on('selection:update', function (params) {
self.update(params.data); self.update(params.data);
}) });
} };
SingleSelection.prototype.clear = function () { SingleSelection.prototype.clear = function () {
this.$selection.find(".rendered-selection").empty(); this.$selection.find('.rendered-selection').empty();
} };
SingleSelection.prototype.display = function (data) { SingleSelection.prototype.display = function (data) {
return data.text; return data.text;
} };
SingleSelection.prototype.update = function (data) { SingleSelection.prototype.update = function (data) {
if (data.length == 0) { if (data.length === 0) {
this.clear(); this.clear();
return; return;
} }
@ -503,8 +504,8 @@ define('select2/selection/single',[
var formatted = this.display(selection); var formatted = this.display(selection);
this.$selection.find(".rendered-selection").html(formatted); this.$selection.find('.rendered-selection').html(formatted);
} };
return SingleSelection; return SingleSelection;
}); });
@ -531,34 +532,34 @@ define('select2/selection/multiple',[
this.$selection = $selection; this.$selection = $selection;
return $selection; return $selection;
} };
MultipleSelection.prototype.bind = function (container, $container) { MultipleSelection.prototype.bind = function (container, $container) {
var self = this; var self = this;
this.$selection.on('click', function (evt) { this.$selection.on('click', function (evt) {
self.trigger("toggle", { self.trigger('toggle', {
originalEvent: evt originalEvent: evt
}); });
}); });
container.on("selection:update", function (params) { container.on('selection:update', function (params) {
self.update(params.data); self.update(params.data);
}); });
} };
MultipleSelection.prototype.clear = function () { MultipleSelection.prototype.clear = function () {
this.$selection.find(".rendered-selection").empty(); this.$selection.find('.rendered-selection').empty();
} };
MultipleSelection.prototype.display = function (data) { MultipleSelection.prototype.display = function (data) {
return data.text; return data.text;
} };
MultipleSelection.prototype.update = function (data) { MultipleSelection.prototype.update = function (data) {
this.clear(); this.clear();
if (data.length == 0) { if (data.length === 0) {
return; return;
} }
@ -572,20 +573,20 @@ define('select2/selection/multiple',[
var $selection = $('<ul class="choice"></ul>'); var $selection = $('<ul class="choice"></ul>');
$selection.text(formatted); $selection.text(formatted);
$selection.data("data", data); $selection.data('data', data);
$selections.push($selection); $selections.push($selection);
} }
this.$selection.find(".rendered-selection").append($selections); this.$selection.find('.rendered-selection').append($selections);
} };
return MultipleSelection; return MultipleSelection;
}); });
define('select2/data/array',[ define('select2/data/array',[
"./select", './select',
"../utils" '../utils'
], function (SelectAdapter, Utils) { ], function (SelectAdapter, Utils) {
function ArrayAdapter ($element, options) { function ArrayAdapter ($element, options) {
this.data = options.options.data; this.data = options.options.data;
@ -598,7 +599,7 @@ define('select2/data/array',[
ArrayAdapter.prototype.select = function (data) { ArrayAdapter.prototype.select = function (data) {
var self = this; var self = this;
this.$element.find("option").each(function () { this.$element.find('option').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -612,17 +613,17 @@ define('select2/data/array',[
this.$element.append($option); this.$element.append($option);
ArrayAdapter.__super__.select.call(this, data); ArrayAdapter.__super__.select.call(this, data);
} };
ArrayAdapter.prototype.option = function (data) { ArrayAdapter.prototype.option = function (data) {
var $option = $("<option></option>"); var $option = $('<option></option>');
$option.text(data.text); $option.text(data.text);
$option.val(data.id); $option.val(data.id);
$option.data("data", data); $option.data('data', data);
return $option; return $option;
} };
ArrayAdapter.prototype.query = function (params, callback) { ArrayAdapter.prototype.query = function (params, callback) {
var matches = []; var matches = [];
@ -637,22 +638,22 @@ define('select2/data/array',[
}); });
callback(matches); callback(matches);
} };
return ArrayAdapter; return ArrayAdapter;
}); });
define('select2/data/ajax',[ define('select2/data/ajax',[
"./array", './array',
"../utils", '../utils',
"jquery" 'jquery'
], function (ArrayAdapter, Utils, $) { ], function (ArrayAdapter, Utils, $) {
function AjaxAdapter ($element, options) { function AjaxAdapter ($element, options) {
this.ajaxOptions = options.options.ajax; this.ajaxOptions = options.options.ajax;
this.processResults = this.ajaxOptions.processResults || this.processResults = this.ajaxOptions.processResults ||
function (results) { function (results) {
return results return results;
}; };
ArrayAdapter.__super__.constructor.call(this, $element, options); ArrayAdapter.__super__.constructor.call(this, $element, options);
@ -665,14 +666,14 @@ define('select2/data/ajax',[
var self = this; var self = this;
var options = $.extend({ var options = $.extend({
type: "GET", type: 'GET',
}, this.ajaxOptions); }, this.ajaxOptions);
if (typeof options.url === "function") { if (typeof options.url === 'function') {
options.url = options.url(params); options.url = options.url(params);
} }
if (typeof options.data === "function") { if (typeof options.data === 'function') {
options.data = options.data(params); options.data = options.data(params);
} }
@ -681,8 +682,6 @@ define('select2/data/ajax',[
$request.success(function (data) { $request.success(function (data) {
var results = self.processResults(data); var results = self.processResults(data);
console.log(results)
callback(results); callback(results);
}); });
}; };
@ -719,8 +718,8 @@ define('select2/options',[
} }
return Options; return Options;
}) });
;
define('select2/core',[ define('select2/core',[
'jquery', 'jquery',
'./options', './options',
@ -731,7 +730,7 @@ define('select2/core',[
options = options || {}; options = options || {};
options.multiple = options.multiple || $element.prop("multiple"); options.multiple = options.multiple || $element.prop('multiple');
this.options = new Options(options); this.options = new Options(options);
@ -750,21 +749,22 @@ define('select2/core',[
this.selection = new this.options.selectionAdapter($element, this.options); this.selection = new this.options.selectionAdapter($element, this.options);
var $selectionContainer = $container.find(".selection"); var $selectionContainer = $container.find('.selection');
var $selection = this.selection.render(); var $selection = this.selection.render();
$selectionContainer.append($selection); $selectionContainer.append($selection);
this.dropdown = new this.options.dropdownAdapter($element, this.options); this.dropdown = new this.options.dropdownAdapter($element, this.options);
var $dropdownContainer = $container.find(".dropdown"); var $dropdownContainer = $container.find('.dropdown');
var $dropdown = this.dropdown.render(); var $dropdown = this.dropdown.render();
$dropdownContainer.append($dropdown); $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(); var $results = this.results.render();
$resultsContainer.append($results); $resultsContainer.append($results);
@ -777,48 +777,48 @@ define('select2/core',[
this.selection.bind(this, $container); this.selection.bind(this, $container);
this.results.bind(this, $container); this.results.bind(this, $container);
this.$element.on("change", function () { this.$element.on('change', function () {
self.data.current(function (data) { self.data.current(function (data) {
self.trigger("selection:update", { self.trigger('selection:update', {
data: data data: data
}); });
}); });
}); });
this.selection.on("toggle", function () { this.selection.on('toggle', function () {
self.toggleDropdown(); self.toggleDropdown();
}); });
this.results.on("selected", function (params) { this.results.on('selected', function (params) {
self.trigger("select", params); self.trigger('select', params);
self.trigger("close"); self.trigger('close');
}); });
this.results.on("unselected", function (params) { this.results.on('unselected', function (params) {
self.trigger("unselect", params); self.trigger('unselect', params);
self.trigger("close"); self.trigger('close');
}); });
this.on("open", function () { this.on('open', function () {
$container.addClass("open"); $container.addClass('open');
}); });
this.on("close", function () { this.on('close', function () {
$container.removeClass("open"); $container.removeClass('open');
}); });
// Set the initial state // Set the initial state
this.data.current(function (initialData) { this.data.current(function (initialData) {
self.trigger("selection:update", { self.trigger('selection:update', {
data: initialData data: initialData
}); });
}); });
this.data.query({}, function (data) { this.data.query({}, function (data) {
self.results.trigger("results:all", data); self.results.trigger('results:all', data);
}); });
// Hide the original select // Hide the original select
@ -829,12 +829,12 @@ define('select2/core',[
Utils.Extend(Select2, Utils.Observable); Utils.Extend(Select2, Utils.Observable);
Select2.prototype.toggleDropdown = function () { Select2.prototype.toggleDropdown = function () {
if (this.$container.hasClass("open")) { if (this.$container.hasClass('open')) {
this.trigger("close"); this.trigger('close');
} else { } else {
this.trigger("open"); this.trigger('open');
}
} }
};
Select2.prototype.render = function () { Select2.prototype.render = function () {
var $container = $( var $container = $(

246
dist/js/select2.amd.js vendored
View File

@ -2,7 +2,7 @@ define('select2/utils',[], function () {
var Utils = {}; var Utils = {};
Utils.Extend = function (ChildClass, SuperClass) { Utils.Extend = function (ChildClass, SuperClass) {
var __hasProp = {}.hasOwnProperty var __hasProp = {}.hasOwnProperty;
function BaseConstructor () { function BaseConstructor () {
this.constructor = ChildClass; this.constructor = ChildClass;
@ -29,7 +29,7 @@ define('select2/utils',[], function () {
for (var methodName in proto) { for (var methodName in proto) {
var m = proto[methodName]; var m = proto[methodName];
if (typeof m !== "function") { if (typeof m !== 'function') {
continue; continue;
} }
@ -68,15 +68,13 @@ define('select2/utils',[], function () {
DecoratedClass.prototype = new ctr(); DecoratedClass.prototype = new ctr();
for (var m = 0; m < superMethods.length; m++) { for (var m = 0; m < superMethods.length; m++) {
var methodName = superMethods[m]; var superMethod = superMethods[m];
DecoratedClass.prototype[methodName] = SuperClass.prototype[methodName]; DecoratedClass.prototype[superMethod] =
SuperClass.prototype[superMethod];
} }
for (var m = 0; m < decoratedMethods.length; m++) { var calledMethod = function (methodName) {
var methodName = decoratedMethods[m];
function calledMethod (methodName) {
// Stub out the original method if it's not decorating an actual method // Stub out the original method if it's not decorating an actual method
var originalMethod = function () {}; var originalMethod = function () {};
@ -92,14 +90,17 @@ define('select2/utils',[], function () {
unshift.call(arguments, originalMethod); unshift.call(arguments, originalMethod);
return decoratedMethod.apply(this, arguments); return decoratedMethod.apply(this, arguments);
} };
} };
DecoratedClass.prototype[methodName] = calledMethod(methodName); for (var d = 0; d < decoratedMethods.length; d++) {
var decoratedMethod = decoratedMethods[d];
DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
} }
return DecoratedClass; return DecoratedClass;
} };
var Observable = function () { var Observable = function () {
this.listeners = {}; this.listeners = {};
@ -120,8 +121,8 @@ define('select2/utils',[], function () {
this.invoke(this.listeners[event], slice.call(arguments, 1)); this.invoke(this.listeners[event], slice.call(arguments, 1));
} }
if ("*" in this.listeners) { if ('*' in this.listeners) {
this.invoke(this.listeners["*"], arguments); this.invoke(this.listeners['*'], arguments);
} }
}; };
@ -146,12 +147,12 @@ define('select2/data/base',[
Utils.Extend(BaseAdapter, Utils.Observable); Utils.Extend(BaseAdapter, Utils.Observable);
BaseAdapter.prototype.current = function (callback) { BaseAdapter.prototype.current = function (callback) {
throw new Error("The `current` method must be defined in child classes."); throw new Error('The `current` method must be defined in child classes.');
} };
BaseAdapter.prototype.query = function (params, callback) { BaseAdapter.prototype.query = function (params, callback) {
throw new Error("The `query` method must be defined in child classes."); throw new Error('The `query` method must be defined in child classes.');
} };
return BaseAdapter; return BaseAdapter;
}); });
@ -173,7 +174,7 @@ define('select2/data/select',[
var data = []; var data = [];
var self = this; var self = this;
this.$element.find(":selected").each(function () { this.$element.find(':selected').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -187,7 +188,7 @@ define('select2/data/select',[
SelectAdapter.prototype.select = function (data) { SelectAdapter.prototype.select = function (data) {
var self = this; var self = this;
if (this.$element.prop("multiple")) { if (this.$element.prop('multiple')) {
this.current(function (currentData) { this.current(function (currentData) {
var val = []; var val = [];
@ -203,20 +204,20 @@ define('select2/data/select',[
} }
self.$element.val(val); self.$element.val(val);
self.$element.trigger("change"); self.$element.trigger('change');
}); });
} else { } else {
var val = data.id; var val = data.id;
this.$element.val(val); this.$element.val(val);
this.$element.trigger("change"); this.$element.trigger('change');
} }
}; };
SelectAdapter.prototype.unselect = function (data) { SelectAdapter.prototype.unselect = function (data) {
var self = this; var self = this;
if (!this.$element.prop("multiple")) { if (!this.$element.prop('multiple')) {
return; return;
} }
@ -232,27 +233,27 @@ define('select2/data/select',[
} }
self.$element.val(val); self.$element.val(val);
self.$element.trigger("change"); self.$element.trigger('change');
}); });
} };
SelectAdapter.prototype.bind = function (container, $container) { SelectAdapter.prototype.bind = function (container, $container) {
var self = this; var self = this;
container.on("select", function (params) { container.on('select', function (params) {
self.select(params.data); self.select(params.data);
}); });
container.on("unselect", function (params) { container.on('unselect', function (params) {
self.unselect(params.data); self.unselect(params.data);
}); });
} };
SelectAdapter.prototype.query = function (params, callback) { SelectAdapter.prototype.query = function (params, callback) {
var data = []; var data = [];
var self = this; var self = this;
this.$element.find("option").each(function () { this.$element.find('option').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -266,7 +267,7 @@ define('select2/data/select',[
}; };
SelectAdapter.prototype.item = function ($option) { SelectAdapter.prototype.item = function ($option) {
var data = $option.data("data"); var data = $option.data('data');
// If the data has already be generated, use it // If the data has already be generated, use it
if (data == null) { if (data == null) {
@ -275,14 +276,14 @@ define('select2/data/select',[
text: $option.html() text: $option.html()
}; };
$option.data("data", data); $option.data('data', data);
} }
return data; return data;
}; };
SelectAdapter.prototype.matches = function (params, data) { SelectAdapter.prototype.matches = function (params, data) {
if ($.trim(params.term) == "") { if ($.trim(params.term) === '') {
return true; return true;
} }
@ -291,7 +292,7 @@ define('select2/data/select',[
} }
return false; return false;
} };
return SelectAdapter; return SelectAdapter;
}); });
@ -342,16 +343,16 @@ define('select2/results',[
this.data.current(function (selected) { this.data.current(function (selected) {
selected = $.map(selected, function (s) { return s.id; }); selected = $.map(selected, function (s) { return s.id; });
self.$results.find(".option.selected").removeClass("selected"); self.$results.find('.option.selected').removeClass('selected');
var $options = self.$results.find(".option"); var $options = self.$results.find('.option');
$options.each(function () { $options.each(function () {
var $option = $(this); var $option = $(this);
var item = $option.data("data"); var item = $option.data('data');
if (selected.indexOf(item.id) > -1) { if (selected.indexOf(item.id) > -1) {
$option.addClass("selected"); $option.addClass('selected');
} }
}); });
}); });
@ -363,43 +364,43 @@ define('select2/results',[
); );
$option.html(data.text); $option.html(data.text);
$option.data("data", data); $option.data('data', data);
return $option; return $option;
} };
Results.prototype.bind = function (container, $container) { Results.prototype.bind = function (container, $container) {
var self = this; var self = this;
this.on("results:all", function (data) { this.on('results:all', function (data) {
self.clear(); self.clear();
self.append(data); self.append(data);
self.setClasses(); self.setClasses();
}); });
this.on("results:append", function (data) { this.on('results:append', function (data) {
self.append(data); self.append(data);
self.setClasses(); self.setClasses();
}) });
this.$results.on("mouseup", ".option", function (evt) { this.$results.on('mouseup', '.option', function (evt) {
var $this = $(this); var $this = $(this);
var data = $this.data("data"); var data = $this.data('data');
if ($this.hasClass("selected")) { if ($this.hasClass('selected')) {
self.trigger("unselected", { self.trigger('unselected', {
originalEvent: evt, originalEvent: evt,
data: data data: data
}) });
self.setClasses(); self.setClasses();
return; return;
} }
self.trigger("selected", { self.trigger('selected', {
originalEvent: evt, originalEvent: evt,
data: data data: data
}); });
@ -407,19 +408,19 @@ define('select2/results',[
self.setClasses(); self.setClasses();
}); });
this.$results.on("mouseenter", ".option", function (evt) { this.$results.on('mouseenter', '.option', function (evt) {
self.$results.find(".option.highlighted").removeClass("highlighted"); self.$results.find('.option.highlighted').removeClass('highlighted');
$(this).addClass("highlighted"); $(this).addClass('highlighted');
}); });
this.$results.on("mouseleave", ".option", function (evt) { this.$results.on('mouseleave', '.option', function (evt) {
$(this).removeClass("highlighted"); $(this).removeClass('highlighted');
}); });
}; };
return Results; return Results;
}) });
;
define('select2/dropdown',[ define('select2/dropdown',[
'./utils' './utils'
], function (Utils) { ], function (Utils) {
@ -437,11 +438,11 @@ define('select2/dropdown',[
); );
return $dropdown; return $dropdown;
} };
return Dropdown; return Dropdown;
}) });
;
define('select2/selection/single',[ define('select2/selection/single',[
'../utils' '../utils'
], function (Utils) { ], function (Utils) {
@ -464,7 +465,7 @@ define('select2/selection/single',[
this.$selection = $selection; this.$selection = $selection;
return $selection; return $selection;
} };
SingleSelection.prototype.bind = function (container, $container) { SingleSelection.prototype.bind = function (container, $container) {
var self = this; var self = this;
@ -475,26 +476,26 @@ define('select2/selection/single',[
return; return;
} }
self.trigger("toggle", { self.trigger('toggle', {
originalEvent: evt originalEvent: evt
}); });
}); });
container.on("selection:update", function (params) { container.on('selection:update', function (params) {
self.update(params.data); self.update(params.data);
}) });
} };
SingleSelection.prototype.clear = function () { SingleSelection.prototype.clear = function () {
this.$selection.find(".rendered-selection").empty(); this.$selection.find('.rendered-selection').empty();
} };
SingleSelection.prototype.display = function (data) { SingleSelection.prototype.display = function (data) {
return data.text; return data.text;
} };
SingleSelection.prototype.update = function (data) { SingleSelection.prototype.update = function (data) {
if (data.length == 0) { if (data.length === 0) {
this.clear(); this.clear();
return; return;
} }
@ -503,8 +504,8 @@ define('select2/selection/single',[
var formatted = this.display(selection); var formatted = this.display(selection);
this.$selection.find(".rendered-selection").html(formatted); this.$selection.find('.rendered-selection').html(formatted);
} };
return SingleSelection; return SingleSelection;
}); });
@ -531,34 +532,34 @@ define('select2/selection/multiple',[
this.$selection = $selection; this.$selection = $selection;
return $selection; return $selection;
} };
MultipleSelection.prototype.bind = function (container, $container) { MultipleSelection.prototype.bind = function (container, $container) {
var self = this; var self = this;
this.$selection.on('click', function (evt) { this.$selection.on('click', function (evt) {
self.trigger("toggle", { self.trigger('toggle', {
originalEvent: evt originalEvent: evt
}); });
}); });
container.on("selection:update", function (params) { container.on('selection:update', function (params) {
self.update(params.data); self.update(params.data);
}); });
} };
MultipleSelection.prototype.clear = function () { MultipleSelection.prototype.clear = function () {
this.$selection.find(".rendered-selection").empty(); this.$selection.find('.rendered-selection').empty();
} };
MultipleSelection.prototype.display = function (data) { MultipleSelection.prototype.display = function (data) {
return data.text; return data.text;
} };
MultipleSelection.prototype.update = function (data) { MultipleSelection.prototype.update = function (data) {
this.clear(); this.clear();
if (data.length == 0) { if (data.length === 0) {
return; return;
} }
@ -572,20 +573,20 @@ define('select2/selection/multiple',[
var $selection = $('<ul class="choice"></ul>'); var $selection = $('<ul class="choice"></ul>');
$selection.text(formatted); $selection.text(formatted);
$selection.data("data", data); $selection.data('data', data);
$selections.push($selection); $selections.push($selection);
} }
this.$selection.find(".rendered-selection").append($selections); this.$selection.find('.rendered-selection').append($selections);
} };
return MultipleSelection; return MultipleSelection;
}); });
define('select2/data/array',[ define('select2/data/array',[
"./select", './select',
"../utils" '../utils'
], function (SelectAdapter, Utils) { ], function (SelectAdapter, Utils) {
function ArrayAdapter ($element, options) { function ArrayAdapter ($element, options) {
this.data = options.options.data; this.data = options.options.data;
@ -598,7 +599,7 @@ define('select2/data/array',[
ArrayAdapter.prototype.select = function (data) { ArrayAdapter.prototype.select = function (data) {
var self = this; var self = this;
this.$element.find("option").each(function () { this.$element.find('option').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -612,17 +613,17 @@ define('select2/data/array',[
this.$element.append($option); this.$element.append($option);
ArrayAdapter.__super__.select.call(this, data); ArrayAdapter.__super__.select.call(this, data);
} };
ArrayAdapter.prototype.option = function (data) { ArrayAdapter.prototype.option = function (data) {
var $option = $("<option></option>"); var $option = $('<option></option>');
$option.text(data.text); $option.text(data.text);
$option.val(data.id); $option.val(data.id);
$option.data("data", data); $option.data('data', data);
return $option; return $option;
} };
ArrayAdapter.prototype.query = function (params, callback) { ArrayAdapter.prototype.query = function (params, callback) {
var matches = []; var matches = [];
@ -637,22 +638,22 @@ define('select2/data/array',[
}); });
callback(matches); callback(matches);
} };
return ArrayAdapter; return ArrayAdapter;
}); });
define('select2/data/ajax',[ define('select2/data/ajax',[
"./array", './array',
"../utils", '../utils',
"jquery" 'jquery'
], function (ArrayAdapter, Utils, $) { ], function (ArrayAdapter, Utils, $) {
function AjaxAdapter ($element, options) { function AjaxAdapter ($element, options) {
this.ajaxOptions = options.options.ajax; this.ajaxOptions = options.options.ajax;
this.processResults = this.ajaxOptions.processResults || this.processResults = this.ajaxOptions.processResults ||
function (results) { function (results) {
return results return results;
}; };
ArrayAdapter.__super__.constructor.call(this, $element, options); ArrayAdapter.__super__.constructor.call(this, $element, options);
@ -665,14 +666,14 @@ define('select2/data/ajax',[
var self = this; var self = this;
var options = $.extend({ var options = $.extend({
type: "GET", type: 'GET',
}, this.ajaxOptions); }, this.ajaxOptions);
if (typeof options.url === "function") { if (typeof options.url === 'function') {
options.url = options.url(params); options.url = options.url(params);
} }
if (typeof options.data === "function") { if (typeof options.data === 'function') {
options.data = options.data(params); options.data = options.data(params);
} }
@ -681,8 +682,6 @@ define('select2/data/ajax',[
$request.success(function (data) { $request.success(function (data) {
var results = self.processResults(data); var results = self.processResults(data);
console.log(results)
callback(results); callback(results);
}); });
}; };
@ -719,8 +718,8 @@ define('select2/options',[
} }
return Options; return Options;
}) });
;
define('select2/core',[ define('select2/core',[
'jquery', 'jquery',
'./options', './options',
@ -731,7 +730,7 @@ define('select2/core',[
options = options || {}; options = options || {};
options.multiple = options.multiple || $element.prop("multiple"); options.multiple = options.multiple || $element.prop('multiple');
this.options = new Options(options); this.options = new Options(options);
@ -750,21 +749,22 @@ define('select2/core',[
this.selection = new this.options.selectionAdapter($element, this.options); this.selection = new this.options.selectionAdapter($element, this.options);
var $selectionContainer = $container.find(".selection"); var $selectionContainer = $container.find('.selection');
var $selection = this.selection.render(); var $selection = this.selection.render();
$selectionContainer.append($selection); $selectionContainer.append($selection);
this.dropdown = new this.options.dropdownAdapter($element, this.options); this.dropdown = new this.options.dropdownAdapter($element, this.options);
var $dropdownContainer = $container.find(".dropdown"); var $dropdownContainer = $container.find('.dropdown');
var $dropdown = this.dropdown.render(); var $dropdown = this.dropdown.render();
$dropdownContainer.append($dropdown); $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(); var $results = this.results.render();
$resultsContainer.append($results); $resultsContainer.append($results);
@ -777,48 +777,48 @@ define('select2/core',[
this.selection.bind(this, $container); this.selection.bind(this, $container);
this.results.bind(this, $container); this.results.bind(this, $container);
this.$element.on("change", function () { this.$element.on('change', function () {
self.data.current(function (data) { self.data.current(function (data) {
self.trigger("selection:update", { self.trigger('selection:update', {
data: data data: data
}); });
}); });
}); });
this.selection.on("toggle", function () { this.selection.on('toggle', function () {
self.toggleDropdown(); self.toggleDropdown();
}); });
this.results.on("selected", function (params) { this.results.on('selected', function (params) {
self.trigger("select", params); self.trigger('select', params);
self.trigger("close"); self.trigger('close');
}); });
this.results.on("unselected", function (params) { this.results.on('unselected', function (params) {
self.trigger("unselect", params); self.trigger('unselect', params);
self.trigger("close"); self.trigger('close');
}); });
this.on("open", function () { this.on('open', function () {
$container.addClass("open"); $container.addClass('open');
}); });
this.on("close", function () { this.on('close', function () {
$container.removeClass("open"); $container.removeClass('open');
}); });
// Set the initial state // Set the initial state
this.data.current(function (initialData) { this.data.current(function (initialData) {
self.trigger("selection:update", { self.trigger('selection:update', {
data: initialData data: initialData
}); });
}); });
this.data.query({}, function (data) { this.data.query({}, function (data) {
self.results.trigger("results:all", data); self.results.trigger('results:all', data);
}); });
// Hide the original select // Hide the original select
@ -829,12 +829,12 @@ define('select2/core',[
Utils.Extend(Select2, Utils.Observable); Utils.Extend(Select2, Utils.Observable);
Select2.prototype.toggleDropdown = function () { Select2.prototype.toggleDropdown = function () {
if (this.$container.hasClass("open")) { if (this.$container.hasClass('open')) {
this.trigger("close"); this.trigger('close');
} else { } else {
this.trigger("open"); this.trigger('open');
}
} }
};
Select2.prototype.render = function () { Select2.prototype.render = function () {
var $container = $( var $container = $(

View File

@ -9539,7 +9539,7 @@ define('select2/utils',[], function () {
var Utils = {}; var Utils = {};
Utils.Extend = function (ChildClass, SuperClass) { Utils.Extend = function (ChildClass, SuperClass) {
var __hasProp = {}.hasOwnProperty var __hasProp = {}.hasOwnProperty;
function BaseConstructor () { function BaseConstructor () {
this.constructor = ChildClass; this.constructor = ChildClass;
@ -9566,7 +9566,7 @@ define('select2/utils',[], function () {
for (var methodName in proto) { for (var methodName in proto) {
var m = proto[methodName]; var m = proto[methodName];
if (typeof m !== "function") { if (typeof m !== 'function') {
continue; continue;
} }
@ -9605,15 +9605,13 @@ define('select2/utils',[], function () {
DecoratedClass.prototype = new ctr(); DecoratedClass.prototype = new ctr();
for (var m = 0; m < superMethods.length; m++) { for (var m = 0; m < superMethods.length; m++) {
var methodName = superMethods[m]; var superMethod = superMethods[m];
DecoratedClass.prototype[methodName] = SuperClass.prototype[methodName]; DecoratedClass.prototype[superMethod] =
SuperClass.prototype[superMethod];
} }
for (var m = 0; m < decoratedMethods.length; m++) { var calledMethod = function (methodName) {
var methodName = decoratedMethods[m];
function calledMethod (methodName) {
// Stub out the original method if it's not decorating an actual method // Stub out the original method if it's not decorating an actual method
var originalMethod = function () {}; var originalMethod = function () {};
@ -9629,14 +9627,17 @@ define('select2/utils',[], function () {
unshift.call(arguments, originalMethod); unshift.call(arguments, originalMethod);
return decoratedMethod.apply(this, arguments); return decoratedMethod.apply(this, arguments);
} };
} };
DecoratedClass.prototype[methodName] = calledMethod(methodName); for (var d = 0; d < decoratedMethods.length; d++) {
var decoratedMethod = decoratedMethods[d];
DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
} }
return DecoratedClass; return DecoratedClass;
} };
var Observable = function () { var Observable = function () {
this.listeners = {}; this.listeners = {};
@ -9657,8 +9658,8 @@ define('select2/utils',[], function () {
this.invoke(this.listeners[event], slice.call(arguments, 1)); this.invoke(this.listeners[event], slice.call(arguments, 1));
} }
if ("*" in this.listeners) { if ('*' in this.listeners) {
this.invoke(this.listeners["*"], arguments); this.invoke(this.listeners['*'], arguments);
} }
}; };
@ -9683,12 +9684,12 @@ define('select2/data/base',[
Utils.Extend(BaseAdapter, Utils.Observable); Utils.Extend(BaseAdapter, Utils.Observable);
BaseAdapter.prototype.current = function (callback) { BaseAdapter.prototype.current = function (callback) {
throw new Error("The `current` method must be defined in child classes."); throw new Error('The `current` method must be defined in child classes.');
} };
BaseAdapter.prototype.query = function (params, callback) { BaseAdapter.prototype.query = function (params, callback) {
throw new Error("The `query` method must be defined in child classes."); throw new Error('The `query` method must be defined in child classes.');
} };
return BaseAdapter; return BaseAdapter;
}); });
@ -9710,7 +9711,7 @@ define('select2/data/select',[
var data = []; var data = [];
var self = this; var self = this;
this.$element.find(":selected").each(function () { this.$element.find(':selected').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -9724,7 +9725,7 @@ define('select2/data/select',[
SelectAdapter.prototype.select = function (data) { SelectAdapter.prototype.select = function (data) {
var self = this; var self = this;
if (this.$element.prop("multiple")) { if (this.$element.prop('multiple')) {
this.current(function (currentData) { this.current(function (currentData) {
var val = []; var val = [];
@ -9740,20 +9741,20 @@ define('select2/data/select',[
} }
self.$element.val(val); self.$element.val(val);
self.$element.trigger("change"); self.$element.trigger('change');
}); });
} else { } else {
var val = data.id; var val = data.id;
this.$element.val(val); this.$element.val(val);
this.$element.trigger("change"); this.$element.trigger('change');
} }
}; };
SelectAdapter.prototype.unselect = function (data) { SelectAdapter.prototype.unselect = function (data) {
var self = this; var self = this;
if (!this.$element.prop("multiple")) { if (!this.$element.prop('multiple')) {
return; return;
} }
@ -9769,27 +9770,27 @@ define('select2/data/select',[
} }
self.$element.val(val); self.$element.val(val);
self.$element.trigger("change"); self.$element.trigger('change');
}); });
} };
SelectAdapter.prototype.bind = function (container, $container) { SelectAdapter.prototype.bind = function (container, $container) {
var self = this; var self = this;
container.on("select", function (params) { container.on('select', function (params) {
self.select(params.data); self.select(params.data);
}); });
container.on("unselect", function (params) { container.on('unselect', function (params) {
self.unselect(params.data); self.unselect(params.data);
}); });
} };
SelectAdapter.prototype.query = function (params, callback) { SelectAdapter.prototype.query = function (params, callback) {
var data = []; var data = [];
var self = this; var self = this;
this.$element.find("option").each(function () { this.$element.find('option').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -9803,7 +9804,7 @@ define('select2/data/select',[
}; };
SelectAdapter.prototype.item = function ($option) { SelectAdapter.prototype.item = function ($option) {
var data = $option.data("data"); var data = $option.data('data');
// If the data has already be generated, use it // If the data has already be generated, use it
if (data == null) { if (data == null) {
@ -9812,14 +9813,14 @@ define('select2/data/select',[
text: $option.html() text: $option.html()
}; };
$option.data("data", data); $option.data('data', data);
} }
return data; return data;
}; };
SelectAdapter.prototype.matches = function (params, data) { SelectAdapter.prototype.matches = function (params, data) {
if ($.trim(params.term) == "") { if ($.trim(params.term) === '') {
return true; return true;
} }
@ -9828,7 +9829,7 @@ define('select2/data/select',[
} }
return false; return false;
} };
return SelectAdapter; return SelectAdapter;
}); });
@ -9879,16 +9880,16 @@ define('select2/results',[
this.data.current(function (selected) { this.data.current(function (selected) {
selected = $.map(selected, function (s) { return s.id; }); selected = $.map(selected, function (s) { return s.id; });
self.$results.find(".option.selected").removeClass("selected"); self.$results.find('.option.selected').removeClass('selected');
var $options = self.$results.find(".option"); var $options = self.$results.find('.option');
$options.each(function () { $options.each(function () {
var $option = $(this); var $option = $(this);
var item = $option.data("data"); var item = $option.data('data');
if (selected.indexOf(item.id) > -1) { if (selected.indexOf(item.id) > -1) {
$option.addClass("selected"); $option.addClass('selected');
} }
}); });
}); });
@ -9900,43 +9901,43 @@ define('select2/results',[
); );
$option.html(data.text); $option.html(data.text);
$option.data("data", data); $option.data('data', data);
return $option; return $option;
} };
Results.prototype.bind = function (container, $container) { Results.prototype.bind = function (container, $container) {
var self = this; var self = this;
this.on("results:all", function (data) { this.on('results:all', function (data) {
self.clear(); self.clear();
self.append(data); self.append(data);
self.setClasses(); self.setClasses();
}); });
this.on("results:append", function (data) { this.on('results:append', function (data) {
self.append(data); self.append(data);
self.setClasses(); self.setClasses();
}) });
this.$results.on("mouseup", ".option", function (evt) { this.$results.on('mouseup', '.option', function (evt) {
var $this = $(this); var $this = $(this);
var data = $this.data("data"); var data = $this.data('data');
if ($this.hasClass("selected")) { if ($this.hasClass('selected')) {
self.trigger("unselected", { self.trigger('unselected', {
originalEvent: evt, originalEvent: evt,
data: data data: data
}) });
self.setClasses(); self.setClasses();
return; return;
} }
self.trigger("selected", { self.trigger('selected', {
originalEvent: evt, originalEvent: evt,
data: data data: data
}); });
@ -9944,19 +9945,19 @@ define('select2/results',[
self.setClasses(); self.setClasses();
}); });
this.$results.on("mouseenter", ".option", function (evt) { this.$results.on('mouseenter', '.option', function (evt) {
self.$results.find(".option.highlighted").removeClass("highlighted"); self.$results.find('.option.highlighted').removeClass('highlighted');
$(this).addClass("highlighted"); $(this).addClass('highlighted');
}); });
this.$results.on("mouseleave", ".option", function (evt) { this.$results.on('mouseleave', '.option', function (evt) {
$(this).removeClass("highlighted"); $(this).removeClass('highlighted');
}); });
}; };
return Results; return Results;
}) });
;
define('select2/dropdown',[ define('select2/dropdown',[
'./utils' './utils'
], function (Utils) { ], function (Utils) {
@ -9974,11 +9975,11 @@ define('select2/dropdown',[
); );
return $dropdown; return $dropdown;
} };
return Dropdown; return Dropdown;
}) });
;
define('select2/selection/single',[ define('select2/selection/single',[
'../utils' '../utils'
], function (Utils) { ], function (Utils) {
@ -10001,7 +10002,7 @@ define('select2/selection/single',[
this.$selection = $selection; this.$selection = $selection;
return $selection; return $selection;
} };
SingleSelection.prototype.bind = function (container, $container) { SingleSelection.prototype.bind = function (container, $container) {
var self = this; var self = this;
@ -10012,26 +10013,26 @@ define('select2/selection/single',[
return; return;
} }
self.trigger("toggle", { self.trigger('toggle', {
originalEvent: evt originalEvent: evt
}); });
}); });
container.on("selection:update", function (params) { container.on('selection:update', function (params) {
self.update(params.data); self.update(params.data);
}) });
} };
SingleSelection.prototype.clear = function () { SingleSelection.prototype.clear = function () {
this.$selection.find(".rendered-selection").empty(); this.$selection.find('.rendered-selection').empty();
} };
SingleSelection.prototype.display = function (data) { SingleSelection.prototype.display = function (data) {
return data.text; return data.text;
} };
SingleSelection.prototype.update = function (data) { SingleSelection.prototype.update = function (data) {
if (data.length == 0) { if (data.length === 0) {
this.clear(); this.clear();
return; return;
} }
@ -10040,8 +10041,8 @@ define('select2/selection/single',[
var formatted = this.display(selection); var formatted = this.display(selection);
this.$selection.find(".rendered-selection").html(formatted); this.$selection.find('.rendered-selection').html(formatted);
} };
return SingleSelection; return SingleSelection;
}); });
@ -10068,34 +10069,34 @@ define('select2/selection/multiple',[
this.$selection = $selection; this.$selection = $selection;
return $selection; return $selection;
} };
MultipleSelection.prototype.bind = function (container, $container) { MultipleSelection.prototype.bind = function (container, $container) {
var self = this; var self = this;
this.$selection.on('click', function (evt) { this.$selection.on('click', function (evt) {
self.trigger("toggle", { self.trigger('toggle', {
originalEvent: evt originalEvent: evt
}); });
}); });
container.on("selection:update", function (params) { container.on('selection:update', function (params) {
self.update(params.data); self.update(params.data);
}); });
} };
MultipleSelection.prototype.clear = function () { MultipleSelection.prototype.clear = function () {
this.$selection.find(".rendered-selection").empty(); this.$selection.find('.rendered-selection').empty();
} };
MultipleSelection.prototype.display = function (data) { MultipleSelection.prototype.display = function (data) {
return data.text; return data.text;
} };
MultipleSelection.prototype.update = function (data) { MultipleSelection.prototype.update = function (data) {
this.clear(); this.clear();
if (data.length == 0) { if (data.length === 0) {
return; return;
} }
@ -10109,20 +10110,20 @@ define('select2/selection/multiple',[
var $selection = $('<ul class="choice"></ul>'); var $selection = $('<ul class="choice"></ul>');
$selection.text(formatted); $selection.text(formatted);
$selection.data("data", data); $selection.data('data', data);
$selections.push($selection); $selections.push($selection);
} }
this.$selection.find(".rendered-selection").append($selections); this.$selection.find('.rendered-selection').append($selections);
} };
return MultipleSelection; return MultipleSelection;
}); });
define('select2/data/array',[ define('select2/data/array',[
"./select", './select',
"../utils" '../utils'
], function (SelectAdapter, Utils) { ], function (SelectAdapter, Utils) {
function ArrayAdapter ($element, options) { function ArrayAdapter ($element, options) {
this.data = options.options.data; this.data = options.options.data;
@ -10135,7 +10136,7 @@ define('select2/data/array',[
ArrayAdapter.prototype.select = function (data) { ArrayAdapter.prototype.select = function (data) {
var self = this; var self = this;
this.$element.find("option").each(function () { this.$element.find('option').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -10149,17 +10150,17 @@ define('select2/data/array',[
this.$element.append($option); this.$element.append($option);
ArrayAdapter.__super__.select.call(this, data); ArrayAdapter.__super__.select.call(this, data);
} };
ArrayAdapter.prototype.option = function (data) { ArrayAdapter.prototype.option = function (data) {
var $option = $("<option></option>"); var $option = $('<option></option>');
$option.text(data.text); $option.text(data.text);
$option.val(data.id); $option.val(data.id);
$option.data("data", data); $option.data('data', data);
return $option; return $option;
} };
ArrayAdapter.prototype.query = function (params, callback) { ArrayAdapter.prototype.query = function (params, callback) {
var matches = []; var matches = [];
@ -10174,22 +10175,22 @@ define('select2/data/array',[
}); });
callback(matches); callback(matches);
} };
return ArrayAdapter; return ArrayAdapter;
}); });
define('select2/data/ajax',[ define('select2/data/ajax',[
"./array", './array',
"../utils", '../utils',
"jquery" 'jquery'
], function (ArrayAdapter, Utils, $) { ], function (ArrayAdapter, Utils, $) {
function AjaxAdapter ($element, options) { function AjaxAdapter ($element, options) {
this.ajaxOptions = options.options.ajax; this.ajaxOptions = options.options.ajax;
this.processResults = this.ajaxOptions.processResults || this.processResults = this.ajaxOptions.processResults ||
function (results) { function (results) {
return results return results;
}; };
ArrayAdapter.__super__.constructor.call(this, $element, options); ArrayAdapter.__super__.constructor.call(this, $element, options);
@ -10202,14 +10203,14 @@ define('select2/data/ajax',[
var self = this; var self = this;
var options = $.extend({ var options = $.extend({
type: "GET", type: 'GET',
}, this.ajaxOptions); }, this.ajaxOptions);
if (typeof options.url === "function") { if (typeof options.url === 'function') {
options.url = options.url(params); options.url = options.url(params);
} }
if (typeof options.data === "function") { if (typeof options.data === 'function') {
options.data = options.data(params); options.data = options.data(params);
} }
@ -10218,8 +10219,6 @@ define('select2/data/ajax',[
$request.success(function (data) { $request.success(function (data) {
var results = self.processResults(data); var results = self.processResults(data);
console.log(results)
callback(results); callback(results);
}); });
}; };
@ -10256,8 +10255,8 @@ define('select2/options',[
} }
return Options; return Options;
}) });
;
define('select2/core',[ define('select2/core',[
'jquery', 'jquery',
'./options', './options',
@ -10268,7 +10267,7 @@ define('select2/core',[
options = options || {}; options = options || {};
options.multiple = options.multiple || $element.prop("multiple"); options.multiple = options.multiple || $element.prop('multiple');
this.options = new Options(options); this.options = new Options(options);
@ -10287,21 +10286,22 @@ define('select2/core',[
this.selection = new this.options.selectionAdapter($element, this.options); this.selection = new this.options.selectionAdapter($element, this.options);
var $selectionContainer = $container.find(".selection"); var $selectionContainer = $container.find('.selection');
var $selection = this.selection.render(); var $selection = this.selection.render();
$selectionContainer.append($selection); $selectionContainer.append($selection);
this.dropdown = new this.options.dropdownAdapter($element, this.options); this.dropdown = new this.options.dropdownAdapter($element, this.options);
var $dropdownContainer = $container.find(".dropdown"); var $dropdownContainer = $container.find('.dropdown');
var $dropdown = this.dropdown.render(); var $dropdown = this.dropdown.render();
$dropdownContainer.append($dropdown); $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(); var $results = this.results.render();
$resultsContainer.append($results); $resultsContainer.append($results);
@ -10314,48 +10314,48 @@ define('select2/core',[
this.selection.bind(this, $container); this.selection.bind(this, $container);
this.results.bind(this, $container); this.results.bind(this, $container);
this.$element.on("change", function () { this.$element.on('change', function () {
self.data.current(function (data) { self.data.current(function (data) {
self.trigger("selection:update", { self.trigger('selection:update', {
data: data data: data
}); });
}); });
}); });
this.selection.on("toggle", function () { this.selection.on('toggle', function () {
self.toggleDropdown(); self.toggleDropdown();
}); });
this.results.on("selected", function (params) { this.results.on('selected', function (params) {
self.trigger("select", params); self.trigger('select', params);
self.trigger("close"); self.trigger('close');
}); });
this.results.on("unselected", function (params) { this.results.on('unselected', function (params) {
self.trigger("unselect", params); self.trigger('unselect', params);
self.trigger("close"); self.trigger('close');
}); });
this.on("open", function () { this.on('open', function () {
$container.addClass("open"); $container.addClass('open');
}); });
this.on("close", function () { this.on('close', function () {
$container.removeClass("open"); $container.removeClass('open');
}); });
// Set the initial state // Set the initial state
this.data.current(function (initialData) { this.data.current(function (initialData) {
self.trigger("selection:update", { self.trigger('selection:update', {
data: initialData data: initialData
}); });
}); });
this.data.query({}, function (data) { this.data.query({}, function (data) {
self.results.trigger("results:all", data); self.results.trigger('results:all', data);
}); });
// Hide the original select // Hide the original select
@ -10366,12 +10366,12 @@ define('select2/core',[
Utils.Extend(Select2, Utils.Observable); Utils.Extend(Select2, Utils.Observable);
Select2.prototype.toggleDropdown = function () { Select2.prototype.toggleDropdown = function () {
if (this.$container.hasClass("open")) { if (this.$container.hasClass('open')) {
this.trigger("close"); this.trigger('close');
} else { } else {
this.trigger("open"); this.trigger('open');
}
} }
};
Select2.prototype.render = function () { Select2.prototype.render = function () {
var $container = $( var $container = $(

250
dist/js/select2.js vendored
View File

@ -424,13 +424,13 @@ define("almond", function(){});
define('jquery',[],function () { define('jquery',[],function () {
return jQuery; return jQuery;
}) });
;
define('select2/utils',[], function () { define('select2/utils',[], function () {
var Utils = {}; var Utils = {};
Utils.Extend = function (ChildClass, SuperClass) { Utils.Extend = function (ChildClass, SuperClass) {
var __hasProp = {}.hasOwnProperty var __hasProp = {}.hasOwnProperty;
function BaseConstructor () { function BaseConstructor () {
this.constructor = ChildClass; this.constructor = ChildClass;
@ -457,7 +457,7 @@ define('select2/utils',[], function () {
for (var methodName in proto) { for (var methodName in proto) {
var m = proto[methodName]; var m = proto[methodName];
if (typeof m !== "function") { if (typeof m !== 'function') {
continue; continue;
} }
@ -496,15 +496,13 @@ define('select2/utils',[], function () {
DecoratedClass.prototype = new ctr(); DecoratedClass.prototype = new ctr();
for (var m = 0; m < superMethods.length; m++) { for (var m = 0; m < superMethods.length; m++) {
var methodName = superMethods[m]; var superMethod = superMethods[m];
DecoratedClass.prototype[methodName] = SuperClass.prototype[methodName]; DecoratedClass.prototype[superMethod] =
SuperClass.prototype[superMethod];
} }
for (var m = 0; m < decoratedMethods.length; m++) { var calledMethod = function (methodName) {
var methodName = decoratedMethods[m];
function calledMethod (methodName) {
// Stub out the original method if it's not decorating an actual method // Stub out the original method if it's not decorating an actual method
var originalMethod = function () {}; var originalMethod = function () {};
@ -520,14 +518,17 @@ define('select2/utils',[], function () {
unshift.call(arguments, originalMethod); unshift.call(arguments, originalMethod);
return decoratedMethod.apply(this, arguments); return decoratedMethod.apply(this, arguments);
} };
} };
DecoratedClass.prototype[methodName] = calledMethod(methodName); for (var d = 0; d < decoratedMethods.length; d++) {
var decoratedMethod = decoratedMethods[d];
DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
} }
return DecoratedClass; return DecoratedClass;
} };
var Observable = function () { var Observable = function () {
this.listeners = {}; this.listeners = {};
@ -548,8 +549,8 @@ define('select2/utils',[], function () {
this.invoke(this.listeners[event], slice.call(arguments, 1)); this.invoke(this.listeners[event], slice.call(arguments, 1));
} }
if ("*" in this.listeners) { if ('*' in this.listeners) {
this.invoke(this.listeners["*"], arguments); this.invoke(this.listeners['*'], arguments);
} }
}; };
@ -574,12 +575,12 @@ define('select2/data/base',[
Utils.Extend(BaseAdapter, Utils.Observable); Utils.Extend(BaseAdapter, Utils.Observable);
BaseAdapter.prototype.current = function (callback) { BaseAdapter.prototype.current = function (callback) {
throw new Error("The `current` method must be defined in child classes."); throw new Error('The `current` method must be defined in child classes.');
} };
BaseAdapter.prototype.query = function (params, callback) { BaseAdapter.prototype.query = function (params, callback) {
throw new Error("The `query` method must be defined in child classes."); throw new Error('The `query` method must be defined in child classes.');
} };
return BaseAdapter; return BaseAdapter;
}); });
@ -601,7 +602,7 @@ define('select2/data/select',[
var data = []; var data = [];
var self = this; var self = this;
this.$element.find(":selected").each(function () { this.$element.find(':selected').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -615,7 +616,7 @@ define('select2/data/select',[
SelectAdapter.prototype.select = function (data) { SelectAdapter.prototype.select = function (data) {
var self = this; var self = this;
if (this.$element.prop("multiple")) { if (this.$element.prop('multiple')) {
this.current(function (currentData) { this.current(function (currentData) {
var val = []; var val = [];
@ -631,20 +632,20 @@ define('select2/data/select',[
} }
self.$element.val(val); self.$element.val(val);
self.$element.trigger("change"); self.$element.trigger('change');
}); });
} else { } else {
var val = data.id; var val = data.id;
this.$element.val(val); this.$element.val(val);
this.$element.trigger("change"); this.$element.trigger('change');
} }
}; };
SelectAdapter.prototype.unselect = function (data) { SelectAdapter.prototype.unselect = function (data) {
var self = this; var self = this;
if (!this.$element.prop("multiple")) { if (!this.$element.prop('multiple')) {
return; return;
} }
@ -660,27 +661,27 @@ define('select2/data/select',[
} }
self.$element.val(val); self.$element.val(val);
self.$element.trigger("change"); self.$element.trigger('change');
}); });
} };
SelectAdapter.prototype.bind = function (container, $container) { SelectAdapter.prototype.bind = function (container, $container) {
var self = this; var self = this;
container.on("select", function (params) { container.on('select', function (params) {
self.select(params.data); self.select(params.data);
}); });
container.on("unselect", function (params) { container.on('unselect', function (params) {
self.unselect(params.data); self.unselect(params.data);
}); });
} };
SelectAdapter.prototype.query = function (params, callback) { SelectAdapter.prototype.query = function (params, callback) {
var data = []; var data = [];
var self = this; var self = this;
this.$element.find("option").each(function () { this.$element.find('option').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -694,7 +695,7 @@ define('select2/data/select',[
}; };
SelectAdapter.prototype.item = function ($option) { SelectAdapter.prototype.item = function ($option) {
var data = $option.data("data"); var data = $option.data('data');
// If the data has already be generated, use it // If the data has already be generated, use it
if (data == null) { if (data == null) {
@ -703,14 +704,14 @@ define('select2/data/select',[
text: $option.html() text: $option.html()
}; };
$option.data("data", data); $option.data('data', data);
} }
return data; return data;
}; };
SelectAdapter.prototype.matches = function (params, data) { SelectAdapter.prototype.matches = function (params, data) {
if ($.trim(params.term) == "") { if ($.trim(params.term) === '') {
return true; return true;
} }
@ -719,7 +720,7 @@ define('select2/data/select',[
} }
return false; return false;
} };
return SelectAdapter; return SelectAdapter;
}); });
@ -770,16 +771,16 @@ define('select2/results',[
this.data.current(function (selected) { this.data.current(function (selected) {
selected = $.map(selected, function (s) { return s.id; }); selected = $.map(selected, function (s) { return s.id; });
self.$results.find(".option.selected").removeClass("selected"); self.$results.find('.option.selected').removeClass('selected');
var $options = self.$results.find(".option"); var $options = self.$results.find('.option');
$options.each(function () { $options.each(function () {
var $option = $(this); var $option = $(this);
var item = $option.data("data"); var item = $option.data('data');
if (selected.indexOf(item.id) > -1) { if (selected.indexOf(item.id) > -1) {
$option.addClass("selected"); $option.addClass('selected');
} }
}); });
}); });
@ -791,43 +792,43 @@ define('select2/results',[
); );
$option.html(data.text); $option.html(data.text);
$option.data("data", data); $option.data('data', data);
return $option; return $option;
} };
Results.prototype.bind = function (container, $container) { Results.prototype.bind = function (container, $container) {
var self = this; var self = this;
this.on("results:all", function (data) { this.on('results:all', function (data) {
self.clear(); self.clear();
self.append(data); self.append(data);
self.setClasses(); self.setClasses();
}); });
this.on("results:append", function (data) { this.on('results:append', function (data) {
self.append(data); self.append(data);
self.setClasses(); self.setClasses();
}) });
this.$results.on("mouseup", ".option", function (evt) { this.$results.on('mouseup', '.option', function (evt) {
var $this = $(this); var $this = $(this);
var data = $this.data("data"); var data = $this.data('data');
if ($this.hasClass("selected")) { if ($this.hasClass('selected')) {
self.trigger("unselected", { self.trigger('unselected', {
originalEvent: evt, originalEvent: evt,
data: data data: data
}) });
self.setClasses(); self.setClasses();
return; return;
} }
self.trigger("selected", { self.trigger('selected', {
originalEvent: evt, originalEvent: evt,
data: data data: data
}); });
@ -835,19 +836,19 @@ define('select2/results',[
self.setClasses(); self.setClasses();
}); });
this.$results.on("mouseenter", ".option", function (evt) { this.$results.on('mouseenter', '.option', function (evt) {
self.$results.find(".option.highlighted").removeClass("highlighted"); self.$results.find('.option.highlighted').removeClass('highlighted');
$(this).addClass("highlighted"); $(this).addClass('highlighted');
}); });
this.$results.on("mouseleave", ".option", function (evt) { this.$results.on('mouseleave', '.option', function (evt) {
$(this).removeClass("highlighted"); $(this).removeClass('highlighted');
}); });
}; };
return Results; return Results;
}) });
;
define('select2/dropdown',[ define('select2/dropdown',[
'./utils' './utils'
], function (Utils) { ], function (Utils) {
@ -865,11 +866,11 @@ define('select2/dropdown',[
); );
return $dropdown; return $dropdown;
} };
return Dropdown; return Dropdown;
}) });
;
define('select2/selection/single',[ define('select2/selection/single',[
'../utils' '../utils'
], function (Utils) { ], function (Utils) {
@ -892,7 +893,7 @@ define('select2/selection/single',[
this.$selection = $selection; this.$selection = $selection;
return $selection; return $selection;
} };
SingleSelection.prototype.bind = function (container, $container) { SingleSelection.prototype.bind = function (container, $container) {
var self = this; var self = this;
@ -903,26 +904,26 @@ define('select2/selection/single',[
return; return;
} }
self.trigger("toggle", { self.trigger('toggle', {
originalEvent: evt originalEvent: evt
}); });
}); });
container.on("selection:update", function (params) { container.on('selection:update', function (params) {
self.update(params.data); self.update(params.data);
}) });
} };
SingleSelection.prototype.clear = function () { SingleSelection.prototype.clear = function () {
this.$selection.find(".rendered-selection").empty(); this.$selection.find('.rendered-selection').empty();
} };
SingleSelection.prototype.display = function (data) { SingleSelection.prototype.display = function (data) {
return data.text; return data.text;
} };
SingleSelection.prototype.update = function (data) { SingleSelection.prototype.update = function (data) {
if (data.length == 0) { if (data.length === 0) {
this.clear(); this.clear();
return; return;
} }
@ -931,8 +932,8 @@ define('select2/selection/single',[
var formatted = this.display(selection); var formatted = this.display(selection);
this.$selection.find(".rendered-selection").html(formatted); this.$selection.find('.rendered-selection').html(formatted);
} };
return SingleSelection; return SingleSelection;
}); });
@ -959,34 +960,34 @@ define('select2/selection/multiple',[
this.$selection = $selection; this.$selection = $selection;
return $selection; return $selection;
} };
MultipleSelection.prototype.bind = function (container, $container) { MultipleSelection.prototype.bind = function (container, $container) {
var self = this; var self = this;
this.$selection.on('click', function (evt) { this.$selection.on('click', function (evt) {
self.trigger("toggle", { self.trigger('toggle', {
originalEvent: evt originalEvent: evt
}); });
}); });
container.on("selection:update", function (params) { container.on('selection:update', function (params) {
self.update(params.data); self.update(params.data);
}); });
} };
MultipleSelection.prototype.clear = function () { MultipleSelection.prototype.clear = function () {
this.$selection.find(".rendered-selection").empty(); this.$selection.find('.rendered-selection').empty();
} };
MultipleSelection.prototype.display = function (data) { MultipleSelection.prototype.display = function (data) {
return data.text; return data.text;
} };
MultipleSelection.prototype.update = function (data) { MultipleSelection.prototype.update = function (data) {
this.clear(); this.clear();
if (data.length == 0) { if (data.length === 0) {
return; return;
} }
@ -1000,20 +1001,20 @@ define('select2/selection/multiple',[
var $selection = $('<ul class="choice"></ul>'); var $selection = $('<ul class="choice"></ul>');
$selection.text(formatted); $selection.text(formatted);
$selection.data("data", data); $selection.data('data', data);
$selections.push($selection); $selections.push($selection);
} }
this.$selection.find(".rendered-selection").append($selections); this.$selection.find('.rendered-selection').append($selections);
} };
return MultipleSelection; return MultipleSelection;
}); });
define('select2/data/array',[ define('select2/data/array',[
"./select", './select',
"../utils" '../utils'
], function (SelectAdapter, Utils) { ], function (SelectAdapter, Utils) {
function ArrayAdapter ($element, options) { function ArrayAdapter ($element, options) {
this.data = options.options.data; this.data = options.options.data;
@ -1026,7 +1027,7 @@ define('select2/data/array',[
ArrayAdapter.prototype.select = function (data) { ArrayAdapter.prototype.select = function (data) {
var self = this; var self = this;
this.$element.find("option").each(function () { this.$element.find('option').each(function () {
var $option = $(this); var $option = $(this);
var option = self.item($option); var option = self.item($option);
@ -1040,17 +1041,17 @@ define('select2/data/array',[
this.$element.append($option); this.$element.append($option);
ArrayAdapter.__super__.select.call(this, data); ArrayAdapter.__super__.select.call(this, data);
} };
ArrayAdapter.prototype.option = function (data) { ArrayAdapter.prototype.option = function (data) {
var $option = $("<option></option>"); var $option = $('<option></option>');
$option.text(data.text); $option.text(data.text);
$option.val(data.id); $option.val(data.id);
$option.data("data", data); $option.data('data', data);
return $option; return $option;
} };
ArrayAdapter.prototype.query = function (params, callback) { ArrayAdapter.prototype.query = function (params, callback) {
var matches = []; var matches = [];
@ -1065,22 +1066,22 @@ define('select2/data/array',[
}); });
callback(matches); callback(matches);
} };
return ArrayAdapter; return ArrayAdapter;
}); });
define('select2/data/ajax',[ define('select2/data/ajax',[
"./array", './array',
"../utils", '../utils',
"jquery" 'jquery'
], function (ArrayAdapter, Utils, $) { ], function (ArrayAdapter, Utils, $) {
function AjaxAdapter ($element, options) { function AjaxAdapter ($element, options) {
this.ajaxOptions = options.options.ajax; this.ajaxOptions = options.options.ajax;
this.processResults = this.ajaxOptions.processResults || this.processResults = this.ajaxOptions.processResults ||
function (results) { function (results) {
return results return results;
}; };
ArrayAdapter.__super__.constructor.call(this, $element, options); ArrayAdapter.__super__.constructor.call(this, $element, options);
@ -1093,14 +1094,14 @@ define('select2/data/ajax',[
var self = this; var self = this;
var options = $.extend({ var options = $.extend({
type: "GET", type: 'GET',
}, this.ajaxOptions); }, this.ajaxOptions);
if (typeof options.url === "function") { if (typeof options.url === 'function') {
options.url = options.url(params); options.url = options.url(params);
} }
if (typeof options.data === "function") { if (typeof options.data === 'function') {
options.data = options.data(params); options.data = options.data(params);
} }
@ -1109,8 +1110,6 @@ define('select2/data/ajax',[
$request.success(function (data) { $request.success(function (data) {
var results = self.processResults(data); var results = self.processResults(data);
console.log(results)
callback(results); callback(results);
}); });
}; };
@ -1147,8 +1146,8 @@ define('select2/options',[
} }
return Options; return Options;
}) });
;
define('select2/core',[ define('select2/core',[
'jquery', 'jquery',
'./options', './options',
@ -1159,7 +1158,7 @@ define('select2/core',[
options = options || {}; options = options || {};
options.multiple = options.multiple || $element.prop("multiple"); options.multiple = options.multiple || $element.prop('multiple');
this.options = new Options(options); this.options = new Options(options);
@ -1178,21 +1177,22 @@ define('select2/core',[
this.selection = new this.options.selectionAdapter($element, this.options); this.selection = new this.options.selectionAdapter($element, this.options);
var $selectionContainer = $container.find(".selection"); var $selectionContainer = $container.find('.selection');
var $selection = this.selection.render(); var $selection = this.selection.render();
$selectionContainer.append($selection); $selectionContainer.append($selection);
this.dropdown = new this.options.dropdownAdapter($element, this.options); this.dropdown = new this.options.dropdownAdapter($element, this.options);
var $dropdownContainer = $container.find(".dropdown"); var $dropdownContainer = $container.find('.dropdown');
var $dropdown = this.dropdown.render(); var $dropdown = this.dropdown.render();
$dropdownContainer.append($dropdown); $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(); var $results = this.results.render();
$resultsContainer.append($results); $resultsContainer.append($results);
@ -1205,48 +1205,48 @@ define('select2/core',[
this.selection.bind(this, $container); this.selection.bind(this, $container);
this.results.bind(this, $container); this.results.bind(this, $container);
this.$element.on("change", function () { this.$element.on('change', function () {
self.data.current(function (data) { self.data.current(function (data) {
self.trigger("selection:update", { self.trigger('selection:update', {
data: data data: data
}); });
}); });
}); });
this.selection.on("toggle", function () { this.selection.on('toggle', function () {
self.toggleDropdown(); self.toggleDropdown();
}); });
this.results.on("selected", function (params) { this.results.on('selected', function (params) {
self.trigger("select", params); self.trigger('select', params);
self.trigger("close"); self.trigger('close');
}); });
this.results.on("unselected", function (params) { this.results.on('unselected', function (params) {
self.trigger("unselect", params); self.trigger('unselect', params);
self.trigger("close"); self.trigger('close');
}); });
this.on("open", function () { this.on('open', function () {
$container.addClass("open"); $container.addClass('open');
}); });
this.on("close", function () { this.on('close', function () {
$container.removeClass("open"); $container.removeClass('open');
}); });
// Set the initial state // Set the initial state
this.data.current(function (initialData) { this.data.current(function (initialData) {
self.trigger("selection:update", { self.trigger('selection:update', {
data: initialData data: initialData
}); });
}); });
this.data.query({}, function (data) { this.data.query({}, function (data) {
self.results.trigger("results:all", data); self.results.trigger('results:all', data);
}); });
// Hide the original select // Hide the original select
@ -1257,12 +1257,12 @@ define('select2/core',[
Utils.Extend(Select2, Utils.Observable); Utils.Extend(Select2, Utils.Observable);
Select2.prototype.toggleDropdown = function () { Select2.prototype.toggleDropdown = function () {
if (this.$container.hasClass("open")) { if (this.$container.hasClass('open')) {
this.trigger("close"); this.trigger('close');
} else { } else {
this.trigger("open"); this.trigger('open');
}
} }
};
Select2.prototype.render = function () { Select2.prototype.render = function () {
var $container = $( var $container = $(

View File

@ -71,7 +71,7 @@ define([], function () {
var superMethod = superMethods[m]; var superMethod = superMethods[m];
DecoratedClass.prototype[superMethod] = DecoratedClass.prototype[superMethod] =
SuperClass.prototype[methodName]; SuperClass.prototype[superMethod];
} }
var calledMethod = function (methodName) { var calledMethod = function (methodName) {