2014-10-15 05:12:57 +04:00
|
|
|
define([
|
|
|
|
'jquery',
|
2015-01-18 05:27:53 +03:00
|
|
|
'./select2/core',
|
|
|
|
'./select2/defaults'
|
|
|
|
], function ($, Select2, Defaults) {
|
2015-01-03 04:32:14 +03:00
|
|
|
// Force jQuery.mousewheel to be loaded if it hasn't already
|
|
|
|
try {
|
|
|
|
require('jquery.mousewheel');
|
|
|
|
} catch (Exception) { }
|
|
|
|
|
2014-10-15 05:12:57 +04:00
|
|
|
if ($.fn.select2 == null) {
|
|
|
|
$.fn.select2 = function (options) {
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
if (typeof options === 'object') {
|
|
|
|
this.each(function () {
|
2015-01-03 02:15:59 +03:00
|
|
|
var instanceOptions = $.extend({}, options, true);
|
|
|
|
|
|
|
|
var instance = new Select2($(this), instanceOptions);
|
2014-10-15 05:12:57 +04:00
|
|
|
});
|
2015-01-03 02:15:59 +03:00
|
|
|
|
|
|
|
return this;
|
2014-10-15 05:12:57 +04:00
|
|
|
} else if (typeof options === 'string') {
|
|
|
|
var instance = this.data('select2');
|
2014-10-21 04:29:23 +04:00
|
|
|
var args = Array.prototype.slice.call(arguments, 1);
|
2014-10-15 05:12:57 +04:00
|
|
|
|
2015-01-03 02:15:59 +03:00
|
|
|
return instance[options](args);
|
2014-10-15 05:12:57 +04:00
|
|
|
} else {
|
|
|
|
throw new Error('Invalid arguments for Select2: ' + options);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-01-18 05:27:53 +03:00
|
|
|
if ($.fn.select2.defaults == null) {
|
|
|
|
$.fn.select2.defaults = Defaults;
|
|
|
|
}
|
|
|
|
|
2014-10-15 05:12:57 +04:00
|
|
|
return Select2;
|
|
|
|
});
|