|
@@ -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,38 +496,39 @@ 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 methodName = decoratedMethods[m];
|
|
|
|
|
|
+ var calledMethod = function (methodName) {
|
|
|
|
+ // Stub out the original method if it's not decorating an actual method
|
|
|
|
+ var originalMethod = function () {};
|
|
|
|
|
|
- function calledMethod (methodName) {
|
|
|
|
- // Stub out the original method if it's not decorating an actual method
|
|
|
|
- var originalMethod = function () {};
|
|
|
|
|
|
+ if (methodName in DecoratedClass.prototype) {
|
|
|
|
+ originalMethod = DecoratedClass.prototype[methodName];
|
|
|
|
+ }
|
|
|
|
|
|
- if (methodName in DecoratedClass.prototype) {
|
|
|
|
- originalMethod = DecoratedClass.prototype[methodName];
|
|
|
|
- }
|
|
|
|
|
|
+ var decoratedMethod = DecoratorClass.prototype[methodName];
|
|
|
|
|
|
- var decoratedMethod = DecoratorClass.prototype[methodName];
|
|
|
|
|
|
+ return function () {
|
|
|
|
+ var unshift = Array.prototype.unshift;
|
|
|
|
|
|
- return function () {
|
|
|
|
- var unshift = Array.prototype.unshift;
|
|
|
|
|
|
+ unshift.call(arguments, originalMethod);
|
|
|
|
|
|
- unshift.call(arguments, originalMethod);
|
|
|
|
|
|
+ return decoratedMethod.apply(this, arguments);
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
|
|
- return decoratedMethod.apply(this, arguments);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ for (var d = 0; d < decoratedMethods.length; d++) {
|
|
|
|
+ var decoratedMethod = decoratedMethods[d];
|
|
|
|
|
|
- DecoratedClass.prototype[methodName] = calledMethod(methodName);
|
|
|
|
|
|
+ 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) {
|
|
|
|
- this.invoke(this.listeners["*"], arguments);
|
|
|
|
|
|
+ if ('*' in this.listeners) {
|
|
|
|
+ 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");
|
|
|
|
- if ($this.hasClass("selected")) {
|
|
|
|
- self.trigger("unselected", {
|
|
|
|
|
|
+ var data = $this.data('data');
|
|
|
|
+ if ($this.hasClass('selected')) {
|
|
|
|
+ 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) {
|
|
|
|
- self.$results.find(".option.highlighted").removeClass("highlighted");
|
|
|
|
- $(this).addClass("highlighted");
|
|
|
|
|
|
+ this.$results.on('mouseenter', '.option', function (evt) {
|
|
|
|
+ self.$results.find('.option.highlighted').removeClass('highlighted');
|
|
|
|
+ $(this).addClass('highlighted');
|
|
});
|
|
});
|
|
|
|
|
|
- this.$results.on("mouseleave", ".option", function (evt) {
|
|
|
|
- $(this).removeClass("highlighted");
|
|
|
|
|
|
+ this.$results.on('mouseleave', '.option', function (evt) {
|
|
|
|
+ $(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",
|
|
|
|
- "../utils"
|
|
|
|
|
|
+ './select',
|
|
|
|
+ '../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",
|
|
|
|
- "../utils",
|
|
|
|
- "jquery"
|
|
|
|
|
|
+ './array',
|
|
|
|
+ '../utils',
|
|
|
|
+ '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) {
|
|
|
|
- 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
|
|
// 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")) {
|
|
|
|
- this.trigger("close");
|
|
|
|
|
|
+ if (this.$container.hasClass('open')) {
|
|
|
|
+ this.trigger('close');
|
|
} else {
|
|
} else {
|
|
- this.trigger("open");
|
|
|
|
|
|
+ this.trigger('open');
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
Select2.prototype.render = function () {
|
|
Select2.prototype.render = function () {
|
|
var $container = $(
|
|
var $container = $(
|