MailPoet Newsletters (New) - Version 3.0.9

Version Description

  • 2017-10-31 =
  • Improved: search forms in listings ignore preceding and trailing whitespace;
  • Fixed: tags aren't shown within categories for automated latest content posts anymore. Thanks Gregor!
  • Fixed: our subscription form no longer conflicts with themes/plugins that use jQuery Serialize Object function. Thanks Albert!
Download this release

Release Info

Developer wysija
Plugin Icon 128x128 MailPoet Newsletters (New)
Version 3.0.9
Comparing to
See all releases

Code changes from version 3.0.8 to 3.0.9

assets/js/{admin.7f0a02d1.js → admin.912a26a8.js} RENAMED
@@ -16763,7 +16763,7 @@ webpackJsonp([0],{
16763
  });
16764
  jQuery('#form_field_new').parsley().on('form:submit', function () {
16765
  // get data
16766
- var data = jQuery(this.$element).serializeObject();
16767
 
16768
  // save custom field
16769
  MailPoet.Ajax.post({
16763
  });
16764
  jQuery('#form_field_new').parsley().on('form:submit', function () {
16765
  // get data
16766
+ var data = jQuery(this.$element).mailpoetSerializeObject();
16767
 
16768
  // save custom field
16769
  MailPoet.Ajax.post({
assets/js/{admin_vendor.fa2d1dd7.js → admin_vendor.66f57ed3.js} RENAMED
@@ -33702,7 +33702,7 @@ webpackJsonp([1],[
33702
 
33703
  handleSearch: function handleSearch(e) {
33704
  e.preventDefault();
33705
- this.props.onSearch(this.refs.search.value);
33706
  },
33707
  componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
33708
  this.refs.search.value = nextProps.search;
@@ -34094,5752 +34094,5752 @@ webpackJsonp([1],[
34094
  /* 289 */
34095
  /***/ function(module, exports, __webpack_require__) {
34096
 
34097
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;var require;/*!
34098
- * Select2 4.0.4
34099
- * https://select2.github.io
34100
- *
34101
- * Released under the MIT license
34102
- * https://github.com/select2/select2/blob/master/LICENSE.md
34103
- */
34104
- (function (factory) {
34105
- if (true) {
34106
- // AMD. Register as an anonymous module.
34107
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(275)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
34108
- } else if (typeof module === 'object' && module.exports) {
34109
- // Node/CommonJS
34110
- module.exports = function (root, jQuery) {
34111
- if (jQuery === undefined) {
34112
- // require('jQuery') returns a factory that requires window to
34113
- // build a jQuery instance, we normalize how we use modules
34114
- // that require this pattern but the window provided is a noop
34115
- // if it's defined (how jquery works)
34116
- if (typeof window !== 'undefined') {
34117
- jQuery = require('jquery');
34118
- }
34119
- else {
34120
- jQuery = require('jquery')(root);
34121
- }
34122
- }
34123
- factory(jQuery);
34124
- return jQuery;
34125
- };
34126
- } else {
34127
- // Browser globals
34128
- factory(jQuery);
34129
- }
34130
- } (function (jQuery) {
34131
- // This is needed so we can catch the AMD loader configuration and use it
34132
- // The inner file should be wrapped (by `banner.start.js`) in a function that
34133
- // returns the AMD loader references.
34134
- var S2 =(function () {
34135
- // Restore the Select2 AMD loader so it can be used
34136
- // Needed mostly in the language files, where the loader is not inserted
34137
- if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
34138
- var S2 = jQuery.fn.select2.amd;
34139
- }
34140
- var S2;(function () { if (!S2 || !S2.requirejs) {
34141
- if (!S2) { S2 = {}; } else { require = S2; }
34142
- /**
34143
- * @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
34144
- * Released under MIT license, http://github.com/requirejs/almond/LICENSE
34145
- */
34146
- //Going sloppy to avoid 'use strict' string cost, but strict practices should
34147
- //be followed.
34148
- /*global setTimeout: false */
34149
-
34150
- var requirejs, require, define;
34151
- (function (undef) {
34152
- var main, req, makeMap, handlers,
34153
- defined = {},
34154
- waiting = {},
34155
- config = {},
34156
- defining = {},
34157
- hasOwn = Object.prototype.hasOwnProperty,
34158
- aps = [].slice,
34159
- jsSuffixRegExp = /\.js$/;
34160
-
34161
- function hasProp(obj, prop) {
34162
- return hasOwn.call(obj, prop);
34163
- }
34164
-
34165
- /**
34166
- * Given a relative module name, like ./something, normalize it to
34167
- * a real name that can be mapped to a path.
34168
- * @param {String} name the relative name
34169
- * @param {String} baseName a real name that the name arg is relative
34170
- * to.
34171
- * @returns {String} normalized name
34172
- */
34173
- function normalize(name, baseName) {
34174
- var nameParts, nameSegment, mapValue, foundMap, lastIndex,
34175
- foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
34176
- baseParts = baseName && baseName.split("/"),
34177
- map = config.map,
34178
- starMap = (map && map['*']) || {};
34179
-
34180
- //Adjust any relative paths.
34181
- if (name) {
34182
- name = name.split('/');
34183
- lastIndex = name.length - 1;
34184
-
34185
- // If wanting node ID compatibility, strip .js from end
34186
- // of IDs. Have to do this here, and not in nameToUrl
34187
- // because node allows either .js or non .js to map
34188
- // to same file.
34189
- if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
34190
- name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
34191
- }
34192
-
34193
- // Starts with a '.' so need the baseName
34194
- if (name[0].charAt(0) === '.' && baseParts) {
34195
- //Convert baseName to array, and lop off the last part,
34196
- //so that . matches that 'directory' and not name of the baseName's
34197
- //module. For instance, baseName of 'one/two/three', maps to
34198
- //'one/two/three.js', but we want the directory, 'one/two' for
34199
- //this normalization.
34200
- normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
34201
- name = normalizedBaseParts.concat(name);
34202
- }
34203
-
34204
- //start trimDots
34205
- for (i = 0; i < name.length; i++) {
34206
- part = name[i];
34207
- if (part === '.') {
34208
- name.splice(i, 1);
34209
- i -= 1;
34210
- } else if (part === '..') {
34211
- // If at the start, or previous value is still ..,
34212
- // keep them so that when converted to a path it may
34213
- // still work when converted to a path, even though
34214
- // as an ID it is less than ideal. In larger point
34215
- // releases, may be better to just kick out an error.
34216
- if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
34217
- continue;
34218
- } else if (i > 0) {
34219
- name.splice(i - 1, 2);
34220
- i -= 2;
34221
- }
34222
- }
34223
- }
34224
- //end trimDots
34225
-
34226
- name = name.join('/');
34227
- }
34228
-
34229
- //Apply map config if available.
34230
- if ((baseParts || starMap) && map) {
34231
- nameParts = name.split('/');
34232
-
34233
- for (i = nameParts.length; i > 0; i -= 1) {
34234
- nameSegment = nameParts.slice(0, i).join("/");
34235
-
34236
- if (baseParts) {
34237
- //Find the longest baseName segment match in the config.
34238
- //So, do joins on the biggest to smallest lengths of baseParts.
34239
- for (j = baseParts.length; j > 0; j -= 1) {
34240
- mapValue = map[baseParts.slice(0, j).join('/')];
34241
-
34242
- //baseName segment has config, find if it has one for
34243
- //this name.
34244
- if (mapValue) {
34245
- mapValue = mapValue[nameSegment];
34246
- if (mapValue) {
34247
- //Match, update name to the new value.
34248
- foundMap = mapValue;
34249
- foundI = i;
34250
- break;
34251
- }
34252
- }
34253
- }
34254
- }
34255
-
34256
- if (foundMap) {
34257
- break;
34258
- }
34259
-
34260
- //Check for a star map match, but just hold on to it,
34261
- //if there is a shorter segment match later in a matching
34262
- //config, then favor over this star map.
34263
- if (!foundStarMap && starMap && starMap[nameSegment]) {
34264
- foundStarMap = starMap[nameSegment];
34265
- starI = i;
34266
- }
34267
- }
34268
-
34269
- if (!foundMap && foundStarMap) {
34270
- foundMap = foundStarMap;
34271
- foundI = starI;
34272
- }
34273
-
34274
- if (foundMap) {
34275
- nameParts.splice(0, foundI, foundMap);
34276
- name = nameParts.join('/');
34277
- }
34278
- }
34279
-
34280
- return name;
34281
- }
34282
-
34283
- function makeRequire(relName, forceSync) {
34284
- return function () {
34285
- //A version of a require function that passes a moduleName
34286
- //value for items that may need to
34287
- //look up paths relative to the moduleName
34288
- var args = aps.call(arguments, 0);
34289
-
34290
- //If first arg is not require('string'), and there is only
34291
- //one arg, it is the array form without a callback. Insert
34292
- //a null so that the following concat is correct.
34293
- if (typeof args[0] !== 'string' && args.length === 1) {
34294
- args.push(null);
34295
- }
34296
- return req.apply(undef, args.concat([relName, forceSync]));
34297
- };
34298
- }
34299
-
34300
- function makeNormalize(relName) {
34301
- return function (name) {
34302
- return normalize(name, relName);
34303
- };
34304
- }
34305
-
34306
- function makeLoad(depName) {
34307
- return function (value) {
34308
- defined[depName] = value;
34309
- };
34310
- }
34311
-
34312
- function callDep(name) {
34313
- if (hasProp(waiting, name)) {
34314
- var args = waiting[name];
34315
- delete waiting[name];
34316
- defining[name] = true;
34317
- main.apply(undef, args);
34318
- }
34319
-
34320
- if (!hasProp(defined, name) && !hasProp(defining, name)) {
34321
- throw new Error('No ' + name);
34322
- }
34323
- return defined[name];
34324
- }
34325
-
34326
- //Turns a plugin!resource to [plugin, resource]
34327
- //with the plugin being undefined if the name
34328
- //did not have a plugin prefix.
34329
- function splitPrefix(name) {
34330
- var prefix,
34331
- index = name ? name.indexOf('!') : -1;
34332
- if (index > -1) {
34333
- prefix = name.substring(0, index);
34334
- name = name.substring(index + 1, name.length);
34335
- }
34336
- return [prefix, name];
34337
- }
34338
-
34339
- //Creates a parts array for a relName where first part is plugin ID,
34340
- //second part is resource ID. Assumes relName has already been normalized.
34341
- function makeRelParts(relName) {
34342
- return relName ? splitPrefix(relName) : [];
34343
- }
34344
-
34345
- /**
34346
- * Makes a name map, normalizing the name, and using a plugin
34347
- * for normalization if necessary. Grabs a ref to plugin
34348
- * too, as an optimization.
34349
- */
34350
- makeMap = function (name, relParts) {
34351
- var plugin,
34352
- parts = splitPrefix(name),
34353
- prefix = parts[0],
34354
- relResourceName = relParts[1];
34355
-
34356
- name = parts[1];
34357
-
34358
- if (prefix) {
34359
- prefix = normalize(prefix, relResourceName);
34360
- plugin = callDep(prefix);
34361
- }
34362
-
34363
- //Normalize according
34364
- if (prefix) {
34365
- if (plugin && plugin.normalize) {
34366
- name = plugin.normalize(name, makeNormalize(relResourceName));
34367
- } else {
34368
- name = normalize(name, relResourceName);
34369
- }
34370
- } else {
34371
- name = normalize(name, relResourceName);
34372
- parts = splitPrefix(name);
34373
- prefix = parts[0];
34374
- name = parts[1];
34375
- if (prefix) {
34376
- plugin = callDep(prefix);
34377
- }
34378
- }
34379
-
34380
- //Using ridiculous property names for space reasons
34381
- return {
34382
- f: prefix ? prefix + '!' + name : name, //fullName
34383
- n: name,
34384
- pr: prefix,
34385
- p: plugin
34386
- };
34387
- };
34388
-
34389
- function makeConfig(name) {
34390
- return function () {
34391
- return (config && config.config && config.config[name]) || {};
34392
- };
34393
- }
34394
-
34395
- handlers = {
34396
- require: function (name) {
34397
- return makeRequire(name);
34398
- },
34399
- exports: function (name) {
34400
- var e = defined[name];
34401
- if (typeof e !== 'undefined') {
34402
- return e;
34403
- } else {
34404
- return (defined[name] = {});
34405
- }
34406
- },
34407
- module: function (name) {
34408
- return {
34409
- id: name,
34410
- uri: '',
34411
- exports: defined[name],
34412
- config: makeConfig(name)
34413
- };
34414
- }
34415
- };
34416
-
34417
- main = function (name, deps, callback, relName) {
34418
- var cjsModule, depName, ret, map, i, relParts,
34419
- args = [],
34420
- callbackType = typeof callback,
34421
- usingExports;
34422
-
34423
- //Use name if no relName
34424
- relName = relName || name;
34425
- relParts = makeRelParts(relName);
34426
-
34427
- //Call the callback to define the module, if necessary.
34428
- if (callbackType === 'undefined' || callbackType === 'function') {
34429
- //Pull out the defined dependencies and pass the ordered
34430
- //values to the callback.
34431
- //Default to [require, exports, module] if no deps
34432
- deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
34433
- for (i = 0; i < deps.length; i += 1) {
34434
- map = makeMap(deps[i], relParts);
34435
- depName = map.f;
34436
-
34437
- //Fast path CommonJS standard dependencies.
34438
- if (depName === "require") {
34439
- args[i] = handlers.require(name);
34440
- } else if (depName === "exports") {
34441
- //CommonJS module spec 1.1
34442
- args[i] = handlers.exports(name);
34443
- usingExports = true;
34444
- } else if (depName === "module") {
34445
- //CommonJS module spec 1.1
34446
- cjsModule = args[i] = handlers.module(name);
34447
- } else if (hasProp(defined, depName) ||
34448
- hasProp(waiting, depName) ||
34449
- hasProp(defining, depName)) {
34450
- args[i] = callDep(depName);
34451
- } else if (map.p) {
34452
- map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
34453
- args[i] = defined[depName];
34454
- } else {
34455
- throw new Error(name + ' missing ' + depName);
34456
- }
34457
- }
34458
-
34459
- ret = callback ? callback.apply(defined[name], args) : undefined;
34460
-
34461
- if (name) {
34462
- //If setting exports via "module" is in play,
34463
- //favor that over return value and exports. After that,
34464
- //favor a non-undefined return value over exports use.
34465
- if (cjsModule && cjsModule.exports !== undef &&
34466
- cjsModule.exports !== defined[name]) {
34467
- defined[name] = cjsModule.exports;
34468
- } else if (ret !== undef || !usingExports) {
34469
- //Use the return value from the function.
34470
- defined[name] = ret;
34471
- }
34472
- }
34473
- } else if (name) {
34474
- //May just be an object definition for the module. Only
34475
- //worry about defining if have a module name.
34476
- defined[name] = callback;
34477
- }
34478
- };
34479
-
34480
- requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
34481
- if (typeof deps === "string") {
34482
- if (handlers[deps]) {
34483
- //callback in this case is really relName
34484
- return handlers[deps](callback);
34485
- }
34486
- //Just return the module wanted. In this scenario, the
34487
- //deps arg is the module name, and second arg (if passed)
34488
- //is just the relName.
34489
- //Normalize module name, if it contains . or ..
34490
- return callDep(makeMap(deps, makeRelParts(callback)).f);
34491
- } else if (!deps.splice) {
34492
- //deps is a config object, not an array.
34493
- config = deps;
34494
- if (config.deps) {
34495
- req(config.deps, config.callback);
34496
- }
34497
- if (!callback) {
34498
- return;
34499
- }
34500
-
34501
- if (callback.splice) {
34502
- //callback is an array, which means it is a dependency list.
34503
- //Adjust args if there are dependencies
34504
- deps = callback;
34505
- callback = relName;
34506
- relName = null;
34507
- } else {
34508
- deps = undef;
34509
- }
34510
- }
34511
-
34512
- //Support require(['a'])
34513
- callback = callback || function () {};
34514
-
34515
- //If relName is a function, it is an errback handler,
34516
- //so remove it.
34517
- if (typeof relName === 'function') {
34518
- relName = forceSync;
34519
- forceSync = alt;
34520
- }
34521
-
34522
- //Simulate async callback;
34523
- if (forceSync) {
34524
- main(undef, deps, callback, relName);
34525
- } else {
34526
- //Using a non-zero value because of concern for what old browsers
34527
- //do, and latest browsers "upgrade" to 4 if lower value is used:
34528
- //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
34529
- //If want a value immediately, use require('id') instead -- something
34530
- //that works in almond on the global level, but not guaranteed and
34531
- //unlikely to work in other AMD implementations.
34532
- setTimeout(function () {
34533
- main(undef, deps, callback, relName);
34534
- }, 4);
34535
- }
34536
-
34537
- return req;
34538
- };
34539
-
34540
- /**
34541
- * Just drops the config on the floor, but returns req in case
34542
- * the config return value is used.
34543
- */
34544
- req.config = function (cfg) {
34545
- return req(cfg);
34546
- };
34547
-
34548
- /**
34549
- * Expose module registry for debugging and tooling
34550
- */
34551
- requirejs._defined = defined;
34552
-
34553
- define = function (name, deps, callback) {
34554
- if (typeof name !== 'string') {
34555
- throw new Error('See almond README: incorrect module build, no module name');
34556
- }
34557
-
34558
- //This module may not have dependencies
34559
- if (!deps.splice) {
34560
- //deps is not an array, so probably means
34561
- //an object literal or factory function for
34562
- //the value. Adjust args.
34563
- callback = deps;
34564
- deps = [];
34565
- }
34566
-
34567
- if (!hasProp(defined, name) && !hasProp(waiting, name)) {
34568
- waiting[name] = [name, deps, callback];
34569
- }
34570
- };
34571
-
34572
- define.amd = {
34573
- jQuery: true
34574
- };
34575
- }());
34576
-
34577
- S2.requirejs = requirejs;S2.require = require;S2.define = define;
34578
- }
34579
- }());
34580
- S2.define("almond", function(){});
34581
-
34582
- /* global jQuery:false, $:false */
34583
- S2.define('jquery',[],function () {
34584
- var _$ = jQuery || $;
34585
-
34586
- if (_$ == null && console && console.error) {
34587
- console.error(
34588
- 'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
34589
- 'found. Make sure that you are including jQuery before Select2 on your ' +
34590
- 'web page.'
34591
- );
34592
- }
34593
-
34594
- return _$;
34595
- });
34596
-
34597
- S2.define('select2/utils',[
34598
- 'jquery'
34599
- ], function ($) {
34600
- var Utils = {};
34601
-
34602
- Utils.Extend = function (ChildClass, SuperClass) {
34603
- var __hasProp = {}.hasOwnProperty;
34604
-
34605
- function BaseConstructor () {
34606
- this.constructor = ChildClass;
34607
- }
34608
-
34609
- for (var key in SuperClass) {
34610
- if (__hasProp.call(SuperClass, key)) {
34611
- ChildClass[key] = SuperClass[key];
34612
- }
34613
- }
34614
-
34615
- BaseConstructor.prototype = SuperClass.prototype;
34616
- ChildClass.prototype = new BaseConstructor();
34617
- ChildClass.__super__ = SuperClass.prototype;
34618
-
34619
- return ChildClass;
34620
- };
34621
-
34622
- function getMethods (theClass) {
34623
- var proto = theClass.prototype;
34624
-
34625
- var methods = [];
34626
-
34627
- for (var methodName in proto) {
34628
- var m = proto[methodName];
34629
-
34630
- if (typeof m !== 'function') {
34631
- continue;
34632
- }
34633
-
34634
- if (methodName === 'constructor') {
34635
- continue;
34636
- }
34637
-
34638
- methods.push(methodName);
34639
- }
34640
-
34641
- return methods;
34642
- }
34643
-
34644
- Utils.Decorate = function (SuperClass, DecoratorClass) {
34645
- var decoratedMethods = getMethods(DecoratorClass);
34646
- var superMethods = getMethods(SuperClass);
34647
-
34648
- function DecoratedClass () {
34649
- var unshift = Array.prototype.unshift;
34650
-
34651
- var argCount = DecoratorClass.prototype.constructor.length;
34652
-
34653
- var calledConstructor = SuperClass.prototype.constructor;
34654
-
34655
- if (argCount > 0) {
34656
- unshift.call(arguments, SuperClass.prototype.constructor);
34657
-
34658
- calledConstructor = DecoratorClass.prototype.constructor;
34659
- }
34660
-
34661
- calledConstructor.apply(this, arguments);
34662
- }
34663
-
34664
- DecoratorClass.displayName = SuperClass.displayName;
34665
-
34666
- function ctr () {
34667
- this.constructor = DecoratedClass;
34668
- }
34669
-
34670
- DecoratedClass.prototype = new ctr();
34671
-
34672
- for (var m = 0; m < superMethods.length; m++) {
34673
- var superMethod = superMethods[m];
34674
-
34675
- DecoratedClass.prototype[superMethod] =
34676
- SuperClass.prototype[superMethod];
34677
- }
34678
-
34679
- var calledMethod = function (methodName) {
34680
- // Stub out the original method if it's not decorating an actual method
34681
- var originalMethod = function () {};
34682
-
34683
- if (methodName in DecoratedClass.prototype) {
34684
- originalMethod = DecoratedClass.prototype[methodName];
34685
- }
34686
-
34687
- var decoratedMethod = DecoratorClass.prototype[methodName];
34688
-
34689
- return function () {
34690
- var unshift = Array.prototype.unshift;
34691
-
34692
- unshift.call(arguments, originalMethod);
34693
-
34694
- return decoratedMethod.apply(this, arguments);
34695
- };
34696
- };
34697
-
34698
- for (var d = 0; d < decoratedMethods.length; d++) {
34699
- var decoratedMethod = decoratedMethods[d];
34700
-
34701
- DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
34702
- }
34703
-
34704
- return DecoratedClass;
34705
- };
34706
-
34707
- var Observable = function () {
34708
- this.listeners = {};
34709
- };
34710
-
34711
- Observable.prototype.on = function (event, callback) {
34712
- this.listeners = this.listeners || {};
34713
-
34714
- if (event in this.listeners) {
34715
- this.listeners[event].push(callback);
34716
- } else {
34717
- this.listeners[event] = [callback];
34718
- }
34719
- };
34720
-
34721
- Observable.prototype.trigger = function (event) {
34722
- var slice = Array.prototype.slice;
34723
- var params = slice.call(arguments, 1);
34724
-
34725
- this.listeners = this.listeners || {};
34726
-
34727
- // Params should always come in as an array
34728
- if (params == null) {
34729
- params = [];
34730
- }
34731
-
34732
- // If there are no arguments to the event, use a temporary object
34733
- if (params.length === 0) {
34734
- params.push({});
34735
- }
34736
-
34737
- // Set the `_type` of the first object to the event
34738
- params[0]._type = event;
34739
-
34740
- if (event in this.listeners) {
34741
- this.invoke(this.listeners[event], slice.call(arguments, 1));
34742
- }
34743
-
34744
- if ('*' in this.listeners) {
34745
- this.invoke(this.listeners['*'], arguments);
34746
- }
34747
- };
34748
-
34749
- Observable.prototype.invoke = function (listeners, params) {
34750
- for (var i = 0, len = listeners.length; i < len; i++) {
34751
- listeners[i].apply(this, params);
34752
- }
34753
- };
34754
-
34755
- Utils.Observable = Observable;
34756
-
34757
- Utils.generateChars = function (length) {
34758
- var chars = '';
34759
-
34760
- for (var i = 0; i < length; i++) {
34761
- var randomChar = Math.floor(Math.random() * 36);
34762
- chars += randomChar.toString(36);
34763
- }
34764
-
34765
- return chars;
34766
- };
34767
-
34768
- Utils.bind = function (func, context) {
34769
- return function () {
34770
- func.apply(context, arguments);
34771
- };
34772
- };
34773
-
34774
- Utils._convertData = function (data) {
34775
- for (var originalKey in data) {
34776
- var keys = originalKey.split('-');
34777
-
34778
- var dataLevel = data;
34779
-
34780
- if (keys.length === 1) {
34781
- continue;
34782
- }
34783
-
34784
- for (var k = 0; k < keys.length; k++) {
34785
- var key = keys[k];
34786
-
34787
- // Lowercase the first letter
34788
- // By default, dash-separated becomes camelCase
34789
- key = key.substring(0, 1).toLowerCase() + key.substring(1);
34790
-
34791
- if (!(key in dataLevel)) {
34792
- dataLevel[key] = {};
34793
- }
34794
-
34795
- if (k == keys.length - 1) {
34796
- dataLevel[key] = data[originalKey];
34797
- }
34798
-
34799
- dataLevel = dataLevel[key];
34800
- }
34801
-
34802
- delete data[originalKey];
34803
- }
34804
-
34805
- return data;
34806
- };
34807
-
34808
- Utils.hasScroll = function (index, el) {
34809
- // Adapted from the function created by @ShadowScripter
34810
- // and adapted by @BillBarry on the Stack Exchange Code Review website.
34811
- // The original code can be found at
34812
- // http://codereview.stackexchange.com/q/13338
34813
- // and was designed to be used with the Sizzle selector engine.
34814
-
34815
- var $el = $(el);
34816
- var overflowX = el.style.overflowX;
34817
- var overflowY = el.style.overflowY;
34818
-
34819
- //Check both x and y declarations
34820
- if (overflowX === overflowY &&
34821
- (overflowY === 'hidden' || overflowY === 'visible')) {
34822
- return false;
34823
- }
34824
-
34825
- if (overflowX === 'scroll' || overflowY === 'scroll') {
34826
- return true;
34827
- }
34828
-
34829
- return ($el.innerHeight() < el.scrollHeight ||
34830
- $el.innerWidth() < el.scrollWidth);
34831
- };
34832
-
34833
- Utils.escapeMarkup = function (markup) {
34834
- var replaceMap = {
34835
- '\\': '&#92;',
34836
- '&': '&amp;',
34837
- '<': '&lt;',
34838
- '>': '&gt;',
34839
- '"': '&quot;',
34840
- '\'': '&#39;',
34841
- '/': '&#47;'
34842
- };
34843
-
34844
- // Do not try to escape the markup if it's not a string
34845
- if (typeof markup !== 'string') {
34846
- return markup;
34847
- }
34848
-
34849
- return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
34850
- return replaceMap[match];
34851
- });
34852
- };
34853
-
34854
- // Append an array of jQuery nodes to a given element.
34855
- Utils.appendMany = function ($element, $nodes) {
34856
- // jQuery 1.7.x does not support $.fn.append() with an array
34857
- // Fall back to a jQuery object collection using $.fn.add()
34858
- if ($.fn.jquery.substr(0, 3) === '1.7') {
34859
- var $jqNodes = $();
34860
-
34861
- $.map($nodes, function (node) {
34862
- $jqNodes = $jqNodes.add(node);
34863
- });
34864
-
34865
- $nodes = $jqNodes;
34866
- }
34867
-
34868
- $element.append($nodes);
34869
- };
34870
-
34871
- return Utils;
34872
- });
34873
-
34874
- S2.define('select2/results',[
34875
- 'jquery',
34876
- './utils'
34877
- ], function ($, Utils) {
34878
- function Results ($element, options, dataAdapter) {
34879
- this.$element = $element;
34880
- this.data = dataAdapter;
34881
- this.options = options;
34882
-
34883
- Results.__super__.constructor.call(this);
34884
- }
34885
-
34886
- Utils.Extend(Results, Utils.Observable);
34887
-
34888
- Results.prototype.render = function () {
34889
- var $results = $(
34890
- '<ul class="select2-results__options" role="tree"></ul>'
34891
- );
34892
-
34893
- if (this.options.get('multiple')) {
34894
- $results.attr('aria-multiselectable', 'true');
34895
- }
34896
-
34897
- this.$results = $results;
34898
-
34899
- return $results;
34900
- };
34901
-
34902
- Results.prototype.clear = function () {
34903
- this.$results.empty();
34904
- };
34905
-
34906
- Results.prototype.displayMessage = function (params) {
34907
- var escapeMarkup = this.options.get('escapeMarkup');
34908
-
34909
- this.clear();
34910
- this.hideLoading();
34911
-
34912
- var $message = $(
34913
- '<li role="treeitem" aria-live="assertive"' +
34914
- ' class="select2-results__option"></li>'
34915
- );
34916
-
34917
- var message = this.options.get('translations').get(params.message);
34918
-
34919
- $message.append(
34920
- escapeMarkup(
34921
- message(params.args)
34922
- )
34923
- );
34924
-
34925
- $message[0].className += ' select2-results__message';
34926
-
34927
- this.$results.append($message);
34928
- };
34929
-
34930
- Results.prototype.hideMessages = function () {
34931
- this.$results.find('.select2-results__message').remove();
34932
- };
34933
-
34934
- Results.prototype.append = function (data) {
34935
- this.hideLoading();
34936
-
34937
- var $options = [];
34938
-
34939
- if (data.results == null || data.results.length === 0) {
34940
- if (this.$results.children().length === 0) {
34941
- this.trigger('results:message', {
34942
- message: 'noResults'
34943
- });
34944
- }
34945
-
34946
- return;
34947
- }
34948
-
34949
- data.results = this.sort(data.results);
34950
-
34951
- for (var d = 0; d < data.results.length; d++) {
34952
- var item = data.results[d];
34953
-
34954
- var $option = this.option(item);
34955
-
34956
- $options.push($option);
34957
- }
34958
-
34959
- this.$results.append($options);
34960
- };
34961
-
34962
- Results.prototype.position = function ($results, $dropdown) {
34963
- var $resultsContainer = $dropdown.find('.select2-results');
34964
- $resultsContainer.append($results);
34965
- };
34966
-
34967
- Results.prototype.sort = function (data) {
34968
- var sorter = this.options.get('sorter');
34969
-
34970
- return sorter(data);
34971
- };
34972
-
34973
- Results.prototype.highlightFirstItem = function () {
34974
- var $options = this.$results
34975
- .find('.select2-results__option[aria-selected]');
34976
-
34977
- var $selected = $options.filter('[aria-selected=true]');
34978
-
34979
- // Check if there are any selected options
34980
- if ($selected.length > 0) {
34981
- // If there are selected options, highlight the first
34982
- $selected.first().trigger('mouseenter');
34983
- } else {
34984
- // If there are no selected options, highlight the first option
34985
- // in the dropdown
34986
- $options.first().trigger('mouseenter');
34987
- }
34988
-
34989
- this.ensureHighlightVisible();
34990
- };
34991
-
34992
- Results.prototype.setClasses = function () {
34993
- var self = this;
34994
-
34995
- this.data.current(function (selected) {
34996
- var selectedIds = $.map(selected, function (s) {
34997
- return s.id.toString();
34998
- });
34999
-
35000
- var $options = self.$results
35001
- .find('.select2-results__option[aria-selected]');
35002
-
35003
- $options.each(function () {
35004
- var $option = $(this);
35005
-
35006
- var item = $.data(this, 'data');
35007
-
35008
- // id needs to be converted to a string when comparing
35009
- var id = '' + item.id;
35010
-
35011
- if ((item.element != null && item.element.selected) ||
35012
- (item.element == null && $.inArray(id, selectedIds) > -1)) {
35013
- $option.attr('aria-selected', 'true');
35014
- } else {
35015
- $option.attr('aria-selected', 'false');
35016
- }
35017
- });
35018
-
35019
- });
35020
- };
35021
-
35022
- Results.prototype.showLoading = function (params) {
35023
- this.hideLoading();
35024
-
35025
- var loadingMore = this.options.get('translations').get('searching');
35026
-
35027
- var loading = {
35028
- disabled: true,
35029
- loading: true,
35030
- text: loadingMore(params)
35031
- };
35032
- var $loading = this.option(loading);
35033
- $loading.className += ' loading-results';
35034
-
35035
- this.$results.prepend($loading);
35036
- };
35037
-
35038
- Results.prototype.hideLoading = function () {
35039
- this.$results.find('.loading-results').remove();
35040
- };
35041
-
35042
- Results.prototype.option = function (data) {
35043
- var option = document.createElement('li');
35044
- option.className = 'select2-results__option';
35045
-
35046
- var attrs = {
35047
- 'role': 'treeitem',
35048
- 'aria-selected': 'false'
35049
- };
35050
-
35051
- if (data.disabled) {
35052
- delete attrs['aria-selected'];
35053
- attrs['aria-disabled'] = 'true';
35054
- }
35055
-
35056
- if (data.id == null) {
35057
- delete attrs['aria-selected'];
35058
- }
35059
-
35060
- if (data._resultId != null) {
35061
- option.id = data._resultId;
35062
- }
35063
-
35064
- if (data.title) {
35065
- option.title = data.title;
35066
- }
35067
-
35068
- if (data.children) {
35069
- attrs.role = 'group';
35070
- attrs['aria-label'] = data.text;
35071
- delete attrs['aria-selected'];
35072
- }
35073
-
35074
- for (var attr in attrs) {
35075
- var val = attrs[attr];
35076
-
35077
- option.setAttribute(attr, val);
35078
- }
35079
-
35080
- if (data.children) {
35081
- var $option = $(option);
35082
-
35083
- var label = document.createElement('strong');
35084
- label.className = 'select2-results__group';
35085
-
35086
- var $label = $(label);
35087
- this.template(data, label);
35088
-
35089
- var $children = [];
35090
-
35091
- for (var c = 0; c < data.children.length; c++) {
35092
- var child = data.children[c];
35093
-
35094
- var $child = this.option(child);
35095
-
35096
- $children.push($child);
35097
- }
35098
-
35099
- var $childrenContainer = $('<ul></ul>', {
35100
- 'class': 'select2-results__options select2-results__options--nested'
35101
- });
35102
-
35103
- $childrenContainer.append($children);
35104
-
35105
- $option.append(label);
35106
- $option.append($childrenContainer);
35107
- } else {
35108
- this.template(data, option);
35109
- }
35110
-
35111
- $.data(option, 'data', data);
35112
-
35113
- return option;
35114
- };
35115
-
35116
- Results.prototype.bind = function (container, $container) {
35117
- var self = this;
35118
-
35119
- var id = container.id + '-results';
35120
-
35121
- this.$results.attr('id', id);
35122
-
35123
- container.on('results:all', function (params) {
35124
- self.clear();
35125
- self.append(params.data);
35126
-
35127
- if (container.isOpen()) {
35128
- self.setClasses();
35129
- self.highlightFirstItem();
35130
- }
35131
- });
35132
-
35133
- container.on('results:append', function (params) {
35134
- self.append(params.data);
35135
-
35136
- if (container.isOpen()) {
35137
- self.setClasses();
35138
- }
35139
- });
35140
-
35141
- container.on('query', function (params) {
35142
- self.hideMessages();
35143
- self.showLoading(params);
35144
- });
35145
-
35146
- container.on('select', function () {
35147
- if (!container.isOpen()) {
35148
- return;
35149
- }
35150
-
35151
- self.setClasses();
35152
- self.highlightFirstItem();
35153
- });
35154
-
35155
- container.on('unselect', function () {
35156
- if (!container.isOpen()) {
35157
- return;
35158
- }
35159
-
35160
- self.setClasses();
35161
- self.highlightFirstItem();
35162
- });
35163
-
35164
- container.on('open', function () {
35165
- // When the dropdown is open, aria-expended="true"
35166
- self.$results.attr('aria-expanded', 'true');
35167
- self.$results.attr('aria-hidden', 'false');
35168
-
35169
- self.setClasses();
35170
- self.ensureHighlightVisible();
35171
- });
35172
-
35173
- container.on('close', function () {
35174
- // When the dropdown is closed, aria-expended="false"
35175
- self.$results.attr('aria-expanded', 'false');
35176
- self.$results.attr('aria-hidden', 'true');
35177
- self.$results.removeAttr('aria-activedescendant');
35178
- });
35179
-
35180
- container.on('results:toggle', function () {
35181
- var $highlighted = self.getHighlightedResults();
35182
-
35183
- if ($highlighted.length === 0) {
35184
- return;
35185
- }
35186
-
35187
- $highlighted.trigger('mouseup');
35188
- });
35189
-
35190
- container.on('results:select', function () {
35191
- var $highlighted = self.getHighlightedResults();
35192
-
35193
- if ($highlighted.length === 0) {
35194
- return;
35195
- }
35196
-
35197
- var data = $highlighted.data('data');
35198
-
35199
- if ($highlighted.attr('aria-selected') == 'true') {
35200
- self.trigger('close', {});
35201
- } else {
35202
- self.trigger('select', {
35203
- data: data
35204
- });
35205
- }
35206
- });
35207
-
35208
- container.on('results:previous', function () {
35209
- var $highlighted = self.getHighlightedResults();
35210
-
35211
- var $options = self.$results.find('[aria-selected]');
35212
-
35213
- var currentIndex = $options.index($highlighted);
35214
-
35215
- // If we are already at te top, don't move further
35216
- if (currentIndex === 0) {
35217
- return;
35218
- }
35219
-
35220
- var nextIndex = currentIndex - 1;
35221
-
35222
- // If none are highlighted, highlight the first
35223
- if ($highlighted.length === 0) {
35224
- nextIndex = 0;
35225
- }
35226
-
35227
- var $next = $options.eq(nextIndex);
35228
-
35229
- $next.trigger('mouseenter');
35230
-
35231
- var currentOffset = self.$results.offset().top;
35232
- var nextTop = $next.offset().top;
35233
- var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
35234
-
35235
- if (nextIndex === 0) {
35236
- self.$results.scrollTop(0);
35237
- } else if (nextTop - currentOffset < 0) {
35238
- self.$results.scrollTop(nextOffset);
35239
- }
35240
- });
35241
-
35242
- container.on('results:next', function () {
35243
- var $highlighted = self.getHighlightedResults();
35244
-
35245
- var $options = self.$results.find('[aria-selected]');
35246
-
35247
- var currentIndex = $options.index($highlighted);
35248
-
35249
- var nextIndex = currentIndex + 1;
35250
-
35251
- // If we are at the last option, stay there
35252
- if (nextIndex >= $options.length) {
35253
- return;
35254
- }
35255
-
35256
- var $next = $options.eq(nextIndex);
35257
-
35258
- $next.trigger('mouseenter');
35259
-
35260
- var currentOffset = self.$results.offset().top +
35261
- self.$results.outerHeight(false);
35262
- var nextBottom = $next.offset().top + $next.outerHeight(false);
35263
- var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
35264
-
35265
- if (nextIndex === 0) {
35266
- self.$results.scrollTop(0);
35267
- } else if (nextBottom > currentOffset) {
35268
- self.$results.scrollTop(nextOffset);
35269
- }
35270
- });
35271
-
35272
- container.on('results:focus', function (params) {
35273
- params.element.addClass('select2-results__option--highlighted');
35274
- });
35275
-
35276
- container.on('results:message', function (params) {
35277
- self.displayMessage(params);
35278
- });
35279
-
35280
- if ($.fn.mousewheel) {
35281
- this.$results.on('mousewheel', function (e) {
35282
- var top = self.$results.scrollTop();
35283
-
35284
- var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
35285
-
35286
- var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
35287
- var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
35288
-
35289
- if (isAtTop) {
35290
- self.$results.scrollTop(0);
35291
-
35292
- e.preventDefault();
35293
- e.stopPropagation();
35294
- } else if (isAtBottom) {
35295
- self.$results.scrollTop(
35296
- self.$results.get(0).scrollHeight - self.$results.height()
35297
- );
35298
-
35299
- e.preventDefault();
35300
- e.stopPropagation();
35301
- }
35302
- });
35303
- }
35304
-
35305
- this.$results.on('mouseup', '.select2-results__option[aria-selected]',
35306
- function (evt) {
35307
- var $this = $(this);
35308
-
35309
- var data = $this.data('data');
35310
-
35311
- if ($this.attr('aria-selected') === 'true') {
35312
- if (self.options.get('multiple')) {
35313
- self.trigger('unselect', {
35314
- originalEvent: evt,
35315
- data: data
35316
- });
35317
- } else {
35318
- self.trigger('close', {});
35319
- }
35320
-
35321
- return;
35322
- }
35323
-
35324
- self.trigger('select', {
35325
- originalEvent: evt,
35326
- data: data
35327
- });
35328
- });
35329
-
35330
- this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
35331
- function (evt) {
35332
- var data = $(this).data('data');
35333
-
35334
- self.getHighlightedResults()
35335
- .removeClass('select2-results__option--highlighted');
35336
-
35337
- self.trigger('results:focus', {
35338
- data: data,
35339
- element: $(this)
35340
- });
35341
- });
35342
- };
35343
-
35344
- Results.prototype.getHighlightedResults = function () {
35345
- var $highlighted = this.$results
35346
- .find('.select2-results__option--highlighted');
35347
-
35348
- return $highlighted;
35349
- };
35350
-
35351
- Results.prototype.destroy = function () {
35352
- this.$results.remove();
35353
- };
35354
-
35355
- Results.prototype.ensureHighlightVisible = function () {
35356
- var $highlighted = this.getHighlightedResults();
35357
-
35358
- if ($highlighted.length === 0) {
35359
- return;
35360
- }
35361
-
35362
- var $options = this.$results.find('[aria-selected]');
35363
-
35364
- var currentIndex = $options.index($highlighted);
35365
-
35366
- var currentOffset = this.$results.offset().top;
35367
- var nextTop = $highlighted.offset().top;
35368
- var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
35369
-
35370
- var offsetDelta = nextTop - currentOffset;
35371
- nextOffset -= $highlighted.outerHeight(false) * 2;
35372
-
35373
- if (currentIndex <= 2) {
35374
- this.$results.scrollTop(0);
35375
- } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
35376
- this.$results.scrollTop(nextOffset);
35377
- }
35378
- };
35379
-
35380
- Results.prototype.template = function (result, container) {
35381
- var template = this.options.get('templateResult');
35382
- var escapeMarkup = this.options.get('escapeMarkup');
35383
-
35384
- var content = template(result, container);
35385
-
35386
- if (content == null) {
35387
- container.style.display = 'none';
35388
- } else if (typeof content === 'string') {
35389
- container.innerHTML = escapeMarkup(content);
35390
- } else {
35391
- $(container).append(content);
35392
- }
35393
- };
35394
-
35395
- return Results;
35396
- });
35397
-
35398
- S2.define('select2/keys',[
35399
-
35400
- ], function () {
35401
- var KEYS = {
35402
- BACKSPACE: 8,
35403
- TAB: 9,
35404
- ENTER: 13,
35405
- SHIFT: 16,
35406
- CTRL: 17,
35407
- ALT: 18,
35408
- ESC: 27,
35409
- SPACE: 32,
35410
- PAGE_UP: 33,
35411
- PAGE_DOWN: 34,
35412
- END: 35,
35413
- HOME: 36,
35414
- LEFT: 37,
35415
- UP: 38,
35416
- RIGHT: 39,
35417
- DOWN: 40,
35418
- DELETE: 46
35419
- };
35420
-
35421
- return KEYS;
35422
- });
35423
-
35424
- S2.define('select2/selection/base',[
35425
- 'jquery',
35426
- '../utils',
35427
- '../keys'
35428
- ], function ($, Utils, KEYS) {
35429
- function BaseSelection ($element, options) {
35430
- this.$element = $element;
35431
- this.options = options;
35432
-
35433
- BaseSelection.__super__.constructor.call(this);
35434
- }
35435
-
35436
- Utils.Extend(BaseSelection, Utils.Observable);
35437
-
35438
- BaseSelection.prototype.render = function () {
35439
- var $selection = $(
35440
- '<span class="select2-selection" role="combobox" ' +
35441
- ' aria-haspopup="true" aria-expanded="false">' +
35442
- '</span>'
35443
- );
35444
-
35445
- this._tabindex = 0;
35446
-
35447
- if (this.$element.data('old-tabindex') != null) {
35448
- this._tabindex = this.$element.data('old-tabindex');
35449
- } else if (this.$element.attr('tabindex') != null) {
35450
- this._tabindex = this.$element.attr('tabindex');
35451
- }
35452
-
35453
- $selection.attr('title', this.$element.attr('title'));
35454
- $selection.attr('tabindex', this._tabindex);
35455
-
35456
- this.$selection = $selection;
35457
-
35458
- return $selection;
35459
- };
35460
-
35461
- BaseSelection.prototype.bind = function (container, $container) {
35462
- var self = this;
35463
-
35464
- var id = container.id + '-container';
35465
- var resultsId = container.id + '-results';
35466
-
35467
- this.container = container;
35468
-
35469
- this.$selection.on('focus', function (evt) {
35470
- self.trigger('focus', evt);
35471
- });
35472
-
35473
- this.$selection.on('blur', function (evt) {
35474
- self._handleBlur(evt);
35475
- });
35476
-
35477
- this.$selection.on('keydown', function (evt) {
35478
- self.trigger('keypress', evt);
35479
-
35480
- if (evt.which === KEYS.SPACE) {
35481
- evt.preventDefault();
35482
- }
35483
- });
35484
-
35485
- container.on('results:focus', function (params) {
35486
- self.$selection.attr('aria-activedescendant', params.data._resultId);
35487
- });
35488
-
35489
- container.on('selection:update', function (params) {
35490
- self.update(params.data);
35491
- });
35492
-
35493
- container.on('open', function () {
35494
- // When the dropdown is open, aria-expanded="true"
35495
- self.$selection.attr('aria-expanded', 'true');
35496
- self.$selection.attr('aria-owns', resultsId);
35497
-
35498
- self._attachCloseHandler(container);
35499
- });
35500
-
35501
- container.on('close', function () {
35502
- // When the dropdown is closed, aria-expanded="false"
35503
- self.$selection.attr('aria-expanded', 'false');
35504
- self.$selection.removeAttr('aria-activedescendant');
35505
- self.$selection.removeAttr('aria-owns');
35506
-
35507
- self.$selection.focus();
35508
-
35509
- self._detachCloseHandler(container);
35510
- });
35511
-
35512
- container.on('enable', function () {
35513
- self.$selection.attr('tabindex', self._tabindex);
35514
- });
35515
-
35516
- container.on('disable', function () {
35517
- self.$selection.attr('tabindex', '-1');
35518
- });
35519
- };
35520
-
35521
- BaseSelection.prototype._handleBlur = function (evt) {
35522
- var self = this;
35523
-
35524
- // This needs to be delayed as the active element is the body when the tab
35525
- // key is pressed, possibly along with others.
35526
- window.setTimeout(function () {
35527
- // Don't trigger `blur` if the focus is still in the selection
35528
- if (
35529
- (document.activeElement == self.$selection[0]) ||
35530
- ($.contains(self.$selection[0], document.activeElement))
35531
- ) {
35532
- return;
35533
- }
35534
-
35535
- self.trigger('blur', evt);
35536
- }, 1);
35537
- };
35538
-
35539
- BaseSelection.prototype._attachCloseHandler = function (container) {
35540
- var self = this;
35541
-
35542
- $(document.body).on('mousedown.select2.' + container.id, function (e) {
35543
- var $target = $(e.target);
35544
-
35545
- var $select = $target.closest('.select2');
35546
-
35547
- var $all = $('.select2.select2-container--open');
35548
-
35549
- $all.each(function () {
35550
- var $this = $(this);
35551
-
35552
- if (this == $select[0]) {
35553
- return;
35554
- }
35555
-
35556
- var $element = $this.data('element');
35557
-
35558
- $element.select2('close');
35559
- });
35560
- });
35561
- };
35562
-
35563
- BaseSelection.prototype._detachCloseHandler = function (container) {
35564
- $(document.body).off('mousedown.select2.' + container.id);
35565
- };
35566
-
35567
- BaseSelection.prototype.position = function ($selection, $container) {
35568
- var $selectionContainer = $container.find('.selection');
35569
- $selectionContainer.append($selection);
35570
- };
35571
-
35572
- BaseSelection.prototype.destroy = function () {
35573
- this._detachCloseHandler(this.container);
35574
- };
35575
-
35576
- BaseSelection.prototype.update = function (data) {
35577
- throw new Error('The `update` method must be defined in child classes.');
35578
- };
35579
-
35580
- return BaseSelection;
35581
- });
35582
-
35583
- S2.define('select2/selection/single',[
35584
- 'jquery',
35585
- './base',
35586
- '../utils',
35587
- '../keys'
35588
- ], function ($, BaseSelection, Utils, KEYS) {
35589
- function SingleSelection () {
35590
- SingleSelection.__super__.constructor.apply(this, arguments);
35591
- }
35592
-
35593
- Utils.Extend(SingleSelection, BaseSelection);
35594
-
35595
- SingleSelection.prototype.render = function () {
35596
- var $selection = SingleSelection.__super__.render.call(this);
35597
-
35598
- $selection.addClass('select2-selection--single');
35599
-
35600
- $selection.html(
35601
- '<span class="select2-selection__rendered"></span>' +
35602
- '<span class="select2-selection__arrow" role="presentation">' +
35603
- '<b role="presentation"></b>' +
35604
- '</span>'
35605
- );
35606
-
35607
- return $selection;
35608
- };
35609
-
35610
- SingleSelection.prototype.bind = function (container, $container) {
35611
- var self = this;
35612
-
35613
- SingleSelection.__super__.bind.apply(this, arguments);
35614
-
35615
- var id = container.id + '-container';
35616
-
35617
- this.$selection.find('.select2-selection__rendered').attr('id', id);
35618
- this.$selection.attr('aria-labelledby', id);
35619
-
35620
- this.$selection.on('mousedown', function (evt) {
35621
- // Only respond to left clicks
35622
- if (evt.which !== 1) {
35623
- return;
35624
- }
35625
-
35626
- self.trigger('toggle', {
35627
- originalEvent: evt
35628
- });
35629
- });
35630
-
35631
- this.$selection.on('focus', function (evt) {
35632
- // User focuses on the container
35633
- });
35634
-
35635
- this.$selection.on('blur', function (evt) {
35636
- // User exits the container
35637
- });
35638
-
35639
- container.on('focus', function (evt) {
35640
- if (!container.isOpen()) {
35641
- self.$selection.focus();
35642
- }
35643
- });
35644
-
35645
- container.on('selection:update', function (params) {
35646
- self.update(params.data);
35647
- });
35648
- };
35649
-
35650
- SingleSelection.prototype.clear = function () {
35651
- this.$selection.find('.select2-selection__rendered').empty();
35652
- };
35653
-
35654
- SingleSelection.prototype.display = function (data, container) {
35655
- var template = this.options.get('templateSelection');
35656
- var escapeMarkup = this.options.get('escapeMarkup');
35657
-
35658
- return escapeMarkup(template(data, container));
35659
- };
35660
-
35661
- SingleSelection.prototype.selectionContainer = function () {
35662
- return $('<span></span>');
35663
- };
35664
-
35665
- SingleSelection.prototype.update = function (data) {
35666
- if (data.length === 0) {
35667
- this.clear();
35668
- return;
35669
- }
35670
-
35671
- var selection = data[0];
35672
-
35673
- var $rendered = this.$selection.find('.select2-selection__rendered');
35674
- var formatted = this.display(selection, $rendered);
35675
-
35676
- $rendered.empty().append(formatted);
35677
- $rendered.prop('title', selection.title || selection.text);
35678
- };
35679
-
35680
- return SingleSelection;
35681
- });
35682
-
35683
- S2.define('select2/selection/multiple',[
35684
- 'jquery',
35685
- './base',
35686
- '../utils'
35687
- ], function ($, BaseSelection, Utils) {
35688
- function MultipleSelection ($element, options) {
35689
- MultipleSelection.__super__.constructor.apply(this, arguments);
35690
- }
35691
-
35692
- Utils.Extend(MultipleSelection, BaseSelection);
35693
-
35694
- MultipleSelection.prototype.render = function () {
35695
- var $selection = MultipleSelection.__super__.render.call(this);
35696
-
35697
- $selection.addClass('select2-selection--multiple');
35698
-
35699
- $selection.html(
35700
- '<ul class="select2-selection__rendered"></ul>'
35701
- );
35702
-
35703
- return $selection;
35704
- };
35705
-
35706
- MultipleSelection.prototype.bind = function (container, $container) {
35707
- var self = this;
35708
-
35709
- MultipleSelection.__super__.bind.apply(this, arguments);
35710
-
35711
- this.$selection.on('click', function (evt) {
35712
- self.trigger('toggle', {
35713
- originalEvent: evt
35714
- });
35715
- });
35716
-
35717
- this.$selection.on(
35718
- 'click',
35719
- '.select2-selection__choice__remove',
35720
- function (evt) {
35721
- // Ignore the event if it is disabled
35722
- if (self.options.get('disabled')) {
35723
- return;
35724
- }
35725
-
35726
- var $remove = $(this);
35727
- var $selection = $remove.parent();
35728
-
35729
- var data = $selection.data('data');
35730
-
35731
- self.trigger('unselect', {
35732
- originalEvent: evt,
35733
- data: data
35734
- });
35735
- }
35736
- );
35737
- };
35738
-
35739
- MultipleSelection.prototype.clear = function () {
35740
- this.$selection.find('.select2-selection__rendered').empty();
35741
- };
35742
-
35743
- MultipleSelection.prototype.display = function (data, container) {
35744
- var template = this.options.get('templateSelection');
35745
- var escapeMarkup = this.options.get('escapeMarkup');
35746
-
35747
- return escapeMarkup(template(data, container));
35748
- };
35749
-
35750
- MultipleSelection.prototype.selectionContainer = function () {
35751
- var $container = $(
35752
- '<li class="select2-selection__choice">' +
35753
- '<span class="select2-selection__choice__remove" role="presentation">' +
35754
- '&times;' +
35755
- '</span>' +
35756
- '</li>'
35757
- );
35758
-
35759
- return $container;
35760
- };
35761
-
35762
- MultipleSelection.prototype.update = function (data) {
35763
- this.clear();
35764
-
35765
- if (data.length === 0) {
35766
- return;
35767
- }
35768
-
35769
- var $selections = [];
35770
-
35771
- for (var d = 0; d < data.length; d++) {
35772
- var selection = data[d];
35773
-
35774
- var $selection = this.selectionContainer();
35775
- var formatted = this.display(selection, $selection);
35776
-
35777
- $selection.append(formatted);
35778
- $selection.prop('title', selection.title || selection.text);
35779
-
35780
- $selection.data('data', selection);
35781
-
35782
- $selections.push($selection);
35783
- }
35784
-
35785
- var $rendered = this.$selection.find('.select2-selection__rendered');
35786
-
35787
- Utils.appendMany($rendered, $selections);
35788
- };
35789
-
35790
- return MultipleSelection;
35791
- });
35792
-
35793
- S2.define('select2/selection/placeholder',[
35794
- '../utils'
35795
- ], function (Utils) {
35796
- function Placeholder (decorated, $element, options) {
35797
- this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
35798
-
35799
- decorated.call(this, $element, options);
35800
- }
35801
-
35802
- Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
35803
- if (typeof placeholder === 'string') {
35804
- placeholder = {
35805
- id: '',
35806
- text: placeholder
35807
- };
35808
- }
35809
-
35810
- return placeholder;
35811
- };
35812
-
35813
- Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
35814
- var $placeholder = this.selectionContainer();
35815
-
35816
- $placeholder.html(this.display(placeholder));
35817
- $placeholder.addClass('select2-selection__placeholder')
35818
- .removeClass('select2-selection__choice');
35819
-
35820
- return $placeholder;
35821
- };
35822
-
35823
- Placeholder.prototype.update = function (decorated, data) {
35824
- var singlePlaceholder = (
35825
- data.length == 1 && data[0].id != this.placeholder.id
35826
- );
35827
- var multipleSelections = data.length > 1;
35828
-
35829
- if (multipleSelections || singlePlaceholder) {
35830
- return decorated.call(this, data);
35831
- }
35832
-
35833
- this.clear();
35834
-
35835
- var $placeholder = this.createPlaceholder(this.placeholder);
35836
-
35837
- this.$selection.find('.select2-selection__rendered').append($placeholder);
35838
- };
35839
-
35840
- return Placeholder;
35841
- });
35842
-
35843
- S2.define('select2/selection/allowClear',[
35844
- 'jquery',
35845
- '../keys'
35846
- ], function ($, KEYS) {
35847
- function AllowClear () { }
35848
-
35849
- AllowClear.prototype.bind = function (decorated, container, $container) {
35850
- var self = this;
35851
-
35852
- decorated.call(this, container, $container);
35853
-
35854
- if (this.placeholder == null) {
35855
- if (this.options.get('debug') && window.console && console.error) {
35856
- console.error(
35857
- 'Select2: The `allowClear` option should be used in combination ' +
35858
- 'with the `placeholder` option.'
35859
- );
35860
- }
35861
- }
35862
-
35863
- this.$selection.on('mousedown', '.select2-selection__clear',
35864
- function (evt) {
35865
- self._handleClear(evt);
35866
- });
35867
-
35868
- container.on('keypress', function (evt) {
35869
- self._handleKeyboardClear(evt, container);
35870
- });
35871
- };
35872
-
35873
- AllowClear.prototype._handleClear = function (_, evt) {
35874
- // Ignore the event if it is disabled
35875
- if (this.options.get('disabled')) {
35876
- return;
35877
- }
35878
-
35879
- var $clear = this.$selection.find('.select2-selection__clear');
35880
-
35881
- // Ignore the event if nothing has been selected
35882
- if ($clear.length === 0) {
35883
- return;
35884
- }
35885
-
35886
- evt.stopPropagation();
35887
-
35888
- var data = $clear.data('data');
35889
-
35890
- for (var d = 0; d < data.length; d++) {
35891
- var unselectData = {
35892
- data: data[d]
35893
- };
35894
-
35895
- // Trigger the `unselect` event, so people can prevent it from being
35896
- // cleared.
35897
- this.trigger('unselect', unselectData);
35898
-
35899
- // If the event was prevented, don't clear it out.
35900
- if (unselectData.prevented) {
35901
- return;
35902
- }
35903
- }
35904
-
35905
- this.$element.val(this.placeholder.id).trigger('change');
35906
-
35907
- this.trigger('toggle', {});
35908
- };
35909
-
35910
- AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
35911
- if (container.isOpen()) {
35912
- return;
35913
- }
35914
-
35915
- if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
35916
- this._handleClear(evt);
35917
- }
35918
- };
35919
-
35920
- AllowClear.prototype.update = function (decorated, data) {
35921
- decorated.call(this, data);
35922
-
35923
- if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
35924
- data.length === 0) {
35925
- return;
35926
- }
35927
-
35928
- var $remove = $(
35929
- '<span class="select2-selection__clear">' +
35930
- '&times;' +
35931
- '</span>'
35932
- );
35933
- $remove.data('data', data);
35934
-
35935
- this.$selection.find('.select2-selection__rendered').prepend($remove);
35936
- };
35937
-
35938
- return AllowClear;
35939
- });
35940
-
35941
- S2.define('select2/selection/search',[
35942
- 'jquery',
35943
- '../utils',
35944
- '../keys'
35945
- ], function ($, Utils, KEYS) {
35946
- function Search (decorated, $element, options) {
35947
- decorated.call(this, $element, options);
35948
- }
35949
-
35950
- Search.prototype.render = function (decorated) {
35951
- var $search = $(
35952
- '<li class="select2-search select2-search--inline">' +
35953
- '<input class="select2-search__field" type="search" tabindex="-1"' +
35954
- ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
35955
- ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
35956
- '</li>'
35957
- );
35958
-
35959
- this.$searchContainer = $search;
35960
- this.$search = $search.find('input');
35961
-
35962
- var $rendered = decorated.call(this);
35963
-
35964
- this._transferTabIndex();
35965
-
35966
- return $rendered;
35967
- };
35968
-
35969
- Search.prototype.bind = function (decorated, container, $container) {
35970
- var self = this;
35971
-
35972
- decorated.call(this, container, $container);
35973
-
35974
- container.on('open', function () {
35975
- self.$search.trigger('focus');
35976
- });
35977
-
35978
- container.on('close', function () {
35979
- self.$search.val('');
35980
- self.$search.removeAttr('aria-activedescendant');
35981
- self.$search.trigger('focus');
35982
- });
35983
-
35984
- container.on('enable', function () {
35985
- self.$search.prop('disabled', false);
35986
-
35987
- self._transferTabIndex();
35988
- });
35989
-
35990
- container.on('disable', function () {
35991
- self.$search.prop('disabled', true);
35992
- });
35993
-
35994
- container.on('focus', function (evt) {
35995
- self.$search.trigger('focus');
35996
- });
35997
-
35998
- container.on('results:focus', function (params) {
35999
- self.$search.attr('aria-activedescendant', params.id);
36000
- });
36001
-
36002
- this.$selection.on('focusin', '.select2-search--inline', function (evt) {
36003
- self.trigger('focus', evt);
36004
- });
36005
-
36006
- this.$selection.on('focusout', '.select2-search--inline', function (evt) {
36007
- self._handleBlur(evt);
36008
- });
36009
-
36010
- this.$selection.on('keydown', '.select2-search--inline', function (evt) {
36011
- evt.stopPropagation();
36012
-
36013
- self.trigger('keypress', evt);
36014
-
36015
- self._keyUpPrevented = evt.isDefaultPrevented();
36016
-
36017
- var key = evt.which;
36018
-
36019
- if (key === KEYS.BACKSPACE && self.$search.val() === '') {
36020
- var $previousChoice = self.$searchContainer
36021
- .prev('.select2-selection__choice');
36022
-
36023
- if ($previousChoice.length > 0) {
36024
- var item = $previousChoice.data('data');
36025
-
36026
- self.searchRemoveChoice(item);
36027
-
36028
- evt.preventDefault();
36029
- }
36030
- }
36031
- });
36032
-
36033
- // Try to detect the IE version should the `documentMode` property that
36034
- // is stored on the document. This is only implemented in IE and is
36035
- // slightly cleaner than doing a user agent check.
36036
- // This property is not available in Edge, but Edge also doesn't have
36037
- // this bug.
36038
- var msie = document.documentMode;
36039
- var disableInputEvents = msie && msie <= 11;
36040
-
36041
- // Workaround for browsers which do not support the `input` event
36042
- // This will prevent double-triggering of events for browsers which support
36043
- // both the `keyup` and `input` events.
36044
- this.$selection.on(
36045
- 'input.searchcheck',
36046
- '.select2-search--inline',
36047
- function (evt) {
36048
- // IE will trigger the `input` event when a placeholder is used on a
36049
- // search box. To get around this issue, we are forced to ignore all
36050
- // `input` events in IE and keep using `keyup`.
36051
- if (disableInputEvents) {
36052
- self.$selection.off('input.search input.searchcheck');
36053
- return;
36054
- }
36055
-
36056
- // Unbind the duplicated `keyup` event
36057
- self.$selection.off('keyup.search');
36058
- }
36059
- );
36060
-
36061
- this.$selection.on(
36062
- 'keyup.search input.search',
36063
- '.select2-search--inline',
36064
- function (evt) {
36065
- // IE will trigger the `input` event when a placeholder is used on a
36066
- // search box. To get around this issue, we are forced to ignore all
36067
- // `input` events in IE and keep using `keyup`.
36068
- if (disableInputEvents && evt.type === 'input') {
36069
- self.$selection.off('input.search input.searchcheck');
36070
- return;
36071
- }
36072
-
36073
- var key = evt.which;
36074
-
36075
- // We can freely ignore events from modifier keys
36076
- if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
36077
- return;
36078
- }
36079
-
36080
- // Tabbing will be handled during the `keydown` phase
36081
- if (key == KEYS.TAB) {
36082
- return;
36083
- }
36084
-
36085
- self.handleSearch(evt);
36086
- }
36087
- );
36088
- };
36089
-
36090
- /**
36091
- * This method will transfer the tabindex attribute from the rendered
36092
- * selection to the search box. This allows for the search box to be used as
36093
- * the primary focus instead of the selection container.
36094
- *
36095
- * @private
36096
- */
36097
- Search.prototype._transferTabIndex = function (decorated) {
36098
- this.$search.attr('tabindex', this.$selection.attr('tabindex'));
36099
- this.$selection.attr('tabindex', '-1');
36100
- };
36101
-
36102
- Search.prototype.createPlaceholder = function (decorated, placeholder) {
36103
- this.$search.attr('placeholder', placeholder.text);
36104
- };
36105
-
36106
- Search.prototype.update = function (decorated, data) {
36107
- var searchHadFocus = this.$search[0] == document.activeElement;
36108
-
36109
- this.$search.attr('placeholder', '');
36110
-
36111
- decorated.call(this, data);
36112
-
36113
- this.$selection.find('.select2-selection__rendered')
36114
- .append(this.$searchContainer);
36115
-
36116
- this.resizeSearch();
36117
- if (searchHadFocus) {
36118
- this.$search.focus();
36119
- }
36120
- };
36121
-
36122
- Search.prototype.handleSearch = function () {
36123
- this.resizeSearch();
36124
-
36125
- if (!this._keyUpPrevented) {
36126
- var input = this.$search.val();
36127
-
36128
- this.trigger('query', {
36129
- term: input
36130
- });
36131
- }
36132
-
36133
- this._keyUpPrevented = false;
36134
- };
36135
-
36136
- Search.prototype.searchRemoveChoice = function (decorated, item) {
36137
- this.trigger('unselect', {
36138
- data: item
36139
- });
36140
-
36141
- this.$search.val(item.text);
36142
- this.handleSearch();
36143
- };
36144
-
36145
- Search.prototype.resizeSearch = function () {
36146
- this.$search.css('width', '25px');
36147
-
36148
- var width = '';
36149
-
36150
- if (this.$search.attr('placeholder') !== '') {
36151
- width = this.$selection.find('.select2-selection__rendered').innerWidth();
36152
- } else {
36153
- var minimumWidth = this.$search.val().length + 1;
36154
-
36155
- width = (minimumWidth * 0.75) + 'em';
36156
- }
36157
-
36158
- this.$search.css('width', width);
36159
- };
36160
-
36161
- return Search;
36162
- });
36163
-
36164
- S2.define('select2/selection/eventRelay',[
36165
- 'jquery'
36166
- ], function ($) {
36167
- function EventRelay () { }
36168
-
36169
- EventRelay.prototype.bind = function (decorated, container, $container) {
36170
- var self = this;
36171
- var relayEvents = [
36172
- 'open', 'opening',
36173
- 'close', 'closing',
36174
- 'select', 'selecting',
36175
- 'unselect', 'unselecting'
36176
- ];
36177
-
36178
- var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
36179
-
36180
- decorated.call(this, container, $container);
36181
-
36182
- container.on('*', function (name, params) {
36183
- // Ignore events that should not be relayed
36184
- if ($.inArray(name, relayEvents) === -1) {
36185
- return;
36186
- }
36187
-
36188
- // The parameters should always be an object
36189
- params = params || {};
36190
-
36191
- // Generate the jQuery event for the Select2 event
36192
- var evt = $.Event('select2:' + name, {
36193
- params: params
36194
- });
36195
-
36196
- self.$element.trigger(evt);
36197
-
36198
- // Only handle preventable events if it was one
36199
- if ($.inArray(name, preventableEvents) === -1) {
36200
- return;
36201
- }
36202
-
36203
- params.prevented = evt.isDefaultPrevented();
36204
- });
36205
- };
36206
-
36207
- return EventRelay;
36208
- });
36209
-
36210
- S2.define('select2/translation',[
36211
- 'jquery',
36212
- 'require'
36213
- ], function ($, require) {
36214
- function Translation (dict) {
36215
- this.dict = dict || {};
36216
- }
36217
-
36218
- Translation.prototype.all = function () {
36219
- return this.dict;
36220
- };
36221
-
36222
- Translation.prototype.get = function (key) {
36223
- return this.dict[key];
36224
- };
36225
-
36226
- Translation.prototype.extend = function (translation) {
36227
- this.dict = $.extend({}, translation.all(), this.dict);
36228
- };
36229
-
36230
- // Static functions
36231
-
36232
- Translation._cache = {};
36233
-
36234
- Translation.loadPath = function (path) {
36235
- if (!(path in Translation._cache)) {
36236
- var translations = require(path);
36237
-
36238
- Translation._cache[path] = translations;
36239
- }
36240
-
36241
- return new Translation(Translation._cache[path]);
36242
- };
36243
-
36244
- return Translation;
36245
- });
36246
-
36247
- S2.define('select2/diacritics',[
36248
-
36249
- ], function () {
36250
- var diacritics = {
36251
- '\u24B6': 'A',
36252
- '\uFF21': 'A',
36253
- '\u00C0': 'A',
36254
- '\u00C1': 'A',
36255
- '\u00C2': 'A',
36256
- '\u1EA6': 'A',
36257
- '\u1EA4': 'A',
36258
- '\u1EAA': 'A',
36259
- '\u1EA8': 'A',
36260
- '\u00C3': 'A',
36261
- '\u0100': 'A',
36262
- '\u0102': 'A',
36263
- '\u1EB0': 'A',
36264
- '\u1EAE': 'A',
36265
- '\u1EB4': 'A',
36266
- '\u1EB2': 'A',
36267
- '\u0226': 'A',
36268
- '\u01E0': 'A',
36269
- '\u00C4': 'A',
36270
- '\u01DE': 'A',
36271
- '\u1EA2': 'A',
36272
- '\u00C5': 'A',
36273
- '\u01FA': 'A',
36274
- '\u01CD': 'A',
36275
- '\u0200': 'A',
36276
- '\u0202': 'A',
36277
- '\u1EA0': 'A',
36278
- '\u1EAC': 'A',
36279
- '\u1EB6': 'A',
36280
- '\u1E00': 'A',
36281
- '\u0104': 'A',
36282
- '\u023A': 'A',
36283
- '\u2C6F': 'A',
36284
- '\uA732': 'AA',
36285
- '\u00C6': 'AE',
36286
- '\u01FC': 'AE',
36287
- '\u01E2': 'AE',
36288
- '\uA734': 'AO',
36289
- '\uA736': 'AU',
36290
- '\uA738': 'AV',
36291
- '\uA73A': 'AV',
36292
- '\uA73C': 'AY',
36293
- '\u24B7': 'B',
36294
- '\uFF22': 'B',
36295
- '\u1E02': 'B',
36296
- '\u1E04': 'B',
36297
- '\u1E06': 'B',
36298
- '\u0243': 'B',
36299
- '\u0182': 'B',
36300
- '\u0181': 'B',
36301
- '\u24B8': 'C',
36302
- '\uFF23': 'C',
36303
- '\u0106': 'C',
36304
- '\u0108': 'C',
36305
- '\u010A': 'C',
36306
- '\u010C': 'C',
36307
- '\u00C7': 'C',
36308
- '\u1E08': 'C',
36309
- '\u0187': 'C',
36310
- '\u023B': 'C',
36311
- '\uA73E': 'C',
36312
- '\u24B9': 'D',
36313
- '\uFF24': 'D',
36314
- '\u1E0A': 'D',
36315
- '\u010E': 'D',
36316
- '\u1E0C': 'D',
36317
- '\u1E10': 'D',
36318
- '\u1E12': 'D',
36319
- '\u1E0E': 'D',
36320
- '\u0110': 'D',
36321
- '\u018B': 'D',
36322
- '\u018A': 'D',
36323
- '\u0189': 'D',
36324
- '\uA779': 'D',
36325
- '\u01F1': 'DZ',
36326
- '\u01C4': 'DZ',
36327
- '\u01F2': 'Dz',
36328
- '\u01C5': 'Dz',
36329
- '\u24BA': 'E',
36330
- '\uFF25': 'E',
36331
- '\u00C8': 'E',
36332
- '\u00C9': 'E',
36333
- '\u00CA': 'E',
36334
- '\u1EC0': 'E',
36335
- '\u1EBE': 'E',
36336
- '\u1EC4': 'E',
36337
- '\u1EC2': 'E',
36338
- '\u1EBC': 'E',
36339
- '\u0112': 'E',
36340
- '\u1E14': 'E',
36341
- '\u1E16': 'E',
36342
- '\u0114': 'E',
36343
- '\u0116': 'E',
36344
- '\u00CB': 'E',
36345
- '\u1EBA': 'E',
36346
- '\u011A': 'E',
36347
- '\u0204': 'E',
36348
- '\u0206': 'E',
36349
- '\u1EB8': 'E',
36350
- '\u1EC6': 'E',
36351
- '\u0228': 'E',
36352
- '\u1E1C': 'E',
36353
- '\u0118': 'E',
36354
- '\u1E18': 'E',
36355
- '\u1E1A': 'E',
36356
- '\u0190': 'E',
36357
- '\u018E': 'E',
36358
- '\u24BB': 'F',
36359
- '\uFF26': 'F',
36360
- '\u1E1E': 'F',
36361
- '\u0191': 'F',
36362
- '\uA77B': 'F',
36363
- '\u24BC': 'G',
36364
- '\uFF27': 'G',
36365
- '\u01F4': 'G',
36366
- '\u011C': 'G',
36367
- '\u1E20': 'G',
36368
- '\u011E': 'G',
36369
- '\u0120': 'G',
36370
- '\u01E6': 'G',
36371
- '\u0122': 'G',
36372
- '\u01E4': 'G',
36373
- '\u0193': 'G',
36374
- '\uA7A0': 'G',
36375
- '\uA77D': 'G',
36376
- '\uA77E': 'G',
36377
- '\u24BD': 'H',
36378
- '\uFF28': 'H',
36379
- '\u0124': 'H',
36380
- '\u1E22': 'H',
36381
- '\u1E26': 'H',
36382
- '\u021E': 'H',
36383
- '\u1E24': 'H',
36384
- '\u1E28': 'H',
36385
- '\u1E2A': 'H',
36386
- '\u0126': 'H',
36387
- '\u2C67': 'H',
36388
- '\u2C75': 'H',
36389
- '\uA78D': 'H',
36390
- '\u24BE': 'I',
36391
- '\uFF29': 'I',
36392
- '\u00CC': 'I',
36393
- '\u00CD': 'I',
36394
- '\u00CE': 'I',
36395
- '\u0128': 'I',
36396
- '\u012A': 'I',
36397
- '\u012C': 'I',
36398
- '\u0130': 'I',
36399
- '\u00CF': 'I',
36400
- '\u1E2E': 'I',
36401
- '\u1EC8': 'I',
36402
- '\u01CF': 'I',
36403
- '\u0208': 'I',
36404
- '\u020A': 'I',
36405
- '\u1ECA': 'I',
36406
- '\u012E': 'I',
36407
- '\u1E2C': 'I',
36408
- '\u0197': 'I',
36409
- '\u24BF': 'J',
36410
- '\uFF2A': 'J',
36411
- '\u0134': 'J',
36412
- '\u0248': 'J',
36413
- '\u24C0': 'K',
36414
- '\uFF2B': 'K',
36415
- '\u1E30': 'K',
36416
- '\u01E8': 'K',
36417
- '\u1E32': 'K',
36418
- '\u0136': 'K',
36419
- '\u1E34': 'K',
36420
- '\u0198': 'K',
36421
- '\u2C69': 'K',
36422
- '\uA740': 'K',
36423
- '\uA742': 'K',
36424
- '\uA744': 'K',
36425
- '\uA7A2': 'K',
36426
- '\u24C1': 'L',
36427
- '\uFF2C': 'L',
36428
- '\u013F': 'L',
36429
- '\u0139': 'L',
36430
- '\u013D': 'L',
36431
- '\u1E36': 'L',
36432
- '\u1E38': 'L',
36433
- '\u013B': 'L',
36434
- '\u1E3C': 'L',
36435
- '\u1E3A': 'L',
36436
- '\u0141': 'L',
36437
- '\u023D': 'L',
36438
- '\u2C62': 'L',
36439
- '\u2C60': 'L',
36440
- '\uA748': 'L',
36441
- '\uA746': 'L',
36442
- '\uA780': 'L',
36443
- '\u01C7': 'LJ',
36444
- '\u01C8': 'Lj',
36445
- '\u24C2': 'M',
36446
- '\uFF2D': 'M',
36447
- '\u1E3E': 'M',
36448
- '\u1E40': 'M',
36449
- '\u1E42': 'M',
36450
- '\u2C6E': 'M',
36451
- '\u019C': 'M',
36452
- '\u24C3': 'N',
36453
- '\uFF2E': 'N',
36454
- '\u01F8': 'N',
36455
- '\u0143': 'N',
36456
- '\u00D1': 'N',
36457
- '\u1E44': 'N',
36458
- '\u0147': 'N',
36459
- '\u1E46': 'N',
36460
- '\u0145': 'N',
36461
- '\u1E4A': 'N',
36462
- '\u1E48': 'N',
36463
- '\u0220': 'N',
36464
- '\u019D': 'N',
36465
- '\uA790': 'N',
36466
- '\uA7A4': 'N',
36467
- '\u01CA': 'NJ',
36468
- '\u01CB': 'Nj',
36469
- '\u24C4': 'O',
36470
- '\uFF2F': 'O',
36471
- '\u00D2': 'O',
36472
- '\u00D3': 'O',
36473
- '\u00D4': 'O',
36474
- '\u1ED2': 'O',
36475
- '\u1ED0': 'O',
36476
- '\u1ED6': 'O',
36477
- '\u1ED4': 'O',
36478
- '\u00D5': 'O',
36479
- '\u1E4C': 'O',
36480
- '\u022C': 'O',
36481
- '\u1E4E': 'O',
36482
- '\u014C': 'O',
36483
- '\u1E50': 'O',
36484
- '\u1E52': 'O',
36485
- '\u014E': 'O',
36486
- '\u022E': 'O',
36487
- '\u0230': 'O',
36488
- '\u00D6': 'O',
36489
- '\u022A': 'O',
36490
- '\u1ECE': 'O',
36491
- '\u0150': 'O',
36492
- '\u01D1': 'O',
36493
- '\u020C': 'O',
36494
- '\u020E': 'O',
36495
- '\u01A0': 'O',
36496
- '\u1EDC': 'O',
36497
- '\u1EDA': 'O',
36498
- '\u1EE0': 'O',
36499
- '\u1EDE': 'O',
36500
- '\u1EE2': 'O',
36501
- '\u1ECC': 'O',
36502
- '\u1ED8': 'O',
36503
- '\u01EA': 'O',
36504
- '\u01EC': 'O',
36505
- '\u00D8': 'O',
36506
- '\u01FE': 'O',
36507
- '\u0186': 'O',
36508
- '\u019F': 'O',
36509
- '\uA74A': 'O',
36510
- '\uA74C': 'O',
36511
- '\u01A2': 'OI',
36512
- '\uA74E': 'OO',
36513
- '\u0222': 'OU',
36514
- '\u24C5': 'P',
36515
- '\uFF30': 'P',
36516
- '\u1E54': 'P',
36517
- '\u1E56': 'P',
36518
- '\u01A4': 'P',
36519
- '\u2C63': 'P',
36520
- '\uA750': 'P',
36521
- '\uA752': 'P',
36522
- '\uA754': 'P',
36523
- '\u24C6': 'Q',
36524
- '\uFF31': 'Q',
36525
- '\uA756': 'Q',
36526
- '\uA758': 'Q',
36527
- '\u024A': 'Q',
36528
- '\u24C7': 'R',
36529
- '\uFF32': 'R',
36530
- '\u0154': 'R',
36531
- '\u1E58': 'R',
36532
- '\u0158': 'R',
36533
- '\u0210': 'R',
36534
- '\u0212': 'R',
36535
- '\u1E5A': 'R',
36536
- '\u1E5C': 'R',
36537
- '\u0156': 'R',
36538
- '\u1E5E': 'R',
36539
- '\u024C': 'R',
36540
- '\u2C64': 'R',
36541
- '\uA75A': 'R',
36542
- '\uA7A6': 'R',
36543
- '\uA782': 'R',
36544
- '\u24C8': 'S',
36545
- '\uFF33': 'S',
36546
- '\u1E9E': 'S',
36547
- '\u015A': 'S',
36548
- '\u1E64': 'S',
36549
- '\u015C': 'S',
36550
- '\u1E60': 'S',
36551
- '\u0160': 'S',
36552
- '\u1E66': 'S',
36553
- '\u1E62': 'S',
36554
- '\u1E68': 'S',
36555
- '\u0218': 'S',
36556
- '\u015E': 'S',
36557
- '\u2C7E': 'S',
36558
- '\uA7A8': 'S',
36559
- '\uA784': 'S',
36560
- '\u24C9': 'T',
36561
- '\uFF34': 'T',
36562
- '\u1E6A': 'T',
36563
- '\u0164': 'T',
36564
- '\u1E6C': 'T',
36565
- '\u021A': 'T',
36566
- '\u0162': 'T',
36567
- '\u1E70': 'T',
36568
- '\u1E6E': 'T',
36569
- '\u0166': 'T',
36570
- '\u01AC': 'T',
36571
- '\u01AE': 'T',
36572
- '\u023E': 'T',
36573
- '\uA786': 'T',
36574
- '\uA728': 'TZ',
36575
- '\u24CA': 'U',
36576
- '\uFF35': 'U',
36577
- '\u00D9': 'U',
36578
- '\u00DA': 'U',
36579
- '\u00DB': 'U',
36580
- '\u0168': 'U',
36581
- '\u1E78': 'U',
36582
- '\u016A': 'U',
36583
- '\u1E7A': 'U',
36584
- '\u016C': 'U',
36585
- '\u00DC': 'U',
36586
- '\u01DB': 'U',
36587
- '\u01D7': 'U',
36588
- '\u01D5': 'U',
36589
- '\u01D9': 'U',
36590
- '\u1EE6': 'U',
36591
- '\u016E': 'U',
36592
- '\u0170': 'U',
36593
- '\u01D3': 'U',
36594
- '\u0214': 'U',
36595
- '\u0216': 'U',
36596
- '\u01AF': 'U',
36597
- '\u1EEA': 'U',
36598
- '\u1EE8': 'U',
36599
- '\u1EEE': 'U',
36600
- '\u1EEC': 'U',
36601
- '\u1EF0': 'U',
36602
- '\u1EE4': 'U',
36603
- '\u1E72': 'U',
36604
- '\u0172': 'U',
36605
- '\u1E76': 'U',
36606
- '\u1E74': 'U',
36607
- '\u0244': 'U',
36608
- '\u24CB': 'V',
36609
- '\uFF36': 'V',
36610
- '\u1E7C': 'V',
36611
- '\u1E7E': 'V',
36612
- '\u01B2': 'V',
36613
- '\uA75E': 'V',
36614
- '\u0245': 'V',
36615
- '\uA760': 'VY',
36616
- '\u24CC': 'W',
36617
- '\uFF37': 'W',
36618
- '\u1E80': 'W',
36619
- '\u1E82': 'W',
36620
- '\u0174': 'W',
36621
- '\u1E86': 'W',
36622
- '\u1E84': 'W',
36623
- '\u1E88': 'W',
36624
- '\u2C72': 'W',
36625
- '\u24CD': 'X',
36626
- '\uFF38': 'X',
36627
- '\u1E8A': 'X',
36628
- '\u1E8C': 'X',
36629
- '\u24CE': 'Y',
36630
- '\uFF39': 'Y',
36631
- '\u1EF2': 'Y',
36632
- '\u00DD': 'Y',
36633
- '\u0176': 'Y',
36634
- '\u1EF8': 'Y',
36635
- '\u0232': 'Y',
36636
- '\u1E8E': 'Y',
36637
- '\u0178': 'Y',
36638
- '\u1EF6': 'Y',
36639
- '\u1EF4': 'Y',
36640
- '\u01B3': 'Y',
36641
- '\u024E': 'Y',
36642
- '\u1EFE': 'Y',
36643
- '\u24CF': 'Z',
36644
- '\uFF3A': 'Z',
36645
- '\u0179': 'Z',
36646
- '\u1E90': 'Z',
36647
- '\u017B': 'Z',
36648
- '\u017D': 'Z',
36649
- '\u1E92': 'Z',
36650
- '\u1E94': 'Z',
36651
- '\u01B5': 'Z',
36652
- '\u0224': 'Z',
36653
- '\u2C7F': 'Z',
36654
- '\u2C6B': 'Z',
36655
- '\uA762': 'Z',
36656
- '\u24D0': 'a',
36657
- '\uFF41': 'a',
36658
- '\u1E9A': 'a',
36659
- '\u00E0': 'a',
36660
- '\u00E1': 'a',
36661
- '\u00E2': 'a',
36662
- '\u1EA7': 'a',
36663
- '\u1EA5': 'a',
36664
- '\u1EAB': 'a',
36665
- '\u1EA9': 'a',
36666
- '\u00E3': 'a',
36667
- '\u0101': 'a',
36668
- '\u0103': 'a',
36669
- '\u1EB1': 'a',
36670
- '\u1EAF': 'a',
36671
- '\u1EB5': 'a',
36672
- '\u1EB3': 'a',
36673
- '\u0227': 'a',
36674
- '\u01E1': 'a',
36675
- '\u00E4': 'a',
36676
- '\u01DF': 'a',
36677
- '\u1EA3': 'a',
36678
- '\u00E5': 'a',
36679
- '\u01FB': 'a',
36680
- '\u01CE': 'a',
36681
- '\u0201': 'a',
36682
- '\u0203': 'a',
36683
- '\u1EA1': 'a',
36684
- '\u1EAD': 'a',
36685
- '\u1EB7': 'a',
36686
- '\u1E01': 'a',
36687
- '\u0105': 'a',
36688
- '\u2C65': 'a',
36689
- '\u0250': 'a',
36690
- '\uA733': 'aa',
36691
- '\u00E6': 'ae',
36692
- '\u01FD': 'ae',
36693
- '\u01E3': 'ae',
36694
- '\uA735': 'ao',
36695
- '\uA737': 'au',
36696
- '\uA739': 'av',
36697
- '\uA73B': 'av',
36698
- '\uA73D': 'ay',
36699
- '\u24D1': 'b',
36700
- '\uFF42': 'b',
36701
- '\u1E03': 'b',
36702
- '\u1E05': 'b',
36703
- '\u1E07': 'b',
36704
- '\u0180': 'b',
36705
- '\u0183': 'b',
36706
- '\u0253': 'b',
36707
- '\u24D2': 'c',
36708
- '\uFF43': 'c',
36709
- '\u0107': 'c',
36710
- '\u0109': 'c',
36711
- '\u010B': 'c',
36712
- '\u010D': 'c',
36713
- '\u00E7': 'c',
36714
- '\u1E09': 'c',
36715
- '\u0188': 'c',
36716
- '\u023C': 'c',
36717
- '\uA73F': 'c',
36718
- '\u2184': 'c',
36719
- '\u24D3': 'd',
36720
- '\uFF44': 'd',
36721
- '\u1E0B': 'd',
36722
- '\u010F': 'd',
36723
- '\u1E0D': 'd',
36724
- '\u1E11': 'd',
36725
- '\u1E13': 'd',
36726
- '\u1E0F': 'd',
36727
- '\u0111': 'd',
36728
- '\u018C': 'd',
36729
- '\u0256': 'd',
36730
- '\u0257': 'd',
36731
- '\uA77A': 'd',
36732
- '\u01F3': 'dz',
36733
- '\u01C6': 'dz',
36734
- '\u24D4': 'e',
36735
- '\uFF45': 'e',
36736
- '\u00E8': 'e',
36737
- '\u00E9': 'e',
36738
- '\u00EA': 'e',
36739
- '\u1EC1': 'e',
36740
- '\u1EBF': 'e',
36741
- '\u1EC5': 'e',
36742
- '\u1EC3': 'e',
36743
- '\u1EBD': 'e',
36744
- '\u0113': 'e',
36745
- '\u1E15': 'e',
36746
- '\u1E17': 'e',
36747
- '\u0115': 'e',
36748
- '\u0117': 'e',
36749
- '\u00EB': 'e',
36750
- '\u1EBB': 'e',
36751
- '\u011B': 'e',
36752
- '\u0205': 'e',
36753
- '\u0207': 'e',
36754
- '\u1EB9': 'e',
36755
- '\u1EC7': 'e',
36756
- '\u0229': 'e',
36757
- '\u1E1D': 'e',
36758
- '\u0119': 'e',
36759
- '\u1E19': 'e',
36760
- '\u1E1B': 'e',
36761
- '\u0247': 'e',
36762
- '\u025B': 'e',
36763
- '\u01DD': 'e',
36764
- '\u24D5': 'f',
36765
- '\uFF46': 'f',
36766
- '\u1E1F': 'f',
36767
- '\u0192': 'f',
36768
- '\uA77C': 'f',
36769
- '\u24D6': 'g',
36770
- '\uFF47': 'g',
36771
- '\u01F5': 'g',
36772
- '\u011D': 'g',
36773
- '\u1E21': 'g',
36774
- '\u011F': 'g',
36775
- '\u0121': 'g',
36776
- '\u01E7': 'g',
36777
- '\u0123': 'g',
36778
- '\u01E5': 'g',
36779
- '\u0260': 'g',
36780
- '\uA7A1': 'g',
36781
- '\u1D79': 'g',
36782
- '\uA77F': 'g',
36783
- '\u24D7': 'h',
36784
- '\uFF48': 'h',
36785
- '\u0125': 'h',
36786
- '\u1E23': 'h',
36787
- '\u1E27': 'h',
36788
- '\u021F': 'h',
36789
- '\u1E25': 'h',
36790
- '\u1E29': 'h',
36791
- '\u1E2B': 'h',
36792
- '\u1E96': 'h',
36793
- '\u0127': 'h',
36794
- '\u2C68': 'h',
36795
- '\u2C76': 'h',
36796
- '\u0265': 'h',
36797
- '\u0195': 'hv',
36798
- '\u24D8': 'i',
36799
- '\uFF49': 'i',
36800
- '\u00EC': 'i',
36801
- '\u00ED': 'i',
36802
- '\u00EE': 'i',
36803
- '\u0129': 'i',
36804
- '\u012B': 'i',
36805
- '\u012D': 'i',
36806
- '\u00EF': 'i',
36807
- '\u1E2F': 'i',
36808
- '\u1EC9': 'i',
36809
- '\u01D0': 'i',
36810
- '\u0209': 'i',
36811
- '\u020B': 'i',
36812
- '\u1ECB': 'i',
36813
- '\u012F': 'i',
36814
- '\u1E2D': 'i',
36815
- '\u0268': 'i',
36816
- '\u0131': 'i',
36817
- '\u24D9': 'j',
36818
- '\uFF4A': 'j',
36819
- '\u0135': 'j',
36820
- '\u01F0': 'j',
36821
- '\u0249': 'j',
36822
- '\u24DA': 'k',
36823
- '\uFF4B': 'k',
36824
- '\u1E31': 'k',
36825
- '\u01E9': 'k',
36826
- '\u1E33': 'k',
36827
- '\u0137': 'k',
36828
- '\u1E35': 'k',
36829
- '\u0199': 'k',
36830
- '\u2C6A': 'k',
36831
- '\uA741': 'k',
36832
- '\uA743': 'k',
36833
- '\uA745': 'k',
36834
- '\uA7A3': 'k',
36835
- '\u24DB': 'l',
36836
- '\uFF4C': 'l',
36837
- '\u0140': 'l',
36838
- '\u013A': 'l',
36839
- '\u013E': 'l',
36840
- '\u1E37': 'l',
36841
- '\u1E39': 'l',
36842
- '\u013C': 'l',
36843
- '\u1E3D': 'l',
36844
- '\u1E3B': 'l',
36845
- '\u017F': 'l',
36846
- '\u0142': 'l',
36847
- '\u019A': 'l',
36848
- '\u026B': 'l',
36849
- '\u2C61': 'l',
36850
- '\uA749': 'l',
36851
- '\uA781': 'l',
36852
- '\uA747': 'l',
36853
- '\u01C9': 'lj',
36854
- '\u24DC': 'm',
36855
- '\uFF4D': 'm',
36856
- '\u1E3F': 'm',
36857
- '\u1E41': 'm',
36858
- '\u1E43': 'm',
36859
- '\u0271': 'm',
36860
- '\u026F': 'm',
36861
- '\u24DD': 'n',
36862
- '\uFF4E': 'n',
36863
- '\u01F9': 'n',
36864
- '\u0144': 'n',
36865
- '\u00F1': 'n',
36866
- '\u1E45': 'n',
36867
- '\u0148': 'n',
36868
- '\u1E47': 'n',
36869
- '\u0146': 'n',
36870
- '\u1E4B': 'n',
36871
- '\u1E49': 'n',
36872
- '\u019E': 'n',
36873
- '\u0272': 'n',
36874
- '\u0149': 'n',
36875
- '\uA791': 'n',
36876
- '\uA7A5': 'n',
36877
- '\u01CC': 'nj',
36878
- '\u24DE': 'o',
36879
- '\uFF4F': 'o',
36880
- '\u00F2': 'o',
36881
- '\u00F3': 'o',
36882
- '\u00F4': 'o',
36883
- '\u1ED3': 'o',
36884
- '\u1ED1': 'o',
36885
- '\u1ED7': 'o',
36886
- '\u1ED5': 'o',
36887
- '\u00F5': 'o',
36888
- '\u1E4D': 'o',
36889
- '\u022D': 'o',
36890
- '\u1E4F': 'o',
36891
- '\u014D': 'o',
36892
- '\u1E51': 'o',
36893
- '\u1E53': 'o',
36894
- '\u014F': 'o',
36895
- '\u022F': 'o',
36896
- '\u0231': 'o',
36897
- '\u00F6': 'o',
36898
- '\u022B': 'o',
36899
- '\u1ECF': 'o',
36900
- '\u0151': 'o',
36901
- '\u01D2': 'o',
36902
- '\u020D': 'o',
36903
- '\u020F': 'o',
36904
- '\u01A1': 'o',
36905
- '\u1EDD': 'o',
36906
- '\u1EDB': 'o',
36907
- '\u1EE1': 'o',
36908
- '\u1EDF': 'o',
36909
- '\u1EE3': 'o',
36910
- '\u1ECD': 'o',
36911
- '\u1ED9': 'o',
36912
- '\u01EB': 'o',
36913
- '\u01ED': 'o',
36914
- '\u00F8': 'o',
36915
- '\u01FF': 'o',
36916
- '\u0254': 'o',
36917
- '\uA74B': 'o',
36918
- '\uA74D': 'o',
36919
- '\u0275': 'o',
36920
- '\u01A3': 'oi',
36921
- '\u0223': 'ou',
36922
- '\uA74F': 'oo',
36923
- '\u24DF': 'p',
36924
- '\uFF50': 'p',
36925
- '\u1E55': 'p',
36926
- '\u1E57': 'p',
36927
- '\u01A5': 'p',
36928
- '\u1D7D': 'p',
36929
- '\uA751': 'p',
36930
- '\uA753': 'p',
36931
- '\uA755': 'p',
36932
- '\u24E0': 'q',
36933
- '\uFF51': 'q',
36934
- '\u024B': 'q',
36935
- '\uA757': 'q',
36936
- '\uA759': 'q',
36937
- '\u24E1': 'r',
36938
- '\uFF52': 'r',
36939
- '\u0155': 'r',
36940
- '\u1E59': 'r',
36941
- '\u0159': 'r',
36942
- '\u0211': 'r',
36943
- '\u0213': 'r',
36944
- '\u1E5B': 'r',
36945
- '\u1E5D': 'r',
36946
- '\u0157': 'r',
36947
- '\u1E5F': 'r',
36948
- '\u024D': 'r',
36949
- '\u027D': 'r',
36950
- '\uA75B': 'r',
36951
- '\uA7A7': 'r',
36952
- '\uA783': 'r',
36953
- '\u24E2': 's',
36954
- '\uFF53': 's',
36955
- '\u00DF': 's',
36956
- '\u015B': 's',
36957
- '\u1E65': 's',
36958
- '\u015D': 's',
36959
- '\u1E61': 's',
36960
- '\u0161': 's',
36961
- '\u1E67': 's',
36962
- '\u1E63': 's',
36963
- '\u1E69': 's',
36964
- '\u0219': 's',
36965
- '\u015F': 's',
36966
- '\u023F': 's',
36967
- '\uA7A9': 's',
36968
- '\uA785': 's',
36969
- '\u1E9B': 's',
36970
- '\u24E3': 't',
36971
- '\uFF54': 't',
36972
- '\u1E6B': 't',
36973
- '\u1E97': 't',
36974
- '\u0165': 't',
36975
- '\u1E6D': 't',
36976
- '\u021B': 't',
36977
- '\u0163': 't',
36978
- '\u1E71': 't',
36979
- '\u1E6F': 't',
36980
- '\u0167': 't',
36981
- '\u01AD': 't',
36982
- '\u0288': 't',
36983
- '\u2C66': 't',
36984
- '\uA787': 't',
36985
- '\uA729': 'tz',
36986
- '\u24E4': 'u',
36987
- '\uFF55': 'u',
36988
- '\u00F9': 'u',
36989
- '\u00FA': 'u',
36990
- '\u00FB': 'u',
36991
- '\u0169': 'u',
36992
- '\u1E79': 'u',
36993
- '\u016B': 'u',
36994
- '\u1E7B': 'u',
36995
- '\u016D': 'u',
36996
- '\u00FC': 'u',
36997
- '\u01DC': 'u',
36998
- '\u01D8': 'u',
36999
- '\u01D6': 'u',
37000
- '\u01DA': 'u',
37001
- '\u1EE7': 'u',
37002
- '\u016F': 'u',
37003
- '\u0171': 'u',
37004
- '\u01D4': 'u',
37005
- '\u0215': 'u',
37006
- '\u0217': 'u',
37007
- '\u01B0': 'u',
37008
- '\u1EEB': 'u',
37009
- '\u1EE9': 'u',
37010
- '\u1EEF': 'u',
37011
- '\u1EED': 'u',
37012
- '\u1EF1': 'u',
37013
- '\u1EE5': 'u',
37014
- '\u1E73': 'u',
37015
- '\u0173': 'u',
37016
- '\u1E77': 'u',
37017
- '\u1E75': 'u',
37018
- '\u0289': 'u',
37019
- '\u24E5': 'v',
37020
- '\uFF56': 'v',
37021
- '\u1E7D': 'v',
37022
- '\u1E7F': 'v',
37023
- '\u028B': 'v',
37024
- '\uA75F': 'v',
37025
- '\u028C': 'v',
37026
- '\uA761': 'vy',
37027
- '\u24E6': 'w',
37028
- '\uFF57': 'w',
37029
- '\u1E81': 'w',
37030
- '\u1E83': 'w',
37031
- '\u0175': 'w',
37032
- '\u1E87': 'w',
37033
- '\u1E85': 'w',
37034
- '\u1E98': 'w',
37035
- '\u1E89': 'w',
37036
- '\u2C73': 'w',
37037
- '\u24E7': 'x',
37038
- '\uFF58': 'x',
37039
- '\u1E8B': 'x',
37040
- '\u1E8D': 'x',
37041
- '\u24E8': 'y',
37042
- '\uFF59': 'y',
37043
- '\u1EF3': 'y',
37044
- '\u00FD': 'y',
37045
- '\u0177': 'y',
37046
- '\u1EF9': 'y',
37047
- '\u0233': 'y',
37048
- '\u1E8F': 'y',
37049
- '\u00FF': 'y',
37050
- '\u1EF7': 'y',
37051
- '\u1E99': 'y',
37052
- '\u1EF5': 'y',
37053
- '\u01B4': 'y',
37054
- '\u024F': 'y',
37055
- '\u1EFF': 'y',
37056
- '\u24E9': 'z',
37057
- '\uFF5A': 'z',
37058
- '\u017A': 'z',
37059
- '\u1E91': 'z',
37060
- '\u017C': 'z',
37061
- '\u017E': 'z',
37062
- '\u1E93': 'z',
37063
- '\u1E95': 'z',
37064
- '\u01B6': 'z',
37065
- '\u0225': 'z',
37066
- '\u0240': 'z',
37067
- '\u2C6C': 'z',
37068
- '\uA763': 'z',
37069
- '\u0386': '\u0391',
37070
- '\u0388': '\u0395',
37071
- '\u0389': '\u0397',
37072
- '\u038A': '\u0399',
37073
- '\u03AA': '\u0399',
37074
- '\u038C': '\u039F',
37075
- '\u038E': '\u03A5',
37076
- '\u03AB': '\u03A5',
37077
- '\u038F': '\u03A9',
37078
- '\u03AC': '\u03B1',
37079
- '\u03AD': '\u03B5',
37080
- '\u03AE': '\u03B7',
37081
- '\u03AF': '\u03B9',
37082
- '\u03CA': '\u03B9',
37083
- '\u0390': '\u03B9',
37084
- '\u03CC': '\u03BF',
37085
- '\u03CD': '\u03C5',
37086
- '\u03CB': '\u03C5',
37087
- '\u03B0': '\u03C5',
37088
- '\u03C9': '\u03C9',
37089
- '\u03C2': '\u03C3'
37090
- };
37091
-
37092
- return diacritics;
37093
- });
37094
-
37095
- S2.define('select2/data/base',[
37096
- '../utils'
37097
- ], function (Utils) {
37098
- function BaseAdapter ($element, options) {
37099
- BaseAdapter.__super__.constructor.call(this);
37100
- }
37101
-
37102
- Utils.Extend(BaseAdapter, Utils.Observable);
37103
-
37104
- BaseAdapter.prototype.current = function (callback) {
37105
- throw new Error('The `current` method must be defined in child classes.');
37106
- };
37107
-
37108
- BaseAdapter.prototype.query = function (params, callback) {
37109
- throw new Error('The `query` method must be defined in child classes.');
37110
- };
37111
-
37112
- BaseAdapter.prototype.bind = function (container, $container) {
37113
- // Can be implemented in subclasses
37114
- };
37115
-
37116
- BaseAdapter.prototype.destroy = function () {
37117
- // Can be implemented in subclasses
37118
- };
37119
-
37120
- BaseAdapter.prototype.generateResultId = function (container, data) {
37121
- var id = container.id + '-result-';
37122
-
37123
- id += Utils.generateChars(4);
37124
-
37125
- if (data.id != null) {
37126
- id += '-' + data.id.toString();
37127
- } else {
37128
- id += '-' + Utils.generateChars(4);
37129
- }
37130
- return id;
37131
- };
37132
-
37133
- return BaseAdapter;
37134
- });
37135
-
37136
- S2.define('select2/data/select',[
37137
- './base',
37138
- '../utils',
37139
- 'jquery'
37140
- ], function (BaseAdapter, Utils, $) {
37141
- function SelectAdapter ($element, options) {
37142
- this.$element = $element;
37143
- this.options = options;
37144
-
37145
- SelectAdapter.__super__.constructor.call(this);
37146
- }
37147
-
37148
- Utils.Extend(SelectAdapter, BaseAdapter);
37149
-
37150
- SelectAdapter.prototype.current = function (callback) {
37151
- var data = [];
37152
- var self = this;
37153
-
37154
- this.$element.find(':selected').each(function () {
37155
- var $option = $(this);
37156
-
37157
- var option = self.item($option);
37158
-
37159
- data.push(option);
37160
- });
37161
-
37162
- callback(data);
37163
- };
37164
-
37165
- SelectAdapter.prototype.select = function (data) {
37166
- var self = this;
37167
-
37168
- data.selected = true;
37169
-
37170
- // If data.element is a DOM node, use it instead
37171
- if ($(data.element).is('option')) {
37172
- data.element.selected = true;
37173
-
37174
- this.$element.trigger('change');
37175
-
37176
- return;
37177
- }
37178
-
37179
- if (this.$element.prop('multiple')) {
37180
- this.current(function (currentData) {
37181
- var val = [];
37182
-
37183
- data = [data];
37184
- data.push.apply(data, currentData);
37185
-
37186
- for (var d = 0; d < data.length; d++) {
37187
- var id = data[d].id;
37188
-
37189
- if ($.inArray(id, val) === -1) {
37190
- val.push(id);
37191
- }
37192
- }
37193
-
37194
- self.$element.val(val);
37195
- self.$element.trigger('change');
37196
- });
37197
- } else {
37198
- var val = data.id;
37199
-
37200
- this.$element.val(val);
37201
- this.$element.trigger('change');
37202
- }
37203
- };
37204
-
37205
- SelectAdapter.prototype.unselect = function (data) {
37206
- var self = this;
37207
-
37208
- if (!this.$element.prop('multiple')) {
37209
- return;
37210
- }
37211
-
37212
- data.selected = false;
37213
-
37214
- if ($(data.element).is('option')) {
37215
- data.element.selected = false;
37216
-
37217
- this.$element.trigger('change');
37218
-
37219
- return;
37220
- }
37221
-
37222
- this.current(function (currentData) {
37223
- var val = [];
37224
-
37225
- for (var d = 0; d < currentData.length; d++) {
37226
- var id = currentData[d].id;
37227
-
37228
- if (id !== data.id && $.inArray(id, val) === -1) {
37229
- val.push(id);
37230
- }
37231
- }
37232
-
37233
- self.$element.val(val);
37234
-
37235
- self.$element.trigger('change');
37236
- });
37237
- };
37238
-
37239
- SelectAdapter.prototype.bind = function (container, $container) {
37240
- var self = this;
37241
-
37242
- this.container = container;
37243
-
37244
- container.on('select', function (params) {
37245
- self.select(params.data);
37246
- });
37247
-
37248
- container.on('unselect', function (params) {
37249
- self.unselect(params.data);
37250
- });
37251
- };
37252
-
37253
- SelectAdapter.prototype.destroy = function () {
37254
- // Remove anything added to child elements
37255
- this.$element.find('*').each(function () {
37256
- // Remove any custom data set by Select2
37257
- $.removeData(this, 'data');
37258
- });
37259
- };
37260
-
37261
- SelectAdapter.prototype.query = function (params, callback) {
37262
- var data = [];
37263
- var self = this;
37264
-
37265
- var $options = this.$element.children();
37266
-
37267
- $options.each(function () {
37268
- var $option = $(this);
37269
-
37270
- if (!$option.is('option') && !$option.is('optgroup')) {
37271
- return;
37272
- }
37273
-
37274
- var option = self.item($option);
37275
-
37276
- var matches = self.matches(params, option);
37277
-
37278
- if (matches !== null) {
37279
- data.push(matches);
37280
- }
37281
- });
37282
-
37283
- callback({
37284
- results: data
37285
- });
37286
- };
37287
-
37288
- SelectAdapter.prototype.addOptions = function ($options) {
37289
- Utils.appendMany(this.$element, $options);
37290
- };
37291
-
37292
- SelectAdapter.prototype.option = function (data) {
37293
- var option;
37294
-
37295
- if (data.children) {
37296
- option = document.createElement('optgroup');
37297
- option.label = data.text;
37298
- } else {
37299
- option = document.createElement('option');
37300
-
37301
- if (option.textContent !== undefined) {
37302
- option.textContent = data.text;
37303
- } else {
37304
- option.innerText = data.text;
37305
- }
37306
- }
37307
-
37308
- if (data.id !== undefined) {
37309
- option.value = data.id;
37310
- }
37311
-
37312
- if (data.disabled) {
37313
- option.disabled = true;
37314
- }
37315
-
37316
- if (data.selected) {
37317
- option.selected = true;
37318
- }
37319
-
37320
- if (data.title) {
37321
- option.title = data.title;
37322
- }
37323
-
37324
- var $option = $(option);
37325
-
37326
- var normalizedData = this._normalizeItem(data);
37327
- normalizedData.element = option;
37328
-
37329
- // Override the option's data with the combined data
37330
- $.data(option, 'data', normalizedData);
37331
-
37332
- return $option;
37333
- };
37334
-
37335
- SelectAdapter.prototype.item = function ($option) {
37336
- var data = {};
37337
-
37338
- data = $.data($option[0], 'data');
37339
-
37340
- if (data != null) {
37341
- return data;
37342
- }
37343
-
37344
- if ($option.is('option')) {
37345
- data = {
37346
- id: $option.val(),
37347
- text: $option.text(),
37348
- disabled: $option.prop('disabled'),
37349
- selected: $option.prop('selected'),
37350
- title: $option.prop('title')
37351
- };
37352
- } else if ($option.is('optgroup')) {
37353
- data = {
37354
- text: $option.prop('label'),
37355
- children: [],
37356
- title: $option.prop('title')
37357
- };
37358
-
37359
- var $children = $option.children('option');
37360
- var children = [];
37361
-
37362
- for (var c = 0; c < $children.length; c++) {
37363
- var $child = $($children[c]);
37364
-
37365
- var child = this.item($child);
37366
-
37367
- children.push(child);
37368
- }
37369
-
37370
- data.children = children;
37371
- }
37372
-
37373
- data = this._normalizeItem(data);
37374
- data.element = $option[0];
37375
-
37376
- $.data($option[0], 'data', data);
37377
-
37378
- return data;
37379
- };
37380
-
37381
- SelectAdapter.prototype._normalizeItem = function (item) {
37382
- if (!$.isPlainObject(item)) {
37383
- item = {
37384
- id: item,
37385
- text: item
37386
- };
37387
- }
37388
-
37389
- item = $.extend({}, {
37390
- text: ''
37391
- }, item);
37392
-
37393
- var defaults = {
37394
- selected: false,
37395
- disabled: false
37396
- };
37397
-
37398
- if (item.id != null) {
37399
- item.id = item.id.toString();
37400
- }
37401
-
37402
- if (item.text != null) {
37403
- item.text = item.text.toString();
37404
- }
37405
-
37406
- if (item._resultId == null && item.id && this.container != null) {
37407
- item._resultId = this.generateResultId(this.container, item);
37408
- }
37409
-
37410
- return $.extend({}, defaults, item);
37411
- };
37412
-
37413
- SelectAdapter.prototype.matches = function (params, data) {
37414
- var matcher = this.options.get('matcher');
37415
-
37416
- return matcher(params, data);
37417
- };
37418
-
37419
- return SelectAdapter;
37420
- });
37421
-
37422
- S2.define('select2/data/array',[
37423
- './select',
37424
- '../utils',
37425
- 'jquery'
37426
- ], function (SelectAdapter, Utils, $) {
37427
- function ArrayAdapter ($element, options) {
37428
- var data = options.get('data') || [];
37429
-
37430
- ArrayAdapter.__super__.constructor.call(this, $element, options);
37431
-
37432
- this.addOptions(this.convertToOptions(data));
37433
- }
37434
-
37435
- Utils.Extend(ArrayAdapter, SelectAdapter);
37436
-
37437
- ArrayAdapter.prototype.select = function (data) {
37438
- var $option = this.$element.find('option').filter(function (i, elm) {
37439
- return elm.value == data.id.toString();
37440
- });
37441
-
37442
- if ($option.length === 0) {
37443
- $option = this.option(data);
37444
-
37445
- this.addOptions($option);
37446
- }
37447
-
37448
- ArrayAdapter.__super__.select.call(this, data);
37449
- };
37450
-
37451
- ArrayAdapter.prototype.convertToOptions = function (data) {
37452
- var self = this;
37453
-
37454
- var $existing = this.$element.find('option');
37455
- var existingIds = $existing.map(function () {
37456
- return self.item($(this)).id;
37457
- }).get();
37458
-
37459
- var $options = [];
37460
-
37461
- // Filter out all items except for the one passed in the argument
37462
- function onlyItem (item) {
37463
- return function () {
37464
- return $(this).val() == item.id;
37465
- };
37466
- }
37467
-
37468
- for (var d = 0; d < data.length; d++) {
37469
- var item = this._normalizeItem(data[d]);
37470
-
37471
- // Skip items which were pre-loaded, only merge the data
37472
- if ($.inArray(item.id, existingIds) >= 0) {
37473
- var $existingOption = $existing.filter(onlyItem(item));
37474
-
37475
- var existingData = this.item($existingOption);
37476
- var newData = $.extend(true, {}, item, existingData);
37477
-
37478
- var $newOption = this.option(newData);
37479
-
37480
- $existingOption.replaceWith($newOption);
37481
-
37482
- continue;
37483
- }
37484
-
37485
- var $option = this.option(item);
37486
-
37487
- if (item.children) {
37488
- var $children = this.convertToOptions(item.children);
37489
-
37490
- Utils.appendMany($option, $children);
37491
- }
37492
-
37493
- $options.push($option);
37494
- }
37495
-
37496
- return $options;
37497
- };
37498
-
37499
- return ArrayAdapter;
37500
- });
37501
-
37502
- S2.define('select2/data/ajax',[
37503
- './array',
37504
- '../utils',
37505
- 'jquery'
37506
- ], function (ArrayAdapter, Utils, $) {
37507
- function AjaxAdapter ($element, options) {
37508
- this.ajaxOptions = this._applyDefaults(options.get('ajax'));
37509
-
37510
- if (this.ajaxOptions.processResults != null) {
37511
- this.processResults = this.ajaxOptions.processResults;
37512
- }
37513
-
37514
- AjaxAdapter.__super__.constructor.call(this, $element, options);
37515
- }
37516
-
37517
- Utils.Extend(AjaxAdapter, ArrayAdapter);
37518
-
37519
- AjaxAdapter.prototype._applyDefaults = function (options) {
37520
- var defaults = {
37521
- data: function (params) {
37522
- return $.extend({}, params, {
37523
- q: params.term
37524
- });
37525
- },
37526
- transport: function (params, success, failure) {
37527
- var $request = $.ajax(params);
37528
-
37529
- $request.then(success);
37530
- $request.fail(failure);
37531
-
37532
- return $request;
37533
- }
37534
- };
37535
-
37536
- return $.extend({}, defaults, options, true);
37537
- };
37538
-
37539
- AjaxAdapter.prototype.processResults = function (results) {
37540
- return results;
37541
- };
37542
-
37543
- AjaxAdapter.prototype.query = function (params, callback) {
37544
- var matches = [];
37545
- var self = this;
37546
-
37547
- if (this._request != null) {
37548
- // JSONP requests cannot always be aborted
37549
- if ($.isFunction(this._request.abort)) {
37550
- this._request.abort();
37551
- }
37552
-
37553
- this._request = null;
37554
- }
37555
-
37556
- var options = $.extend({
37557
- type: 'GET'
37558
- }, this.ajaxOptions);
37559
-
37560
- if (typeof options.url === 'function') {
37561
- options.url = options.url.call(this.$element, params);
37562
- }
37563
-
37564
- if (typeof options.data === 'function') {
37565
- options.data = options.data.call(this.$element, params);
37566
- }
37567
-
37568
- function request () {
37569
- var $request = options.transport(options, function (data) {
37570
- var results = self.processResults(data, params);
37571
-
37572
- if (self.options.get('debug') && window.console && console.error) {
37573
- // Check to make sure that the response included a `results` key.
37574
- if (!results || !results.results || !$.isArray(results.results)) {
37575
- console.error(
37576
- 'Select2: The AJAX results did not return an array in the ' +
37577
- '`results` key of the response.'
37578
- );
37579
- }
37580
- }
37581
-
37582
- callback(results);
37583
- }, function () {
37584
- // Attempt to detect if a request was aborted
37585
- // Only works if the transport exposes a status property
37586
- if ($request.status && $request.status === '0') {
37587
- return;
37588
- }
37589
-
37590
- self.trigger('results:message', {
37591
- message: 'errorLoading'
37592
- });
37593
- });
37594
-
37595
- self._request = $request;
37596
- }
37597
-
37598
- if (this.ajaxOptions.delay && params.term != null) {
37599
- if (this._queryTimeout) {
37600
- window.clearTimeout(this._queryTimeout);
37601
- }
37602
-
37603
- this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
37604
- } else {
37605
- request();
37606
- }
37607
- };
37608
-
37609
- return AjaxAdapter;
37610
- });
37611
-
37612
- S2.define('select2/data/tags',[
37613
- 'jquery'
37614
- ], function ($) {
37615
- function Tags (decorated, $element, options) {
37616
- var tags = options.get('tags');
37617
-
37618
- var createTag = options.get('createTag');
37619
-
37620
- if (createTag !== undefined) {
37621
- this.createTag = createTag;
37622
- }
37623
-
37624
- var insertTag = options.get('insertTag');
37625
-
37626
- if (insertTag !== undefined) {
37627
- this.insertTag = insertTag;
37628
- }
37629
-
37630
- decorated.call(this, $element, options);
37631
-
37632
- if ($.isArray(tags)) {
37633
- for (var t = 0; t < tags.length; t++) {
37634
- var tag = tags[t];
37635
- var item = this._normalizeItem(tag);
37636
-
37637
- var $option = this.option(item);
37638
-
37639
- this.$element.append($option);
37640
- }
37641
- }
37642
- }
37643
-
37644
- Tags.prototype.query = function (decorated, params, callback) {
37645
- var self = this;
37646
-
37647
- this._removeOldTags();
37648
-
37649
- if (params.term == null || params.page != null) {
37650
- decorated.call(this, params, callback);
37651
- return;
37652
- }
37653
-
37654
- function wrapper (obj, child) {
37655
- var data = obj.results;
37656
-
37657
- for (var i = 0; i < data.length; i++) {
37658
- var option = data[i];
37659
-
37660
- var checkChildren = (
37661
- option.children != null &&
37662
- !wrapper({
37663
- results: option.children
37664
- }, true)
37665
- );
37666
-
37667
- var optionText = (option.text || '').toUpperCase();
37668
- var paramsTerm = (params.term || '').toUpperCase();
37669
-
37670
- var checkText = optionText === paramsTerm;
37671
-
37672
- if (checkText || checkChildren) {
37673
- if (child) {
37674
- return false;
37675
- }
37676
-
37677
- obj.data = data;
37678
- callback(obj);
37679
-
37680
- return;
37681
- }
37682
- }
37683
-
37684
- if (child) {
37685
- return true;
37686
- }
37687
-
37688
- var tag = self.createTag(params);
37689
-
37690
- if (tag != null) {
37691
- var $option = self.option(tag);
37692
- $option.attr('data-select2-tag', true);
37693
-
37694
- self.addOptions([$option]);
37695
-
37696
- self.insertTag(data, tag);
37697
- }
37698
-
37699
- obj.results = data;
37700
-
37701
- callback(obj);
37702
- }
37703
-
37704
- decorated.call(this, params, wrapper);
37705
- };
37706
-
37707
- Tags.prototype.createTag = function (decorated, params) {
37708
- var term = $.trim(params.term);
37709
-
37710
- if (term === '') {
37711
- return null;
37712
- }
37713
-
37714
- return {
37715
- id: term,
37716
- text: term
37717
- };
37718
- };
37719
-
37720
- Tags.prototype.insertTag = function (_, data, tag) {
37721
- data.unshift(tag);
37722
- };
37723
-
37724
- Tags.prototype._removeOldTags = function (_) {
37725
- var tag = this._lastTag;
37726
-
37727
- var $options = this.$element.find('option[data-select2-tag]');
37728
-
37729
- $options.each(function () {
37730
- if (this.selected) {
37731
- return;
37732
- }
37733
-
37734
- $(this).remove();
37735
- });
37736
- };
37737
-
37738
- return Tags;
37739
- });
37740
-
37741
- S2.define('select2/data/tokenizer',[
37742
- 'jquery'
37743
- ], function ($) {
37744
- function Tokenizer (decorated, $element, options) {
37745
- var tokenizer = options.get('tokenizer');
37746
-
37747
- if (tokenizer !== undefined) {
37748
- this.tokenizer = tokenizer;
37749
- }
37750
-
37751
- decorated.call(this, $element, options);
37752
- }
37753
-
37754
- Tokenizer.prototype.bind = function (decorated, container, $container) {
37755
- decorated.call(this, container, $container);
37756
-
37757
- this.$search = container.dropdown.$search || container.selection.$search ||
37758
- $container.find('.select2-search__field');
37759
- };
37760
-
37761
- Tokenizer.prototype.query = function (decorated, params, callback) {
37762
- var self = this;
37763
-
37764
- function createAndSelect (data) {
37765
- // Normalize the data object so we can use it for checks
37766
- var item = self._normalizeItem(data);
37767
-
37768
- // Check if the data object already exists as a tag
37769
- // Select it if it doesn't
37770
- var $existingOptions = self.$element.find('option').filter(function () {
37771
- return $(this).val() === item.id;
37772
- });
37773
-
37774
- // If an existing option wasn't found for it, create the option
37775
- if (!$existingOptions.length) {
37776
- var $option = self.option(item);
37777
- $option.attr('data-select2-tag', true);
37778
-
37779
- self._removeOldTags();
37780
- self.addOptions([$option]);
37781
- }
37782
-
37783
- // Select the item, now that we know there is an option for it
37784
- select(item);
37785
- }
37786
-
37787
- function select (data) {
37788
- self.trigger('select', {
37789
- data: data
37790
- });
37791
- }
37792
-
37793
- params.term = params.term || '';
37794
-
37795
- var tokenData = this.tokenizer(params, this.options, createAndSelect);
37796
-
37797
- if (tokenData.term !== params.term) {
37798
- // Replace the search term if we have the search box
37799
- if (this.$search.length) {
37800
- this.$search.val(tokenData.term);
37801
- this.$search.focus();
37802
- }
37803
-
37804
- params.term = tokenData.term;
37805
- }
37806
-
37807
- decorated.call(this, params, callback);
37808
- };
37809
-
37810
- Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
37811
- var separators = options.get('tokenSeparators') || [];
37812
- var term = params.term;
37813
- var i = 0;
37814
-
37815
- var createTag = this.createTag || function (params) {
37816
- return {
37817
- id: params.term,
37818
- text: params.term
37819
- };
37820
- };
37821
-
37822
- while (i < term.length) {
37823
- var termChar = term[i];
37824
-
37825
- if ($.inArray(termChar, separators) === -1) {
37826
- i++;
37827
-
37828
- continue;
37829
- }
37830
-
37831
- var part = term.substr(0, i);
37832
- var partParams = $.extend({}, params, {
37833
- term: part
37834
- });
37835
-
37836
- var data = createTag(partParams);
37837
-
37838
- if (data == null) {
37839
- i++;
37840
- continue;
37841
- }
37842
-
37843
- callback(data);
37844
-
37845
- // Reset the term to not include the tokenized portion
37846
- term = term.substr(i + 1) || '';
37847
- i = 0;
37848
- }
37849
-
37850
- return {
37851
- term: term
37852
- };
37853
- };
37854
-
37855
- return Tokenizer;
37856
- });
37857
-
37858
- S2.define('select2/data/minimumInputLength',[
37859
-
37860
- ], function () {
37861
- function MinimumInputLength (decorated, $e, options) {
37862
- this.minimumInputLength = options.get('minimumInputLength');
37863
-
37864
- decorated.call(this, $e, options);
37865
- }
37866
-
37867
- MinimumInputLength.prototype.query = function (decorated, params, callback) {
37868
- params.term = params.term || '';
37869
-
37870
- if (params.term.length < this.minimumInputLength) {
37871
- this.trigger('results:message', {
37872
- message: 'inputTooShort',
37873
- args: {
37874
- minimum: this.minimumInputLength,
37875
- input: params.term,
37876
- params: params
37877
- }
37878
- });
37879
-
37880
- return;
37881
- }
37882
-
37883
- decorated.call(this, params, callback);
37884
- };
37885
-
37886
- return MinimumInputLength;
37887
- });
37888
-
37889
- S2.define('select2/data/maximumInputLength',[
37890
-
37891
- ], function () {
37892
- function MaximumInputLength (decorated, $e, options) {
37893
- this.maximumInputLength = options.get('maximumInputLength');
37894
-
37895
- decorated.call(this, $e, options);
37896
- }
37897
-
37898
- MaximumInputLength.prototype.query = function (decorated, params, callback) {
37899
- params.term = params.term || '';
37900
-
37901
- if (this.maximumInputLength > 0 &&
37902
- params.term.length > this.maximumInputLength) {
37903
- this.trigger('results:message', {
37904
- message: 'inputTooLong',
37905
- args: {
37906
- maximum: this.maximumInputLength,
37907
- input: params.term,
37908
- params: params
37909
- }
37910
- });
37911
-
37912
- return;
37913
- }
37914
-
37915
- decorated.call(this, params, callback);
37916
- };
37917
-
37918
- return MaximumInputLength;
37919
- });
37920
-
37921
- S2.define('select2/data/maximumSelectionLength',[
37922
-
37923
- ], function (){
37924
- function MaximumSelectionLength (decorated, $e, options) {
37925
- this.maximumSelectionLength = options.get('maximumSelectionLength');
37926
-
37927
- decorated.call(this, $e, options);
37928
- }
37929
-
37930
- MaximumSelectionLength.prototype.query =
37931
- function (decorated, params, callback) {
37932
- var self = this;
37933
-
37934
- this.current(function (currentData) {
37935
- var count = currentData != null ? currentData.length : 0;
37936
- if (self.maximumSelectionLength > 0 &&
37937
- count >= self.maximumSelectionLength) {
37938
- self.trigger('results:message', {
37939
- message: 'maximumSelected',
37940
- args: {
37941
- maximum: self.maximumSelectionLength
37942
- }
37943
- });
37944
- return;
37945
- }
37946
- decorated.call(self, params, callback);
37947
- });
37948
- };
37949
-
37950
- return MaximumSelectionLength;
37951
- });
37952
-
37953
- S2.define('select2/dropdown',[
37954
- 'jquery',
37955
- './utils'
37956
- ], function ($, Utils) {
37957
- function Dropdown ($element, options) {
37958
- this.$element = $element;
37959
- this.options = options;
37960
-
37961
- Dropdown.__super__.constructor.call(this);
37962
- }
37963
-
37964
- Utils.Extend(Dropdown, Utils.Observable);
37965
-
37966
- Dropdown.prototype.render = function () {
37967
- var $dropdown = $(
37968
- '<span class="select2-dropdown">' +
37969
- '<span class="select2-results"></span>' +
37970
- '</span>'
37971
- );
37972
-
37973
- $dropdown.attr('dir', this.options.get('dir'));
37974
-
37975
- this.$dropdown = $dropdown;
37976
-
37977
- return $dropdown;
37978
- };
37979
-
37980
- Dropdown.prototype.bind = function () {
37981
- // Should be implemented in subclasses
37982
- };
37983
-
37984
- Dropdown.prototype.position = function ($dropdown, $container) {
37985
- // Should be implmented in subclasses
37986
- };
37987
-
37988
- Dropdown.prototype.destroy = function () {
37989
- // Remove the dropdown from the DOM
37990
- this.$dropdown.remove();
37991
- };
37992
-
37993
- return Dropdown;
37994
- });
37995
-
37996
- S2.define('select2/dropdown/search',[
37997
- 'jquery',
37998
- '../utils'
37999
- ], function ($, Utils) {
38000
- function Search () { }
38001
-
38002
- Search.prototype.render = function (decorated) {
38003
- var $rendered = decorated.call(this);
38004
-
38005
- var $search = $(
38006
- '<span class="select2-search select2-search--dropdown">' +
38007
- '<input class="select2-search__field" type="search" tabindex="-1"' +
38008
- ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
38009
- ' spellcheck="false" role="textbox" />' +
38010
- '</span>'
38011
- );
38012
-
38013
- this.$searchContainer = $search;
38014
- this.$search = $search.find('input');
38015
-
38016
- $rendered.prepend($search);
38017
-
38018
- return $rendered;
38019
- };
38020
-
38021
- Search.prototype.bind = function (decorated, container, $container) {
38022
- var self = this;
38023
-
38024
- decorated.call(this, container, $container);
38025
-
38026
- this.$search.on('keydown', function (evt) {
38027
- self.trigger('keypress', evt);
38028
-
38029
- self._keyUpPrevented = evt.isDefaultPrevented();
38030
- });
38031
-
38032
- // Workaround for browsers which do not support the `input` event
38033
- // This will prevent double-triggering of events for browsers which support
38034
- // both the `keyup` and `input` events.
38035
- this.$search.on('input', function (evt) {
38036
- // Unbind the duplicated `keyup` event
38037
- $(this).off('keyup');
38038
- });
38039
-
38040
- this.$search.on('keyup input', function (evt) {
38041
- self.handleSearch(evt);
38042
- });
38043
-
38044
- container.on('open', function () {
38045
- self.$search.attr('tabindex', 0);
38046
-
38047
- self.$search.focus();
38048
-
38049
- window.setTimeout(function () {
38050
- self.$search.focus();
38051
- }, 0);
38052
- });
38053
-
38054
- container.on('close', function () {
38055
- self.$search.attr('tabindex', -1);
38056
-
38057
- self.$search.val('');
38058
- });
38059
-
38060
- container.on('focus', function () {
38061
- if (!container.isOpen()) {
38062
- self.$search.focus();
38063
- }
38064
- });
38065
-
38066
- container.on('results:all', function (params) {
38067
- if (params.query.term == null || params.query.term === '') {
38068
- var showSearch = self.showSearch(params);
38069
-
38070
- if (showSearch) {
38071
- self.$searchContainer.removeClass('select2-search--hide');
38072
- } else {
38073
- self.$searchContainer.addClass('select2-search--hide');
38074
- }
38075
- }
38076
- });
38077
- };
38078
-
38079
- Search.prototype.handleSearch = function (evt) {
38080
- if (!this._keyUpPrevented) {
38081
- var input = this.$search.val();
38082
-
38083
- this.trigger('query', {
38084
- term: input
38085
- });
38086
- }
38087
-
38088
- this._keyUpPrevented = false;
38089
- };
38090
-
38091
- Search.prototype.showSearch = function (_, params) {
38092
- return true;
38093
- };
38094
-
38095
- return Search;
38096
- });
38097
-
38098
- S2.define('select2/dropdown/hidePlaceholder',[
38099
-
38100
- ], function () {
38101
- function HidePlaceholder (decorated, $element, options, dataAdapter) {
38102
- this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
38103
-
38104
- decorated.call(this, $element, options, dataAdapter);
38105
- }
38106
-
38107
- HidePlaceholder.prototype.append = function (decorated, data) {
38108
- data.results = this.removePlaceholder(data.results);
38109
-
38110
- decorated.call(this, data);
38111
- };
38112
-
38113
- HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
38114
- if (typeof placeholder === 'string') {
38115
- placeholder = {
38116
- id: '',
38117
- text: placeholder
38118
- };
38119
- }
38120
-
38121
- return placeholder;
38122
- };
38123
-
38124
- HidePlaceholder.prototype.removePlaceholder = function (_, data) {
38125
- var modifiedData = data.slice(0);
38126
-
38127
- for (var d = data.length - 1; d >= 0; d--) {
38128
- var item = data[d];
38129
-
38130
- if (this.placeholder.id === item.id) {
38131
- modifiedData.splice(d, 1);
38132
- }
38133
- }
38134
-
38135
- return modifiedData;
38136
- };
38137
-
38138
- return HidePlaceholder;
38139
- });
38140
-
38141
- S2.define('select2/dropdown/infiniteScroll',[
38142
- 'jquery'
38143
- ], function ($) {
38144
- function InfiniteScroll (decorated, $element, options, dataAdapter) {
38145
- this.lastParams = {};
38146
-
38147
- decorated.call(this, $element, options, dataAdapter);
38148
-
38149
- this.$loadingMore = this.createLoadingMore();
38150
- this.loading = false;
38151
- }
38152
-
38153
- InfiniteScroll.prototype.append = function (decorated, data) {
38154
- this.$loadingMore.remove();
38155
- this.loading = false;
38156
-
38157
- decorated.call(this, data);
38158
-
38159
- if (this.showLoadingMore(data)) {
38160
- this.$results.append(this.$loadingMore);
38161
- }
38162
- };
38163
-
38164
- InfiniteScroll.prototype.bind = function (decorated, container, $container) {
38165
- var self = this;
38166
-
38167
- decorated.call(this, container, $container);
38168
-
38169
- container.on('query', function (params) {
38170
- self.lastParams = params;
38171
- self.loading = true;
38172
- });
38173
-
38174
- container.on('query:append', function (params) {
38175
- self.lastParams = params;
38176
- self.loading = true;
38177
- });
38178
-
38179
- this.$results.on('scroll', function () {
38180
- var isLoadMoreVisible = $.contains(
38181
- document.documentElement,
38182
- self.$loadingMore[0]
38183
- );
38184
-
38185
- if (self.loading || !isLoadMoreVisible) {
38186
- return;
38187
- }
38188
-
38189
- var currentOffset = self.$results.offset().top +
38190
- self.$results.outerHeight(false);
38191
- var loadingMoreOffset = self.$loadingMore.offset().top +
38192
- self.$loadingMore.outerHeight(false);
38193
-
38194
- if (currentOffset + 50 >= loadingMoreOffset) {
38195
- self.loadMore();
38196
- }
38197
- });
38198
- };
38199
-
38200
- InfiniteScroll.prototype.loadMore = function () {
38201
- this.loading = true;
38202
-
38203
- var params = $.extend({}, {page: 1}, this.lastParams);
38204
-
38205
- params.page++;
38206
-
38207
- this.trigger('query:append', params);
38208
- };
38209
-
38210
- InfiniteScroll.prototype.showLoadingMore = function (_, data) {
38211
- return data.pagination && data.pagination.more;
38212
- };
38213
-
38214
- InfiniteScroll.prototype.createLoadingMore = function () {
38215
- var $option = $(
38216
- '<li ' +
38217
- 'class="select2-results__option select2-results__option--load-more"' +
38218
- 'role="treeitem" aria-disabled="true"></li>'
38219
- );
38220
-
38221
- var message = this.options.get('translations').get('loadingMore');
38222
-
38223
- $option.html(message(this.lastParams));
38224
-
38225
- return $option;
38226
- };
38227
-
38228
- return InfiniteScroll;
38229
- });
38230
-
38231
- S2.define('select2/dropdown/attachBody',[
38232
- 'jquery',
38233
- '../utils'
38234
- ], function ($, Utils) {
38235
- function AttachBody (decorated, $element, options) {
38236
- this.$dropdownParent = options.get('dropdownParent') || $(document.body);
38237
-
38238
- decorated.call(this, $element, options);
38239
- }
38240
-
38241
- AttachBody.prototype.bind = function (decorated, container, $container) {
38242
- var self = this;
38243
-
38244
- var setupResultsEvents = false;
38245
-
38246
- decorated.call(this, container, $container);
38247
-
38248
- container.on('open', function () {
38249
- self._showDropdown();
38250
- self._attachPositioningHandler(container);
38251
-
38252
- if (!setupResultsEvents) {
38253
- setupResultsEvents = true;
38254
-
38255
- container.on('results:all', function () {
38256
- self._positionDropdown();
38257
- self._resizeDropdown();
38258
- });
38259
-
38260
- container.on('results:append', function () {
38261
- self._positionDropdown();
38262
- self._resizeDropdown();
38263
- });
38264
- }
38265
- });
38266
-
38267
- container.on('close', function () {
38268
- self._hideDropdown();
38269
- self._detachPositioningHandler(container);
38270
- });
38271
-
38272
- this.$dropdownContainer.on('mousedown', function (evt) {
38273
- evt.stopPropagation();
38274
- });
38275
- };
38276
-
38277
- AttachBody.prototype.destroy = function (decorated) {
38278
- decorated.call(this);
38279
-
38280
- this.$dropdownContainer.remove();
38281
- };
38282
-
38283
- AttachBody.prototype.position = function (decorated, $dropdown, $container) {
38284
- // Clone all of the container classes
38285
- $dropdown.attr('class', $container.attr('class'));
38286
-
38287
- $dropdown.removeClass('select2');
38288
- $dropdown.addClass('select2-container--open');
38289
-
38290
- $dropdown.css({
38291
- position: 'absolute',
38292
- top: -999999
38293
- });
38294
-
38295
- this.$container = $container;
38296
- };
38297
-
38298
- AttachBody.prototype.render = function (decorated) {
38299
- var $container = $('<span></span>');
38300
-
38301
- var $dropdown = decorated.call(this);
38302
- $container.append($dropdown);
38303
-
38304
- this.$dropdownContainer = $container;
38305
-
38306
- return $container;
38307
- };
38308
-
38309
- AttachBody.prototype._hideDropdown = function (decorated) {
38310
- this.$dropdownContainer.detach();
38311
- };
38312
-
38313
- AttachBody.prototype._attachPositioningHandler =
38314
- function (decorated, container) {
38315
- var self = this;
38316
-
38317
- var scrollEvent = 'scroll.select2.' + container.id;
38318
- var resizeEvent = 'resize.select2.' + container.id;
38319
- var orientationEvent = 'orientationchange.select2.' + container.id;
38320
-
38321
- var $watchers = this.$container.parents().filter(Utils.hasScroll);
38322
- $watchers.each(function () {
38323
- $(this).data('select2-scroll-position', {
38324
- x: $(this).scrollLeft(),
38325
- y: $(this).scrollTop()
38326
- });
38327
- });
38328
-
38329
- $watchers.on(scrollEvent, function (ev) {
38330
- var position = $(this).data('select2-scroll-position');
38331
- $(this).scrollTop(position.y);
38332
- });
38333
-
38334
- $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
38335
- function (e) {
38336
- self._positionDropdown();
38337
- self._resizeDropdown();
38338
- });
38339
- };
38340
-
38341
- AttachBody.prototype._detachPositioningHandler =
38342
- function (decorated, container) {
38343
- var scrollEvent = 'scroll.select2.' + container.id;
38344
- var resizeEvent = 'resize.select2.' + container.id;
38345
- var orientationEvent = 'orientationchange.select2.' + container.id;
38346
-
38347
- var $watchers = this.$container.parents().filter(Utils.hasScroll);
38348
- $watchers.off(scrollEvent);
38349
-
38350
- $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
38351
- };
38352
-
38353
- AttachBody.prototype._positionDropdown = function () {
38354
- var $window = $(window);
38355
-
38356
- var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
38357
- var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
38358
-
38359
- var newDirection = null;
38360
-
38361
- var offset = this.$container.offset();
38362
-
38363
- offset.bottom = offset.top + this.$container.outerHeight(false);
38364
-
38365
- var container = {
38366
- height: this.$container.outerHeight(false)
38367
- };
38368
-
38369
- container.top = offset.top;
38370
- container.bottom = offset.top + container.height;
38371
-
38372
- var dropdown = {
38373
- height: this.$dropdown.outerHeight(false)
38374
- };
38375
-
38376
- var viewport = {
38377
- top: $window.scrollTop(),
38378
- bottom: $window.scrollTop() + $window.height()
38379
- };
38380
-
38381
- var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
38382
- var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
38383
-
38384
- var css = {
38385
- left: offset.left,
38386
- top: container.bottom
38387
- };
38388
-
38389
- // Determine what the parent element is to use for calciulating the offset
38390
- var $offsetParent = this.$dropdownParent;
38391
-
38392
- // For statically positoned elements, we need to get the element
38393
- // that is determining the offset
38394
- if ($offsetParent.css('position') === 'static') {
38395
- $offsetParent = $offsetParent.offsetParent();
38396
- }
38397
-
38398
- var parentOffset = $offsetParent.offset();
38399
-
38400
- css.top -= parentOffset.top;
38401
- css.left -= parentOffset.left;
38402
-
38403
- if (!isCurrentlyAbove && !isCurrentlyBelow) {
38404
- newDirection = 'below';
38405
- }
38406
-
38407
- if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
38408
- newDirection = 'above';
38409
- } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
38410
- newDirection = 'below';
38411
- }
38412
-
38413
- if (newDirection == 'above' ||
38414
- (isCurrentlyAbove && newDirection !== 'below')) {
38415
- css.top = container.top - parentOffset.top - dropdown.height;
38416
- }
38417
-
38418
- if (newDirection != null) {
38419
- this.$dropdown
38420
- .removeClass('select2-dropdown--below select2-dropdown--above')
38421
- .addClass('select2-dropdown--' + newDirection);
38422
- this.$container
38423
- .removeClass('select2-container--below select2-container--above')
38424
- .addClass('select2-container--' + newDirection);
38425
- }
38426
-
38427
- this.$dropdownContainer.css(css);
38428
- };
38429
-
38430
- AttachBody.prototype._resizeDropdown = function () {
38431
- var css = {
38432
- width: this.$container.outerWidth(false) + 'px'
38433
- };
38434
-
38435
- if (this.options.get('dropdownAutoWidth')) {
38436
- css.minWidth = css.width;
38437
- css.position = 'relative';
38438
- css.width = 'auto';
38439
- }
38440
-
38441
- this.$dropdown.css(css);
38442
- };
38443
-
38444
- AttachBody.prototype._showDropdown = function (decorated) {
38445
- this.$dropdownContainer.appendTo(this.$dropdownParent);
38446
-
38447
- this._positionDropdown();
38448
- this._resizeDropdown();
38449
- };
38450
-
38451
- return AttachBody;
38452
- });
38453
-
38454
- S2.define('select2/dropdown/minimumResultsForSearch',[
38455
-
38456
- ], function () {
38457
- function countResults (data) {
38458
- var count = 0;
38459
-
38460
- for (var d = 0; d < data.length; d++) {
38461
- var item = data[d];
38462
-
38463
- if (item.children) {
38464
- count += countResults(item.children);
38465
- } else {
38466
- count++;
38467
- }
38468
- }
38469
-
38470
- return count;
38471
- }
38472
-
38473
- function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
38474
- this.minimumResultsForSearch = options.get('minimumResultsForSearch');
38475
-
38476
- if (this.minimumResultsForSearch < 0) {
38477
- this.minimumResultsForSearch = Infinity;
38478
- }
38479
-
38480
- decorated.call(this, $element, options, dataAdapter);
38481
- }
38482
-
38483
- MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
38484
- if (countResults(params.data.results) < this.minimumResultsForSearch) {
38485
- return false;
38486
- }
38487
-
38488
- return decorated.call(this, params);
38489
- };
38490
-
38491
- return MinimumResultsForSearch;
38492
- });
38493
-
38494
- S2.define('select2/dropdown/selectOnClose',[
38495
-
38496
- ], function () {
38497
- function SelectOnClose () { }
38498
-
38499
- SelectOnClose.prototype.bind = function (decorated, container, $container) {
38500
- var self = this;
38501
-
38502
- decorated.call(this, container, $container);
38503
-
38504
- container.on('close', function (params) {
38505
- self._handleSelectOnClose(params);
38506
- });
38507
- };
38508
-
38509
- SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
38510
- if (params && params.originalSelect2Event != null) {
38511
- var event = params.originalSelect2Event;
38512
-
38513
- // Don't select an item if the close event was triggered from a select or
38514
- // unselect event
38515
- if (event._type === 'select' || event._type === 'unselect') {
38516
- return;
38517
- }
38518
- }
38519
-
38520
- var $highlightedResults = this.getHighlightedResults();
38521
-
38522
- // Only select highlighted results
38523
- if ($highlightedResults.length < 1) {
38524
- return;
38525
- }
38526
-
38527
- var data = $highlightedResults.data('data');
38528
-
38529
- // Don't re-select already selected resulte
38530
- if (
38531
- (data.element != null && data.element.selected) ||
38532
- (data.element == null && data.selected)
38533
- ) {
38534
- return;
38535
- }
38536
-
38537
- this.trigger('select', {
38538
- data: data
38539
- });
38540
- };
38541
-
38542
- return SelectOnClose;
38543
- });
38544
-
38545
- S2.define('select2/dropdown/closeOnSelect',[
38546
-
38547
- ], function () {
38548
- function CloseOnSelect () { }
38549
-
38550
- CloseOnSelect.prototype.bind = function (decorated, container, $container) {
38551
- var self = this;
38552
-
38553
- decorated.call(this, container, $container);
38554
-
38555
- container.on('select', function (evt) {
38556
- self._selectTriggered(evt);
38557
- });
38558
-
38559
- container.on('unselect', function (evt) {
38560
- self._selectTriggered(evt);
38561
- });
38562
- };
38563
-
38564
- CloseOnSelect.prototype._selectTriggered = function (_, evt) {
38565
- var originalEvent = evt.originalEvent;
38566
-
38567
- // Don't close if the control key is being held
38568
- if (originalEvent && originalEvent.ctrlKey) {
38569
- return;
38570
- }
38571
-
38572
- this.trigger('close', {
38573
- originalEvent: originalEvent,
38574
- originalSelect2Event: evt
38575
- });
38576
- };
38577
-
38578
- return CloseOnSelect;
38579
- });
38580
-
38581
- S2.define('select2/i18n/en',[],function () {
38582
- // English
38583
- return {
38584
- errorLoading: function () {
38585
- return 'The results could not be loaded.';
38586
- },
38587
- inputTooLong: function (args) {
38588
- var overChars = args.input.length - args.maximum;
38589
-
38590
- var message = 'Please delete ' + overChars + ' character';
38591
-
38592
- if (overChars != 1) {
38593
- message += 's';
38594
- }
38595
-
38596
- return message;
38597
- },
38598
- inputTooShort: function (args) {
38599
- var remainingChars = args.minimum - args.input.length;
38600
-
38601
- var message = 'Please enter ' + remainingChars + ' or more characters';
38602
-
38603
- return message;
38604
- },
38605
- loadingMore: function () {
38606
- return 'Loading more results…';
38607
- },
38608
- maximumSelected: function (args) {
38609
- var message = 'You can only select ' + args.maximum + ' item';
38610
-
38611
- if (args.maximum != 1) {
38612
- message += 's';
38613
- }
38614
-
38615
- return message;
38616
- },
38617
- noResults: function () {
38618
- return 'No results found';
38619
- },
38620
- searching: function () {
38621
- return 'Searching…';
38622
- }
38623
- };
38624
- });
38625
-
38626
- S2.define('select2/defaults',[
38627
- 'jquery',
38628
- 'require',
38629
-
38630
- './results',
38631
-
38632
- './selection/single',
38633
- './selection/multiple',
38634
- './selection/placeholder',
38635
- './selection/allowClear',
38636
- './selection/search',
38637
- './selection/eventRelay',
38638
-
38639
- './utils',
38640
- './translation',
38641
- './diacritics',
38642
-
38643
- './data/select',
38644
- './data/array',
38645
- './data/ajax',
38646
- './data/tags',
38647
- './data/tokenizer',
38648
- './data/minimumInputLength',
38649
- './data/maximumInputLength',
38650
- './data/maximumSelectionLength',
38651
-
38652
- './dropdown',
38653
- './dropdown/search',
38654
- './dropdown/hidePlaceholder',
38655
- './dropdown/infiniteScroll',
38656
- './dropdown/attachBody',
38657
- './dropdown/minimumResultsForSearch',
38658
- './dropdown/selectOnClose',
38659
- './dropdown/closeOnSelect',
38660
-
38661
- './i18n/en'
38662
- ], function ($, require,
38663
-
38664
- ResultsList,
38665
-
38666
- SingleSelection, MultipleSelection, Placeholder, AllowClear,
38667
- SelectionSearch, EventRelay,
38668
-
38669
- Utils, Translation, DIACRITICS,
38670
-
38671
- SelectData, ArrayData, AjaxData, Tags, Tokenizer,
38672
- MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
38673
-
38674
- Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
38675
- AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
38676
-
38677
- EnglishTranslation) {
38678
- function Defaults () {
38679
- this.reset();
38680
- }
38681
-
38682
- Defaults.prototype.apply = function (options) {
38683
- options = $.extend(true, {}, this.defaults, options);
38684
-
38685
- if (options.dataAdapter == null) {
38686
- if (options.ajax != null) {
38687
- options.dataAdapter = AjaxData;
38688
- } else if (options.data != null) {
38689
- options.dataAdapter = ArrayData;
38690
- } else {
38691
- options.dataAdapter = SelectData;
38692
- }
38693
-
38694
- if (options.minimumInputLength > 0) {
38695
- options.dataAdapter = Utils.Decorate(
38696
- options.dataAdapter,
38697
- MinimumInputLength
38698
- );
38699
- }
38700
-
38701
- if (options.maximumInputLength > 0) {
38702
- options.dataAdapter = Utils.Decorate(
38703
- options.dataAdapter,
38704
- MaximumInputLength
38705
- );
38706
- }
38707
-
38708
- if (options.maximumSelectionLength > 0) {
38709
- options.dataAdapter = Utils.Decorate(
38710
- options.dataAdapter,
38711
- MaximumSelectionLength
38712
- );
38713
- }
38714
-
38715
- if (options.tags) {
38716
- options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
38717
- }
38718
-
38719
- if (options.tokenSeparators != null || options.tokenizer != null) {
38720
- options.dataAdapter = Utils.Decorate(
38721
- options.dataAdapter,
38722
- Tokenizer
38723
- );
38724
- }
38725
-
38726
- if (options.query != null) {
38727
- var Query = require(options.amdBase + 'compat/query');
38728
-
38729
- options.dataAdapter = Utils.Decorate(
38730
- options.dataAdapter,
38731
- Query
38732
- );
38733
- }
38734
-
38735
- if (options.initSelection != null) {
38736
- var InitSelection = require(options.amdBase + 'compat/initSelection');
38737
-
38738
- options.dataAdapter = Utils.Decorate(
38739
- options.dataAdapter,
38740
- InitSelection
38741
- );
38742
- }
38743
- }
38744
-
38745
- if (options.resultsAdapter == null) {
38746
- options.resultsAdapter = ResultsList;
38747
-
38748
- if (options.ajax != null) {
38749
- options.resultsAdapter = Utils.Decorate(
38750
- options.resultsAdapter,
38751
- InfiniteScroll
38752
- );
38753
- }
38754
-
38755
- if (options.placeholder != null) {
38756
- options.resultsAdapter = Utils.Decorate(
38757
- options.resultsAdapter,
38758
- HidePlaceholder
38759
- );
38760
- }
38761
-
38762
- if (options.selectOnClose) {
38763
- options.resultsAdapter = Utils.Decorate(
38764
- options.resultsAdapter,
38765
- SelectOnClose
38766
- );
38767
- }
38768
- }
38769
-
38770
- if (options.dropdownAdapter == null) {
38771
- if (options.multiple) {
38772
- options.dropdownAdapter = Dropdown;
38773
- } else {
38774
- var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
38775
-
38776
- options.dropdownAdapter = SearchableDropdown;
38777
- }
38778
-
38779
- if (options.minimumResultsForSearch !== 0) {
38780
- options.dropdownAdapter = Utils.Decorate(
38781
- options.dropdownAdapter,
38782
- MinimumResultsForSearch
38783
- );
38784
- }
38785
-
38786
- if (options.closeOnSelect) {
38787
- options.dropdownAdapter = Utils.Decorate(
38788
- options.dropdownAdapter,
38789
- CloseOnSelect
38790
- );
38791
- }
38792
-
38793
- if (
38794
- options.dropdownCssClass != null ||
38795
- options.dropdownCss != null ||
38796
- options.adaptDropdownCssClass != null
38797
- ) {
38798
- var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
38799
-
38800
- options.dropdownAdapter = Utils.Decorate(
38801
- options.dropdownAdapter,
38802
- DropdownCSS
38803
- );
38804
- }
38805
-
38806
- options.dropdownAdapter = Utils.Decorate(
38807
- options.dropdownAdapter,
38808
- AttachBody
38809
- );
38810
- }
38811
-
38812
- if (options.selectionAdapter == null) {
38813
- if (options.multiple) {
38814
- options.selectionAdapter = MultipleSelection;
38815
- } else {
38816
- options.selectionAdapter = SingleSelection;
38817
- }
38818
-
38819
- // Add the placeholder mixin if a placeholder was specified
38820
- if (options.placeholder != null) {
38821
- options.selectionAdapter = Utils.Decorate(
38822
- options.selectionAdapter,
38823
- Placeholder
38824
- );
38825
- }
38826
-
38827
- if (options.allowClear) {
38828
- options.selectionAdapter = Utils.Decorate(
38829
- options.selectionAdapter,
38830
- AllowClear
38831
- );
38832
- }
38833
-
38834
- if (options.multiple) {
38835
- options.selectionAdapter = Utils.Decorate(
38836
- options.selectionAdapter,
38837
- SelectionSearch
38838
- );
38839
- }
38840
-
38841
- if (
38842
- options.containerCssClass != null ||
38843
- options.containerCss != null ||
38844
- options.adaptContainerCssClass != null
38845
- ) {
38846
- var ContainerCSS = require(options.amdBase + 'compat/containerCss');
38847
-
38848
- options.selectionAdapter = Utils.Decorate(
38849
- options.selectionAdapter,
38850
- ContainerCSS
38851
- );
38852
- }
38853
-
38854
- options.selectionAdapter = Utils.Decorate(
38855
- options.selectionAdapter,
38856
- EventRelay
38857
- );
38858
- }
38859
-
38860
- if (typeof options.language === 'string') {
38861
- // Check if the language is specified with a region
38862
- if (options.language.indexOf('-') > 0) {
38863
- // Extract the region information if it is included
38864
- var languageParts = options.language.split('-');
38865
- var baseLanguage = languageParts[0];
38866
-
38867
- options.language = [options.language, baseLanguage];
38868
- } else {
38869
- options.language = [options.language];
38870
- }
38871
- }
38872
-
38873
- if ($.isArray(options.language)) {
38874
- var languages = new Translation();
38875
- options.language.push('en');
38876
-
38877
- var languageNames = options.language;
38878
-
38879
- for (var l = 0; l < languageNames.length; l++) {
38880
- var name = languageNames[l];
38881
- var language = {};
38882
-
38883
- try {
38884
- // Try to load it with the original name
38885
- language = Translation.loadPath(name);
38886
- } catch (e) {
38887
- try {
38888
- // If we couldn't load it, check if it wasn't the full path
38889
- name = this.defaults.amdLanguageBase + name;
38890
- language = Translation.loadPath(name);
38891
- } catch (ex) {
38892
- // The translation could not be loaded at all. Sometimes this is
38893
- // because of a configuration problem, other times this can be
38894
- // because of how Select2 helps load all possible translation files.
38895
- if (options.debug && window.console && console.warn) {
38896
- console.warn(
38897
- 'Select2: The language file for "' + name + '" could not be ' +
38898
- 'automatically loaded. A fallback will be used instead.'
38899
- );
38900
- }
38901
-
38902
- continue;
38903
- }
38904
- }
38905
-
38906
- languages.extend(language);
38907
- }
38908
-
38909
- options.translations = languages;
38910
- } else {
38911
- var baseTranslation = Translation.loadPath(
38912
- this.defaults.amdLanguageBase + 'en'
38913
- );
38914
- var customTranslation = new Translation(options.language);
38915
-
38916
- customTranslation.extend(baseTranslation);
38917
-
38918
- options.translations = customTranslation;
38919
- }
38920
-
38921
- return options;
38922
- };
38923
-
38924
- Defaults.prototype.reset = function () {
38925
- function stripDiacritics (text) {
38926
- // Used 'uni range + named function' from http://jsperf.com/diacritics/18
38927
- function match(a) {
38928
- return DIACRITICS[a] || a;
38929
- }
38930
-
38931
- return text.replace(/[^\u0000-\u007E]/g, match);
38932
- }
38933
-
38934
- function matcher (params, data) {
38935
- // Always return the object if there is nothing to compare
38936
- if ($.trim(params.term) === '') {
38937
- return data;
38938
- }
38939
-
38940
- // Do a recursive check for options with children
38941
- if (data.children && data.children.length > 0) {
38942
- // Clone the data object if there are children
38943
- // This is required as we modify the object to remove any non-matches
38944
- var match = $.extend(true, {}, data);
38945
-
38946
- // Check each child of the option
38947
- for (var c = data.children.length - 1; c >= 0; c--) {
38948
- var child = data.children[c];
38949
-
38950
- var matches = matcher(params, child);
38951
-
38952
- // If there wasn't a match, remove the object in the array
38953
- if (matches == null) {
38954
- match.children.splice(c, 1);
38955
- }
38956
- }
38957
-
38958
- // If any children matched, return the new object
38959
- if (match.children.length > 0) {
38960
- return match;
38961
- }
38962
-
38963
- // If there were no matching children, check just the plain object
38964
- return matcher(params, match);
38965
- }
38966
-
38967
- var original = stripDiacritics(data.text).toUpperCase();
38968
- var term = stripDiacritics(params.term).toUpperCase();
38969
-
38970
- // Check if the text contains the term
38971
- if (original.indexOf(term) > -1) {
38972
- return data;
38973
- }
38974
-
38975
- // If it doesn't contain the term, don't return anything
38976
- return null;
38977
- }
38978
-
38979
- this.defaults = {
38980
- amdBase: './',
38981
- amdLanguageBase: './i18n/',
38982
- closeOnSelect: true,
38983
- debug: false,
38984
- dropdownAutoWidth: false,
38985
- escapeMarkup: Utils.escapeMarkup,
38986
- language: EnglishTranslation,
38987
- matcher: matcher,
38988
- minimumInputLength: 0,
38989
- maximumInputLength: 0,
38990
- maximumSelectionLength: 0,
38991
- minimumResultsForSearch: 0,
38992
- selectOnClose: false,
38993
- sorter: function (data) {
38994
- return data;
38995
- },
38996
- templateResult: function (result) {
38997
- return result.text;
38998
- },
38999
- templateSelection: function (selection) {
39000
- return selection.text;
39001
- },
39002
- theme: 'default',
39003
- width: 'resolve'
39004
- };
39005
- };
39006
-
39007
- Defaults.prototype.set = function (key, value) {
39008
- var camelKey = $.camelCase(key);
39009
-
39010
- var data = {};
39011
- data[camelKey] = value;
39012
-
39013
- var convertedData = Utils._convertData(data);
39014
-
39015
- $.extend(this.defaults, convertedData);
39016
- };
39017
-
39018
- var defaults = new Defaults();
39019
-
39020
- return defaults;
39021
- });
39022
-
39023
- S2.define('select2/options',[
39024
- 'require',
39025
- 'jquery',
39026
- './defaults',
39027
- './utils'
39028
- ], function (require, $, Defaults, Utils) {
39029
- function Options (options, $element) {
39030
- this.options = options;
39031
-
39032
- if ($element != null) {
39033
- this.fromElement($element);
39034
- }
39035
-
39036
- this.options = Defaults.apply(this.options);
39037
-
39038
- if ($element && $element.is('input')) {
39039
- var InputCompat = require(this.get('amdBase') + 'compat/inputData');
39040
-
39041
- this.options.dataAdapter = Utils.Decorate(
39042
- this.options.dataAdapter,
39043
- InputCompat
39044
- );
39045
- }
39046
- }
39047
-
39048
- Options.prototype.fromElement = function ($e) {
39049
- var excludedData = ['select2'];
39050
-
39051
- if (this.options.multiple == null) {
39052
- this.options.multiple = $e.prop('multiple');
39053
- }
39054
-
39055
- if (this.options.disabled == null) {
39056
- this.options.disabled = $e.prop('disabled');
39057
- }
39058
-
39059
- if (this.options.language == null) {
39060
- if ($e.prop('lang')) {
39061
- this.options.language = $e.prop('lang').toLowerCase();
39062
- } else if ($e.closest('[lang]').prop('lang')) {
39063
- this.options.language = $e.closest('[lang]').prop('lang');
39064
- }
39065
- }
39066
-
39067
- if (this.options.dir == null) {
39068
- if ($e.prop('dir')) {
39069
- this.options.dir = $e.prop('dir');
39070
- } else if ($e.closest('[dir]').prop('dir')) {
39071
- this.options.dir = $e.closest('[dir]').prop('dir');
39072
- } else {
39073
- this.options.dir = 'ltr';
39074
- }
39075
- }
39076
-
39077
- $e.prop('disabled', this.options.disabled);
39078
- $e.prop('multiple', this.options.multiple);
39079
-
39080
- if ($e.data('select2Tags')) {
39081
- if (this.options.debug && window.console && console.warn) {
39082
- console.warn(
39083
- 'Select2: The `data-select2-tags` attribute has been changed to ' +
39084
- 'use the `data-data` and `data-tags="true"` attributes and will be ' +
39085
- 'removed in future versions of Select2.'
39086
- );
39087
- }
39088
-
39089
- $e.data('data', $e.data('select2Tags'));
39090
- $e.data('tags', true);
39091
- }
39092
-
39093
- if ($e.data('ajaxUrl')) {
39094
- if (this.options.debug && window.console && console.warn) {
39095
- console.warn(
39096
- 'Select2: The `data-ajax-url` attribute has been changed to ' +
39097
- '`data-ajax--url` and support for the old attribute will be removed' +
39098
- ' in future versions of Select2.'
39099
- );
39100
- }
39101
-
39102
- $e.attr('ajax--url', $e.data('ajaxUrl'));
39103
- $e.data('ajax--url', $e.data('ajaxUrl'));
39104
- }
39105
-
39106
- var dataset = {};
39107
-
39108
- // Prefer the element's `dataset` attribute if it exists
39109
- // jQuery 1.x does not correctly handle data attributes with multiple dashes
39110
- if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
39111
- dataset = $.extend(true, {}, $e[0].dataset, $e.data());
39112
- } else {
39113
- dataset = $e.data();
39114
- }
39115
-
39116
- var data = $.extend(true, {}, dataset);
39117
-
39118
- data = Utils._convertData(data);
39119
-
39120
- for (var key in data) {
39121
- if ($.inArray(key, excludedData) > -1) {
39122
- continue;
39123
- }
39124
-
39125
- if ($.isPlainObject(this.options[key])) {
39126
- $.extend(this.options[key], data[key]);
39127
- } else {
39128
- this.options[key] = data[key];
39129
- }
39130
- }
39131
-
39132
- return this;
39133
- };
39134
-
39135
- Options.prototype.get = function (key) {
39136
- return this.options[key];
39137
- };
39138
-
39139
- Options.prototype.set = function (key, val) {
39140
- this.options[key] = val;
39141
- };
39142
-
39143
- return Options;
39144
- });
39145
-
39146
- S2.define('select2/core',[
39147
- 'jquery',
39148
- './options',
39149
- './utils',
39150
- './keys'
39151
- ], function ($, Options, Utils, KEYS) {
39152
- var Select2 = function ($element, options) {
39153
- if ($element.data('select2') != null) {
39154
- $element.data('select2').destroy();
39155
- }
39156
-
39157
- this.$element = $element;
39158
-
39159
- this.id = this._generateId($element);
39160
-
39161
- options = options || {};
39162
-
39163
- this.options = new Options(options, $element);
39164
-
39165
- Select2.__super__.constructor.call(this);
39166
-
39167
- // Set up the tabindex
39168
-
39169
- var tabindex = $element.attr('tabindex') || 0;
39170
- $element.data('old-tabindex', tabindex);
39171
- $element.attr('tabindex', '-1');
39172
-
39173
- // Set up containers and adapters
39174
-
39175
- var DataAdapter = this.options.get('dataAdapter');
39176
- this.dataAdapter = new DataAdapter($element, this.options);
39177
-
39178
- var $container = this.render();
39179
-
39180
- this._placeContainer($container);
39181
-
39182
- var SelectionAdapter = this.options.get('selectionAdapter');
39183
- this.selection = new SelectionAdapter($element, this.options);
39184
- this.$selection = this.selection.render();
39185
-
39186
- this.selection.position(this.$selection, $container);
39187
-
39188
- var DropdownAdapter = this.options.get('dropdownAdapter');
39189
- this.dropdown = new DropdownAdapter($element, this.options);
39190
- this.$dropdown = this.dropdown.render();
39191
-
39192
- this.dropdown.position(this.$dropdown, $container);
39193
-
39194
- var ResultsAdapter = this.options.get('resultsAdapter');
39195
- this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
39196
- this.$results = this.results.render();
39197
-
39198
- this.results.position(this.$results, this.$dropdown);
39199
-
39200
- // Bind events
39201
-
39202
- var self = this;
39203
-
39204
- // Bind the container to all of the adapters
39205
- this._bindAdapters();
39206
-
39207
- // Register any DOM event handlers
39208
- this._registerDomEvents();
39209
-
39210
- // Register any internal event handlers
39211
- this._registerDataEvents();
39212
- this._registerSelectionEvents();
39213
- this._registerDropdownEvents();
39214
- this._registerResultsEvents();
39215
- this._registerEvents();
39216
-
39217
- // Set the initial state
39218
- this.dataAdapter.current(function (initialData) {
39219
- self.trigger('selection:update', {
39220
- data: initialData
39221
- });
39222
- });
39223
-
39224
- // Hide the original select
39225
- $element.addClass('select2-hidden-accessible');
39226
- $element.attr('aria-hidden', 'true');
39227
-
39228
- // Synchronize any monitored attributes
39229
- this._syncAttributes();
39230
-
39231
- $element.data('select2', this);
39232
- };
39233
-
39234
- Utils.Extend(Select2, Utils.Observable);
39235
-
39236
- Select2.prototype._generateId = function ($element) {
39237
- var id = '';
39238
-
39239
- if ($element.attr('id') != null) {
39240
- id = $element.attr('id');
39241
- } else if ($element.attr('name') != null) {
39242
- id = $element.attr('name') + '-' + Utils.generateChars(2);
39243
- } else {
39244
- id = Utils.generateChars(4);
39245
- }
39246
-
39247
- id = id.replace(/(:|\.|\[|\]|,)/g, '');
39248
- id = 'select2-' + id;
39249
-
39250
- return id;
39251
- };
39252
-
39253
- Select2.prototype._placeContainer = function ($container) {
39254
- $container.insertAfter(this.$element);
39255
-
39256
- var width = this._resolveWidth(this.$element, this.options.get('width'));
39257
-
39258
- if (width != null) {
39259
- $container.css('width', width);
39260
- }
39261
- };
39262
-
39263
- Select2.prototype._resolveWidth = function ($element, method) {
39264
- var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
39265
-
39266
- if (method == 'resolve') {
39267
- var styleWidth = this._resolveWidth($element, 'style');
39268
-
39269
- if (styleWidth != null) {
39270
- return styleWidth;
39271
- }
39272
-
39273
- return this._resolveWidth($element, 'element');
39274
- }
39275
-
39276
- if (method == 'element') {
39277
- var elementWidth = $element.outerWidth(false);
39278
-
39279
- if (elementWidth <= 0) {
39280
- return 'auto';
39281
- }
39282
-
39283
- return elementWidth + 'px';
39284
- }
39285
-
39286
- if (method == 'style') {
39287
- var style = $element.attr('style');
39288
-
39289
- if (typeof(style) !== 'string') {
39290
- return null;
39291
- }
39292
-
39293
- var attrs = style.split(';');
39294
-
39295
- for (var i = 0, l = attrs.length; i < l; i = i + 1) {
39296
- var attr = attrs[i].replace(/\s/g, '');
39297
- var matches = attr.match(WIDTH);
39298
-
39299
- if (matches !== null && matches.length >= 1) {
39300
- return matches[1];
39301
- }
39302
- }
39303
-
39304
- return null;
39305
- }
39306
-
39307
- return method;
39308
- };
39309
-
39310
- Select2.prototype._bindAdapters = function () {
39311
- this.dataAdapter.bind(this, this.$container);
39312
- this.selection.bind(this, this.$container);
39313
-
39314
- this.dropdown.bind(this, this.$container);
39315
- this.results.bind(this, this.$container);
39316
- };
39317
-
39318
- Select2.prototype._registerDomEvents = function () {
39319
- var self = this;
39320
-
39321
- this.$element.on('change.select2', function () {
39322
- self.dataAdapter.current(function (data) {
39323
- self.trigger('selection:update', {
39324
- data: data
39325
- });
39326
- });
39327
- });
39328
-
39329
- this.$element.on('focus.select2', function (evt) {
39330
- self.trigger('focus', evt);
39331
- });
39332
-
39333
- this._syncA = Utils.bind(this._syncAttributes, this);
39334
- this._syncS = Utils.bind(this._syncSubtree, this);
39335
-
39336
- if (this.$element[0].attachEvent) {
39337
- this.$element[0].attachEvent('onpropertychange', this._syncA);
39338
- }
39339
-
39340
- var observer = window.MutationObserver ||
39341
- window.WebKitMutationObserver ||
39342
- window.MozMutationObserver
39343
- ;
39344
-
39345
- if (observer != null) {
39346
- this._observer = new observer(function (mutations) {
39347
- $.each(mutations, self._syncA);
39348
- $.each(mutations, self._syncS);
39349
- });
39350
- this._observer.observe(this.$element[0], {
39351
- attributes: true,
39352
- childList: true,
39353
- subtree: false
39354
- });
39355
- } else if (this.$element[0].addEventListener) {
39356
- this.$element[0].addEventListener(
39357
- 'DOMAttrModified',
39358
- self._syncA,
39359
- false
39360
- );
39361
- this.$element[0].addEventListener(
39362
- 'DOMNodeInserted',
39363
- self._syncS,
39364
- false
39365
- );
39366
- this.$element[0].addEventListener(
39367
- 'DOMNodeRemoved',
39368
- self._syncS,
39369
- false
39370
- );
39371
- }
39372
- };
39373
-
39374
- Select2.prototype._registerDataEvents = function () {
39375
- var self = this;
39376
-
39377
- this.dataAdapter.on('*', function (name, params) {
39378
- self.trigger(name, params);
39379
- });
39380
- };
39381
-
39382
- Select2.prototype._registerSelectionEvents = function () {
39383
- var self = this;
39384
- var nonRelayEvents = ['toggle', 'focus'];
39385
-
39386
- this.selection.on('toggle', function () {
39387
- self.toggleDropdown();
39388
- });
39389
-
39390
- this.selection.on('focus', function (params) {
39391
- self.focus(params);
39392
- });
39393
-
39394
- this.selection.on('*', function (name, params) {
39395
- if ($.inArray(name, nonRelayEvents) !== -1) {
39396
- return;
39397
- }
39398
-
39399
- self.trigger(name, params);
39400
- });
39401
- };
39402
-
39403
- Select2.prototype._registerDropdownEvents = function () {
39404
- var self = this;
39405
-
39406
- this.dropdown.on('*', function (name, params) {
39407
- self.trigger(name, params);
39408
- });
39409
- };
39410
-
39411
- Select2.prototype._registerResultsEvents = function () {
39412
- var self = this;
39413
-
39414
- this.results.on('*', function (name, params) {
39415
- self.trigger(name, params);
39416
- });
39417
- };
39418
-
39419
- Select2.prototype._registerEvents = function () {
39420
- var self = this;
39421
-
39422
- this.on('open', function () {
39423
- self.$container.addClass('select2-container--open');
39424
- });
39425
-
39426
- this.on('close', function () {
39427
- self.$container.removeClass('select2-container--open');
39428
- });
39429
-
39430
- this.on('enable', function () {
39431
- self.$container.removeClass('select2-container--disabled');
39432
- });
39433
-
39434
- this.on('disable', function () {
39435
- self.$container.addClass('select2-container--disabled');
39436
- });
39437
-
39438
- this.on('blur', function () {
39439
- self.$container.removeClass('select2-container--focus');
39440
- });
39441
-
39442
- this.on('query', function (params) {
39443
- if (!self.isOpen()) {
39444
- self.trigger('open', {});
39445
- }
39446
-
39447
- this.dataAdapter.query(params, function (data) {
39448
- self.trigger('results:all', {
39449
- data: data,
39450
- query: params
39451
- });
39452
- });
39453
- });
39454
-
39455
- this.on('query:append', function (params) {
39456
- this.dataAdapter.query(params, function (data) {
39457
- self.trigger('results:append', {
39458
- data: data,
39459
- query: params
39460
- });
39461
- });
39462
- });
39463
-
39464
- this.on('keypress', function (evt) {
39465
- var key = evt.which;
39466
-
39467
- if (self.isOpen()) {
39468
- if (key === KEYS.ESC || key === KEYS.TAB ||
39469
- (key === KEYS.UP && evt.altKey)) {
39470
- self.close();
39471
-
39472
- evt.preventDefault();
39473
- } else if (key === KEYS.ENTER) {
39474
- self.trigger('results:select', {});
39475
-
39476
- evt.preventDefault();
39477
- } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
39478
- self.trigger('results:toggle', {});
39479
-
39480
- evt.preventDefault();
39481
- } else if (key === KEYS.UP) {
39482
- self.trigger('results:previous', {});
39483
-
39484
- evt.preventDefault();
39485
- } else if (key === KEYS.DOWN) {
39486
- self.trigger('results:next', {});
39487
-
39488
- evt.preventDefault();
39489
- }
39490
- } else {
39491
- if (key === KEYS.ENTER || key === KEYS.SPACE ||
39492
- (key === KEYS.DOWN && evt.altKey)) {
39493
- self.open();
39494
-
39495
- evt.preventDefault();
39496
- }
39497
- }
39498
- });
39499
- };
39500
-
39501
- Select2.prototype._syncAttributes = function () {
39502
- this.options.set('disabled', this.$element.prop('disabled'));
39503
-
39504
- if (this.options.get('disabled')) {
39505
- if (this.isOpen()) {
39506
- this.close();
39507
- }
39508
-
39509
- this.trigger('disable', {});
39510
- } else {
39511
- this.trigger('enable', {});
39512
- }
39513
- };
39514
-
39515
- Select2.prototype._syncSubtree = function (evt, mutations) {
39516
- var changed = false;
39517
- var self = this;
39518
-
39519
- // Ignore any mutation events raised for elements that aren't options or
39520
- // optgroups. This handles the case when the select element is destroyed
39521
- if (
39522
- evt && evt.target && (
39523
- evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
39524
- )
39525
- ) {
39526
- return;
39527
- }
39528
-
39529
- if (!mutations) {
39530
- // If mutation events aren't supported, then we can only assume that the
39531
- // change affected the selections
39532
- changed = true;
39533
- } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
39534
- for (var n = 0; n < mutations.addedNodes.length; n++) {
39535
- var node = mutations.addedNodes[n];
39536
-
39537
- if (node.selected) {
39538
- changed = true;
39539
- }
39540
- }
39541
- } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
39542
- changed = true;
39543
- }
39544
-
39545
- // Only re-pull the data if we think there is a change
39546
- if (changed) {
39547
- this.dataAdapter.current(function (currentData) {
39548
- self.trigger('selection:update', {
39549
- data: currentData
39550
- });
39551
- });
39552
- }
39553
- };
39554
-
39555
- /**
39556
- * Override the trigger method to automatically trigger pre-events when
39557
- * there are events that can be prevented.
39558
- */
39559
- Select2.prototype.trigger = function (name, args) {
39560
- var actualTrigger = Select2.__super__.trigger;
39561
- var preTriggerMap = {
39562
- 'open': 'opening',
39563
- 'close': 'closing',
39564
- 'select': 'selecting',
39565
- 'unselect': 'unselecting'
39566
- };
39567
-
39568
- if (args === undefined) {
39569
- args = {};
39570
- }
39571
-
39572
- if (name in preTriggerMap) {
39573
- var preTriggerName = preTriggerMap[name];
39574
- var preTriggerArgs = {
39575
- prevented: false,
39576
- name: name,
39577
- args: args
39578
- };
39579
-
39580
- actualTrigger.call(this, preTriggerName, preTriggerArgs);
39581
-
39582
- if (preTriggerArgs.prevented) {
39583
- args.prevented = true;
39584
-
39585
- return;
39586
- }
39587
- }
39588
-
39589
- actualTrigger.call(this, name, args);
39590
- };
39591
-
39592
- Select2.prototype.toggleDropdown = function () {
39593
- if (this.options.get('disabled')) {
39594
- return;
39595
- }
39596
-
39597
- if (this.isOpen()) {
39598
- this.close();
39599
- } else {
39600
- this.open();
39601
- }
39602
- };
39603
-
39604
- Select2.prototype.open = function () {
39605
- if (this.isOpen()) {
39606
- return;
39607
- }
39608
-
39609
- this.trigger('query', {});
39610
- };
39611
-
39612
- Select2.prototype.close = function () {
39613
- if (!this.isOpen()) {
39614
- return;
39615
- }
39616
-
39617
- this.trigger('close', {});
39618
- };
39619
-
39620
- Select2.prototype.isOpen = function () {
39621
- return this.$container.hasClass('select2-container--open');
39622
- };
39623
-
39624
- Select2.prototype.hasFocus = function () {
39625
- return this.$container.hasClass('select2-container--focus');
39626
- };
39627
-
39628
- Select2.prototype.focus = function (data) {
39629
- // No need to re-trigger focus events if we are already focused
39630
- if (this.hasFocus()) {
39631
- return;
39632
- }
39633
-
39634
- this.$container.addClass('select2-container--focus');
39635
- this.trigger('focus', {});
39636
- };
39637
-
39638
- Select2.prototype.enable = function (args) {
39639
- if (this.options.get('debug') && window.console && console.warn) {
39640
- console.warn(
39641
- 'Select2: The `select2("enable")` method has been deprecated and will' +
39642
- ' be removed in later Select2 versions. Use $element.prop("disabled")' +
39643
- ' instead.'
39644
- );
39645
- }
39646
-
39647
- if (args == null || args.length === 0) {
39648
- args = [true];
39649
- }
39650
-
39651
- var disabled = !args[0];
39652
-
39653
- this.$element.prop('disabled', disabled);
39654
- };
39655
-
39656
- Select2.prototype.data = function () {
39657
- if (this.options.get('debug') &&
39658
- arguments.length > 0 && window.console && console.warn) {
39659
- console.warn(
39660
- 'Select2: Data can no longer be set using `select2("data")`. You ' +
39661
- 'should consider setting the value instead using `$element.val()`.'
39662
- );
39663
- }
39664
-
39665
- var data = [];
39666
-
39667
- this.dataAdapter.current(function (currentData) {
39668
- data = currentData;
39669
- });
39670
-
39671
- return data;
39672
- };
39673
-
39674
- Select2.prototype.val = function (args) {
39675
- if (this.options.get('debug') && window.console && console.warn) {
39676
- console.warn(
39677
- 'Select2: The `select2("val")` method has been deprecated and will be' +
39678
- ' removed in later Select2 versions. Use $element.val() instead.'
39679
- );
39680
- }
39681
-
39682
- if (args == null || args.length === 0) {
39683
- return this.$element.val();
39684
- }
39685
-
39686
- var newVal = args[0];
39687
-
39688
- if ($.isArray(newVal)) {
39689
- newVal = $.map(newVal, function (obj) {
39690
- return obj.toString();
39691
- });
39692
- }
39693
-
39694
- this.$element.val(newVal).trigger('change');
39695
- };
39696
-
39697
- Select2.prototype.destroy = function () {
39698
- this.$container.remove();
39699
-
39700
- if (this.$element[0].detachEvent) {
39701
- this.$element[0].detachEvent('onpropertychange', this._syncA);
39702
- }
39703
-
39704
- if (this._observer != null) {
39705
- this._observer.disconnect();
39706
- this._observer = null;
39707
- } else if (this.$element[0].removeEventListener) {
39708
- this.$element[0]
39709
- .removeEventListener('DOMAttrModified', this._syncA, false);
39710
- this.$element[0]
39711
- .removeEventListener('DOMNodeInserted', this._syncS, false);
39712
- this.$element[0]
39713
- .removeEventListener('DOMNodeRemoved', this._syncS, false);
39714
- }
39715
-
39716
- this._syncA = null;
39717
- this._syncS = null;
39718
-
39719
- this.$element.off('.select2');
39720
- this.$element.attr('tabindex', this.$element.data('old-tabindex'));
39721
-
39722
- this.$element.removeClass('select2-hidden-accessible');
39723
- this.$element.attr('aria-hidden', 'false');
39724
- this.$element.removeData('select2');
39725
-
39726
- this.dataAdapter.destroy();
39727
- this.selection.destroy();
39728
- this.dropdown.destroy();
39729
- this.results.destroy();
39730
-
39731
- this.dataAdapter = null;
39732
- this.selection = null;
39733
- this.dropdown = null;
39734
- this.results = null;
39735
- };
39736
-
39737
- Select2.prototype.render = function () {
39738
- var $container = $(
39739
- '<span class="select2 select2-container">' +
39740
- '<span class="selection"></span>' +
39741
- '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
39742
- '</span>'
39743
- );
39744
-
39745
- $container.attr('dir', this.options.get('dir'));
39746
-
39747
- this.$container = $container;
39748
-
39749
- this.$container.addClass('select2-container--' + this.options.get('theme'));
39750
-
39751
- $container.data('element', this.$element);
39752
-
39753
- return $container;
39754
- };
39755
-
39756
- return Select2;
39757
- });
39758
-
39759
- S2.define('jquery-mousewheel',[
39760
- 'jquery'
39761
- ], function ($) {
39762
- // Used to shim jQuery.mousewheel for non-full builds.
39763
- return $;
39764
- });
39765
-
39766
- S2.define('jquery.select2',[
39767
- 'jquery',
39768
- 'jquery-mousewheel',
39769
-
39770
- './select2/core',
39771
- './select2/defaults'
39772
- ], function ($, _, Select2, Defaults) {
39773
- if ($.fn.select2 == null) {
39774
- // All methods that should return the element
39775
- var thisMethods = ['open', 'close', 'destroy'];
39776
-
39777
- $.fn.select2 = function (options) {
39778
- options = options || {};
39779
-
39780
- if (typeof options === 'object') {
39781
- this.each(function () {
39782
- var instanceOptions = $.extend(true, {}, options);
39783
-
39784
- var instance = new Select2($(this), instanceOptions);
39785
- });
39786
-
39787
- return this;
39788
- } else if (typeof options === 'string') {
39789
- var ret;
39790
- var args = Array.prototype.slice.call(arguments, 1);
39791
-
39792
- this.each(function () {
39793
- var instance = $(this).data('select2');
39794
-
39795
- if (instance == null && window.console && console.error) {
39796
- console.error(
39797
- 'The select2(\'' + options + '\') method was called on an ' +
39798
- 'element that is not using Select2.'
39799
- );
39800
- }
39801
-
39802
- ret = instance[options].apply(instance, args);
39803
- });
39804
-
39805
- // Check if we should be returning `this`
39806
- if ($.inArray(options, thisMethods) > -1) {
39807
- return this;
39808
- }
39809
-
39810
- return ret;
39811
- } else {
39812
- throw new Error('Invalid arguments for Select2: ' + options);
39813
- }
39814
- };
39815
- }
39816
-
39817
- if ($.fn.select2.defaults == null) {
39818
- $.fn.select2.defaults = Defaults;
39819
- }
39820
-
39821
- return Select2;
39822
- });
39823
-
39824
- // Return the AMD loader configuration so it can be used outside of this file
39825
- return {
39826
- define: S2.define,
39827
- require: S2.require
39828
- };
39829
- }());
39830
-
39831
- // Autoload the jQuery bindings
39832
- // We know that all of the modules exist above this, so we're safe
39833
- var select2 = S2.require('jquery.select2');
39834
-
39835
- // Hold the AMD module references on the jQuery function that was just loaded
39836
- // This allows Select2 to use the internal loader outside of this file, such
39837
- // as in the language files.
39838
- jQuery.fn.select2.amd = S2;
39839
-
39840
- // Return the Select2 instance for anyone who is importing it.
39841
- return select2;
39842
- }));
39843
 
39844
 
39845
  /***/ },
@@ -39892,7 +39892,7 @@ webpackJsonp([1],[
39892
  this.loadItem(this.props.params.id);
39893
  } else {
39894
  this.setState({
39895
- item: jQuery('.mailpoet_form').serializeObject()
39896
  });
39897
  }
39898
  }
33702
 
33703
  handleSearch: function handleSearch(e) {
33704
  e.preventDefault();
33705
+ this.props.onSearch(this.refs.search.value.trim());
33706
  },
33707
  componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
33708
  this.refs.search.value = nextProps.search;
34094
  /* 289 */
34095
  /***/ function(module, exports, __webpack_require__) {
34096
 
34097
+ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;var require;/*!
34098
+ * Select2 4.0.5
34099
+ * https://select2.github.io
34100
+ *
34101
+ * Released under the MIT license
34102
+ * https://github.com/select2/select2/blob/master/LICENSE.md
34103
+ */
34104
+ (function (factory) {
34105
+ if (true) {
34106
+ // AMD. Register as an anonymous module.
34107
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(275)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
34108
+ } else if (typeof module === 'object' && module.exports) {
34109
+ // Node/CommonJS
34110
+ module.exports = function (root, jQuery) {
34111
+ if (jQuery === undefined) {
34112
+ // require('jQuery') returns a factory that requires window to
34113
+ // build a jQuery instance, we normalize how we use modules
34114
+ // that require this pattern but the window provided is a noop
34115
+ // if it's defined (how jquery works)
34116
+ if (typeof window !== 'undefined') {
34117
+ jQuery = require('jquery');
34118
+ }
34119
+ else {
34120
+ jQuery = require('jquery')(root);
34121
+ }
34122
+ }
34123
+ factory(jQuery);
34124
+ return jQuery;
34125
+ };
34126
+ } else {
34127
+ // Browser globals
34128
+ factory(jQuery);
34129
+ }
34130
+ } (function (jQuery) {
34131
+ // This is needed so we can catch the AMD loader configuration and use it
34132
+ // The inner file should be wrapped (by `banner.start.js`) in a function that
34133
+ // returns the AMD loader references.
34134
+ var S2 =(function () {
34135
+ // Restore the Select2 AMD loader so it can be used
34136
+ // Needed mostly in the language files, where the loader is not inserted
34137
+ if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
34138
+ var S2 = jQuery.fn.select2.amd;
34139
+ }
34140
+ var S2;(function () { if (!S2 || !S2.requirejs) {
34141
+ if (!S2) { S2 = {}; } else { require = S2; }
34142
+ /**
34143
+ * @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
34144
+ * Released under MIT license, http://github.com/requirejs/almond/LICENSE
34145
+ */
34146
+ //Going sloppy to avoid 'use strict' string cost, but strict practices should
34147
+ //be followed.
34148
+ /*global setTimeout: false */
34149
+
34150
+ var requirejs, require, define;
34151
+ (function (undef) {
34152
+ var main, req, makeMap, handlers,
34153
+ defined = {},
34154
+ waiting = {},
34155
+ config = {},
34156
+ defining = {},
34157
+ hasOwn = Object.prototype.hasOwnProperty,
34158
+ aps = [].slice,
34159
+ jsSuffixRegExp = /\.js$/;
34160
+
34161
+ function hasProp(obj, prop) {
34162
+ return hasOwn.call(obj, prop);
34163
+ }
34164
+
34165
+ /**
34166
+ * Given a relative module name, like ./something, normalize it to
34167
+ * a real name that can be mapped to a path.
34168
+ * @param {String} name the relative name
34169
+ * @param {String} baseName a real name that the name arg is relative
34170
+ * to.
34171
+ * @returns {String} normalized name
34172
+ */
34173
+ function normalize(name, baseName) {
34174
+ var nameParts, nameSegment, mapValue, foundMap, lastIndex,
34175
+ foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
34176
+ baseParts = baseName && baseName.split("/"),
34177
+ map = config.map,
34178
+ starMap = (map && map['*']) || {};
34179
+
34180
+ //Adjust any relative paths.
34181
+ if (name) {
34182
+ name = name.split('/');
34183
+ lastIndex = name.length - 1;
34184
+
34185
+ // If wanting node ID compatibility, strip .js from end
34186
+ // of IDs. Have to do this here, and not in nameToUrl
34187
+ // because node allows either .js or non .js to map
34188
+ // to same file.
34189
+ if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
34190
+ name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
34191
+ }
34192
+
34193
+ // Starts with a '.' so need the baseName
34194
+ if (name[0].charAt(0) === '.' && baseParts) {
34195
+ //Convert baseName to array, and lop off the last part,
34196
+ //so that . matches that 'directory' and not name of the baseName's
34197
+ //module. For instance, baseName of 'one/two/three', maps to
34198
+ //'one/two/three.js', but we want the directory, 'one/two' for
34199
+ //this normalization.
34200
+ normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
34201
+ name = normalizedBaseParts.concat(name);
34202
+ }
34203
+
34204
+ //start trimDots
34205
+ for (i = 0; i < name.length; i++) {
34206
+ part = name[i];
34207
+ if (part === '.') {
34208
+ name.splice(i, 1);
34209
+ i -= 1;
34210
+ } else if (part === '..') {
34211
+ // If at the start, or previous value is still ..,
34212
+ // keep them so that when converted to a path it may
34213
+ // still work when converted to a path, even though
34214
+ // as an ID it is less than ideal. In larger point
34215
+ // releases, may be better to just kick out an error.
34216
+ if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
34217
+ continue;
34218
+ } else if (i > 0) {
34219
+ name.splice(i - 1, 2);
34220
+ i -= 2;
34221
+ }
34222
+ }
34223
+ }
34224
+ //end trimDots
34225
+
34226
+ name = name.join('/');
34227
+ }
34228
+
34229
+ //Apply map config if available.
34230
+ if ((baseParts || starMap) && map) {
34231
+ nameParts = name.split('/');
34232
+
34233
+ for (i = nameParts.length; i > 0; i -= 1) {
34234
+ nameSegment = nameParts.slice(0, i).join("/");
34235
+
34236
+ if (baseParts) {
34237
+ //Find the longest baseName segment match in the config.
34238
+ //So, do joins on the biggest to smallest lengths of baseParts.
34239
+ for (j = baseParts.length; j > 0; j -= 1) {
34240
+ mapValue = map[baseParts.slice(0, j).join('/')];
34241
+
34242
+ //baseName segment has config, find if it has one for
34243
+ //this name.
34244
+ if (mapValue) {
34245
+ mapValue = mapValue[nameSegment];
34246
+ if (mapValue) {
34247
+ //Match, update name to the new value.
34248
+ foundMap = mapValue;
34249
+ foundI = i;
34250
+ break;
34251
+ }
34252
+ }
34253
+ }
34254
+ }
34255
+
34256
+ if (foundMap) {
34257
+ break;
34258
+ }
34259
+
34260
+ //Check for a star map match, but just hold on to it,
34261
+ //if there is a shorter segment match later in a matching
34262
+ //config, then favor over this star map.
34263
+ if (!foundStarMap && starMap && starMap[nameSegment]) {
34264
+ foundStarMap = starMap[nameSegment];
34265
+ starI = i;
34266
+ }
34267
+ }
34268
+
34269
+ if (!foundMap && foundStarMap) {
34270
+ foundMap = foundStarMap;
34271
+ foundI = starI;
34272
+ }
34273
+
34274
+ if (foundMap) {
34275
+ nameParts.splice(0, foundI, foundMap);
34276
+ name = nameParts.join('/');
34277
+ }
34278
+ }
34279
+
34280
+ return name;
34281
+ }
34282
+
34283
+ function makeRequire(relName, forceSync) {
34284
+ return function () {
34285
+ //A version of a require function that passes a moduleName
34286
+ //value for items that may need to
34287
+ //look up paths relative to the moduleName
34288
+ var args = aps.call(arguments, 0);
34289
+
34290
+ //If first arg is not require('string'), and there is only
34291
+ //one arg, it is the array form without a callback. Insert
34292
+ //a null so that the following concat is correct.
34293
+ if (typeof args[0] !== 'string' && args.length === 1) {
34294
+ args.push(null);
34295
+ }
34296
+ return req.apply(undef, args.concat([relName, forceSync]));
34297
+ };
34298
+ }
34299
+
34300
+ function makeNormalize(relName) {
34301
+ return function (name) {
34302
+ return normalize(name, relName);
34303
+ };
34304
+ }
34305
+
34306
+ function makeLoad(depName) {
34307
+ return function (value) {
34308
+ defined[depName] = value;
34309
+ };
34310
+ }
34311
+
34312
+ function callDep(name) {
34313
+ if (hasProp(waiting, name)) {
34314
+ var args = waiting[name];
34315
+ delete waiting[name];
34316
+ defining[name] = true;
34317
+ main.apply(undef, args);
34318
+ }
34319
+
34320
+ if (!hasProp(defined, name) && !hasProp(defining, name)) {
34321
+ throw new Error('No ' + name);
34322
+ }
34323
+ return defined[name];
34324
+ }
34325
+
34326
+ //Turns a plugin!resource to [plugin, resource]
34327
+ //with the plugin being undefined if the name
34328
+ //did not have a plugin prefix.
34329
+ function splitPrefix(name) {
34330
+ var prefix,
34331
+ index = name ? name.indexOf('!') : -1;
34332
+ if (index > -1) {
34333
+ prefix = name.substring(0, index);
34334
+ name = name.substring(index + 1, name.length);
34335
+ }
34336
+ return [prefix, name];
34337
+ }
34338
+
34339
+ //Creates a parts array for a relName where first part is plugin ID,
34340
+ //second part is resource ID. Assumes relName has already been normalized.
34341
+ function makeRelParts(relName) {
34342
+ return relName ? splitPrefix(relName) : [];
34343
+ }
34344
+
34345
+ /**
34346
+ * Makes a name map, normalizing the name, and using a plugin
34347
+ * for normalization if necessary. Grabs a ref to plugin
34348
+ * too, as an optimization.
34349
+ */
34350
+ makeMap = function (name, relParts) {
34351
+ var plugin,
34352
+ parts = splitPrefix(name),
34353
+ prefix = parts[0],
34354
+ relResourceName = relParts[1];
34355
+
34356
+ name = parts[1];
34357
+
34358
+ if (prefix) {
34359
+ prefix = normalize(prefix, relResourceName);
34360
+ plugin = callDep(prefix);
34361
+ }
34362
+
34363
+ //Normalize according
34364
+ if (prefix) {
34365
+ if (plugin && plugin.normalize) {
34366
+ name = plugin.normalize(name, makeNormalize(relResourceName));
34367
+ } else {
34368
+ name = normalize(name, relResourceName);
34369
+ }
34370
+ } else {
34371
+ name = normalize(name, relResourceName);
34372
+ parts = splitPrefix(name);
34373
+ prefix = parts[0];
34374
+ name = parts[1];
34375
+ if (prefix) {
34376
+ plugin = callDep(prefix);
34377
+ }
34378
+ }
34379
+
34380
+ //Using ridiculous property names for space reasons
34381
+ return {
34382
+ f: prefix ? prefix + '!' + name : name, //fullName
34383
+ n: name,
34384
+ pr: prefix,
34385
+ p: plugin
34386
+ };
34387
+ };
34388
+
34389
+ function makeConfig(name) {
34390
+ return function () {
34391
+ return (config && config.config && config.config[name]) || {};
34392
+ };
34393
+ }
34394
+
34395
+ handlers = {
34396
+ require: function (name) {
34397
+ return makeRequire(name);
34398
+ },
34399
+ exports: function (name) {
34400
+ var e = defined[name];
34401
+ if (typeof e !== 'undefined') {
34402
+ return e;
34403
+ } else {
34404
+ return (defined[name] = {});
34405
+ }
34406
+ },
34407
+ module: function (name) {
34408
+ return {
34409
+ id: name,
34410
+ uri: '',
34411
+ exports: defined[name],
34412
+ config: makeConfig(name)
34413
+ };
34414
+ }
34415
+ };
34416
+
34417
+ main = function (name, deps, callback, relName) {
34418
+ var cjsModule, depName, ret, map, i, relParts,
34419
+ args = [],
34420
+ callbackType = typeof callback,
34421
+ usingExports;
34422
+
34423
+ //Use name if no relName
34424
+ relName = relName || name;
34425
+ relParts = makeRelParts(relName);
34426
+
34427
+ //Call the callback to define the module, if necessary.
34428
+ if (callbackType === 'undefined' || callbackType === 'function') {
34429
+ //Pull out the defined dependencies and pass the ordered
34430
+ //values to the callback.
34431
+ //Default to [require, exports, module] if no deps
34432
+ deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
34433
+ for (i = 0; i < deps.length; i += 1) {
34434
+ map = makeMap(deps[i], relParts);
34435
+ depName = map.f;
34436
+
34437
+ //Fast path CommonJS standard dependencies.
34438
+ if (depName === "require") {
34439
+ args[i] = handlers.require(name);
34440
+ } else if (depName === "exports") {
34441
+ //CommonJS module spec 1.1
34442
+ args[i] = handlers.exports(name);
34443
+ usingExports = true;
34444
+ } else if (depName === "module") {
34445
+ //CommonJS module spec 1.1
34446
+ cjsModule = args[i] = handlers.module(name);
34447
+ } else if (hasProp(defined, depName) ||
34448
+ hasProp(waiting, depName) ||
34449
+ hasProp(defining, depName)) {
34450
+ args[i] = callDep(depName);
34451
+ } else if (map.p) {
34452
+ map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
34453
+ args[i] = defined[depName];
34454
+ } else {
34455
+ throw new Error(name + ' missing ' + depName);
34456
+ }
34457
+ }
34458
+
34459
+ ret = callback ? callback.apply(defined[name], args) : undefined;
34460
+
34461
+ if (name) {
34462
+ //If setting exports via "module" is in play,
34463
+ //favor that over return value and exports. After that,
34464
+ //favor a non-undefined return value over exports use.
34465
+ if (cjsModule && cjsModule.exports !== undef &&
34466
+ cjsModule.exports !== defined[name]) {
34467
+ defined[name] = cjsModule.exports;
34468
+ } else if (ret !== undef || !usingExports) {
34469
+ //Use the return value from the function.
34470
+ defined[name] = ret;
34471
+ }
34472
+ }
34473
+ } else if (name) {
34474
+ //May just be an object definition for the module. Only
34475
+ //worry about defining if have a module name.
34476
+ defined[name] = callback;
34477
+ }
34478
+ };
34479
+
34480
+ requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
34481
+ if (typeof deps === "string") {
34482
+ if (handlers[deps]) {
34483
+ //callback in this case is really relName
34484
+ return handlers[deps](callback);
34485
+ }
34486
+ //Just return the module wanted. In this scenario, the
34487
+ //deps arg is the module name, and second arg (if passed)
34488
+ //is just the relName.
34489
+ //Normalize module name, if it contains . or ..
34490
+ return callDep(makeMap(deps, makeRelParts(callback)).f);
34491
+ } else if (!deps.splice) {
34492
+ //deps is a config object, not an array.
34493
+ config = deps;
34494
+ if (config.deps) {
34495
+ req(config.deps, config.callback);
34496
+ }
34497
+ if (!callback) {
34498
+ return;
34499
+ }
34500
+
34501
+ if (callback.splice) {
34502
+ //callback is an array, which means it is a dependency list.
34503
+ //Adjust args if there are dependencies
34504
+ deps = callback;
34505
+ callback = relName;
34506
+ relName = null;
34507
+ } else {
34508
+ deps = undef;
34509
+ }
34510
+ }
34511
+
34512
+ //Support require(['a'])
34513
+ callback = callback || function () {};
34514
+
34515
+ //If relName is a function, it is an errback handler,
34516
+ //so remove it.
34517
+ if (typeof relName === 'function') {
34518
+ relName = forceSync;
34519
+ forceSync = alt;
34520
+ }
34521
+
34522
+ //Simulate async callback;
34523
+ if (forceSync) {
34524
+ main(undef, deps, callback, relName);
34525
+ } else {
34526
+ //Using a non-zero value because of concern for what old browsers
34527
+ //do, and latest browsers "upgrade" to 4 if lower value is used:
34528
+ //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
34529
+ //If want a value immediately, use require('id') instead -- something
34530
+ //that works in almond on the global level, but not guaranteed and
34531
+ //unlikely to work in other AMD implementations.
34532
+ setTimeout(function () {
34533
+ main(undef, deps, callback, relName);
34534
+ }, 4);
34535
+ }
34536
+
34537
+ return req;
34538
+ };
34539
+
34540
+ /**
34541
+ * Just drops the config on the floor, but returns req in case
34542
+ * the config return value is used.
34543
+ */
34544
+ req.config = function (cfg) {
34545
+ return req(cfg);
34546
+ };
34547
+
34548
+ /**
34549
+ * Expose module registry for debugging and tooling
34550
+ */
34551
+ requirejs._defined = defined;
34552
+
34553
+ define = function (name, deps, callback) {
34554
+ if (typeof name !== 'string') {
34555
+ throw new Error('See almond README: incorrect module build, no module name');
34556
+ }
34557
+
34558
+ //This module may not have dependencies
34559
+ if (!deps.splice) {
34560
+ //deps is not an array, so probably means
34561
+ //an object literal or factory function for
34562
+ //the value. Adjust args.
34563
+ callback = deps;
34564
+ deps = [];
34565
+ }
34566
+
34567
+ if (!hasProp(defined, name) && !hasProp(waiting, name)) {
34568
+ waiting[name] = [name, deps, callback];
34569
+ }
34570
+ };
34571
+
34572
+ define.amd = {
34573
+ jQuery: true
34574
+ };
34575
+ }());
34576
+
34577
+ S2.requirejs = requirejs;S2.require = require;S2.define = define;
34578
+ }
34579
+ }());
34580
+ S2.define("almond", function(){});
34581
+
34582
+ /* global jQuery:false, $:false */
34583
+ S2.define('jquery',[],function () {
34584
+ var _$ = jQuery || $;
34585
+
34586
+ if (_$ == null && console && console.error) {
34587
+ console.error(
34588
+ 'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
34589
+ 'found. Make sure that you are including jQuery before Select2 on your ' +
34590
+ 'web page.'
34591
+ );
34592
+ }
34593
+
34594
+ return _$;
34595
+ });
34596
+
34597
+ S2.define('select2/utils',[
34598
+ 'jquery'
34599
+ ], function ($) {
34600
+ var Utils = {};
34601
+
34602
+ Utils.Extend = function (ChildClass, SuperClass) {
34603
+ var __hasProp = {}.hasOwnProperty;
34604
+
34605
+ function BaseConstructor () {
34606
+ this.constructor = ChildClass;
34607
+ }
34608
+
34609
+ for (var key in SuperClass) {
34610
+ if (__hasProp.call(SuperClass, key)) {
34611
+ ChildClass[key] = SuperClass[key];
34612
+ }
34613
+ }
34614
+
34615
+ BaseConstructor.prototype = SuperClass.prototype;
34616
+ ChildClass.prototype = new BaseConstructor();
34617
+ ChildClass.__super__ = SuperClass.prototype;
34618
+
34619
+ return ChildClass;
34620
+ };
34621
+
34622
+ function getMethods (theClass) {
34623
+ var proto = theClass.prototype;
34624
+
34625
+ var methods = [];
34626
+
34627
+ for (var methodName in proto) {
34628
+ var m = proto[methodName];
34629
+
34630
+ if (typeof m !== 'function') {
34631
+ continue;
34632
+ }
34633
+
34634
+ if (methodName === 'constructor') {
34635
+ continue;
34636
+ }
34637
+
34638
+ methods.push(methodName);
34639
+ }
34640
+
34641
+ return methods;
34642
+ }
34643
+
34644
+ Utils.Decorate = function (SuperClass, DecoratorClass) {
34645
+ var decoratedMethods = getMethods(DecoratorClass);
34646
+ var superMethods = getMethods(SuperClass);
34647
+
34648
+ function DecoratedClass () {
34649
+ var unshift = Array.prototype.unshift;
34650
+
34651
+ var argCount = DecoratorClass.prototype.constructor.length;
34652
+
34653
+ var calledConstructor = SuperClass.prototype.constructor;
34654
+
34655
+ if (argCount > 0) {
34656
+ unshift.call(arguments, SuperClass.prototype.constructor);
34657
+
34658
+ calledConstructor = DecoratorClass.prototype.constructor;
34659
+ }
34660
+
34661
+ calledConstructor.apply(this, arguments);
34662
+ }
34663
+
34664
+ DecoratorClass.displayName = SuperClass.displayName;
34665
+
34666
+ function ctr () {
34667
+ this.constructor = DecoratedClass;
34668
+ }
34669
+
34670
+ DecoratedClass.prototype = new ctr();
34671
+
34672
+ for (var m = 0; m < superMethods.length; m++) {
34673
+ var superMethod = superMethods[m];
34674
+
34675
+ DecoratedClass.prototype[superMethod] =
34676
+ SuperClass.prototype[superMethod];
34677
+ }
34678
+
34679
+ var calledMethod = function (methodName) {
34680
+ // Stub out the original method if it's not decorating an actual method
34681
+ var originalMethod = function () {};
34682
+
34683
+ if (methodName in DecoratedClass.prototype) {
34684
+ originalMethod = DecoratedClass.prototype[methodName];
34685
+ }
34686
+
34687
+ var decoratedMethod = DecoratorClass.prototype[methodName];
34688
+
34689
+ return function () {
34690
+ var unshift = Array.prototype.unshift;
34691
+
34692
+ unshift.call(arguments, originalMethod);
34693
+
34694
+ return decoratedMethod.apply(this, arguments);
34695
+ };
34696
+ };
34697
+
34698
+ for (var d = 0; d < decoratedMethods.length; d++) {
34699
+ var decoratedMethod = decoratedMethods[d];
34700
+
34701
+ DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
34702
+ }
34703
+
34704
+ return DecoratedClass;
34705
+ };
34706
+
34707
+ var Observable = function () {
34708
+ this.listeners = {};
34709
+ };
34710
+
34711
+ Observable.prototype.on = function (event, callback) {
34712
+ this.listeners = this.listeners || {};
34713
+
34714
+ if (event in this.listeners) {
34715
+ this.listeners[event].push(callback);
34716
+ } else {
34717
+ this.listeners[event] = [callback];
34718
+ }
34719
+ };
34720
+
34721
+ Observable.prototype.trigger = function (event) {
34722
+ var slice = Array.prototype.slice;
34723
+ var params = slice.call(arguments, 1);
34724
+
34725
+ this.listeners = this.listeners || {};
34726
+
34727
+ // Params should always come in as an array
34728
+ if (params == null) {
34729
+ params = [];
34730
+ }
34731
+
34732
+ // If there are no arguments to the event, use a temporary object
34733
+ if (params.length === 0) {
34734
+ params.push({});
34735
+ }
34736
+
34737
+ // Set the `_type` of the first object to the event
34738
+ params[0]._type = event;
34739
+
34740
+ if (event in this.listeners) {
34741
+ this.invoke(this.listeners[event], slice.call(arguments, 1));
34742
+ }
34743
+
34744
+ if ('*' in this.listeners) {
34745
+ this.invoke(this.listeners['*'], arguments);
34746
+ }
34747
+ };
34748
+
34749
+ Observable.prototype.invoke = function (listeners, params) {
34750
+ for (var i = 0, len = listeners.length; i < len; i++) {
34751
+ listeners[i].apply(this, params);
34752
+ }
34753
+ };
34754
+
34755
+ Utils.Observable = Observable;
34756
+
34757
+ Utils.generateChars = function (length) {
34758
+ var chars = '';
34759
+
34760
+ for (var i = 0; i < length; i++) {
34761
+ var randomChar = Math.floor(Math.random() * 36);
34762
+ chars += randomChar.toString(36);
34763
+ }
34764
+
34765
+ return chars;
34766
+ };
34767
+
34768
+ Utils.bind = function (func, context) {
34769
+ return function () {
34770
+ func.apply(context, arguments);
34771
+ };
34772
+ };
34773
+
34774
+ Utils._convertData = function (data) {
34775
+ for (var originalKey in data) {
34776
+ var keys = originalKey.split('-');
34777
+
34778
+ var dataLevel = data;
34779
+
34780
+ if (keys.length === 1) {
34781
+ continue;
34782
+ }
34783
+
34784
+ for (var k = 0; k < keys.length; k++) {
34785
+ var key = keys[k];
34786
+
34787
+ // Lowercase the first letter
34788
+ // By default, dash-separated becomes camelCase
34789
+ key = key.substring(0, 1).toLowerCase() + key.substring(1);
34790
+
34791
+ if (!(key in dataLevel)) {
34792
+ dataLevel[key] = {};
34793
+ }
34794
+
34795
+ if (k == keys.length - 1) {
34796
+ dataLevel[key] = data[originalKey];
34797
+ }
34798
+
34799
+ dataLevel = dataLevel[key];
34800
+ }
34801
+
34802
+ delete data[originalKey];
34803
+ }
34804
+
34805
+ return data;
34806
+ };
34807
+
34808
+ Utils.hasScroll = function (index, el) {
34809
+ // Adapted from the function created by @ShadowScripter
34810
+ // and adapted by @BillBarry on the Stack Exchange Code Review website.
34811
+ // The original code can be found at
34812
+ // http://codereview.stackexchange.com/q/13338
34813
+ // and was designed to be used with the Sizzle selector engine.
34814
+
34815
+ var $el = $(el);
34816
+ var overflowX = el.style.overflowX;
34817
+ var overflowY = el.style.overflowY;
34818
+
34819
+ //Check both x and y declarations
34820
+ if (overflowX === overflowY &&
34821
+ (overflowY === 'hidden' || overflowY === 'visible')) {
34822
+ return false;
34823
+ }
34824
+
34825
+ if (overflowX === 'scroll' || overflowY === 'scroll') {
34826
+ return true;
34827
+ }
34828
+
34829
+ return ($el.innerHeight() < el.scrollHeight ||
34830
+ $el.innerWidth() < el.scrollWidth);
34831
+ };
34832
+
34833
+ Utils.escapeMarkup = function (markup) {
34834
+ var replaceMap = {
34835
+ '\\': '&#92;',
34836
+ '&': '&amp;',
34837
+ '<': '&lt;',
34838
+ '>': '&gt;',
34839
+ '"': '&quot;',
34840
+ '\'': '&#39;',
34841
+ '/': '&#47;'
34842
+ };
34843
+
34844
+ // Do not try to escape the markup if it's not a string
34845
+ if (typeof markup !== 'string') {
34846
+ return markup;
34847
+ }
34848
+
34849
+ return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
34850
+ return replaceMap[match];
34851
+ });
34852
+ };
34853
+
34854
+ // Append an array of jQuery nodes to a given element.
34855
+ Utils.appendMany = function ($element, $nodes) {
34856
+ // jQuery 1.7.x does not support $.fn.append() with an array
34857
+ // Fall back to a jQuery object collection using $.fn.add()
34858
+ if ($.fn.jquery.substr(0, 3) === '1.7') {
34859
+ var $jqNodes = $();
34860
+
34861
+ $.map($nodes, function (node) {
34862
+ $jqNodes = $jqNodes.add(node);
34863
+ });
34864
+
34865
+ $nodes = $jqNodes;
34866
+ }
34867
+
34868
+ $element.append($nodes);
34869
+ };
34870
+
34871
+ return Utils;
34872
+ });
34873
+
34874
+ S2.define('select2/results',[
34875
+ 'jquery',
34876
+ './utils'
34877
+ ], function ($, Utils) {
34878
+ function Results ($element, options, dataAdapter) {
34879
+ this.$element = $element;
34880
+ this.data = dataAdapter;
34881
+ this.options = options;
34882
+
34883
+ Results.__super__.constructor.call(this);
34884
+ }
34885
+
34886
+ Utils.Extend(Results, Utils.Observable);
34887
+
34888
+ Results.prototype.render = function () {
34889
+ var $results = $(
34890
+ '<ul class="select2-results__options" role="tree"></ul>'
34891
+ );
34892
+
34893
+ if (this.options.get('multiple')) {
34894
+ $results.attr('aria-multiselectable', 'true');
34895
+ }
34896
+
34897
+ this.$results = $results;
34898
+
34899
+ return $results;
34900
+ };
34901
+
34902
+ Results.prototype.clear = function () {
34903
+ this.$results.empty();
34904
+ };
34905
+
34906
+ Results.prototype.displayMessage = function (params) {
34907
+ var escapeMarkup = this.options.get('escapeMarkup');
34908
+
34909
+ this.clear();
34910
+ this.hideLoading();
34911
+
34912
+ var $message = $(
34913
+ '<li role="treeitem" aria-live="assertive"' +
34914
+ ' class="select2-results__option"></li>'
34915
+ );
34916
+
34917
+ var message = this.options.get('translations').get(params.message);
34918
+
34919
+ $message.append(
34920
+ escapeMarkup(
34921
+ message(params.args)
34922
+ )
34923
+ );
34924
+
34925
+ $message[0].className += ' select2-results__message';
34926
+
34927
+ this.$results.append($message);
34928
+ };
34929
+
34930
+ Results.prototype.hideMessages = function () {
34931
+ this.$results.find('.select2-results__message').remove();
34932
+ };
34933
+
34934
+ Results.prototype.append = function (data) {
34935
+ this.hideLoading();
34936
+
34937
+ var $options = [];
34938
+
34939
+ if (data.results == null || data.results.length === 0) {
34940
+ if (this.$results.children().length === 0) {
34941
+ this.trigger('results:message', {
34942
+ message: 'noResults'
34943
+ });
34944
+ }
34945
+
34946
+ return;
34947
+ }
34948
+
34949
+ data.results = this.sort(data.results);
34950
+
34951
+ for (var d = 0; d < data.results.length; d++) {
34952
+ var item = data.results[d];
34953
+
34954
+ var $option = this.option(item);
34955
+
34956
+ $options.push($option);
34957
+ }
34958
+
34959
+ this.$results.append($options);
34960
+ };
34961
+
34962
+ Results.prototype.position = function ($results, $dropdown) {
34963
+ var $resultsContainer = $dropdown.find('.select2-results');
34964
+ $resultsContainer.append($results);
34965
+ };
34966
+
34967
+ Results.prototype.sort = function (data) {
34968
+ var sorter = this.options.get('sorter');
34969
+
34970
+ return sorter(data);
34971
+ };
34972
+
34973
+ Results.prototype.highlightFirstItem = function () {
34974
+ var $options = this.$results
34975
+ .find('.select2-results__option[aria-selected]');
34976
+
34977
+ var $selected = $options.filter('[aria-selected=true]');
34978
+
34979
+ // Check if there are any selected options
34980
+ if ($selected.length > 0) {
34981
+ // If there are selected options, highlight the first
34982
+ $selected.first().trigger('mouseenter');
34983
+ } else {
34984
+ // If there are no selected options, highlight the first option
34985
+ // in the dropdown
34986
+ $options.first().trigger('mouseenter');
34987
+ }
34988
+
34989
+ this.ensureHighlightVisible();
34990
+ };
34991
+
34992
+ Results.prototype.setClasses = function () {
34993
+ var self = this;
34994
+
34995
+ this.data.current(function (selected) {
34996
+ var selectedIds = $.map(selected, function (s) {
34997
+ return s.id.toString();
34998
+ });
34999
+
35000
+ var $options = self.$results
35001
+ .find('.select2-results__option[aria-selected]');
35002
+
35003
+ $options.each(function () {
35004
+ var $option = $(this);
35005
+
35006
+ var item = $.data(this, 'data');
35007
+
35008
+ // id needs to be converted to a string when comparing
35009
+ var id = '' + item.id;
35010
+
35011
+ if ((item.element != null && item.element.selected) ||
35012
+ (item.element == null && $.inArray(id, selectedIds) > -1)) {
35013
+ $option.attr('aria-selected', 'true');
35014
+ } else {
35015
+ $option.attr('aria-selected', 'false');
35016
+ }
35017
+ });
35018
+
35019
+ });
35020
+ };
35021
+
35022
+ Results.prototype.showLoading = function (params) {
35023
+ this.hideLoading();
35024
+
35025
+ var loadingMore = this.options.get('translations').get('searching');
35026
+
35027
+ var loading = {
35028
+ disabled: true,
35029
+ loading: true,
35030
+ text: loadingMore(params)
35031
+ };
35032
+ var $loading = this.option(loading);
35033
+ $loading.className += ' loading-results';
35034
+
35035
+ this.$results.prepend($loading);
35036
+ };
35037
+
35038
+ Results.prototype.hideLoading = function () {
35039
+ this.$results.find('.loading-results').remove();
35040
+ };
35041
+
35042
+ Results.prototype.option = function (data) {
35043
+ var option = document.createElement('li');
35044
+ option.className = 'select2-results__option';
35045
+
35046
+ var attrs = {
35047
+ 'role': 'treeitem',
35048
+ 'aria-selected': 'false'
35049
+ };
35050
+
35051
+ if (data.disabled) {
35052
+ delete attrs['aria-selected'];
35053
+ attrs['aria-disabled'] = 'true';
35054
+ }
35055
+
35056
+ if (data.id == null) {
35057
+ delete attrs['aria-selected'];
35058
+ }
35059
+
35060
+ if (data._resultId != null) {
35061
+ option.id = data._resultId;
35062
+ }
35063
+
35064
+ if (data.title) {
35065
+ option.title = data.title;
35066
+ }
35067
+
35068
+ if (data.children) {
35069
+ attrs.role = 'group';
35070
+ attrs['aria-label'] = data.text;
35071
+ delete attrs['aria-selected'];
35072
+ }
35073
+
35074
+ for (var attr in attrs) {
35075
+ var val = attrs[attr];
35076
+
35077
+ option.setAttribute(attr, val);
35078
+ }
35079
+
35080
+ if (data.children) {
35081
+ var $option = $(option);
35082
+
35083
+ var label = document.createElement('strong');
35084
+ label.className = 'select2-results__group';
35085
+
35086
+ var $label = $(label);
35087
+ this.template(data, label);
35088
+
35089
+ var $children = [];
35090
+
35091
+ for (var c = 0; c < data.children.length; c++) {
35092
+ var child = data.children[c];
35093
+
35094
+ var $child = this.option(child);
35095
+
35096
+ $children.push($child);
35097
+ }
35098
+
35099
+ var $childrenContainer = $('<ul></ul>', {
35100
+ 'class': 'select2-results__options select2-results__options--nested'
35101
+ });
35102
+
35103
+ $childrenContainer.append($children);
35104
+
35105
+ $option.append(label);
35106
+ $option.append($childrenContainer);
35107
+ } else {
35108
+ this.template(data, option);
35109
+ }
35110
+
35111
+ $.data(option, 'data', data);
35112
+
35113
+ return option;
35114
+ };
35115
+
35116
+ Results.prototype.bind = function (container, $container) {
35117
+ var self = this;
35118
+
35119
+ var id = container.id + '-results';
35120
+
35121
+ this.$results.attr('id', id);
35122
+
35123
+ container.on('results:all', function (params) {
35124
+ self.clear();
35125
+ self.append(params.data);
35126
+
35127
+ if (container.isOpen()) {
35128
+ self.setClasses();
35129
+ self.highlightFirstItem();
35130
+ }
35131
+ });
35132
+
35133
+ container.on('results:append', function (params) {
35134
+ self.append(params.data);
35135
+
35136
+ if (container.isOpen()) {
35137
+ self.setClasses();
35138
+ }
35139
+ });
35140
+
35141
+ container.on('query', function (params) {
35142
+ self.hideMessages();
35143
+ self.showLoading(params);
35144
+ });
35145
+
35146
+ container.on('select', function () {
35147
+ if (!container.isOpen()) {
35148
+ return;
35149
+ }
35150
+
35151
+ self.setClasses();
35152
+ self.highlightFirstItem();
35153
+ });
35154
+
35155
+ container.on('unselect', function () {
35156
+ if (!container.isOpen()) {
35157
+ return;
35158
+ }
35159
+
35160
+ self.setClasses();
35161
+ self.highlightFirstItem();
35162
+ });
35163
+
35164
+ container.on('open', function () {
35165
+ // When the dropdown is open, aria-expended="true"
35166
+ self.$results.attr('aria-expanded', 'true');
35167
+ self.$results.attr('aria-hidden', 'false');
35168
+
35169
+ self.setClasses();
35170
+ self.ensureHighlightVisible();
35171
+ });
35172
+
35173
+ container.on('close', function () {
35174
+ // When the dropdown is closed, aria-expended="false"
35175
+ self.$results.attr('aria-expanded', 'false');
35176
+ self.$results.attr('aria-hidden', 'true');
35177
+ self.$results.removeAttr('aria-activedescendant');
35178
+ });
35179
+
35180
+ container.on('results:toggle', function () {
35181
+ var $highlighted = self.getHighlightedResults();
35182
+
35183
+ if ($highlighted.length === 0) {
35184
+ return;
35185
+ }
35186
+
35187
+ $highlighted.trigger('mouseup');
35188
+ });
35189
+
35190
+ container.on('results:select', function () {
35191
+ var $highlighted = self.getHighlightedResults();
35192
+
35193
+ if ($highlighted.length === 0) {
35194
+ return;
35195
+ }
35196
+
35197
+ var data = $highlighted.data('data');
35198
+
35199
+ if ($highlighted.attr('aria-selected') == 'true') {
35200
+ self.trigger('close', {});
35201
+ } else {
35202
+ self.trigger('select', {
35203
+ data: data
35204
+ });
35205
+ }
35206
+ });
35207
+
35208
+ container.on('results:previous', function () {
35209
+ var $highlighted = self.getHighlightedResults();
35210
+
35211
+ var $options = self.$results.find('[aria-selected]');
35212
+
35213
+ var currentIndex = $options.index($highlighted);
35214
+
35215
+ // If we are already at te top, don't move further
35216
+ if (currentIndex === 0) {
35217
+ return;
35218
+ }
35219
+
35220
+ var nextIndex = currentIndex - 1;
35221
+
35222
+ // If none are highlighted, highlight the first
35223
+ if ($highlighted.length === 0) {
35224
+ nextIndex = 0;
35225
+ }
35226
+
35227
+ var $next = $options.eq(nextIndex);
35228
+
35229
+ $next.trigger('mouseenter');
35230
+
35231
+ var currentOffset = self.$results.offset().top;
35232
+ var nextTop = $next.offset().top;
35233
+ var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
35234
+
35235
+ if (nextIndex === 0) {
35236
+ self.$results.scrollTop(0);
35237
+ } else if (nextTop - currentOffset < 0) {
35238
+ self.$results.scrollTop(nextOffset);
35239
+ }
35240
+ });
35241
+
35242
+ container.on('results:next', function () {
35243
+ var $highlighted = self.getHighlightedResults();
35244
+
35245
+ var $options = self.$results.find('[aria-selected]');
35246
+
35247
+ var currentIndex = $options.index($highlighted);
35248
+
35249
+ var nextIndex = currentIndex + 1;
35250
+
35251
+ // If we are at the last option, stay there
35252
+ if (nextIndex >= $options.length) {
35253
+ return;
35254
+ }
35255
+
35256
+ var $next = $options.eq(nextIndex);
35257
+
35258
+ $next.trigger('mouseenter');
35259
+
35260
+ var currentOffset = self.$results.offset().top +
35261
+ self.$results.outerHeight(false);
35262
+ var nextBottom = $next.offset().top + $next.outerHeight(false);
35263
+ var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
35264
+
35265
+ if (nextIndex === 0) {
35266
+ self.$results.scrollTop(0);
35267
+ } else if (nextBottom > currentOffset) {
35268
+ self.$results.scrollTop(nextOffset);
35269
+ }
35270
+ });
35271
+
35272
+ container.on('results:focus', function (params) {
35273
+ params.element.addClass('select2-results__option--highlighted');
35274
+ });
35275
+
35276
+ container.on('results:message', function (params) {
35277
+ self.displayMessage(params);
35278
+ });
35279
+
35280
+ if ($.fn.mousewheel) {
35281
+ this.$results.on('mousewheel', function (e) {
35282
+ var top = self.$results.scrollTop();
35283
+
35284
+ var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
35285
+
35286
+ var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
35287
+ var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
35288
+
35289
+ if (isAtTop) {
35290
+ self.$results.scrollTop(0);
35291
+
35292
+ e.preventDefault();
35293
+ e.stopPropagation();
35294
+ } else if (isAtBottom) {
35295
+ self.$results.scrollTop(
35296
+ self.$results.get(0).scrollHeight - self.$results.height()
35297
+ );
35298
+
35299
+ e.preventDefault();
35300
+ e.stopPropagation();
35301
+ }
35302
+ });
35303
+ }
35304
+
35305
+ this.$results.on('mouseup', '.select2-results__option[aria-selected]',
35306
+ function (evt) {
35307
+ var $this = $(this);
35308
+
35309
+ var data = $this.data('data');
35310
+
35311
+ if ($this.attr('aria-selected') === 'true') {
35312
+ if (self.options.get('multiple')) {
35313
+ self.trigger('unselect', {
35314
+ originalEvent: evt,
35315
+ data: data
35316
+ });
35317
+ } else {
35318
+ self.trigger('close', {});
35319
+ }
35320
+
35321
+ return;
35322
+ }
35323
+
35324
+ self.trigger('select', {
35325
+ originalEvent: evt,
35326
+ data: data
35327
+ });
35328
+ });
35329
+
35330
+ this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
35331
+ function (evt) {
35332
+ var data = $(this).data('data');
35333
+
35334
+ self.getHighlightedResults()
35335
+ .removeClass('select2-results__option--highlighted');
35336
+
35337
+ self.trigger('results:focus', {
35338
+ data: data,
35339
+ element: $(this)
35340
+ });
35341
+ });
35342
+ };
35343
+
35344
+ Results.prototype.getHighlightedResults = function () {
35345
+ var $highlighted = this.$results
35346
+ .find('.select2-results__option--highlighted');
35347
+
35348
+ return $highlighted;
35349
+ };
35350
+
35351
+ Results.prototype.destroy = function () {
35352
+ this.$results.remove();
35353
+ };
35354
+
35355
+ Results.prototype.ensureHighlightVisible = function () {
35356
+ var $highlighted = this.getHighlightedResults();
35357
+
35358
+ if ($highlighted.length === 0) {
35359
+ return;
35360
+ }
35361
+
35362
+ var $options = this.$results.find('[aria-selected]');
35363
+
35364
+ var currentIndex = $options.index($highlighted);
35365
+
35366
+ var currentOffset = this.$results.offset().top;
35367
+ var nextTop = $highlighted.offset().top;
35368
+ var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
35369
+
35370
+ var offsetDelta = nextTop - currentOffset;
35371
+ nextOffset -= $highlighted.outerHeight(false) * 2;
35372
+
35373
+ if (currentIndex <= 2) {
35374
+ this.$results.scrollTop(0);
35375
+ } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
35376
+ this.$results.scrollTop(nextOffset);
35377
+ }
35378
+ };
35379
+
35380
+ Results.prototype.template = function (result, container) {
35381
+ var template = this.options.get('templateResult');
35382
+ var escapeMarkup = this.options.get('escapeMarkup');
35383
+
35384
+ var content = template(result, container);
35385
+
35386
+ if (content == null) {
35387
+ container.style.display = 'none';
35388
+ } else if (typeof content === 'string') {
35389
+ container.innerHTML = escapeMarkup(content);
35390
+ } else {
35391
+ $(container).append(content);
35392
+ }
35393
+ };
35394
+
35395
+ return Results;
35396
+ });
35397
+
35398
+ S2.define('select2/keys',[
35399
+
35400
+ ], function () {
35401
+ var KEYS = {
35402
+ BACKSPACE: 8,
35403
+ TAB: 9,
35404
+ ENTER: 13,
35405
+ SHIFT: 16,
35406
+ CTRL: 17,
35407
+ ALT: 18,
35408
+ ESC: 27,
35409
+ SPACE: 32,
35410
+ PAGE_UP: 33,
35411
+ PAGE_DOWN: 34,
35412
+ END: 35,
35413
+ HOME: 36,
35414
+ LEFT: 37,
35415
+ UP: 38,
35416
+ RIGHT: 39,
35417
+ DOWN: 40,
35418
+ DELETE: 46
35419
+ };
35420
+
35421
+ return KEYS;
35422
+ });
35423
+
35424
+ S2.define('select2/selection/base',[
35425
+ 'jquery',
35426
+ '../utils',
35427
+ '../keys'
35428
+ ], function ($, Utils, KEYS) {
35429
+ function BaseSelection ($element, options) {
35430
+ this.$element = $element;
35431
+ this.options = options;
35432
+
35433
+ BaseSelection.__super__.constructor.call(this);
35434
+ }
35435
+
35436
+ Utils.Extend(BaseSelection, Utils.Observable);
35437
+
35438
+ BaseSelection.prototype.render = function () {
35439
+ var $selection = $(
35440
+ '<span class="select2-selection" role="combobox" ' +
35441
+ ' aria-haspopup="true" aria-expanded="false">' +
35442
+ '</span>'
35443
+ );
35444
+
35445
+ this._tabindex = 0;
35446
+
35447
+ if (this.$element.data('old-tabindex') != null) {
35448
+ this._tabindex = this.$element.data('old-tabindex');
35449
+ } else if (this.$element.attr('tabindex') != null) {
35450
+ this._tabindex = this.$element.attr('tabindex');
35451
+ }
35452
+
35453
+ $selection.attr('title', this.$element.attr('title'));
35454
+ $selection.attr('tabindex', this._tabindex);
35455
+
35456
+ this.$selection = $selection;
35457
+
35458
+ return $selection;
35459
+ };
35460
+
35461
+ BaseSelection.prototype.bind = function (container, $container) {
35462
+ var self = this;
35463
+
35464
+ var id = container.id + '-container';
35465
+ var resultsId = container.id + '-results';
35466
+
35467
+ this.container = container;
35468
+
35469
+ this.$selection.on('focus', function (evt) {
35470
+ self.trigger('focus', evt);
35471
+ });
35472
+
35473
+ this.$selection.on('blur', function (evt) {
35474
+ self._handleBlur(evt);
35475
+ });
35476
+
35477
+ this.$selection.on('keydown', function (evt) {
35478
+ self.trigger('keypress', evt);
35479
+
35480
+ if (evt.which === KEYS.SPACE) {
35481
+ evt.preventDefault();
35482
+ }
35483
+ });
35484
+
35485
+ container.on('results:focus', function (params) {
35486
+ self.$selection.attr('aria-activedescendant', params.data._resultId);
35487
+ });
35488
+
35489
+ container.on('selection:update', function (params) {
35490
+ self.update(params.data);
35491
+ });
35492
+
35493
+ container.on('open', function () {
35494
+ // When the dropdown is open, aria-expanded="true"
35495
+ self.$selection.attr('aria-expanded', 'true');
35496
+ self.$selection.attr('aria-owns', resultsId);
35497
+
35498
+ self._attachCloseHandler(container);
35499
+ });
35500
+
35501
+ container.on('close', function () {
35502
+ // When the dropdown is closed, aria-expanded="false"
35503
+ self.$selection.attr('aria-expanded', 'false');
35504
+ self.$selection.removeAttr('aria-activedescendant');
35505
+ self.$selection.removeAttr('aria-owns');
35506
+
35507
+ self.$selection.focus();
35508
+
35509
+ self._detachCloseHandler(container);
35510
+ });
35511
+
35512
+ container.on('enable', function () {
35513
+ self.$selection.attr('tabindex', self._tabindex);
35514
+ });
35515
+
35516
+ container.on('disable', function () {
35517
+ self.$selection.attr('tabindex', '-1');
35518
+ });
35519
+ };
35520
+
35521
+ BaseSelection.prototype._handleBlur = function (evt) {
35522
+ var self = this;
35523
+
35524
+ // This needs to be delayed as the active element is the body when the tab
35525
+ // key is pressed, possibly along with others.
35526
+ window.setTimeout(function () {
35527
+ // Don't trigger `blur` if the focus is still in the selection
35528
+ if (
35529
+ (document.activeElement == self.$selection[0]) ||
35530
+ ($.contains(self.$selection[0], document.activeElement))
35531
+ ) {
35532
+ return;
35533
+ }
35534
+
35535
+ self.trigger('blur', evt);
35536
+ }, 1);
35537
+ };
35538
+
35539
+ BaseSelection.prototype._attachCloseHandler = function (container) {
35540
+ var self = this;
35541
+
35542
+ $(document.body).on('mousedown.select2.' + container.id, function (e) {
35543
+ var $target = $(e.target);
35544
+
35545
+ var $select = $target.closest('.select2');
35546
+
35547
+ var $all = $('.select2.select2-container--open');
35548
+
35549
+ $all.each(function () {
35550
+ var $this = $(this);
35551
+
35552
+ if (this == $select[0]) {
35553
+ return;
35554
+ }
35555
+
35556
+ var $element = $this.data('element');
35557
+
35558
+ $element.select2('close');
35559
+ });
35560
+ });
35561
+ };
35562
+
35563
+ BaseSelection.prototype._detachCloseHandler = function (container) {
35564
+ $(document.body).off('mousedown.select2.' + container.id);
35565
+ };
35566
+
35567
+ BaseSelection.prototype.position = function ($selection, $container) {
35568
+ var $selectionContainer = $container.find('.selection');
35569
+ $selectionContainer.append($selection);
35570
+ };
35571
+
35572
+ BaseSelection.prototype.destroy = function () {
35573
+ this._detachCloseHandler(this.container);
35574
+ };
35575
+
35576
+ BaseSelection.prototype.update = function (data) {
35577
+ throw new Error('The `update` method must be defined in child classes.');
35578
+ };
35579
+
35580
+ return BaseSelection;
35581
+ });
35582
+
35583
+ S2.define('select2/selection/single',[
35584
+ 'jquery',
35585
+ './base',
35586
+ '../utils',
35587
+ '../keys'
35588
+ ], function ($, BaseSelection, Utils, KEYS) {
35589
+ function SingleSelection () {
35590
+ SingleSelection.__super__.constructor.apply(this, arguments);
35591
+ }
35592
+
35593
+ Utils.Extend(SingleSelection, BaseSelection);
35594
+
35595
+ SingleSelection.prototype.render = function () {
35596
+ var $selection = SingleSelection.__super__.render.call(this);
35597
+
35598
+ $selection.addClass('select2-selection--single');
35599
+
35600
+ $selection.html(
35601
+ '<span class="select2-selection__rendered"></span>' +
35602
+ '<span class="select2-selection__arrow" role="presentation">' +
35603
+ '<b role="presentation"></b>' +
35604
+ '</span>'
35605
+ );
35606
+
35607
+ return $selection;
35608
+ };
35609
+
35610
+ SingleSelection.prototype.bind = function (container, $container) {
35611
+ var self = this;
35612
+
35613
+ SingleSelection.__super__.bind.apply(this, arguments);
35614
+
35615
+ var id = container.id + '-container';
35616
+
35617
+ this.$selection.find('.select2-selection__rendered').attr('id', id);
35618
+ this.$selection.attr('aria-labelledby', id);
35619
+
35620
+ this.$selection.on('mousedown', function (evt) {
35621
+ // Only respond to left clicks
35622
+ if (evt.which !== 1) {
35623
+ return;
35624
+ }
35625
+
35626
+ self.trigger('toggle', {
35627
+ originalEvent: evt
35628
+ });
35629
+ });
35630
+
35631
+ this.$selection.on('focus', function (evt) {
35632
+ // User focuses on the container
35633
+ });
35634
+
35635
+ this.$selection.on('blur', function (evt) {
35636
+ // User exits the container
35637
+ });
35638
+
35639
+ container.on('focus', function (evt) {
35640
+ if (!container.isOpen()) {
35641
+ self.$selection.focus();
35642
+ }
35643
+ });
35644
+
35645
+ container.on('selection:update', function (params) {
35646
+ self.update(params.data);
35647
+ });
35648
+ };
35649
+
35650
+ SingleSelection.prototype.clear = function () {
35651
+ this.$selection.find('.select2-selection__rendered').empty();
35652
+ };
35653
+
35654
+ SingleSelection.prototype.display = function (data, container) {
35655
+ var template = this.options.get('templateSelection');
35656
+ var escapeMarkup = this.options.get('escapeMarkup');
35657
+
35658
+ return escapeMarkup(template(data, container));
35659
+ };
35660
+
35661
+ SingleSelection.prototype.selectionContainer = function () {
35662
+ return $('<span></span>');
35663
+ };
35664
+
35665
+ SingleSelection.prototype.update = function (data) {
35666
+ if (data.length === 0) {
35667
+ this.clear();
35668
+ return;
35669
+ }
35670
+
35671
+ var selection = data[0];
35672
+
35673
+ var $rendered = this.$selection.find('.select2-selection__rendered');
35674
+ var formatted = this.display(selection, $rendered);
35675
+
35676
+ $rendered.empty().append(formatted);
35677
+ $rendered.prop('title', selection.title || selection.text);
35678
+ };
35679
+
35680
+ return SingleSelection;
35681
+ });
35682
+
35683
+ S2.define('select2/selection/multiple',[
35684
+ 'jquery',
35685
+ './base',
35686
+ '../utils'
35687
+ ], function ($, BaseSelection, Utils) {
35688
+ function MultipleSelection ($element, options) {
35689
+ MultipleSelection.__super__.constructor.apply(this, arguments);
35690
+ }
35691
+
35692
+ Utils.Extend(MultipleSelection, BaseSelection);
35693
+
35694
+ MultipleSelection.prototype.render = function () {
35695
+ var $selection = MultipleSelection.__super__.render.call(this);
35696
+
35697
+ $selection.addClass('select2-selection--multiple');
35698
+
35699
+ $selection.html(
35700
+ '<ul class="select2-selection__rendered"></ul>'
35701
+ );
35702
+
35703
+ return $selection;
35704
+ };
35705
+
35706
+ MultipleSelection.prototype.bind = function (container, $container) {
35707
+ var self = this;
35708
+
35709
+ MultipleSelection.__super__.bind.apply(this, arguments);
35710
+
35711
+ this.$selection.on('click', function (evt) {
35712
+ self.trigger('toggle', {
35713
+ originalEvent: evt
35714
+ });
35715
+ });
35716
+
35717
+ this.$selection.on(
35718
+ 'click',
35719
+ '.select2-selection__choice__remove',
35720
+ function (evt) {
35721
+ // Ignore the event if it is disabled
35722
+ if (self.options.get('disabled')) {
35723
+ return;
35724
+ }
35725
+
35726
+ var $remove = $(this);
35727
+ var $selection = $remove.parent();
35728
+
35729
+ var data = $selection.data('data');
35730
+
35731
+ self.trigger('unselect', {
35732
+ originalEvent: evt,
35733
+ data: data
35734
+ });
35735
+ }
35736
+ );
35737
+ };
35738
+
35739
+ MultipleSelection.prototype.clear = function () {
35740
+ this.$selection.find('.select2-selection__rendered').empty();
35741
+ };
35742
+
35743
+ MultipleSelection.prototype.display = function (data, container) {
35744
+ var template = this.options.get('templateSelection');
35745
+ var escapeMarkup = this.options.get('escapeMarkup');
35746
+
35747
+ return escapeMarkup(template(data, container));
35748
+ };
35749
+
35750
+ MultipleSelection.prototype.selectionContainer = function () {
35751
+ var $container = $(
35752
+ '<li class="select2-selection__choice">' +
35753
+ '<span class="select2-selection__choice__remove" role="presentation">' +
35754
+ '&times;' +
35755
+ '</span>' +
35756
+ '</li>'
35757
+ );
35758
+
35759
+ return $container;
35760
+ };
35761
+
35762
+ MultipleSelection.prototype.update = function (data) {
35763
+ this.clear();
35764
+
35765
+ if (data.length === 0) {
35766
+ return;
35767
+ }
35768
+
35769
+ var $selections = [];
35770
+
35771
+ for (var d = 0; d < data.length; d++) {
35772
+ var selection = data[d];
35773
+
35774
+ var $selection = this.selectionContainer();
35775
+ var formatted = this.display(selection, $selection);
35776
+
35777
+ $selection.append(formatted);
35778
+ $selection.prop('title', selection.title || selection.text);
35779
+
35780
+ $selection.data('data', selection);
35781
+
35782
+ $selections.push($selection);
35783
+ }
35784
+
35785
+ var $rendered = this.$selection.find('.select2-selection__rendered');
35786
+
35787
+ Utils.appendMany($rendered, $selections);
35788
+ };
35789
+
35790
+ return MultipleSelection;
35791
+ });
35792
+
35793
+ S2.define('select2/selection/placeholder',[
35794
+ '../utils'
35795
+ ], function (Utils) {
35796
+ function Placeholder (decorated, $element, options) {
35797
+ this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
35798
+
35799
+ decorated.call(this, $element, options);
35800
+ }
35801
+
35802
+ Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
35803
+ if (typeof placeholder === 'string') {
35804
+ placeholder = {
35805
+ id: '',
35806
+ text: placeholder
35807
+ };
35808
+ }
35809
+
35810
+ return placeholder;
35811
+ };
35812
+
35813
+ Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
35814
+ var $placeholder = this.selectionContainer();
35815
+
35816
+ $placeholder.html(this.display(placeholder));
35817
+ $placeholder.addClass('select2-selection__placeholder')
35818
+ .removeClass('select2-selection__choice');
35819
+
35820
+ return $placeholder;
35821
+ };
35822
+
35823
+ Placeholder.prototype.update = function (decorated, data) {
35824
+ var singlePlaceholder = (
35825
+ data.length == 1 && data[0].id != this.placeholder.id
35826
+ );
35827
+ var multipleSelections = data.length > 1;
35828
+
35829
+ if (multipleSelections || singlePlaceholder) {
35830
+ return decorated.call(this, data);
35831
+ }
35832
+
35833
+ this.clear();
35834
+
35835
+ var $placeholder = this.createPlaceholder(this.placeholder);
35836
+
35837
+ this.$selection.find('.select2-selection__rendered').append($placeholder);
35838
+ };
35839
+
35840
+ return Placeholder;
35841
+ });
35842
+
35843
+ S2.define('select2/selection/allowClear',[
35844
+ 'jquery',
35845
+ '../keys'
35846
+ ], function ($, KEYS) {
35847
+ function AllowClear () { }
35848
+
35849
+ AllowClear.prototype.bind = function (decorated, container, $container) {
35850
+ var self = this;
35851
+
35852
+ decorated.call(this, container, $container);
35853
+
35854
+ if (this.placeholder == null) {
35855
+ if (this.options.get('debug') && window.console && console.error) {
35856
+ console.error(
35857
+ 'Select2: The `allowClear` option should be used in combination ' +
35858
+ 'with the `placeholder` option.'
35859
+ );
35860
+ }
35861
+ }
35862
+
35863
+ this.$selection.on('mousedown', '.select2-selection__clear',
35864
+ function (evt) {
35865
+ self._handleClear(evt);
35866
+ });
35867
+
35868
+ container.on('keypress', function (evt) {
35869
+ self._handleKeyboardClear(evt, container);
35870
+ });
35871
+ };
35872
+
35873
+ AllowClear.prototype._handleClear = function (_, evt) {
35874
+ // Ignore the event if it is disabled
35875
+ if (this.options.get('disabled')) {
35876
+ return;
35877
+ }
35878
+
35879
+ var $clear = this.$selection.find('.select2-selection__clear');
35880
+
35881
+ // Ignore the event if nothing has been selected
35882
+ if ($clear.length === 0) {
35883
+ return;
35884
+ }
35885
+
35886
+ evt.stopPropagation();
35887
+
35888
+ var data = $clear.data('data');
35889
+
35890
+ for (var d = 0; d < data.length; d++) {
35891
+ var unselectData = {
35892
+ data: data[d]
35893
+ };
35894
+
35895
+ // Trigger the `unselect` event, so people can prevent it from being
35896
+ // cleared.
35897
+ this.trigger('unselect', unselectData);
35898
+
35899
+ // If the event was prevented, don't clear it out.
35900
+ if (unselectData.prevented) {
35901
+ return;
35902
+ }
35903
+ }
35904
+
35905
+ this.$element.val(this.placeholder.id).trigger('change');
35906
+
35907
+ this.trigger('toggle', {});
35908
+ };
35909
+
35910
+ AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
35911
+ if (container.isOpen()) {
35912
+ return;
35913
+ }
35914
+
35915
+ if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
35916
+ this._handleClear(evt);
35917
+ }
35918
+ };
35919
+
35920
+ AllowClear.prototype.update = function (decorated, data) {
35921
+ decorated.call(this, data);
35922
+
35923
+ if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
35924
+ data.length === 0) {
35925
+ return;
35926
+ }
35927
+
35928
+ var $remove = $(
35929
+ '<span class="select2-selection__clear">' +
35930
+ '&times;' +
35931
+ '</span>'
35932
+ );
35933
+ $remove.data('data', data);
35934
+
35935
+ this.$selection.find('.select2-selection__rendered').prepend($remove);
35936
+ };
35937
+
35938
+ return AllowClear;
35939
+ });
35940
+
35941
+ S2.define('select2/selection/search',[
35942
+ 'jquery',
35943
+ '../utils',
35944
+ '../keys'
35945
+ ], function ($, Utils, KEYS) {
35946
+ function Search (decorated, $element, options) {
35947
+ decorated.call(this, $element, options);
35948
+ }
35949
+
35950
+ Search.prototype.render = function (decorated) {
35951
+ var $search = $(
35952
+ '<li class="select2-search select2-search--inline">' +
35953
+ '<input class="select2-search__field" type="search" tabindex="-1"' +
35954
+ ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
35955
+ ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
35956
+ '</li>'
35957
+ );
35958
+
35959
+ this.$searchContainer = $search;
35960
+ this.$search = $search.find('input');
35961
+
35962
+ var $rendered = decorated.call(this);
35963
+
35964
+ this._transferTabIndex();
35965
+
35966
+ return $rendered;
35967
+ };
35968
+
35969
+ Search.prototype.bind = function (decorated, container, $container) {
35970
+ var self = this;
35971
+
35972
+ decorated.call(this, container, $container);
35973
+
35974
+ container.on('open', function () {
35975
+ self.$search.trigger('focus');
35976
+ });
35977
+
35978
+ container.on('close', function () {
35979
+ self.$search.val('');
35980
+ self.$search.removeAttr('aria-activedescendant');
35981
+ self.$search.trigger('focus');
35982
+ });
35983
+
35984
+ container.on('enable', function () {
35985
+ self.$search.prop('disabled', false);
35986
+
35987
+ self._transferTabIndex();
35988
+ });
35989
+
35990
+ container.on('disable', function () {
35991
+ self.$search.prop('disabled', true);
35992
+ });
35993
+
35994
+ container.on('focus', function (evt) {
35995
+ self.$search.trigger('focus');
35996
+ });
35997
+
35998
+ container.on('results:focus', function (params) {
35999
+ self.$search.attr('aria-activedescendant', params.id);
36000
+ });
36001
+
36002
+ this.$selection.on('focusin', '.select2-search--inline', function (evt) {
36003
+ self.trigger('focus', evt);
36004
+ });
36005
+
36006
+ this.$selection.on('focusout', '.select2-search--inline', function (evt) {
36007
+ self._handleBlur(evt);
36008
+ });
36009
+
36010
+ this.$selection.on('keydown', '.select2-search--inline', function (evt) {
36011
+ evt.stopPropagation();
36012
+
36013
+ self.trigger('keypress', evt);
36014
+
36015
+ self._keyUpPrevented = evt.isDefaultPrevented();
36016
+
36017
+ var key = evt.which;
36018
+
36019
+ if (key === KEYS.BACKSPACE && self.$search.val() === '') {
36020
+ var $previousChoice = self.$searchContainer
36021
+ .prev('.select2-selection__choice');
36022
+
36023
+ if ($previousChoice.length > 0) {
36024
+ var item = $previousChoice.data('data');
36025
+
36026
+ self.searchRemoveChoice(item);
36027
+
36028
+ evt.preventDefault();
36029
+ }
36030
+ }
36031
+ });
36032
+
36033
+ // Try to detect the IE version should the `documentMode` property that
36034
+ // is stored on the document. This is only implemented in IE and is
36035
+ // slightly cleaner than doing a user agent check.
36036
+ // This property is not available in Edge, but Edge also doesn't have
36037
+ // this bug.
36038
+ var msie = document.documentMode;
36039
+ var disableInputEvents = msie && msie <= 11;
36040
+
36041
+ // Workaround for browsers which do not support the `input` event
36042
+ // This will prevent double-triggering of events for browsers which support
36043
+ // both the `keyup` and `input` events.
36044
+ this.$selection.on(
36045
+ 'input.searchcheck',
36046
+ '.select2-search--inline',
36047
+ function (evt) {
36048
+ // IE will trigger the `input` event when a placeholder is used on a
36049
+ // search box. To get around this issue, we are forced to ignore all
36050
+ // `input` events in IE and keep using `keyup`.
36051
+ if (disableInputEvents) {
36052
+ self.$selection.off('input.search input.searchcheck');
36053
+ return;
36054
+ }
36055
+
36056
+ // Unbind the duplicated `keyup` event
36057
+ self.$selection.off('keyup.search');
36058
+ }
36059
+ );
36060
+
36061
+ this.$selection.on(
36062
+ 'keyup.search input.search',
36063
+ '.select2-search--inline',
36064
+ function (evt) {
36065
+ // IE will trigger the `input` event when a placeholder is used on a
36066
+ // search box. To get around this issue, we are forced to ignore all
36067
+ // `input` events in IE and keep using `keyup`.
36068
+ if (disableInputEvents && evt.type === 'input') {
36069
+ self.$selection.off('input.search input.searchcheck');
36070
+ return;
36071
+ }
36072
+
36073
+ var key = evt.which;
36074
+
36075
+ // We can freely ignore events from modifier keys
36076
+ if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
36077
+ return;
36078
+ }
36079
+
36080
+ // Tabbing will be handled during the `keydown` phase
36081
+ if (key == KEYS.TAB) {
36082
+ return;
36083
+ }
36084
+
36085
+ self.handleSearch(evt);
36086
+ }
36087
+ );
36088
+ };
36089
+
36090
+ /**
36091
+ * This method will transfer the tabindex attribute from the rendered
36092
+ * selection to the search box. This allows for the search box to be used as
36093
+ * the primary focus instead of the selection container.
36094
+ *
36095
+ * @private
36096
+ */
36097
+ Search.prototype._transferTabIndex = function (decorated) {
36098
+ this.$search.attr('tabindex', this.$selection.attr('tabindex'));
36099
+ this.$selection.attr('tabindex', '-1');
36100
+ };
36101
+
36102
+ Search.prototype.createPlaceholder = function (decorated, placeholder) {
36103
+ this.$search.attr('placeholder', placeholder.text);
36104
+ };
36105
+
36106
+ Search.prototype.update = function (decorated, data) {
36107
+ var searchHadFocus = this.$search[0] == document.activeElement;
36108
+
36109
+ this.$search.attr('placeholder', '');
36110
+
36111
+ decorated.call(this, data);
36112
+
36113
+ this.$selection.find('.select2-selection__rendered')
36114
+ .append(this.$searchContainer);
36115
+
36116
+ this.resizeSearch();
36117
+ if (searchHadFocus) {
36118
+ this.$search.focus();
36119
+ }
36120
+ };
36121
+
36122
+ Search.prototype.handleSearch = function () {
36123
+ this.resizeSearch();
36124
+
36125
+ if (!this._keyUpPrevented) {
36126
+ var input = this.$search.val();
36127
+
36128
+ this.trigger('query', {
36129
+ term: input
36130
+ });
36131
+ }
36132
+
36133
+ this._keyUpPrevented = false;
36134
+ };
36135
+
36136
+ Search.prototype.searchRemoveChoice = function (decorated, item) {
36137
+ this.trigger('unselect', {
36138
+ data: item
36139
+ });
36140
+
36141
+ this.$search.val(item.text);
36142
+ this.handleSearch();
36143
+ };
36144
+
36145
+ Search.prototype.resizeSearch = function () {
36146
+ this.$search.css('width', '25px');
36147
+
36148
+ var width = '';
36149
+
36150
+ if (this.$search.attr('placeholder') !== '') {
36151
+ width = this.$selection.find('.select2-selection__rendered').innerWidth();
36152
+ } else {
36153
+ var minimumWidth = this.$search.val().length + 1;
36154
+
36155
+ width = (minimumWidth * 0.75) + 'em';
36156
+ }
36157
+
36158
+ this.$search.css('width', width);
36159
+ };
36160
+
36161
+ return Search;
36162
+ });
36163
+
36164
+ S2.define('select2/selection/eventRelay',[
36165
+ 'jquery'
36166
+ ], function ($) {
36167
+ function EventRelay () { }
36168
+
36169
+ EventRelay.prototype.bind = function (decorated, container, $container) {
36170
+ var self = this;
36171
+ var relayEvents = [
36172
+ 'open', 'opening',
36173
+ 'close', 'closing',
36174
+ 'select', 'selecting',
36175
+ 'unselect', 'unselecting'
36176
+ ];
36177
+
36178
+ var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
36179
+
36180
+ decorated.call(this, container, $container);
36181
+
36182
+ container.on('*', function (name, params) {
36183
+ // Ignore events that should not be relayed
36184
+ if ($.inArray(name, relayEvents) === -1) {
36185
+ return;
36186
+ }
36187
+
36188
+ // The parameters should always be an object
36189
+ params = params || {};
36190
+
36191
+ // Generate the jQuery event for the Select2 event
36192
+ var evt = $.Event('select2:' + name, {
36193
+ params: params
36194
+ });
36195
+
36196
+ self.$element.trigger(evt);
36197
+
36198
+ // Only handle preventable events if it was one
36199
+ if ($.inArray(name, preventableEvents) === -1) {
36200
+ return;
36201
+ }
36202
+
36203
+ params.prevented = evt.isDefaultPrevented();
36204
+ });
36205
+ };
36206
+
36207
+ return EventRelay;
36208
+ });
36209
+
36210
+ S2.define('select2/translation',[
36211
+ 'jquery',
36212
+ 'require'
36213
+ ], function ($, require) {
36214
+ function Translation (dict) {
36215
+ this.dict = dict || {};
36216
+ }
36217
+
36218
+ Translation.prototype.all = function () {
36219
+ return this.dict;
36220
+ };
36221
+
36222
+ Translation.prototype.get = function (key) {
36223
+ return this.dict[key];
36224
+ };
36225
+
36226
+ Translation.prototype.extend = function (translation) {
36227
+ this.dict = $.extend({}, translation.all(), this.dict);
36228
+ };
36229
+
36230
+ // Static functions
36231
+
36232
+ Translation._cache = {};
36233
+
36234
+ Translation.loadPath = function (path) {
36235
+ if (!(path in Translation._cache)) {
36236
+ var translations = require(path);
36237
+
36238
+ Translation._cache[path] = translations;
36239
+ }
36240
+
36241
+ return new Translation(Translation._cache[path]);
36242
+ };
36243
+
36244
+ return Translation;
36245
+ });
36246
+
36247
+ S2.define('select2/diacritics',[
36248
+
36249
+ ], function () {
36250
+ var diacritics = {
36251
+ '\u24B6': 'A',
36252
+ '\uFF21': 'A',
36253
+ '\u00C0': 'A',
36254
+ '\u00C1': 'A',
36255
+ '\u00C2': 'A',
36256
+ '\u1EA6': 'A',
36257
+ '\u1EA4': 'A',
36258
+ '\u1EAA': 'A',
36259
+ '\u1EA8': 'A',
36260
+ '\u00C3': 'A',
36261
+ '\u0100': 'A',
36262
+ '\u0102': 'A',
36263
+ '\u1EB0': 'A',
36264
+ '\u1EAE': 'A',
36265
+ '\u1EB4': 'A',
36266
+ '\u1EB2': 'A',
36267
+ '\u0226': 'A',
36268
+ '\u01E0': 'A',
36269
+ '\u00C4': 'A',
36270
+ '\u01DE': 'A',
36271
+ '\u1EA2': 'A',
36272
+ '\u00C5': 'A',
36273
+ '\u01FA': 'A',
36274
+ '\u01CD': 'A',
36275
+ '\u0200': 'A',
36276
+ '\u0202': 'A',
36277
+ '\u1EA0': 'A',
36278
+ '\u1EAC': 'A',
36279
+ '\u1EB6': 'A',
36280
+ '\u1E00': 'A',
36281
+ '\u0104': 'A',
36282
+ '\u023A': 'A',
36283
+ '\u2C6F': 'A',
36284
+ '\uA732': 'AA',
36285
+ '\u00C6': 'AE',
36286
+ '\u01FC': 'AE',
36287
+ '\u01E2': 'AE',
36288
+ '\uA734': 'AO',
36289
+ '\uA736': 'AU',
36290
+ '\uA738': 'AV',
36291
+ '\uA73A': 'AV',
36292
+ '\uA73C': 'AY',
36293
+ '\u24B7': 'B',
36294
+ '\uFF22': 'B',
36295
+ '\u1E02': 'B',
36296
+ '\u1E04': 'B',
36297
+ '\u1E06': 'B',
36298
+ '\u0243': 'B',
36299
+ '\u0182': 'B',
36300
+ '\u0181': 'B',
36301
+ '\u24B8': 'C',
36302
+ '\uFF23': 'C',
36303
+ '\u0106': 'C',
36304
+ '\u0108': 'C',
36305
+ '\u010A': 'C',
36306
+ '\u010C': 'C',
36307
+ '\u00C7': 'C',
36308
+ '\u1E08': 'C',
36309
+ '\u0187': 'C',
36310
+ '\u023B': 'C',
36311
+ '\uA73E': 'C',
36312
+ '\u24B9': 'D',
36313
+ '\uFF24': 'D',
36314
+ '\u1E0A': 'D',
36315
+ '\u010E': 'D',
36316
+ '\u1E0C': 'D',
36317
+ '\u1E10': 'D',
36318
+ '\u1E12': 'D',
36319
+ '\u1E0E': 'D',
36320
+ '\u0110': 'D',
36321
+ '\u018B': 'D',
36322
+ '\u018A': 'D',
36323
+ '\u0189': 'D',
36324
+ '\uA779': 'D',
36325
+ '\u01F1': 'DZ',
36326
+ '\u01C4': 'DZ',
36327
+ '\u01F2': 'Dz',
36328
+ '\u01C5': 'Dz',
36329
+ '\u24BA': 'E',
36330
+ '\uFF25': 'E',
36331
+ '\u00C8': 'E',
36332
+ '\u00C9': 'E',
36333
+ '\u00CA': 'E',
36334
+ '\u1EC0': 'E',
36335
+ '\u1EBE': 'E',
36336
+ '\u1EC4': 'E',
36337
+ '\u1EC2': 'E',
36338
+ '\u1EBC': 'E',
36339
+ '\u0112': 'E',
36340
+ '\u1E14': 'E',
36341
+ '\u1E16': 'E',
36342
+ '\u0114': 'E',
36343
+ '\u0116': 'E',
36344
+ '\u00CB': 'E',
36345
+ '\u1EBA': 'E',
36346
+ '\u011A': 'E',
36347
+ '\u0204': 'E',
36348
+ '\u0206': 'E',
36349
+ '\u1EB8': 'E',
36350
+ '\u1EC6': 'E',
36351
+ '\u0228': 'E',
36352
+ '\u1E1C': 'E',
36353
+ '\u0118': 'E',
36354
+ '\u1E18': 'E',
36355
+ '\u1E1A': 'E',
36356
+ '\u0190': 'E',
36357
+ '\u018E': 'E',
36358
+ '\u24BB': 'F',
36359
+ '\uFF26': 'F',
36360
+ '\u1E1E': 'F',
36361
+ '\u0191': 'F',
36362
+ '\uA77B': 'F',
36363
+ '\u24BC': 'G',
36364
+ '\uFF27': 'G',
36365
+ '\u01F4': 'G',
36366
+ '\u011C': 'G',
36367
+ '\u1E20': 'G',
36368
+ '\u011E': 'G',
36369
+ '\u0120': 'G',
36370
+ '\u01E6': 'G',
36371
+ '\u0122': 'G',
36372
+ '\u01E4': 'G',
36373
+ '\u0193': 'G',
36374
+ '\uA7A0': 'G',
36375
+ '\uA77D': 'G',
36376
+ '\uA77E': 'G',
36377
+ '\u24BD': 'H',
36378
+ '\uFF28': 'H',
36379
+ '\u0124': 'H',
36380
+ '\u1E22': 'H',
36381
+ '\u1E26': 'H',
36382
+ '\u021E': 'H',
36383
+ '\u1E24': 'H',
36384
+ '\u1E28': 'H',
36385
+ '\u1E2A': 'H',
36386
+ '\u0126': 'H',
36387
+ '\u2C67': 'H',
36388
+ '\u2C75': 'H',
36389
+ '\uA78D': 'H',
36390
+ '\u24BE': 'I',
36391
+ '\uFF29': 'I',
36392
+ '\u00CC': 'I',
36393
+ '\u00CD': 'I',
36394
+ '\u00CE': 'I',
36395
+ '\u0128': 'I',
36396
+ '\u012A': 'I',
36397
+ '\u012C': 'I',
36398
+ '\u0130': 'I',
36399
+ '\u00CF': 'I',
36400
+ '\u1E2E': 'I',
36401
+ '\u1EC8': 'I',
36402
+ '\u01CF': 'I',
36403
+ '\u0208': 'I',
36404
+ '\u020A': 'I',
36405
+ '\u1ECA': 'I',
36406
+ '\u012E': 'I',
36407
+ '\u1E2C': 'I',
36408
+ '\u0197': 'I',
36409
+ '\u24BF': 'J',
36410
+ '\uFF2A': 'J',
36411
+ '\u0134': 'J',
36412
+ '\u0248': 'J',
36413
+ '\u24C0': 'K',
36414
+ '\uFF2B': 'K',
36415
+ '\u1E30': 'K',
36416
+ '\u01E8': 'K',
36417
+ '\u1E32': 'K',
36418
+ '\u0136': 'K',
36419
+ '\u1E34': 'K',
36420
+ '\u0198': 'K',
36421
+ '\u2C69': 'K',
36422
+ '\uA740': 'K',
36423
+ '\uA742': 'K',
36424
+ '\uA744': 'K',
36425
+ '\uA7A2': 'K',
36426
+ '\u24C1': 'L',
36427
+ '\uFF2C': 'L',
36428
+ '\u013F': 'L',
36429
+ '\u0139': 'L',
36430
+ '\u013D': 'L',
36431
+ '\u1E36': 'L',
36432
+ '\u1E38': 'L',
36433
+ '\u013B': 'L',
36434
+ '\u1E3C': 'L',
36435
+ '\u1E3A': 'L',
36436
+ '\u0141': 'L',
36437
+ '\u023D': 'L',
36438
+ '\u2C62': 'L',
36439
+ '\u2C60': 'L',
36440
+ '\uA748': 'L',
36441
+ '\uA746': 'L',
36442
+ '\uA780': 'L',
36443
+ '\u01C7': 'LJ',
36444
+ '\u01C8': 'Lj',
36445
+ '\u24C2': 'M',
36446
+ '\uFF2D': 'M',
36447
+ '\u1E3E': 'M',
36448
+ '\u1E40': 'M',
36449
+ '\u1E42': 'M',
36450
+ '\u2C6E': 'M',
36451
+ '\u019C': 'M',
36452
+ '\u24C3': 'N',
36453
+ '\uFF2E': 'N',
36454
+ '\u01F8': 'N',
36455
+ '\u0143': 'N',
36456
+ '\u00D1': 'N',
36457
+ '\u1E44': 'N',
36458
+ '\u0147': 'N',
36459
+ '\u1E46': 'N',
36460
+ '\u0145': 'N',
36461
+ '\u1E4A': 'N',
36462
+ '\u1E48': 'N',
36463
+ '\u0220': 'N',
36464
+ '\u019D': 'N',
36465
+ '\uA790': 'N',
36466
+ '\uA7A4': 'N',
36467
+ '\u01CA': 'NJ',
36468
+ '\u01CB': 'Nj',
36469
+ '\u24C4': 'O',
36470
+ '\uFF2F': 'O',
36471
+ '\u00D2': 'O',
36472
+ '\u00D3': 'O',
36473
+ '\u00D4': 'O',
36474
+ '\u1ED2': 'O',
36475
+ '\u1ED0': 'O',
36476
+ '\u1ED6': 'O',
36477
+ '\u1ED4': 'O',
36478
+ '\u00D5': 'O',
36479
+ '\u1E4C': 'O',
36480
+ '\u022C': 'O',
36481
+ '\u1E4E': 'O',
36482
+ '\u014C': 'O',
36483
+ '\u1E50': 'O',
36484
+ '\u1E52': 'O',
36485
+ '\u014E': 'O',
36486
+ '\u022E': 'O',
36487
+ '\u0230': 'O',
36488
+ '\u00D6': 'O',
36489
+ '\u022A': 'O',
36490
+ '\u1ECE': 'O',
36491
+ '\u0150': 'O',
36492
+ '\u01D1': 'O',
36493
+ '\u020C': 'O',
36494
+ '\u020E': 'O',
36495
+ '\u01A0': 'O',
36496
+ '\u1EDC': 'O',
36497
+ '\u1EDA': 'O',
36498
+ '\u1EE0': 'O',
36499
+ '\u1EDE': 'O',
36500
+ '\u1EE2': 'O',
36501
+ '\u1ECC': 'O',
36502
+ '\u1ED8': 'O',
36503
+ '\u01EA': 'O',
36504
+ '\u01EC': 'O',
36505
+ '\u00D8': 'O',
36506
+ '\u01FE': 'O',
36507
+ '\u0186': 'O',
36508
+ '\u019F': 'O',
36509
+ '\uA74A': 'O',
36510
+ '\uA74C': 'O',
36511
+ '\u01A2': 'OI',
36512
+ '\uA74E': 'OO',
36513
+ '\u0222': 'OU',
36514
+ '\u24C5': 'P',
36515
+ '\uFF30': 'P',
36516
+ '\u1E54': 'P',
36517
+ '\u1E56': 'P',
36518
+ '\u01A4': 'P',
36519
+ '\u2C63': 'P',
36520
+ '\uA750': 'P',
36521
+ '\uA752': 'P',
36522
+ '\uA754': 'P',
36523
+ '\u24C6': 'Q',
36524
+ '\uFF31': 'Q',
36525
+ '\uA756': 'Q',
36526
+ '\uA758': 'Q',
36527
+ '\u024A': 'Q',
36528
+ '\u24C7': 'R',
36529
+ '\uFF32': 'R',
36530
+ '\u0154': 'R',
36531
+ '\u1E58': 'R',
36532
+ '\u0158': 'R',
36533
+ '\u0210': 'R',
36534
+ '\u0212': 'R',
36535
+ '\u1E5A': 'R',
36536
+ '\u1E5C': 'R',
36537
+ '\u0156': 'R',
36538
+ '\u1E5E': 'R',
36539
+ '\u024C': 'R',
36540
+ '\u2C64': 'R',
36541
+ '\uA75A': 'R',
36542
+ '\uA7A6': 'R',
36543
+ '\uA782': 'R',
36544
+ '\u24C8': 'S',
36545
+ '\uFF33': 'S',
36546
+ '\u1E9E': 'S',
36547
+ '\u015A': 'S',
36548
+ '\u1E64': 'S',
36549
+ '\u015C': 'S',
36550
+ '\u1E60': 'S',
36551
+ '\u0160': 'S',
36552
+ '\u1E66': 'S',
36553
+ '\u1E62': 'S',
36554
+ '\u1E68': 'S',
36555
+ '\u0218': 'S',
36556
+ '\u015E': 'S',
36557
+ '\u2C7E': 'S',
36558
+ '\uA7A8': 'S',
36559
+ '\uA784': 'S',
36560
+ '\u24C9': 'T',
36561
+ '\uFF34': 'T',
36562
+ '\u1E6A': 'T',
36563
+ '\u0164': 'T',
36564
+ '\u1E6C': 'T',
36565
+ '\u021A': 'T',
36566
+ '\u0162': 'T',
36567
+ '\u1E70': 'T',
36568
+ '\u1E6E': 'T',
36569
+ '\u0166': 'T',
36570
+ '\u01AC': 'T',
36571
+ '\u01AE': 'T',
36572
+ '\u023E': 'T',
36573
+ '\uA786': 'T',
36574
+ '\uA728': 'TZ',
36575
+ '\u24CA': 'U',
36576
+ '\uFF35': 'U',
36577
+ '\u00D9': 'U',
36578
+ '\u00DA': 'U',
36579
+ '\u00DB': 'U',
36580
+ '\u0168': 'U',
36581
+ '\u1E78': 'U',
36582
+ '\u016A': 'U',
36583
+ '\u1E7A': 'U',
36584
+ '\u016C': 'U',
36585
+ '\u00DC': 'U',
36586
+ '\u01DB': 'U',
36587
+ '\u01D7': 'U',
36588
+ '\u01D5': 'U',
36589
+ '\u01D9': 'U',
36590
+ '\u1EE6': 'U',
36591
+ '\u016E': 'U',
36592
+ '\u0170': 'U',
36593
+ '\u01D3': 'U',
36594
+ '\u0214': 'U',
36595
+ '\u0216': 'U',
36596
+ '\u01AF': 'U',
36597
+ '\u1EEA': 'U',
36598
+ '\u1EE8': 'U',
36599
+ '\u1EEE': 'U',
36600
+ '\u1EEC': 'U',
36601
+ '\u1EF0': 'U',
36602
+ '\u1EE4': 'U',
36603
+ '\u1E72': 'U',
36604
+ '\u0172': 'U',
36605
+ '\u1E76': 'U',
36606
+ '\u1E74': 'U',
36607
+ '\u0244': 'U',
36608
+ '\u24CB': 'V',
36609
+ '\uFF36': 'V',
36610
+ '\u1E7C': 'V',
36611
+ '\u1E7E': 'V',
36612
+ '\u01B2': 'V',
36613
+ '\uA75E': 'V',
36614
+ '\u0245': 'V',
36615
+ '\uA760': 'VY',
36616
+ '\u24CC': 'W',
36617
+ '\uFF37': 'W',
36618
+ '\u1E80': 'W',
36619
+ '\u1E82': 'W',
36620
+ '\u0174': 'W',
36621
+ '\u1E86': 'W',
36622
+ '\u1E84': 'W',
36623
+ '\u1E88': 'W',
36624
+ '\u2C72': 'W',
36625
+ '\u24CD': 'X',
36626
+ '\uFF38': 'X',
36627
+ '\u1E8A': 'X',
36628
+ '\u1E8C': 'X',
36629
+ '\u24CE': 'Y',
36630
+ '\uFF39': 'Y',
36631
+ '\u1EF2': 'Y',
36632
+ '\u00DD': 'Y',
36633
+ '\u0176': 'Y',
36634
+ '\u1EF8': 'Y',
36635
+ '\u0232': 'Y',
36636
+ '\u1E8E': 'Y',
36637
+ '\u0178': 'Y',
36638
+ '\u1EF6': 'Y',
36639
+ '\u1EF4': 'Y',
36640
+ '\u01B3': 'Y',
36641
+ '\u024E': 'Y',
36642
+ '\u1EFE': 'Y',
36643
+ '\u24CF': 'Z',
36644
+ '\uFF3A': 'Z',
36645
+ '\u0179': 'Z',
36646
+ '\u1E90': 'Z',
36647
+ '\u017B': 'Z',
36648
+ '\u017D': 'Z',
36649
+ '\u1E92': 'Z',
36650
+ '\u1E94': 'Z',
36651
+ '\u01B5': 'Z',
36652
+ '\u0224': 'Z',
36653
+ '\u2C7F': 'Z',
36654
+ '\u2C6B': 'Z',
36655
+ '\uA762': 'Z',
36656
+ '\u24D0': 'a',
36657
+ '\uFF41': 'a',
36658
+ '\u1E9A': 'a',
36659
+ '\u00E0': 'a',
36660
+ '\u00E1': 'a',
36661
+ '\u00E2': 'a',
36662
+ '\u1EA7': 'a',
36663
+ '\u1EA5': 'a',
36664
+ '\u1EAB': 'a',
36665
+ '\u1EA9': 'a',
36666
+ '\u00E3': 'a',
36667
+ '\u0101': 'a',
36668
+ '\u0103': 'a',
36669
+ '\u1EB1': 'a',
36670
+ '\u1EAF': 'a',
36671
+ '\u1EB5': 'a',
36672
+ '\u1EB3': 'a',
36673
+ '\u0227': 'a',
36674
+ '\u01E1': 'a',
36675
+ '\u00E4': 'a',
36676
+ '\u01DF': 'a',
36677
+ '\u1EA3': 'a',
36678
+ '\u00E5': 'a',
36679
+ '\u01FB': 'a',
36680
+ '\u01CE': 'a',
36681
+ '\u0201': 'a',
36682
+ '\u0203': 'a',
36683
+ '\u1EA1': 'a',
36684
+ '\u1EAD': 'a',
36685
+ '\u1EB7': 'a',
36686
+ '\u1E01': 'a',
36687
+ '\u0105': 'a',
36688
+ '\u2C65': 'a',
36689
+ '\u0250': 'a',
36690
+ '\uA733': 'aa',
36691
+ '\u00E6': 'ae',
36692
+ '\u01FD': 'ae',
36693
+ '\u01E3': 'ae',
36694
+ '\uA735': 'ao',
36695
+ '\uA737': 'au',
36696
+ '\uA739': 'av',
36697
+ '\uA73B': 'av',
36698
+ '\uA73D': 'ay',
36699
+ '\u24D1': 'b',
36700
+ '\uFF42': 'b',
36701
+ '\u1E03': 'b',
36702
+ '\u1E05': 'b',
36703
+ '\u1E07': 'b',
36704
+ '\u0180': 'b',
36705
+ '\u0183': 'b',
36706
+ '\u0253': 'b',
36707
+ '\u24D2': 'c',
36708
+ '\uFF43': 'c',
36709
+ '\u0107': 'c',
36710
+ '\u0109': 'c',
36711
+ '\u010B': 'c',
36712
+ '\u010D': 'c',
36713
+ '\u00E7': 'c',
36714
+ '\u1E09': 'c',
36715
+ '\u0188': 'c',
36716
+ '\u023C': 'c',
36717
+ '\uA73F': 'c',
36718
+ '\u2184': 'c',
36719
+ '\u24D3': 'd',
36720
+ '\uFF44': 'd',
36721
+ '\u1E0B': 'd',
36722
+ '\u010F': 'd',
36723
+ '\u1E0D': 'd',
36724
+ '\u1E11': 'd',
36725
+ '\u1E13': 'd',
36726
+ '\u1E0F': 'd',
36727
+ '\u0111': 'd',
36728
+ '\u018C': 'd',
36729
+ '\u0256': 'd',
36730
+ '\u0257': 'd',
36731
+ '\uA77A': 'd',
36732
+ '\u01F3': 'dz',
36733
+ '\u01C6': 'dz',
36734
+ '\u24D4': 'e',
36735
+ '\uFF45': 'e',
36736
+ '\u00E8': 'e',
36737
+ '\u00E9': 'e',
36738
+ '\u00EA': 'e',
36739
+ '\u1EC1': 'e',
36740
+ '\u1EBF': 'e',
36741
+ '\u1EC5': 'e',
36742
+ '\u1EC3': 'e',
36743
+ '\u1EBD': 'e',
36744
+ '\u0113': 'e',
36745
+ '\u1E15': 'e',
36746
+ '\u1E17': 'e',
36747
+ '\u0115': 'e',
36748
+ '\u0117': 'e',
36749
+ '\u00EB': 'e',
36750
+ '\u1EBB': 'e',
36751
+ '\u011B': 'e',
36752
+ '\u0205': 'e',
36753
+ '\u0207': 'e',
36754
+ '\u1EB9': 'e',
36755
+ '\u1EC7': 'e',
36756
+ '\u0229': 'e',
36757
+ '\u1E1D': 'e',
36758
+ '\u0119': 'e',
36759
+ '\u1E19': 'e',
36760
+ '\u1E1B': 'e',
36761
+ '\u0247': 'e',
36762
+ '\u025B': 'e',
36763
+ '\u01DD': 'e',
36764
+ '\u24D5': 'f',
36765
+ '\uFF46': 'f',
36766
+ '\u1E1F': 'f',
36767
+ '\u0192': 'f',
36768
+ '\uA77C': 'f',
36769
+ '\u24D6': 'g',
36770
+ '\uFF47': 'g',
36771
+ '\u01F5': 'g',
36772
+ '\u011D': 'g',
36773
+ '\u1E21': 'g',
36774
+ '\u011F': 'g',
36775
+ '\u0121': 'g',
36776
+ '\u01E7': 'g',
36777
+ '\u0123': 'g',
36778
+ '\u01E5': 'g',
36779
+ '\u0260': 'g',
36780
+ '\uA7A1': 'g',
36781
+ '\u1D79': 'g',
36782
+ '\uA77F': 'g',
36783
+ '\u24D7': 'h',
36784
+ '\uFF48': 'h',
36785
+ '\u0125': 'h',
36786
+ '\u1E23': 'h',
36787
+ '\u1E27': 'h',
36788
+ '\u021F': 'h',
36789
+ '\u1E25': 'h',
36790
+ '\u1E29': 'h',
36791
+ '\u1E2B': 'h',
36792
+ '\u1E96': 'h',
36793
+ '\u0127': 'h',
36794
+ '\u2C68': 'h',
36795
+ '\u2C76': 'h',
36796
+ '\u0265': 'h',
36797
+ '\u0195': 'hv',
36798
+ '\u24D8': 'i',
36799
+ '\uFF49': 'i',
36800
+ '\u00EC': 'i',
36801
+ '\u00ED': 'i',
36802
+ '\u00EE': 'i',
36803
+ '\u0129': 'i',
36804
+ '\u012B': 'i',
36805
+ '\u012D': 'i',
36806
+ '\u00EF': 'i',
36807
+ '\u1E2F': 'i',
36808
+ '\u1EC9': 'i',
36809
+ '\u01D0': 'i',
36810
+ '\u0209': 'i',
36811
+ '\u020B': 'i',
36812
+ '\u1ECB': 'i',
36813
+ '\u012F': 'i',
36814
+ '\u1E2D': 'i',
36815
+ '\u0268': 'i',
36816
+ '\u0131': 'i',
36817
+ '\u24D9': 'j',
36818
+ '\uFF4A': 'j',
36819
+ '\u0135': 'j',
36820
+ '\u01F0': 'j',
36821
+ '\u0249': 'j',
36822
+ '\u24DA': 'k',
36823
+ '\uFF4B': 'k',
36824
+ '\u1E31': 'k',
36825
+ '\u01E9': 'k',
36826
+ '\u1E33': 'k',
36827
+ '\u0137': 'k',
36828
+ '\u1E35': 'k',
36829
+ '\u0199': 'k',
36830
+ '\u2C6A': 'k',
36831
+ '\uA741': 'k',
36832
+ '\uA743': 'k',
36833
+ '\uA745': 'k',
36834
+ '\uA7A3': 'k',
36835
+ '\u24DB': 'l',
36836
+ '\uFF4C': 'l',
36837
+ '\u0140': 'l',
36838
+ '\u013A': 'l',
36839
+ '\u013E': 'l',
36840
+ '\u1E37': 'l',
36841
+ '\u1E39': 'l',
36842
+ '\u013C': 'l',
36843
+ '\u1E3D': 'l',
36844
+ '\u1E3B': 'l',
36845
+ '\u017F': 'l',
36846
+ '\u0142': 'l',
36847
+ '\u019A': 'l',
36848
+ '\u026B': 'l',
36849
+ '\u2C61': 'l',
36850
+ '\uA749': 'l',
36851
+ '\uA781': 'l',
36852
+ '\uA747': 'l',
36853
+ '\u01C9': 'lj',
36854
+ '\u24DC': 'm',
36855
+ '\uFF4D': 'm',
36856
+ '\u1E3F': 'm',
36857
+ '\u1E41': 'm',
36858
+ '\u1E43': 'm',
36859
+ '\u0271': 'm',
36860
+ '\u026F': 'm',
36861
+ '\u24DD': 'n',
36862
+ '\uFF4E': 'n',
36863
+ '\u01F9': 'n',
36864
+ '\u0144': 'n',
36865
+ '\u00F1': 'n',
36866
+ '\u1E45': 'n',
36867
+ '\u0148': 'n',
36868
+ '\u1E47': 'n',
36869
+ '\u0146': 'n',
36870
+ '\u1E4B': 'n',
36871
+ '\u1E49': 'n',
36872
+ '\u019E': 'n',
36873
+ '\u0272': 'n',
36874
+ '\u0149': 'n',
36875
+ '\uA791': 'n',
36876
+ '\uA7A5': 'n',
36877
+ '\u01CC': 'nj',
36878
+ '\u24DE': 'o',
36879
+ '\uFF4F': 'o',
36880
+ '\u00F2': 'o',
36881
+ '\u00F3': 'o',
36882
+ '\u00F4': 'o',
36883
+ '\u1ED3': 'o',
36884
+ '\u1ED1': 'o',
36885
+ '\u1ED7': 'o',
36886
+ '\u1ED5': 'o',
36887
+ '\u00F5': 'o',
36888
+ '\u1E4D': 'o',
36889
+ '\u022D': 'o',
36890
+ '\u1E4F': 'o',
36891
+ '\u014D': 'o',
36892
+ '\u1E51': 'o',
36893
+ '\u1E53': 'o',
36894
+ '\u014F': 'o',
36895
+ '\u022F': 'o',
36896
+ '\u0231': 'o',
36897
+ '\u00F6': 'o',
36898
+ '\u022B': 'o',
36899
+ '\u1ECF': 'o',
36900
+ '\u0151': 'o',
36901
+ '\u01D2': 'o',
36902
+ '\u020D': 'o',
36903
+ '\u020F': 'o',
36904
+ '\u01A1': 'o',
36905
+ '\u1EDD': 'o',
36906
+ '\u1EDB': 'o',
36907
+ '\u1EE1': 'o',
36908
+ '\u1EDF': 'o',
36909
+ '\u1EE3': 'o',
36910
+ '\u1ECD': 'o',
36911
+ '\u1ED9': 'o',
36912
+ '\u01EB': 'o',
36913
+ '\u01ED': 'o',
36914
+ '\u00F8': 'o',
36915
+ '\u01FF': 'o',
36916
+ '\u0254': 'o',
36917
+ '\uA74B': 'o',
36918
+ '\uA74D': 'o',
36919
+ '\u0275': 'o',
36920
+ '\u01A3': 'oi',
36921
+ '\u0223': 'ou',
36922
+ '\uA74F': 'oo',
36923
+ '\u24DF': 'p',
36924
+ '\uFF50': 'p',
36925
+ '\u1E55': 'p',
36926
+ '\u1E57': 'p',
36927
+ '\u01A5': 'p',
36928
+ '\u1D7D': 'p',
36929
+ '\uA751': 'p',
36930
+ '\uA753': 'p',
36931
+ '\uA755': 'p',
36932
+ '\u24E0': 'q',
36933
+ '\uFF51': 'q',
36934
+ '\u024B': 'q',
36935
+ '\uA757': 'q',
36936
+ '\uA759': 'q',
36937
+ '\u24E1': 'r',
36938
+ '\uFF52': 'r',
36939
+ '\u0155': 'r',
36940
+ '\u1E59': 'r',
36941
+ '\u0159': 'r',
36942
+ '\u0211': 'r',
36943
+ '\u0213': 'r',
36944
+ '\u1E5B': 'r',
36945
+ '\u1E5D': 'r',
36946
+ '\u0157': 'r',
36947
+ '\u1E5F': 'r',
36948
+ '\u024D': 'r',
36949
+ '\u027D': 'r',
36950
+ '\uA75B': 'r',
36951
+ '\uA7A7': 'r',
36952
+ '\uA783': 'r',
36953
+ '\u24E2': 's',
36954
+ '\uFF53': 's',
36955
+ '\u00DF': 's',
36956
+ '\u015B': 's',
36957
+ '\u1E65': 's',
36958
+ '\u015D': 's',
36959
+ '\u1E61': 's',
36960
+ '\u0161': 's',
36961
+ '\u1E67': 's',
36962
+ '\u1E63': 's',
36963
+ '\u1E69': 's',
36964
+ '\u0219': 's',
36965
+ '\u015F': 's',
36966
+ '\u023F': 's',
36967
+ '\uA7A9': 's',
36968
+ '\uA785': 's',
36969
+ '\u1E9B': 's',
36970
+ '\u24E3': 't',
36971
+ '\uFF54': 't',
36972
+ '\u1E6B': 't',
36973
+ '\u1E97': 't',
36974
+ '\u0165': 't',
36975
+ '\u1E6D': 't',
36976
+ '\u021B': 't',
36977
+ '\u0163': 't',
36978
+ '\u1E71': 't',
36979
+ '\u1E6F': 't',
36980
+ '\u0167': 't',
36981
+ '\u01AD': 't',
36982
+ '\u0288': 't',
36983
+ '\u2C66': 't',
36984
+ '\uA787': 't',
36985
+ '\uA729': 'tz',
36986
+ '\u24E4': 'u',
36987
+ '\uFF55': 'u',
36988
+ '\u00F9': 'u',
36989
+ '\u00FA': 'u',
36990
+ '\u00FB': 'u',
36991
+ '\u0169': 'u',
36992
+ '\u1E79': 'u',
36993
+ '\u016B': 'u',
36994
+ '\u1E7B': 'u',
36995
+ '\u016D': 'u',
36996
+ '\u00FC': 'u',
36997
+ '\u01DC': 'u',
36998
+ '\u01D8': 'u',
36999
+ '\u01D6': 'u',
37000
+ '\u01DA': 'u',
37001
+ '\u1EE7': 'u',
37002
+ '\u016F': 'u',
37003
+ '\u0171': 'u',
37004
+ '\u01D4': 'u',
37005
+ '\u0215': 'u',
37006
+ '\u0217': 'u',
37007
+ '\u01B0': 'u',
37008
+ '\u1EEB': 'u',
37009
+ '\u1EE9': 'u',
37010
+ '\u1EEF': 'u',
37011
+ '\u1EED': 'u',
37012
+ '\u1EF1': 'u',
37013
+ '\u1EE5': 'u',
37014
+ '\u1E73': 'u',
37015
+ '\u0173': 'u',
37016
+ '\u1E77': 'u',
37017
+ '\u1E75': 'u',
37018
+ '\u0289': 'u',
37019
+ '\u24E5': 'v',
37020
+ '\uFF56': 'v',
37021
+ '\u1E7D': 'v',
37022
+ '\u1E7F': 'v',
37023
+ '\u028B': 'v',
37024
+ '\uA75F': 'v',
37025
+ '\u028C': 'v',
37026
+ '\uA761': 'vy',
37027
+ '\u24E6': 'w',
37028
+ '\uFF57': 'w',
37029
+ '\u1E81': 'w',
37030
+ '\u1E83': 'w',
37031
+ '\u0175': 'w',
37032
+ '\u1E87': 'w',
37033
+ '\u1E85': 'w',
37034
+ '\u1E98': 'w',
37035
+ '\u1E89': 'w',
37036
+ '\u2C73': 'w',
37037
+ '\u24E7': 'x',
37038
+ '\uFF58': 'x',
37039
+ '\u1E8B': 'x',
37040
+ '\u1E8D': 'x',
37041
+ '\u24E8': 'y',
37042
+ '\uFF59': 'y',
37043
+ '\u1EF3': 'y',
37044
+ '\u00FD': 'y',
37045
+ '\u0177': 'y',
37046
+ '\u1EF9': 'y',
37047
+ '\u0233': 'y',
37048
+ '\u1E8F': 'y',
37049
+ '\u00FF': 'y',
37050
+ '\u1EF7': 'y',
37051
+ '\u1E99': 'y',
37052
+ '\u1EF5': 'y',
37053
+ '\u01B4': 'y',
37054
+ '\u024F': 'y',
37055
+ '\u1EFF': 'y',
37056
+ '\u24E9': 'z',
37057
+ '\uFF5A': 'z',
37058
+ '\u017A': 'z',
37059
+ '\u1E91': 'z',
37060
+ '\u017C': 'z',
37061
+ '\u017E': 'z',
37062
+ '\u1E93': 'z',
37063
+ '\u1E95': 'z',
37064
+ '\u01B6': 'z',
37065
+ '\u0225': 'z',
37066
+ '\u0240': 'z',
37067
+ '\u2C6C': 'z',
37068
+ '\uA763': 'z',
37069
+ '\u0386': '\u0391',
37070
+ '\u0388': '\u0395',
37071
+ '\u0389': '\u0397',
37072
+ '\u038A': '\u0399',
37073
+ '\u03AA': '\u0399',
37074
+ '\u038C': '\u039F',
37075
+ '\u038E': '\u03A5',
37076
+ '\u03AB': '\u03A5',
37077
+ '\u038F': '\u03A9',
37078
+ '\u03AC': '\u03B1',
37079
+ '\u03AD': '\u03B5',
37080
+ '\u03AE': '\u03B7',
37081
+ '\u03AF': '\u03B9',
37082
+ '\u03CA': '\u03B9',
37083
+ '\u0390': '\u03B9',
37084
+ '\u03CC': '\u03BF',
37085
+ '\u03CD': '\u03C5',
37086
+ '\u03CB': '\u03C5',
37087
+ '\u03B0': '\u03C5',
37088
+ '\u03C9': '\u03C9',
37089
+ '\u03C2': '\u03C3'
37090
+ };
37091
+
37092
+ return diacritics;
37093
+ });
37094
+
37095
+ S2.define('select2/data/base',[
37096
+ '../utils'
37097
+ ], function (Utils) {
37098
+ function BaseAdapter ($element, options) {
37099
+ BaseAdapter.__super__.constructor.call(this);
37100
+ }
37101
+
37102
+ Utils.Extend(BaseAdapter, Utils.Observable);
37103
+
37104
+ BaseAdapter.prototype.current = function (callback) {
37105
+ throw new Error('The `current` method must be defined in child classes.');
37106
+ };
37107
+
37108
+ BaseAdapter.prototype.query = function (params, callback) {
37109
+ throw new Error('The `query` method must be defined in child classes.');
37110
+ };
37111
+
37112
+ BaseAdapter.prototype.bind = function (container, $container) {
37113
+ // Can be implemented in subclasses
37114
+ };
37115
+
37116
+ BaseAdapter.prototype.destroy = function () {
37117
+ // Can be implemented in subclasses
37118
+ };
37119
+
37120
+ BaseAdapter.prototype.generateResultId = function (container, data) {
37121
+ var id = container.id + '-result-';
37122
+
37123
+ id += Utils.generateChars(4);
37124
+
37125
+ if (data.id != null) {
37126
+ id += '-' + data.id.toString();
37127
+ } else {
37128
+ id += '-' + Utils.generateChars(4);
37129
+ }
37130
+ return id;
37131
+ };
37132
+
37133
+ return BaseAdapter;
37134
+ });
37135
+
37136
+ S2.define('select2/data/select',[
37137
+ './base',
37138
+ '../utils',
37139
+ 'jquery'
37140
+ ], function (BaseAdapter, Utils, $) {
37141
+ function SelectAdapter ($element, options) {
37142
+ this.$element = $element;
37143
+ this.options = options;
37144
+
37145
+ SelectAdapter.__super__.constructor.call(this);
37146
+ }
37147
+
37148
+ Utils.Extend(SelectAdapter, BaseAdapter);
37149
+
37150
+ SelectAdapter.prototype.current = function (callback) {
37151
+ var data = [];
37152
+ var self = this;
37153
+
37154
+ this.$element.find(':selected').each(function () {
37155
+ var $option = $(this);
37156
+
37157
+ var option = self.item($option);
37158
+
37159
+ data.push(option);
37160
+ });
37161
+
37162
+ callback(data);
37163
+ };
37164
+
37165
+ SelectAdapter.prototype.select = function (data) {
37166
+ var self = this;
37167
+
37168
+ data.selected = true;
37169
+
37170
+ // If data.element is a DOM node, use it instead
37171
+ if ($(data.element).is('option')) {
37172
+ data.element.selected = true;
37173
+
37174
+ this.$element.trigger('change');
37175
+
37176
+ return;
37177
+ }
37178
+
37179
+ if (this.$element.prop('multiple')) {
37180
+ this.current(function (currentData) {
37181
+ var val = [];
37182
+
37183
+ data = [data];
37184
+ data.push.apply(data, currentData);
37185
+
37186
+ for (var d = 0; d < data.length; d++) {
37187
+ var id = data[d].id;
37188
+
37189
+ if ($.inArray(id, val) === -1) {
37190
+ val.push(id);
37191
+ }
37192
+ }
37193
+
37194
+ self.$element.val(val);
37195
+ self.$element.trigger('change');
37196
+ });
37197
+ } else {
37198
+ var val = data.id;
37199
+
37200
+ this.$element.val(val);
37201
+ this.$element.trigger('change');
37202
+ }
37203
+ };
37204
+
37205
+ SelectAdapter.prototype.unselect = function (data) {
37206
+ var self = this;
37207
+
37208
+ if (!this.$element.prop('multiple')) {
37209
+ return;
37210
+ }
37211
+
37212
+ data.selected = false;
37213
+
37214
+ if ($(data.element).is('option')) {
37215
+ data.element.selected = false;
37216
+
37217
+ this.$element.trigger('change');
37218
+
37219
+ return;
37220
+ }
37221
+
37222
+ this.current(function (currentData) {
37223
+ var val = [];
37224
+
37225
+ for (var d = 0; d < currentData.length; d++) {
37226
+ var id = currentData[d].id;
37227
+
37228
+ if (id !== data.id && $.inArray(id, val) === -1) {
37229
+ val.push(id);
37230
+ }
37231
+ }
37232
+
37233
+ self.$element.val(val);
37234
+
37235
+ self.$element.trigger('change');
37236
+ });
37237
+ };
37238
+
37239
+ SelectAdapter.prototype.bind = function (container, $container) {
37240
+ var self = this;
37241
+
37242
+ this.container = container;
37243
+
37244
+ container.on('select', function (params) {
37245
+ self.select(params.data);
37246
+ });
37247
+
37248
+ container.on('unselect', function (params) {
37249
+ self.unselect(params.data);
37250
+ });
37251
+ };
37252
+
37253
+ SelectAdapter.prototype.destroy = function () {
37254
+ // Remove anything added to child elements
37255
+ this.$element.find('*').each(function () {
37256
+ // Remove any custom data set by Select2
37257
+ $.removeData(this, 'data');
37258
+ });
37259
+ };
37260
+
37261
+ SelectAdapter.prototype.query = function (params, callback) {
37262
+ var data = [];
37263
+ var self = this;
37264
+
37265
+ var $options = this.$element.children();
37266
+
37267
+ $options.each(function () {
37268
+ var $option = $(this);
37269
+
37270
+ if (!$option.is('option') && !$option.is('optgroup')) {
37271
+ return;
37272
+ }
37273
+
37274
+ var option = self.item($option);
37275
+
37276
+ var matches = self.matches(params, option);
37277
+
37278
+ if (matches !== null) {
37279
+ data.push(matches);
37280
+ }
37281
+ });
37282
+
37283
+ callback({
37284
+ results: data
37285
+ });
37286
+ };
37287
+
37288
+ SelectAdapter.prototype.addOptions = function ($options) {
37289
+ Utils.appendMany(this.$element, $options);
37290
+ };
37291
+
37292
+ SelectAdapter.prototype.option = function (data) {
37293
+ var option;
37294
+
37295
+ if (data.children) {
37296
+ option = document.createElement('optgroup');
37297
+ option.label = data.text;
37298
+ } else {
37299
+ option = document.createElement('option');
37300
+
37301
+ if (option.textContent !== undefined) {
37302
+ option.textContent = data.text;
37303
+ } else {
37304
+ option.innerText = data.text;
37305
+ }
37306
+ }
37307
+
37308
+ if (data.id !== undefined) {
37309
+ option.value = data.id;
37310
+ }
37311
+
37312
+ if (data.disabled) {
37313
+ option.disabled = true;
37314
+ }
37315
+
37316
+ if (data.selected) {
37317
+ option.selected = true;
37318
+ }
37319
+
37320
+ if (data.title) {
37321
+ option.title = data.title;
37322
+ }
37323
+
37324
+ var $option = $(option);
37325
+
37326
+ var normalizedData = this._normalizeItem(data);
37327
+ normalizedData.element = option;
37328
+
37329
+ // Override the option's data with the combined data
37330
+ $.data(option, 'data', normalizedData);
37331
+
37332
+ return $option;
37333
+ };
37334
+
37335
+ SelectAdapter.prototype.item = function ($option) {
37336
+ var data = {};
37337
+
37338
+ data = $.data($option[0], 'data');
37339
+
37340
+ if (data != null) {
37341
+ return data;
37342
+ }
37343
+
37344
+ if ($option.is('option')) {
37345
+ data = {
37346
+ id: $option.val(),
37347
+ text: $option.text(),
37348
+ disabled: $option.prop('disabled'),
37349
+ selected: $option.prop('selected'),
37350
+ title: $option.prop('title')
37351
+ };
37352
+ } else if ($option.is('optgroup')) {
37353
+ data = {
37354
+ text: $option.prop('label'),
37355
+ children: [],
37356
+ title: $option.prop('title')
37357
+ };
37358
+
37359
+ var $children = $option.children('option');
37360
+ var children = [];
37361
+
37362
+ for (var c = 0; c < $children.length; c++) {
37363
+ var $child = $($children[c]);
37364
+
37365
+ var child = this.item($child);
37366
+
37367
+ children.push(child);
37368
+ }
37369
+
37370
+ data.children = children;
37371
+ }
37372
+
37373
+ data = this._normalizeItem(data);
37374
+ data.element = $option[0];
37375
+
37376
+ $.data($option[0], 'data', data);
37377
+
37378
+ return data;
37379
+ };
37380
+
37381
+ SelectAdapter.prototype._normalizeItem = function (item) {
37382
+ if (!$.isPlainObject(item)) {
37383
+ item = {
37384
+ id: item,
37385
+ text: item
37386
+ };
37387
+ }
37388
+
37389
+ item = $.extend({}, {
37390
+ text: ''
37391
+ }, item);
37392
+
37393
+ var defaults = {
37394
+ selected: false,
37395
+ disabled: false
37396
+ };
37397
+
37398
+ if (item.id != null) {
37399
+ item.id = item.id.toString();
37400
+ }
37401
+
37402
+ if (item.text != null) {
37403
+ item.text = item.text.toString();
37404
+ }
37405
+
37406
+ if (item._resultId == null && item.id && this.container != null) {
37407
+ item._resultId = this.generateResultId(this.container, item);
37408
+ }
37409
+
37410
+ return $.extend({}, defaults, item);
37411
+ };
37412
+
37413
+ SelectAdapter.prototype.matches = function (params, data) {
37414
+ var matcher = this.options.get('matcher');
37415
+
37416
+ return matcher(params, data);
37417
+ };
37418
+
37419
+ return SelectAdapter;
37420
+ });
37421
+
37422
+ S2.define('select2/data/array',[
37423
+ './select',
37424
+ '../utils',
37425
+ 'jquery'
37426
+ ], function (SelectAdapter, Utils, $) {
37427
+ function ArrayAdapter ($element, options) {
37428
+ var data = options.get('data') || [];
37429
+
37430
+ ArrayAdapter.__super__.constructor.call(this, $element, options);
37431
+
37432
+ this.addOptions(this.convertToOptions(data));
37433
+ }
37434
+
37435
+ Utils.Extend(ArrayAdapter, SelectAdapter);
37436
+
37437
+ ArrayAdapter.prototype.select = function (data) {
37438
+ var $option = this.$element.find('option').filter(function (i, elm) {
37439
+ return elm.value == data.id.toString();
37440
+ });
37441
+
37442
+ if ($option.length === 0) {
37443
+ $option = this.option(data);
37444
+
37445
+ this.addOptions($option);
37446
+ }
37447
+
37448
+ ArrayAdapter.__super__.select.call(this, data);
37449
+ };
37450
+
37451
+ ArrayAdapter.prototype.convertToOptions = function (data) {
37452
+ var self = this;
37453
+
37454
+ var $existing = this.$element.find('option');
37455
+ var existingIds = $existing.map(function () {
37456
+ return self.item($(this)).id;
37457
+ }).get();
37458
+
37459
+ var $options = [];
37460
+
37461
+ // Filter out all items except for the one passed in the argument
37462
+ function onlyItem (item) {
37463
+ return function () {
37464
+ return $(this).val() == item.id;
37465
+ };
37466
+ }
37467
+
37468
+ for (var d = 0; d < data.length; d++) {
37469
+ var item = this._normalizeItem(data[d]);
37470
+
37471
+ // Skip items which were pre-loaded, only merge the data
37472
+ if ($.inArray(item.id, existingIds) >= 0) {
37473
+ var $existingOption = $existing.filter(onlyItem(item));
37474
+
37475
+ var existingData = this.item($existingOption);
37476
+ var newData = $.extend(true, {}, item, existingData);
37477
+
37478
+ var $newOption = this.option(newData);
37479
+
37480
+ $existingOption.replaceWith($newOption);
37481
+
37482
+ continue;
37483
+ }
37484
+
37485
+ var $option = this.option(item);
37486
+
37487
+ if (item.children) {
37488
+ var $children = this.convertToOptions(item.children);
37489
+
37490
+ Utils.appendMany($option, $children);
37491
+ }
37492
+
37493
+ $options.push($option);
37494
+ }
37495
+
37496
+ return $options;
37497
+ };
37498
+
37499
+ return ArrayAdapter;
37500
+ });
37501
+
37502
+ S2.define('select2/data/ajax',[
37503
+ './array',
37504
+ '../utils',
37505
+ 'jquery'
37506
+ ], function (ArrayAdapter, Utils, $) {
37507
+ function AjaxAdapter ($element, options) {
37508
+ this.ajaxOptions = this._applyDefaults(options.get('ajax'));
37509
+
37510
+ if (this.ajaxOptions.processResults != null) {
37511
+ this.processResults = this.ajaxOptions.processResults;
37512
+ }
37513
+
37514
+ AjaxAdapter.__super__.constructor.call(this, $element, options);
37515
+ }
37516
+
37517
+ Utils.Extend(AjaxAdapter, ArrayAdapter);
37518
+
37519
+ AjaxAdapter.prototype._applyDefaults = function (options) {
37520
+ var defaults = {
37521
+ data: function (params) {
37522
+ return $.extend({}, params, {
37523
+ q: params.term
37524
+ });
37525
+ },
37526
+ transport: function (params, success, failure) {
37527
+ var $request = $.ajax(params);
37528
+
37529
+ $request.then(success);
37530
+ $request.fail(failure);
37531
+
37532
+ return $request;
37533
+ }
37534
+ };
37535
+
37536
+ return $.extend({}, defaults, options, true);
37537
+ };
37538
+
37539
+ AjaxAdapter.prototype.processResults = function (results) {
37540
+ return results;
37541
+ };
37542
+
37543
+ AjaxAdapter.prototype.query = function (params, callback) {
37544
+ var matches = [];
37545
+ var self = this;
37546
+
37547
+ if (this._request != null) {
37548
+ // JSONP requests cannot always be aborted
37549
+ if ($.isFunction(this._request.abort)) {
37550
+ this._request.abort();
37551
+ }
37552
+
37553
+ this._request = null;
37554
+ }
37555
+
37556
+ var options = $.extend({
37557
+ type: 'GET'
37558
+ }, this.ajaxOptions);
37559
+
37560
+ if (typeof options.url === 'function') {
37561
+ options.url = options.url.call(this.$element, params);
37562
+ }
37563
+
37564
+ if (typeof options.data === 'function') {
37565
+ options.data = options.data.call(this.$element, params);
37566
+ }
37567
+
37568
+ function request () {
37569
+ var $request = options.transport(options, function (data) {
37570
+ var results = self.processResults(data, params);
37571
+
37572
+ if (self.options.get('debug') && window.console && console.error) {
37573
+ // Check to make sure that the response included a `results` key.
37574
+ if (!results || !results.results || !$.isArray(results.results)) {
37575
+ console.error(
37576
+ 'Select2: The AJAX results did not return an array in the ' +
37577
+ '`results` key of the response.'
37578
+ );
37579
+ }
37580
+ }
37581
+
37582
+ callback(results);
37583
+ }, function () {
37584
+ // Attempt to detect if a request was aborted
37585
+ // Only works if the transport exposes a status property
37586
+ if ($request.status && $request.status === '0') {
37587
+ return;
37588
+ }
37589
+
37590
+ self.trigger('results:message', {
37591
+ message: 'errorLoading'
37592
+ });
37593
+ });
37594
+
37595
+ self._request = $request;
37596
+ }
37597
+
37598
+ if (this.ajaxOptions.delay && params.term != null) {
37599
+ if (this._queryTimeout) {
37600
+ window.clearTimeout(this._queryTimeout);
37601
+ }
37602
+
37603
+ this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
37604
+ } else {
37605
+ request();
37606
+ }
37607
+ };
37608
+
37609
+ return AjaxAdapter;
37610
+ });
37611
+
37612
+ S2.define('select2/data/tags',[
37613
+ 'jquery'
37614
+ ], function ($) {
37615
+ function Tags (decorated, $element, options) {
37616
+ var tags = options.get('tags');
37617
+
37618
+ var createTag = options.get('createTag');
37619
+
37620
+ if (createTag !== undefined) {
37621
+ this.createTag = createTag;
37622
+ }
37623
+
37624
+ var insertTag = options.get('insertTag');
37625
+
37626
+ if (insertTag !== undefined) {
37627
+ this.insertTag = insertTag;
37628
+ }
37629
+
37630
+ decorated.call(this, $element, options);
37631
+
37632
+ if ($.isArray(tags)) {
37633
+ for (var t = 0; t < tags.length; t++) {
37634
+ var tag = tags[t];
37635
+ var item = this._normalizeItem(tag);
37636
+
37637
+ var $option = this.option(item);
37638
+
37639
+ this.$element.append($option);
37640
+ }
37641
+ }
37642
+ }
37643
+
37644
+ Tags.prototype.query = function (decorated, params, callback) {
37645
+ var self = this;
37646
+
37647
+ this._removeOldTags();
37648
+
37649
+ if (params.term == null || params.page != null) {
37650
+ decorated.call(this, params, callback);
37651
+ return;
37652
+ }
37653
+
37654
+ function wrapper (obj, child) {
37655
+ var data = obj.results;
37656
+
37657
+ for (var i = 0; i < data.length; i++) {
37658
+ var option = data[i];
37659
+
37660
+ var checkChildren = (
37661
+ option.children != null &&
37662
+ !wrapper({
37663
+ results: option.children
37664
+ }, true)
37665
+ );
37666
+
37667
+ var optionText = (option.text || '').toUpperCase();
37668
+ var paramsTerm = (params.term || '').toUpperCase();
37669
+
37670
+ var checkText = optionText === paramsTerm;
37671
+
37672
+ if (checkText || checkChildren) {
37673
+ if (child) {
37674
+ return false;
37675
+ }
37676
+
37677
+ obj.data = data;
37678
+ callback(obj);
37679
+
37680
+ return;
37681
+ }
37682
+ }
37683
+
37684
+ if (child) {
37685
+ return true;
37686
+ }
37687
+
37688
+ var tag = self.createTag(params);
37689
+
37690
+ if (tag != null) {
37691
+ var $option = self.option(tag);
37692
+ $option.attr('data-select2-tag', true);
37693
+
37694
+ self.addOptions([$option]);
37695
+
37696
+ self.insertTag(data, tag);
37697
+ }
37698
+
37699
+ obj.results = data;
37700
+
37701
+ callback(obj);
37702
+ }
37703
+
37704
+ decorated.call(this, params, wrapper);
37705
+ };
37706
+
37707
+ Tags.prototype.createTag = function (decorated, params) {
37708
+ var term = $.trim(params.term);
37709
+
37710
+ if (term === '') {
37711
+ return null;
37712
+ }
37713
+
37714
+ return {
37715
+ id: term,
37716
+ text: term
37717
+ };
37718
+ };
37719
+
37720
+ Tags.prototype.insertTag = function (_, data, tag) {
37721
+ data.unshift(tag);
37722
+ };
37723
+
37724
+ Tags.prototype._removeOldTags = function (_) {
37725
+ var tag = this._lastTag;
37726
+
37727
+ var $options = this.$element.find('option[data-select2-tag]');
37728
+
37729
+ $options.each(function () {
37730
+ if (this.selected) {
37731
+ return;
37732
+ }
37733
+
37734
+ $(this).remove();
37735
+ });
37736
+ };
37737
+
37738
+ return Tags;
37739
+ });
37740
+
37741
+ S2.define('select2/data/tokenizer',[
37742
+ 'jquery'
37743
+ ], function ($) {
37744
+ function Tokenizer (decorated, $element, options) {
37745
+ var tokenizer = options.get('tokenizer');
37746
+
37747
+ if (tokenizer !== undefined) {
37748
+ this.tokenizer = tokenizer;
37749
+ }
37750
+
37751
+ decorated.call(this, $element, options);
37752
+ }
37753
+
37754
+ Tokenizer.prototype.bind = function (decorated, container, $container) {
37755
+ decorated.call(this, container, $container);
37756
+
37757
+ this.$search = container.dropdown.$search || container.selection.$search ||
37758
+ $container.find('.select2-search__field');
37759
+ };
37760
+
37761
+ Tokenizer.prototype.query = function (decorated, params, callback) {
37762
+ var self = this;
37763
+
37764
+ function createAndSelect (data) {
37765
+ // Normalize the data object so we can use it for checks
37766
+ var item = self._normalizeItem(data);
37767
+
37768
+ // Check if the data object already exists as a tag
37769
+ // Select it if it doesn't
37770
+ var $existingOptions = self.$element.find('option').filter(function () {
37771
+ return $(this).val() === item.id;
37772
+ });
37773
+
37774
+ // If an existing option wasn't found for it, create the option
37775
+ if (!$existingOptions.length) {
37776
+ var $option = self.option(item);
37777
+ $option.attr('data-select2-tag', true);
37778
+
37779
+ self._removeOldTags();
37780
+ self.addOptions([$option]);
37781
+ }
37782
+
37783
+ // Select the item, now that we know there is an option for it
37784
+ select(item);
37785
+ }
37786
+
37787
+ function select (data) {
37788
+ self.trigger('select', {
37789
+ data: data
37790
+ });
37791
+ }
37792
+
37793
+ params.term = params.term || '';
37794
+
37795
+ var tokenData = this.tokenizer(params, this.options, createAndSelect);
37796
+
37797
+ if (tokenData.term !== params.term) {
37798
+ // Replace the search term if we have the search box
37799
+ if (this.$search.length) {
37800
+ this.$search.val(tokenData.term);
37801
+ this.$search.focus();
37802
+ }
37803
+
37804
+ params.term = tokenData.term;
37805
+ }
37806
+
37807
+ decorated.call(this, params, callback);
37808
+ };
37809
+
37810
+ Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
37811
+ var separators = options.get('tokenSeparators') || [];
37812
+ var term = params.term;
37813
+ var i = 0;
37814
+
37815
+ var createTag = this.createTag || function (params) {
37816
+ return {
37817
+ id: params.term,
37818
+ text: params.term
37819
+ };
37820
+ };
37821
+
37822
+ while (i < term.length) {
37823
+ var termChar = term[i];
37824
+
37825
+ if ($.inArray(termChar, separators) === -1) {
37826
+ i++;
37827
+
37828
+ continue;
37829
+ }
37830
+
37831
+ var part = term.substr(0, i);
37832
+ var partParams = $.extend({}, params, {
37833
+ term: part
37834
+ });
37835
+
37836
+ var data = createTag(partParams);
37837
+
37838
+ if (data == null) {
37839
+ i++;
37840
+ continue;
37841
+ }
37842
+
37843
+ callback(data);
37844
+
37845
+ // Reset the term to not include the tokenized portion
37846
+ term = term.substr(i + 1) || '';
37847
+ i = 0;
37848
+ }
37849
+
37850
+ return {
37851
+ term: term
37852
+ };
37853
+ };
37854
+
37855
+ return Tokenizer;
37856
+ });
37857
+
37858
+ S2.define('select2/data/minimumInputLength',[
37859
+
37860
+ ], function () {
37861
+ function MinimumInputLength (decorated, $e, options) {
37862
+ this.minimumInputLength = options.get('minimumInputLength');
37863
+
37864
+ decorated.call(this, $e, options);
37865
+ }
37866
+
37867
+ MinimumInputLength.prototype.query = function (decorated, params, callback) {
37868
+ params.term = params.term || '';
37869
+
37870
+ if (params.term.length < this.minimumInputLength) {
37871
+ this.trigger('results:message', {
37872
+ message: 'inputTooShort',
37873
+ args: {
37874
+ minimum: this.minimumInputLength,
37875
+ input: params.term,
37876
+ params: params
37877
+ }
37878
+ });
37879
+
37880
+ return;
37881
+ }
37882
+
37883
+ decorated.call(this, params, callback);
37884
+ };
37885
+
37886
+ return MinimumInputLength;
37887
+ });
37888
+
37889
+ S2.define('select2/data/maximumInputLength',[
37890
+
37891
+ ], function () {
37892
+ function MaximumInputLength (decorated, $e, options) {
37893
+ this.maximumInputLength = options.get('maximumInputLength');
37894
+
37895
+ decorated.call(this, $e, options);
37896
+ }
37897
+
37898
+ MaximumInputLength.prototype.query = function (decorated, params, callback) {
37899
+ params.term = params.term || '';
37900
+
37901
+ if (this.maximumInputLength > 0 &&
37902
+ params.term.length > this.maximumInputLength) {
37903
+ this.trigger('results:message', {
37904
+ message: 'inputTooLong',
37905
+ args: {
37906
+ maximum: this.maximumInputLength,
37907
+ input: params.term,
37908
+ params: params
37909
+ }
37910
+ });
37911
+
37912
+ return;
37913
+ }
37914
+
37915
+ decorated.call(this, params, callback);
37916
+ };
37917
+
37918
+ return MaximumInputLength;
37919
+ });
37920
+
37921
+ S2.define('select2/data/maximumSelectionLength',[
37922
+
37923
+ ], function (){
37924
+ function MaximumSelectionLength (decorated, $e, options) {
37925
+ this.maximumSelectionLength = options.get('maximumSelectionLength');
37926
+
37927
+ decorated.call(this, $e, options);
37928
+ }
37929
+
37930
+ MaximumSelectionLength.prototype.query =
37931
+ function (decorated, params, callback) {
37932
+ var self = this;
37933
+
37934
+ this.current(function (currentData) {
37935
+ var count = currentData != null ? currentData.length : 0;
37936
+ if (self.maximumSelectionLength > 0 &&
37937
+ count >= self.maximumSelectionLength) {
37938
+ self.trigger('results:message', {
37939
+ message: 'maximumSelected',
37940
+ args: {
37941
+ maximum: self.maximumSelectionLength
37942
+ }
37943
+ });
37944
+ return;
37945
+ }
37946
+ decorated.call(self, params, callback);
37947
+ });
37948
+ };
37949
+
37950
+ return MaximumSelectionLength;
37951
+ });
37952
+
37953
+ S2.define('select2/dropdown',[
37954
+ 'jquery',
37955
+ './utils'
37956
+ ], function ($, Utils) {
37957
+ function Dropdown ($element, options) {
37958
+ this.$element = $element;
37959
+ this.options = options;
37960
+
37961
+ Dropdown.__super__.constructor.call(this);
37962
+ }
37963
+
37964
+ Utils.Extend(Dropdown, Utils.Observable);
37965
+
37966
+ Dropdown.prototype.render = function () {
37967
+ var $dropdown = $(
37968
+ '<span class="select2-dropdown">' +
37969
+ '<span class="select2-results"></span>' +
37970
+ '</span>'
37971
+ );
37972
+
37973
+ $dropdown.attr('dir', this.options.get('dir'));
37974
+
37975
+ this.$dropdown = $dropdown;
37976
+
37977
+ return $dropdown;
37978
+ };
37979
+
37980
+ Dropdown.prototype.bind = function () {
37981
+ // Should be implemented in subclasses
37982
+ };
37983
+
37984
+ Dropdown.prototype.position = function ($dropdown, $container) {
37985
+ // Should be implmented in subclasses
37986
+ };
37987
+
37988
+ Dropdown.prototype.destroy = function () {
37989
+ // Remove the dropdown from the DOM
37990
+ this.$dropdown.remove();
37991
+ };
37992
+
37993
+ return Dropdown;
37994
+ });
37995
+
37996
+ S2.define('select2/dropdown/search',[
37997
+ 'jquery',
37998
+ '../utils'
37999
+ ], function ($, Utils) {
38000
+ function Search () { }
38001
+
38002
+ Search.prototype.render = function (decorated) {
38003
+ var $rendered = decorated.call(this);
38004
+
38005
+ var $search = $(
38006
+ '<span class="select2-search select2-search--dropdown">' +
38007
+ '<input class="select2-search__field" type="search" tabindex="-1"' +
38008
+ ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
38009
+ ' spellcheck="false" role="textbox" />' +
38010
+ '</span>'
38011
+ );
38012
+
38013
+ this.$searchContainer = $search;
38014
+ this.$search = $search.find('input');
38015
+
38016
+ $rendered.prepend($search);
38017
+
38018
+ return $rendered;
38019
+ };
38020
+
38021
+ Search.prototype.bind = function (decorated, container, $container) {
38022
+ var self = this;
38023
+
38024
+ decorated.call(this, container, $container);
38025
+
38026
+ this.$search.on('keydown', function (evt) {
38027
+ self.trigger('keypress', evt);
38028
+
38029
+ self._keyUpPrevented = evt.isDefaultPrevented();
38030
+ });
38031
+
38032
+ // Workaround for browsers which do not support the `input` event
38033
+ // This will prevent double-triggering of events for browsers which support
38034
+ // both the `keyup` and `input` events.
38035
+ this.$search.on('input', function (evt) {
38036
+ // Unbind the duplicated `keyup` event
38037
+ $(this).off('keyup');
38038
+ });
38039
+
38040
+ this.$search.on('keyup input', function (evt) {
38041
+ self.handleSearch(evt);
38042
+ });
38043
+
38044
+ container.on('open', function () {
38045
+ self.$search.attr('tabindex', 0);
38046
+
38047
+ self.$search.focus();
38048
+
38049
+ window.setTimeout(function () {
38050
+ self.$search.focus();
38051
+ }, 0);
38052
+ });
38053
+
38054
+ container.on('close', function () {
38055
+ self.$search.attr('tabindex', -1);
38056
+
38057
+ self.$search.val('');
38058
+ });
38059
+
38060
+ container.on('focus', function () {
38061
+ if (!container.isOpen()) {
38062
+ self.$search.focus();
38063
+ }
38064
+ });
38065
+
38066
+ container.on('results:all', function (params) {
38067
+ if (params.query.term == null || params.query.term === '') {
38068
+ var showSearch = self.showSearch(params);
38069
+
38070
+ if (showSearch) {
38071
+ self.$searchContainer.removeClass('select2-search--hide');
38072
+ } else {
38073
+ self.$searchContainer.addClass('select2-search--hide');
38074
+ }
38075
+ }
38076
+ });
38077
+ };
38078
+
38079
+ Search.prototype.handleSearch = function (evt) {
38080
+ if (!this._keyUpPrevented) {
38081
+ var input = this.$search.val();
38082
+
38083
+ this.trigger('query', {
38084
+ term: input
38085
+ });
38086
+ }
38087
+
38088
+ this._keyUpPrevented = false;
38089
+ };
38090
+
38091
+ Search.prototype.showSearch = function (_, params) {
38092
+ return true;
38093
+ };
38094
+
38095
+ return Search;
38096
+ });
38097
+
38098
+ S2.define('select2/dropdown/hidePlaceholder',[
38099
+
38100
+ ], function () {
38101
+ function HidePlaceholder (decorated, $element, options, dataAdapter) {
38102
+ this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
38103
+
38104
+ decorated.call(this, $element, options, dataAdapter);
38105
+ }
38106
+
38107
+ HidePlaceholder.prototype.append = function (decorated, data) {
38108
+ data.results = this.removePlaceholder(data.results);
38109
+
38110
+ decorated.call(this, data);
38111
+ };
38112
+
38113
+ HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
38114
+ if (typeof placeholder === 'string') {
38115
+ placeholder = {
38116
+ id: '',
38117
+ text: placeholder
38118
+ };
38119
+ }
38120
+
38121
+ return placeholder;
38122
+ };
38123
+
38124
+ HidePlaceholder.prototype.removePlaceholder = function (_, data) {
38125
+ var modifiedData = data.slice(0);
38126
+
38127
+ for (var d = data.length - 1; d >= 0; d--) {
38128
+ var item = data[d];
38129
+
38130
+ if (this.placeholder.id === item.id) {
38131
+ modifiedData.splice(d, 1);
38132
+ }
38133
+ }
38134
+
38135
+ return modifiedData;
38136
+ };
38137
+
38138
+ return HidePlaceholder;
38139
+ });
38140
+
38141
+ S2.define('select2/dropdown/infiniteScroll',[
38142
+ 'jquery'
38143
+ ], function ($) {
38144
+ function InfiniteScroll (decorated, $element, options, dataAdapter) {
38145
+ this.lastParams = {};
38146
+
38147
+ decorated.call(this, $element, options, dataAdapter);
38148
+
38149
+ this.$loadingMore = this.createLoadingMore();
38150
+ this.loading = false;
38151
+ }
38152
+
38153
+ InfiniteScroll.prototype.append = function (decorated, data) {
38154
+ this.$loadingMore.remove();
38155
+ this.loading = false;
38156
+
38157
+ decorated.call(this, data);
38158
+
38159
+ if (this.showLoadingMore(data)) {
38160
+ this.$results.append(this.$loadingMore);
38161
+ }
38162
+ };
38163
+
38164
+ InfiniteScroll.prototype.bind = function (decorated, container, $container) {
38165
+ var self = this;
38166
+
38167
+ decorated.call(this, container, $container);
38168
+
38169
+ container.on('query', function (params) {
38170
+ self.lastParams = params;
38171
+ self.loading = true;
38172
+ });
38173
+
38174
+ container.on('query:append', function (params) {
38175
+ self.lastParams = params;
38176
+ self.loading = true;
38177
+ });
38178
+
38179
+ this.$results.on('scroll', function () {
38180
+ var isLoadMoreVisible = $.contains(
38181
+ document.documentElement,
38182
+ self.$loadingMore[0]
38183
+ );
38184
+
38185
+ if (self.loading || !isLoadMoreVisible) {
38186
+ return;
38187
+ }
38188
+
38189
+ var currentOffset = self.$results.offset().top +
38190
+ self.$results.outerHeight(false);
38191
+ var loadingMoreOffset = self.$loadingMore.offset().top +
38192
+ self.$loadingMore.outerHeight(false);
38193
+
38194
+ if (currentOffset + 50 >= loadingMoreOffset) {
38195
+ self.loadMore();
38196
+ }
38197
+ });
38198
+ };
38199
+
38200
+ InfiniteScroll.prototype.loadMore = function () {
38201
+ this.loading = true;
38202
+
38203
+ var params = $.extend({}, {page: 1}, this.lastParams);
38204
+
38205
+ params.page++;
38206
+
38207
+ this.trigger('query:append', params);
38208
+ };
38209
+
38210
+ InfiniteScroll.prototype.showLoadingMore = function (_, data) {
38211
+ return data.pagination && data.pagination.more;
38212
+ };
38213
+
38214
+ InfiniteScroll.prototype.createLoadingMore = function () {
38215
+ var $option = $(
38216
+ '<li ' +
38217
+ 'class="select2-results__option select2-results__option--load-more"' +
38218
+ 'role="treeitem" aria-disabled="true"></li>'
38219
+ );
38220
+
38221
+ var message = this.options.get('translations').get('loadingMore');
38222
+
38223
+ $option.html(message(this.lastParams));
38224
+
38225
+ return $option;
38226
+ };
38227
+
38228
+ return InfiniteScroll;
38229
+ });
38230
+
38231
+ S2.define('select2/dropdown/attachBody',[
38232
+ 'jquery',
38233
+ '../utils'
38234
+ ], function ($, Utils) {
38235
+ function AttachBody (decorated, $element, options) {
38236
+ this.$dropdownParent = options.get('dropdownParent') || $(document.body);
38237
+
38238
+ decorated.call(this, $element, options);
38239
+ }
38240
+
38241
+ AttachBody.prototype.bind = function (decorated, container, $container) {
38242
+ var self = this;
38243
+
38244
+ var setupResultsEvents = false;
38245
+
38246
+ decorated.call(this, container, $container);
38247
+
38248
+ container.on('open', function () {
38249
+ self._showDropdown();
38250
+ self._attachPositioningHandler(container);
38251
+
38252
+ if (!setupResultsEvents) {
38253
+ setupResultsEvents = true;
38254
+
38255
+ container.on('results:all', function () {
38256
+ self._positionDropdown();
38257
+ self._resizeDropdown();
38258
+ });
38259
+
38260
+ container.on('results:append', function () {
38261
+ self._positionDropdown();
38262
+ self._resizeDropdown();
38263
+ });
38264
+ }
38265
+ });
38266
+
38267
+ container.on('close', function () {
38268
+ self._hideDropdown();
38269
+ self._detachPositioningHandler(container);
38270
+ });
38271
+
38272
+ this.$dropdownContainer.on('mousedown', function (evt) {
38273
+ evt.stopPropagation();
38274
+ });
38275
+ };
38276
+
38277
+ AttachBody.prototype.destroy = function (decorated) {
38278
+ decorated.call(this);
38279
+
38280
+ this.$dropdownContainer.remove();
38281
+ };
38282
+
38283
+ AttachBody.prototype.position = function (decorated, $dropdown, $container) {
38284
+ // Clone all of the container classes
38285
+ $dropdown.attr('class', $container.attr('class'));
38286
+
38287
+ $dropdown.removeClass('select2');
38288
+ $dropdown.addClass('select2-container--open');
38289
+
38290
+ $dropdown.css({
38291
+ position: 'absolute',
38292
+ top: -999999
38293
+ });
38294
+
38295
+ this.$container = $container;
38296
+ };
38297
+
38298
+ AttachBody.prototype.render = function (decorated) {
38299
+ var $container = $('<span></span>');
38300
+
38301
+ var $dropdown = decorated.call(this);
38302
+ $container.append($dropdown);
38303
+
38304
+ this.$dropdownContainer = $container;
38305
+
38306
+ return $container;
38307
+ };
38308
+
38309
+ AttachBody.prototype._hideDropdown = function (decorated) {
38310
+ this.$dropdownContainer.detach();
38311
+ };
38312
+
38313
+ AttachBody.prototype._attachPositioningHandler =
38314
+ function (decorated, container) {
38315
+ var self = this;
38316
+
38317
+ var scrollEvent = 'scroll.select2.' + container.id;
38318
+ var resizeEvent = 'resize.select2.' + container.id;
38319
+ var orientationEvent = 'orientationchange.select2.' + container.id;
38320
+
38321
+ var $watchers = this.$container.parents().filter(Utils.hasScroll);
38322
+ $watchers.each(function () {
38323
+ $(this).data('select2-scroll-position', {
38324
+ x: $(this).scrollLeft(),
38325
+ y: $(this).scrollTop()
38326
+ });
38327
+ });
38328
+
38329
+ $watchers.on(scrollEvent, function (ev) {
38330
+ var position = $(this).data('select2-scroll-position');
38331
+ $(this).scrollTop(position.y);
38332
+ });
38333
+
38334
+ $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
38335
+ function (e) {
38336
+ self._positionDropdown();
38337
+ self._resizeDropdown();
38338
+ });
38339
+ };
38340
+
38341
+ AttachBody.prototype._detachPositioningHandler =
38342
+ function (decorated, container) {
38343
+ var scrollEvent = 'scroll.select2.' + container.id;
38344
+ var resizeEvent = 'resize.select2.' + container.id;
38345
+ var orientationEvent = 'orientationchange.select2.' + container.id;
38346
+
38347
+ var $watchers = this.$container.parents().filter(Utils.hasScroll);
38348
+ $watchers.off(scrollEvent);
38349
+
38350
+ $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
38351
+ };
38352
+
38353
+ AttachBody.prototype._positionDropdown = function () {
38354
+ var $window = $(window);
38355
+
38356
+ var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
38357
+ var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
38358
+
38359
+ var newDirection = null;
38360
+
38361
+ var offset = this.$container.offset();
38362
+
38363
+ offset.bottom = offset.top + this.$container.outerHeight(false);
38364
+
38365
+ var container = {
38366
+ height: this.$container.outerHeight(false)
38367
+ };
38368
+
38369
+ container.top = offset.top;
38370
+ container.bottom = offset.top + container.height;
38371
+
38372
+ var dropdown = {
38373
+ height: this.$dropdown.outerHeight(false)
38374
+ };
38375
+
38376
+ var viewport = {
38377
+ top: $window.scrollTop(),
38378
+ bottom: $window.scrollTop() + $window.height()
38379
+ };
38380
+
38381
+ var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
38382
+ var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
38383
+
38384
+ var css = {
38385
+ left: offset.left,
38386
+ top: container.bottom
38387
+ };
38388
+
38389
+ // Determine what the parent element is to use for calciulating the offset
38390
+ var $offsetParent = this.$dropdownParent;
38391
+
38392
+ // For statically positoned elements, we need to get the element
38393
+ // that is determining the offset
38394
+ if ($offsetParent.css('position') === 'static') {
38395
+ $offsetParent = $offsetParent.offsetParent();
38396
+ }
38397
+
38398
+ var parentOffset = $offsetParent.offset();
38399
+
38400
+ css.top -= parentOffset.top;
38401
+ css.left -= parentOffset.left;
38402
+
38403
+ if (!isCurrentlyAbove && !isCurrentlyBelow) {
38404
+ newDirection = 'below';
38405
+ }
38406
+
38407
+ if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
38408
+ newDirection = 'above';
38409
+ } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
38410
+ newDirection = 'below';
38411
+ }
38412
+
38413
+ if (newDirection == 'above' ||
38414
+ (isCurrentlyAbove && newDirection !== 'below')) {
38415
+ css.top = container.top - parentOffset.top - dropdown.height;
38416
+ }
38417
+
38418
+ if (newDirection != null) {
38419
+ this.$dropdown
38420
+ .removeClass('select2-dropdown--below select2-dropdown--above')
38421
+ .addClass('select2-dropdown--' + newDirection);
38422
+ this.$container
38423
+ .removeClass('select2-container--below select2-container--above')
38424
+ .addClass('select2-container--' + newDirection);
38425
+ }
38426
+
38427
+ this.$dropdownContainer.css(css);
38428
+ };
38429
+
38430
+ AttachBody.prototype._resizeDropdown = function () {
38431
+ var css = {
38432
+ width: this.$container.outerWidth(false) + 'px'
38433
+ };
38434
+
38435
+ if (this.options.get('dropdownAutoWidth')) {
38436
+ css.minWidth = css.width;
38437
+ css.position = 'relative';
38438
+ css.width = 'auto';
38439
+ }
38440
+
38441
+ this.$dropdown.css(css);
38442
+ };
38443
+
38444
+ AttachBody.prototype._showDropdown = function (decorated) {
38445
+ this.$dropdownContainer.appendTo(this.$dropdownParent);
38446
+
38447
+ this._positionDropdown();
38448
+ this._resizeDropdown();
38449
+ };
38450
+
38451
+ return AttachBody;
38452
+ });
38453
+
38454
+ S2.define('select2/dropdown/minimumResultsForSearch',[
38455
+
38456
+ ], function () {
38457
+ function countResults (data) {
38458
+ var count = 0;
38459
+
38460
+ for (var d = 0; d < data.length; d++) {
38461
+ var item = data[d];
38462
+
38463
+ if (item.children) {
38464
+ count += countResults(item.children);
38465
+ } else {
38466
+ count++;
38467
+ }
38468
+ }
38469
+
38470
+ return count;
38471
+ }
38472
+
38473
+ function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
38474
+ this.minimumResultsForSearch = options.get('minimumResultsForSearch');
38475
+
38476
+ if (this.minimumResultsForSearch < 0) {
38477
+ this.minimumResultsForSearch = Infinity;
38478
+ }
38479
+
38480
+ decorated.call(this, $element, options, dataAdapter);
38481
+ }
38482
+
38483
+ MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
38484
+ if (countResults(params.data.results) < this.minimumResultsForSearch) {
38485
+ return false;
38486
+ }
38487
+
38488
+ return decorated.call(this, params);
38489
+ };
38490
+
38491
+ return MinimumResultsForSearch;
38492
+ });
38493
+
38494
+ S2.define('select2/dropdown/selectOnClose',[
38495
+
38496
+ ], function () {
38497
+ function SelectOnClose () { }
38498
+
38499
+ SelectOnClose.prototype.bind = function (decorated, container, $container) {
38500
+ var self = this;
38501
+
38502
+ decorated.call(this, container, $container);
38503
+
38504
+ container.on('close', function (params) {
38505
+ self._handleSelectOnClose(params);
38506
+ });
38507
+ };
38508
+
38509
+ SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
38510
+ if (params && params.originalSelect2Event != null) {
38511
+ var event = params.originalSelect2Event;
38512
+
38513
+ // Don't select an item if the close event was triggered from a select or
38514
+ // unselect event
38515
+ if (event._type === 'select' || event._type === 'unselect') {
38516
+ return;
38517
+ }
38518
+ }
38519
+
38520
+ var $highlightedResults = this.getHighlightedResults();
38521
+
38522
+ // Only select highlighted results
38523
+ if ($highlightedResults.length < 1) {
38524
+ return;
38525
+ }
38526
+
38527
+ var data = $highlightedResults.data('data');
38528
+
38529
+ // Don't re-select already selected resulte
38530
+ if (
38531
+ (data.element != null && data.element.selected) ||
38532
+ (data.element == null && data.selected)
38533
+ ) {
38534
+ return;
38535
+ }
38536
+
38537
+ this.trigger('select', {
38538
+ data: data
38539
+ });
38540
+ };
38541
+
38542
+ return SelectOnClose;
38543
+ });
38544
+
38545
+ S2.define('select2/dropdown/closeOnSelect',[
38546
+
38547
+ ], function () {
38548
+ function CloseOnSelect () { }
38549
+
38550
+ CloseOnSelect.prototype.bind = function (decorated, container, $container) {
38551
+ var self = this;
38552
+
38553
+ decorated.call(this, container, $container);
38554
+
38555
+ container.on('select', function (evt) {
38556
+ self._selectTriggered(evt);
38557
+ });
38558
+
38559
+ container.on('unselect', function (evt) {
38560
+ self._selectTriggered(evt);
38561
+ });
38562
+ };
38563
+
38564
+ CloseOnSelect.prototype._selectTriggered = function (_, evt) {
38565
+ var originalEvent = evt.originalEvent;
38566
+
38567
+ // Don't close if the control key is being held
38568
+ if (originalEvent && originalEvent.ctrlKey) {
38569
+ return;
38570
+ }
38571
+
38572
+ this.trigger('close', {
38573
+ originalEvent: originalEvent,
38574
+ originalSelect2Event: evt
38575
+ });
38576
+ };
38577
+
38578
+ return CloseOnSelect;
38579
+ });
38580
+
38581
+ S2.define('select2/i18n/en',[],function () {
38582
+ // English
38583
+ return {
38584
+ errorLoading: function () {
38585
+ return 'The results could not be loaded.';
38586
+ },
38587
+ inputTooLong: function (args) {
38588
+ var overChars = args.input.length - args.maximum;
38589
+
38590
+ var message = 'Please delete ' + overChars + ' character';
38591
+
38592
+ if (overChars != 1) {
38593
+ message += 's';
38594
+ }
38595
+
38596
+ return message;
38597
+ },
38598
+ inputTooShort: function (args) {
38599
+ var remainingChars = args.minimum - args.input.length;
38600
+
38601
+ var message = 'Please enter ' + remainingChars + ' or more characters';
38602
+
38603
+ return message;
38604
+ },
38605
+ loadingMore: function () {
38606
+ return 'Loading more results…';
38607
+ },
38608
+ maximumSelected: function (args) {
38609
+ var message = 'You can only select ' + args.maximum + ' item';
38610
+
38611
+ if (args.maximum != 1) {
38612
+ message += 's';
38613
+ }
38614
+
38615
+ return message;
38616
+ },
38617
+ noResults: function () {
38618
+ return 'No results found';
38619
+ },
38620
+ searching: function () {
38621
+ return 'Searching…';
38622
+ }
38623
+ };
38624
+ });
38625
+
38626
+ S2.define('select2/defaults',[
38627
+ 'jquery',
38628
+ 'require',
38629
+
38630
+ './results',
38631
+
38632
+ './selection/single',
38633
+ './selection/multiple',
38634
+ './selection/placeholder',
38635
+ './selection/allowClear',
38636
+ './selection/search',
38637
+ './selection/eventRelay',
38638
+
38639
+ './utils',
38640
+ './translation',
38641
+ './diacritics',
38642
+
38643
+ './data/select',
38644
+ './data/array',
38645
+ './data/ajax',
38646
+ './data/tags',
38647
+ './data/tokenizer',
38648
+ './data/minimumInputLength',
38649
+ './data/maximumInputLength',
38650
+ './data/maximumSelectionLength',
38651
+
38652
+ './dropdown',
38653
+ './dropdown/search',
38654
+ './dropdown/hidePlaceholder',
38655
+ './dropdown/infiniteScroll',
38656
+ './dropdown/attachBody',
38657
+ './dropdown/minimumResultsForSearch',
38658
+ './dropdown/selectOnClose',
38659
+ './dropdown/closeOnSelect',
38660
+
38661
+ './i18n/en'
38662
+ ], function ($, require,
38663
+
38664
+ ResultsList,
38665
+
38666
+ SingleSelection, MultipleSelection, Placeholder, AllowClear,
38667
+ SelectionSearch, EventRelay,
38668
+
38669
+ Utils, Translation, DIACRITICS,
38670
+
38671
+ SelectData, ArrayData, AjaxData, Tags, Tokenizer,
38672
+ MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
38673
+
38674
+ Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
38675
+ AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
38676
+
38677
+ EnglishTranslation) {
38678
+ function Defaults () {
38679
+ this.reset();
38680
+ }
38681
+
38682
+ Defaults.prototype.apply = function (options) {
38683
+ options = $.extend(true, {}, this.defaults, options);
38684
+
38685
+ if (options.dataAdapter == null) {
38686
+ if (options.ajax != null) {
38687
+ options.dataAdapter = AjaxData;
38688
+ } else if (options.data != null) {
38689
+ options.dataAdapter = ArrayData;
38690
+ } else {
38691
+ options.dataAdapter = SelectData;
38692
+ }
38693
+
38694
+ if (options.minimumInputLength > 0) {
38695
+ options.dataAdapter = Utils.Decorate(
38696
+ options.dataAdapter,
38697
+ MinimumInputLength
38698
+ );
38699
+ }
38700
+
38701
+ if (options.maximumInputLength > 0) {
38702
+ options.dataAdapter = Utils.Decorate(
38703
+ options.dataAdapter,
38704
+ MaximumInputLength
38705
+ );
38706
+ }
38707
+
38708
+ if (options.maximumSelectionLength > 0) {
38709
+ options.dataAdapter = Utils.Decorate(
38710
+ options.dataAdapter,
38711
+ MaximumSelectionLength
38712
+ );
38713
+ }
38714
+
38715
+ if (options.tags) {
38716
+ options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
38717
+ }
38718
+
38719
+ if (options.tokenSeparators != null || options.tokenizer != null) {
38720
+ options.dataAdapter = Utils.Decorate(
38721
+ options.dataAdapter,
38722
+ Tokenizer
38723
+ );
38724
+ }
38725
+
38726
+ if (options.query != null) {
38727
+ var Query = require(options.amdBase + 'compat/query');
38728
+
38729
+ options.dataAdapter = Utils.Decorate(
38730
+ options.dataAdapter,
38731
+ Query
38732
+ );
38733
+ }
38734
+
38735
+ if (options.initSelection != null) {
38736
+ var InitSelection = require(options.amdBase + 'compat/initSelection');
38737
+
38738
+ options.dataAdapter = Utils.Decorate(
38739
+ options.dataAdapter,
38740
+ InitSelection
38741
+ );
38742
+ }
38743
+ }
38744
+
38745
+ if (options.resultsAdapter == null) {
38746
+ options.resultsAdapter = ResultsList;
38747
+
38748
+ if (options.ajax != null) {
38749
+ options.resultsAdapter = Utils.Decorate(
38750
+ options.resultsAdapter,
38751
+ InfiniteScroll
38752
+ );
38753
+ }
38754
+
38755
+ if (options.placeholder != null) {
38756
+ options.resultsAdapter = Utils.Decorate(
38757
+ options.resultsAdapter,
38758
+ HidePlaceholder
38759
+ );
38760
+ }
38761
+
38762
+ if (options.selectOnClose) {
38763
+ options.resultsAdapter = Utils.Decorate(
38764
+ options.resultsAdapter,
38765
+ SelectOnClose
38766
+ );
38767
+ }
38768
+ }
38769
+
38770
+ if (options.dropdownAdapter == null) {
38771
+ if (options.multiple) {
38772
+ options.dropdownAdapter = Dropdown;
38773
+ } else {
38774
+ var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
38775
+
38776
+ options.dropdownAdapter = SearchableDropdown;
38777
+ }
38778
+
38779
+ if (options.minimumResultsForSearch !== 0) {
38780
+ options.dropdownAdapter = Utils.Decorate(
38781
+ options.dropdownAdapter,
38782
+ MinimumResultsForSearch
38783
+ );
38784
+ }
38785
+
38786
+ if (options.closeOnSelect) {
38787
+ options.dropdownAdapter = Utils.Decorate(
38788
+ options.dropdownAdapter,
38789
+ CloseOnSelect
38790
+ );
38791
+ }
38792
+
38793
+ if (
38794
+ options.dropdownCssClass != null ||
38795
+ options.dropdownCss != null ||
38796
+ options.adaptDropdownCssClass != null
38797
+ ) {
38798
+ var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
38799
+
38800
+ options.dropdownAdapter = Utils.Decorate(
38801
+ options.dropdownAdapter,
38802
+ DropdownCSS
38803
+ );
38804
+ }
38805
+
38806
+ options.dropdownAdapter = Utils.Decorate(
38807
+ options.dropdownAdapter,
38808
+ AttachBody
38809
+ );
38810
+ }
38811
+
38812
+ if (options.selectionAdapter == null) {
38813
+ if (options.multiple) {
38814
+ options.selectionAdapter = MultipleSelection;
38815
+ } else {
38816
+ options.selectionAdapter = SingleSelection;
38817
+ }
38818
+
38819
+ // Add the placeholder mixin if a placeholder was specified
38820
+ if (options.placeholder != null) {
38821
+ options.selectionAdapter = Utils.Decorate(
38822
+ options.selectionAdapter,
38823
+ Placeholder
38824
+ );
38825
+ }
38826
+
38827
+ if (options.allowClear) {
38828
+ options.selectionAdapter = Utils.Decorate(
38829
+ options.selectionAdapter,
38830
+ AllowClear
38831
+ );
38832
+ }
38833
+
38834
+ if (options.multiple) {
38835
+ options.selectionAdapter = Utils.Decorate(
38836
+ options.selectionAdapter,
38837
+ SelectionSearch
38838
+ );
38839
+ }
38840
+
38841
+ if (
38842
+ options.containerCssClass != null ||
38843
+ options.containerCss != null ||
38844
+ options.adaptContainerCssClass != null
38845
+ ) {
38846
+ var ContainerCSS = require(options.amdBase + 'compat/containerCss');
38847
+
38848
+ options.selectionAdapter = Utils.Decorate(
38849
+ options.selectionAdapter,
38850
+ ContainerCSS
38851
+ );
38852
+ }
38853
+
38854
+ options.selectionAdapter = Utils.Decorate(
38855
+ options.selectionAdapter,
38856
+ EventRelay
38857
+ );
38858
+ }
38859
+
38860
+ if (typeof options.language === 'string') {
38861
+ // Check if the language is specified with a region
38862
+ if (options.language.indexOf('-') > 0) {
38863
+ // Extract the region information if it is included
38864
+ var languageParts = options.language.split('-');
38865
+ var baseLanguage = languageParts[0];
38866
+
38867
+ options.language = [options.language, baseLanguage];
38868
+ } else {
38869
+ options.language = [options.language];
38870
+ }
38871
+ }
38872
+
38873
+ if ($.isArray(options.language)) {
38874
+ var languages = new Translation();
38875
+ options.language.push('en');
38876
+
38877
+ var languageNames = options.language;
38878
+
38879
+ for (var l = 0; l < languageNames.length; l++) {
38880
+ var name = languageNames[l];
38881
+ var language = {};
38882
+
38883
+ try {
38884
+ // Try to load it with the original name
38885
+ language = Translation.loadPath(name);
38886
+ } catch (e) {
38887
+ try {
38888
+ // If we couldn't load it, check if it wasn't the full path
38889
+ name = this.defaults.amdLanguageBase + name;
38890
+ language = Translation.loadPath(name);
38891
+ } catch (ex) {
38892
+ // The translation could not be loaded at all. Sometimes this is
38893
+ // because of a configuration problem, other times this can be
38894
+ // because of how Select2 helps load all possible translation files.
38895
+ if (options.debug && window.console && console.warn) {
38896
+ console.warn(
38897
+ 'Select2: The language file for "' + name + '" could not be ' +
38898
+ 'automatically loaded. A fallback will be used instead.'
38899
+ );
38900
+ }
38901
+
38902
+ continue;
38903
+ }
38904
+ }
38905
+
38906
+ languages.extend(language);
38907
+ }
38908
+
38909
+ options.translations = languages;
38910
+ } else {
38911
+ var baseTranslation = Translation.loadPath(
38912
+ this.defaults.amdLanguageBase + 'en'
38913
+ );
38914
+ var customTranslation = new Translation(options.language);
38915
+
38916
+ customTranslation.extend(baseTranslation);
38917
+
38918
+ options.translations = customTranslation;
38919
+ }
38920
+
38921
+ return options;
38922
+ };
38923
+
38924
+ Defaults.prototype.reset = function () {
38925
+ function stripDiacritics (text) {
38926
+ // Used 'uni range + named function' from http://jsperf.com/diacritics/18
38927
+ function match(a) {
38928
+ return DIACRITICS[a] || a;
38929
+ }
38930
+
38931
+ return text.replace(/[^\u0000-\u007E]/g, match);
38932
+ }
38933
+
38934
+ function matcher (params, data) {
38935
+ // Always return the object if there is nothing to compare
38936
+ if ($.trim(params.term) === '') {
38937
+ return data;
38938
+ }
38939
+
38940
+ // Do a recursive check for options with children
38941
+ if (data.children && data.children.length > 0) {
38942
+ // Clone the data object if there are children
38943
+ // This is required as we modify the object to remove any non-matches
38944
+ var match = $.extend(true, {}, data);
38945
+
38946
+ // Check each child of the option
38947
+ for (var c = data.children.length - 1; c >= 0; c--) {
38948
+ var child = data.children[c];
38949
+
38950
+ var matches = matcher(params, child);
38951
+
38952
+ // If there wasn't a match, remove the object in the array
38953
+ if (matches == null) {
38954
+ match.children.splice(c, 1);
38955
+ }
38956
+ }
38957
+
38958
+ // If any children matched, return the new object
38959
+ if (match.children.length > 0) {
38960
+ return match;
38961
+ }
38962
+
38963
+ // If there were no matching children, check just the plain object
38964
+ return matcher(params, match);
38965
+ }
38966
+
38967
+ var original = stripDiacritics(data.text).toUpperCase();
38968
+ var term = stripDiacritics(params.term).toUpperCase();
38969
+
38970
+ // Check if the text contains the term
38971
+ if (original.indexOf(term) > -1) {
38972
+ return data;
38973
+ }
38974
+
38975
+ // If it doesn't contain the term, don't return anything
38976
+ return null;
38977
+ }
38978
+
38979
+ this.defaults = {
38980
+ amdBase: './',
38981
+ amdLanguageBase: './i18n/',
38982
+ closeOnSelect: true,
38983
+ debug: false,
38984
+ dropdownAutoWidth: false,
38985
+ escapeMarkup: Utils.escapeMarkup,
38986
+ language: EnglishTranslation,
38987
+ matcher: matcher,
38988
+ minimumInputLength: 0,
38989
+ maximumInputLength: 0,
38990
+ maximumSelectionLength: 0,
38991
+ minimumResultsForSearch: 0,
38992
+ selectOnClose: false,
38993
+ sorter: function (data) {
38994
+ return data;
38995
+ },
38996
+ templateResult: function (result) {
38997
+ return result.text;
38998
+ },
38999
+ templateSelection: function (selection) {
39000
+ return selection.text;
39001
+ },
39002
+ theme: 'default',
39003
+ width: 'resolve'
39004
+ };
39005
+ };
39006
+
39007
+ Defaults.prototype.set = function (key, value) {
39008
+ var camelKey = $.camelCase(key);
39009
+
39010
+ var data = {};
39011
+ data[camelKey] = value;
39012
+
39013
+ var convertedData = Utils._convertData(data);
39014
+
39015
+ $.extend(this.defaults, convertedData);
39016
+ };
39017
+
39018
+ var defaults = new Defaults();
39019
+
39020
+ return defaults;
39021
+ });
39022
+
39023
+ S2.define('select2/options',[
39024
+ 'require',
39025
+ 'jquery',
39026
+ './defaults',
39027
+ './utils'
39028
+ ], function (require, $, Defaults, Utils) {
39029
+ function Options (options, $element) {
39030
+ this.options = options;
39031
+
39032
+ if ($element != null) {
39033
+ this.fromElement($element);
39034
+ }
39035
+
39036
+ this.options = Defaults.apply(this.options);
39037
+
39038
+ if ($element && $element.is('input')) {
39039
+ var InputCompat = require(this.get('amdBase') + 'compat/inputData');
39040
+
39041
+ this.options.dataAdapter = Utils.Decorate(
39042
+ this.options.dataAdapter,
39043
+ InputCompat
39044
+ );
39045
+ }
39046
+ }
39047
+
39048
+ Options.prototype.fromElement = function ($e) {
39049
+ var excludedData = ['select2'];
39050
+
39051
+ if (this.options.multiple == null) {
39052
+ this.options.multiple = $e.prop('multiple');
39053
+ }
39054
+
39055
+ if (this.options.disabled == null) {
39056
+ this.options.disabled = $e.prop('disabled');
39057
+ }
39058
+
39059
+ if (this.options.language == null) {
39060
+ if ($e.prop('lang')) {
39061
+ this.options.language = $e.prop('lang').toLowerCase();
39062
+ } else if ($e.closest('[lang]').prop('lang')) {
39063
+ this.options.language = $e.closest('[lang]').prop('lang');
39064
+ }
39065
+ }
39066
+
39067
+ if (this.options.dir == null) {
39068
+ if ($e.prop('dir')) {
39069
+ this.options.dir = $e.prop('dir');
39070
+ } else if ($e.closest('[dir]').prop('dir')) {
39071
+ this.options.dir = $e.closest('[dir]').prop('dir');
39072
+ } else {
39073
+ this.options.dir = 'ltr';
39074
+ }
39075
+ }
39076
+
39077
+ $e.prop('disabled', this.options.disabled);
39078
+ $e.prop('multiple', this.options.multiple);
39079
+
39080
+ if ($e.data('select2Tags')) {
39081
+ if (this.options.debug && window.console && console.warn) {
39082
+ console.warn(
39083
+ 'Select2: The `data-select2-tags` attribute has been changed to ' +
39084
+ 'use the `data-data` and `data-tags="true"` attributes and will be ' +
39085
+ 'removed in future versions of Select2.'
39086
+ );
39087
+ }
39088
+
39089
+ $e.data('data', $e.data('select2Tags'));
39090
+ $e.data('tags', true);
39091
+ }
39092
+
39093
+ if ($e.data('ajaxUrl')) {
39094
+ if (this.options.debug && window.console && console.warn) {
39095
+ console.warn(
39096
+ 'Select2: The `data-ajax-url` attribute has been changed to ' +
39097
+ '`data-ajax--url` and support for the old attribute will be removed' +
39098
+ ' in future versions of Select2.'
39099
+ );
39100
+ }
39101
+
39102
+ $e.attr('ajax--url', $e.data('ajaxUrl'));
39103
+ $e.data('ajax--url', $e.data('ajaxUrl'));
39104
+ }
39105
+
39106
+ var dataset = {};
39107
+
39108
+ // Prefer the element's `dataset` attribute if it exists
39109
+ // jQuery 1.x does not correctly handle data attributes with multiple dashes
39110
+ if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
39111
+ dataset = $.extend(true, {}, $e[0].dataset, $e.data());
39112
+ } else {
39113
+ dataset = $e.data();
39114
+ }
39115
+
39116
+ var data = $.extend(true, {}, dataset);
39117
+
39118
+ data = Utils._convertData(data);
39119
+
39120
+ for (var key in data) {
39121
+ if ($.inArray(key, excludedData) > -1) {
39122
+ continue;
39123
+ }
39124
+
39125
+ if ($.isPlainObject(this.options[key])) {
39126
+ $.extend(this.options[key], data[key]);
39127
+ } else {
39128
+ this.options[key] = data[key];
39129
+ }
39130
+ }
39131
+
39132
+ return this;
39133
+ };
39134
+
39135
+ Options.prototype.get = function (key) {
39136
+ return this.options[key];
39137
+ };
39138
+
39139
+ Options.prototype.set = function (key, val) {
39140
+ this.options[key] = val;
39141
+ };
39142
+
39143
+ return Options;
39144
+ });
39145
+
39146
+ S2.define('select2/core',[
39147
+ 'jquery',
39148
+ './options',
39149
+ './utils',
39150
+ './keys'
39151
+ ], function ($, Options, Utils, KEYS) {
39152
+ var Select2 = function ($element, options) {
39153
+ if ($element.data('select2') != null) {
39154
+ $element.data('select2').destroy();
39155
+ }
39156
+
39157
+ this.$element = $element;
39158
+
39159
+ this.id = this._generateId($element);
39160
+
39161
+ options = options || {};
39162
+
39163
+ this.options = new Options(options, $element);
39164
+
39165
+ Select2.__super__.constructor.call(this);
39166
+
39167
+ // Set up the tabindex
39168
+
39169
+ var tabindex = $element.attr('tabindex') || 0;
39170
+ $element.data('old-tabindex', tabindex);
39171
+ $element.attr('tabindex', '-1');
39172
+
39173
+ // Set up containers and adapters
39174
+
39175
+ var DataAdapter = this.options.get('dataAdapter');
39176
+ this.dataAdapter = new DataAdapter($element, this.options);
39177
+
39178
+ var $container = this.render();
39179
+
39180
+ this._placeContainer($container);
39181
+
39182
+ var SelectionAdapter = this.options.get('selectionAdapter');
39183
+ this.selection = new SelectionAdapter($element, this.options);
39184
+ this.$selection = this.selection.render();
39185
+
39186
+ this.selection.position(this.$selection, $container);
39187
+
39188
+ var DropdownAdapter = this.options.get('dropdownAdapter');
39189
+ this.dropdown = new DropdownAdapter($element, this.options);
39190
+ this.$dropdown = this.dropdown.render();
39191
+
39192
+ this.dropdown.position(this.$dropdown, $container);
39193
+
39194
+ var ResultsAdapter = this.options.get('resultsAdapter');
39195
+ this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
39196
+ this.$results = this.results.render();
39197
+
39198
+ this.results.position(this.$results, this.$dropdown);
39199
+
39200
+ // Bind events
39201
+
39202
+ var self = this;
39203
+
39204
+ // Bind the container to all of the adapters
39205
+ this._bindAdapters();
39206
+
39207
+ // Register any DOM event handlers
39208
+ this._registerDomEvents();
39209
+
39210
+ // Register any internal event handlers
39211
+ this._registerDataEvents();
39212
+ this._registerSelectionEvents();
39213
+ this._registerDropdownEvents();
39214
+ this._registerResultsEvents();
39215
+ this._registerEvents();
39216
+
39217
+ // Set the initial state
39218
+ this.dataAdapter.current(function (initialData) {
39219
+ self.trigger('selection:update', {
39220
+ data: initialData
39221
+ });
39222
+ });
39223
+
39224
+ // Hide the original select
39225
+ $element.addClass('select2-hidden-accessible');
39226
+ $element.attr('aria-hidden', 'true');
39227
+
39228
+ // Synchronize any monitored attributes
39229
+ this._syncAttributes();
39230
+
39231
+ $element.data('select2', this);
39232
+ };
39233
+
39234
+ Utils.Extend(Select2, Utils.Observable);
39235
+
39236
+ Select2.prototype._generateId = function ($element) {
39237
+ var id = '';
39238
+
39239
+ if ($element.attr('id') != null) {
39240
+ id = $element.attr('id');
39241
+ } else if ($element.attr('name') != null) {
39242
+ id = $element.attr('name') + '-' + Utils.generateChars(2);
39243
+ } else {
39244
+ id = Utils.generateChars(4);
39245
+ }
39246
+
39247
+ id = id.replace(/(:|\.|\[|\]|,)/g, '');
39248
+ id = 'select2-' + id;
39249
+
39250
+ return id;
39251
+ };
39252
+
39253
+ Select2.prototype._placeContainer = function ($container) {
39254
+ $container.insertAfter(this.$element);
39255
+
39256
+ var width = this._resolveWidth(this.$element, this.options.get('width'));
39257
+
39258
+ if (width != null) {
39259
+ $container.css('width', width);
39260
+ }
39261
+ };
39262
+
39263
+ Select2.prototype._resolveWidth = function ($element, method) {
39264
+ var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
39265
+
39266
+ if (method == 'resolve') {
39267
+ var styleWidth = this._resolveWidth($element, 'style');
39268
+
39269
+ if (styleWidth != null) {
39270
+ return styleWidth;
39271
+ }
39272
+
39273
+ return this._resolveWidth($element, 'element');
39274
+ }
39275
+
39276
+ if (method == 'element') {
39277
+ var elementWidth = $element.outerWidth(false);
39278
+
39279
+ if (elementWidth <= 0) {
39280
+ return 'auto';
39281
+ }
39282
+
39283
+ return elementWidth + 'px';
39284
+ }
39285
+
39286
+ if (method == 'style') {
39287
+ var style = $element.attr('style');
39288
+
39289
+ if (typeof(style) !== 'string') {
39290
+ return null;
39291
+ }
39292
+
39293
+ var attrs = style.split(';');
39294
+
39295
+ for (var i = 0, l = attrs.length; i < l; i = i + 1) {
39296
+ var attr = attrs[i].replace(/\s/g, '');
39297
+ var matches = attr.match(WIDTH);
39298
+
39299
+ if (matches !== null && matches.length >= 1) {
39300
+ return matches[1];
39301
+ }
39302
+ }
39303
+
39304
+ return null;
39305
+ }
39306
+
39307
+ return method;
39308
+ };
39309
+
39310
+ Select2.prototype._bindAdapters = function () {
39311
+ this.dataAdapter.bind(this, this.$container);
39312
+ this.selection.bind(this, this.$container);
39313
+
39314
+ this.dropdown.bind(this, this.$container);
39315
+ this.results.bind(this, this.$container);
39316
+ };
39317
+
39318
+ Select2.prototype._registerDomEvents = function () {
39319
+ var self = this;
39320
+
39321
+ this.$element.on('change.select2', function () {
39322
+ self.dataAdapter.current(function (data) {
39323
+ self.trigger('selection:update', {
39324
+ data: data
39325
+ });
39326
+ });
39327
+ });
39328
+
39329
+ this.$element.on('focus.select2', function (evt) {
39330
+ self.trigger('focus', evt);
39331
+ });
39332
+
39333
+ this._syncA = Utils.bind(this._syncAttributes, this);
39334
+ this._syncS = Utils.bind(this._syncSubtree, this);
39335
+
39336
+ if (this.$element[0].attachEvent) {
39337
+ this.$element[0].attachEvent('onpropertychange', this._syncA);
39338
+ }
39339
+
39340
+ var observer = window.MutationObserver ||
39341
+ window.WebKitMutationObserver ||
39342
+ window.MozMutationObserver
39343
+ ;
39344
+
39345
+ if (observer != null) {
39346
+ this._observer = new observer(function (mutations) {
39347
+ $.each(mutations, self._syncA);
39348
+ $.each(mutations, self._syncS);
39349
+ });
39350
+ this._observer.observe(this.$element[0], {
39351
+ attributes: true,
39352
+ childList: true,
39353
+ subtree: false
39354
+ });
39355
+ } else if (this.$element[0].addEventListener) {
39356
+ this.$element[0].addEventListener(
39357
+ 'DOMAttrModified',
39358
+ self._syncA,
39359
+ false
39360
+ );
39361
+ this.$element[0].addEventListener(
39362
+ 'DOMNodeInserted',
39363
+ self._syncS,
39364
+ false
39365
+ );
39366
+ this.$element[0].addEventListener(
39367
+ 'DOMNodeRemoved',
39368
+ self._syncS,
39369
+ false
39370
+ );
39371
+ }
39372
+ };
39373
+
39374
+ Select2.prototype._registerDataEvents = function () {
39375
+ var self = this;
39376
+
39377
+ this.dataAdapter.on('*', function (name, params) {
39378
+ self.trigger(name, params);
39379
+ });
39380
+ };
39381
+
39382
+ Select2.prototype._registerSelectionEvents = function () {
39383
+ var self = this;
39384
+ var nonRelayEvents = ['toggle', 'focus'];
39385
+
39386
+ this.selection.on('toggle', function () {
39387
+ self.toggleDropdown();
39388
+ });
39389
+
39390
+ this.selection.on('focus', function (params) {
39391
+ self.focus(params);
39392
+ });
39393
+
39394
+ this.selection.on('*', function (name, params) {
39395
+ if ($.inArray(name, nonRelayEvents) !== -1) {
39396
+ return;
39397
+ }
39398
+
39399
+ self.trigger(name, params);
39400
+ });
39401
+ };
39402
+
39403
+ Select2.prototype._registerDropdownEvents = function () {
39404
+ var self = this;
39405
+
39406
+ this.dropdown.on('*', function (name, params) {
39407
+ self.trigger(name, params);
39408
+ });
39409
+ };
39410
+
39411
+ Select2.prototype._registerResultsEvents = function () {
39412
+ var self = this;
39413
+
39414
+ this.results.on('*', function (name, params) {
39415
+ self.trigger(name, params);
39416
+ });
39417
+ };
39418
+
39419
+ Select2.prototype._registerEvents = function () {
39420
+ var self = this;
39421
+
39422
+ this.on('open', function () {
39423
+ self.$container.addClass('select2-container--open');
39424
+ });
39425
+
39426
+ this.on('close', function () {
39427
+ self.$container.removeClass('select2-container--open');
39428
+ });
39429
+
39430
+ this.on('enable', function () {
39431
+ self.$container.removeClass('select2-container--disabled');
39432
+ });
39433
+
39434
+ this.on('disable', function () {
39435
+ self.$container.addClass('select2-container--disabled');
39436
+ });
39437
+
39438
+ this.on('blur', function () {
39439
+ self.$container.removeClass('select2-container--focus');
39440
+ });
39441
+
39442
+ this.on('query', function (params) {
39443
+ if (!self.isOpen()) {
39444
+ self.trigger('open', {});
39445
+ }
39446
+
39447
+ this.dataAdapter.query(params, function (data) {
39448
+ self.trigger('results:all', {
39449
+ data: data,
39450
+ query: params
39451
+ });
39452
+ });
39453
+ });
39454
+
39455
+ this.on('query:append', function (params) {
39456
+ this.dataAdapter.query(params, function (data) {
39457
+ self.trigger('results:append', {
39458
+ data: data,
39459
+ query: params
39460
+ });
39461
+ });
39462
+ });
39463
+
39464
+ this.on('keypress', function (evt) {
39465
+ var key = evt.which;
39466
+
39467
+ if (self.isOpen()) {
39468
+ if (key === KEYS.ESC || key === KEYS.TAB ||
39469
+ (key === KEYS.UP && evt.altKey)) {
39470
+ self.close();
39471
+
39472
+ evt.preventDefault();
39473
+ } else if (key === KEYS.ENTER) {
39474
+ self.trigger('results:select', {});
39475
+
39476
+ evt.preventDefault();
39477
+ } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
39478
+ self.trigger('results:toggle', {});
39479
+
39480
+ evt.preventDefault();
39481
+ } else if (key === KEYS.UP) {
39482
+ self.trigger('results:previous', {});
39483
+
39484
+ evt.preventDefault();
39485
+ } else if (key === KEYS.DOWN) {
39486
+ self.trigger('results:next', {});
39487
+
39488
+ evt.preventDefault();
39489
+ }
39490
+ } else {
39491
+ if (key === KEYS.ENTER || key === KEYS.SPACE ||
39492
+ (key === KEYS.DOWN && evt.altKey)) {
39493
+ self.open();
39494
+
39495
+ evt.preventDefault();
39496
+ }
39497
+ }
39498
+ });
39499
+ };
39500
+
39501
+ Select2.prototype._syncAttributes = function () {
39502
+ this.options.set('disabled', this.$element.prop('disabled'));
39503
+
39504
+ if (this.options.get('disabled')) {
39505
+ if (this.isOpen()) {
39506
+ this.close();
39507
+ }
39508
+
39509
+ this.trigger('disable', {});
39510
+ } else {
39511
+ this.trigger('enable', {});
39512
+ }
39513
+ };
39514
+
39515
+ Select2.prototype._syncSubtree = function (evt, mutations) {
39516
+ var changed = false;
39517
+ var self = this;
39518
+
39519
+ // Ignore any mutation events raised for elements that aren't options or
39520
+ // optgroups. This handles the case when the select element is destroyed
39521
+ if (
39522
+ evt && evt.target && (
39523
+ evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
39524
+ )
39525
+ ) {
39526
+ return;
39527
+ }
39528
+
39529
+ if (!mutations) {
39530
+ // If mutation events aren't supported, then we can only assume that the
39531
+ // change affected the selections
39532
+ changed = true;
39533
+ } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
39534
+ for (var n = 0; n < mutations.addedNodes.length; n++) {
39535
+ var node = mutations.addedNodes[n];
39536
+
39537
+ if (node.selected) {
39538
+ changed = true;
39539
+ }
39540
+ }
39541
+ } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
39542
+ changed = true;
39543
+ }
39544
+
39545
+ // Only re-pull the data if we think there is a change
39546
+ if (changed) {
39547
+ this.dataAdapter.current(function (currentData) {
39548
+ self.trigger('selection:update', {
39549
+ data: currentData
39550
+ });
39551
+ });
39552
+ }
39553
+ };
39554
+
39555
+ /**
39556
+ * Override the trigger method to automatically trigger pre-events when
39557
+ * there are events that can be prevented.
39558
+ */
39559
+ Select2.prototype.trigger = function (name, args) {
39560
+ var actualTrigger = Select2.__super__.trigger;
39561
+ var preTriggerMap = {
39562
+ 'open': 'opening',
39563
+ 'close': 'closing',
39564
+ 'select': 'selecting',
39565
+ 'unselect': 'unselecting'
39566
+ };
39567
+
39568
+ if (args === undefined) {
39569
+ args = {};
39570
+ }
39571
+
39572
+ if (name in preTriggerMap) {
39573
+ var preTriggerName = preTriggerMap[name];
39574
+ var preTriggerArgs = {
39575
+ prevented: false,
39576
+ name: name,
39577
+ args: args
39578
+ };
39579
+
39580
+ actualTrigger.call(this, preTriggerName, preTriggerArgs);
39581
+
39582
+ if (preTriggerArgs.prevented) {
39583
+ args.prevented = true;
39584
+
39585
+ return;
39586
+ }
39587
+ }
39588
+
39589
+ actualTrigger.call(this, name, args);
39590
+ };
39591
+
39592
+ Select2.prototype.toggleDropdown = function () {
39593
+ if (this.options.get('disabled')) {
39594
+ return;
39595
+ }
39596
+
39597
+ if (this.isOpen()) {
39598
+ this.close();
39599
+ } else {
39600
+ this.open();
39601
+ }
39602
+ };
39603
+
39604
+ Select2.prototype.open = function () {
39605
+ if (this.isOpen()) {
39606
+ return;
39607
+ }
39608
+
39609
+ this.trigger('query', {});
39610
+ };
39611
+
39612
+ Select2.prototype.close = function () {
39613
+ if (!this.isOpen()) {
39614
+ return;
39615
+ }
39616
+
39617
+ this.trigger('close', {});
39618
+ };
39619
+
39620
+ Select2.prototype.isOpen = function () {
39621
+ return this.$container.hasClass('select2-container--open');
39622
+ };
39623
+
39624
+ Select2.prototype.hasFocus = function () {
39625
+ return this.$container.hasClass('select2-container--focus');
39626
+ };
39627
+
39628
+ Select2.prototype.focus = function (data) {
39629
+ // No need to re-trigger focus events if we are already focused
39630
+ if (this.hasFocus()) {
39631
+ return;
39632
+ }
39633
+
39634
+ this.$container.addClass('select2-container--focus');
39635
+ this.trigger('focus', {});
39636
+ };
39637
+
39638
+ Select2.prototype.enable = function (args) {
39639
+ if (this.options.get('debug') && window.console && console.warn) {
39640
+ console.warn(
39641
+ 'Select2: The `select2("enable")` method has been deprecated and will' +
39642
+ ' be removed in later Select2 versions. Use $element.prop("disabled")' +
39643
+ ' instead.'
39644
+ );
39645
+ }
39646
+
39647
+ if (args == null || args.length === 0) {
39648
+ args = [true];
39649
+ }
39650
+
39651
+ var disabled = !args[0];
39652
+
39653
+ this.$element.prop('disabled', disabled);
39654
+ };
39655
+
39656
+ Select2.prototype.data = function () {
39657
+ if (this.options.get('debug') &&
39658
+ arguments.length > 0 && window.console && console.warn) {
39659
+ console.warn(
39660
+ 'Select2: Data can no longer be set using `select2("data")`. You ' +
39661
+ 'should consider setting the value instead using `$element.val()`.'
39662
+ );
39663
+ }
39664
+
39665
+ var data = [];
39666
+
39667
+ this.dataAdapter.current(function (currentData) {
39668
+ data = currentData;
39669
+ });
39670
+
39671
+ return data;
39672
+ };
39673
+
39674
+ Select2.prototype.val = function (args) {
39675
+ if (this.options.get('debug') && window.console && console.warn) {
39676
+ console.warn(
39677
+ 'Select2: The `select2("val")` method has been deprecated and will be' +
39678
+ ' removed in later Select2 versions. Use $element.val() instead.'
39679
+ );
39680
+ }
39681
+
39682
+ if (args == null || args.length === 0) {
39683
+ return this.$element.val();
39684
+ }
39685
+
39686
+ var newVal = args[0];
39687
+
39688
+ if ($.isArray(newVal)) {
39689
+ newVal = $.map(newVal, function (obj) {
39690
+ return obj.toString();
39691
+ });
39692
+ }
39693
+
39694
+ this.$element.val(newVal).trigger('change');
39695
+ };
39696
+
39697
+ Select2.prototype.destroy = function () {
39698
+ this.$container.remove();
39699
+
39700
+ if (this.$element[0].detachEvent) {
39701
+ this.$element[0].detachEvent('onpropertychange', this._syncA);
39702
+ }
39703
+
39704
+ if (this._observer != null) {
39705
+ this._observer.disconnect();
39706
+ this._observer = null;
39707
+ } else if (this.$element[0].removeEventListener) {
39708
+ this.$element[0]
39709
+ .removeEventListener('DOMAttrModified', this._syncA, false);
39710
+ this.$element[0]
39711
+ .removeEventListener('DOMNodeInserted', this._syncS, false);
39712
+ this.$element[0]
39713
+ .removeEventListener('DOMNodeRemoved', this._syncS, false);
39714
+ }
39715
+
39716
+ this._syncA = null;
39717
+ this._syncS = null;
39718
+
39719
+ this.$element.off('.select2');
39720
+ this.$element.attr('tabindex', this.$element.data('old-tabindex'));
39721
+
39722
+ this.$element.removeClass('select2-hidden-accessible');
39723
+ this.$element.attr('aria-hidden', 'false');
39724
+ this.$element.removeData('select2');
39725
+
39726
+ this.dataAdapter.destroy();
39727
+ this.selection.destroy();
39728
+ this.dropdown.destroy();
39729
+ this.results.destroy();
39730
+
39731
+ this.dataAdapter = null;
39732
+ this.selection = null;
39733
+ this.dropdown = null;
39734
+ this.results = null;
39735
+ };
39736
+
39737
+ Select2.prototype.render = function () {
39738
+ var $container = $(
39739
+ '<span class="select2 select2-container">' +
39740
+ '<span class="selection"></span>' +
39741
+ '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
39742
+ '</span>'
39743
+ );
39744
+
39745
+ $container.attr('dir', this.options.get('dir'));
39746
+
39747
+ this.$container = $container;
39748
+
39749
+ this.$container.addClass('select2-container--' + this.options.get('theme'));
39750
+
39751
+ $container.data('element', this.$element);
39752
+
39753
+ return $container;
39754
+ };
39755
+
39756
+ return Select2;
39757
+ });
39758
+
39759
+ S2.define('jquery-mousewheel',[
39760
+ 'jquery'
39761
+ ], function ($) {
39762
+ // Used to shim jQuery.mousewheel for non-full builds.
39763
+ return $;
39764
+ });
39765
+
39766
+ S2.define('jquery.select2',[
39767
+ 'jquery',
39768
+ 'jquery-mousewheel',
39769
+
39770
+ './select2/core',
39771
+ './select2/defaults'
39772
+ ], function ($, _, Select2, Defaults) {
39773
+ if ($.fn.select2 == null) {
39774
+ // All methods that should return the element
39775
+ var thisMethods = ['open', 'close', 'destroy'];
39776
+
39777
+ $.fn.select2 = function (options) {
39778
+ options = options || {};
39779
+
39780
+ if (typeof options === 'object') {
39781
+ this.each(function () {
39782
+ var instanceOptions = $.extend(true, {}, options);
39783
+
39784
+ var instance = new Select2($(this), instanceOptions);
39785
+ });
39786
+
39787
+ return this;
39788
+ } else if (typeof options === 'string') {
39789
+ var ret;
39790
+ var args = Array.prototype.slice.call(arguments, 1);
39791
+
39792
+ this.each(function () {
39793
+ var instance = $(this).data('select2');
39794
+
39795
+ if (instance == null && window.console && console.error) {
39796
+ console.error(
39797
+ 'The select2(\'' + options + '\') method was called on an ' +
39798
+ 'element that is not using Select2.'
39799
+ );
39800
+ }
39801
+
39802
+ ret = instance[options].apply(instance, args);
39803
+ });
39804
+
39805
+ // Check if we should be returning `this`
39806
+ if ($.inArray(options, thisMethods) > -1) {
39807
+ return this;
39808
+ }
39809
+
39810
+ return ret;
39811
+ } else {
39812
+ throw new Error('Invalid arguments for Select2: ' + options);
39813
+ }
39814
+ };
39815
+ }
39816
+
39817
+ if ($.fn.select2.defaults == null) {
39818
+ $.fn.select2.defaults = Defaults;
39819
+ }
39820
+
39821
+ return Select2;
39822
+ });
39823
+
39824
+ // Return the AMD loader configuration so it can be used outside of this file
39825
+ return {
39826
+ define: S2.define,
39827
+ require: S2.require
39828
+ };
39829
+ }());
39830
+
39831
+ // Autoload the jQuery bindings
39832
+ // We know that all of the modules exist above this, so we're safe
39833
+ var select2 = S2.require('jquery.select2');
39834
+
39835
+ // Hold the AMD module references on the jQuery function that was just loaded
39836
+ // This allows Select2 to use the internal loader outside of this file, such
39837
+ // as in the language files.
39838
+ jQuery.fn.select2.amd = S2;
39839
+
39840
+ // Return the Select2 instance for anyone who is importing it.
39841
+ return select2;
39842
+ }));
39843
 
39844
 
39845
  /***/ },
39892
  this.loadItem(this.props.params.id);
39893
  } else {
39894
  this.setState({
39895
+ item: jQuery('.mailpoet_form').mailpoetSerializeObject()
39896
  });
39897
  }
39898
  }
assets/js/{form_editor.28c23e1a.js → form_editor.612beb34.js} RENAMED
@@ -1083,7 +1083,7 @@ webpackJsonp([2],{
1083
  template: window.jQuery('#form_template_field_settings').html(),
1084
  data: this.getData(),
1085
  onSuccess: function () {
1086
- var data = window.jQuery('#form_field_settings').serializeObject();
1087
  this.redraw(data);
1088
  }.bind(this)
1089
  });
1083
  template: window.jQuery('#form_template_field_settings').html(),
1084
  data: this.getData(),
1085
  onSuccess: function () {
1086
+ var data = window.jQuery('#form_field_settings').mailpoetSerializeObject();
1087
  this.redraw(data);
1088
  }.bind(this)
1089
  });
assets/js/{mailpoet.6fead39d.js → mailpoet.3dd11c86.js} RENAMED
@@ -51481,7 +51481,7 @@ webpackJsonp([3],[
51481
  * Dual licensed under the MIT and GPL licenses.
51482
  * http://benalman.com/about/license/
51483
  */
51484
- $.fn.serializeObject = function (coerce) {
51485
  var obj = {};
51486
  var coerce_types = { true: !0, false: !1, null: null };
51487
 
51481
  * Dual licensed under the MIT and GPL licenses.
51482
  * http://benalman.com/about/license/
51483
  */
51484
+ $.fn.mailpoetSerializeObject = function (coerce) {
51485
  var obj = {};
51486
  var coerce_types = { true: !0, false: !1, null: null };
51487
 
assets/js/manifest.json CHANGED
@@ -1,10 +1,10 @@
1
  {
2
  "mp2migrator.js": "mp2migrator.e755af46.js",
3
- "public.js": "public.820cdc99.js",
4
- "admin.js": "admin.7f0a02d1.js",
5
- "admin_vendor.js": "admin_vendor.fa2d1dd7.js",
6
- "form_editor.js": "form_editor.28c23e1a.js",
7
- "mailpoet.js": "mailpoet.6fead39d.js",
8
- "newsletter_editor.js": "newsletter_editor.e7c440c6.js",
9
- "vendor.js": "vendor.f03e722d.js"
10
  }
1
  {
2
  "mp2migrator.js": "mp2migrator.e755af46.js",
3
+ "public.js": "public.8173fe64.js",
4
+ "admin.js": "admin.912a26a8.js",
5
+ "admin_vendor.js": "admin_vendor.66f57ed3.js",
6
+ "form_editor.js": "form_editor.612beb34.js",
7
+ "mailpoet.js": "mailpoet.3dd11c86.js",
8
+ "newsletter_editor.js": "newsletter_editor.c4722da5.js",
9
+ "vendor.js": "vendor.17b09b6c.js"
10
  }
assets/js/{newsletter_editor.e7c440c6.js → newsletter_editor.c4722da5.js} RENAMED
@@ -1746,5752 +1746,5752 @@ webpackJsonp([4],{
1746
  /***/ 289:
1747
  /***/ function(module, exports, __webpack_require__) {
1748
 
1749
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;var require;/*!
1750
- * Select2 4.0.4
1751
- * https://select2.github.io
1752
- *
1753
- * Released under the MIT license
1754
- * https://github.com/select2/select2/blob/master/LICENSE.md
1755
- */
1756
- (function (factory) {
1757
- if (true) {
1758
- // AMD. Register as an anonymous module.
1759
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(275)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
1760
- } else if (typeof module === 'object' && module.exports) {
1761
- // Node/CommonJS
1762
- module.exports = function (root, jQuery) {
1763
- if (jQuery === undefined) {
1764
- // require('jQuery') returns a factory that requires window to
1765
- // build a jQuery instance, we normalize how we use modules
1766
- // that require this pattern but the window provided is a noop
1767
- // if it's defined (how jquery works)
1768
- if (typeof window !== 'undefined') {
1769
- jQuery = require('jquery');
1770
- }
1771
- else {
1772
- jQuery = require('jquery')(root);
1773
- }
1774
- }
1775
- factory(jQuery);
1776
- return jQuery;
1777
- };
1778
- } else {
1779
- // Browser globals
1780
- factory(jQuery);
1781
- }
1782
- } (function (jQuery) {
1783
- // This is needed so we can catch the AMD loader configuration and use it
1784
- // The inner file should be wrapped (by `banner.start.js`) in a function that
1785
- // returns the AMD loader references.
1786
- var S2 =(function () {
1787
- // Restore the Select2 AMD loader so it can be used
1788
- // Needed mostly in the language files, where the loader is not inserted
1789
- if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
1790
- var S2 = jQuery.fn.select2.amd;
1791
- }
1792
- var S2;(function () { if (!S2 || !S2.requirejs) {
1793
- if (!S2) { S2 = {}; } else { require = S2; }
1794
- /**
1795
- * @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
1796
- * Released under MIT license, http://github.com/requirejs/almond/LICENSE
1797
- */
1798
- //Going sloppy to avoid 'use strict' string cost, but strict practices should
1799
- //be followed.
1800
- /*global setTimeout: false */
1801
-
1802
- var requirejs, require, define;
1803
- (function (undef) {
1804
- var main, req, makeMap, handlers,
1805
- defined = {},
1806
- waiting = {},
1807
- config = {},
1808
- defining = {},
1809
- hasOwn = Object.prototype.hasOwnProperty,
1810
- aps = [].slice,
1811
- jsSuffixRegExp = /\.js$/;
1812
-
1813
- function hasProp(obj, prop) {
1814
- return hasOwn.call(obj, prop);
1815
- }
1816
-
1817
- /**
1818
- * Given a relative module name, like ./something, normalize it to
1819
- * a real name that can be mapped to a path.
1820
- * @param {String} name the relative name
1821
- * @param {String} baseName a real name that the name arg is relative
1822
- * to.
1823
- * @returns {String} normalized name
1824
- */
1825
- function normalize(name, baseName) {
1826
- var nameParts, nameSegment, mapValue, foundMap, lastIndex,
1827
- foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
1828
- baseParts = baseName && baseName.split("/"),
1829
- map = config.map,
1830
- starMap = (map && map['*']) || {};
1831
-
1832
- //Adjust any relative paths.
1833
- if (name) {
1834
- name = name.split('/');
1835
- lastIndex = name.length - 1;
1836
-
1837
- // If wanting node ID compatibility, strip .js from end
1838
- // of IDs. Have to do this here, and not in nameToUrl
1839
- // because node allows either .js or non .js to map
1840
- // to same file.
1841
- if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
1842
- name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
1843
- }
1844
-
1845
- // Starts with a '.' so need the baseName
1846
- if (name[0].charAt(0) === '.' && baseParts) {
1847
- //Convert baseName to array, and lop off the last part,
1848
- //so that . matches that 'directory' and not name of the baseName's
1849
- //module. For instance, baseName of 'one/two/three', maps to
1850
- //'one/two/three.js', but we want the directory, 'one/two' for
1851
- //this normalization.
1852
- normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
1853
- name = normalizedBaseParts.concat(name);
1854
- }
1855
-
1856
- //start trimDots
1857
- for (i = 0; i < name.length; i++) {
1858
- part = name[i];
1859
- if (part === '.') {
1860
- name.splice(i, 1);
1861
- i -= 1;
1862
- } else if (part === '..') {
1863
- // If at the start, or previous value is still ..,
1864
- // keep them so that when converted to a path it may
1865
- // still work when converted to a path, even though
1866
- // as an ID it is less than ideal. In larger point
1867
- // releases, may be better to just kick out an error.
1868
- if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
1869
- continue;
1870
- } else if (i > 0) {
1871
- name.splice(i - 1, 2);
1872
- i -= 2;
1873
- }
1874
- }
1875
- }
1876
- //end trimDots
1877
-
1878
- name = name.join('/');
1879
- }
1880
-
1881
- //Apply map config if available.
1882
- if ((baseParts || starMap) && map) {
1883
- nameParts = name.split('/');
1884
-
1885
- for (i = nameParts.length; i > 0; i -= 1) {
1886
- nameSegment = nameParts.slice(0, i).join("/");
1887
-
1888
- if (baseParts) {
1889
- //Find the longest baseName segment match in the config.
1890
- //So, do joins on the biggest to smallest lengths of baseParts.
1891
- for (j = baseParts.length; j > 0; j -= 1) {
1892
- mapValue = map[baseParts.slice(0, j).join('/')];
1893
-
1894
- //baseName segment has config, find if it has one for
1895
- //this name.
1896
- if (mapValue) {
1897
- mapValue = mapValue[nameSegment];
1898
- if (mapValue) {
1899
- //Match, update name to the new value.
1900
- foundMap = mapValue;
1901
- foundI = i;
1902
- break;
1903
- }
1904
- }
1905
- }
1906
- }
1907
-
1908
- if (foundMap) {
1909
- break;
1910
- }
1911
-
1912
- //Check for a star map match, but just hold on to it,
1913
- //if there is a shorter segment match later in a matching
1914
- //config, then favor over this star map.
1915
- if (!foundStarMap && starMap && starMap[nameSegment]) {
1916
- foundStarMap = starMap[nameSegment];
1917
- starI = i;
1918
- }
1919
- }
1920
-
1921
- if (!foundMap && foundStarMap) {
1922
- foundMap = foundStarMap;
1923
- foundI = starI;
1924
- }
1925
-
1926
- if (foundMap) {
1927
- nameParts.splice(0, foundI, foundMap);
1928
- name = nameParts.join('/');
1929
- }
1930
- }
1931
-
1932
- return name;
1933
- }
1934
-
1935
- function makeRequire(relName, forceSync) {
1936
- return function () {
1937
- //A version of a require function that passes a moduleName
1938
- //value for items that may need to
1939
- //look up paths relative to the moduleName
1940
- var args = aps.call(arguments, 0);
1941
-
1942
- //If first arg is not require('string'), and there is only
1943
- //one arg, it is the array form without a callback. Insert
1944
- //a null so that the following concat is correct.
1945
- if (typeof args[0] !== 'string' && args.length === 1) {
1946
- args.push(null);
1947
- }
1948
- return req.apply(undef, args.concat([relName, forceSync]));
1949
- };
1950
- }
1951
-
1952
- function makeNormalize(relName) {
1953
- return function (name) {
1954
- return normalize(name, relName);
1955
- };
1956
- }
1957
-
1958
- function makeLoad(depName) {
1959
- return function (value) {
1960
- defined[depName] = value;
1961
- };
1962
- }
1963
-
1964
- function callDep(name) {
1965
- if (hasProp(waiting, name)) {
1966
- var args = waiting[name];
1967
- delete waiting[name];
1968
- defining[name] = true;
1969
- main.apply(undef, args);
1970
- }
1971
-
1972
- if (!hasProp(defined, name) && !hasProp(defining, name)) {
1973
- throw new Error('No ' + name);
1974
- }
1975
- return defined[name];
1976
- }
1977
-
1978
- //Turns a plugin!resource to [plugin, resource]
1979
- //with the plugin being undefined if the name
1980
- //did not have a plugin prefix.
1981
- function splitPrefix(name) {
1982
- var prefix,
1983
- index = name ? name.indexOf('!') : -1;
1984
- if (index > -1) {
1985
- prefix = name.substring(0, index);
1986
- name = name.substring(index + 1, name.length);
1987
- }
1988
- return [prefix, name];
1989
- }
1990
-
1991
- //Creates a parts array for a relName where first part is plugin ID,
1992
- //second part is resource ID. Assumes relName has already been normalized.
1993
- function makeRelParts(relName) {
1994
- return relName ? splitPrefix(relName) : [];
1995
- }
1996
-
1997
- /**
1998
- * Makes a name map, normalizing the name, and using a plugin
1999
- * for normalization if necessary. Grabs a ref to plugin
2000
- * too, as an optimization.
2001
- */
2002
- makeMap = function (name, relParts) {
2003
- var plugin,
2004
- parts = splitPrefix(name),
2005
- prefix = parts[0],
2006
- relResourceName = relParts[1];
2007
-
2008
- name = parts[1];
2009
-
2010
- if (prefix) {
2011
- prefix = normalize(prefix, relResourceName);
2012
- plugin = callDep(prefix);
2013
- }
2014
-
2015
- //Normalize according
2016
- if (prefix) {
2017
- if (plugin && plugin.normalize) {
2018
- name = plugin.normalize(name, makeNormalize(relResourceName));
2019
- } else {
2020
- name = normalize(name, relResourceName);
2021
- }
2022
- } else {
2023
- name = normalize(name, relResourceName);
2024
- parts = splitPrefix(name);
2025
- prefix = parts[0];
2026
- name = parts[1];
2027
- if (prefix) {
2028
- plugin = callDep(prefix);
2029
- }
2030
- }
2031
-
2032
- //Using ridiculous property names for space reasons
2033
- return {
2034
- f: prefix ? prefix + '!' + name : name, //fullName
2035
- n: name,
2036
- pr: prefix,
2037
- p: plugin
2038
- };
2039
- };
2040
-
2041
- function makeConfig(name) {
2042
- return function () {
2043
- return (config && config.config && config.config[name]) || {};
2044
- };
2045
- }
2046
-
2047
- handlers = {
2048
- require: function (name) {
2049
- return makeRequire(name);
2050
- },
2051
- exports: function (name) {
2052
- var e = defined[name];
2053
- if (typeof e !== 'undefined') {
2054
- return e;
2055
- } else {
2056
- return (defined[name] = {});
2057
- }
2058
- },
2059
- module: function (name) {
2060
- return {
2061
- id: name,
2062
- uri: '',
2063
- exports: defined[name],
2064
- config: makeConfig(name)
2065
- };
2066
- }
2067
- };
2068
-
2069
- main = function (name, deps, callback, relName) {
2070
- var cjsModule, depName, ret, map, i, relParts,
2071
- args = [],
2072
- callbackType = typeof callback,
2073
- usingExports;
2074
-
2075
- //Use name if no relName
2076
- relName = relName || name;
2077
- relParts = makeRelParts(relName);
2078
-
2079
- //Call the callback to define the module, if necessary.
2080
- if (callbackType === 'undefined' || callbackType === 'function') {
2081
- //Pull out the defined dependencies and pass the ordered
2082
- //values to the callback.
2083
- //Default to [require, exports, module] if no deps
2084
- deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
2085
- for (i = 0; i < deps.length; i += 1) {
2086
- map = makeMap(deps[i], relParts);
2087
- depName = map.f;
2088
-
2089
- //Fast path CommonJS standard dependencies.
2090
- if (depName === "require") {
2091
- args[i] = handlers.require(name);
2092
- } else if (depName === "exports") {
2093
- //CommonJS module spec 1.1
2094
- args[i] = handlers.exports(name);
2095
- usingExports = true;
2096
- } else if (depName === "module") {
2097
- //CommonJS module spec 1.1
2098
- cjsModule = args[i] = handlers.module(name);
2099
- } else if (hasProp(defined, depName) ||
2100
- hasProp(waiting, depName) ||
2101
- hasProp(defining, depName)) {
2102
- args[i] = callDep(depName);
2103
- } else if (map.p) {
2104
- map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
2105
- args[i] = defined[depName];
2106
- } else {
2107
- throw new Error(name + ' missing ' + depName);
2108
- }
2109
- }
2110
-
2111
- ret = callback ? callback.apply(defined[name], args) : undefined;
2112
-
2113
- if (name) {
2114
- //If setting exports via "module" is in play,
2115
- //favor that over return value and exports. After that,
2116
- //favor a non-undefined return value over exports use.
2117
- if (cjsModule && cjsModule.exports !== undef &&
2118
- cjsModule.exports !== defined[name]) {
2119
- defined[name] = cjsModule.exports;
2120
- } else if (ret !== undef || !usingExports) {
2121
- //Use the return value from the function.
2122
- defined[name] = ret;
2123
- }
2124
- }
2125
- } else if (name) {
2126
- //May just be an object definition for the module. Only
2127
- //worry about defining if have a module name.
2128
- defined[name] = callback;
2129
- }
2130
- };
2131
-
2132
- requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
2133
- if (typeof deps === "string") {
2134
- if (handlers[deps]) {
2135
- //callback in this case is really relName
2136
- return handlers[deps](callback);
2137
- }
2138
- //Just return the module wanted. In this scenario, the
2139
- //deps arg is the module name, and second arg (if passed)
2140
- //is just the relName.
2141
- //Normalize module name, if it contains . or ..
2142
- return callDep(makeMap(deps, makeRelParts(callback)).f);
2143
- } else if (!deps.splice) {
2144
- //deps is a config object, not an array.
2145
- config = deps;
2146
- if (config.deps) {
2147
- req(config.deps, config.callback);
2148
- }
2149
- if (!callback) {
2150
- return;
2151
- }
2152
-
2153
- if (callback.splice) {
2154
- //callback is an array, which means it is a dependency list.
2155
- //Adjust args if there are dependencies
2156
- deps = callback;
2157
- callback = relName;
2158
- relName = null;
2159
- } else {
2160
- deps = undef;
2161
- }
2162
- }
2163
-
2164
- //Support require(['a'])
2165
- callback = callback || function () {};
2166
-
2167
- //If relName is a function, it is an errback handler,
2168
- //so remove it.
2169
- if (typeof relName === 'function') {
2170
- relName = forceSync;
2171
- forceSync = alt;
2172
- }
2173
-
2174
- //Simulate async callback;
2175
- if (forceSync) {
2176
- main(undef, deps, callback, relName);
2177
- } else {
2178
- //Using a non-zero value because of concern for what old browsers
2179
- //do, and latest browsers "upgrade" to 4 if lower value is used:
2180
- //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
2181
- //If want a value immediately, use require('id') instead -- something
2182
- //that works in almond on the global level, but not guaranteed and
2183
- //unlikely to work in other AMD implementations.
2184
- setTimeout(function () {
2185
- main(undef, deps, callback, relName);
2186
- }, 4);
2187
- }
2188
-
2189
- return req;
2190
- };
2191
-
2192
- /**
2193
- * Just drops the config on the floor, but returns req in case
2194
- * the config return value is used.
2195
- */
2196
- req.config = function (cfg) {
2197
- return req(cfg);
2198
- };
2199
-
2200
- /**
2201
- * Expose module registry for debugging and tooling
2202
- */
2203
- requirejs._defined = defined;
2204
-
2205
- define = function (name, deps, callback) {
2206
- if (typeof name !== 'string') {
2207
- throw new Error('See almond README: incorrect module build, no module name');
2208
- }
2209
-
2210
- //This module may not have dependencies
2211
- if (!deps.splice) {
2212
- //deps is not an array, so probably means
2213
- //an object literal or factory function for
2214
- //the value. Adjust args.
2215
- callback = deps;
2216
- deps = [];
2217
- }
2218
-
2219
- if (!hasProp(defined, name) && !hasProp(waiting, name)) {
2220
- waiting[name] = [name, deps, callback];
2221
- }
2222
- };
2223
-
2224
- define.amd = {
2225
- jQuery: true
2226
- };
2227
- }());
2228
-
2229
- S2.requirejs = requirejs;S2.require = require;S2.define = define;
2230
- }
2231
- }());
2232
- S2.define("almond", function(){});
2233
-
2234
- /* global jQuery:false, $:false */
2235
- S2.define('jquery',[],function () {
2236
- var _$ = jQuery || $;
2237
-
2238
- if (_$ == null && console && console.error) {
2239
- console.error(
2240
- 'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
2241
- 'found. Make sure that you are including jQuery before Select2 on your ' +
2242
- 'web page.'
2243
- );
2244
- }
2245
-
2246
- return _$;
2247
- });
2248
-
2249
- S2.define('select2/utils',[
2250
- 'jquery'
2251
- ], function ($) {
2252
- var Utils = {};
2253
-
2254
- Utils.Extend = function (ChildClass, SuperClass) {
2255
- var __hasProp = {}.hasOwnProperty;
2256
-
2257
- function BaseConstructor () {
2258
- this.constructor = ChildClass;
2259
- }
2260
-
2261
- for (var key in SuperClass) {
2262
- if (__hasProp.call(SuperClass, key)) {
2263
- ChildClass[key] = SuperClass[key];
2264
- }
2265
- }
2266
-
2267
- BaseConstructor.prototype = SuperClass.prototype;
2268
- ChildClass.prototype = new BaseConstructor();
2269
- ChildClass.__super__ = SuperClass.prototype;
2270
-
2271
- return ChildClass;
2272
- };
2273
-
2274
- function getMethods (theClass) {
2275
- var proto = theClass.prototype;
2276
-
2277
- var methods = [];
2278
-
2279
- for (var methodName in proto) {
2280
- var m = proto[methodName];
2281
-
2282
- if (typeof m !== 'function') {
2283
- continue;
2284
- }
2285
-
2286
- if (methodName === 'constructor') {
2287
- continue;
2288
- }
2289
-
2290
- methods.push(methodName);
2291
- }
2292
-
2293
- return methods;
2294
- }
2295
-
2296
- Utils.Decorate = function (SuperClass, DecoratorClass) {
2297
- var decoratedMethods = getMethods(DecoratorClass);
2298
- var superMethods = getMethods(SuperClass);
2299
-
2300
- function DecoratedClass () {
2301
- var unshift = Array.prototype.unshift;
2302
-
2303
- var argCount = DecoratorClass.prototype.constructor.length;
2304
-
2305
- var calledConstructor = SuperClass.prototype.constructor;
2306
-
2307
- if (argCount > 0) {
2308
- unshift.call(arguments, SuperClass.prototype.constructor);
2309
-
2310
- calledConstructor = DecoratorClass.prototype.constructor;
2311
- }
2312
-
2313
- calledConstructor.apply(this, arguments);
2314
- }
2315
-
2316
- DecoratorClass.displayName = SuperClass.displayName;
2317
-
2318
- function ctr () {
2319
- this.constructor = DecoratedClass;
2320
- }
2321
-
2322
- DecoratedClass.prototype = new ctr();
2323
-
2324
- for (var m = 0; m < superMethods.length; m++) {
2325
- var superMethod = superMethods[m];
2326
-
2327
- DecoratedClass.prototype[superMethod] =
2328
- SuperClass.prototype[superMethod];
2329
- }
2330
-
2331
- var calledMethod = function (methodName) {
2332
- // Stub out the original method if it's not decorating an actual method
2333
- var originalMethod = function () {};
2334
-
2335
- if (methodName in DecoratedClass.prototype) {
2336
- originalMethod = DecoratedClass.prototype[methodName];
2337
- }
2338
-
2339
- var decoratedMethod = DecoratorClass.prototype[methodName];
2340
-
2341
- return function () {
2342
- var unshift = Array.prototype.unshift;
2343
-
2344
- unshift.call(arguments, originalMethod);
2345
-
2346
- return decoratedMethod.apply(this, arguments);
2347
- };
2348
- };
2349
-
2350
- for (var d = 0; d < decoratedMethods.length; d++) {
2351
- var decoratedMethod = decoratedMethods[d];
2352
-
2353
- DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
2354
- }
2355
-
2356
- return DecoratedClass;
2357
- };
2358
-
2359
- var Observable = function () {
2360
- this.listeners = {};
2361
- };
2362
-
2363
- Observable.prototype.on = function (event, callback) {
2364
- this.listeners = this.listeners || {};
2365
-
2366
- if (event in this.listeners) {
2367
- this.listeners[event].push(callback);
2368
- } else {
2369
- this.listeners[event] = [callback];
2370
- }
2371
- };
2372
-
2373
- Observable.prototype.trigger = function (event) {
2374
- var slice = Array.prototype.slice;
2375
- var params = slice.call(arguments, 1);
2376
-
2377
- this.listeners = this.listeners || {};
2378
-
2379
- // Params should always come in as an array
2380
- if (params == null) {
2381
- params = [];
2382
- }
2383
-
2384
- // If there are no arguments to the event, use a temporary object
2385
- if (params.length === 0) {
2386
- params.push({});
2387
- }
2388
-
2389
- // Set the `_type` of the first object to the event
2390
- params[0]._type = event;
2391
-
2392
- if (event in this.listeners) {
2393
- this.invoke(this.listeners[event], slice.call(arguments, 1));
2394
- }
2395
-
2396
- if ('*' in this.listeners) {
2397
- this.invoke(this.listeners['*'], arguments);
2398
- }
2399
- };
2400
-
2401
- Observable.prototype.invoke = function (listeners, params) {
2402
- for (var i = 0, len = listeners.length; i < len; i++) {
2403
- listeners[i].apply(this, params);
2404
- }
2405
- };
2406
-
2407
- Utils.Observable = Observable;
2408
-
2409
- Utils.generateChars = function (length) {
2410
- var chars = '';
2411
-
2412
- for (var i = 0; i < length; i++) {
2413
- var randomChar = Math.floor(Math.random() * 36);
2414
- chars += randomChar.toString(36);
2415
- }
2416
-
2417
- return chars;
2418
- };
2419
-
2420
- Utils.bind = function (func, context) {
2421
- return function () {
2422
- func.apply(context, arguments);
2423
- };
2424
- };
2425
-
2426
- Utils._convertData = function (data) {
2427
- for (var originalKey in data) {
2428
- var keys = originalKey.split('-');
2429
-
2430
- var dataLevel = data;
2431
-
2432
- if (keys.length === 1) {
2433
- continue;
2434
- }
2435
-
2436
- for (var k = 0; k < keys.length; k++) {
2437
- var key = keys[k];
2438
-
2439
- // Lowercase the first letter
2440
- // By default, dash-separated becomes camelCase
2441
- key = key.substring(0, 1).toLowerCase() + key.substring(1);
2442
-
2443
- if (!(key in dataLevel)) {
2444
- dataLevel[key] = {};
2445
- }
2446
-
2447
- if (k == keys.length - 1) {
2448
- dataLevel[key] = data[originalKey];
2449
- }
2450
-
2451
- dataLevel = dataLevel[key];
2452
- }
2453
-
2454
- delete data[originalKey];
2455
- }
2456
-
2457
- return data;
2458
- };
2459
-
2460
- Utils.hasScroll = function (index, el) {
2461
- // Adapted from the function created by @ShadowScripter
2462
- // and adapted by @BillBarry on the Stack Exchange Code Review website.
2463
- // The original code can be found at
2464
- // http://codereview.stackexchange.com/q/13338
2465
- // and was designed to be used with the Sizzle selector engine.
2466
-
2467
- var $el = $(el);
2468
- var overflowX = el.style.overflowX;
2469
- var overflowY = el.style.overflowY;
2470
-
2471
- //Check both x and y declarations
2472
- if (overflowX === overflowY &&
2473
- (overflowY === 'hidden' || overflowY === 'visible')) {
2474
- return false;
2475
- }
2476
-
2477
- if (overflowX === 'scroll' || overflowY === 'scroll') {
2478
- return true;
2479
- }
2480
-
2481
- return ($el.innerHeight() < el.scrollHeight ||
2482
- $el.innerWidth() < el.scrollWidth);
2483
- };
2484
-
2485
- Utils.escapeMarkup = function (markup) {
2486
- var replaceMap = {
2487
- '\\': '&#92;',
2488
- '&': '&amp;',
2489
- '<': '&lt;',
2490
- '>': '&gt;',
2491
- '"': '&quot;',
2492
- '\'': '&#39;',
2493
- '/': '&#47;'
2494
- };
2495
-
2496
- // Do not try to escape the markup if it's not a string
2497
- if (typeof markup !== 'string') {
2498
- return markup;
2499
- }
2500
-
2501
- return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
2502
- return replaceMap[match];
2503
- });
2504
- };
2505
-
2506
- // Append an array of jQuery nodes to a given element.
2507
- Utils.appendMany = function ($element, $nodes) {
2508
- // jQuery 1.7.x does not support $.fn.append() with an array
2509
- // Fall back to a jQuery object collection using $.fn.add()
2510
- if ($.fn.jquery.substr(0, 3) === '1.7') {
2511
- var $jqNodes = $();
2512
-
2513
- $.map($nodes, function (node) {
2514
- $jqNodes = $jqNodes.add(node);
2515
- });
2516
-
2517
- $nodes = $jqNodes;
2518
- }
2519
-
2520
- $element.append($nodes);
2521
- };
2522
-
2523
- return Utils;
2524
- });
2525
-
2526
- S2.define('select2/results',[
2527
- 'jquery',
2528
- './utils'
2529
- ], function ($, Utils) {
2530
- function Results ($element, options, dataAdapter) {
2531
- this.$element = $element;
2532
- this.data = dataAdapter;
2533
- this.options = options;
2534
-
2535
- Results.__super__.constructor.call(this);
2536
- }
2537
-
2538
- Utils.Extend(Results, Utils.Observable);
2539
-
2540
- Results.prototype.render = function () {
2541
- var $results = $(
2542
- '<ul class="select2-results__options" role="tree"></ul>'
2543
- );
2544
-
2545
- if (this.options.get('multiple')) {
2546
- $results.attr('aria-multiselectable', 'true');
2547
- }
2548
-
2549
- this.$results = $results;
2550
-
2551
- return $results;
2552
- };
2553
-
2554
- Results.prototype.clear = function () {
2555
- this.$results.empty();
2556
- };
2557
-
2558
- Results.prototype.displayMessage = function (params) {
2559
- var escapeMarkup = this.options.get('escapeMarkup');
2560
-
2561
- this.clear();
2562
- this.hideLoading();
2563
-
2564
- var $message = $(
2565
- '<li role="treeitem" aria-live="assertive"' +
2566
- ' class="select2-results__option"></li>'
2567
- );
2568
-
2569
- var message = this.options.get('translations').get(params.message);
2570
-
2571
- $message.append(
2572
- escapeMarkup(
2573
- message(params.args)
2574
- )
2575
- );
2576
-
2577
- $message[0].className += ' select2-results__message';
2578
-
2579
- this.$results.append($message);
2580
- };
2581
-
2582
- Results.prototype.hideMessages = function () {
2583
- this.$results.find('.select2-results__message').remove();
2584
- };
2585
-
2586
- Results.prototype.append = function (data) {
2587
- this.hideLoading();
2588
-
2589
- var $options = [];
2590
-
2591
- if (data.results == null || data.results.length === 0) {
2592
- if (this.$results.children().length === 0) {
2593
- this.trigger('results:message', {
2594
- message: 'noResults'
2595
- });
2596
- }
2597
-
2598
- return;
2599
- }
2600
-
2601
- data.results = this.sort(data.results);
2602
-
2603
- for (var d = 0; d < data.results.length; d++) {
2604
- var item = data.results[d];
2605
-
2606
- var $option = this.option(item);
2607
-
2608
- $options.push($option);
2609
- }
2610
-
2611
- this.$results.append($options);
2612
- };
2613
-
2614
- Results.prototype.position = function ($results, $dropdown) {
2615
- var $resultsContainer = $dropdown.find('.select2-results');
2616
- $resultsContainer.append($results);
2617
- };
2618
-
2619
- Results.prototype.sort = function (data) {
2620
- var sorter = this.options.get('sorter');
2621
-
2622
- return sorter(data);
2623
- };
2624
-
2625
- Results.prototype.highlightFirstItem = function () {
2626
- var $options = this.$results
2627
- .find('.select2-results__option[aria-selected]');
2628
-
2629
- var $selected = $options.filter('[aria-selected=true]');
2630
-
2631
- // Check if there are any selected options
2632
- if ($selected.length > 0) {
2633
- // If there are selected options, highlight the first
2634
- $selected.first().trigger('mouseenter');
2635
- } else {
2636
- // If there are no selected options, highlight the first option
2637
- // in the dropdown
2638
- $options.first().trigger('mouseenter');
2639
- }
2640
-
2641
- this.ensureHighlightVisible();
2642
- };
2643
-
2644
- Results.prototype.setClasses = function () {
2645
- var self = this;
2646
-
2647
- this.data.current(function (selected) {
2648
- var selectedIds = $.map(selected, function (s) {
2649
- return s.id.toString();
2650
- });
2651
-
2652
- var $options = self.$results
2653
- .find('.select2-results__option[aria-selected]');
2654
-
2655
- $options.each(function () {
2656
- var $option = $(this);
2657
-
2658
- var item = $.data(this, 'data');
2659
-
2660
- // id needs to be converted to a string when comparing
2661
- var id = '' + item.id;
2662
-
2663
- if ((item.element != null && item.element.selected) ||
2664
- (item.element == null && $.inArray(id, selectedIds) > -1)) {
2665
- $option.attr('aria-selected', 'true');
2666
- } else {
2667
- $option.attr('aria-selected', 'false');
2668
- }
2669
- });
2670
-
2671
- });
2672
- };
2673
-
2674
- Results.prototype.showLoading = function (params) {
2675
- this.hideLoading();
2676
-
2677
- var loadingMore = this.options.get('translations').get('searching');
2678
-
2679
- var loading = {
2680
- disabled: true,
2681
- loading: true,
2682
- text: loadingMore(params)
2683
- };
2684
- var $loading = this.option(loading);
2685
- $loading.className += ' loading-results';
2686
-
2687
- this.$results.prepend($loading);
2688
- };
2689
-
2690
- Results.prototype.hideLoading = function () {
2691
- this.$results.find('.loading-results').remove();
2692
- };
2693
-
2694
- Results.prototype.option = function (data) {
2695
- var option = document.createElement('li');
2696
- option.className = 'select2-results__option';
2697
-
2698
- var attrs = {
2699
- 'role': 'treeitem',
2700
- 'aria-selected': 'false'
2701
- };
2702
-
2703
- if (data.disabled) {
2704
- delete attrs['aria-selected'];
2705
- attrs['aria-disabled'] = 'true';
2706
- }
2707
-
2708
- if (data.id == null) {
2709
- delete attrs['aria-selected'];
2710
- }
2711
-
2712
- if (data._resultId != null) {
2713
- option.id = data._resultId;
2714
- }
2715
-
2716
- if (data.title) {
2717
- option.title = data.title;
2718
- }
2719
-
2720
- if (data.children) {
2721
- attrs.role = 'group';
2722
- attrs['aria-label'] = data.text;
2723
- delete attrs['aria-selected'];
2724
- }
2725
-
2726
- for (var attr in attrs) {
2727
- var val = attrs[attr];
2728
-
2729
- option.setAttribute(attr, val);
2730
- }
2731
-
2732
- if (data.children) {
2733
- var $option = $(option);
2734
-
2735
- var label = document.createElement('strong');
2736
- label.className = 'select2-results__group';
2737
-
2738
- var $label = $(label);
2739
- this.template(data, label);
2740
-
2741
- var $children = [];
2742
-
2743
- for (var c = 0; c < data.children.length; c++) {
2744
- var child = data.children[c];
2745
-
2746
- var $child = this.option(child);
2747
-
2748
- $children.push($child);
2749
- }
2750
-
2751
- var $childrenContainer = $('<ul></ul>', {
2752
- 'class': 'select2-results__options select2-results__options--nested'
2753
- });
2754
-
2755
- $childrenContainer.append($children);
2756
-
2757
- $option.append(label);
2758
- $option.append($childrenContainer);
2759
- } else {
2760
- this.template(data, option);
2761
- }
2762
-
2763
- $.data(option, 'data', data);
2764
-
2765
- return option;
2766
- };
2767
-
2768
- Results.prototype.bind = function (container, $container) {
2769
- var self = this;
2770
-
2771
- var id = container.id + '-results';
2772
-
2773
- this.$results.attr('id', id);
2774
-
2775
- container.on('results:all', function (params) {
2776
- self.clear();
2777
- self.append(params.data);
2778
-
2779
- if (container.isOpen()) {
2780
- self.setClasses();
2781
- self.highlightFirstItem();
2782
- }
2783
- });
2784
-
2785
- container.on('results:append', function (params) {
2786
- self.append(params.data);
2787
-
2788
- if (container.isOpen()) {
2789
- self.setClasses();
2790
- }
2791
- });
2792
-
2793
- container.on('query', function (params) {
2794
- self.hideMessages();
2795
- self.showLoading(params);
2796
- });
2797
-
2798
- container.on('select', function () {
2799
- if (!container.isOpen()) {
2800
- return;
2801
- }
2802
-
2803
- self.setClasses();
2804
- self.highlightFirstItem();
2805
- });
2806
-
2807
- container.on('unselect', function () {
2808
- if (!container.isOpen()) {
2809
- return;
2810
- }
2811
-
2812
- self.setClasses();
2813
- self.highlightFirstItem();
2814
- });
2815
-
2816
- container.on('open', function () {
2817
- // When the dropdown is open, aria-expended="true"
2818
- self.$results.attr('aria-expanded', 'true');
2819
- self.$results.attr('aria-hidden', 'false');
2820
-
2821
- self.setClasses();
2822
- self.ensureHighlightVisible();
2823
- });
2824
-
2825
- container.on('close', function () {
2826
- // When the dropdown is closed, aria-expended="false"
2827
- self.$results.attr('aria-expanded', 'false');
2828
- self.$results.attr('aria-hidden', 'true');
2829
- self.$results.removeAttr('aria-activedescendant');
2830
- });
2831
-
2832
- container.on('results:toggle', function () {
2833
- var $highlighted = self.getHighlightedResults();
2834
-
2835
- if ($highlighted.length === 0) {
2836
- return;
2837
- }
2838
-
2839
- $highlighted.trigger('mouseup');
2840
- });
2841
-
2842
- container.on('results:select', function () {
2843
- var $highlighted = self.getHighlightedResults();
2844
-
2845
- if ($highlighted.length === 0) {
2846
- return;
2847
- }
2848
-
2849
- var data = $highlighted.data('data');
2850
-
2851
- if ($highlighted.attr('aria-selected') == 'true') {
2852
- self.trigger('close', {});
2853
- } else {
2854
- self.trigger('select', {
2855
- data: data
2856
- });
2857
- }
2858
- });
2859
-
2860
- container.on('results:previous', function () {
2861
- var $highlighted = self.getHighlightedResults();
2862
-
2863
- var $options = self.$results.find('[aria-selected]');
2864
-
2865
- var currentIndex = $options.index($highlighted);
2866
-
2867
- // If we are already at te top, don't move further
2868
- if (currentIndex === 0) {
2869
- return;
2870
- }
2871
-
2872
- var nextIndex = currentIndex - 1;
2873
-
2874
- // If none are highlighted, highlight the first
2875
- if ($highlighted.length === 0) {
2876
- nextIndex = 0;
2877
- }
2878
-
2879
- var $next = $options.eq(nextIndex);
2880
-
2881
- $next.trigger('mouseenter');
2882
-
2883
- var currentOffset = self.$results.offset().top;
2884
- var nextTop = $next.offset().top;
2885
- var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
2886
-
2887
- if (nextIndex === 0) {
2888
- self.$results.scrollTop(0);
2889
- } else if (nextTop - currentOffset < 0) {
2890
- self.$results.scrollTop(nextOffset);
2891
- }
2892
- });
2893
-
2894
- container.on('results:next', function () {
2895
- var $highlighted = self.getHighlightedResults();
2896
-
2897
- var $options = self.$results.find('[aria-selected]');
2898
-
2899
- var currentIndex = $options.index($highlighted);
2900
-
2901
- var nextIndex = currentIndex + 1;
2902
-
2903
- // If we are at the last option, stay there
2904
- if (nextIndex >= $options.length) {
2905
- return;
2906
- }
2907
-
2908
- var $next = $options.eq(nextIndex);
2909
-
2910
- $next.trigger('mouseenter');
2911
-
2912
- var currentOffset = self.$results.offset().top +
2913
- self.$results.outerHeight(false);
2914
- var nextBottom = $next.offset().top + $next.outerHeight(false);
2915
- var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
2916
-
2917
- if (nextIndex === 0) {
2918
- self.$results.scrollTop(0);
2919
- } else if (nextBottom > currentOffset) {
2920
- self.$results.scrollTop(nextOffset);
2921
- }
2922
- });
2923
-
2924
- container.on('results:focus', function (params) {
2925
- params.element.addClass('select2-results__option--highlighted');
2926
- });
2927
-
2928
- container.on('results:message', function (params) {
2929
- self.displayMessage(params);
2930
- });
2931
-
2932
- if ($.fn.mousewheel) {
2933
- this.$results.on('mousewheel', function (e) {
2934
- var top = self.$results.scrollTop();
2935
-
2936
- var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
2937
-
2938
- var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
2939
- var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
2940
-
2941
- if (isAtTop) {
2942
- self.$results.scrollTop(0);
2943
-
2944
- e.preventDefault();
2945
- e.stopPropagation();
2946
- } else if (isAtBottom) {
2947
- self.$results.scrollTop(
2948
- self.$results.get(0).scrollHeight - self.$results.height()
2949
- );
2950
-
2951
- e.preventDefault();
2952
- e.stopPropagation();
2953
- }
2954
- });
2955
- }
2956
-
2957
- this.$results.on('mouseup', '.select2-results__option[aria-selected]',
2958
- function (evt) {
2959
- var $this = $(this);
2960
-
2961
- var data = $this.data('data');
2962
-
2963
- if ($this.attr('aria-selected') === 'true') {
2964
- if (self.options.get('multiple')) {
2965
- self.trigger('unselect', {
2966
- originalEvent: evt,
2967
- data: data
2968
- });
2969
- } else {
2970
- self.trigger('close', {});
2971
- }
2972
-
2973
- return;
2974
- }
2975
-
2976
- self.trigger('select', {
2977
- originalEvent: evt,
2978
- data: data
2979
- });
2980
- });
2981
-
2982
- this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
2983
- function (evt) {
2984
- var data = $(this).data('data');
2985
-
2986
- self.getHighlightedResults()
2987
- .removeClass('select2-results__option--highlighted');
2988
-
2989
- self.trigger('results:focus', {
2990
- data: data,
2991
- element: $(this)
2992
- });
2993
- });
2994
- };
2995
-
2996
- Results.prototype.getHighlightedResults = function () {
2997
- var $highlighted = this.$results
2998
- .find('.select2-results__option--highlighted');
2999
-
3000
- return $highlighted;
3001
- };
3002
-
3003
- Results.prototype.destroy = function () {
3004
- this.$results.remove();
3005
- };
3006
-
3007
- Results.prototype.ensureHighlightVisible = function () {
3008
- var $highlighted = this.getHighlightedResults();
3009
-
3010
- if ($highlighted.length === 0) {
3011
- return;
3012
- }
3013
-
3014
- var $options = this.$results.find('[aria-selected]');
3015
-
3016
- var currentIndex = $options.index($highlighted);
3017
-
3018
- var currentOffset = this.$results.offset().top;
3019
- var nextTop = $highlighted.offset().top;
3020
- var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
3021
-
3022
- var offsetDelta = nextTop - currentOffset;
3023
- nextOffset -= $highlighted.outerHeight(false) * 2;
3024
-
3025
- if (currentIndex <= 2) {
3026
- this.$results.scrollTop(0);
3027
- } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
3028
- this.$results.scrollTop(nextOffset);
3029
- }
3030
- };
3031
-
3032
- Results.prototype.template = function (result, container) {
3033
- var template = this.options.get('templateResult');
3034
- var escapeMarkup = this.options.get('escapeMarkup');
3035
-
3036
- var content = template(result, container);
3037
-
3038
- if (content == null) {
3039
- container.style.display = 'none';
3040
- } else if (typeof content === 'string') {
3041
- container.innerHTML = escapeMarkup(content);
3042
- } else {
3043
- $(container).append(content);
3044
- }
3045
- };
3046
-
3047
- return Results;
3048
- });
3049
-
3050
- S2.define('select2/keys',[
3051
-
3052
- ], function () {
3053
- var KEYS = {
3054
- BACKSPACE: 8,
3055
- TAB: 9,
3056
- ENTER: 13,
3057
- SHIFT: 16,
3058
- CTRL: 17,
3059
- ALT: 18,
3060
- ESC: 27,
3061
- SPACE: 32,
3062
- PAGE_UP: 33,
3063
- PAGE_DOWN: 34,
3064
- END: 35,
3065
- HOME: 36,
3066
- LEFT: 37,
3067
- UP: 38,
3068
- RIGHT: 39,
3069
- DOWN: 40,
3070
- DELETE: 46
3071
- };
3072
-
3073
- return KEYS;
3074
- });
3075
-
3076
- S2.define('select2/selection/base',[
3077
- 'jquery',
3078
- '../utils',
3079
- '../keys'
3080
- ], function ($, Utils, KEYS) {
3081
- function BaseSelection ($element, options) {
3082
- this.$element = $element;
3083
- this.options = options;
3084
-
3085
- BaseSelection.__super__.constructor.call(this);
3086
- }
3087
-
3088
- Utils.Extend(BaseSelection, Utils.Observable);
3089
-
3090
- BaseSelection.prototype.render = function () {
3091
- var $selection = $(
3092
- '<span class="select2-selection" role="combobox" ' +
3093
- ' aria-haspopup="true" aria-expanded="false">' +
3094
- '</span>'
3095
- );
3096
-
3097
- this._tabindex = 0;
3098
-
3099
- if (this.$element.data('old-tabindex') != null) {
3100
- this._tabindex = this.$element.data('old-tabindex');
3101
- } else if (this.$element.attr('tabindex') != null) {
3102
- this._tabindex = this.$element.attr('tabindex');
3103
- }
3104
-
3105
- $selection.attr('title', this.$element.attr('title'));
3106
- $selection.attr('tabindex', this._tabindex);
3107
-
3108
- this.$selection = $selection;
3109
-
3110
- return $selection;
3111
- };
3112
-
3113
- BaseSelection.prototype.bind = function (container, $container) {
3114
- var self = this;
3115
-
3116
- var id = container.id + '-container';
3117
- var resultsId = container.id + '-results';
3118
-
3119
- this.container = container;
3120
-
3121
- this.$selection.on('focus', function (evt) {
3122
- self.trigger('focus', evt);
3123
- });
3124
-
3125
- this.$selection.on('blur', function (evt) {
3126
- self._handleBlur(evt);
3127
- });
3128
-
3129
- this.$selection.on('keydown', function (evt) {
3130
- self.trigger('keypress', evt);
3131
-
3132
- if (evt.which === KEYS.SPACE) {
3133
- evt.preventDefault();
3134
- }
3135
- });
3136
-
3137
- container.on('results:focus', function (params) {
3138
- self.$selection.attr('aria-activedescendant', params.data._resultId);
3139
- });
3140
-
3141
- container.on('selection:update', function (params) {
3142
- self.update(params.data);
3143
- });
3144
-
3145
- container.on('open', function () {
3146
- // When the dropdown is open, aria-expanded="true"
3147
- self.$selection.attr('aria-expanded', 'true');
3148
- self.$selection.attr('aria-owns', resultsId);
3149
-
3150
- self._attachCloseHandler(container);
3151
- });
3152
-
3153
- container.on('close', function () {
3154
- // When the dropdown is closed, aria-expanded="false"
3155
- self.$selection.attr('aria-expanded', 'false');
3156
- self.$selection.removeAttr('aria-activedescendant');
3157
- self.$selection.removeAttr('aria-owns');
3158
-
3159
- self.$selection.focus();
3160
-
3161
- self._detachCloseHandler(container);
3162
- });
3163
-
3164
- container.on('enable', function () {
3165
- self.$selection.attr('tabindex', self._tabindex);
3166
- });
3167
-
3168
- container.on('disable', function () {
3169
- self.$selection.attr('tabindex', '-1');
3170
- });
3171
- };
3172
-
3173
- BaseSelection.prototype._handleBlur = function (evt) {
3174
- var self = this;
3175
-
3176
- // This needs to be delayed as the active element is the body when the tab
3177
- // key is pressed, possibly along with others.
3178
- window.setTimeout(function () {
3179
- // Don't trigger `blur` if the focus is still in the selection
3180
- if (
3181
- (document.activeElement == self.$selection[0]) ||
3182
- ($.contains(self.$selection[0], document.activeElement))
3183
- ) {
3184
- return;
3185
- }
3186
-
3187
- self.trigger('blur', evt);
3188
- }, 1);
3189
- };
3190
-
3191
- BaseSelection.prototype._attachCloseHandler = function (container) {
3192
- var self = this;
3193
-
3194
- $(document.body).on('mousedown.select2.' + container.id, function (e) {
3195
- var $target = $(e.target);
3196
-
3197
- var $select = $target.closest('.select2');
3198
-
3199
- var $all = $('.select2.select2-container--open');
3200
-
3201
- $all.each(function () {
3202
- var $this = $(this);
3203
-
3204
- if (this == $select[0]) {
3205
- return;
3206
- }
3207
-
3208
- var $element = $this.data('element');
3209
-
3210
- $element.select2('close');
3211
- });
3212
- });
3213
- };
3214
-
3215
- BaseSelection.prototype._detachCloseHandler = function (container) {
3216
- $(document.body).off('mousedown.select2.' + container.id);
3217
- };
3218
-
3219
- BaseSelection.prototype.position = function ($selection, $container) {
3220
- var $selectionContainer = $container.find('.selection');
3221
- $selectionContainer.append($selection);
3222
- };
3223
-
3224
- BaseSelection.prototype.destroy = function () {
3225
- this._detachCloseHandler(this.container);
3226
- };
3227
-
3228
- BaseSelection.prototype.update = function (data) {
3229
- throw new Error('The `update` method must be defined in child classes.');
3230
- };
3231
-
3232
- return BaseSelection;
3233
- });
3234
-
3235
- S2.define('select2/selection/single',[
3236
- 'jquery',
3237
- './base',
3238
- '../utils',
3239
- '../keys'
3240
- ], function ($, BaseSelection, Utils, KEYS) {
3241
- function SingleSelection () {
3242
- SingleSelection.__super__.constructor.apply(this, arguments);
3243
- }
3244
-
3245
- Utils.Extend(SingleSelection, BaseSelection);
3246
-
3247
- SingleSelection.prototype.render = function () {
3248
- var $selection = SingleSelection.__super__.render.call(this);
3249
-
3250
- $selection.addClass('select2-selection--single');
3251
-
3252
- $selection.html(
3253
- '<span class="select2-selection__rendered"></span>' +
3254
- '<span class="select2-selection__arrow" role="presentation">' +
3255
- '<b role="presentation"></b>' +
3256
- '</span>'
3257
- );
3258
-
3259
- return $selection;
3260
- };
3261
-
3262
- SingleSelection.prototype.bind = function (container, $container) {
3263
- var self = this;
3264
-
3265
- SingleSelection.__super__.bind.apply(this, arguments);
3266
-
3267
- var id = container.id + '-container';
3268
-
3269
- this.$selection.find('.select2-selection__rendered').attr('id', id);
3270
- this.$selection.attr('aria-labelledby', id);
3271
-
3272
- this.$selection.on('mousedown', function (evt) {
3273
- // Only respond to left clicks
3274
- if (evt.which !== 1) {
3275
- return;
3276
- }
3277
-
3278
- self.trigger('toggle', {
3279
- originalEvent: evt
3280
- });
3281
- });
3282
-
3283
- this.$selection.on('focus', function (evt) {
3284
- // User focuses on the container
3285
- });
3286
-
3287
- this.$selection.on('blur', function (evt) {
3288
- // User exits the container
3289
- });
3290
-
3291
- container.on('focus', function (evt) {
3292
- if (!container.isOpen()) {
3293
- self.$selection.focus();
3294
- }
3295
- });
3296
-
3297
- container.on('selection:update', function (params) {
3298
- self.update(params.data);
3299
- });
3300
- };
3301
-
3302
- SingleSelection.prototype.clear = function () {
3303
- this.$selection.find('.select2-selection__rendered').empty();
3304
- };
3305
-
3306
- SingleSelection.prototype.display = function (data, container) {
3307
- var template = this.options.get('templateSelection');
3308
- var escapeMarkup = this.options.get('escapeMarkup');
3309
-
3310
- return escapeMarkup(template(data, container));
3311
- };
3312
-
3313
- SingleSelection.prototype.selectionContainer = function () {
3314
- return $('<span></span>');
3315
- };
3316
-
3317
- SingleSelection.prototype.update = function (data) {
3318
- if (data.length === 0) {
3319
- this.clear();
3320
- return;
3321
- }
3322
-
3323
- var selection = data[0];
3324
-
3325
- var $rendered = this.$selection.find('.select2-selection__rendered');
3326
- var formatted = this.display(selection, $rendered);
3327
-
3328
- $rendered.empty().append(formatted);
3329
- $rendered.prop('title', selection.title || selection.text);
3330
- };
3331
-
3332
- return SingleSelection;
3333
- });
3334
-
3335
- S2.define('select2/selection/multiple',[
3336
- 'jquery',
3337
- './base',
3338
- '../utils'
3339
- ], function ($, BaseSelection, Utils) {
3340
- function MultipleSelection ($element, options) {
3341
- MultipleSelection.__super__.constructor.apply(this, arguments);
3342
- }
3343
-
3344
- Utils.Extend(MultipleSelection, BaseSelection);
3345
-
3346
- MultipleSelection.prototype.render = function () {
3347
- var $selection = MultipleSelection.__super__.render.call(this);
3348
-
3349
- $selection.addClass('select2-selection--multiple');
3350
-
3351
- $selection.html(
3352
- '<ul class="select2-selection__rendered"></ul>'
3353
- );
3354
-
3355
- return $selection;
3356
- };
3357
-
3358
- MultipleSelection.prototype.bind = function (container, $container) {
3359
- var self = this;
3360
-
3361
- MultipleSelection.__super__.bind.apply(this, arguments);
3362
-
3363
- this.$selection.on('click', function (evt) {
3364
- self.trigger('toggle', {
3365
- originalEvent: evt
3366
- });
3367
- });
3368
-
3369
- this.$selection.on(
3370
- 'click',
3371
- '.select2-selection__choice__remove',
3372
- function (evt) {
3373
- // Ignore the event if it is disabled
3374
- if (self.options.get('disabled')) {
3375
- return;
3376
- }
3377
-
3378
- var $remove = $(this);
3379
- var $selection = $remove.parent();
3380
-
3381
- var data = $selection.data('data');
3382
-
3383
- self.trigger('unselect', {
3384
- originalEvent: evt,
3385
- data: data
3386
- });
3387
- }
3388
- );
3389
- };
3390
-
3391
- MultipleSelection.prototype.clear = function () {
3392
- this.$selection.find('.select2-selection__rendered').empty();
3393
- };
3394
-
3395
- MultipleSelection.prototype.display = function (data, container) {
3396
- var template = this.options.get('templateSelection');
3397
- var escapeMarkup = this.options.get('escapeMarkup');
3398
-
3399
- return escapeMarkup(template(data, container));
3400
- };
3401
-
3402
- MultipleSelection.prototype.selectionContainer = function () {
3403
- var $container = $(
3404
- '<li class="select2-selection__choice">' +
3405
- '<span class="select2-selection__choice__remove" role="presentation">' +
3406
- '&times;' +
3407
- '</span>' +
3408
- '</li>'
3409
- );
3410
-
3411
- return $container;
3412
- };
3413
-
3414
- MultipleSelection.prototype.update = function (data) {
3415
- this.clear();
3416
-
3417
- if (data.length === 0) {
3418
- return;
3419
- }
3420
-
3421
- var $selections = [];
3422
-
3423
- for (var d = 0; d < data.length; d++) {
3424
- var selection = data[d];
3425
-
3426
- var $selection = this.selectionContainer();
3427
- var formatted = this.display(selection, $selection);
3428
-
3429
- $selection.append(formatted);
3430
- $selection.prop('title', selection.title || selection.text);
3431
-
3432
- $selection.data('data', selection);
3433
-
3434
- $selections.push($selection);
3435
- }
3436
-
3437
- var $rendered = this.$selection.find('.select2-selection__rendered');
3438
-
3439
- Utils.appendMany($rendered, $selections);
3440
- };
3441
-
3442
- return MultipleSelection;
3443
- });
3444
-
3445
- S2.define('select2/selection/placeholder',[
3446
- '../utils'
3447
- ], function (Utils) {
3448
- function Placeholder (decorated, $element, options) {
3449
- this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
3450
-
3451
- decorated.call(this, $element, options);
3452
- }
3453
-
3454
- Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
3455
- if (typeof placeholder === 'string') {
3456
- placeholder = {
3457
- id: '',
3458
- text: placeholder
3459
- };
3460
- }
3461
-
3462
- return placeholder;
3463
- };
3464
-
3465
- Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
3466
- var $placeholder = this.selectionContainer();
3467
-
3468
- $placeholder.html(this.display(placeholder));
3469
- $placeholder.addClass('select2-selection__placeholder')
3470
- .removeClass('select2-selection__choice');
3471
-
3472
- return $placeholder;
3473
- };
3474
-
3475
- Placeholder.prototype.update = function (decorated, data) {
3476
- var singlePlaceholder = (
3477
- data.length == 1 && data[0].id != this.placeholder.id
3478
- );
3479
- var multipleSelections = data.length > 1;
3480
-
3481
- if (multipleSelections || singlePlaceholder) {
3482
- return decorated.call(this, data);
3483
- }
3484
-
3485
- this.clear();
3486
-
3487
- var $placeholder = this.createPlaceholder(this.placeholder);
3488
-
3489
- this.$selection.find('.select2-selection__rendered').append($placeholder);
3490
- };
3491
-
3492
- return Placeholder;
3493
- });
3494
-
3495
- S2.define('select2/selection/allowClear',[
3496
- 'jquery',
3497
- '../keys'
3498
- ], function ($, KEYS) {
3499
- function AllowClear () { }
3500
-
3501
- AllowClear.prototype.bind = function (decorated, container, $container) {
3502
- var self = this;
3503
-
3504
- decorated.call(this, container, $container);
3505
-
3506
- if (this.placeholder == null) {
3507
- if (this.options.get('debug') && window.console && console.error) {
3508
- console.error(
3509
- 'Select2: The `allowClear` option should be used in combination ' +
3510
- 'with the `placeholder` option.'
3511
- );
3512
- }
3513
- }
3514
-
3515
- this.$selection.on('mousedown', '.select2-selection__clear',
3516
- function (evt) {
3517
- self._handleClear(evt);
3518
- });
3519
-
3520
- container.on('keypress', function (evt) {
3521
- self._handleKeyboardClear(evt, container);
3522
- });
3523
- };
3524
-
3525
- AllowClear.prototype._handleClear = function (_, evt) {
3526
- // Ignore the event if it is disabled
3527
- if (this.options.get('disabled')) {
3528
- return;
3529
- }
3530
-
3531
- var $clear = this.$selection.find('.select2-selection__clear');
3532
-
3533
- // Ignore the event if nothing has been selected
3534
- if ($clear.length === 0) {
3535
- return;
3536
- }
3537
-
3538
- evt.stopPropagation();
3539
-
3540
- var data = $clear.data('data');
3541
-
3542
- for (var d = 0; d < data.length; d++) {
3543
- var unselectData = {
3544
- data: data[d]
3545
- };
3546
-
3547
- // Trigger the `unselect` event, so people can prevent it from being
3548
- // cleared.
3549
- this.trigger('unselect', unselectData);
3550
-
3551
- // If the event was prevented, don't clear it out.
3552
- if (unselectData.prevented) {
3553
- return;
3554
- }
3555
- }
3556
-
3557
- this.$element.val(this.placeholder.id).trigger('change');
3558
-
3559
- this.trigger('toggle', {});
3560
- };
3561
-
3562
- AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
3563
- if (container.isOpen()) {
3564
- return;
3565
- }
3566
-
3567
- if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
3568
- this._handleClear(evt);
3569
- }
3570
- };
3571
-
3572
- AllowClear.prototype.update = function (decorated, data) {
3573
- decorated.call(this, data);
3574
-
3575
- if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
3576
- data.length === 0) {
3577
- return;
3578
- }
3579
-
3580
- var $remove = $(
3581
- '<span class="select2-selection__clear">' +
3582
- '&times;' +
3583
- '</span>'
3584
- );
3585
- $remove.data('data', data);
3586
-
3587
- this.$selection.find('.select2-selection__rendered').prepend($remove);
3588
- };
3589
-
3590
- return AllowClear;
3591
- });
3592
-
3593
- S2.define('select2/selection/search',[
3594
- 'jquery',
3595
- '../utils',
3596
- '../keys'
3597
- ], function ($, Utils, KEYS) {
3598
- function Search (decorated, $element, options) {
3599
- decorated.call(this, $element, options);
3600
- }
3601
-
3602
- Search.prototype.render = function (decorated) {
3603
- var $search = $(
3604
- '<li class="select2-search select2-search--inline">' +
3605
- '<input class="select2-search__field" type="search" tabindex="-1"' +
3606
- ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
3607
- ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
3608
- '</li>'
3609
- );
3610
-
3611
- this.$searchContainer = $search;
3612
- this.$search = $search.find('input');
3613
-
3614
- var $rendered = decorated.call(this);
3615
-
3616
- this._transferTabIndex();
3617
-
3618
- return $rendered;
3619
- };
3620
-
3621
- Search.prototype.bind = function (decorated, container, $container) {
3622
- var self = this;
3623
-
3624
- decorated.call(this, container, $container);
3625
-
3626
- container.on('open', function () {
3627
- self.$search.trigger('focus');
3628
- });
3629
-
3630
- container.on('close', function () {
3631
- self.$search.val('');
3632
- self.$search.removeAttr('aria-activedescendant');
3633
- self.$search.trigger('focus');
3634
- });
3635
-
3636
- container.on('enable', function () {
3637
- self.$search.prop('disabled', false);
3638
-
3639
- self._transferTabIndex();
3640
- });
3641
-
3642
- container.on('disable', function () {
3643
- self.$search.prop('disabled', true);
3644
- });
3645
-
3646
- container.on('focus', function (evt) {
3647
- self.$search.trigger('focus');
3648
- });
3649
-
3650
- container.on('results:focus', function (params) {
3651
- self.$search.attr('aria-activedescendant', params.id);
3652
- });
3653
-
3654
- this.$selection.on('focusin', '.select2-search--inline', function (evt) {
3655
- self.trigger('focus', evt);
3656
- });
3657
-
3658
- this.$selection.on('focusout', '.select2-search--inline', function (evt) {
3659
- self._handleBlur(evt);
3660
- });
3661
-
3662
- this.$selection.on('keydown', '.select2-search--inline', function (evt) {
3663
- evt.stopPropagation();
3664
-
3665
- self.trigger('keypress', evt);
3666
-
3667
- self._keyUpPrevented = evt.isDefaultPrevented();
3668
-
3669
- var key = evt.which;
3670
-
3671
- if (key === KEYS.BACKSPACE && self.$search.val() === '') {
3672
- var $previousChoice = self.$searchContainer
3673
- .prev('.select2-selection__choice');
3674
-
3675
- if ($previousChoice.length > 0) {
3676
- var item = $previousChoice.data('data');
3677
-
3678
- self.searchRemoveChoice(item);
3679
-
3680
- evt.preventDefault();
3681
- }
3682
- }
3683
- });
3684
-
3685
- // Try to detect the IE version should the `documentMode` property that
3686
- // is stored on the document. This is only implemented in IE and is
3687
- // slightly cleaner than doing a user agent check.
3688
- // This property is not available in Edge, but Edge also doesn't have
3689
- // this bug.
3690
- var msie = document.documentMode;
3691
- var disableInputEvents = msie && msie <= 11;
3692
-
3693
- // Workaround for browsers which do not support the `input` event
3694
- // This will prevent double-triggering of events for browsers which support
3695
- // both the `keyup` and `input` events.
3696
- this.$selection.on(
3697
- 'input.searchcheck',
3698
- '.select2-search--inline',
3699
- function (evt) {
3700
- // IE will trigger the `input` event when a placeholder is used on a
3701
- // search box. To get around this issue, we are forced to ignore all
3702
- // `input` events in IE and keep using `keyup`.
3703
- if (disableInputEvents) {
3704
- self.$selection.off('input.search input.searchcheck');
3705
- return;
3706
- }
3707
-
3708
- // Unbind the duplicated `keyup` event
3709
- self.$selection.off('keyup.search');
3710
- }
3711
- );
3712
-
3713
- this.$selection.on(
3714
- 'keyup.search input.search',
3715
- '.select2-search--inline',
3716
- function (evt) {
3717
- // IE will trigger the `input` event when a placeholder is used on a
3718
- // search box. To get around this issue, we are forced to ignore all
3719
- // `input` events in IE and keep using `keyup`.
3720
- if (disableInputEvents && evt.type === 'input') {
3721
- self.$selection.off('input.search input.searchcheck');
3722
- return;
3723
- }
3724
-
3725
- var key = evt.which;
3726
-
3727
- // We can freely ignore events from modifier keys
3728
- if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
3729
- return;
3730
- }
3731
-
3732
- // Tabbing will be handled during the `keydown` phase
3733
- if (key == KEYS.TAB) {
3734
- return;
3735
- }
3736
-
3737
- self.handleSearch(evt);
3738
- }
3739
- );
3740
- };
3741
-
3742
- /**
3743
- * This method will transfer the tabindex attribute from the rendered
3744
- * selection to the search box. This allows for the search box to be used as
3745
- * the primary focus instead of the selection container.
3746
- *
3747
- * @private
3748
- */
3749
- Search.prototype._transferTabIndex = function (decorated) {
3750
- this.$search.attr('tabindex', this.$selection.attr('tabindex'));
3751
- this.$selection.attr('tabindex', '-1');
3752
- };
3753
-
3754
- Search.prototype.createPlaceholder = function (decorated, placeholder) {
3755
- this.$search.attr('placeholder', placeholder.text);
3756
- };
3757
-
3758
- Search.prototype.update = function (decorated, data) {
3759
- var searchHadFocus = this.$search[0] == document.activeElement;
3760
-
3761
- this.$search.attr('placeholder', '');
3762
-
3763
- decorated.call(this, data);
3764
-
3765
- this.$selection.find('.select2-selection__rendered')
3766
- .append(this.$searchContainer);
3767
-
3768
- this.resizeSearch();
3769
- if (searchHadFocus) {
3770
- this.$search.focus();
3771
- }
3772
- };
3773
-
3774
- Search.prototype.handleSearch = function () {
3775
- this.resizeSearch();
3776
-
3777
- if (!this._keyUpPrevented) {
3778
- var input = this.$search.val();
3779
-
3780
- this.trigger('query', {
3781
- term: input
3782
- });
3783
- }
3784
-
3785
- this._keyUpPrevented = false;
3786
- };
3787
-
3788
- Search.prototype.searchRemoveChoice = function (decorated, item) {
3789
- this.trigger('unselect', {
3790
- data: item
3791
- });
3792
-
3793
- this.$search.val(item.text);
3794
- this.handleSearch();
3795
- };
3796
-
3797
- Search.prototype.resizeSearch = function () {
3798
- this.$search.css('width', '25px');
3799
-
3800
- var width = '';
3801
-
3802
- if (this.$search.attr('placeholder') !== '') {
3803
- width = this.$selection.find('.select2-selection__rendered').innerWidth();
3804
- } else {
3805
- var minimumWidth = this.$search.val().length + 1;
3806
-
3807
- width = (minimumWidth * 0.75) + 'em';
3808
- }
3809
-
3810
- this.$search.css('width', width);
3811
- };
3812
-
3813
- return Search;
3814
- });
3815
-
3816
- S2.define('select2/selection/eventRelay',[
3817
- 'jquery'
3818
- ], function ($) {
3819
- function EventRelay () { }
3820
-
3821
- EventRelay.prototype.bind = function (decorated, container, $container) {
3822
- var self = this;
3823
- var relayEvents = [
3824
- 'open', 'opening',
3825
- 'close', 'closing',
3826
- 'select', 'selecting',
3827
- 'unselect', 'unselecting'
3828
- ];
3829
-
3830
- var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
3831
-
3832
- decorated.call(this, container, $container);
3833
-
3834
- container.on('*', function (name, params) {
3835
- // Ignore events that should not be relayed
3836
- if ($.inArray(name, relayEvents) === -1) {
3837
- return;
3838
- }
3839
-
3840
- // The parameters should always be an object
3841
- params = params || {};
3842
-
3843
- // Generate the jQuery event for the Select2 event
3844
- var evt = $.Event('select2:' + name, {
3845
- params: params
3846
- });
3847
-
3848
- self.$element.trigger(evt);
3849
-
3850
- // Only handle preventable events if it was one
3851
- if ($.inArray(name, preventableEvents) === -1) {
3852
- return;
3853
- }
3854
-
3855
- params.prevented = evt.isDefaultPrevented();
3856
- });
3857
- };
3858
-
3859
- return EventRelay;
3860
- });
3861
-
3862
- S2.define('select2/translation',[
3863
- 'jquery',
3864
- 'require'
3865
- ], function ($, require) {
3866
- function Translation (dict) {
3867
- this.dict = dict || {};
3868
- }
3869
-
3870
- Translation.prototype.all = function () {
3871
- return this.dict;
3872
- };
3873
-
3874
- Translation.prototype.get = function (key) {
3875
- return this.dict[key];
3876
- };
3877
-
3878
- Translation.prototype.extend = function (translation) {
3879
- this.dict = $.extend({}, translation.all(), this.dict);
3880
- };
3881
-
3882
- // Static functions
3883
-
3884
- Translation._cache = {};
3885
-
3886
- Translation.loadPath = function (path) {
3887
- if (!(path in Translation._cache)) {
3888
- var translations = require(path);
3889
-
3890
- Translation._cache[path] = translations;
3891
- }
3892
-
3893
- return new Translation(Translation._cache[path]);
3894
- };
3895
-
3896
- return Translation;
3897
- });
3898
-
3899
- S2.define('select2/diacritics',[
3900
-
3901
- ], function () {
3902
- var diacritics = {
3903
- '\u24B6': 'A',
3904
- '\uFF21': 'A',
3905
- '\u00C0': 'A',
3906
- '\u00C1': 'A',
3907
- '\u00C2': 'A',
3908
- '\u1EA6': 'A',
3909
- '\u1EA4': 'A',
3910
- '\u1EAA': 'A',
3911
- '\u1EA8': 'A',
3912
- '\u00C3': 'A',
3913
- '\u0100': 'A',
3914
- '\u0102': 'A',
3915
- '\u1EB0': 'A',
3916
- '\u1EAE': 'A',
3917
- '\u1EB4': 'A',
3918
- '\u1EB2': 'A',
3919
- '\u0226': 'A',
3920
- '\u01E0': 'A',
3921
- '\u00C4': 'A',
3922
- '\u01DE': 'A',
3923
- '\u1EA2': 'A',
3924
- '\u00C5': 'A',
3925
- '\u01FA': 'A',
3926
- '\u01CD': 'A',
3927
- '\u0200': 'A',
3928
- '\u0202': 'A',
3929
- '\u1EA0': 'A',
3930
- '\u1EAC': 'A',
3931
- '\u1EB6': 'A',
3932
- '\u1E00': 'A',
3933
- '\u0104': 'A',
3934
- '\u023A': 'A',
3935
- '\u2C6F': 'A',
3936
- '\uA732': 'AA',
3937
- '\u00C6': 'AE',
3938
- '\u01FC': 'AE',
3939
- '\u01E2': 'AE',
3940
- '\uA734': 'AO',
3941
- '\uA736': 'AU',
3942
- '\uA738': 'AV',
3943
- '\uA73A': 'AV',
3944
- '\uA73C': 'AY',
3945
- '\u24B7': 'B',
3946
- '\uFF22': 'B',
3947
- '\u1E02': 'B',
3948
- '\u1E04': 'B',
3949
- '\u1E06': 'B',
3950
- '\u0243': 'B',
3951
- '\u0182': 'B',
3952
- '\u0181': 'B',
3953
- '\u24B8': 'C',
3954
- '\uFF23': 'C',
3955
- '\u0106': 'C',
3956
- '\u0108': 'C',
3957
- '\u010A': 'C',
3958
- '\u010C': 'C',
3959
- '\u00C7': 'C',
3960
- '\u1E08': 'C',
3961
- '\u0187': 'C',
3962
- '\u023B': 'C',
3963
- '\uA73E': 'C',
3964
- '\u24B9': 'D',
3965
- '\uFF24': 'D',
3966
- '\u1E0A': 'D',
3967
- '\u010E': 'D',
3968
- '\u1E0C': 'D',
3969
- '\u1E10': 'D',
3970
- '\u1E12': 'D',
3971
- '\u1E0E': 'D',
3972
- '\u0110': 'D',
3973
- '\u018B': 'D',
3974
- '\u018A': 'D',
3975
- '\u0189': 'D',
3976
- '\uA779': 'D',
3977
- '\u01F1': 'DZ',
3978
- '\u01C4': 'DZ',
3979
- '\u01F2': 'Dz',
3980
- '\u01C5': 'Dz',
3981
- '\u24BA': 'E',
3982
- '\uFF25': 'E',
3983
- '\u00C8': 'E',
3984
- '\u00C9': 'E',
3985
- '\u00CA': 'E',
3986
- '\u1EC0': 'E',
3987
- '\u1EBE': 'E',
3988
- '\u1EC4': 'E',
3989
- '\u1EC2': 'E',
3990
- '\u1EBC': 'E',
3991
- '\u0112': 'E',
3992
- '\u1E14': 'E',
3993
- '\u1E16': 'E',
3994
- '\u0114': 'E',
3995
- '\u0116': 'E',
3996
- '\u00CB': 'E',
3997
- '\u1EBA': 'E',
3998
- '\u011A': 'E',
3999
- '\u0204': 'E',
4000
- '\u0206': 'E',
4001
- '\u1EB8': 'E',
4002
- '\u1EC6': 'E',
4003
- '\u0228': 'E',
4004
- '\u1E1C': 'E',
4005
- '\u0118': 'E',
4006
- '\u1E18': 'E',
4007
- '\u1E1A': 'E',
4008
- '\u0190': 'E',
4009
- '\u018E': 'E',
4010
- '\u24BB': 'F',
4011
- '\uFF26': 'F',
4012
- '\u1E1E': 'F',
4013
- '\u0191': 'F',
4014
- '\uA77B': 'F',
4015
- '\u24BC': 'G',
4016
- '\uFF27': 'G',
4017
- '\u01F4': 'G',
4018
- '\u011C': 'G',
4019
- '\u1E20': 'G',
4020
- '\u011E': 'G',
4021
- '\u0120': 'G',
4022
- '\u01E6': 'G',
4023
- '\u0122': 'G',
4024
- '\u01E4': 'G',
4025
- '\u0193': 'G',
4026
- '\uA7A0': 'G',
4027
- '\uA77D': 'G',
4028
- '\uA77E': 'G',
4029
- '\u24BD': 'H',
4030
- '\uFF28': 'H',
4031
- '\u0124': 'H',
4032
- '\u1E22': 'H',
4033
- '\u1E26': 'H',
4034
- '\u021E': 'H',
4035
- '\u1E24': 'H',
4036
- '\u1E28': 'H',
4037
- '\u1E2A': 'H',
4038
- '\u0126': 'H',
4039
- '\u2C67': 'H',
4040
- '\u2C75': 'H',
4041
- '\uA78D': 'H',
4042
- '\u24BE': 'I',
4043
- '\uFF29': 'I',
4044
- '\u00CC': 'I',
4045
- '\u00CD': 'I',
4046
- '\u00CE': 'I',
4047
- '\u0128': 'I',
4048
- '\u012A': 'I',
4049
- '\u012C': 'I',
4050
- '\u0130': 'I',
4051
- '\u00CF': 'I',
4052
- '\u1E2E': 'I',
4053
- '\u1EC8': 'I',
4054
- '\u01CF': 'I',
4055
- '\u0208': 'I',
4056
- '\u020A': 'I',
4057
- '\u1ECA': 'I',
4058
- '\u012E': 'I',
4059
- '\u1E2C': 'I',
4060
- '\u0197': 'I',
4061
- '\u24BF': 'J',
4062
- '\uFF2A': 'J',
4063
- '\u0134': 'J',
4064
- '\u0248': 'J',
4065
- '\u24C0': 'K',
4066
- '\uFF2B': 'K',
4067
- '\u1E30': 'K',
4068
- '\u01E8': 'K',
4069
- '\u1E32': 'K',
4070
- '\u0136': 'K',
4071
- '\u1E34': 'K',
4072
- '\u0198': 'K',
4073
- '\u2C69': 'K',
4074
- '\uA740': 'K',
4075
- '\uA742': 'K',
4076
- '\uA744': 'K',
4077
- '\uA7A2': 'K',
4078
- '\u24C1': 'L',
4079
- '\uFF2C': 'L',
4080
- '\u013F': 'L',
4081
- '\u0139': 'L',
4082
- '\u013D': 'L',
4083
- '\u1E36': 'L',
4084
- '\u1E38': 'L',
4085
- '\u013B': 'L',
4086
- '\u1E3C': 'L',
4087
- '\u1E3A': 'L',
4088
- '\u0141': 'L',
4089
- '\u023D': 'L',
4090
- '\u2C62': 'L',
4091
- '\u2C60': 'L',
4092
- '\uA748': 'L',
4093
- '\uA746': 'L',
4094
- '\uA780': 'L',
4095
- '\u01C7': 'LJ',
4096
- '\u01C8': 'Lj',
4097
- '\u24C2': 'M',
4098
- '\uFF2D': 'M',
4099
- '\u1E3E': 'M',
4100
- '\u1E40': 'M',
4101
- '\u1E42': 'M',
4102
- '\u2C6E': 'M',
4103
- '\u019C': 'M',
4104
- '\u24C3': 'N',
4105
- '\uFF2E': 'N',
4106
- '\u01F8': 'N',
4107
- '\u0143': 'N',
4108
- '\u00D1': 'N',
4109
- '\u1E44': 'N',
4110
- '\u0147': 'N',
4111
- '\u1E46': 'N',
4112
- '\u0145': 'N',
4113
- '\u1E4A': 'N',
4114
- '\u1E48': 'N',
4115
- '\u0220': 'N',
4116
- '\u019D': 'N',
4117
- '\uA790': 'N',
4118
- '\uA7A4': 'N',
4119
- '\u01CA': 'NJ',
4120
- '\u01CB': 'Nj',
4121
- '\u24C4': 'O',
4122
- '\uFF2F': 'O',
4123
- '\u00D2': 'O',
4124
- '\u00D3': 'O',
4125
- '\u00D4': 'O',
4126
- '\u1ED2': 'O',
4127
- '\u1ED0': 'O',
4128
- '\u1ED6': 'O',
4129
- '\u1ED4': 'O',
4130
- '\u00D5': 'O',
4131
- '\u1E4C': 'O',
4132
- '\u022C': 'O',
4133
- '\u1E4E': 'O',
4134
- '\u014C': 'O',
4135
- '\u1E50': 'O',
4136
- '\u1E52': 'O',
4137
- '\u014E': 'O',
4138
- '\u022E': 'O',
4139
- '\u0230': 'O',
4140
- '\u00D6': 'O',
4141
- '\u022A': 'O',
4142
- '\u1ECE': 'O',
4143
- '\u0150': 'O',
4144
- '\u01D1': 'O',
4145
- '\u020C': 'O',
4146
- '\u020E': 'O',
4147
- '\u01A0': 'O',
4148
- '\u1EDC': 'O',
4149
- '\u1EDA': 'O',
4150
- '\u1EE0': 'O',
4151
- '\u1EDE': 'O',
4152
- '\u1EE2': 'O',
4153
- '\u1ECC': 'O',
4154
- '\u1ED8': 'O',
4155
- '\u01EA': 'O',
4156
- '\u01EC': 'O',
4157
- '\u00D8': 'O',
4158
- '\u01FE': 'O',
4159
- '\u0186': 'O',
4160
- '\u019F': 'O',
4161
- '\uA74A': 'O',
4162
- '\uA74C': 'O',
4163
- '\u01A2': 'OI',
4164
- '\uA74E': 'OO',
4165
- '\u0222': 'OU',
4166
- '\u24C5': 'P',
4167
- '\uFF30': 'P',
4168
- '\u1E54': 'P',
4169
- '\u1E56': 'P',
4170
- '\u01A4': 'P',
4171
- '\u2C63': 'P',
4172
- '\uA750': 'P',
4173
- '\uA752': 'P',
4174
- '\uA754': 'P',
4175
- '\u24C6': 'Q',
4176
- '\uFF31': 'Q',
4177
- '\uA756': 'Q',
4178
- '\uA758': 'Q',
4179
- '\u024A': 'Q',
4180
- '\u24C7': 'R',
4181
- '\uFF32': 'R',
4182
- '\u0154': 'R',
4183
- '\u1E58': 'R',
4184
- '\u0158': 'R',
4185
- '\u0210': 'R',
4186
- '\u0212': 'R',
4187
- '\u1E5A': 'R',
4188
- '\u1E5C': 'R',
4189
- '\u0156': 'R',
4190
- '\u1E5E': 'R',
4191
- '\u024C': 'R',
4192
- '\u2C64': 'R',
4193
- '\uA75A': 'R',
4194
- '\uA7A6': 'R',
4195
- '\uA782': 'R',
4196
- '\u24C8': 'S',
4197
- '\uFF33': 'S',
4198
- '\u1E9E': 'S',
4199
- '\u015A': 'S',
4200
- '\u1E64': 'S',
4201
- '\u015C': 'S',
4202
- '\u1E60': 'S',
4203
- '\u0160': 'S',
4204
- '\u1E66': 'S',
4205
- '\u1E62': 'S',
4206
- '\u1E68': 'S',
4207
- '\u0218': 'S',
4208
- '\u015E': 'S',
4209
- '\u2C7E': 'S',
4210
- '\uA7A8': 'S',
4211
- '\uA784': 'S',
4212
- '\u24C9': 'T',
4213
- '\uFF34': 'T',
4214
- '\u1E6A': 'T',
4215
- '\u0164': 'T',
4216
- '\u1E6C': 'T',
4217
- '\u021A': 'T',
4218
- '\u0162': 'T',
4219
- '\u1E70': 'T',
4220
- '\u1E6E': 'T',
4221
- '\u0166': 'T',
4222
- '\u01AC': 'T',
4223
- '\u01AE': 'T',
4224
- '\u023E': 'T',
4225
- '\uA786': 'T',
4226
- '\uA728': 'TZ',
4227
- '\u24CA': 'U',
4228
- '\uFF35': 'U',
4229
- '\u00D9': 'U',
4230
- '\u00DA': 'U',
4231
- '\u00DB': 'U',
4232
- '\u0168': 'U',
4233
- '\u1E78': 'U',
4234
- '\u016A': 'U',
4235
- '\u1E7A': 'U',
4236
- '\u016C': 'U',
4237
- '\u00DC': 'U',
4238
- '\u01DB': 'U',
4239
- '\u01D7': 'U',
4240
- '\u01D5': 'U',
4241
- '\u01D9': 'U',
4242
- '\u1EE6': 'U',
4243
- '\u016E': 'U',
4244
- '\u0170': 'U',
4245
- '\u01D3': 'U',
4246
- '\u0214': 'U',
4247
- '\u0216': 'U',
4248
- '\u01AF': 'U',
4249
- '\u1EEA': 'U',
4250
- '\u1EE8': 'U',
4251
- '\u1EEE': 'U',
4252
- '\u1EEC': 'U',
4253
- '\u1EF0': 'U',
4254
- '\u1EE4': 'U',
4255
- '\u1E72': 'U',
4256
- '\u0172': 'U',
4257
- '\u1E76': 'U',
4258
- '\u1E74': 'U',
4259
- '\u0244': 'U',
4260
- '\u24CB': 'V',
4261
- '\uFF36': 'V',
4262
- '\u1E7C': 'V',
4263
- '\u1E7E': 'V',
4264
- '\u01B2': 'V',
4265
- '\uA75E': 'V',
4266
- '\u0245': 'V',
4267
- '\uA760': 'VY',
4268
- '\u24CC': 'W',
4269
- '\uFF37': 'W',
4270
- '\u1E80': 'W',
4271
- '\u1E82': 'W',
4272
- '\u0174': 'W',
4273
- '\u1E86': 'W',
4274
- '\u1E84': 'W',
4275
- '\u1E88': 'W',
4276
- '\u2C72': 'W',
4277
- '\u24CD': 'X',
4278
- '\uFF38': 'X',
4279
- '\u1E8A': 'X',
4280
- '\u1E8C': 'X',
4281
- '\u24CE': 'Y',
4282
- '\uFF39': 'Y',
4283
- '\u1EF2': 'Y',
4284
- '\u00DD': 'Y',
4285
- '\u0176': 'Y',
4286
- '\u1EF8': 'Y',
4287
- '\u0232': 'Y',
4288
- '\u1E8E': 'Y',
4289
- '\u0178': 'Y',
4290
- '\u1EF6': 'Y',
4291
- '\u1EF4': 'Y',
4292
- '\u01B3': 'Y',
4293
- '\u024E': 'Y',
4294
- '\u1EFE': 'Y',
4295
- '\u24CF': 'Z',
4296
- '\uFF3A': 'Z',
4297
- '\u0179': 'Z',
4298
- '\u1E90': 'Z',
4299
- '\u017B': 'Z',
4300
- '\u017D': 'Z',
4301
- '\u1E92': 'Z',
4302
- '\u1E94': 'Z',
4303
- '\u01B5': 'Z',
4304
- '\u0224': 'Z',
4305
- '\u2C7F': 'Z',
4306
- '\u2C6B': 'Z',
4307
- '\uA762': 'Z',
4308
- '\u24D0': 'a',
4309
- '\uFF41': 'a',
4310
- '\u1E9A': 'a',
4311
- '\u00E0': 'a',
4312
- '\u00E1': 'a',
4313
- '\u00E2': 'a',
4314
- '\u1EA7': 'a',
4315
- '\u1EA5': 'a',
4316
- '\u1EAB': 'a',
4317
- '\u1EA9': 'a',
4318
- '\u00E3': 'a',
4319
- '\u0101': 'a',
4320
- '\u0103': 'a',
4321
- '\u1EB1': 'a',
4322
- '\u1EAF': 'a',
4323
- '\u1EB5': 'a',
4324
- '\u1EB3': 'a',
4325
- '\u0227': 'a',
4326
- '\u01E1': 'a',
4327
- '\u00E4': 'a',
4328
- '\u01DF': 'a',
4329
- '\u1EA3': 'a',
4330
- '\u00E5': 'a',
4331
- '\u01FB': 'a',
4332
- '\u01CE': 'a',
4333
- '\u0201': 'a',
4334
- '\u0203': 'a',
4335
- '\u1EA1': 'a',
4336
- '\u1EAD': 'a',
4337
- '\u1EB7': 'a',
4338
- '\u1E01': 'a',
4339
- '\u0105': 'a',
4340
- '\u2C65': 'a',
4341
- '\u0250': 'a',
4342
- '\uA733': 'aa',
4343
- '\u00E6': 'ae',
4344
- '\u01FD': 'ae',
4345
- '\u01E3': 'ae',
4346
- '\uA735': 'ao',
4347
- '\uA737': 'au',
4348
- '\uA739': 'av',
4349
- '\uA73B': 'av',
4350
- '\uA73D': 'ay',
4351
- '\u24D1': 'b',
4352
- '\uFF42': 'b',
4353
- '\u1E03': 'b',
4354
- '\u1E05': 'b',
4355
- '\u1E07': 'b',
4356
- '\u0180': 'b',
4357
- '\u0183': 'b',
4358
- '\u0253': 'b',
4359
- '\u24D2': 'c',
4360
- '\uFF43': 'c',
4361
- '\u0107': 'c',
4362
- '\u0109': 'c',
4363
- '\u010B': 'c',
4364
- '\u010D': 'c',
4365
- '\u00E7': 'c',
4366
- '\u1E09': 'c',
4367
- '\u0188': 'c',
4368
- '\u023C': 'c',
4369
- '\uA73F': 'c',
4370
- '\u2184': 'c',
4371
- '\u24D3': 'd',
4372
- '\uFF44': 'd',
4373
- '\u1E0B': 'd',
4374
- '\u010F': 'd',
4375
- '\u1E0D': 'd',
4376
- '\u1E11': 'd',
4377
- '\u1E13': 'd',
4378
- '\u1E0F': 'd',
4379
- '\u0111': 'd',
4380
- '\u018C': 'd',
4381
- '\u0256': 'd',
4382
- '\u0257': 'd',
4383
- '\uA77A': 'd',
4384
- '\u01F3': 'dz',
4385
- '\u01C6': 'dz',
4386
- '\u24D4': 'e',
4387
- '\uFF45': 'e',
4388
- '\u00E8': 'e',
4389
- '\u00E9': 'e',
4390
- '\u00EA': 'e',
4391
- '\u1EC1': 'e',
4392
- '\u1EBF': 'e',
4393
- '\u1EC5': 'e',
4394
- '\u1EC3': 'e',
4395
- '\u1EBD': 'e',
4396
- '\u0113': 'e',
4397
- '\u1E15': 'e',
4398
- '\u1E17': 'e',
4399
- '\u0115': 'e',
4400
- '\u0117': 'e',
4401
- '\u00EB': 'e',
4402
- '\u1EBB': 'e',
4403
- '\u011B': 'e',
4404
- '\u0205': 'e',
4405
- '\u0207': 'e',
4406
- '\u1EB9': 'e',
4407
- '\u1EC7': 'e',
4408
- '\u0229': 'e',
4409
- '\u1E1D': 'e',
4410
- '\u0119': 'e',
4411
- '\u1E19': 'e',
4412
- '\u1E1B': 'e',
4413
- '\u0247': 'e',
4414
- '\u025B': 'e',
4415
- '\u01DD': 'e',
4416
- '\u24D5': 'f',
4417
- '\uFF46': 'f',
4418
- '\u1E1F': 'f',
4419
- '\u0192': 'f',
4420
- '\uA77C': 'f',
4421
- '\u24D6': 'g',
4422
- '\uFF47': 'g',
4423
- '\u01F5': 'g',
4424
- '\u011D': 'g',
4425
- '\u1E21': 'g',
4426
- '\u011F': 'g',
4427
- '\u0121': 'g',
4428
- '\u01E7': 'g',
4429
- '\u0123': 'g',
4430
- '\u01E5': 'g',
4431
- '\u0260': 'g',
4432
- '\uA7A1': 'g',
4433
- '\u1D79': 'g',
4434
- '\uA77F': 'g',
4435
- '\u24D7': 'h',
4436
- '\uFF48': 'h',
4437
- '\u0125': 'h',
4438
- '\u1E23': 'h',
4439
- '\u1E27': 'h',
4440
- '\u021F': 'h',
4441
- '\u1E25': 'h',
4442
- '\u1E29': 'h',
4443
- '\u1E2B': 'h',
4444
- '\u1E96': 'h',
4445
- '\u0127': 'h',
4446
- '\u2C68': 'h',
4447
- '\u2C76': 'h',
4448
- '\u0265': 'h',
4449
- '\u0195': 'hv',
4450
- '\u24D8': 'i',
4451
- '\uFF49': 'i',
4452
- '\u00EC': 'i',
4453
- '\u00ED': 'i',
4454
- '\u00EE': 'i',
4455
- '\u0129': 'i',
4456
- '\u012B': 'i',
4457
- '\u012D': 'i',
4458
- '\u00EF': 'i',
4459
- '\u1E2F': 'i',
4460
- '\u1EC9': 'i',
4461
- '\u01D0': 'i',
4462
- '\u0209': 'i',
4463
- '\u020B': 'i',
4464
- '\u1ECB': 'i',
4465
- '\u012F': 'i',
4466
- '\u1E2D': 'i',
4467
- '\u0268': 'i',
4468
- '\u0131': 'i',
4469
- '\u24D9': 'j',
4470
- '\uFF4A': 'j',
4471
- '\u0135': 'j',
4472
- '\u01F0': 'j',
4473
- '\u0249': 'j',
4474
- '\u24DA': 'k',
4475
- '\uFF4B': 'k',
4476
- '\u1E31': 'k',
4477
- '\u01E9': 'k',
4478
- '\u1E33': 'k',
4479
- '\u0137': 'k',
4480
- '\u1E35': 'k',
4481
- '\u0199': 'k',
4482
- '\u2C6A': 'k',
4483
- '\uA741': 'k',
4484
- '\uA743': 'k',
4485
- '\uA745': 'k',
4486
- '\uA7A3': 'k',
4487
- '\u24DB': 'l',
4488
- '\uFF4C': 'l',
4489
- '\u0140': 'l',
4490
- '\u013A': 'l',
4491
- '\u013E': 'l',
4492
- '\u1E37': 'l',
4493
- '\u1E39': 'l',
4494
- '\u013C': 'l',
4495
- '\u1E3D': 'l',
4496
- '\u1E3B': 'l',
4497
- '\u017F': 'l',
4498
- '\u0142': 'l',
4499
- '\u019A': 'l',
4500
- '\u026B': 'l',
4501
- '\u2C61': 'l',
4502
- '\uA749': 'l',
4503
- '\uA781': 'l',
4504
- '\uA747': 'l',
4505
- '\u01C9': 'lj',
4506
- '\u24DC': 'm',
4507
- '\uFF4D': 'm',
4508
- '\u1E3F': 'm',
4509
- '\u1E41': 'm',
4510
- '\u1E43': 'm',
4511
- '\u0271': 'm',
4512
- '\u026F': 'm',
4513
- '\u24DD': 'n',
4514
- '\uFF4E': 'n',
4515
- '\u01F9': 'n',
4516
- '\u0144': 'n',
4517
- '\u00F1': 'n',
4518
- '\u1E45': 'n',
4519
- '\u0148': 'n',
4520
- '\u1E47': 'n',
4521
- '\u0146': 'n',
4522
- '\u1E4B': 'n',
4523
- '\u1E49': 'n',
4524
- '\u019E': 'n',
4525
- '\u0272': 'n',
4526
- '\u0149': 'n',
4527
- '\uA791': 'n',
4528
- '\uA7A5': 'n',
4529
- '\u01CC': 'nj',
4530
- '\u24DE': 'o',
4531
- '\uFF4F': 'o',
4532
- '\u00F2': 'o',
4533
- '\u00F3': 'o',
4534
- '\u00F4': 'o',
4535
- '\u1ED3': 'o',
4536
- '\u1ED1': 'o',
4537
- '\u1ED7': 'o',
4538
- '\u1ED5': 'o',
4539
- '\u00F5': 'o',
4540
- '\u1E4D': 'o',
4541
- '\u022D': 'o',
4542
- '\u1E4F': 'o',
4543
- '\u014D': 'o',
4544
- '\u1E51': 'o',
4545
- '\u1E53': 'o',
4546
- '\u014F': 'o',
4547
- '\u022F': 'o',
4548
- '\u0231': 'o',
4549
- '\u00F6': 'o',
4550
- '\u022B': 'o',
4551
- '\u1ECF': 'o',
4552
- '\u0151': 'o',
4553
- '\u01D2': 'o',
4554
- '\u020D': 'o',
4555
- '\u020F': 'o',
4556
- '\u01A1': 'o',
4557
- '\u1EDD': 'o',
4558
- '\u1EDB': 'o',
4559
- '\u1EE1': 'o',
4560
- '\u1EDF': 'o',
4561
- '\u1EE3': 'o',
4562
- '\u1ECD': 'o',
4563
- '\u1ED9': 'o',
4564
- '\u01EB': 'o',
4565
- '\u01ED': 'o',
4566
- '\u00F8': 'o',
4567
- '\u01FF': 'o',
4568
- '\u0254': 'o',
4569
- '\uA74B': 'o',
4570
- '\uA74D': 'o',
4571
- '\u0275': 'o',
4572
- '\u01A3': 'oi',
4573
- '\u0223': 'ou',
4574
- '\uA74F': 'oo',
4575
- '\u24DF': 'p',
4576
- '\uFF50': 'p',
4577
- '\u1E55': 'p',
4578
- '\u1E57': 'p',
4579
- '\u01A5': 'p',
4580
- '\u1D7D': 'p',
4581
- '\uA751': 'p',
4582
- '\uA753': 'p',
4583
- '\uA755': 'p',
4584
- '\u24E0': 'q',
4585
- '\uFF51': 'q',
4586
- '\u024B': 'q',
4587
- '\uA757': 'q',
4588
- '\uA759': 'q',
4589
- '\u24E1': 'r',
4590
- '\uFF52': 'r',
4591
- '\u0155': 'r',
4592
- '\u1E59': 'r',
4593
- '\u0159': 'r',
4594
- '\u0211': 'r',
4595
- '\u0213': 'r',
4596
- '\u1E5B': 'r',
4597
- '\u1E5D': 'r',
4598
- '\u0157': 'r',
4599
- '\u1E5F': 'r',
4600
- '\u024D': 'r',
4601
- '\u027D': 'r',
4602
- '\uA75B': 'r',
4603
- '\uA7A7': 'r',
4604
- '\uA783': 'r',
4605
- '\u24E2': 's',
4606
- '\uFF53': 's',
4607
- '\u00DF': 's',
4608
- '\u015B': 's',
4609
- '\u1E65': 's',
4610
- '\u015D': 's',
4611
- '\u1E61': 's',
4612
- '\u0161': 's',
4613
- '\u1E67': 's',
4614
- '\u1E63': 's',
4615
- '\u1E69': 's',
4616
- '\u0219': 's',
4617
- '\u015F': 's',
4618
- '\u023F': 's',
4619
- '\uA7A9': 's',
4620
- '\uA785': 's',
4621
- '\u1E9B': 's',
4622
- '\u24E3': 't',
4623
- '\uFF54': 't',
4624
- '\u1E6B': 't',
4625
- '\u1E97': 't',
4626
- '\u0165': 't',
4627
- '\u1E6D': 't',
4628
- '\u021B': 't',
4629
- '\u0163': 't',
4630
- '\u1E71': 't',
4631
- '\u1E6F': 't',
4632
- '\u0167': 't',
4633
- '\u01AD': 't',
4634
- '\u0288': 't',
4635
- '\u2C66': 't',
4636
- '\uA787': 't',
4637
- '\uA729': 'tz',
4638
- '\u24E4': 'u',
4639
- '\uFF55': 'u',
4640
- '\u00F9': 'u',
4641
- '\u00FA': 'u',
4642
- '\u00FB': 'u',
4643
- '\u0169': 'u',
4644
- '\u1E79': 'u',
4645
- '\u016B': 'u',
4646
- '\u1E7B': 'u',
4647
- '\u016D': 'u',
4648
- '\u00FC': 'u',
4649
- '\u01DC': 'u',
4650
- '\u01D8': 'u',
4651
- '\u01D6': 'u',
4652
- '\u01DA': 'u',
4653
- '\u1EE7': 'u',
4654
- '\u016F': 'u',
4655
- '\u0171': 'u',
4656
- '\u01D4': 'u',
4657
- '\u0215': 'u',
4658
- '\u0217': 'u',
4659
- '\u01B0': 'u',
4660
- '\u1EEB': 'u',
4661
- '\u1EE9': 'u',
4662
- '\u1EEF': 'u',
4663
- '\u1EED': 'u',
4664
- '\u1EF1': 'u',
4665
- '\u1EE5': 'u',
4666
- '\u1E73': 'u',
4667
- '\u0173': 'u',
4668
- '\u1E77': 'u',
4669
- '\u1E75': 'u',
4670
- '\u0289': 'u',
4671
- '\u24E5': 'v',
4672
- '\uFF56': 'v',
4673
- '\u1E7D': 'v',
4674
- '\u1E7F': 'v',
4675
- '\u028B': 'v',
4676
- '\uA75F': 'v',
4677
- '\u028C': 'v',
4678
- '\uA761': 'vy',
4679
- '\u24E6': 'w',
4680
- '\uFF57': 'w',
4681
- '\u1E81': 'w',
4682
- '\u1E83': 'w',
4683
- '\u0175': 'w',
4684
- '\u1E87': 'w',
4685
- '\u1E85': 'w',
4686
- '\u1E98': 'w',
4687
- '\u1E89': 'w',
4688
- '\u2C73': 'w',
4689
- '\u24E7': 'x',
4690
- '\uFF58': 'x',
4691
- '\u1E8B': 'x',
4692
- '\u1E8D': 'x',
4693
- '\u24E8': 'y',
4694
- '\uFF59': 'y',
4695
- '\u1EF3': 'y',
4696
- '\u00FD': 'y',
4697
- '\u0177': 'y',
4698
- '\u1EF9': 'y',
4699
- '\u0233': 'y',
4700
- '\u1E8F': 'y',
4701
- '\u00FF': 'y',
4702
- '\u1EF7': 'y',
4703
- '\u1E99': 'y',
4704
- '\u1EF5': 'y',
4705
- '\u01B4': 'y',
4706
- '\u024F': 'y',
4707
- '\u1EFF': 'y',
4708
- '\u24E9': 'z',
4709
- '\uFF5A': 'z',
4710
- '\u017A': 'z',
4711
- '\u1E91': 'z',
4712
- '\u017C': 'z',
4713
- '\u017E': 'z',
4714
- '\u1E93': 'z',
4715
- '\u1E95': 'z',
4716
- '\u01B6': 'z',
4717
- '\u0225': 'z',
4718
- '\u0240': 'z',
4719
- '\u2C6C': 'z',
4720
- '\uA763': 'z',
4721
- '\u0386': '\u0391',
4722
- '\u0388': '\u0395',
4723
- '\u0389': '\u0397',
4724
- '\u038A': '\u0399',
4725
- '\u03AA': '\u0399',
4726
- '\u038C': '\u039F',
4727
- '\u038E': '\u03A5',
4728
- '\u03AB': '\u03A5',
4729
- '\u038F': '\u03A9',
4730
- '\u03AC': '\u03B1',
4731
- '\u03AD': '\u03B5',
4732
- '\u03AE': '\u03B7',
4733
- '\u03AF': '\u03B9',
4734
- '\u03CA': '\u03B9',
4735
- '\u0390': '\u03B9',
4736
- '\u03CC': '\u03BF',
4737
- '\u03CD': '\u03C5',
4738
- '\u03CB': '\u03C5',
4739
- '\u03B0': '\u03C5',
4740
- '\u03C9': '\u03C9',
4741
- '\u03C2': '\u03C3'
4742
- };
4743
-
4744
- return diacritics;
4745
- });
4746
-
4747
- S2.define('select2/data/base',[
4748
- '../utils'
4749
- ], function (Utils) {
4750
- function BaseAdapter ($element, options) {
4751
- BaseAdapter.__super__.constructor.call(this);
4752
- }
4753
-
4754
- Utils.Extend(BaseAdapter, Utils.Observable);
4755
-
4756
- BaseAdapter.prototype.current = function (callback) {
4757
- throw new Error('The `current` method must be defined in child classes.');
4758
- };
4759
-
4760
- BaseAdapter.prototype.query = function (params, callback) {
4761
- throw new Error('The `query` method must be defined in child classes.');
4762
- };
4763
-
4764
- BaseAdapter.prototype.bind = function (container, $container) {
4765
- // Can be implemented in subclasses
4766
- };
4767
-
4768
- BaseAdapter.prototype.destroy = function () {
4769
- // Can be implemented in subclasses
4770
- };
4771
-
4772
- BaseAdapter.prototype.generateResultId = function (container, data) {
4773
- var id = container.id + '-result-';
4774
-
4775
- id += Utils.generateChars(4);
4776
-
4777
- if (data.id != null) {
4778
- id += '-' + data.id.toString();
4779
- } else {
4780
- id += '-' + Utils.generateChars(4);
4781
- }
4782
- return id;
4783
- };
4784
-
4785
- return BaseAdapter;
4786
- });
4787
-
4788
- S2.define('select2/data/select',[
4789
- './base',
4790
- '../utils',
4791
- 'jquery'
4792
- ], function (BaseAdapter, Utils, $) {
4793
- function SelectAdapter ($element, options) {
4794
- this.$element = $element;
4795
- this.options = options;
4796
-
4797
- SelectAdapter.__super__.constructor.call(this);
4798
- }
4799
-
4800
- Utils.Extend(SelectAdapter, BaseAdapter);
4801
-
4802
- SelectAdapter.prototype.current = function (callback) {
4803
- var data = [];
4804
- var self = this;
4805
-
4806
- this.$element.find(':selected').each(function () {
4807
- var $option = $(this);
4808
-
4809
- var option = self.item($option);
4810
-
4811
- data.push(option);
4812
- });
4813
-
4814
- callback(data);
4815
- };
4816
-
4817
- SelectAdapter.prototype.select = function (data) {
4818
- var self = this;
4819
-
4820
- data.selected = true;
4821
-
4822
- // If data.element is a DOM node, use it instead
4823
- if ($(data.element).is('option')) {
4824
- data.element.selected = true;
4825
-
4826
- this.$element.trigger('change');
4827
-
4828
- return;
4829
- }
4830
-
4831
- if (this.$element.prop('multiple')) {
4832
- this.current(function (currentData) {
4833
- var val = [];
4834
-
4835
- data = [data];
4836
- data.push.apply(data, currentData);
4837
-
4838
- for (var d = 0; d < data.length; d++) {
4839
- var id = data[d].id;
4840
-
4841
- if ($.inArray(id, val) === -1) {
4842
- val.push(id);
4843
- }
4844
- }
4845
-
4846
- self.$element.val(val);
4847
- self.$element.trigger('change');
4848
- });
4849
- } else {
4850
- var val = data.id;
4851
-
4852
- this.$element.val(val);
4853
- this.$element.trigger('change');
4854
- }
4855
- };
4856
-
4857
- SelectAdapter.prototype.unselect = function (data) {
4858
- var self = this;
4859
-
4860
- if (!this.$element.prop('multiple')) {
4861
- return;
4862
- }
4863
-
4864
- data.selected = false;
4865
-
4866
- if ($(data.element).is('option')) {
4867
- data.element.selected = false;
4868
-
4869
- this.$element.trigger('change');
4870
-
4871
- return;
4872
- }
4873
-
4874
- this.current(function (currentData) {
4875
- var val = [];
4876
-
4877
- for (var d = 0; d < currentData.length; d++) {
4878
- var id = currentData[d].id;
4879
-
4880
- if (id !== data.id && $.inArray(id, val) === -1) {
4881
- val.push(id);
4882
- }
4883
- }
4884
-
4885
- self.$element.val(val);
4886
-
4887
- self.$element.trigger('change');
4888
- });
4889
- };
4890
-
4891
- SelectAdapter.prototype.bind = function (container, $container) {
4892
- var self = this;
4893
-
4894
- this.container = container;
4895
-
4896
- container.on('select', function (params) {
4897
- self.select(params.data);
4898
- });
4899
-
4900
- container.on('unselect', function (params) {
4901
- self.unselect(params.data);
4902
- });
4903
- };
4904
-
4905
- SelectAdapter.prototype.destroy = function () {
4906
- // Remove anything added to child elements
4907
- this.$element.find('*').each(function () {
4908
- // Remove any custom data set by Select2
4909
- $.removeData(this, 'data');
4910
- });
4911
- };
4912
-
4913
- SelectAdapter.prototype.query = function (params, callback) {
4914
- var data = [];
4915
- var self = this;
4916
-
4917
- var $options = this.$element.children();
4918
-
4919
- $options.each(function () {
4920
- var $option = $(this);
4921
-
4922
- if (!$option.is('option') && !$option.is('optgroup')) {
4923
- return;
4924
- }
4925
-
4926
- var option = self.item($option);
4927
-
4928
- var matches = self.matches(params, option);
4929
-
4930
- if (matches !== null) {
4931
- data.push(matches);
4932
- }
4933
- });
4934
-
4935
- callback({
4936
- results: data
4937
- });
4938
- };
4939
-
4940
- SelectAdapter.prototype.addOptions = function ($options) {
4941
- Utils.appendMany(this.$element, $options);
4942
- };
4943
-
4944
- SelectAdapter.prototype.option = function (data) {
4945
- var option;
4946
-
4947
- if (data.children) {
4948
- option = document.createElement('optgroup');
4949
- option.label = data.text;
4950
- } else {
4951
- option = document.createElement('option');
4952
-
4953
- if (option.textContent !== undefined) {
4954
- option.textContent = data.text;
4955
- } else {
4956
- option.innerText = data.text;
4957
- }
4958
- }
4959
-
4960
- if (data.id !== undefined) {
4961
- option.value = data.id;
4962
- }
4963
-
4964
- if (data.disabled) {
4965
- option.disabled = true;
4966
- }
4967
-
4968
- if (data.selected) {
4969
- option.selected = true;
4970
- }
4971
-
4972
- if (data.title) {
4973
- option.title = data.title;
4974
- }
4975
-
4976
- var $option = $(option);
4977
-
4978
- var normalizedData = this._normalizeItem(data);
4979
- normalizedData.element = option;
4980
-
4981
- // Override the option's data with the combined data
4982
- $.data(option, 'data', normalizedData);
4983
-
4984
- return $option;
4985
- };
4986
-
4987
- SelectAdapter.prototype.item = function ($option) {
4988
- var data = {};
4989
-
4990
- data = $.data($option[0], 'data');
4991
-
4992
- if (data != null) {
4993
- return data;
4994
- }
4995
-
4996
- if ($option.is('option')) {
4997
- data = {
4998
- id: $option.val(),
4999
- text: $option.text(),
5000
- disabled: $option.prop('disabled'),
5001
- selected: $option.prop('selected'),
5002
- title: $option.prop('title')
5003
- };
5004
- } else if ($option.is('optgroup')) {
5005
- data = {
5006
- text: $option.prop('label'),
5007
- children: [],
5008
- title: $option.prop('title')
5009
- };
5010
-
5011
- var $children = $option.children('option');
5012
- var children = [];
5013
-
5014
- for (var c = 0; c < $children.length; c++) {
5015
- var $child = $($children[c]);
5016
-
5017
- var child = this.item($child);
5018
-
5019
- children.push(child);
5020
- }
5021
-
5022
- data.children = children;
5023
- }
5024
-
5025
- data = this._normalizeItem(data);
5026
- data.element = $option[0];
5027
-
5028
- $.data($option[0], 'data', data);
5029
-
5030
- return data;
5031
- };
5032
-
5033
- SelectAdapter.prototype._normalizeItem = function (item) {
5034
- if (!$.isPlainObject(item)) {
5035
- item = {
5036
- id: item,
5037
- text: item
5038
- };
5039
- }
5040
-
5041
- item = $.extend({}, {
5042
- text: ''
5043
- }, item);
5044
-
5045
- var defaults = {
5046
- selected: false,
5047
- disabled: false
5048
- };
5049
-
5050
- if (item.id != null) {
5051
- item.id = item.id.toString();
5052
- }
5053
-
5054
- if (item.text != null) {
5055
- item.text = item.text.toString();
5056
- }
5057
-
5058
- if (item._resultId == null && item.id && this.container != null) {
5059
- item._resultId = this.generateResultId(this.container, item);
5060
- }
5061
-
5062
- return $.extend({}, defaults, item);
5063
- };
5064
-
5065
- SelectAdapter.prototype.matches = function (params, data) {
5066
- var matcher = this.options.get('matcher');
5067
-
5068
- return matcher(params, data);
5069
- };
5070
-
5071
- return SelectAdapter;
5072
- });
5073
-
5074
- S2.define('select2/data/array',[
5075
- './select',
5076
- '../utils',
5077
- 'jquery'
5078
- ], function (SelectAdapter, Utils, $) {
5079
- function ArrayAdapter ($element, options) {
5080
- var data = options.get('data') || [];
5081
-
5082
- ArrayAdapter.__super__.constructor.call(this, $element, options);
5083
-
5084
- this.addOptions(this.convertToOptions(data));
5085
- }
5086
-
5087
- Utils.Extend(ArrayAdapter, SelectAdapter);
5088
-
5089
- ArrayAdapter.prototype.select = function (data) {
5090
- var $option = this.$element.find('option').filter(function (i, elm) {
5091
- return elm.value == data.id.toString();
5092
- });
5093
-
5094
- if ($option.length === 0) {
5095
- $option = this.option(data);
5096
-
5097
- this.addOptions($option);
5098
- }
5099
-
5100
- ArrayAdapter.__super__.select.call(this, data);
5101
- };
5102
-
5103
- ArrayAdapter.prototype.convertToOptions = function (data) {
5104
- var self = this;
5105
-
5106
- var $existing = this.$element.find('option');
5107
- var existingIds = $existing.map(function () {
5108
- return self.item($(this)).id;
5109
- }).get();
5110
-
5111
- var $options = [];
5112
-
5113
- // Filter out all items except for the one passed in the argument
5114
- function onlyItem (item) {
5115
- return function () {
5116
- return $(this).val() == item.id;
5117
- };
5118
- }
5119
-
5120
- for (var d = 0; d < data.length; d++) {
5121
- var item = this._normalizeItem(data[d]);
5122
-
5123
- // Skip items which were pre-loaded, only merge the data
5124
- if ($.inArray(item.id, existingIds) >= 0) {
5125
- var $existingOption = $existing.filter(onlyItem(item));
5126
-
5127
- var existingData = this.item($existingOption);
5128
- var newData = $.extend(true, {}, item, existingData);
5129
-
5130
- var $newOption = this.option(newData);
5131
-
5132
- $existingOption.replaceWith($newOption);
5133
-
5134
- continue;
5135
- }
5136
-
5137
- var $option = this.option(item);
5138
-
5139
- if (item.children) {
5140
- var $children = this.convertToOptions(item.children);
5141
-
5142
- Utils.appendMany($option, $children);
5143
- }
5144
-
5145
- $options.push($option);
5146
- }
5147
-
5148
- return $options;
5149
- };
5150
-
5151
- return ArrayAdapter;
5152
- });
5153
-
5154
- S2.define('select2/data/ajax',[
5155
- './array',
5156
- '../utils',
5157
- 'jquery'
5158
- ], function (ArrayAdapter, Utils, $) {
5159
- function AjaxAdapter ($element, options) {
5160
- this.ajaxOptions = this._applyDefaults(options.get('ajax'));
5161
-
5162
- if (this.ajaxOptions.processResults != null) {
5163
- this.processResults = this.ajaxOptions.processResults;
5164
- }
5165
-
5166
- AjaxAdapter.__super__.constructor.call(this, $element, options);
5167
- }
5168
-
5169
- Utils.Extend(AjaxAdapter, ArrayAdapter);
5170
-
5171
- AjaxAdapter.prototype._applyDefaults = function (options) {
5172
- var defaults = {
5173
- data: function (params) {
5174
- return $.extend({}, params, {
5175
- q: params.term
5176
- });
5177
- },
5178
- transport: function (params, success, failure) {
5179
- var $request = $.ajax(params);
5180
-
5181
- $request.then(success);
5182
- $request.fail(failure);
5183
-
5184
- return $request;
5185
- }
5186
- };
5187
-
5188
- return $.extend({}, defaults, options, true);
5189
- };
5190
-
5191
- AjaxAdapter.prototype.processResults = function (results) {
5192
- return results;
5193
- };
5194
-
5195
- AjaxAdapter.prototype.query = function (params, callback) {
5196
- var matches = [];
5197
- var self = this;
5198
-
5199
- if (this._request != null) {
5200
- // JSONP requests cannot always be aborted
5201
- if ($.isFunction(this._request.abort)) {
5202
- this._request.abort();
5203
- }
5204
-
5205
- this._request = null;
5206
- }
5207
-
5208
- var options = $.extend({
5209
- type: 'GET'
5210
- }, this.ajaxOptions);
5211
-
5212
- if (typeof options.url === 'function') {
5213
- options.url = options.url.call(this.$element, params);
5214
- }
5215
-
5216
- if (typeof options.data === 'function') {
5217
- options.data = options.data.call(this.$element, params);
5218
- }
5219
-
5220
- function request () {
5221
- var $request = options.transport(options, function (data) {
5222
- var results = self.processResults(data, params);
5223
-
5224
- if (self.options.get('debug') && window.console && console.error) {
5225
- // Check to make sure that the response included a `results` key.
5226
- if (!results || !results.results || !$.isArray(results.results)) {
5227
- console.error(
5228
- 'Select2: The AJAX results did not return an array in the ' +
5229
- '`results` key of the response.'
5230
- );
5231
- }
5232
- }
5233
-
5234
- callback(results);
5235
- }, function () {
5236
- // Attempt to detect if a request was aborted
5237
- // Only works if the transport exposes a status property
5238
- if ($request.status && $request.status === '0') {
5239
- return;
5240
- }
5241
-
5242
- self.trigger('results:message', {
5243
- message: 'errorLoading'
5244
- });
5245
- });
5246
-
5247
- self._request = $request;
5248
- }
5249
-
5250
- if (this.ajaxOptions.delay && params.term != null) {
5251
- if (this._queryTimeout) {
5252
- window.clearTimeout(this._queryTimeout);
5253
- }
5254
-
5255
- this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
5256
- } else {
5257
- request();
5258
- }
5259
- };
5260
-
5261
- return AjaxAdapter;
5262
- });
5263
-
5264
- S2.define('select2/data/tags',[
5265
- 'jquery'
5266
- ], function ($) {
5267
- function Tags (decorated, $element, options) {
5268
- var tags = options.get('tags');
5269
-
5270
- var createTag = options.get('createTag');
5271
-
5272
- if (createTag !== undefined) {
5273
- this.createTag = createTag;
5274
- }
5275
-
5276
- var insertTag = options.get('insertTag');
5277
-
5278
- if (insertTag !== undefined) {
5279
- this.insertTag = insertTag;
5280
- }
5281
-
5282
- decorated.call(this, $element, options);
5283
-
5284
- if ($.isArray(tags)) {
5285
- for (var t = 0; t < tags.length; t++) {
5286
- var tag = tags[t];
5287
- var item = this._normalizeItem(tag);
5288
-
5289
- var $option = this.option(item);
5290
-
5291
- this.$element.append($option);
5292
- }
5293
- }
5294
- }
5295
-
5296
- Tags.prototype.query = function (decorated, params, callback) {
5297
- var self = this;
5298
-
5299
- this._removeOldTags();
5300
-
5301
- if (params.term == null || params.page != null) {
5302
- decorated.call(this, params, callback);
5303
- return;
5304
- }
5305
-
5306
- function wrapper (obj, child) {
5307
- var data = obj.results;
5308
-
5309
- for (var i = 0; i < data.length; i++) {
5310
- var option = data[i];
5311
-
5312
- var checkChildren = (
5313
- option.children != null &&
5314
- !wrapper({
5315
- results: option.children
5316
- }, true)
5317
- );
5318
-
5319
- var optionText = (option.text || '').toUpperCase();
5320
- var paramsTerm = (params.term || '').toUpperCase();
5321
-
5322
- var checkText = optionText === paramsTerm;
5323
-
5324
- if (checkText || checkChildren) {
5325
- if (child) {
5326
- return false;
5327
- }
5328
-
5329
- obj.data = data;
5330
- callback(obj);
5331
-
5332
- return;
5333
- }
5334
- }
5335
-
5336
- if (child) {
5337
- return true;
5338
- }
5339
-
5340
- var tag = self.createTag(params);
5341
-
5342
- if (tag != null) {
5343
- var $option = self.option(tag);
5344
- $option.attr('data-select2-tag', true);
5345
-
5346
- self.addOptions([$option]);
5347
-
5348
- self.insertTag(data, tag);
5349
- }
5350
-
5351
- obj.results = data;
5352
-
5353
- callback(obj);
5354
- }
5355
-
5356
- decorated.call(this, params, wrapper);
5357
- };
5358
-
5359
- Tags.prototype.createTag = function (decorated, params) {
5360
- var term = $.trim(params.term);
5361
-
5362
- if (term === '') {
5363
- return null;
5364
- }
5365
-
5366
- return {
5367
- id: term,
5368
- text: term
5369
- };
5370
- };
5371
-
5372
- Tags.prototype.insertTag = function (_, data, tag) {
5373
- data.unshift(tag);
5374
- };
5375
-
5376
- Tags.prototype._removeOldTags = function (_) {
5377
- var tag = this._lastTag;
5378
-
5379
- var $options = this.$element.find('option[data-select2-tag]');
5380
-
5381
- $options.each(function () {
5382
- if (this.selected) {
5383
- return;
5384
- }
5385
-
5386
- $(this).remove();
5387
- });
5388
- };
5389
-
5390
- return Tags;
5391
- });
5392
-
5393
- S2.define('select2/data/tokenizer',[
5394
- 'jquery'
5395
- ], function ($) {
5396
- function Tokenizer (decorated, $element, options) {
5397
- var tokenizer = options.get('tokenizer');
5398
-
5399
- if (tokenizer !== undefined) {
5400
- this.tokenizer = tokenizer;
5401
- }
5402
-
5403
- decorated.call(this, $element, options);
5404
- }
5405
-
5406
- Tokenizer.prototype.bind = function (decorated, container, $container) {
5407
- decorated.call(this, container, $container);
5408
-
5409
- this.$search = container.dropdown.$search || container.selection.$search ||
5410
- $container.find('.select2-search__field');
5411
- };
5412
-
5413
- Tokenizer.prototype.query = function (decorated, params, callback) {
5414
- var self = this;
5415
-
5416
- function createAndSelect (data) {
5417
- // Normalize the data object so we can use it for checks
5418
- var item = self._normalizeItem(data);
5419
-
5420
- // Check if the data object already exists as a tag
5421
- // Select it if it doesn't
5422
- var $existingOptions = self.$element.find('option').filter(function () {
5423
- return $(this).val() === item.id;
5424
- });
5425
-
5426
- // If an existing option wasn't found for it, create the option
5427
- if (!$existingOptions.length) {
5428
- var $option = self.option(item);
5429
- $option.attr('data-select2-tag', true);
5430
-
5431
- self._removeOldTags();
5432
- self.addOptions([$option]);
5433
- }
5434
-
5435
- // Select the item, now that we know there is an option for it
5436
- select(item);
5437
- }
5438
-
5439
- function select (data) {
5440
- self.trigger('select', {
5441
- data: data
5442
- });
5443
- }
5444
-
5445
- params.term = params.term || '';
5446
-
5447
- var tokenData = this.tokenizer(params, this.options, createAndSelect);
5448
-
5449
- if (tokenData.term !== params.term) {
5450
- // Replace the search term if we have the search box
5451
- if (this.$search.length) {
5452
- this.$search.val(tokenData.term);
5453
- this.$search.focus();
5454
- }
5455
-
5456
- params.term = tokenData.term;
5457
- }
5458
-
5459
- decorated.call(this, params, callback);
5460
- };
5461
-
5462
- Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
5463
- var separators = options.get('tokenSeparators') || [];
5464
- var term = params.term;
5465
- var i = 0;
5466
-
5467
- var createTag = this.createTag || function (params) {
5468
- return {
5469
- id: params.term,
5470
- text: params.term
5471
- };
5472
- };
5473
-
5474
- while (i < term.length) {
5475
- var termChar = term[i];
5476
-
5477
- if ($.inArray(termChar, separators) === -1) {
5478
- i++;
5479
-
5480
- continue;
5481
- }
5482
-
5483
- var part = term.substr(0, i);
5484
- var partParams = $.extend({}, params, {
5485
- term: part
5486
- });
5487
-
5488
- var data = createTag(partParams);
5489
-
5490
- if (data == null) {
5491
- i++;
5492
- continue;
5493
- }
5494
-
5495
- callback(data);
5496
-
5497
- // Reset the term to not include the tokenized portion
5498
- term = term.substr(i + 1) || '';
5499
- i = 0;
5500
- }
5501
-
5502
- return {
5503
- term: term
5504
- };
5505
- };
5506
-
5507
- return Tokenizer;
5508
- });
5509
-
5510
- S2.define('select2/data/minimumInputLength',[
5511
-
5512
- ], function () {
5513
- function MinimumInputLength (decorated, $e, options) {
5514
- this.minimumInputLength = options.get('minimumInputLength');
5515
-
5516
- decorated.call(this, $e, options);
5517
- }
5518
-
5519
- MinimumInputLength.prototype.query = function (decorated, params, callback) {
5520
- params.term = params.term || '';
5521
-
5522
- if (params.term.length < this.minimumInputLength) {
5523
- this.trigger('results:message', {
5524
- message: 'inputTooShort',
5525
- args: {
5526
- minimum: this.minimumInputLength,
5527
- input: params.term,
5528
- params: params
5529
- }
5530
- });
5531
-
5532
- return;
5533
- }
5534
-
5535
- decorated.call(this, params, callback);
5536
- };
5537
-
5538
- return MinimumInputLength;
5539
- });
5540
-
5541
- S2.define('select2/data/maximumInputLength',[
5542
-
5543
- ], function () {
5544
- function MaximumInputLength (decorated, $e, options) {
5545
- this.maximumInputLength = options.get('maximumInputLength');
5546
-
5547
- decorated.call(this, $e, options);
5548
- }
5549
-
5550
- MaximumInputLength.prototype.query = function (decorated, params, callback) {
5551
- params.term = params.term || '';
5552
-
5553
- if (this.maximumInputLength > 0 &&
5554
- params.term.length > this.maximumInputLength) {
5555
- this.trigger('results:message', {
5556
- message: 'inputTooLong',
5557
- args: {
5558
- maximum: this.maximumInputLength,
5559
- input: params.term,
5560
- params: params
5561
- }
5562
- });
5563
-
5564
- return;
5565
- }
5566
-
5567
- decorated.call(this, params, callback);
5568
- };
5569
-
5570
- return MaximumInputLength;
5571
- });
5572
-
5573
- S2.define('select2/data/maximumSelectionLength',[
5574
-
5575
- ], function (){
5576
- function MaximumSelectionLength (decorated, $e, options) {
5577
- this.maximumSelectionLength = options.get('maximumSelectionLength');
5578
-
5579
- decorated.call(this, $e, options);
5580
- }
5581
-
5582
- MaximumSelectionLength.prototype.query =
5583
- function (decorated, params, callback) {
5584
- var self = this;
5585
-
5586
- this.current(function (currentData) {
5587
- var count = currentData != null ? currentData.length : 0;
5588
- if (self.maximumSelectionLength > 0 &&
5589
- count >= self.maximumSelectionLength) {
5590
- self.trigger('results:message', {
5591
- message: 'maximumSelected',
5592
- args: {
5593
- maximum: self.maximumSelectionLength
5594
- }
5595
- });
5596
- return;
5597
- }
5598
- decorated.call(self, params, callback);
5599
- });
5600
- };
5601
-
5602
- return MaximumSelectionLength;
5603
- });
5604
-
5605
- S2.define('select2/dropdown',[
5606
- 'jquery',
5607
- './utils'
5608
- ], function ($, Utils) {
5609
- function Dropdown ($element, options) {
5610
- this.$element = $element;
5611
- this.options = options;
5612
-
5613
- Dropdown.__super__.constructor.call(this);
5614
- }
5615
-
5616
- Utils.Extend(Dropdown, Utils.Observable);
5617
-
5618
- Dropdown.prototype.render = function () {
5619
- var $dropdown = $(
5620
- '<span class="select2-dropdown">' +
5621
- '<span class="select2-results"></span>' +
5622
- '</span>'
5623
- );
5624
-
5625
- $dropdown.attr('dir', this.options.get('dir'));
5626
-
5627
- this.$dropdown = $dropdown;
5628
-
5629
- return $dropdown;
5630
- };
5631
-
5632
- Dropdown.prototype.bind = function () {
5633
- // Should be implemented in subclasses
5634
- };
5635
-
5636
- Dropdown.prototype.position = function ($dropdown, $container) {
5637
- // Should be implmented in subclasses
5638
- };
5639
-
5640
- Dropdown.prototype.destroy = function () {
5641
- // Remove the dropdown from the DOM
5642
- this.$dropdown.remove();
5643
- };
5644
-
5645
- return Dropdown;
5646
- });
5647
-
5648
- S2.define('select2/dropdown/search',[
5649
- 'jquery',
5650
- '../utils'
5651
- ], function ($, Utils) {
5652
- function Search () { }
5653
-
5654
- Search.prototype.render = function (decorated) {
5655
- var $rendered = decorated.call(this);
5656
-
5657
- var $search = $(
5658
- '<span class="select2-search select2-search--dropdown">' +
5659
- '<input class="select2-search__field" type="search" tabindex="-1"' +
5660
- ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
5661
- ' spellcheck="false" role="textbox" />' +
5662
- '</span>'
5663
- );
5664
-
5665
- this.$searchContainer = $search;
5666
- this.$search = $search.find('input');
5667
-
5668
- $rendered.prepend($search);
5669
-
5670
- return $rendered;
5671
- };
5672
-
5673
- Search.prototype.bind = function (decorated, container, $container) {
5674
- var self = this;
5675
-
5676
- decorated.call(this, container, $container);
5677
-
5678
- this.$search.on('keydown', function (evt) {
5679
- self.trigger('keypress', evt);
5680
-
5681
- self._keyUpPrevented = evt.isDefaultPrevented();
5682
- });
5683
-
5684
- // Workaround for browsers which do not support the `input` event
5685
- // This will prevent double-triggering of events for browsers which support
5686
- // both the `keyup` and `input` events.
5687
- this.$search.on('input', function (evt) {
5688
- // Unbind the duplicated `keyup` event
5689
- $(this).off('keyup');
5690
- });
5691
-
5692
- this.$search.on('keyup input', function (evt) {
5693
- self.handleSearch(evt);
5694
- });
5695
-
5696
- container.on('open', function () {
5697
- self.$search.attr('tabindex', 0);
5698
-
5699
- self.$search.focus();
5700
-
5701
- window.setTimeout(function () {
5702
- self.$search.focus();
5703
- }, 0);
5704
- });
5705
-
5706
- container.on('close', function () {
5707
- self.$search.attr('tabindex', -1);
5708
-
5709
- self.$search.val('');
5710
- });
5711
-
5712
- container.on('focus', function () {
5713
- if (!container.isOpen()) {
5714
- self.$search.focus();
5715
- }
5716
- });
5717
-
5718
- container.on('results:all', function (params) {
5719
- if (params.query.term == null || params.query.term === '') {
5720
- var showSearch = self.showSearch(params);
5721
-
5722
- if (showSearch) {
5723
- self.$searchContainer.removeClass('select2-search--hide');
5724
- } else {
5725
- self.$searchContainer.addClass('select2-search--hide');
5726
- }
5727
- }
5728
- });
5729
- };
5730
-
5731
- Search.prototype.handleSearch = function (evt) {
5732
- if (!this._keyUpPrevented) {
5733
- var input = this.$search.val();
5734
-
5735
- this.trigger('query', {
5736
- term: input
5737
- });
5738
- }
5739
-
5740
- this._keyUpPrevented = false;
5741
- };
5742
-
5743
- Search.prototype.showSearch = function (_, params) {
5744
- return true;
5745
- };
5746
-
5747
- return Search;
5748
- });
5749
-
5750
- S2.define('select2/dropdown/hidePlaceholder',[
5751
-
5752
- ], function () {
5753
- function HidePlaceholder (decorated, $element, options, dataAdapter) {
5754
- this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
5755
-
5756
- decorated.call(this, $element, options, dataAdapter);
5757
- }
5758
-
5759
- HidePlaceholder.prototype.append = function (decorated, data) {
5760
- data.results = this.removePlaceholder(data.results);
5761
-
5762
- decorated.call(this, data);
5763
- };
5764
-
5765
- HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
5766
- if (typeof placeholder === 'string') {
5767
- placeholder = {
5768
- id: '',
5769
- text: placeholder
5770
- };
5771
- }
5772
-
5773
- return placeholder;
5774
- };
5775
-
5776
- HidePlaceholder.prototype.removePlaceholder = function (_, data) {
5777
- var modifiedData = data.slice(0);
5778
-
5779
- for (var d = data.length - 1; d >= 0; d--) {
5780
- var item = data[d];
5781
-
5782
- if (this.placeholder.id === item.id) {
5783
- modifiedData.splice(d, 1);
5784
- }
5785
- }
5786
-
5787
- return modifiedData;
5788
- };
5789
-
5790
- return HidePlaceholder;
5791
- });
5792
-
5793
- S2.define('select2/dropdown/infiniteScroll',[
5794
- 'jquery'
5795
- ], function ($) {
5796
- function InfiniteScroll (decorated, $element, options, dataAdapter) {
5797
- this.lastParams = {};
5798
-
5799
- decorated.call(this, $element, options, dataAdapter);
5800
-
5801
- this.$loadingMore = this.createLoadingMore();
5802
- this.loading = false;
5803
- }
5804
-
5805
- InfiniteScroll.prototype.append = function (decorated, data) {
5806
- this.$loadingMore.remove();
5807
- this.loading = false;
5808
-
5809
- decorated.call(this, data);
5810
-
5811
- if (this.showLoadingMore(data)) {
5812
- this.$results.append(this.$loadingMore);
5813
- }
5814
- };
5815
-
5816
- InfiniteScroll.prototype.bind = function (decorated, container, $container) {
5817
- var self = this;
5818
-
5819
- decorated.call(this, container, $container);
5820
-
5821
- container.on('query', function (params) {
5822
- self.lastParams = params;
5823
- self.loading = true;
5824
- });
5825
-
5826
- container.on('query:append', function (params) {
5827
- self.lastParams = params;
5828
- self.loading = true;
5829
- });
5830
-
5831
- this.$results.on('scroll', function () {
5832
- var isLoadMoreVisible = $.contains(
5833
- document.documentElement,
5834
- self.$loadingMore[0]
5835
- );
5836
-
5837
- if (self.loading || !isLoadMoreVisible) {
5838
- return;
5839
- }
5840
-
5841
- var currentOffset = self.$results.offset().top +
5842
- self.$results.outerHeight(false);
5843
- var loadingMoreOffset = self.$loadingMore.offset().top +
5844
- self.$loadingMore.outerHeight(false);
5845
-
5846
- if (currentOffset + 50 >= loadingMoreOffset) {
5847
- self.loadMore();
5848
- }
5849
- });
5850
- };
5851
-
5852
- InfiniteScroll.prototype.loadMore = function () {
5853
- this.loading = true;
5854
-
5855
- var params = $.extend({}, {page: 1}, this.lastParams);
5856
-
5857
- params.page++;
5858
-
5859
- this.trigger('query:append', params);
5860
- };
5861
-
5862
- InfiniteScroll.prototype.showLoadingMore = function (_, data) {
5863
- return data.pagination && data.pagination.more;
5864
- };
5865
-
5866
- InfiniteScroll.prototype.createLoadingMore = function () {
5867
- var $option = $(
5868
- '<li ' +
5869
- 'class="select2-results__option select2-results__option--load-more"' +
5870
- 'role="treeitem" aria-disabled="true"></li>'
5871
- );
5872
-
5873
- var message = this.options.get('translations').get('loadingMore');
5874
-
5875
- $option.html(message(this.lastParams));
5876
-
5877
- return $option;
5878
- };
5879
-
5880
- return InfiniteScroll;
5881
- });
5882
-
5883
- S2.define('select2/dropdown/attachBody',[
5884
- 'jquery',
5885
- '../utils'
5886
- ], function ($, Utils) {
5887
- function AttachBody (decorated, $element, options) {
5888
- this.$dropdownParent = options.get('dropdownParent') || $(document.body);
5889
-
5890
- decorated.call(this, $element, options);
5891
- }
5892
-
5893
- AttachBody.prototype.bind = function (decorated, container, $container) {
5894
- var self = this;
5895
-
5896
- var setupResultsEvents = false;
5897
-
5898
- decorated.call(this, container, $container);
5899
-
5900
- container.on('open', function () {
5901
- self._showDropdown();
5902
- self._attachPositioningHandler(container);
5903
-
5904
- if (!setupResultsEvents) {
5905
- setupResultsEvents = true;
5906
-
5907
- container.on('results:all', function () {
5908
- self._positionDropdown();
5909
- self._resizeDropdown();
5910
- });
5911
-
5912
- container.on('results:append', function () {
5913
- self._positionDropdown();
5914
- self._resizeDropdown();
5915
- });
5916
- }
5917
- });
5918
-
5919
- container.on('close', function () {
5920
- self._hideDropdown();
5921
- self._detachPositioningHandler(container);
5922
- });
5923
-
5924
- this.$dropdownContainer.on('mousedown', function (evt) {
5925
- evt.stopPropagation();
5926
- });
5927
- };
5928
-
5929
- AttachBody.prototype.destroy = function (decorated) {
5930
- decorated.call(this);
5931
-
5932
- this.$dropdownContainer.remove();
5933
- };
5934
-
5935
- AttachBody.prototype.position = function (decorated, $dropdown, $container) {
5936
- // Clone all of the container classes
5937
- $dropdown.attr('class', $container.attr('class'));
5938
-
5939
- $dropdown.removeClass('select2');
5940
- $dropdown.addClass('select2-container--open');
5941
-
5942
- $dropdown.css({
5943
- position: 'absolute',
5944
- top: -999999
5945
- });
5946
-
5947
- this.$container = $container;
5948
- };
5949
-
5950
- AttachBody.prototype.render = function (decorated) {
5951
- var $container = $('<span></span>');
5952
-
5953
- var $dropdown = decorated.call(this);
5954
- $container.append($dropdown);
5955
-
5956
- this.$dropdownContainer = $container;
5957
-
5958
- return $container;
5959
- };
5960
-
5961
- AttachBody.prototype._hideDropdown = function (decorated) {
5962
- this.$dropdownContainer.detach();
5963
- };
5964
-
5965
- AttachBody.prototype._attachPositioningHandler =
5966
- function (decorated, container) {
5967
- var self = this;
5968
-
5969
- var scrollEvent = 'scroll.select2.' + container.id;
5970
- var resizeEvent = 'resize.select2.' + container.id;
5971
- var orientationEvent = 'orientationchange.select2.' + container.id;
5972
-
5973
- var $watchers = this.$container.parents().filter(Utils.hasScroll);
5974
- $watchers.each(function () {
5975
- $(this).data('select2-scroll-position', {
5976
- x: $(this).scrollLeft(),
5977
- y: $(this).scrollTop()
5978
- });
5979
- });
5980
-
5981
- $watchers.on(scrollEvent, function (ev) {
5982
- var position = $(this).data('select2-scroll-position');
5983
- $(this).scrollTop(position.y);
5984
- });
5985
-
5986
- $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
5987
- function (e) {
5988
- self._positionDropdown();
5989
- self._resizeDropdown();
5990
- });
5991
- };
5992
-
5993
- AttachBody.prototype._detachPositioningHandler =
5994
- function (decorated, container) {
5995
- var scrollEvent = 'scroll.select2.' + container.id;
5996
- var resizeEvent = 'resize.select2.' + container.id;
5997
- var orientationEvent = 'orientationchange.select2.' + container.id;
5998
-
5999
- var $watchers = this.$container.parents().filter(Utils.hasScroll);
6000
- $watchers.off(scrollEvent);
6001
-
6002
- $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
6003
- };
6004
-
6005
- AttachBody.prototype._positionDropdown = function () {
6006
- var $window = $(window);
6007
-
6008
- var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
6009
- var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
6010
-
6011
- var newDirection = null;
6012
-
6013
- var offset = this.$container.offset();
6014
-
6015
- offset.bottom = offset.top + this.$container.outerHeight(false);
6016
-
6017
- var container = {
6018
- height: this.$container.outerHeight(false)
6019
- };
6020
-
6021
- container.top = offset.top;
6022
- container.bottom = offset.top + container.height;
6023
-
6024
- var dropdown = {
6025
- height: this.$dropdown.outerHeight(false)
6026
- };
6027
-
6028
- var viewport = {
6029
- top: $window.scrollTop(),
6030
- bottom: $window.scrollTop() + $window.height()
6031
- };
6032
-
6033
- var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
6034
- var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
6035
-
6036
- var css = {
6037
- left: offset.left,
6038
- top: container.bottom
6039
- };
6040
-
6041
- // Determine what the parent element is to use for calciulating the offset
6042
- var $offsetParent = this.$dropdownParent;
6043
-
6044
- // For statically positoned elements, we need to get the element
6045
- // that is determining the offset
6046
- if ($offsetParent.css('position') === 'static') {
6047
- $offsetParent = $offsetParent.offsetParent();
6048
- }
6049
-
6050
- var parentOffset = $offsetParent.offset();
6051
-
6052
- css.top -= parentOffset.top;
6053
- css.left -= parentOffset.left;
6054
-
6055
- if (!isCurrentlyAbove && !isCurrentlyBelow) {
6056
- newDirection = 'below';
6057
- }
6058
-
6059
- if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
6060
- newDirection = 'above';
6061
- } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
6062
- newDirection = 'below';
6063
- }
6064
-
6065
- if (newDirection == 'above' ||
6066
- (isCurrentlyAbove && newDirection !== 'below')) {
6067
- css.top = container.top - parentOffset.top - dropdown.height;
6068
- }
6069
-
6070
- if (newDirection != null) {
6071
- this.$dropdown
6072
- .removeClass('select2-dropdown--below select2-dropdown--above')
6073
- .addClass('select2-dropdown--' + newDirection);
6074
- this.$container
6075
- .removeClass('select2-container--below select2-container--above')
6076
- .addClass('select2-container--' + newDirection);
6077
- }
6078
-
6079
- this.$dropdownContainer.css(css);
6080
- };
6081
-
6082
- AttachBody.prototype._resizeDropdown = function () {
6083
- var css = {
6084
- width: this.$container.outerWidth(false) + 'px'
6085
- };
6086
-
6087
- if (this.options.get('dropdownAutoWidth')) {
6088
- css.minWidth = css.width;
6089
- css.position = 'relative';
6090
- css.width = 'auto';
6091
- }
6092
-
6093
- this.$dropdown.css(css);
6094
- };
6095
-
6096
- AttachBody.prototype._showDropdown = function (decorated) {
6097
- this.$dropdownContainer.appendTo(this.$dropdownParent);
6098
-
6099
- this._positionDropdown();
6100
- this._resizeDropdown();
6101
- };
6102
-
6103
- return AttachBody;
6104
- });
6105
-
6106
- S2.define('select2/dropdown/minimumResultsForSearch',[
6107
-
6108
- ], function () {
6109
- function countResults (data) {
6110
- var count = 0;
6111
-
6112
- for (var d = 0; d < data.length; d++) {
6113
- var item = data[d];
6114
-
6115
- if (item.children) {
6116
- count += countResults(item.children);
6117
- } else {
6118
- count++;
6119
- }
6120
- }
6121
-
6122
- return count;
6123
- }
6124
-
6125
- function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
6126
- this.minimumResultsForSearch = options.get('minimumResultsForSearch');
6127
-
6128
- if (this.minimumResultsForSearch < 0) {
6129
- this.minimumResultsForSearch = Infinity;
6130
- }
6131
-
6132
- decorated.call(this, $element, options, dataAdapter);
6133
- }
6134
-
6135
- MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
6136
- if (countResults(params.data.results) < this.minimumResultsForSearch) {
6137
- return false;
6138
- }
6139
-
6140
- return decorated.call(this, params);
6141
- };
6142
-
6143
- return MinimumResultsForSearch;
6144
- });
6145
-
6146
- S2.define('select2/dropdown/selectOnClose',[
6147
-
6148
- ], function () {
6149
- function SelectOnClose () { }
6150
-
6151
- SelectOnClose.prototype.bind = function (decorated, container, $container) {
6152
- var self = this;
6153
-
6154
- decorated.call(this, container, $container);
6155
-
6156
- container.on('close', function (params) {
6157
- self._handleSelectOnClose(params);
6158
- });
6159
- };
6160
-
6161
- SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
6162
- if (params && params.originalSelect2Event != null) {
6163
- var event = params.originalSelect2Event;
6164
-
6165
- // Don't select an item if the close event was triggered from a select or
6166
- // unselect event
6167
- if (event._type === 'select' || event._type === 'unselect') {
6168
- return;
6169
- }
6170
- }
6171
-
6172
- var $highlightedResults = this.getHighlightedResults();
6173
-
6174
- // Only select highlighted results
6175
- if ($highlightedResults.length < 1) {
6176
- return;
6177
- }
6178
-
6179
- var data = $highlightedResults.data('data');
6180
-
6181
- // Don't re-select already selected resulte
6182
- if (
6183
- (data.element != null && data.element.selected) ||
6184
- (data.element == null && data.selected)
6185
- ) {
6186
- return;
6187
- }
6188
-
6189
- this.trigger('select', {
6190
- data: data
6191
- });
6192
- };
6193
-
6194
- return SelectOnClose;
6195
- });
6196
-
6197
- S2.define('select2/dropdown/closeOnSelect',[
6198
-
6199
- ], function () {
6200
- function CloseOnSelect () { }
6201
-
6202
- CloseOnSelect.prototype.bind = function (decorated, container, $container) {
6203
- var self = this;
6204
-
6205
- decorated.call(this, container, $container);
6206
-
6207
- container.on('select', function (evt) {
6208
- self._selectTriggered(evt);
6209
- });
6210
-
6211
- container.on('unselect', function (evt) {
6212
- self._selectTriggered(evt);
6213
- });
6214
- };
6215
-
6216
- CloseOnSelect.prototype._selectTriggered = function (_, evt) {
6217
- var originalEvent = evt.originalEvent;
6218
-
6219
- // Don't close if the control key is being held
6220
- if (originalEvent && originalEvent.ctrlKey) {
6221
- return;
6222
- }
6223
-
6224
- this.trigger('close', {
6225
- originalEvent: originalEvent,
6226
- originalSelect2Event: evt
6227
- });
6228
- };
6229
-
6230
- return CloseOnSelect;
6231
- });
6232
-
6233
- S2.define('select2/i18n/en',[],function () {
6234
- // English
6235
- return {
6236
- errorLoading: function () {
6237
- return 'The results could not be loaded.';
6238
- },
6239
- inputTooLong: function (args) {
6240
- var overChars = args.input.length - args.maximum;
6241
-
6242
- var message = 'Please delete ' + overChars + ' character';
6243
-
6244
- if (overChars != 1) {
6245
- message += 's';
6246
- }
6247
-
6248
- return message;
6249
- },
6250
- inputTooShort: function (args) {
6251
- var remainingChars = args.minimum - args.input.length;
6252
-
6253
- var message = 'Please enter ' + remainingChars + ' or more characters';
6254
-
6255
- return message;
6256
- },
6257
- loadingMore: function () {
6258
- return 'Loading more results…';
6259
- },
6260
- maximumSelected: function (args) {
6261
- var message = 'You can only select ' + args.maximum + ' item';
6262
-
6263
- if (args.maximum != 1) {
6264
- message += 's';
6265
- }
6266
-
6267
- return message;
6268
- },
6269
- noResults: function () {
6270
- return 'No results found';
6271
- },
6272
- searching: function () {
6273
- return 'Searching…';
6274
- }
6275
- };
6276
- });
6277
-
6278
- S2.define('select2/defaults',[
6279
- 'jquery',
6280
- 'require',
6281
-
6282
- './results',
6283
-
6284
- './selection/single',
6285
- './selection/multiple',
6286
- './selection/placeholder',
6287
- './selection/allowClear',
6288
- './selection/search',
6289
- './selection/eventRelay',
6290
-
6291
- './utils',
6292
- './translation',
6293
- './diacritics',
6294
-
6295
- './data/select',
6296
- './data/array',
6297
- './data/ajax',
6298
- './data/tags',
6299
- './data/tokenizer',
6300
- './data/minimumInputLength',
6301
- './data/maximumInputLength',
6302
- './data/maximumSelectionLength',
6303
-
6304
- './dropdown',
6305
- './dropdown/search',
6306
- './dropdown/hidePlaceholder',
6307
- './dropdown/infiniteScroll',
6308
- './dropdown/attachBody',
6309
- './dropdown/minimumResultsForSearch',
6310
- './dropdown/selectOnClose',
6311
- './dropdown/closeOnSelect',
6312
-
6313
- './i18n/en'
6314
- ], function ($, require,
6315
-
6316
- ResultsList,
6317
-
6318
- SingleSelection, MultipleSelection, Placeholder, AllowClear,
6319
- SelectionSearch, EventRelay,
6320
-
6321
- Utils, Translation, DIACRITICS,
6322
-
6323
- SelectData, ArrayData, AjaxData, Tags, Tokenizer,
6324
- MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
6325
-
6326
- Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
6327
- AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
6328
-
6329
- EnglishTranslation) {
6330
- function Defaults () {
6331
- this.reset();
6332
- }
6333
-
6334
- Defaults.prototype.apply = function (options) {
6335
- options = $.extend(true, {}, this.defaults, options);
6336
-
6337
- if (options.dataAdapter == null) {
6338
- if (options.ajax != null) {
6339
- options.dataAdapter = AjaxData;
6340
- } else if (options.data != null) {
6341
- options.dataAdapter = ArrayData;
6342
- } else {
6343
- options.dataAdapter = SelectData;
6344
- }
6345
-
6346
- if (options.minimumInputLength > 0) {
6347
- options.dataAdapter = Utils.Decorate(
6348
- options.dataAdapter,
6349
- MinimumInputLength
6350
- );
6351
- }
6352
-
6353
- if (options.maximumInputLength > 0) {
6354
- options.dataAdapter = Utils.Decorate(
6355
- options.dataAdapter,
6356
- MaximumInputLength
6357
- );
6358
- }
6359
-
6360
- if (options.maximumSelectionLength > 0) {
6361
- options.dataAdapter = Utils.Decorate(
6362
- options.dataAdapter,
6363
- MaximumSelectionLength
6364
- );
6365
- }
6366
-
6367
- if (options.tags) {
6368
- options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
6369
- }
6370
-
6371
- if (options.tokenSeparators != null || options.tokenizer != null) {
6372
- options.dataAdapter = Utils.Decorate(
6373
- options.dataAdapter,
6374
- Tokenizer
6375
- );
6376
- }
6377
-
6378
- if (options.query != null) {
6379
- var Query = require(options.amdBase + 'compat/query');
6380
-
6381
- options.dataAdapter = Utils.Decorate(
6382
- options.dataAdapter,
6383
- Query
6384
- );
6385
- }
6386
-
6387
- if (options.initSelection != null) {
6388
- var InitSelection = require(options.amdBase + 'compat/initSelection');
6389
-
6390
- options.dataAdapter = Utils.Decorate(
6391
- options.dataAdapter,
6392
- InitSelection
6393
- );
6394
- }
6395
- }
6396
-
6397
- if (options.resultsAdapter == null) {
6398
- options.resultsAdapter = ResultsList;
6399
-
6400
- if (options.ajax != null) {
6401
- options.resultsAdapter = Utils.Decorate(
6402
- options.resultsAdapter,
6403
- InfiniteScroll
6404
- );
6405
- }
6406
-
6407
- if (options.placeholder != null) {
6408
- options.resultsAdapter = Utils.Decorate(
6409
- options.resultsAdapter,
6410
- HidePlaceholder
6411
- );
6412
- }
6413
-
6414
- if (options.selectOnClose) {
6415
- options.resultsAdapter = Utils.Decorate(
6416
- options.resultsAdapter,
6417
- SelectOnClose
6418
- );
6419
- }
6420
- }
6421
-
6422
- if (options.dropdownAdapter == null) {
6423
- if (options.multiple) {
6424
- options.dropdownAdapter = Dropdown;
6425
- } else {
6426
- var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
6427
-
6428
- options.dropdownAdapter = SearchableDropdown;
6429
- }
6430
-
6431
- if (options.minimumResultsForSearch !== 0) {
6432
- options.dropdownAdapter = Utils.Decorate(
6433
- options.dropdownAdapter,
6434
- MinimumResultsForSearch
6435
- );
6436
- }
6437
-
6438
- if (options.closeOnSelect) {
6439
- options.dropdownAdapter = Utils.Decorate(
6440
- options.dropdownAdapter,
6441
- CloseOnSelect
6442
- );
6443
- }
6444
-
6445
- if (
6446
- options.dropdownCssClass != null ||
6447
- options.dropdownCss != null ||
6448
- options.adaptDropdownCssClass != null
6449
- ) {
6450
- var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
6451
-
6452
- options.dropdownAdapter = Utils.Decorate(
6453
- options.dropdownAdapter,
6454
- DropdownCSS
6455
- );
6456
- }
6457
-
6458
- options.dropdownAdapter = Utils.Decorate(
6459
- options.dropdownAdapter,
6460
- AttachBody
6461
- );
6462
- }
6463
-
6464
- if (options.selectionAdapter == null) {
6465
- if (options.multiple) {
6466
- options.selectionAdapter = MultipleSelection;
6467
- } else {
6468
- options.selectionAdapter = SingleSelection;
6469
- }
6470
-
6471
- // Add the placeholder mixin if a placeholder was specified
6472
- if (options.placeholder != null) {
6473
- options.selectionAdapter = Utils.Decorate(
6474
- options.selectionAdapter,
6475
- Placeholder
6476
- );
6477
- }
6478
-
6479
- if (options.allowClear) {
6480
- options.selectionAdapter = Utils.Decorate(
6481
- options.selectionAdapter,
6482
- AllowClear
6483
- );
6484
- }
6485
-
6486
- if (options.multiple) {
6487
- options.selectionAdapter = Utils.Decorate(
6488
- options.selectionAdapter,
6489
- SelectionSearch
6490
- );
6491
- }
6492
-
6493
- if (
6494
- options.containerCssClass != null ||
6495
- options.containerCss != null ||
6496
- options.adaptContainerCssClass != null
6497
- ) {
6498
- var ContainerCSS = require(options.amdBase + 'compat/containerCss');
6499
-
6500
- options.selectionAdapter = Utils.Decorate(
6501
- options.selectionAdapter,
6502
- ContainerCSS
6503
- );
6504
- }
6505
-
6506
- options.selectionAdapter = Utils.Decorate(
6507
- options.selectionAdapter,
6508
- EventRelay
6509
- );
6510
- }
6511
-
6512
- if (typeof options.language === 'string') {
6513
- // Check if the language is specified with a region
6514
- if (options.language.indexOf('-') > 0) {
6515
- // Extract the region information if it is included
6516
- var languageParts = options.language.split('-');
6517
- var baseLanguage = languageParts[0];
6518
-
6519
- options.language = [options.language, baseLanguage];
6520
- } else {
6521
- options.language = [options.language];
6522
- }
6523
- }
6524
-
6525
- if ($.isArray(options.language)) {
6526
- var languages = new Translation();
6527
- options.language.push('en');
6528
-
6529
- var languageNames = options.language;
6530
-
6531
- for (var l = 0; l < languageNames.length; l++) {
6532
- var name = languageNames[l];
6533
- var language = {};
6534
-
6535
- try {
6536
- // Try to load it with the original name
6537
- language = Translation.loadPath(name);
6538
- } catch (e) {
6539
- try {
6540
- // If we couldn't load it, check if it wasn't the full path
6541
- name = this.defaults.amdLanguageBase + name;
6542
- language = Translation.loadPath(name);
6543
- } catch (ex) {
6544
- // The translation could not be loaded at all. Sometimes this is
6545
- // because of a configuration problem, other times this can be
6546
- // because of how Select2 helps load all possible translation files.
6547
- if (options.debug && window.console && console.warn) {
6548
- console.warn(
6549
- 'Select2: The language file for "' + name + '" could not be ' +
6550
- 'automatically loaded. A fallback will be used instead.'
6551
- );
6552
- }
6553
-
6554
- continue;
6555
- }
6556
- }
6557
-
6558
- languages.extend(language);
6559
- }
6560
-
6561
- options.translations = languages;
6562
- } else {
6563
- var baseTranslation = Translation.loadPath(
6564
- this.defaults.amdLanguageBase + 'en'
6565
- );
6566
- var customTranslation = new Translation(options.language);
6567
-
6568
- customTranslation.extend(baseTranslation);
6569
-
6570
- options.translations = customTranslation;
6571
- }
6572
-
6573
- return options;
6574
- };
6575
-
6576
- Defaults.prototype.reset = function () {
6577
- function stripDiacritics (text) {
6578
- // Used 'uni range + named function' from http://jsperf.com/diacritics/18
6579
- function match(a) {
6580
- return DIACRITICS[a] || a;
6581
- }
6582
-
6583
- return text.replace(/[^\u0000-\u007E]/g, match);
6584
- }
6585
-
6586
- function matcher (params, data) {
6587
- // Always return the object if there is nothing to compare
6588
- if ($.trim(params.term) === '') {
6589
- return data;
6590
- }
6591
-
6592
- // Do a recursive check for options with children
6593
- if (data.children && data.children.length > 0) {
6594
- // Clone the data object if there are children
6595
- // This is required as we modify the object to remove any non-matches
6596
- var match = $.extend(true, {}, data);
6597
-
6598
- // Check each child of the option
6599
- for (var c = data.children.length - 1; c >= 0; c--) {
6600
- var child = data.children[c];
6601
-
6602
- var matches = matcher(params, child);
6603
-
6604
- // If there wasn't a match, remove the object in the array
6605
- if (matches == null) {
6606
- match.children.splice(c, 1);
6607
- }
6608
- }
6609
-
6610
- // If any children matched, return the new object
6611
- if (match.children.length > 0) {
6612
- return match;
6613
- }
6614
-
6615
- // If there were no matching children, check just the plain object
6616
- return matcher(params, match);
6617
- }
6618
-
6619
- var original = stripDiacritics(data.text).toUpperCase();
6620
- var term = stripDiacritics(params.term).toUpperCase();
6621
-
6622
- // Check if the text contains the term
6623
- if (original.indexOf(term) > -1) {
6624
- return data;
6625
- }
6626
-
6627
- // If it doesn't contain the term, don't return anything
6628
- return null;
6629
- }
6630
-
6631
- this.defaults = {
6632
- amdBase: './',
6633
- amdLanguageBase: './i18n/',
6634
- closeOnSelect: true,
6635
- debug: false,
6636
- dropdownAutoWidth: false,
6637
- escapeMarkup: Utils.escapeMarkup,
6638
- language: EnglishTranslation,
6639
- matcher: matcher,
6640
- minimumInputLength: 0,
6641
- maximumInputLength: 0,
6642
- maximumSelectionLength: 0,
6643
- minimumResultsForSearch: 0,
6644
- selectOnClose: false,
6645
- sorter: function (data) {
6646
- return data;
6647
- },
6648
- templateResult: function (result) {
6649
- return result.text;
6650
- },
6651
- templateSelection: function (selection) {
6652
- return selection.text;
6653
- },
6654
- theme: 'default',
6655
- width: 'resolve'
6656
- };
6657
- };
6658
-
6659
- Defaults.prototype.set = function (key, value) {
6660
- var camelKey = $.camelCase(key);
6661
-
6662
- var data = {};
6663
- data[camelKey] = value;
6664
-
6665
- var convertedData = Utils._convertData(data);
6666
-
6667
- $.extend(this.defaults, convertedData);
6668
- };
6669
-
6670
- var defaults = new Defaults();
6671
-
6672
- return defaults;
6673
- });
6674
-
6675
- S2.define('select2/options',[
6676
- 'require',
6677
- 'jquery',
6678
- './defaults',
6679
- './utils'
6680
- ], function (require, $, Defaults, Utils) {
6681
- function Options (options, $element) {
6682
- this.options = options;
6683
-
6684
- if ($element != null) {
6685
- this.fromElement($element);
6686
- }
6687
-
6688
- this.options = Defaults.apply(this.options);
6689
-
6690
- if ($element && $element.is('input')) {
6691
- var InputCompat = require(this.get('amdBase') + 'compat/inputData');
6692
-
6693
- this.options.dataAdapter = Utils.Decorate(
6694
- this.options.dataAdapter,
6695
- InputCompat
6696
- );
6697
- }
6698
- }
6699
-
6700
- Options.prototype.fromElement = function ($e) {
6701
- var excludedData = ['select2'];
6702
-
6703
- if (this.options.multiple == null) {
6704
- this.options.multiple = $e.prop('multiple');
6705
- }
6706
-
6707
- if (this.options.disabled == null) {
6708
- this.options.disabled = $e.prop('disabled');
6709
- }
6710
-
6711
- if (this.options.language == null) {
6712
- if ($e.prop('lang')) {
6713
- this.options.language = $e.prop('lang').toLowerCase();
6714
- } else if ($e.closest('[lang]').prop('lang')) {
6715
- this.options.language = $e.closest('[lang]').prop('lang');
6716
- }
6717
- }
6718
-
6719
- if (this.options.dir == null) {
6720
- if ($e.prop('dir')) {
6721
- this.options.dir = $e.prop('dir');
6722
- } else if ($e.closest('[dir]').prop('dir')) {
6723
- this.options.dir = $e.closest('[dir]').prop('dir');
6724
- } else {
6725
- this.options.dir = 'ltr';
6726
- }
6727
- }
6728
-
6729
- $e.prop('disabled', this.options.disabled);
6730
- $e.prop('multiple', this.options.multiple);
6731
-
6732
- if ($e.data('select2Tags')) {
6733
- if (this.options.debug && window.console && console.warn) {
6734
- console.warn(
6735
- 'Select2: The `data-select2-tags` attribute has been changed to ' +
6736
- 'use the `data-data` and `data-tags="true"` attributes and will be ' +
6737
- 'removed in future versions of Select2.'
6738
- );
6739
- }
6740
-
6741
- $e.data('data', $e.data('select2Tags'));
6742
- $e.data('tags', true);
6743
- }
6744
-
6745
- if ($e.data('ajaxUrl')) {
6746
- if (this.options.debug && window.console && console.warn) {
6747
- console.warn(
6748
- 'Select2: The `data-ajax-url` attribute has been changed to ' +
6749
- '`data-ajax--url` and support for the old attribute will be removed' +
6750
- ' in future versions of Select2.'
6751
- );
6752
- }
6753
-
6754
- $e.attr('ajax--url', $e.data('ajaxUrl'));
6755
- $e.data('ajax--url', $e.data('ajaxUrl'));
6756
- }
6757
-
6758
- var dataset = {};
6759
-
6760
- // Prefer the element's `dataset` attribute if it exists
6761
- // jQuery 1.x does not correctly handle data attributes with multiple dashes
6762
- if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
6763
- dataset = $.extend(true, {}, $e[0].dataset, $e.data());
6764
- } else {
6765
- dataset = $e.data();
6766
- }
6767
-
6768
- var data = $.extend(true, {}, dataset);
6769
-
6770
- data = Utils._convertData(data);
6771
-
6772
- for (var key in data) {
6773
- if ($.inArray(key, excludedData) > -1) {
6774
- continue;
6775
- }
6776
-
6777
- if ($.isPlainObject(this.options[key])) {
6778
- $.extend(this.options[key], data[key]);
6779
- } else {
6780
- this.options[key] = data[key];
6781
- }
6782
- }
6783
-
6784
- return this;
6785
- };
6786
-
6787
- Options.prototype.get = function (key) {
6788
- return this.options[key];
6789
- };
6790
-
6791
- Options.prototype.set = function (key, val) {
6792
- this.options[key] = val;
6793
- };
6794
-
6795
- return Options;
6796
- });
6797
-
6798
- S2.define('select2/core',[
6799
- 'jquery',
6800
- './options',
6801
- './utils',
6802
- './keys'
6803
- ], function ($, Options, Utils, KEYS) {
6804
- var Select2 = function ($element, options) {
6805
- if ($element.data('select2') != null) {
6806
- $element.data('select2').destroy();
6807
- }
6808
-
6809
- this.$element = $element;
6810
-
6811
- this.id = this._generateId($element);
6812
-
6813
- options = options || {};
6814
-
6815
- this.options = new Options(options, $element);
6816
-
6817
- Select2.__super__.constructor.call(this);
6818
-
6819
- // Set up the tabindex
6820
-
6821
- var tabindex = $element.attr('tabindex') || 0;
6822
- $element.data('old-tabindex', tabindex);
6823
- $element.attr('tabindex', '-1');
6824
-
6825
- // Set up containers and adapters
6826
-
6827
- var DataAdapter = this.options.get('dataAdapter');
6828
- this.dataAdapter = new DataAdapter($element, this.options);
6829
-
6830
- var $container = this.render();
6831
-
6832
- this._placeContainer($container);
6833
-
6834
- var SelectionAdapter = this.options.get('selectionAdapter');
6835
- this.selection = new SelectionAdapter($element, this.options);
6836
- this.$selection = this.selection.render();
6837
-
6838
- this.selection.position(this.$selection, $container);
6839
-
6840
- var DropdownAdapter = this.options.get('dropdownAdapter');
6841
- this.dropdown = new DropdownAdapter($element, this.options);
6842
- this.$dropdown = this.dropdown.render();
6843
-
6844
- this.dropdown.position(this.$dropdown, $container);
6845
-
6846
- var ResultsAdapter = this.options.get('resultsAdapter');
6847
- this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
6848
- this.$results = this.results.render();
6849
-
6850
- this.results.position(this.$results, this.$dropdown);
6851
-
6852
- // Bind events
6853
-
6854
- var self = this;
6855
-
6856
- // Bind the container to all of the adapters
6857
- this._bindAdapters();
6858
-
6859
- // Register any DOM event handlers
6860
- this._registerDomEvents();
6861
-
6862
- // Register any internal event handlers
6863
- this._registerDataEvents();
6864
- this._registerSelectionEvents();
6865
- this._registerDropdownEvents();
6866
- this._registerResultsEvents();
6867
- this._registerEvents();
6868
-
6869
- // Set the initial state
6870
- this.dataAdapter.current(function (initialData) {
6871
- self.trigger('selection:update', {
6872
- data: initialData
6873
- });
6874
- });
6875
-
6876
- // Hide the original select
6877
- $element.addClass('select2-hidden-accessible');
6878
- $element.attr('aria-hidden', 'true');
6879
-
6880
- // Synchronize any monitored attributes
6881
- this._syncAttributes();
6882
-
6883
- $element.data('select2', this);
6884
- };
6885
-
6886
- Utils.Extend(Select2, Utils.Observable);
6887
-
6888
- Select2.prototype._generateId = function ($element) {
6889
- var id = '';
6890
-
6891
- if ($element.attr('id') != null) {
6892
- id = $element.attr('id');
6893
- } else if ($element.attr('name') != null) {
6894
- id = $element.attr('name') + '-' + Utils.generateChars(2);
6895
- } else {
6896
- id = Utils.generateChars(4);
6897
- }
6898
-
6899
- id = id.replace(/(:|\.|\[|\]|,)/g, '');
6900
- id = 'select2-' + id;
6901
-
6902
- return id;
6903
- };
6904
-
6905
- Select2.prototype._placeContainer = function ($container) {
6906
- $container.insertAfter(this.$element);
6907
-
6908
- var width = this._resolveWidth(this.$element, this.options.get('width'));
6909
-
6910
- if (width != null) {
6911
- $container.css('width', width);
6912
- }
6913
- };
6914
-
6915
- Select2.prototype._resolveWidth = function ($element, method) {
6916
- var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
6917
-
6918
- if (method == 'resolve') {
6919
- var styleWidth = this._resolveWidth($element, 'style');
6920
-
6921
- if (styleWidth != null) {
6922
- return styleWidth;
6923
- }
6924
-
6925
- return this._resolveWidth($element, 'element');
6926
- }
6927
-
6928
- if (method == 'element') {
6929
- var elementWidth = $element.outerWidth(false);
6930
-
6931
- if (elementWidth <= 0) {
6932
- return 'auto';
6933
- }
6934
-
6935
- return elementWidth + 'px';
6936
- }
6937
-
6938
- if (method == 'style') {
6939
- var style = $element.attr('style');
6940
-
6941
- if (typeof(style) !== 'string') {
6942
- return null;
6943
- }
6944
-
6945
- var attrs = style.split(';');
6946
-
6947
- for (var i = 0, l = attrs.length; i < l; i = i + 1) {
6948
- var attr = attrs[i].replace(/\s/g, '');
6949
- var matches = attr.match(WIDTH);
6950
-
6951
- if (matches !== null && matches.length >= 1) {
6952
- return matches[1];
6953
- }
6954
- }
6955
-
6956
- return null;
6957
- }
6958
-
6959
- return method;
6960
- };
6961
-
6962
- Select2.prototype._bindAdapters = function () {
6963
- this.dataAdapter.bind(this, this.$container);
6964
- this.selection.bind(this, this.$container);
6965
-
6966
- this.dropdown.bind(this, this.$container);
6967
- this.results.bind(this, this.$container);
6968
- };
6969
-
6970
- Select2.prototype._registerDomEvents = function () {
6971
- var self = this;
6972
-
6973
- this.$element.on('change.select2', function () {
6974
- self.dataAdapter.current(function (data) {
6975
- self.trigger('selection:update', {
6976
- data: data
6977
- });
6978
- });
6979
- });
6980
-
6981
- this.$element.on('focus.select2', function (evt) {
6982
- self.trigger('focus', evt);
6983
- });
6984
-
6985
- this._syncA = Utils.bind(this._syncAttributes, this);
6986
- this._syncS = Utils.bind(this._syncSubtree, this);
6987
-
6988
- if (this.$element[0].attachEvent) {
6989
- this.$element[0].attachEvent('onpropertychange', this._syncA);
6990
- }
6991
-
6992
- var observer = window.MutationObserver ||
6993
- window.WebKitMutationObserver ||
6994
- window.MozMutationObserver
6995
- ;
6996
-
6997
- if (observer != null) {
6998
- this._observer = new observer(function (mutations) {
6999
- $.each(mutations, self._syncA);
7000
- $.each(mutations, self._syncS);
7001
- });
7002
- this._observer.observe(this.$element[0], {
7003
- attributes: true,
7004
- childList: true,
7005
- subtree: false
7006
- });
7007
- } else if (this.$element[0].addEventListener) {
7008
- this.$element[0].addEventListener(
7009
- 'DOMAttrModified',
7010
- self._syncA,
7011
- false
7012
- );
7013
- this.$element[0].addEventListener(
7014
- 'DOMNodeInserted',
7015
- self._syncS,
7016
- false
7017
- );
7018
- this.$element[0].addEventListener(
7019
- 'DOMNodeRemoved',
7020
- self._syncS,
7021
- false
7022
- );
7023
- }
7024
- };
7025
-
7026
- Select2.prototype._registerDataEvents = function () {
7027
- var self = this;
7028
-
7029
- this.dataAdapter.on('*', function (name, params) {
7030
- self.trigger(name, params);
7031
- });
7032
- };
7033
-
7034
- Select2.prototype._registerSelectionEvents = function () {
7035
- var self = this;
7036
- var nonRelayEvents = ['toggle', 'focus'];
7037
-
7038
- this.selection.on('toggle', function () {
7039
- self.toggleDropdown();
7040
- });
7041
-
7042
- this.selection.on('focus', function (params) {
7043
- self.focus(params);
7044
- });
7045
-
7046
- this.selection.on('*', function (name, params) {
7047
- if ($.inArray(name, nonRelayEvents) !== -1) {
7048
- return;
7049
- }
7050
-
7051
- self.trigger(name, params);
7052
- });
7053
- };
7054
-
7055
- Select2.prototype._registerDropdownEvents = function () {
7056
- var self = this;
7057
-
7058
- this.dropdown.on('*', function (name, params) {
7059
- self.trigger(name, params);
7060
- });
7061
- };
7062
-
7063
- Select2.prototype._registerResultsEvents = function () {
7064
- var self = this;
7065
-
7066
- this.results.on('*', function (name, params) {
7067
- self.trigger(name, params);
7068
- });
7069
- };
7070
-
7071
- Select2.prototype._registerEvents = function () {
7072
- var self = this;
7073
-
7074
- this.on('open', function () {
7075
- self.$container.addClass('select2-container--open');
7076
- });
7077
-
7078
- this.on('close', function () {
7079
- self.$container.removeClass('select2-container--open');
7080
- });
7081
-
7082
- this.on('enable', function () {
7083
- self.$container.removeClass('select2-container--disabled');
7084
- });
7085
-
7086
- this.on('disable', function () {
7087
- self.$container.addClass('select2-container--disabled');
7088
- });
7089
-
7090
- this.on('blur', function () {
7091
- self.$container.removeClass('select2-container--focus');
7092
- });
7093
-
7094
- this.on('query', function (params) {
7095
- if (!self.isOpen()) {
7096
- self.trigger('open', {});
7097
- }
7098
-
7099
- this.dataAdapter.query(params, function (data) {
7100
- self.trigger('results:all', {
7101
- data: data,
7102
- query: params
7103
- });
7104
- });
7105
- });
7106
-
7107
- this.on('query:append', function (params) {
7108
- this.dataAdapter.query(params, function (data) {
7109
- self.trigger('results:append', {
7110
- data: data,
7111
- query: params
7112
- });
7113
- });
7114
- });
7115
-
7116
- this.on('keypress', function (evt) {
7117
- var key = evt.which;
7118
-
7119
- if (self.isOpen()) {
7120
- if (key === KEYS.ESC || key === KEYS.TAB ||
7121
- (key === KEYS.UP && evt.altKey)) {
7122
- self.close();
7123
-
7124
- evt.preventDefault();
7125
- } else if (key === KEYS.ENTER) {
7126
- self.trigger('results:select', {});
7127
-
7128
- evt.preventDefault();
7129
- } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
7130
- self.trigger('results:toggle', {});
7131
-
7132
- evt.preventDefault();
7133
- } else if (key === KEYS.UP) {
7134
- self.trigger('results:previous', {});
7135
-
7136
- evt.preventDefault();
7137
- } else if (key === KEYS.DOWN) {
7138
- self.trigger('results:next', {});
7139
-
7140
- evt.preventDefault();
7141
- }
7142
- } else {
7143
- if (key === KEYS.ENTER || key === KEYS.SPACE ||
7144
- (key === KEYS.DOWN && evt.altKey)) {
7145
- self.open();
7146
-
7147
- evt.preventDefault();
7148
- }
7149
- }
7150
- });
7151
- };
7152
-
7153
- Select2.prototype._syncAttributes = function () {
7154
- this.options.set('disabled', this.$element.prop('disabled'));
7155
-
7156
- if (this.options.get('disabled')) {
7157
- if (this.isOpen()) {
7158
- this.close();
7159
- }
7160
-
7161
- this.trigger('disable', {});
7162
- } else {
7163
- this.trigger('enable', {});
7164
- }
7165
- };
7166
-
7167
- Select2.prototype._syncSubtree = function (evt, mutations) {
7168
- var changed = false;
7169
- var self = this;
7170
-
7171
- // Ignore any mutation events raised for elements that aren't options or
7172
- // optgroups. This handles the case when the select element is destroyed
7173
- if (
7174
- evt && evt.target && (
7175
- evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
7176
- )
7177
- ) {
7178
- return;
7179
- }
7180
-
7181
- if (!mutations) {
7182
- // If mutation events aren't supported, then we can only assume that the
7183
- // change affected the selections
7184
- changed = true;
7185
- } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
7186
- for (var n = 0; n < mutations.addedNodes.length; n++) {
7187
- var node = mutations.addedNodes[n];
7188
-
7189
- if (node.selected) {
7190
- changed = true;
7191
- }
7192
- }
7193
- } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
7194
- changed = true;
7195
- }
7196
-
7197
- // Only re-pull the data if we think there is a change
7198
- if (changed) {
7199
- this.dataAdapter.current(function (currentData) {
7200
- self.trigger('selection:update', {
7201
- data: currentData
7202
- });
7203
- });
7204
- }
7205
- };
7206
-
7207
- /**
7208
- * Override the trigger method to automatically trigger pre-events when
7209
- * there are events that can be prevented.
7210
- */
7211
- Select2.prototype.trigger = function (name, args) {
7212
- var actualTrigger = Select2.__super__.trigger;
7213
- var preTriggerMap = {
7214
- 'open': 'opening',
7215
- 'close': 'closing',
7216
- 'select': 'selecting',
7217
- 'unselect': 'unselecting'
7218
- };
7219
-
7220
- if (args === undefined) {
7221
- args = {};
7222
- }
7223
-
7224
- if (name in preTriggerMap) {
7225
- var preTriggerName = preTriggerMap[name];
7226
- var preTriggerArgs = {
7227
- prevented: false,
7228
- name: name,
7229
- args: args
7230
- };
7231
-
7232
- actualTrigger.call(this, preTriggerName, preTriggerArgs);
7233
-
7234
- if (preTriggerArgs.prevented) {
7235
- args.prevented = true;
7236
-
7237
- return;
7238
- }
7239
- }
7240
-
7241
- actualTrigger.call(this, name, args);
7242
- };
7243
-
7244
- Select2.prototype.toggleDropdown = function () {
7245
- if (this.options.get('disabled')) {
7246
- return;
7247
- }
7248
-
7249
- if (this.isOpen()) {
7250
- this.close();
7251
- } else {
7252
- this.open();
7253
- }
7254
- };
7255
-
7256
- Select2.prototype.open = function () {
7257
- if (this.isOpen()) {
7258
- return;
7259
- }
7260
-
7261
- this.trigger('query', {});
7262
- };
7263
-
7264
- Select2.prototype.close = function () {
7265
- if (!this.isOpen()) {
7266
- return;
7267
- }
7268
-
7269
- this.trigger('close', {});
7270
- };
7271
-
7272
- Select2.prototype.isOpen = function () {
7273
- return this.$container.hasClass('select2-container--open');
7274
- };
7275
-
7276
- Select2.prototype.hasFocus = function () {
7277
- return this.$container.hasClass('select2-container--focus');
7278
- };
7279
-
7280
- Select2.prototype.focus = function (data) {
7281
- // No need to re-trigger focus events if we are already focused
7282
- if (this.hasFocus()) {
7283
- return;
7284
- }
7285
-
7286
- this.$container.addClass('select2-container--focus');
7287
- this.trigger('focus', {});
7288
- };
7289
-
7290
- Select2.prototype.enable = function (args) {
7291
- if (this.options.get('debug') && window.console && console.warn) {
7292
- console.warn(
7293
- 'Select2: The `select2("enable")` method has been deprecated and will' +
7294
- ' be removed in later Select2 versions. Use $element.prop("disabled")' +
7295
- ' instead.'
7296
- );
7297
- }
7298
-
7299
- if (args == null || args.length === 0) {
7300
- args = [true];
7301
- }
7302
-
7303
- var disabled = !args[0];
7304
-
7305
- this.$element.prop('disabled', disabled);
7306
- };
7307
-
7308
- Select2.prototype.data = function () {
7309
- if (this.options.get('debug') &&
7310
- arguments.length > 0 && window.console && console.warn) {
7311
- console.warn(
7312
- 'Select2: Data can no longer be set using `select2("data")`. You ' +
7313
- 'should consider setting the value instead using `$element.val()`.'
7314
- );
7315
- }
7316
-
7317
- var data = [];
7318
-
7319
- this.dataAdapter.current(function (currentData) {
7320
- data = currentData;
7321
- });
7322
-
7323
- return data;
7324
- };
7325
-
7326
- Select2.prototype.val = function (args) {
7327
- if (this.options.get('debug') && window.console && console.warn) {
7328
- console.warn(
7329
- 'Select2: The `select2("val")` method has been deprecated and will be' +
7330
- ' removed in later Select2 versions. Use $element.val() instead.'
7331
- );
7332
- }
7333
-
7334
- if (args == null || args.length === 0) {
7335
- return this.$element.val();
7336
- }
7337
-
7338
- var newVal = args[0];
7339
-
7340
- if ($.isArray(newVal)) {
7341
- newVal = $.map(newVal, function (obj) {
7342
- return obj.toString();
7343
- });
7344
- }
7345
-
7346
- this.$element.val(newVal).trigger('change');
7347
- };
7348
-
7349
- Select2.prototype.destroy = function () {
7350
- this.$container.remove();
7351
-
7352
- if (this.$element[0].detachEvent) {
7353
- this.$element[0].detachEvent('onpropertychange', this._syncA);
7354
- }
7355
-
7356
- if (this._observer != null) {
7357
- this._observer.disconnect();
7358
- this._observer = null;
7359
- } else if (this.$element[0].removeEventListener) {
7360
- this.$element[0]
7361
- .removeEventListener('DOMAttrModified', this._syncA, false);
7362
- this.$element[0]
7363
- .removeEventListener('DOMNodeInserted', this._syncS, false);
7364
- this.$element[0]
7365
- .removeEventListener('DOMNodeRemoved', this._syncS, false);
7366
- }
7367
-
7368
- this._syncA = null;
7369
- this._syncS = null;
7370
-
7371
- this.$element.off('.select2');
7372
- this.$element.attr('tabindex', this.$element.data('old-tabindex'));
7373
-
7374
- this.$element.removeClass('select2-hidden-accessible');
7375
- this.$element.attr('aria-hidden', 'false');
7376
- this.$element.removeData('select2');
7377
-
7378
- this.dataAdapter.destroy();
7379
- this.selection.destroy();
7380
- this.dropdown.destroy();
7381
- this.results.destroy();
7382
-
7383
- this.dataAdapter = null;
7384
- this.selection = null;
7385
- this.dropdown = null;
7386
- this.results = null;
7387
- };
7388
-
7389
- Select2.prototype.render = function () {
7390
- var $container = $(
7391
- '<span class="select2 select2-container">' +
7392
- '<span class="selection"></span>' +
7393
- '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
7394
- '</span>'
7395
- );
7396
-
7397
- $container.attr('dir', this.options.get('dir'));
7398
-
7399
- this.$container = $container;
7400
-
7401
- this.$container.addClass('select2-container--' + this.options.get('theme'));
7402
-
7403
- $container.data('element', this.$element);
7404
-
7405
- return $container;
7406
- };
7407
-
7408
- return Select2;
7409
- });
7410
-
7411
- S2.define('jquery-mousewheel',[
7412
- 'jquery'
7413
- ], function ($) {
7414
- // Used to shim jQuery.mousewheel for non-full builds.
7415
- return $;
7416
- });
7417
-
7418
- S2.define('jquery.select2',[
7419
- 'jquery',
7420
- 'jquery-mousewheel',
7421
-
7422
- './select2/core',
7423
- './select2/defaults'
7424
- ], function ($, _, Select2, Defaults) {
7425
- if ($.fn.select2 == null) {
7426
- // All methods that should return the element
7427
- var thisMethods = ['open', 'close', 'destroy'];
7428
-
7429
- $.fn.select2 = function (options) {
7430
- options = options || {};
7431
-
7432
- if (typeof options === 'object') {
7433
- this.each(function () {
7434
- var instanceOptions = $.extend(true, {}, options);
7435
-
7436
- var instance = new Select2($(this), instanceOptions);
7437
- });
7438
-
7439
- return this;
7440
- } else if (typeof options === 'string') {
7441
- var ret;
7442
- var args = Array.prototype.slice.call(arguments, 1);
7443
-
7444
- this.each(function () {
7445
- var instance = $(this).data('select2');
7446
-
7447
- if (instance == null && window.console && console.error) {
7448
- console.error(
7449
- 'The select2(\'' + options + '\') method was called on an ' +
7450
- 'element that is not using Select2.'
7451
- );
7452
- }
7453
-
7454
- ret = instance[options].apply(instance, args);
7455
- });
7456
-
7457
- // Check if we should be returning `this`
7458
- if ($.inArray(options, thisMethods) > -1) {
7459
- return this;
7460
- }
7461
-
7462
- return ret;
7463
- } else {
7464
- throw new Error('Invalid arguments for Select2: ' + options);
7465
- }
7466
- };
7467
- }
7468
-
7469
- if ($.fn.select2.defaults == null) {
7470
- $.fn.select2.defaults = Defaults;
7471
- }
7472
-
7473
- return Select2;
7474
- });
7475
-
7476
- // Return the AMD loader configuration so it can be used outside of this file
7477
- return {
7478
- define: S2.define,
7479
- require: S2.require
7480
- };
7481
- }());
7482
-
7483
- // Autoload the jQuery bindings
7484
- // We know that all of the modules exist above this, so we're safe
7485
- var select2 = S2.require('jquery.select2');
7486
-
7487
- // Hold the AMD module references on the jQuery function that was just loaded
7488
- // This allows Select2 to use the internal loader outside of this file, such
7489
- // as in the language files.
7490
- jQuery.fn.select2.amd = S2;
7491
-
7492
- // Return the Select2 instance for anyone who is importing it.
7493
- return select2;
7494
- }));
7495
 
7496
 
7497
  /***/ },
1746
  /***/ 289:
1747
  /***/ function(module, exports, __webpack_require__) {
1748
 
1749
+ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;var require;/*!
1750
+ * Select2 4.0.5
1751
+ * https://select2.github.io
1752
+ *
1753
+ * Released under the MIT license
1754
+ * https://github.com/select2/select2/blob/master/LICENSE.md
1755
+ */
1756
+ (function (factory) {
1757
+ if (true) {
1758
+ // AMD. Register as an anonymous module.
1759
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(275)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
1760
+ } else if (typeof module === 'object' && module.exports) {
1761
+ // Node/CommonJS
1762
+ module.exports = function (root, jQuery) {
1763
+ if (jQuery === undefined) {
1764
+ // require('jQuery') returns a factory that requires window to
1765
+ // build a jQuery instance, we normalize how we use modules
1766
+ // that require this pattern but the window provided is a noop
1767
+ // if it's defined (how jquery works)
1768
+ if (typeof window !== 'undefined') {
1769
+ jQuery = require('jquery');
1770
+ }
1771
+ else {
1772
+ jQuery = require('jquery')(root);
1773
+ }
1774
+ }
1775
+ factory(jQuery);
1776
+ return jQuery;
1777
+ };
1778
+ } else {
1779
+ // Browser globals
1780
+ factory(jQuery);
1781
+ }
1782
+ } (function (jQuery) {
1783
+ // This is needed so we can catch the AMD loader configuration and use it
1784
+ // The inner file should be wrapped (by `banner.start.js`) in a function that
1785
+ // returns the AMD loader references.
1786
+ var S2 =(function () {
1787
+ // Restore the Select2 AMD loader so it can be used
1788
+ // Needed mostly in the language files, where the loader is not inserted
1789
+ if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
1790
+ var S2 = jQuery.fn.select2.amd;
1791
+ }
1792
+ var S2;(function () { if (!S2 || !S2.requirejs) {
1793
+ if (!S2) { S2 = {}; } else { require = S2; }
1794
+ /**
1795
+ * @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
1796
+ * Released under MIT license, http://github.com/requirejs/almond/LICENSE
1797
+ */
1798
+ //Going sloppy to avoid 'use strict' string cost, but strict practices should
1799
+ //be followed.
1800
+ /*global setTimeout: false */
1801
+
1802
+ var requirejs, require, define;
1803
+ (function (undef) {
1804
+ var main, req, makeMap, handlers,
1805
+ defined = {},
1806
+ waiting = {},
1807
+ config = {},
1808
+ defining = {},
1809
+ hasOwn = Object.prototype.hasOwnProperty,
1810
+ aps = [].slice,
1811
+ jsSuffixRegExp = /\.js$/;
1812
+
1813
+ function hasProp(obj, prop) {
1814
+ return hasOwn.call(obj, prop);
1815
+ }
1816
+
1817
+ /**
1818
+ * Given a relative module name, like ./something, normalize it to
1819
+ * a real name that can be mapped to a path.
1820
+ * @param {String} name the relative name
1821
+ * @param {String} baseName a real name that the name arg is relative
1822
+ * to.
1823
+ * @returns {String} normalized name
1824
+ */
1825
+ function normalize(name, baseName) {
1826
+ var nameParts, nameSegment, mapValue, foundMap, lastIndex,
1827
+ foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
1828
+ baseParts = baseName && baseName.split("/"),
1829
+ map = config.map,
1830
+ starMap = (map && map['*']) || {};
1831
+
1832
+ //Adjust any relative paths.
1833
+ if (name) {
1834
+ name = name.split('/');
1835
+ lastIndex = name.length - 1;
1836
+
1837
+ // If wanting node ID compatibility, strip .js from end
1838
+ // of IDs. Have to do this here, and not in nameToUrl
1839
+ // because node allows either .js or non .js to map
1840
+ // to same file.
1841
+ if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
1842
+ name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
1843
+ }
1844
+
1845
+ // Starts with a '.' so need the baseName
1846
+ if (name[0].charAt(0) === '.' && baseParts) {
1847
+ //Convert baseName to array, and lop off the last part,
1848
+ //so that . matches that 'directory' and not name of the baseName's
1849
+ //module. For instance, baseName of 'one/two/three', maps to
1850
+ //'one/two/three.js', but we want the directory, 'one/two' for
1851
+ //this normalization.
1852
+ normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
1853
+ name = normalizedBaseParts.concat(name);
1854
+ }
1855
+
1856
+ //start trimDots
1857
+ for (i = 0; i < name.length; i++) {
1858
+ part = name[i];
1859
+ if (part === '.') {
1860
+ name.splice(i, 1);
1861
+ i -= 1;
1862
+ } else if (part === '..') {
1863
+ // If at the start, or previous value is still ..,
1864
+ // keep them so that when converted to a path it may
1865
+ // still work when converted to a path, even though
1866
+ // as an ID it is less than ideal. In larger point
1867
+ // releases, may be better to just kick out an error.
1868
+ if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
1869
+ continue;
1870
+ } else if (i > 0) {
1871
+ name.splice(i - 1, 2);
1872
+ i -= 2;
1873
+ }
1874
+ }
1875
+ }
1876
+ //end trimDots
1877
+
1878
+ name = name.join('/');
1879
+ }
1880
+
1881
+ //Apply map config if available.
1882
+ if ((baseParts || starMap) && map) {
1883
+ nameParts = name.split('/');
1884
+
1885
+ for (i = nameParts.length; i > 0; i -= 1) {
1886
+ nameSegment = nameParts.slice(0, i).join("/");
1887
+
1888
+ if (baseParts) {
1889
+ //Find the longest baseName segment match in the config.
1890
+ //So, do joins on the biggest to smallest lengths of baseParts.
1891
+ for (j = baseParts.length; j > 0; j -= 1) {
1892
+ mapValue = map[baseParts.slice(0, j).join('/')];
1893
+
1894
+ //baseName segment has config, find if it has one for
1895
+ //this name.
1896
+ if (mapValue) {
1897
+ mapValue = mapValue[nameSegment];
1898
+ if (mapValue) {
1899
+ //Match, update name to the new value.
1900
+ foundMap = mapValue;
1901
+ foundI = i;
1902
+ break;
1903
+ }
1904
+ }
1905
+ }
1906
+ }
1907
+
1908
+ if (foundMap) {
1909
+ break;
1910
+ }
1911
+
1912
+ //Check for a star map match, but just hold on to it,
1913
+ //if there is a shorter segment match later in a matching
1914
+ //config, then favor over this star map.
1915
+ if (!foundStarMap && starMap && starMap[nameSegment]) {
1916
+ foundStarMap = starMap[nameSegment];
1917
+ starI = i;
1918
+ }
1919
+ }
1920
+
1921
+ if (!foundMap && foundStarMap) {
1922
+ foundMap = foundStarMap;
1923
+ foundI = starI;
1924
+ }
1925
+
1926
+ if (foundMap) {
1927
+ nameParts.splice(0, foundI, foundMap);
1928
+ name = nameParts.join('/');
1929
+ }
1930
+ }
1931
+
1932
+ return name;
1933
+ }
1934
+
1935
+ function makeRequire(relName, forceSync) {
1936
+ return function () {
1937
+ //A version of a require function that passes a moduleName
1938
+ //value for items that may need to
1939
+ //look up paths relative to the moduleName
1940
+ var args = aps.call(arguments, 0);
1941
+
1942
+ //If first arg is not require('string'), and there is only
1943
+ //one arg, it is the array form without a callback. Insert
1944
+ //a null so that the following concat is correct.
1945
+ if (typeof args[0] !== 'string' && args.length === 1) {
1946
+ args.push(null);
1947
+ }
1948
+ return req.apply(undef, args.concat([relName, forceSync]));
1949
+ };
1950
+ }
1951
+
1952
+ function makeNormalize(relName) {
1953
+ return function (name) {
1954
+ return normalize(name, relName);
1955
+ };
1956
+ }
1957
+
1958
+ function makeLoad(depName) {
1959
+ return function (value) {
1960
+ defined[depName] = value;
1961
+ };
1962
+ }
1963
+
1964
+ function callDep(name) {
1965
+ if (hasProp(waiting, name)) {
1966
+ var args = waiting[name];
1967
+ delete waiting[name];
1968
+ defining[name] = true;
1969
+ main.apply(undef, args);
1970
+ }
1971
+
1972
+ if (!hasProp(defined, name) && !hasProp(defining, name)) {
1973
+ throw new Error('No ' + name);
1974
+ }
1975
+ return defined[name];
1976
+ }
1977
+
1978
+ //Turns a plugin!resource to [plugin, resource]
1979
+ //with the plugin being undefined if the name
1980
+ //did not have a plugin prefix.
1981
+ function splitPrefix(name) {
1982
+ var prefix,
1983
+ index = name ? name.indexOf('!') : -1;
1984
+ if (index > -1) {
1985
+ prefix = name.substring(0, index);
1986
+ name = name.substring(index + 1, name.length);
1987
+ }
1988
+ return [prefix, name];
1989
+ }
1990
+
1991
+ //Creates a parts array for a relName where first part is plugin ID,
1992
+ //second part is resource ID. Assumes relName has already been normalized.
1993
+ function makeRelParts(relName) {
1994
+ return relName ? splitPrefix(relName) : [];
1995
+ }
1996
+
1997
+ /**
1998
+ * Makes a name map, normalizing the name, and using a plugin
1999
+ * for normalization if necessary. Grabs a ref to plugin
2000
+ * too, as an optimization.
2001
+ */
2002
+ makeMap = function (name, relParts) {
2003
+ var plugin,
2004
+ parts = splitPrefix(name),
2005
+ prefix = parts[0],
2006
+ relResourceName = relParts[1];
2007
+
2008
+ name = parts[1];
2009
+
2010
+ if (prefix) {
2011
+ prefix = normalize(prefix, relResourceName);
2012
+ plugin = callDep(prefix);
2013
+ }
2014
+
2015
+ //Normalize according
2016
+ if (prefix) {
2017
+ if (plugin && plugin.normalize) {
2018
+ name = plugin.normalize(name, makeNormalize(relResourceName));
2019
+ } else {
2020
+ name = normalize(name, relResourceName);
2021
+ }
2022
+ } else {
2023
+ name = normalize(name, relResourceName);
2024
+ parts = splitPrefix(name);
2025
+ prefix = parts[0];
2026
+ name = parts[1];
2027
+ if (prefix) {
2028
+ plugin = callDep(prefix);
2029
+ }
2030
+ }
2031
+
2032
+ //Using ridiculous property names for space reasons
2033
+ return {
2034
+ f: prefix ? prefix + '!' + name : name, //fullName
2035
+ n: name,
2036
+ pr: prefix,
2037
+ p: plugin
2038
+ };
2039
+ };
2040
+
2041
+ function makeConfig(name) {
2042
+ return function () {
2043
+ return (config && config.config && config.config[name]) || {};
2044
+ };
2045
+ }
2046
+
2047
+ handlers = {
2048
+ require: function (name) {
2049
+ return makeRequire(name);
2050
+ },
2051
+ exports: function (name) {
2052
+ var e = defined[name];
2053
+ if (typeof e !== 'undefined') {
2054
+ return e;
2055
+ } else {
2056
+ return (defined[name] = {});
2057
+ }
2058
+ },
2059
+ module: function (name) {
2060
+ return {
2061
+ id: name,
2062
+ uri: '',
2063
+ exports: defined[name],
2064
+ config: makeConfig(name)
2065
+ };
2066
+ }
2067
+ };
2068
+
2069
+ main = function (name, deps, callback, relName) {
2070
+ var cjsModule, depName, ret, map, i, relParts,
2071
+ args = [],
2072
+ callbackType = typeof callback,
2073
+ usingExports;
2074
+
2075
+ //Use name if no relName
2076
+ relName = relName || name;
2077
+ relParts = makeRelParts(relName);
2078
+
2079
+ //Call the callback to define the module, if necessary.
2080
+ if (callbackType === 'undefined' || callbackType === 'function') {
2081
+ //Pull out the defined dependencies and pass the ordered
2082
+ //values to the callback.
2083
+ //Default to [require, exports, module] if no deps
2084
+ deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
2085
+ for (i = 0; i < deps.length; i += 1) {
2086
+ map = makeMap(deps[i], relParts);
2087
+ depName = map.f;
2088
+
2089
+ //Fast path CommonJS standard dependencies.
2090
+ if (depName === "require") {
2091
+ args[i] = handlers.require(name);
2092
+ } else if (depName === "exports") {
2093
+ //CommonJS module spec 1.1
2094
+ args[i] = handlers.exports(name);
2095
+ usingExports = true;
2096
+ } else if (depName === "module") {
2097
+ //CommonJS module spec 1.1
2098
+ cjsModule = args[i] = handlers.module(name);
2099
+ } else if (hasProp(defined, depName) ||
2100
+ hasProp(waiting, depName) ||
2101
+ hasProp(defining, depName)) {
2102
+ args[i] = callDep(depName);
2103
+ } else if (map.p) {
2104
+ map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
2105
+ args[i] = defined[depName];
2106
+ } else {
2107
+ throw new Error(name + ' missing ' + depName);
2108
+ }
2109
+ }
2110
+
2111
+ ret = callback ? callback.apply(defined[name], args) : undefined;
2112
+
2113
+ if (name) {
2114
+ //If setting exports via "module" is in play,
2115
+ //favor that over return value and exports. After that,
2116
+ //favor a non-undefined return value over exports use.
2117
+ if (cjsModule && cjsModule.exports !== undef &&
2118
+ cjsModule.exports !== defined[name]) {
2119
+ defined[name] = cjsModule.exports;
2120
+ } else if (ret !== undef || !usingExports) {
2121
+ //Use the return value from the function.
2122
+ defined[name] = ret;
2123
+ }
2124
+ }
2125
+ } else if (name) {
2126
+ //May just be an object definition for the module. Only
2127
+ //worry about defining if have a module name.
2128
+ defined[name] = callback;
2129
+ }
2130
+ };
2131
+
2132
+ requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
2133
+ if (typeof deps === "string") {
2134
+ if (handlers[deps]) {
2135
+ //callback in this case is really relName
2136
+ return handlers[deps](callback);
2137
+ }
2138
+ //Just return the module wanted. In this scenario, the
2139
+ //deps arg is the module name, and second arg (if passed)
2140
+ //is just the relName.
2141
+ //Normalize module name, if it contains . or ..
2142
+ return callDep(makeMap(deps, makeRelParts(callback)).f);
2143
+ } else if (!deps.splice) {
2144
+ //deps is a config object, not an array.
2145
+ config = deps;
2146
+ if (config.deps) {
2147
+ req(config.deps, config.callback);
2148
+ }
2149
+ if (!callback) {
2150
+ return;
2151
+ }
2152
+
2153
+ if (callback.splice) {
2154
+ //callback is an array, which means it is a dependency list.
2155
+ //Adjust args if there are dependencies
2156
+ deps = callback;
2157
+ callback = relName;
2158
+ relName = null;
2159
+ } else {
2160
+ deps = undef;
2161
+ }
2162
+ }
2163
+
2164
+ //Support require(['a'])
2165
+ callback = callback || function () {};
2166
+
2167
+ //If relName is a function, it is an errback handler,
2168
+ //so remove it.
2169
+ if (typeof relName === 'function') {
2170
+ relName = forceSync;
2171
+ forceSync = alt;
2172
+ }
2173
+
2174
+ //Simulate async callback;
2175
+ if (forceSync) {
2176
+ main(undef, deps, callback, relName);
2177
+ } else {
2178
+ //Using a non-zero value because of concern for what old browsers
2179
+ //do, and latest browsers "upgrade" to 4 if lower value is used:
2180
+ //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
2181
+ //If want a value immediately, use require('id') instead -- something
2182
+ //that works in almond on the global level, but not guaranteed and
2183
+ //unlikely to work in other AMD implementations.
2184
+ setTimeout(function () {
2185
+ main(undef, deps, callback, relName);
2186
+ }, 4);
2187
+ }
2188
+
2189
+ return req;
2190
+ };
2191
+
2192
+ /**
2193
+ * Just drops the config on the floor, but returns req in case
2194
+ * the config return value is used.
2195
+ */
2196
+ req.config = function (cfg) {
2197
+ return req(cfg);
2198
+ };
2199
+
2200
+ /**
2201
+ * Expose module registry for debugging and tooling
2202
+ */
2203
+ requirejs._defined = defined;
2204
+
2205
+ define = function (name, deps, callback) {
2206
+ if (typeof name !== 'string') {
2207
+ throw new Error('See almond README: incorrect module build, no module name');
2208
+ }
2209
+
2210
+ //This module may not have dependencies
2211
+ if (!deps.splice) {
2212
+ //deps is not an array, so probably means
2213
+ //an object literal or factory function for
2214
+ //the value. Adjust args.
2215
+ callback = deps;
2216
+ deps = [];
2217
+ }
2218
+
2219
+ if (!hasProp(defined, name) && !hasProp(waiting, name)) {
2220
+ waiting[name] = [name, deps, callback];
2221
+ }
2222
+ };
2223
+
2224
+ define.amd = {
2225
+ jQuery: true
2226
+ };
2227
+ }());
2228
+
2229
+ S2.requirejs = requirejs;S2.require = require;S2.define = define;
2230
+ }
2231
+ }());
2232
+ S2.define("almond", function(){});
2233
+
2234
+ /* global jQuery:false, $:false */
2235
+ S2.define('jquery',[],function () {
2236
+ var _$ = jQuery || $;
2237
+
2238
+ if (_$ == null && console && console.error) {
2239
+ console.error(
2240
+ 'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
2241
+ 'found. Make sure that you are including jQuery before Select2 on your ' +
2242
+ 'web page.'
2243
+ );
2244
+ }
2245
+
2246
+ return _$;
2247
+ });
2248
+
2249
+ S2.define('select2/utils',[
2250
+ 'jquery'
2251
+ ], function ($) {
2252
+ var Utils = {};
2253
+
2254
+ Utils.Extend = function (ChildClass, SuperClass) {
2255
+ var __hasProp = {}.hasOwnProperty;
2256
+
2257
+ function BaseConstructor () {
2258
+ this.constructor = ChildClass;
2259
+ }
2260
+
2261
+ for (var key in SuperClass) {
2262
+ if (__hasProp.call(SuperClass, key)) {
2263
+ ChildClass[key] = SuperClass[key];
2264
+ }
2265
+ }
2266
+
2267
+ BaseConstructor.prototype = SuperClass.prototype;
2268
+ ChildClass.prototype = new BaseConstructor();
2269
+ ChildClass.__super__ = SuperClass.prototype;
2270
+
2271
+ return ChildClass;
2272
+ };
2273
+
2274
+ function getMethods (theClass) {
2275
+ var proto = theClass.prototype;
2276
+
2277
+ var methods = [];
2278
+
2279
+ for (var methodName in proto) {
2280
+ var m = proto[methodName];
2281
+
2282
+ if (typeof m !== 'function') {
2283
+ continue;
2284
+ }
2285
+
2286
+ if (methodName === 'constructor') {
2287
+ continue;
2288
+ }
2289
+
2290
+ methods.push(methodName);
2291
+ }
2292
+
2293
+ return methods;
2294
+ }
2295
+
2296
+ Utils.Decorate = function (SuperClass, DecoratorClass) {
2297
+ var decoratedMethods = getMethods(DecoratorClass);
2298
+ var superMethods = getMethods(SuperClass);
2299
+
2300
+ function DecoratedClass () {
2301
+ var unshift = Array.prototype.unshift;
2302
+
2303
+ var argCount = DecoratorClass.prototype.constructor.length;
2304
+
2305
+ var calledConstructor = SuperClass.prototype.constructor;
2306
+
2307
+ if (argCount > 0) {
2308
+ unshift.call(arguments, SuperClass.prototype.constructor);
2309
+
2310
+ calledConstructor = DecoratorClass.prototype.constructor;
2311
+ }
2312
+
2313
+ calledConstructor.apply(this, arguments);
2314
+ }
2315
+
2316
+ DecoratorClass.displayName = SuperClass.displayName;
2317
+
2318
+ function ctr () {
2319
+ this.constructor = DecoratedClass;
2320
+ }
2321
+
2322
+ DecoratedClass.prototype = new ctr();
2323
+
2324
+ for (var m = 0; m < superMethods.length; m++) {
2325
+ var superMethod = superMethods[m];
2326
+
2327
+ DecoratedClass.prototype[superMethod] =
2328
+ SuperClass.prototype[superMethod];
2329
+ }
2330
+
2331
+ var calledMethod = function (methodName) {
2332
+ // Stub out the original method if it's not decorating an actual method
2333
+ var originalMethod = function () {};
2334
+
2335
+ if (methodName in DecoratedClass.prototype) {
2336
+ originalMethod = DecoratedClass.prototype[methodName];
2337
+ }
2338
+
2339
+ var decoratedMethod = DecoratorClass.prototype[methodName];
2340
+
2341
+ return function () {
2342
+ var unshift = Array.prototype.unshift;
2343
+
2344
+ unshift.call(arguments, originalMethod);
2345
+
2346
+ return decoratedMethod.apply(this, arguments);
2347
+ };
2348
+ };
2349
+
2350
+ for (var d = 0; d < decoratedMethods.length; d++) {
2351
+ var decoratedMethod = decoratedMethods[d];
2352
+
2353
+ DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
2354
+ }
2355
+
2356
+ return DecoratedClass;
2357
+ };
2358
+
2359
+ var Observable = function () {
2360
+ this.listeners = {};
2361
+ };
2362
+
2363
+ Observable.prototype.on = function (event, callback) {
2364
+ this.listeners = this.listeners || {};
2365
+
2366
+ if (event in this.listeners) {
2367
+ this.listeners[event].push(callback);
2368
+ } else {
2369
+ this.listeners[event] = [callback];
2370
+ }
2371
+ };
2372
+
2373
+ Observable.prototype.trigger = function (event) {
2374
+ var slice = Array.prototype.slice;
2375
+ var params = slice.call(arguments, 1);
2376
+
2377
+ this.listeners = this.listeners || {};
2378
+
2379
+ // Params should always come in as an array
2380
+ if (params == null) {
2381
+ params = [];
2382
+ }
2383
+
2384
+ // If there are no arguments to the event, use a temporary object
2385
+ if (params.length === 0) {
2386
+ params.push({});
2387
+ }
2388
+
2389
+ // Set the `_type` of the first object to the event
2390
+ params[0]._type = event;
2391
+
2392
+ if (event in this.listeners) {
2393
+ this.invoke(this.listeners[event], slice.call(arguments, 1));
2394
+ }
2395
+
2396
+ if ('*' in this.listeners) {
2397
+ this.invoke(this.listeners['*'], arguments);
2398
+ }
2399
+ };
2400
+
2401
+ Observable.prototype.invoke = function (listeners, params) {
2402
+ for (var i = 0, len = listeners.length; i < len; i++) {
2403
+ listeners[i].apply(this, params);
2404
+ }
2405
+ };
2406
+
2407
+ Utils.Observable = Observable;
2408
+
2409
+ Utils.generateChars = function (length) {
2410
+ var chars = '';
2411
+
2412
+ for (var i = 0; i < length; i++) {
2413
+ var randomChar = Math.floor(Math.random() * 36);
2414
+ chars += randomChar.toString(36);
2415
+ }
2416
+
2417
+ return chars;
2418
+ };
2419
+
2420
+ Utils.bind = function (func, context) {
2421
+ return function () {
2422
+ func.apply(context, arguments);
2423
+ };
2424
+ };
2425
+
2426
+ Utils._convertData = function (data) {
2427
+ for (var originalKey in data) {
2428
+ var keys = originalKey.split('-');
2429
+
2430
+ var dataLevel = data;
2431
+
2432
+ if (keys.length === 1) {
2433
+ continue;
2434
+ }
2435
+
2436
+ for (var k = 0; k < keys.length; k++) {
2437
+ var key = keys[k];
2438
+
2439
+ // Lowercase the first letter
2440
+ // By default, dash-separated becomes camelCase
2441
+ key = key.substring(0, 1).toLowerCase() + key.substring(1);
2442
+
2443
+ if (!(key in dataLevel)) {
2444
+ dataLevel[key] = {};
2445
+ }
2446
+
2447
+ if (k == keys.length - 1) {
2448
+ dataLevel[key] = data[originalKey];
2449
+ }
2450
+
2451
+ dataLevel = dataLevel[key];
2452
+ }
2453
+
2454
+ delete data[originalKey];
2455
+ }
2456
+
2457
+ return data;
2458
+ };
2459
+
2460
+ Utils.hasScroll = function (index, el) {
2461
+ // Adapted from the function created by @ShadowScripter
2462
+ // and adapted by @BillBarry on the Stack Exchange Code Review website.
2463
+ // The original code can be found at
2464
+ // http://codereview.stackexchange.com/q/13338
2465
+ // and was designed to be used with the Sizzle selector engine.
2466
+
2467
+ var $el = $(el);
2468
+ var overflowX = el.style.overflowX;
2469
+ var overflowY = el.style.overflowY;
2470
+
2471
+ //Check both x and y declarations
2472
+ if (overflowX === overflowY &&
2473
+ (overflowY === 'hidden' || overflowY === 'visible')) {
2474
+ return false;
2475
+ }
2476
+
2477
+ if (overflowX === 'scroll' || overflowY === 'scroll') {
2478
+ return true;
2479
+ }
2480
+
2481
+ return ($el.innerHeight() < el.scrollHeight ||
2482
+ $el.innerWidth() < el.scrollWidth);
2483
+ };
2484
+
2485
+ Utils.escapeMarkup = function (markup) {
2486
+ var replaceMap = {
2487
+ '\\': '&#92;',
2488
+ '&': '&amp;',
2489
+ '<': '&lt;',
2490
+ '>': '&gt;',
2491
+ '"': '&quot;',
2492
+ '\'': '&#39;',
2493
+ '/': '&#47;'
2494
+ };
2495
+
2496
+ // Do not try to escape the markup if it's not a string
2497
+ if (typeof markup !== 'string') {
2498
+ return markup;
2499
+ }
2500
+
2501
+ return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
2502
+ return replaceMap[match];
2503
+ });
2504
+ };
2505
+
2506
+ // Append an array of jQuery nodes to a given element.
2507
+ Utils.appendMany = function ($element, $nodes) {
2508
+ // jQuery 1.7.x does not support $.fn.append() with an array
2509
+ // Fall back to a jQuery object collection using $.fn.add()
2510
+ if ($.fn.jquery.substr(0, 3) === '1.7') {
2511
+ var $jqNodes = $();
2512
+
2513
+ $.map($nodes, function (node) {
2514
+ $jqNodes = $jqNodes.add(node);
2515
+ });
2516
+
2517
+ $nodes = $jqNodes;
2518
+ }
2519
+
2520
+ $element.append($nodes);
2521
+ };
2522
+
2523
+ return Utils;
2524
+ });
2525
+
2526
+ S2.define('select2/results',[
2527
+ 'jquery',
2528
+ './utils'
2529
+ ], function ($, Utils) {
2530
+ function Results ($element, options, dataAdapter) {
2531
+ this.$element = $element;
2532
+ this.data = dataAdapter;
2533
+ this.options = options;
2534
+
2535
+ Results.__super__.constructor.call(this);
2536
+ }
2537
+
2538
+ Utils.Extend(Results, Utils.Observable);
2539
+
2540
+ Results.prototype.render = function () {
2541
+ var $results = $(
2542
+ '<ul class="select2-results__options" role="tree"></ul>'
2543
+ );
2544
+
2545
+ if (this.options.get('multiple')) {
2546
+ $results.attr('aria-multiselectable', 'true');
2547
+ }
2548
+
2549
+ this.$results = $results;
2550
+
2551
+ return $results;
2552
+ };
2553
+
2554
+ Results.prototype.clear = function () {
2555
+ this.$results.empty();
2556
+ };
2557
+
2558
+ Results.prototype.displayMessage = function (params) {
2559
+ var escapeMarkup = this.options.get('escapeMarkup');
2560
+
2561
+ this.clear();
2562
+ this.hideLoading();
2563
+
2564
+ var $message = $(
2565
+ '<li role="treeitem" aria-live="assertive"' +
2566
+ ' class="select2-results__option"></li>'
2567
+ );
2568
+
2569
+ var message = this.options.get('translations').get(params.message);
2570
+
2571
+ $message.append(
2572
+ escapeMarkup(
2573
+ message(params.args)
2574
+ )
2575
+ );
2576
+
2577
+ $message[0].className += ' select2-results__message';
2578
+
2579
+ this.$results.append($message);
2580
+ };
2581
+
2582
+ Results.prototype.hideMessages = function () {
2583
+ this.$results.find('.select2-results__message').remove();
2584
+ };
2585
+
2586
+ Results.prototype.append = function (data) {
2587
+ this.hideLoading();
2588
+
2589
+ var $options = [];
2590
+
2591
+ if (data.results == null || data.results.length === 0) {
2592
+ if (this.$results.children().length === 0) {
2593
+ this.trigger('results:message', {
2594
+ message: 'noResults'
2595
+ });
2596
+ }
2597
+
2598
+ return;
2599
+ }
2600
+
2601
+ data.results = this.sort(data.results);
2602
+
2603
+ for (var d = 0; d < data.results.length; d++) {
2604
+ var item = data.results[d];
2605
+
2606
+ var $option = this.option(item);
2607
+
2608
+ $options.push($option);
2609
+ }
2610
+
2611
+ this.$results.append($options);
2612
+ };
2613
+
2614
+ Results.prototype.position = function ($results, $dropdown) {
2615
+ var $resultsContainer = $dropdown.find('.select2-results');
2616
+ $resultsContainer.append($results);
2617
+ };
2618
+
2619
+ Results.prototype.sort = function (data) {
2620
+ var sorter = this.options.get('sorter');
2621
+
2622
+ return sorter(data);
2623
+ };
2624
+
2625
+ Results.prototype.highlightFirstItem = function () {
2626
+ var $options = this.$results
2627
+ .find('.select2-results__option[aria-selected]');
2628
+
2629
+ var $selected = $options.filter('[aria-selected=true]');
2630
+
2631
+ // Check if there are any selected options
2632
+ if ($selected.length > 0) {
2633
+ // If there are selected options, highlight the first
2634
+ $selected.first().trigger('mouseenter');
2635
+ } else {
2636
+ // If there are no selected options, highlight the first option
2637
+ // in the dropdown
2638
+ $options.first().trigger('mouseenter');
2639
+ }
2640
+
2641
+ this.ensureHighlightVisible();
2642
+ };
2643
+
2644
+ Results.prototype.setClasses = function () {
2645
+ var self = this;
2646
+
2647
+ this.data.current(function (selected) {
2648
+ var selectedIds = $.map(selected, function (s) {
2649
+ return s.id.toString();
2650
+ });
2651
+
2652
+ var $options = self.$results
2653
+ .find('.select2-results__option[aria-selected]');
2654
+
2655
+ $options.each(function () {
2656
+ var $option = $(this);
2657
+
2658
+ var item = $.data(this, 'data');
2659
+
2660
+ // id needs to be converted to a string when comparing
2661
+ var id = '' + item.id;
2662
+
2663
+ if ((item.element != null && item.element.selected) ||
2664
+ (item.element == null && $.inArray(id, selectedIds) > -1)) {
2665
+ $option.attr('aria-selected', 'true');
2666
+ } else {
2667
+ $option.attr('aria-selected', 'false');
2668
+ }
2669
+ });
2670
+
2671
+ });
2672
+ };
2673
+
2674
+ Results.prototype.showLoading = function (params) {
2675
+ this.hideLoading();
2676
+
2677
+ var loadingMore = this.options.get('translations').get('searching');
2678
+
2679
+ var loading = {
2680
+ disabled: true,
2681
+ loading: true,
2682
+ text: loadingMore(params)
2683
+ };
2684
+ var $loading = this.option(loading);
2685
+ $loading.className += ' loading-results';
2686
+
2687
+ this.$results.prepend($loading);
2688
+ };
2689
+
2690
+ Results.prototype.hideLoading = function () {
2691
+ this.$results.find('.loading-results').remove();
2692
+ };
2693
+
2694
+ Results.prototype.option = function (data) {
2695
+ var option = document.createElement('li');
2696
+ option.className = 'select2-results__option';
2697
+
2698
+ var attrs = {
2699
+ 'role': 'treeitem',
2700
+ 'aria-selected': 'false'
2701
+ };
2702
+
2703
+ if (data.disabled) {
2704
+ delete attrs['aria-selected'];
2705
+ attrs['aria-disabled'] = 'true';
2706
+ }
2707
+
2708
+ if (data.id == null) {
2709
+ delete attrs['aria-selected'];
2710
+ }
2711
+
2712
+ if (data._resultId != null) {
2713
+ option.id = data._resultId;
2714
+ }
2715
+
2716
+ if (data.title) {
2717
+ option.title = data.title;
2718
+ }
2719
+
2720
+ if (data.children) {
2721
+ attrs.role = 'group';
2722
+ attrs['aria-label'] = data.text;
2723
+ delete attrs['aria-selected'];
2724
+ }
2725
+
2726
+ for (var attr in attrs) {
2727
+ var val = attrs[attr];
2728
+
2729
+ option.setAttribute(attr, val);
2730
+ }
2731
+
2732
+ if (data.children) {
2733
+ var $option = $(option);
2734
+
2735
+ var label = document.createElement('strong');
2736
+ label.className = 'select2-results__group';
2737
+
2738
+ var $label = $(label);
2739
+ this.template(data, label);
2740
+
2741
+ var $children = [];
2742
+
2743
+ for (var c = 0; c < data.children.length; c++) {
2744
+ var child = data.children[c];
2745
+
2746
+ var $child = this.option(child);
2747
+
2748
+ $children.push($child);
2749
+ }
2750
+
2751
+ var $childrenContainer = $('<ul></ul>', {
2752
+ 'class': 'select2-results__options select2-results__options--nested'
2753
+ });
2754
+
2755
+ $childrenContainer.append($children);
2756
+
2757
+ $option.append(label);
2758
+ $option.append($childrenContainer);
2759
+ } else {
2760
+ this.template(data, option);
2761
+ }
2762
+
2763
+ $.data(option, 'data', data);
2764
+
2765
+ return option;
2766
+ };
2767
+
2768
+ Results.prototype.bind = function (container, $container) {
2769
+ var self = this;
2770
+
2771
+ var id = container.id + '-results';
2772
+
2773
+ this.$results.attr('id', id);
2774
+
2775
+ container.on('results:all', function (params) {
2776
+ self.clear();
2777
+ self.append(params.data);
2778
+
2779
+ if (container.isOpen()) {
2780
+ self.setClasses();
2781
+ self.highlightFirstItem();
2782
+ }
2783
+ });
2784
+
2785
+ container.on('results:append', function (params) {
2786
+ self.append(params.data);
2787
+
2788
+ if (container.isOpen()) {
2789
+ self.setClasses();
2790
+ }
2791
+ });
2792
+
2793
+ container.on('query', function (params) {
2794
+ self.hideMessages();
2795
+ self.showLoading(params);
2796
+ });
2797
+
2798
+ container.on('select', function () {
2799
+ if (!container.isOpen()) {
2800
+ return;
2801
+ }
2802
+
2803
+ self.setClasses();
2804
+ self.highlightFirstItem();
2805
+ });
2806
+
2807
+ container.on('unselect', function () {
2808
+ if (!container.isOpen()) {
2809
+ return;
2810
+ }
2811
+
2812
+ self.setClasses();
2813
+ self.highlightFirstItem();
2814
+ });
2815
+
2816
+ container.on('open', function () {
2817
+ // When the dropdown is open, aria-expended="true"
2818
+ self.$results.attr('aria-expanded', 'true');
2819
+ self.$results.attr('aria-hidden', 'false');
2820
+
2821
+ self.setClasses();
2822
+ self.ensureHighlightVisible();
2823
+ });
2824
+
2825
+ container.on('close', function () {
2826
+ // When the dropdown is closed, aria-expended="false"
2827
+ self.$results.attr('aria-expanded', 'false');
2828
+ self.$results.attr('aria-hidden', 'true');
2829
+ self.$results.removeAttr('aria-activedescendant');
2830
+ });
2831
+
2832
+ container.on('results:toggle', function () {
2833
+ var $highlighted = self.getHighlightedResults();
2834
+
2835
+ if ($highlighted.length === 0) {
2836
+ return;
2837
+ }
2838
+
2839
+ $highlighted.trigger('mouseup');
2840
+ });
2841
+
2842
+ container.on('results:select', function () {
2843
+ var $highlighted = self.getHighlightedResults();
2844
+
2845
+ if ($highlighted.length === 0) {
2846
+ return;
2847
+ }
2848
+
2849
+ var data = $highlighted.data('data');
2850
+
2851
+ if ($highlighted.attr('aria-selected') == 'true') {
2852
+ self.trigger('close', {});
2853
+ } else {
2854
+ self.trigger('select', {
2855
+ data: data
2856
+ });
2857
+ }
2858
+ });
2859
+
2860
+ container.on('results:previous', function () {
2861
+ var $highlighted = self.getHighlightedResults();
2862
+
2863
+ var $options = self.$results.find('[aria-selected]');
2864
+
2865
+ var currentIndex = $options.index($highlighted);
2866
+
2867
+ // If we are already at te top, don't move further
2868
+ if (currentIndex === 0) {
2869
+ return;
2870
+ }
2871
+
2872
+ var nextIndex = currentIndex - 1;
2873
+
2874
+ // If none are highlighted, highlight the first
2875
+ if ($highlighted.length === 0) {
2876
+ nextIndex = 0;
2877
+ }
2878
+
2879
+ var $next = $options.eq(nextIndex);
2880
+
2881
+ $next.trigger('mouseenter');
2882
+
2883
+ var currentOffset = self.$results.offset().top;
2884
+ var nextTop = $next.offset().top;
2885
+ var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
2886
+
2887
+ if (nextIndex === 0) {
2888
+ self.$results.scrollTop(0);
2889
+ } else if (nextTop - currentOffset < 0) {
2890
+ self.$results.scrollTop(nextOffset);
2891
+ }
2892
+ });
2893
+
2894
+ container.on('results:next', function () {
2895
+ var $highlighted = self.getHighlightedResults();
2896
+
2897
+ var $options = self.$results.find('[aria-selected]');
2898
+
2899
+ var currentIndex = $options.index($highlighted);
2900
+
2901
+ var nextIndex = currentIndex + 1;
2902
+
2903
+ // If we are at the last option, stay there
2904
+ if (nextIndex >= $options.length) {
2905
+ return;
2906
+ }
2907
+
2908
+ var $next = $options.eq(nextIndex);
2909
+
2910
+ $next.trigger('mouseenter');
2911
+
2912
+ var currentOffset = self.$results.offset().top +
2913
+ self.$results.outerHeight(false);
2914
+ var nextBottom = $next.offset().top + $next.outerHeight(false);
2915
+ var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
2916
+
2917
+ if (nextIndex === 0) {
2918
+ self.$results.scrollTop(0);
2919
+ } else if (nextBottom > currentOffset) {
2920
+ self.$results.scrollTop(nextOffset);
2921
+ }
2922
+ });
2923
+
2924
+ container.on('results:focus', function (params) {
2925
+ params.element.addClass('select2-results__option--highlighted');
2926
+ });
2927
+
2928
+ container.on('results:message', function (params) {
2929
+ self.displayMessage(params);
2930
+ });
2931
+
2932
+ if ($.fn.mousewheel) {
2933
+ this.$results.on('mousewheel', function (e) {
2934
+ var top = self.$results.scrollTop();
2935
+
2936
+ var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
2937
+
2938
+ var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
2939
+ var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
2940
+
2941
+ if (isAtTop) {
2942
+ self.$results.scrollTop(0);
2943
+
2944
+ e.preventDefault();
2945
+ e.stopPropagation();
2946
+ } else if (isAtBottom) {
2947
+ self.$results.scrollTop(
2948
+ self.$results.get(0).scrollHeight - self.$results.height()
2949
+ );
2950
+
2951
+ e.preventDefault();
2952
+ e.stopPropagation();
2953
+ }
2954
+ });
2955
+ }
2956
+
2957
+ this.$results.on('mouseup', '.select2-results__option[aria-selected]',
2958
+ function (evt) {
2959
+ var $this = $(this);
2960
+
2961
+ var data = $this.data('data');
2962
+
2963
+ if ($this.attr('aria-selected') === 'true') {
2964
+ if (self.options.get('multiple')) {
2965
+ self.trigger('unselect', {
2966
+ originalEvent: evt,
2967
+ data: data
2968
+ });
2969
+ } else {
2970
+ self.trigger('close', {});
2971
+ }
2972
+
2973
+ return;
2974
+ }
2975
+
2976
+ self.trigger('select', {
2977
+ originalEvent: evt,
2978
+ data: data
2979
+ });
2980
+ });
2981
+
2982
+ this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
2983
+ function (evt) {
2984
+ var data = $(this).data('data');
2985
+
2986
+ self.getHighlightedResults()
2987
+ .removeClass('select2-results__option--highlighted');
2988
+
2989
+ self.trigger('results:focus', {
2990
+ data: data,
2991
+ element: $(this)
2992
+ });
2993
+ });
2994
+ };
2995
+
2996
+ Results.prototype.getHighlightedResults = function () {
2997
+ var $highlighted = this.$results
2998
+ .find('.select2-results__option--highlighted');
2999
+
3000
+ return $highlighted;
3001
+ };
3002
+
3003
+ Results.prototype.destroy = function () {
3004
+ this.$results.remove();
3005
+ };
3006
+
3007
+ Results.prototype.ensureHighlightVisible = function () {
3008
+ var $highlighted = this.getHighlightedResults();
3009
+
3010
+ if ($highlighted.length === 0) {
3011
+ return;
3012
+ }
3013
+
3014
+ var $options = this.$results.find('[aria-selected]');
3015
+
3016
+ var currentIndex = $options.index($highlighted);
3017
+
3018
+ var currentOffset = this.$results.offset().top;
3019
+ var nextTop = $highlighted.offset().top;
3020
+ var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
3021
+
3022
+ var offsetDelta = nextTop - currentOffset;
3023
+ nextOffset -= $highlighted.outerHeight(false) * 2;
3024
+
3025
+ if (currentIndex <= 2) {
3026
+ this.$results.scrollTop(0);
3027
+ } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
3028
+ this.$results.scrollTop(nextOffset);
3029
+ }
3030
+ };
3031
+
3032
+ Results.prototype.template = function (result, container) {
3033
+ var template = this.options.get('templateResult');
3034
+ var escapeMarkup = this.options.get('escapeMarkup');
3035
+
3036
+ var content = template(result, container);
3037
+
3038
+ if (content == null) {
3039
+ container.style.display = 'none';
3040
+ } else if (typeof content === 'string') {
3041
+ container.innerHTML = escapeMarkup(content);
3042
+ } else {
3043
+ $(container).append(content);
3044
+ }
3045
+ };
3046
+
3047
+ return Results;
3048
+ });
3049
+
3050
+ S2.define('select2/keys',[
3051
+
3052
+ ], function () {
3053
+ var KEYS = {
3054
+ BACKSPACE: 8,
3055
+ TAB: 9,
3056
+ ENTER: 13,
3057
+ SHIFT: 16,
3058
+ CTRL: 17,
3059
+ ALT: 18,
3060
+ ESC: 27,
3061
+ SPACE: 32,
3062
+ PAGE_UP: 33,
3063
+ PAGE_DOWN: 34,
3064
+ END: 35,
3065
+ HOME: 36,
3066
+ LEFT: 37,
3067
+ UP: 38,
3068
+ RIGHT: 39,
3069
+ DOWN: 40,
3070
+ DELETE: 46
3071
+ };
3072
+
3073
+ return KEYS;
3074
+ });
3075
+
3076
+ S2.define('select2/selection/base',[
3077
+ 'jquery',
3078
+ '../utils',
3079
+ '../keys'
3080
+ ], function ($, Utils, KEYS) {
3081
+ function BaseSelection ($element, options) {
3082
+ this.$element = $element;
3083
+ this.options = options;
3084
+
3085
+ BaseSelection.__super__.constructor.call(this);
3086
+ }
3087
+
3088
+ Utils.Extend(BaseSelection, Utils.Observable);
3089
+
3090
+ BaseSelection.prototype.render = function () {
3091
+ var $selection = $(
3092
+ '<span class="select2-selection" role="combobox" ' +
3093
+ ' aria-haspopup="true" aria-expanded="false">' +
3094
+ '</span>'
3095
+ );
3096
+
3097
+ this._tabindex = 0;
3098
+
3099
+ if (this.$element.data('old-tabindex') != null) {
3100
+ this._tabindex = this.$element.data('old-tabindex');
3101
+ } else if (this.$element.attr('tabindex') != null) {
3102
+ this._tabindex = this.$element.attr('tabindex');
3103
+ }
3104
+
3105
+ $selection.attr('title', this.$element.attr('title'));
3106
+ $selection.attr('tabindex', this._tabindex);
3107
+
3108
+ this.$selection = $selection;
3109
+
3110
+ return $selection;
3111
+ };
3112
+
3113
+ BaseSelection.prototype.bind = function (container, $container) {
3114
+ var self = this;
3115
+
3116
+ var id = container.id + '-container';
3117
+ var resultsId = container.id + '-results';
3118
+
3119
+ this.container = container;
3120
+
3121
+ this.$selection.on('focus', function (evt) {
3122
+ self.trigger('focus', evt);
3123
+ });
3124
+
3125
+ this.$selection.on('blur', function (evt) {
3126
+ self._handleBlur(evt);
3127
+ });
3128
+
3129
+ this.$selection.on('keydown', function (evt) {
3130
+ self.trigger('keypress', evt);
3131
+
3132
+ if (evt.which === KEYS.SPACE) {
3133
+ evt.preventDefault();
3134
+ }
3135
+ });
3136
+
3137
+ container.on('results:focus', function (params) {
3138
+ self.$selection.attr('aria-activedescendant', params.data._resultId);
3139
+ });
3140
+
3141
+ container.on('selection:update', function (params) {
3142
+ self.update(params.data);
3143
+ });
3144
+
3145
+ container.on('open', function () {
3146
+ // When the dropdown is open, aria-expanded="true"
3147
+ self.$selection.attr('aria-expanded', 'true');
3148
+ self.$selection.attr('aria-owns', resultsId);
3149
+
3150
+ self._attachCloseHandler(container);
3151
+ });
3152
+
3153
+ container.on('close', function () {
3154
+ // When the dropdown is closed, aria-expanded="false"
3155
+ self.$selection.attr('aria-expanded', 'false');
3156
+ self.$selection.removeAttr('aria-activedescendant');
3157
+ self.$selection.removeAttr('aria-owns');
3158
+
3159
+ self.$selection.focus();
3160
+
3161
+ self._detachCloseHandler(container);
3162
+ });
3163
+
3164
+ container.on('enable', function () {
3165
+ self.$selection.attr('tabindex', self._tabindex);
3166
+ });
3167
+
3168
+ container.on('disable', function () {
3169
+ self.$selection.attr('tabindex', '-1');
3170
+ });
3171
+ };
3172
+
3173
+ BaseSelection.prototype._handleBlur = function (evt) {
3174
+ var self = this;
3175
+
3176
+ // This needs to be delayed as the active element is the body when the tab
3177
+ // key is pressed, possibly along with others.
3178
+ window.setTimeout(function () {
3179
+ // Don't trigger `blur` if the focus is still in the selection
3180
+ if (
3181
+ (document.activeElement == self.$selection[0]) ||
3182
+ ($.contains(self.$selection[0], document.activeElement))
3183
+ ) {
3184
+ return;
3185
+ }
3186
+
3187
+ self.trigger('blur', evt);
3188
+ }, 1);
3189
+ };
3190
+
3191
+ BaseSelection.prototype._attachCloseHandler = function (container) {
3192
+ var self = this;
3193
+
3194
+ $(document.body).on('mousedown.select2.' + container.id, function (e) {
3195
+ var $target = $(e.target);
3196
+
3197
+ var $select = $target.closest('.select2');
3198
+
3199
+ var $all = $('.select2.select2-container--open');
3200
+
3201
+ $all.each(function () {
3202
+ var $this = $(this);
3203
+
3204
+ if (this == $select[0]) {
3205
+ return;
3206
+ }
3207
+
3208
+ var $element = $this.data('element');
3209
+
3210
+ $element.select2('close');
3211
+ });
3212
+ });
3213
+ };
3214
+
3215
+ BaseSelection.prototype._detachCloseHandler = function (container) {
3216
+ $(document.body).off('mousedown.select2.' + container.id);
3217
+ };
3218
+
3219
+ BaseSelection.prototype.position = function ($selection, $container) {
3220
+ var $selectionContainer = $container.find('.selection');
3221
+ $selectionContainer.append($selection);
3222
+ };
3223
+
3224
+ BaseSelection.prototype.destroy = function () {
3225
+ this._detachCloseHandler(this.container);
3226
+ };
3227
+
3228
+ BaseSelection.prototype.update = function (data) {
3229
+ throw new Error('The `update` method must be defined in child classes.');
3230
+ };
3231
+
3232
+ return BaseSelection;
3233
+ });
3234
+
3235
+ S2.define('select2/selection/single',[
3236
+ 'jquery',
3237
+ './base',
3238
+ '../utils',
3239
+ '../keys'
3240
+ ], function ($, BaseSelection, Utils, KEYS) {
3241
+ function SingleSelection () {
3242
+ SingleSelection.__super__.constructor.apply(this, arguments);
3243
+ }
3244
+
3245
+ Utils.Extend(SingleSelection, BaseSelection);
3246
+
3247
+ SingleSelection.prototype.render = function () {
3248
+ var $selection = SingleSelection.__super__.render.call(this);
3249
+
3250
+ $selection.addClass('select2-selection--single');
3251
+
3252
+ $selection.html(
3253
+ '<span class="select2-selection__rendered"></span>' +
3254
+ '<span class="select2-selection__arrow" role="presentation">' +
3255
+ '<b role="presentation"></b>' +
3256
+ '</span>'
3257
+ );
3258
+
3259
+ return $selection;
3260
+ };
3261
+
3262
+ SingleSelection.prototype.bind = function (container, $container) {
3263
+ var self = this;
3264
+
3265
+ SingleSelection.__super__.bind.apply(this, arguments);
3266
+
3267
+ var id = container.id + '-container';
3268
+
3269
+ this.$selection.find('.select2-selection__rendered').attr('id', id);
3270
+ this.$selection.attr('aria-labelledby', id);
3271
+
3272
+ this.$selection.on('mousedown', function (evt) {
3273
+ // Only respond to left clicks
3274
+ if (evt.which !== 1) {
3275
+ return;
3276
+ }
3277
+
3278
+ self.trigger('toggle', {
3279
+ originalEvent: evt
3280
+ });
3281
+ });
3282
+
3283
+ this.$selection.on('focus', function (evt) {
3284
+ // User focuses on the container
3285
+ });
3286
+
3287
+ this.$selection.on('blur', function (evt) {
3288
+ // User exits the container
3289
+ });
3290
+
3291
+ container.on('focus', function (evt) {
3292
+ if (!container.isOpen()) {
3293
+ self.$selection.focus();
3294
+ }
3295
+ });
3296
+
3297
+ container.on('selection:update', function (params) {
3298
+ self.update(params.data);
3299
+ });
3300
+ };
3301
+
3302
+ SingleSelection.prototype.clear = function () {
3303
+ this.$selection.find('.select2-selection__rendered').empty();
3304
+ };
3305
+
3306
+ SingleSelection.prototype.display = function (data, container) {
3307
+ var template = this.options.get('templateSelection');
3308
+ var escapeMarkup = this.options.get('escapeMarkup');
3309
+
3310
+ return escapeMarkup(template(data, container));
3311
+ };
3312
+
3313
+ SingleSelection.prototype.selectionContainer = function () {
3314
+ return $('<span></span>');
3315
+ };
3316
+
3317
+ SingleSelection.prototype.update = function (data) {
3318
+ if (data.length === 0) {
3319
+ this.clear();
3320
+ return;
3321
+ }
3322
+
3323
+ var selection = data[0];
3324
+
3325
+ var $rendered = this.$selection.find('.select2-selection__rendered');
3326
+ var formatted = this.display(selection, $rendered);
3327
+
3328
+ $rendered.empty().append(formatted);
3329
+ $rendered.prop('title', selection.title || selection.text);
3330
+ };
3331
+
3332
+ return SingleSelection;
3333
+ });
3334
+
3335
+ S2.define('select2/selection/multiple',[
3336
+ 'jquery',
3337
+ './base',
3338
+ '../utils'
3339
+ ], function ($, BaseSelection, Utils) {
3340
+ function MultipleSelection ($element, options) {
3341
+ MultipleSelection.__super__.constructor.apply(this, arguments);
3342
+ }
3343
+
3344
+ Utils.Extend(MultipleSelection, BaseSelection);
3345
+
3346
+ MultipleSelection.prototype.render = function () {
3347
+ var $selection = MultipleSelection.__super__.render.call(this);
3348
+
3349
+ $selection.addClass('select2-selection--multiple');
3350
+
3351
+ $selection.html(
3352
+ '<ul class="select2-selection__rendered"></ul>'
3353
+ );
3354
+
3355
+ return $selection;
3356
+ };
3357
+
3358
+ MultipleSelection.prototype.bind = function (container, $container) {
3359
+ var self = this;
3360
+
3361
+ MultipleSelection.__super__.bind.apply(this, arguments);
3362
+
3363
+ this.$selection.on('click', function (evt) {
3364
+ self.trigger('toggle', {
3365
+ originalEvent: evt
3366
+ });
3367
+ });
3368
+
3369
+ this.$selection.on(
3370
+ 'click',
3371
+ '.select2-selection__choice__remove',
3372
+ function (evt) {
3373
+ // Ignore the event if it is disabled
3374
+ if (self.options.get('disabled')) {
3375
+ return;
3376
+ }
3377
+
3378
+ var $remove = $(this);
3379
+ var $selection = $remove.parent();
3380
+
3381
+ var data = $selection.data('data');
3382
+
3383
+ self.trigger('unselect', {
3384
+ originalEvent: evt,
3385
+ data: data
3386
+ });
3387
+ }
3388
+ );
3389
+ };
3390
+
3391
+ MultipleSelection.prototype.clear = function () {
3392
+ this.$selection.find('.select2-selection__rendered').empty();
3393
+ };
3394
+
3395
+ MultipleSelection.prototype.display = function (data, container) {
3396
+ var template = this.options.get('templateSelection');
3397
+ var escapeMarkup = this.options.get('escapeMarkup');
3398
+
3399
+ return escapeMarkup(template(data, container));
3400
+ };
3401
+
3402
+ MultipleSelection.prototype.selectionContainer = function () {
3403
+ var $container = $(
3404
+ '<li class="select2-selection__choice">' +
3405
+ '<span class="select2-selection__choice__remove" role="presentation">' +
3406
+ '&times;' +
3407
+ '</span>' +
3408
+ '</li>'
3409
+ );
3410
+
3411
+ return $container;
3412
+ };
3413
+
3414
+ MultipleSelection.prototype.update = function (data) {
3415
+ this.clear();
3416
+
3417
+ if (data.length === 0) {
3418
+ return;
3419
+ }
3420
+
3421
+ var $selections = [];
3422
+
3423
+ for (var d = 0; d < data.length; d++) {
3424
+ var selection = data[d];
3425
+
3426
+ var $selection = this.selectionContainer();
3427
+ var formatted = this.display(selection, $selection);
3428
+
3429
+ $selection.append(formatted);
3430
+ $selection.prop('title', selection.title || selection.text);
3431
+
3432
+ $selection.data('data', selection);
3433
+
3434
+ $selections.push($selection);
3435
+ }
3436
+
3437
+ var $rendered = this.$selection.find('.select2-selection__rendered');
3438
+
3439
+ Utils.appendMany($rendered, $selections);
3440
+ };
3441
+
3442
+ return MultipleSelection;
3443
+ });
3444
+
3445
+ S2.define('select2/selection/placeholder',[
3446
+ '../utils'
3447
+ ], function (Utils) {
3448
+ function Placeholder (decorated, $element, options) {
3449
+ this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
3450
+
3451
+ decorated.call(this, $element, options);
3452
+ }
3453
+
3454
+ Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
3455
+ if (typeof placeholder === 'string') {
3456
+ placeholder = {
3457
+ id: '',
3458
+ text: placeholder
3459
+ };
3460
+ }
3461
+
3462
+ return placeholder;
3463
+ };
3464
+
3465
+ Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
3466
+ var $placeholder = this.selectionContainer();
3467
+
3468
+ $placeholder.html(this.display(placeholder));
3469
+ $placeholder.addClass('select2-selection__placeholder')
3470
+ .removeClass('select2-selection__choice');
3471
+
3472
+ return $placeholder;
3473
+ };
3474
+
3475
+ Placeholder.prototype.update = function (decorated, data) {
3476
+ var singlePlaceholder = (
3477
+ data.length == 1 && data[0].id != this.placeholder.id
3478
+ );
3479
+ var multipleSelections = data.length > 1;
3480
+
3481
+ if (multipleSelections || singlePlaceholder) {
3482
+ return decorated.call(this, data);
3483
+ }
3484
+
3485
+ this.clear();
3486
+
3487
+ var $placeholder = this.createPlaceholder(this.placeholder);
3488
+
3489
+ this.$selection.find('.select2-selection__rendered').append($placeholder);
3490
+ };
3491
+
3492
+ return Placeholder;
3493
+ });
3494
+
3495
+ S2.define('select2/selection/allowClear',[
3496
+ 'jquery',
3497
+ '../keys'
3498
+ ], function ($, KEYS) {
3499
+ function AllowClear () { }
3500
+
3501
+ AllowClear.prototype.bind = function (decorated, container, $container) {
3502
+ var self = this;
3503
+
3504
+ decorated.call(this, container, $container);
3505
+
3506
+ if (this.placeholder == null) {
3507
+ if (this.options.get('debug') && window.console && console.error) {
3508
+ console.error(
3509
+ 'Select2: The `allowClear` option should be used in combination ' +
3510
+ 'with the `placeholder` option.'
3511
+ );
3512
+ }
3513
+ }
3514
+
3515
+ this.$selection.on('mousedown', '.select2-selection__clear',
3516
+ function (evt) {
3517
+ self._handleClear(evt);
3518
+ });
3519
+
3520
+ container.on('keypress', function (evt) {
3521
+ self._handleKeyboardClear(evt, container);
3522
+ });
3523
+ };
3524
+
3525
+ AllowClear.prototype._handleClear = function (_, evt) {
3526
+ // Ignore the event if it is disabled
3527
+ if (this.options.get('disabled')) {
3528
+ return;
3529
+ }
3530
+
3531
+ var $clear = this.$selection.find('.select2-selection__clear');
3532
+
3533
+ // Ignore the event if nothing has been selected
3534
+ if ($clear.length === 0) {
3535
+ return;
3536
+ }
3537
+
3538
+ evt.stopPropagation();
3539
+
3540
+ var data = $clear.data('data');
3541
+
3542
+ for (var d = 0; d < data.length; d++) {
3543
+ var unselectData = {
3544
+ data: data[d]
3545
+ };
3546
+
3547
+ // Trigger the `unselect` event, so people can prevent it from being
3548
+ // cleared.
3549
+ this.trigger('unselect', unselectData);
3550
+
3551
+ // If the event was prevented, don't clear it out.
3552
+ if (unselectData.prevented) {
3553
+ return;
3554
+ }
3555
+ }
3556
+
3557
+ this.$element.val(this.placeholder.id).trigger('change');
3558
+
3559
+ this.trigger('toggle', {});
3560
+ };
3561
+
3562
+ AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
3563
+ if (container.isOpen()) {
3564
+ return;
3565
+ }
3566
+
3567
+ if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
3568
+ this._handleClear(evt);
3569
+ }
3570
+ };
3571
+
3572
+ AllowClear.prototype.update = function (decorated, data) {
3573
+ decorated.call(this, data);
3574
+
3575
+ if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
3576
+ data.length === 0) {
3577
+ return;
3578
+ }
3579
+
3580
+ var $remove = $(
3581
+ '<span class="select2-selection__clear">' +
3582
+ '&times;' +
3583
+ '</span>'
3584
+ );
3585
+ $remove.data('data', data);
3586
+
3587
+ this.$selection.find('.select2-selection__rendered').prepend($remove);
3588
+ };
3589
+
3590
+ return AllowClear;
3591
+ });
3592
+
3593
+ S2.define('select2/selection/search',[
3594
+ 'jquery',
3595
+ '../utils',
3596
+ '../keys'
3597
+ ], function ($, Utils, KEYS) {
3598
+ function Search (decorated, $element, options) {
3599
+ decorated.call(this, $element, options);
3600
+ }
3601
+
3602
+ Search.prototype.render = function (decorated) {
3603
+ var $search = $(
3604
+ '<li class="select2-search select2-search--inline">' +
3605
+ '<input class="select2-search__field" type="search" tabindex="-1"' +
3606
+ ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
3607
+ ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
3608
+ '</li>'
3609
+ );
3610
+
3611
+ this.$searchContainer = $search;
3612
+ this.$search = $search.find('input');
3613
+
3614
+ var $rendered = decorated.call(this);
3615
+
3616
+ this._transferTabIndex();
3617
+
3618
+ return $rendered;
3619
+ };
3620
+
3621
+ Search.prototype.bind = function (decorated, container, $container) {
3622
+ var self = this;
3623
+
3624
+ decorated.call(this, container, $container);
3625
+
3626
+ container.on('open', function () {
3627
+ self.$search.trigger('focus');
3628
+ });
3629
+
3630
+ container.on('close', function () {
3631
+ self.$search.val('');
3632
+ self.$search.removeAttr('aria-activedescendant');
3633
+ self.$search.trigger('focus');
3634
+ });
3635
+
3636
+ container.on('enable', function () {
3637
+ self.$search.prop('disabled', false);
3638
+
3639
+ self._transferTabIndex();
3640
+ });
3641
+
3642
+ container.on('disable', function () {
3643
+ self.$search.prop('disabled', true);
3644
+ });
3645
+
3646
+ container.on('focus', function (evt) {
3647
+ self.$search.trigger('focus');
3648
+ });
3649
+
3650
+ container.on('results:focus', function (params) {
3651
+ self.$search.attr('aria-activedescendant', params.id);
3652
+ });
3653
+
3654
+ this.$selection.on('focusin', '.select2-search--inline', function (evt) {
3655
+ self.trigger('focus', evt);
3656
+ });
3657
+
3658
+ this.$selection.on('focusout', '.select2-search--inline', function (evt) {
3659
+ self._handleBlur(evt);
3660
+ });
3661
+
3662
+ this.$selection.on('keydown', '.select2-search--inline', function (evt) {
3663
+ evt.stopPropagation();
3664
+
3665
+ self.trigger('keypress', evt);
3666
+
3667
+ self._keyUpPrevented = evt.isDefaultPrevented();
3668
+
3669
+ var key = evt.which;
3670
+
3671
+ if (key === KEYS.BACKSPACE && self.$search.val() === '') {
3672
+ var $previousChoice = self.$searchContainer
3673
+ .prev('.select2-selection__choice');
3674
+
3675
+ if ($previousChoice.length > 0) {
3676
+ var item = $previousChoice.data('data');
3677
+
3678
+ self.searchRemoveChoice(item);
3679
+
3680
+ evt.preventDefault();
3681
+ }
3682
+ }
3683
+ });
3684
+
3685
+ // Try to detect the IE version should the `documentMode` property that
3686
+ // is stored on the document. This is only implemented in IE and is
3687
+ // slightly cleaner than doing a user agent check.
3688
+ // This property is not available in Edge, but Edge also doesn't have
3689
+ // this bug.
3690
+ var msie = document.documentMode;
3691
+ var disableInputEvents = msie && msie <= 11;
3692
+
3693
+ // Workaround for browsers which do not support the `input` event
3694
+ // This will prevent double-triggering of events for browsers which support
3695
+ // both the `keyup` and `input` events.
3696
+ this.$selection.on(
3697
+ 'input.searchcheck',
3698
+ '.select2-search--inline',
3699
+ function (evt) {
3700
+ // IE will trigger the `input` event when a placeholder is used on a
3701
+ // search box. To get around this issue, we are forced to ignore all
3702
+ // `input` events in IE and keep using `keyup`.
3703
+ if (disableInputEvents) {
3704
+ self.$selection.off('input.search input.searchcheck');
3705
+ return;
3706
+ }
3707
+
3708
+ // Unbind the duplicated `keyup` event
3709
+ self.$selection.off('keyup.search');
3710
+ }
3711
+ );
3712
+
3713
+ this.$selection.on(
3714
+ 'keyup.search input.search',
3715
+ '.select2-search--inline',
3716
+ function (evt) {
3717
+ // IE will trigger the `input` event when a placeholder is used on a
3718
+ // search box. To get around this issue, we are forced to ignore all
3719
+ // `input` events in IE and keep using `keyup`.
3720
+ if (disableInputEvents && evt.type === 'input') {
3721
+ self.$selection.off('input.search input.searchcheck');
3722
+ return;
3723
+ }
3724
+
3725
+ var key = evt.which;
3726
+
3727
+ // We can freely ignore events from modifier keys
3728
+ if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
3729
+ return;
3730
+ }
3731
+
3732
+ // Tabbing will be handled during the `keydown` phase
3733
+ if (key == KEYS.TAB) {
3734
+ return;
3735
+ }
3736
+
3737
+ self.handleSearch(evt);
3738
+ }
3739
+ );
3740
+ };
3741
+
3742
+ /**
3743
+ * This method will transfer the tabindex attribute from the rendered
3744
+ * selection to the search box. This allows for the search box to be used as
3745
+ * the primary focus instead of the selection container.
3746
+ *
3747
+ * @private
3748
+ */
3749
+ Search.prototype._transferTabIndex = function (decorated) {
3750
+ this.$search.attr('tabindex', this.$selection.attr('tabindex'));
3751
+ this.$selection.attr('tabindex', '-1');
3752
+ };
3753
+
3754
+ Search.prototype.createPlaceholder = function (decorated, placeholder) {
3755
+ this.$search.attr('placeholder', placeholder.text);
3756
+ };
3757
+
3758
+ Search.prototype.update = function (decorated, data) {
3759
+ var searchHadFocus = this.$search[0] == document.activeElement;
3760
+
3761
+ this.$search.attr('placeholder', '');
3762
+
3763
+ decorated.call(this, data);
3764
+
3765
+ this.$selection.find('.select2-selection__rendered')
3766
+ .append(this.$searchContainer);
3767
+
3768
+ this.resizeSearch();
3769
+ if (searchHadFocus) {
3770
+ this.$search.focus();
3771
+ }
3772
+ };
3773
+
3774
+ Search.prototype.handleSearch = function () {
3775
+ this.resizeSearch();
3776
+
3777
+ if (!this._keyUpPrevented) {
3778
+ var input = this.$search.val();
3779
+
3780
+ this.trigger('query', {
3781
+ term: input
3782
+ });
3783
+ }
3784
+
3785
+ this._keyUpPrevented = false;
3786
+ };
3787
+
3788
+ Search.prototype.searchRemoveChoice = function (decorated, item) {
3789
+ this.trigger('unselect', {
3790
+ data: item
3791
+ });
3792
+
3793
+ this.$search.val(item.text);
3794
+ this.handleSearch();
3795
+ };
3796
+
3797
+ Search.prototype.resizeSearch = function () {
3798
+ this.$search.css('width', '25px');
3799
+
3800
+ var width = '';
3801
+
3802
+ if (this.$search.attr('placeholder') !== '') {
3803
+ width = this.$selection.find('.select2-selection__rendered').innerWidth();
3804
+ } else {
3805
+ var minimumWidth = this.$search.val().length + 1;
3806
+
3807
+ width = (minimumWidth * 0.75) + 'em';
3808
+ }
3809
+
3810
+ this.$search.css('width', width);
3811
+ };
3812
+
3813
+ return Search;
3814
+ });
3815
+
3816
+ S2.define('select2/selection/eventRelay',[
3817
+ 'jquery'
3818
+ ], function ($) {
3819
+ function EventRelay () { }
3820
+
3821
+ EventRelay.prototype.bind = function (decorated, container, $container) {
3822
+ var self = this;
3823
+ var relayEvents = [
3824
+ 'open', 'opening',
3825
+ 'close', 'closing',
3826
+ 'select', 'selecting',
3827
+ 'unselect', 'unselecting'
3828
+ ];
3829
+
3830
+ var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
3831
+
3832
+ decorated.call(this, container, $container);
3833
+
3834
+ container.on('*', function (name, params) {
3835
+ // Ignore events that should not be relayed
3836
+ if ($.inArray(name, relayEvents) === -1) {
3837
+ return;
3838
+ }
3839
+
3840
+ // The parameters should always be an object
3841
+ params = params || {};
3842
+
3843
+ // Generate the jQuery event for the Select2 event
3844
+ var evt = $.Event('select2:' + name, {
3845
+ params: params
3846
+ });
3847
+
3848
+ self.$element.trigger(evt);
3849
+
3850
+ // Only handle preventable events if it was one
3851
+ if ($.inArray(name, preventableEvents) === -1) {
3852
+ return;
3853
+ }
3854
+
3855
+ params.prevented = evt.isDefaultPrevented();
3856
+ });
3857
+ };
3858
+
3859
+ return EventRelay;
3860
+ });
3861
+
3862
+ S2.define('select2/translation',[
3863
+ 'jquery',
3864
+ 'require'
3865
+ ], function ($, require) {
3866
+ function Translation (dict) {
3867
+ this.dict = dict || {};
3868
+ }
3869
+
3870
+ Translation.prototype.all = function () {
3871
+ return this.dict;
3872
+ };
3873
+
3874
+ Translation.prototype.get = function (key) {
3875
+ return this.dict[key];
3876
+ };
3877
+
3878
+ Translation.prototype.extend = function (translation) {
3879
+ this.dict = $.extend({}, translation.all(), this.dict);
3880
+ };
3881
+
3882
+ // Static functions
3883
+
3884
+ Translation._cache = {};
3885
+
3886
+ Translation.loadPath = function (path) {
3887
+ if (!(path in Translation._cache)) {
3888
+ var translations = require(path);
3889
+
3890
+ Translation._cache[path] = translations;
3891
+ }
3892
+
3893
+ return new Translation(Translation._cache[path]);
3894
+ };
3895
+
3896
+ return Translation;
3897
+ });
3898
+
3899
+ S2.define('select2/diacritics',[
3900
+
3901
+ ], function () {
3902
+ var diacritics = {
3903
+ '\u24B6': 'A',
3904
+ '\uFF21': 'A',
3905
+ '\u00C0': 'A',
3906
+ '\u00C1': 'A',
3907
+ '\u00C2': 'A',
3908
+ '\u1EA6': 'A',
3909
+ '\u1EA4': 'A',
3910
+ '\u1EAA': 'A',
3911
+ '\u1EA8': 'A',
3912
+ '\u00C3': 'A',
3913
+ '\u0100': 'A',
3914
+ '\u0102': 'A',
3915
+ '\u1EB0': 'A',
3916
+ '\u1EAE': 'A',
3917
+ '\u1EB4': 'A',
3918
+ '\u1EB2': 'A',
3919
+ '\u0226': 'A',
3920
+ '\u01E0': 'A',
3921
+ '\u00C4': 'A',
3922
+ '\u01DE': 'A',
3923
+ '\u1EA2': 'A',
3924
+ '\u00C5': 'A',
3925
+ '\u01FA': 'A',
3926
+ '\u01CD': 'A',
3927
+ '\u0200': 'A',
3928
+ '\u0202': 'A',
3929
+ '\u1EA0': 'A',
3930
+ '\u1EAC': 'A',
3931
+ '\u1EB6': 'A',
3932
+ '\u1E00': 'A',
3933
+ '\u0104': 'A',
3934
+ '\u023A': 'A',
3935
+ '\u2C6F': 'A',
3936
+ '\uA732': 'AA',
3937
+ '\u00C6': 'AE',
3938
+ '\u01FC': 'AE',
3939
+ '\u01E2': 'AE',
3940
+ '\uA734': 'AO',
3941
+ '\uA736': 'AU',
3942
+ '\uA738': 'AV',
3943
+ '\uA73A': 'AV',
3944
+ '\uA73C': 'AY',
3945
+ '\u24B7': 'B',
3946
+ '\uFF22': 'B',
3947
+ '\u1E02': 'B',
3948
+ '\u1E04': 'B',
3949
+ '\u1E06': 'B',
3950
+ '\u0243': 'B',
3951
+ '\u0182': 'B',
3952
+ '\u0181': 'B',
3953
+ '\u24B8': 'C',
3954
+ '\uFF23': 'C',
3955
+ '\u0106': 'C',
3956
+ '\u0108': 'C',
3957
+ '\u010A': 'C',
3958
+ '\u010C': 'C',
3959
+ '\u00C7': 'C',
3960
+ '\u1E08': 'C',
3961
+ '\u0187': 'C',
3962
+ '\u023B': 'C',
3963
+ '\uA73E': 'C',
3964
+ '\u24B9': 'D',
3965
+ '\uFF24': 'D',
3966
+ '\u1E0A': 'D',
3967
+ '\u010E': 'D',
3968
+ '\u1E0C': 'D',
3969
+ '\u1E10': 'D',
3970
+ '\u1E12': 'D',
3971
+ '\u1E0E': 'D',
3972
+ '\u0110': 'D',
3973
+ '\u018B': 'D',
3974
+ '\u018A': 'D',
3975
+ '\u0189': 'D',
3976
+ '\uA779': 'D',
3977
+ '\u01F1': 'DZ',
3978
+ '\u01C4': 'DZ',
3979
+ '\u01F2': 'Dz',
3980
+ '\u01C5': 'Dz',
3981
+ '\u24BA': 'E',
3982
+ '\uFF25': 'E',
3983
+ '\u00C8': 'E',
3984
+ '\u00C9': 'E',
3985
+ '\u00CA': 'E',
3986
+ '\u1EC0': 'E',
3987
+ '\u1EBE': 'E',
3988
+ '\u1EC4': 'E',
3989
+ '\u1EC2': 'E',
3990
+ '\u1EBC': 'E',
3991
+ '\u0112': 'E',
3992
+ '\u1E14': 'E',
3993
+ '\u1E16': 'E',
3994
+ '\u0114': 'E',
3995
+ '\u0116': 'E',
3996
+ '\u00CB': 'E',
3997
+ '\u1EBA': 'E',
3998
+ '\u011A': 'E',
3999
+ '\u0204': 'E',
4000
+ '\u0206': 'E',
4001
+ '\u1EB8': 'E',
4002
+ '\u1EC6': 'E',
4003
+ '\u0228': 'E',
4004
+ '\u1E1C': 'E',
4005
+ '\u0118': 'E',
4006
+ '\u1E18': 'E',
4007
+ '\u1E1A': 'E',
4008
+ '\u0190': 'E',
4009
+ '\u018E': 'E',
4010
+ '\u24BB': 'F',
4011
+ '\uFF26': 'F',
4012
+ '\u1E1E': 'F',
4013
+ '\u0191': 'F',
4014
+ '\uA77B': 'F',
4015
+ '\u24BC': 'G',
4016
+ '\uFF27': 'G',
4017
+ '\u01F4': 'G',
4018
+ '\u011C': 'G',
4019
+ '\u1E20': 'G',
4020
+ '\u011E': 'G',
4021
+ '\u0120': 'G',
4022
+ '\u01E6': 'G',
4023
+ '\u0122': 'G',
4024
+ '\u01E4': 'G',
4025
+ '\u0193': 'G',
4026
+ '\uA7A0': 'G',
4027
+ '\uA77D': 'G',
4028
+ '\uA77E': 'G',
4029
+ '\u24BD': 'H',
4030
+ '\uFF28': 'H',
4031
+ '\u0124': 'H',
4032
+ '\u1E22': 'H',
4033
+ '\u1E26': 'H',
4034
+ '\u021E': 'H',
4035
+ '\u1E24': 'H',
4036
+ '\u1E28': 'H',
4037
+ '\u1E2A': 'H',
4038
+ '\u0126': 'H',
4039
+ '\u2C67': 'H',
4040
+ '\u2C75': 'H',
4041
+ '\uA78D': 'H',
4042
+ '\u24BE': 'I',
4043
+ '\uFF29': 'I',
4044
+ '\u00CC': 'I',
4045
+ '\u00CD': 'I',
4046
+ '\u00CE': 'I',
4047
+ '\u0128': 'I',
4048
+ '\u012A': 'I',
4049
+ '\u012C': 'I',
4050
+ '\u0130': 'I',
4051
+ '\u00CF': 'I',
4052
+ '\u1E2E': 'I',
4053
+ '\u1EC8': 'I',
4054
+ '\u01CF': 'I',
4055
+ '\u0208': 'I',
4056
+ '\u020A': 'I',
4057
+ '\u1ECA': 'I',
4058
+ '\u012E': 'I',
4059
+ '\u1E2C': 'I',
4060
+ '\u0197': 'I',
4061
+ '\u24BF': 'J',
4062
+ '\uFF2A': 'J',
4063
+ '\u0134': 'J',
4064
+ '\u0248': 'J',
4065
+ '\u24C0': 'K',
4066
+ '\uFF2B': 'K',
4067
+ '\u1E30': 'K',
4068
+ '\u01E8': 'K',
4069
+ '\u1E32': 'K',
4070
+ '\u0136': 'K',
4071
+ '\u1E34': 'K',
4072
+ '\u0198': 'K',
4073
+ '\u2C69': 'K',
4074
+ '\uA740': 'K',
4075
+ '\uA742': 'K',
4076
+ '\uA744': 'K',
4077
+ '\uA7A2': 'K',
4078
+ '\u24C1': 'L',
4079
+ '\uFF2C': 'L',
4080
+ '\u013F': 'L',
4081
+ '\u0139': 'L',
4082
+ '\u013D': 'L',
4083
+ '\u1E36': 'L',
4084
+ '\u1E38': 'L',
4085
+ '\u013B': 'L',
4086
+ '\u1E3C': 'L',
4087
+ '\u1E3A': 'L',
4088
+ '\u0141': 'L',
4089
+ '\u023D': 'L',
4090
+ '\u2C62': 'L',
4091
+ '\u2C60': 'L',
4092
+ '\uA748': 'L',
4093
+ '\uA746': 'L',
4094
+ '\uA780': 'L',
4095
+ '\u01C7': 'LJ',
4096
+ '\u01C8': 'Lj',
4097
+ '\u24C2': 'M',
4098
+ '\uFF2D': 'M',
4099
+ '\u1E3E': 'M',
4100
+ '\u1E40': 'M',
4101
+ '\u1E42': 'M',
4102
+ '\u2C6E': 'M',
4103
+ '\u019C': 'M',
4104
+ '\u24C3': 'N',
4105
+ '\uFF2E': 'N',
4106
+ '\u01F8': 'N',
4107
+ '\u0143': 'N',
4108
+ '\u00D1': 'N',
4109
+ '\u1E44': 'N',
4110
+ '\u0147': 'N',
4111
+ '\u1E46': 'N',
4112
+ '\u0145': 'N',
4113
+ '\u1E4A': 'N',
4114
+ '\u1E48': 'N',
4115
+ '\u0220': 'N',
4116
+ '\u019D': 'N',
4117
+ '\uA790': 'N',
4118
+ '\uA7A4': 'N',
4119
+ '\u01CA': 'NJ',
4120
+ '\u01CB': 'Nj',
4121
+ '\u24C4': 'O',
4122
+ '\uFF2F': 'O',
4123
+ '\u00D2': 'O',
4124
+ '\u00D3': 'O',
4125
+ '\u00D4': 'O',
4126
+ '\u1ED2': 'O',
4127
+ '\u1ED0': 'O',
4128
+ '\u1ED6': 'O',
4129
+ '\u1ED4': 'O',
4130
+ '\u00D5': 'O',
4131
+ '\u1E4C': 'O',
4132
+ '\u022C': 'O',
4133
+ '\u1E4E': 'O',
4134
+ '\u014C': 'O',
4135
+ '\u1E50': 'O',
4136
+ '\u1E52': 'O',
4137
+ '\u014E': 'O',
4138
+ '\u022E': 'O',
4139
+ '\u0230': 'O',
4140
+ '\u00D6': 'O',
4141
+ '\u022A': 'O',
4142
+ '\u1ECE': 'O',
4143
+ '\u0150': 'O',
4144
+ '\u01D1': 'O',
4145
+ '\u020C': 'O',
4146
+ '\u020E': 'O',
4147
+ '\u01A0': 'O',
4148
+ '\u1EDC': 'O',
4149
+ '\u1EDA': 'O',
4150
+ '\u1EE0': 'O',
4151
+ '\u1EDE': 'O',
4152
+ '\u1EE2': 'O',
4153
+ '\u1ECC': 'O',
4154
+ '\u1ED8': 'O',
4155
+ '\u01EA': 'O',
4156
+ '\u01EC': 'O',
4157
+ '\u00D8': 'O',
4158
+ '\u01FE': 'O',
4159
+ '\u0186': 'O',
4160
+ '\u019F': 'O',
4161
+ '\uA74A': 'O',
4162
+ '\uA74C': 'O',
4163
+ '\u01A2': 'OI',
4164
+ '\uA74E': 'OO',
4165
+ '\u0222': 'OU',
4166
+ '\u24C5': 'P',
4167
+ '\uFF30': 'P',
4168
+ '\u1E54': 'P',
4169
+ '\u1E56': 'P',
4170
+ '\u01A4': 'P',
4171
+ '\u2C63': 'P',
4172
+ '\uA750': 'P',
4173
+ '\uA752': 'P',
4174
+ '\uA754': 'P',
4175
+ '\u24C6': 'Q',
4176
+ '\uFF31': 'Q',
4177
+ '\uA756': 'Q',
4178
+ '\uA758': 'Q',
4179
+ '\u024A': 'Q',
4180
+ '\u24C7': 'R',
4181
+ '\uFF32': 'R',
4182
+ '\u0154': 'R',
4183
+ '\u1E58': 'R',
4184
+ '\u0158': 'R',
4185
+ '\u0210': 'R',
4186
+ '\u0212': 'R',
4187
+ '\u1E5A': 'R',
4188
+ '\u1E5C': 'R',
4189
+ '\u0156': 'R',
4190
+ '\u1E5E': 'R',
4191
+ '\u024C': 'R',
4192
+ '\u2C64': 'R',
4193
+ '\uA75A': 'R',
4194
+ '\uA7A6': 'R',
4195
+ '\uA782': 'R',
4196
+ '\u24C8': 'S',
4197
+ '\uFF33': 'S',
4198
+ '\u1E9E': 'S',
4199
+ '\u015A': 'S',
4200
+ '\u1E64': 'S',
4201
+ '\u015C': 'S',
4202
+ '\u1E60': 'S',
4203
+ '\u0160': 'S',
4204
+ '\u1E66': 'S',
4205
+ '\u1E62': 'S',
4206
+ '\u1E68': 'S',
4207
+ '\u0218': 'S',
4208
+ '\u015E': 'S',
4209
+ '\u2C7E': 'S',
4210
+ '\uA7A8': 'S',
4211
+ '\uA784': 'S',
4212
+ '\u24C9': 'T',
4213
+ '\uFF34': 'T',
4214
+ '\u1E6A': 'T',
4215
+ '\u0164': 'T',
4216
+ '\u1E6C': 'T',
4217
+ '\u021A': 'T',
4218
+ '\u0162': 'T',
4219
+ '\u1E70': 'T',
4220
+ '\u1E6E': 'T',
4221
+ '\u0166': 'T',
4222
+ '\u01AC': 'T',
4223
+ '\u01AE': 'T',
4224
+ '\u023E': 'T',
4225
+ '\uA786': 'T',
4226
+ '\uA728': 'TZ',
4227
+ '\u24CA': 'U',
4228
+ '\uFF35': 'U',
4229
+ '\u00D9': 'U',
4230
+ '\u00DA': 'U',
4231
+ '\u00DB': 'U',
4232
+ '\u0168': 'U',
4233
+ '\u1E78': 'U',
4234
+ '\u016A': 'U',
4235
+ '\u1E7A': 'U',
4236
+ '\u016C': 'U',
4237
+ '\u00DC': 'U',
4238
+ '\u01DB': 'U',
4239
+ '\u01D7': 'U',
4240
+ '\u01D5': 'U',
4241
+ '\u01D9': 'U',
4242
+ '\u1EE6': 'U',
4243
+ '\u016E': 'U',
4244
+ '\u0170': 'U',
4245
+ '\u01D3': 'U',
4246
+ '\u0214': 'U',
4247
+ '\u0216': 'U',
4248
+ '\u01AF': 'U',
4249
+ '\u1EEA': 'U',
4250
+ '\u1EE8': 'U',
4251
+ '\u1EEE': 'U',
4252
+ '\u1EEC': 'U',
4253
+ '\u1EF0': 'U',
4254
+ '\u1EE4': 'U',
4255
+ '\u1E72': 'U',
4256
+ '\u0172': 'U',
4257
+ '\u1E76': 'U',
4258
+ '\u1E74': 'U',
4259
+ '\u0244': 'U',
4260
+ '\u24CB': 'V',
4261
+ '\uFF36': 'V',
4262
+ '\u1E7C': 'V',
4263
+ '\u1E7E': 'V',
4264
+ '\u01B2': 'V',
4265
+ '\uA75E': 'V',
4266
+ '\u0245': 'V',
4267
+ '\uA760': 'VY',
4268
+ '\u24CC': 'W',
4269
+ '\uFF37': 'W',
4270
+ '\u1E80': 'W',
4271
+ '\u1E82': 'W',
4272
+ '\u0174': 'W',
4273
+ '\u1E86': 'W',
4274
+ '\u1E84': 'W',
4275
+ '\u1E88': 'W',
4276
+ '\u2C72': 'W',
4277
+ '\u24CD': 'X',
4278
+ '\uFF38': 'X',
4279
+ '\u1E8A': 'X',
4280
+ '\u1E8C': 'X',
4281
+ '\u24CE': 'Y',
4282
+ '\uFF39': 'Y',
4283
+ '\u1EF2': 'Y',
4284
+ '\u00DD': 'Y',
4285
+ '\u0176': 'Y',
4286
+ '\u1EF8': 'Y',
4287
+ '\u0232': 'Y',
4288
+ '\u1E8E': 'Y',
4289
+ '\u0178': 'Y',
4290
+ '\u1EF6': 'Y',
4291
+ '\u1EF4': 'Y',
4292
+ '\u01B3': 'Y',
4293
+ '\u024E': 'Y',
4294
+ '\u1EFE': 'Y',
4295
+ '\u24CF': 'Z',
4296
+ '\uFF3A': 'Z',
4297
+ '\u0179': 'Z',
4298
+ '\u1E90': 'Z',
4299
+ '\u017B': 'Z',
4300
+ '\u017D': 'Z',
4301
+ '\u1E92': 'Z',
4302
+ '\u1E94': 'Z',
4303
+ '\u01B5': 'Z',
4304
+ '\u0224': 'Z',
4305
+ '\u2C7F': 'Z',
4306
+ '\u2C6B': 'Z',
4307
+ '\uA762': 'Z',
4308
+ '\u24D0': 'a',
4309
+ '\uFF41': 'a',
4310
+ '\u1E9A': 'a',
4311
+ '\u00E0': 'a',
4312
+ '\u00E1': 'a',
4313
+ '\u00E2': 'a',
4314
+ '\u1EA7': 'a',
4315
+ '\u1EA5': 'a',
4316
+ '\u1EAB': 'a',
4317
+ '\u1EA9': 'a',
4318
+ '\u00E3': 'a',
4319
+ '\u0101': 'a',
4320
+ '\u0103': 'a',
4321
+ '\u1EB1': 'a',
4322
+ '\u1EAF': 'a',
4323
+ '\u1EB5': 'a',
4324
+ '\u1EB3': 'a',
4325
+ '\u0227': 'a',
4326
+ '\u01E1': 'a',
4327
+ '\u00E4': 'a',
4328
+ '\u01DF': 'a',
4329
+ '\u1EA3': 'a',
4330
+ '\u00E5': 'a',
4331
+ '\u01FB': 'a',
4332
+ '\u01CE': 'a',
4333
+ '\u0201': 'a',
4334
+ '\u0203': 'a',
4335
+ '\u1EA1': 'a',
4336
+ '\u1EAD': 'a',
4337
+ '\u1EB7': 'a',
4338
+ '\u1E01': 'a',
4339
+ '\u0105': 'a',
4340
+ '\u2C65': 'a',
4341
+ '\u0250': 'a',
4342
+ '\uA733': 'aa',
4343
+ '\u00E6': 'ae',
4344
+ '\u01FD': 'ae',
4345
+ '\u01E3': 'ae',
4346
+ '\uA735': 'ao',
4347
+ '\uA737': 'au',
4348
+ '\uA739': 'av',
4349
+ '\uA73B': 'av',
4350
+ '\uA73D': 'ay',
4351
+ '\u24D1': 'b',
4352
+ '\uFF42': 'b',
4353
+ '\u1E03': 'b',
4354
+ '\u1E05': 'b',
4355
+ '\u1E07': 'b',
4356
+ '\u0180': 'b',
4357
+ '\u0183': 'b',
4358
+ '\u0253': 'b',
4359
+ '\u24D2': 'c',
4360
+ '\uFF43': 'c',
4361
+ '\u0107': 'c',
4362
+ '\u0109': 'c',
4363
+ '\u010B': 'c',
4364
+ '\u010D': 'c',
4365
+ '\u00E7': 'c',
4366
+ '\u1E09': 'c',
4367
+ '\u0188': 'c',
4368
+ '\u023C': 'c',
4369
+ '\uA73F': 'c',
4370
+ '\u2184': 'c',
4371
+ '\u24D3': 'd',
4372
+ '\uFF44': 'd',
4373
+ '\u1E0B': 'd',
4374
+ '\u010F': 'd',
4375
+ '\u1E0D': 'd',
4376
+ '\u1E11': 'd',
4377
+ '\u1E13': 'd',
4378
+ '\u1E0F': 'd',
4379
+ '\u0111': 'd',
4380
+ '\u018C': 'd',
4381
+ '\u0256': 'd',
4382
+ '\u0257': 'd',
4383
+ '\uA77A': 'd',
4384
+ '\u01F3': 'dz',
4385
+ '\u01C6': 'dz',
4386
+ '\u24D4': 'e',
4387
+ '\uFF45': 'e',
4388
+ '\u00E8': 'e',
4389
+ '\u00E9': 'e',
4390
+ '\u00EA': 'e',
4391
+ '\u1EC1': 'e',
4392
+ '\u1EBF': 'e',
4393
+ '\u1EC5': 'e',
4394
+ '\u1EC3': 'e',
4395
+ '\u1EBD': 'e',
4396
+ '\u0113': 'e',
4397
+ '\u1E15': 'e',
4398
+ '\u1E17': 'e',
4399
+ '\u0115': 'e',
4400
+ '\u0117': 'e',
4401
+ '\u00EB': 'e',
4402
+ '\u1EBB': 'e',
4403
+ '\u011B': 'e',
4404
+ '\u0205': 'e',
4405
+ '\u0207': 'e',
4406
+ '\u1EB9': 'e',
4407
+ '\u1EC7': 'e',
4408
+ '\u0229': 'e',
4409
+ '\u1E1D': 'e',
4410
+ '\u0119': 'e',
4411
+ '\u1E19': 'e',
4412
+ '\u1E1B': 'e',
4413
+ '\u0247': 'e',
4414
+ '\u025B': 'e',
4415
+ '\u01DD': 'e',
4416
+ '\u24D5': 'f',
4417
+ '\uFF46': 'f',
4418
+ '\u1E1F': 'f',
4419
+ '\u0192': 'f',
4420
+ '\uA77C': 'f',
4421
+ '\u24D6': 'g',
4422
+ '\uFF47': 'g',
4423
+ '\u01F5': 'g',
4424
+ '\u011D': 'g',
4425
+ '\u1E21': 'g',
4426
+ '\u011F': 'g',
4427
+ '\u0121': 'g',
4428
+ '\u01E7': 'g',
4429
+ '\u0123': 'g',
4430
+ '\u01E5': 'g',
4431
+ '\u0260': 'g',
4432
+ '\uA7A1': 'g',
4433
+ '\u1D79': 'g',
4434
+ '\uA77F': 'g',
4435
+ '\u24D7': 'h',
4436
+ '\uFF48': 'h',
4437
+ '\u0125': 'h',
4438
+ '\u1E23': 'h',
4439
+ '\u1E27': 'h',
4440
+ '\u021F': 'h',
4441
+ '\u1E25': 'h',
4442
+ '\u1E29': 'h',
4443
+ '\u1E2B': 'h',
4444
+ '\u1E96': 'h',
4445
+ '\u0127': 'h',
4446
+ '\u2C68': 'h',
4447
+ '\u2C76': 'h',
4448
+ '\u0265': 'h',
4449
+ '\u0195': 'hv',
4450
+ '\u24D8': 'i',
4451
+ '\uFF49': 'i',
4452
+ '\u00EC': 'i',
4453
+ '\u00ED': 'i',
4454
+ '\u00EE': 'i',
4455
+ '\u0129': 'i',
4456
+ '\u012B': 'i',
4457
+ '\u012D': 'i',
4458
+ '\u00EF': 'i',
4459
+ '\u1E2F': 'i',
4460
+ '\u1EC9': 'i',
4461
+ '\u01D0': 'i',
4462
+ '\u0209': 'i',
4463
+ '\u020B': 'i',
4464
+ '\u1ECB': 'i',
4465
+ '\u012F': 'i',
4466
+ '\u1E2D': 'i',
4467
+ '\u0268': 'i',
4468
+ '\u0131': 'i',
4469
+ '\u24D9': 'j',
4470
+ '\uFF4A': 'j',
4471
+ '\u0135': 'j',
4472
+ '\u01F0': 'j',
4473
+ '\u0249': 'j',
4474
+ '\u24DA': 'k',
4475
+ '\uFF4B': 'k',
4476
+ '\u1E31': 'k',
4477
+ '\u01E9': 'k',
4478
+ '\u1E33': 'k',
4479
+ '\u0137': 'k',
4480
+ '\u1E35': 'k',
4481
+ '\u0199': 'k',
4482
+ '\u2C6A': 'k',
4483
+ '\uA741': 'k',
4484
+ '\uA743': 'k',
4485
+ '\uA745': 'k',
4486
+ '\uA7A3': 'k',
4487
+ '\u24DB': 'l',
4488
+ '\uFF4C': 'l',
4489
+ '\u0140': 'l',
4490
+ '\u013A': 'l',
4491
+ '\u013E': 'l',
4492
+ '\u1E37': 'l',
4493
+ '\u1E39': 'l',
4494
+ '\u013C': 'l',
4495
+ '\u1E3D': 'l',
4496
+ '\u1E3B': 'l',
4497
+ '\u017F': 'l',
4498
+ '\u0142': 'l',
4499
+ '\u019A': 'l',
4500
+ '\u026B': 'l',
4501
+ '\u2C61': 'l',
4502
+ '\uA749': 'l',
4503
+ '\uA781': 'l',
4504
+ '\uA747': 'l',
4505
+ '\u01C9': 'lj',
4506
+ '\u24DC': 'm',
4507
+ '\uFF4D': 'm',
4508
+ '\u1E3F': 'm',
4509
+ '\u1E41': 'm',
4510
+ '\u1E43': 'm',
4511
+ '\u0271': 'm',
4512
+ '\u026F': 'm',
4513
+ '\u24DD': 'n',
4514
+ '\uFF4E': 'n',
4515
+ '\u01F9': 'n',
4516
+ '\u0144': 'n',
4517
+ '\u00F1': 'n',
4518
+ '\u1E45': 'n',
4519
+ '\u0148': 'n',
4520
+ '\u1E47': 'n',
4521
+ '\u0146': 'n',
4522
+ '\u1E4B': 'n',
4523
+ '\u1E49': 'n',
4524
+ '\u019E': 'n',
4525
+ '\u0272': 'n',
4526
+ '\u0149': 'n',
4527
+ '\uA791': 'n',
4528
+ '\uA7A5': 'n',
4529
+ '\u01CC': 'nj',
4530
+ '\u24DE': 'o',
4531
+ '\uFF4F': 'o',
4532
+ '\u00F2': 'o',
4533
+ '\u00F3': 'o',
4534
+ '\u00F4': 'o',
4535
+ '\u1ED3': 'o',
4536
+ '\u1ED1': 'o',
4537
+ '\u1ED7': 'o',
4538
+ '\u1ED5': 'o',
4539
+ '\u00F5': 'o',
4540
+ '\u1E4D': 'o',
4541
+ '\u022D': 'o',
4542
+ '\u1E4F': 'o',
4543
+ '\u014D': 'o',
4544
+ '\u1E51': 'o',
4545
+ '\u1E53': 'o',
4546
+ '\u014F': 'o',
4547
+ '\u022F': 'o',
4548
+ '\u0231': 'o',
4549
+ '\u00F6': 'o',
4550
+ '\u022B': 'o',
4551
+ '\u1ECF': 'o',
4552
+ '\u0151': 'o',
4553
+ '\u01D2': 'o',
4554
+ '\u020D': 'o',
4555
+ '\u020F': 'o',
4556
+ '\u01A1': 'o',
4557
+ '\u1EDD': 'o',
4558
+ '\u1EDB': 'o',
4559
+ '\u1EE1': 'o',
4560
+ '\u1EDF': 'o',
4561
+ '\u1EE3': 'o',
4562
+ '\u1ECD': 'o',
4563
+ '\u1ED9': 'o',
4564
+ '\u01EB': 'o',
4565
+ '\u01ED': 'o',
4566
+ '\u00F8': 'o',
4567
+ '\u01FF': 'o',
4568
+ '\u0254': 'o',
4569
+ '\uA74B': 'o',
4570
+ '\uA74D': 'o',
4571
+ '\u0275': 'o',
4572
+ '\u01A3': 'oi',
4573
+ '\u0223': 'ou',
4574
+ '\uA74F': 'oo',
4575
+ '\u24DF': 'p',
4576
+ '\uFF50': 'p',
4577
+ '\u1E55': 'p',
4578
+ '\u1E57': 'p',
4579
+ '\u01A5': 'p',
4580
+ '\u1D7D': 'p',
4581
+ '\uA751': 'p',
4582
+ '\uA753': 'p',
4583
+ '\uA755': 'p',
4584
+ '\u24E0': 'q',
4585
+ '\uFF51': 'q',
4586
+ '\u024B': 'q',
4587
+ '\uA757': 'q',
4588
+ '\uA759': 'q',
4589
+ '\u24E1': 'r',
4590
+ '\uFF52': 'r',
4591
+ '\u0155': 'r',
4592
+ '\u1E59': 'r',
4593
+ '\u0159': 'r',
4594
+ '\u0211': 'r',
4595
+ '\u0213': 'r',
4596
+ '\u1E5B': 'r',
4597
+ '\u1E5D': 'r',
4598
+ '\u0157': 'r',
4599
+ '\u1E5F': 'r',
4600
+ '\u024D': 'r',
4601
+ '\u027D': 'r',
4602
+ '\uA75B': 'r',
4603
+ '\uA7A7': 'r',
4604
+ '\uA783': 'r',
4605
+ '\u24E2': 's',
4606
+ '\uFF53': 's',
4607
+ '\u00DF': 's',
4608
+ '\u015B': 's',
4609
+ '\u1E65': 's',
4610
+ '\u015D': 's',
4611
+ '\u1E61': 's',
4612
+ '\u0161': 's',
4613
+ '\u1E67': 's',
4614
+ '\u1E63': 's',
4615
+ '\u1E69': 's',
4616
+ '\u0219': 's',
4617
+ '\u015F': 's',
4618
+ '\u023F': 's',
4619
+ '\uA7A9': 's',
4620
+ '\uA785': 's',
4621
+ '\u1E9B': 's',
4622
+ '\u24E3': 't',
4623
+ '\uFF54': 't',
4624
+ '\u1E6B': 't',
4625
+ '\u1E97': 't',
4626
+ '\u0165': 't',
4627
+ '\u1E6D': 't',
4628
+ '\u021B': 't',
4629
+ '\u0163': 't',
4630
+ '\u1E71': 't',
4631
+ '\u1E6F': 't',
4632
+ '\u0167': 't',
4633
+ '\u01AD': 't',
4634
+ '\u0288': 't',
4635
+ '\u2C66': 't',
4636
+ '\uA787': 't',
4637
+ '\uA729': 'tz',
4638
+ '\u24E4': 'u',
4639
+ '\uFF55': 'u',
4640
+ '\u00F9': 'u',
4641
+ '\u00FA': 'u',
4642
+ '\u00FB': 'u',
4643
+ '\u0169': 'u',
4644
+ '\u1E79': 'u',
4645
+ '\u016B': 'u',
4646
+ '\u1E7B': 'u',
4647
+ '\u016D': 'u',
4648
+ '\u00FC': 'u',
4649
+ '\u01DC': 'u',
4650
+ '\u01D8': 'u',
4651
+ '\u01D6': 'u',
4652
+ '\u01DA': 'u',
4653
+ '\u1EE7': 'u',
4654
+ '\u016F': 'u',
4655
+ '\u0171': 'u',
4656
+ '\u01D4': 'u',
4657
+ '\u0215': 'u',
4658
+ '\u0217': 'u',
4659
+ '\u01B0': 'u',
4660
+ '\u1EEB': 'u',
4661
+ '\u1EE9': 'u',
4662
+ '\u1EEF': 'u',
4663
+ '\u1EED': 'u',
4664
+ '\u1EF1': 'u',
4665
+ '\u1EE5': 'u',
4666
+ '\u1E73': 'u',
4667
+ '\u0173': 'u',
4668
+ '\u1E77': 'u',
4669
+ '\u1E75': 'u',
4670
+ '\u0289': 'u',
4671
+ '\u24E5': 'v',
4672
+ '\uFF56': 'v',
4673
+ '\u1E7D': 'v',
4674
+ '\u1E7F': 'v',
4675
+ '\u028B': 'v',
4676
+ '\uA75F': 'v',
4677
+ '\u028C': 'v',
4678
+ '\uA761': 'vy',
4679
+ '\u24E6': 'w',
4680
+ '\uFF57': 'w',
4681
+ '\u1E81': 'w',
4682
+ '\u1E83': 'w',
4683
+ '\u0175': 'w',
4684
+ '\u1E87': 'w',
4685
+ '\u1E85': 'w',
4686
+ '\u1E98': 'w',
4687
+ '\u1E89': 'w',
4688
+ '\u2C73': 'w',
4689
+ '\u24E7': 'x',
4690
+ '\uFF58': 'x',
4691
+ '\u1E8B': 'x',
4692
+ '\u1E8D': 'x',
4693
+ '\u24E8': 'y',
4694
+ '\uFF59': 'y',
4695
+ '\u1EF3': 'y',
4696
+ '\u00FD': 'y',
4697
+ '\u0177': 'y',
4698
+ '\u1EF9': 'y',
4699
+ '\u0233': 'y',
4700
+ '\u1E8F': 'y',
4701
+ '\u00FF': 'y',
4702
+ '\u1EF7': 'y',
4703
+ '\u1E99': 'y',
4704
+ '\u1EF5': 'y',
4705
+ '\u01B4': 'y',
4706
+ '\u024F': 'y',
4707
+ '\u1EFF': 'y',
4708
+ '\u24E9': 'z',
4709
+ '\uFF5A': 'z',
4710
+ '\u017A': 'z',
4711
+ '\u1E91': 'z',
4712
+ '\u017C': 'z',
4713
+ '\u017E': 'z',
4714
+ '\u1E93': 'z',
4715
+ '\u1E95': 'z',
4716
+ '\u01B6': 'z',
4717
+ '\u0225': 'z',
4718
+ '\u0240': 'z',
4719
+ '\u2C6C': 'z',
4720
+ '\uA763': 'z',
4721
+ '\u0386': '\u0391',
4722
+ '\u0388': '\u0395',
4723
+ '\u0389': '\u0397',
4724
+ '\u038A': '\u0399',
4725
+ '\u03AA': '\u0399',
4726
+ '\u038C': '\u039F',
4727
+ '\u038E': '\u03A5',
4728
+ '\u03AB': '\u03A5',
4729
+ '\u038F': '\u03A9',
4730
+ '\u03AC': '\u03B1',
4731
+ '\u03AD': '\u03B5',
4732
+ '\u03AE': '\u03B7',
4733
+ '\u03AF': '\u03B9',
4734
+ '\u03CA': '\u03B9',
4735
+ '\u0390': '\u03B9',
4736
+ '\u03CC': '\u03BF',
4737
+ '\u03CD': '\u03C5',
4738
+ '\u03CB': '\u03C5',
4739
+ '\u03B0': '\u03C5',
4740
+ '\u03C9': '\u03C9',
4741
+ '\u03C2': '\u03C3'
4742
+ };
4743
+
4744
+ return diacritics;
4745
+ });
4746
+
4747
+ S2.define('select2/data/base',[
4748
+ '../utils'
4749
+ ], function (Utils) {
4750
+ function BaseAdapter ($element, options) {
4751
+ BaseAdapter.__super__.constructor.call(this);
4752
+ }
4753
+
4754
+ Utils.Extend(BaseAdapter, Utils.Observable);
4755
+
4756
+ BaseAdapter.prototype.current = function (callback) {
4757
+ throw new Error('The `current` method must be defined in child classes.');
4758
+ };
4759
+
4760
+ BaseAdapter.prototype.query = function (params, callback) {
4761
+ throw new Error('The `query` method must be defined in child classes.');
4762
+ };
4763
+
4764
+ BaseAdapter.prototype.bind = function (container, $container) {
4765
+ // Can be implemented in subclasses
4766
+ };
4767
+
4768
+ BaseAdapter.prototype.destroy = function () {
4769
+ // Can be implemented in subclasses
4770
+ };
4771
+
4772
+ BaseAdapter.prototype.generateResultId = function (container, data) {
4773
+ var id = container.id + '-result-';
4774
+
4775
+ id += Utils.generateChars(4);
4776
+
4777
+ if (data.id != null) {
4778
+ id += '-' + data.id.toString();
4779
+ } else {
4780
+ id += '-' + Utils.generateChars(4);
4781
+ }
4782
+ return id;
4783
+ };
4784
+
4785
+ return BaseAdapter;
4786
+ });
4787
+
4788
+ S2.define('select2/data/select',[
4789
+ './base',
4790
+ '../utils',
4791
+ 'jquery'
4792
+ ], function (BaseAdapter, Utils, $) {
4793
+ function SelectAdapter ($element, options) {
4794
+ this.$element = $element;
4795
+ this.options = options;
4796
+
4797
+ SelectAdapter.__super__.constructor.call(this);
4798
+ }
4799
+
4800
+ Utils.Extend(SelectAdapter, BaseAdapter);
4801
+
4802
+ SelectAdapter.prototype.current = function (callback) {
4803
+ var data = [];
4804
+ var self = this;
4805
+
4806
+ this.$element.find(':selected').each(function () {
4807
+ var $option = $(this);
4808
+
4809
+ var option = self.item($option);
4810
+
4811
+ data.push(option);
4812
+ });
4813
+
4814
+ callback(data);
4815
+ };
4816
+
4817
+ SelectAdapter.prototype.select = function (data) {
4818
+ var self = this;
4819
+
4820
+ data.selected = true;
4821
+
4822
+ // If data.element is a DOM node, use it instead
4823
+ if ($(data.element).is('option')) {
4824
+ data.element.selected = true;
4825
+
4826
+ this.$element.trigger('change');
4827
+
4828
+ return;
4829
+ }
4830
+
4831
+ if (this.$element.prop('multiple')) {
4832
+ this.current(function (currentData) {
4833
+ var val = [];
4834
+
4835
+ data = [data];
4836
+ data.push.apply(data, currentData);
4837
+
4838
+ for (var d = 0; d < data.length; d++) {
4839
+ var id = data[d].id;
4840
+
4841
+ if ($.inArray(id, val) === -1) {
4842
+ val.push(id);
4843
+ }
4844
+ }
4845
+
4846
+ self.$element.val(val);
4847
+ self.$element.trigger('change');
4848
+ });
4849
+ } else {
4850
+ var val = data.id;
4851
+
4852
+ this.$element.val(val);
4853
+ this.$element.trigger('change');
4854
+ }
4855
+ };
4856
+
4857
+ SelectAdapter.prototype.unselect = function (data) {
4858
+ var self = this;
4859
+
4860
+ if (!this.$element.prop('multiple')) {
4861
+ return;
4862
+ }
4863
+
4864
+ data.selected = false;
4865
+
4866
+ if ($(data.element).is('option')) {
4867
+ data.element.selected = false;
4868
+
4869
+ this.$element.trigger('change');
4870
+
4871
+ return;
4872
+ }
4873
+
4874
+ this.current(function (currentData) {
4875
+ var val = [];
4876
+
4877
+ for (var d = 0; d < currentData.length; d++) {
4878
+ var id = currentData[d].id;
4879
+
4880
+ if (id !== data.id && $.inArray(id, val) === -1) {
4881
+ val.push(id);
4882
+ }
4883
+ }
4884
+
4885
+ self.$element.val(val);
4886
+
4887
+ self.$element.trigger('change');
4888
+ });
4889
+ };
4890
+
4891
+ SelectAdapter.prototype.bind = function (container, $container) {
4892
+ var self = this;
4893
+
4894
+ this.container = container;
4895
+
4896
+ container.on('select', function (params) {
4897
+ self.select(params.data);
4898
+ });
4899
+
4900
+ container.on('unselect', function (params) {
4901
+ self.unselect(params.data);
4902
+ });
4903
+ };
4904
+
4905
+ SelectAdapter.prototype.destroy = function () {
4906
+ // Remove anything added to child elements
4907
+ this.$element.find('*').each(function () {
4908
+ // Remove any custom data set by Select2
4909
+ $.removeData(this, 'data');
4910
+ });
4911
+ };
4912
+
4913
+ SelectAdapter.prototype.query = function (params, callback) {
4914
+ var data = [];
4915
+ var self = this;
4916
+
4917
+ var $options = this.$element.children();
4918
+
4919
+ $options.each(function () {
4920
+ var $option = $(this);
4921
+
4922
+ if (!$option.is('option') && !$option.is('optgroup')) {
4923
+ return;
4924
+ }
4925
+
4926
+ var option = self.item($option);
4927
+
4928
+ var matches = self.matches(params, option);
4929
+
4930
+ if (matches !== null) {
4931
+ data.push(matches);
4932
+ }
4933
+ });
4934
+
4935
+ callback({
4936
+ results: data
4937
+ });
4938
+ };
4939
+
4940
+ SelectAdapter.prototype.addOptions = function ($options) {
4941
+ Utils.appendMany(this.$element, $options);
4942
+ };
4943
+
4944
+ SelectAdapter.prototype.option = function (data) {
4945
+ var option;
4946
+
4947
+ if (data.children) {
4948
+ option = document.createElement('optgroup');
4949
+ option.label = data.text;
4950
+ } else {
4951
+ option = document.createElement('option');
4952
+
4953
+ if (option.textContent !== undefined) {
4954
+ option.textContent = data.text;
4955
+ } else {
4956
+ option.innerText = data.text;
4957
+ }
4958
+ }
4959
+
4960
+ if (data.id !== undefined) {
4961
+ option.value = data.id;
4962
+ }
4963
+
4964
+ if (data.disabled) {
4965
+ option.disabled = true;
4966
+ }
4967
+
4968
+ if (data.selected) {
4969
+ option.selected = true;
4970
+ }
4971
+
4972
+ if (data.title) {
4973
+ option.title = data.title;
4974
+ }
4975
+
4976
+ var $option = $(option);
4977
+
4978
+ var normalizedData = this._normalizeItem(data);
4979
+ normalizedData.element = option;
4980
+
4981
+ // Override the option's data with the combined data
4982
+ $.data(option, 'data', normalizedData);
4983
+
4984
+ return $option;
4985
+ };
4986
+
4987
+ SelectAdapter.prototype.item = function ($option) {
4988
+ var data = {};
4989
+
4990
+ data = $.data($option[0], 'data');
4991
+
4992
+ if (data != null) {
4993
+ return data;
4994
+ }
4995
+
4996
+ if ($option.is('option')) {
4997
+ data = {
4998
+ id: $option.val(),
4999
+ text: $option.text(),
5000
+ disabled: $option.prop('disabled'),
5001
+ selected: $option.prop('selected'),
5002
+ title: $option.prop('title')
5003
+ };
5004
+ } else if ($option.is('optgroup')) {
5005
+ data = {
5006
+ text: $option.prop('label'),
5007
+ children: [],
5008
+ title: $option.prop('title')
5009
+ };
5010
+
5011
+ var $children = $option.children('option');
5012
+ var children = [];
5013
+
5014
+ for (var c = 0; c < $children.length; c++) {
5015
+ var $child = $($children[c]);
5016
+
5017
+ var child = this.item($child);
5018
+
5019
+ children.push(child);
5020
+ }
5021
+
5022
+ data.children = children;
5023
+ }
5024
+
5025
+ data = this._normalizeItem(data);
5026
+ data.element = $option[0];
5027
+
5028
+ $.data($option[0], 'data', data);
5029
+
5030
+ return data;
5031
+ };
5032
+
5033
+ SelectAdapter.prototype._normalizeItem = function (item) {
5034
+ if (!$.isPlainObject(item)) {
5035
+ item = {
5036
+ id: item,
5037
+ text: item
5038
+ };
5039
+ }
5040
+
5041
+ item = $.extend({}, {
5042
+ text: ''
5043
+ }, item);
5044
+
5045
+ var defaults = {
5046
+ selected: false,
5047
+ disabled: false
5048
+ };
5049
+
5050
+ if (item.id != null) {
5051
+ item.id = item.id.toString();
5052
+ }
5053
+
5054
+ if (item.text != null) {
5055
+ item.text = item.text.toString();
5056
+ }
5057
+
5058
+ if (item._resultId == null && item.id && this.container != null) {
5059
+ item._resultId = this.generateResultId(this.container, item);
5060
+ }
5061
+
5062
+ return $.extend({}, defaults, item);
5063
+ };
5064
+
5065
+ SelectAdapter.prototype.matches = function (params, data) {
5066
+ var matcher = this.options.get('matcher');
5067
+
5068
+ return matcher(params, data);
5069
+ };
5070
+
5071
+ return SelectAdapter;
5072
+ });
5073
+
5074
+ S2.define('select2/data/array',[
5075
+ './select',
5076
+ '../utils',
5077
+ 'jquery'
5078
+ ], function (SelectAdapter, Utils, $) {
5079
+ function ArrayAdapter ($element, options) {
5080
+ var data = options.get('data') || [];
5081
+
5082
+ ArrayAdapter.__super__.constructor.call(this, $element, options);
5083
+
5084
+ this.addOptions(this.convertToOptions(data));
5085
+ }
5086
+
5087
+ Utils.Extend(ArrayAdapter, SelectAdapter);
5088
+
5089
+ ArrayAdapter.prototype.select = function (data) {
5090
+ var $option = this.$element.find('option').filter(function (i, elm) {
5091
+ return elm.value == data.id.toString();
5092
+ });
5093
+
5094
+ if ($option.length === 0) {
5095
+ $option = this.option(data);
5096
+
5097
+ this.addOptions($option);
5098
+ }
5099
+
5100
+ ArrayAdapter.__super__.select.call(this, data);
5101
+ };
5102
+
5103
+ ArrayAdapter.prototype.convertToOptions = function (data) {
5104
+ var self = this;
5105
+
5106
+ var $existing = this.$element.find('option');
5107
+ var existingIds = $existing.map(function () {
5108
+ return self.item($(this)).id;
5109
+ }).get();
5110
+
5111
+ var $options = [];
5112
+
5113
+ // Filter out all items except for the one passed in the argument
5114
+ function onlyItem (item) {
5115
+ return function () {
5116
+ return $(this).val() == item.id;
5117
+ };
5118
+ }
5119
+
5120
+ for (var d = 0; d < data.length; d++) {
5121
+ var item = this._normalizeItem(data[d]);
5122
+
5123
+ // Skip items which were pre-loaded, only merge the data
5124
+ if ($.inArray(item.id, existingIds) >= 0) {
5125
+ var $existingOption = $existing.filter(onlyItem(item));
5126
+
5127
+ var existingData = this.item($existingOption);
5128
+ var newData = $.extend(true, {}, item, existingData);
5129
+
5130
+ var $newOption = this.option(newData);
5131
+
5132
+ $existingOption.replaceWith($newOption);
5133
+
5134
+ continue;
5135
+ }
5136
+
5137
+ var $option = this.option(item);
5138
+
5139
+ if (item.children) {
5140
+ var $children = this.convertToOptions(item.children);
5141
+
5142
+ Utils.appendMany($option, $children);
5143
+ }
5144
+
5145
+ $options.push($option);
5146
+ }
5147
+
5148
+ return $options;
5149
+ };
5150
+
5151
+ return ArrayAdapter;
5152
+ });
5153
+
5154
+ S2.define('select2/data/ajax',[
5155
+ './array',
5156
+ '../utils',
5157
+ 'jquery'
5158
+ ], function (ArrayAdapter, Utils, $) {
5159
+ function AjaxAdapter ($element, options) {
5160
+ this.ajaxOptions = this._applyDefaults(options.get('ajax'));
5161
+
5162
+ if (this.ajaxOptions.processResults != null) {
5163
+ this.processResults = this.ajaxOptions.processResults;
5164
+ }
5165
+
5166
+ AjaxAdapter.__super__.constructor.call(this, $element, options);
5167
+ }
5168
+
5169
+ Utils.Extend(AjaxAdapter, ArrayAdapter);
5170
+
5171
+ AjaxAdapter.prototype._applyDefaults = function (options) {
5172
+ var defaults = {
5173
+ data: function (params) {
5174
+ return $.extend({}, params, {
5175
+ q: params.term
5176
+ });
5177
+ },
5178
+ transport: function (params, success, failure) {
5179
+ var $request = $.ajax(params);
5180
+
5181
+ $request.then(success);
5182
+ $request.fail(failure);
5183
+
5184
+ return $request;
5185
+ }
5186
+ };
5187
+
5188
+ return $.extend({}, defaults, options, true);
5189
+ };
5190
+
5191
+ AjaxAdapter.prototype.processResults = function (results) {
5192
+ return results;
5193
+ };
5194
+
5195
+ AjaxAdapter.prototype.query = function (params, callback) {
5196
+ var matches = [];
5197
+ var self = this;
5198
+
5199
+ if (this._request != null) {
5200
+ // JSONP requests cannot always be aborted
5201
+ if ($.isFunction(this._request.abort)) {
5202
+ this._request.abort();
5203
+ }
5204
+
5205
+ this._request = null;
5206
+ }
5207
+
5208
+ var options = $.extend({
5209
+ type: 'GET'
5210
+ }, this.ajaxOptions);
5211
+
5212
+ if (typeof options.url === 'function') {
5213
+ options.url = options.url.call(this.$element, params);
5214
+ }
5215
+
5216
+ if (typeof options.data === 'function') {
5217
+ options.data = options.data.call(this.$element, params);
5218
+ }
5219
+
5220
+ function request () {
5221
+ var $request = options.transport(options, function (data) {
5222
+ var results = self.processResults(data, params);
5223
+
5224
+ if (self.options.get('debug') && window.console && console.error) {
5225
+ // Check to make sure that the response included a `results` key.
5226
+ if (!results || !results.results || !$.isArray(results.results)) {
5227
+ console.error(
5228
+ 'Select2: The AJAX results did not return an array in the ' +
5229
+ '`results` key of the response.'
5230
+ );
5231
+ }
5232
+ }
5233
+
5234
+ callback(results);
5235
+ }, function () {
5236
+ // Attempt to detect if a request was aborted
5237
+ // Only works if the transport exposes a status property
5238
+ if ($request.status && $request.status === '0') {
5239
+ return;
5240
+ }
5241
+
5242
+ self.trigger('results:message', {
5243
+ message: 'errorLoading'
5244
+ });
5245
+ });
5246
+
5247
+ self._request = $request;
5248
+ }
5249
+
5250
+ if (this.ajaxOptions.delay && params.term != null) {
5251
+ if (this._queryTimeout) {
5252
+ window.clearTimeout(this._queryTimeout);
5253
+ }
5254
+
5255
+ this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
5256
+ } else {
5257
+ request();
5258
+ }
5259
+ };
5260
+
5261
+ return AjaxAdapter;
5262
+ });
5263
+
5264
+ S2.define('select2/data/tags',[
5265
+ 'jquery'
5266
+ ], function ($) {
5267
+ function Tags (decorated, $element, options) {
5268
+ var tags = options.get('tags');
5269
+
5270
+ var createTag = options.get('createTag');
5271
+
5272
+ if (createTag !== undefined) {
5273
+ this.createTag = createTag;
5274
+ }
5275
+
5276
+ var insertTag = options.get('insertTag');
5277
+
5278
+ if (insertTag !== undefined) {
5279
+ this.insertTag = insertTag;
5280
+ }
5281
+
5282
+ decorated.call(this, $element, options);
5283
+
5284
+ if ($.isArray(tags)) {
5285
+ for (var t = 0; t < tags.length; t++) {
5286
+ var tag = tags[t];
5287
+ var item = this._normalizeItem(tag);
5288
+
5289
+ var $option = this.option(item);
5290
+
5291
+ this.$element.append($option);
5292
+ }
5293
+ }
5294
+ }
5295
+
5296
+ Tags.prototype.query = function (decorated, params, callback) {
5297
+ var self = this;
5298
+
5299
+ this._removeOldTags();
5300
+
5301
+ if (params.term == null || params.page != null) {
5302
+ decorated.call(this, params, callback);
5303
+ return;
5304
+ }
5305
+
5306
+ function wrapper (obj, child) {
5307
+ var data = obj.results;
5308
+
5309
+ for (var i = 0; i < data.length; i++) {
5310
+ var option = data[i];
5311
+
5312
+ var checkChildren = (
5313
+ option.children != null &&
5314
+ !wrapper({
5315
+ results: option.children
5316
+ }, true)
5317
+ );
5318
+
5319
+ var optionText = (option.text || '').toUpperCase();
5320
+ var paramsTerm = (params.term || '').toUpperCase();
5321
+
5322
+ var checkText = optionText === paramsTerm;
5323
+
5324
+ if (checkText || checkChildren) {
5325
+ if (child) {
5326
+ return false;
5327
+ }
5328
+
5329
+ obj.data = data;
5330
+ callback(obj);
5331
+
5332
+ return;
5333
+ }
5334
+ }
5335
+
5336
+ if (child) {
5337
+ return true;
5338
+ }
5339
+
5340
+ var tag = self.createTag(params);
5341
+
5342
+ if (tag != null) {
5343
+ var $option = self.option(tag);
5344
+ $option.attr('data-select2-tag', true);
5345
+
5346
+ self.addOptions([$option]);
5347
+
5348
+ self.insertTag(data, tag);
5349
+ }
5350
+
5351
+ obj.results = data;
5352
+
5353
+ callback(obj);
5354
+ }
5355
+
5356
+ decorated.call(this, params, wrapper);
5357
+ };
5358
+
5359
+ Tags.prototype.createTag = function (decorated, params) {
5360
+ var term = $.trim(params.term);
5361
+
5362
+ if (term === '') {
5363
+ return null;
5364
+ }
5365
+
5366
+ return {
5367
+ id: term,
5368
+ text: term
5369
+ };
5370
+ };
5371
+
5372
+ Tags.prototype.insertTag = function (_, data, tag) {
5373
+ data.unshift(tag);
5374
+ };
5375
+
5376
+ Tags.prototype._removeOldTags = function (_) {
5377
+ var tag = this._lastTag;
5378
+
5379
+ var $options = this.$element.find('option[data-select2-tag]');
5380
+
5381
+ $options.each(function () {
5382
+ if (this.selected) {
5383
+ return;
5384
+ }
5385
+
5386
+ $(this).remove();
5387
+ });
5388
+ };
5389
+
5390
+ return Tags;
5391
+ });
5392
+
5393
+ S2.define('select2/data/tokenizer',[
5394
+ 'jquery'
5395
+ ], function ($) {
5396
+ function Tokenizer (decorated, $element, options) {
5397
+ var tokenizer = options.get('tokenizer');
5398
+
5399
+ if (tokenizer !== undefined) {
5400
+ this.tokenizer = tokenizer;
5401
+ }
5402
+
5403
+ decorated.call(this, $element, options);
5404
+ }
5405
+
5406
+ Tokenizer.prototype.bind = function (decorated, container, $container) {
5407
+ decorated.call(this, container, $container);
5408
+
5409
+ this.$search = container.dropdown.$search || container.selection.$search ||
5410
+ $container.find('.select2-search__field');
5411
+ };
5412
+
5413
+ Tokenizer.prototype.query = function (decorated, params, callback) {
5414
+ var self = this;
5415
+
5416
+ function createAndSelect (data) {
5417
+ // Normalize the data object so we can use it for checks
5418
+ var item = self._normalizeItem(data);
5419
+
5420
+ // Check if the data object already exists as a tag
5421
+ // Select it if it doesn't
5422
+ var $existingOptions = self.$element.find('option').filter(function () {
5423
+ return $(this).val() === item.id;
5424
+ });
5425
+
5426
+ // If an existing option wasn't found for it, create the option
5427
+ if (!$existingOptions.length) {
5428
+ var $option = self.option(item);
5429
+ $option.attr('data-select2-tag', true);
5430
+
5431
+ self._removeOldTags();
5432
+ self.addOptions([$option]);
5433
+ }
5434
+
5435
+ // Select the item, now that we know there is an option for it
5436
+ select(item);
5437
+ }
5438
+
5439
+ function select (data) {
5440
+ self.trigger('select', {
5441
+ data: data
5442
+ });
5443
+ }
5444
+
5445
+ params.term = params.term || '';
5446
+
5447
+ var tokenData = this.tokenizer(params, this.options, createAndSelect);
5448
+
5449
+ if (tokenData.term !== params.term) {
5450
+ // Replace the search term if we have the search box
5451
+ if (this.$search.length) {
5452
+ this.$search.val(tokenData.term);
5453
+ this.$search.focus();
5454
+ }
5455
+
5456
+ params.term = tokenData.term;
5457
+ }
5458
+
5459
+ decorated.call(this, params, callback);
5460
+ };
5461
+
5462
+ Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
5463
+ var separators = options.get('tokenSeparators') || [];
5464
+ var term = params.term;
5465
+ var i = 0;
5466
+
5467
+ var createTag = this.createTag || function (params) {
5468
+ return {
5469
+ id: params.term,
5470
+ text: params.term
5471
+ };
5472
+ };
5473
+
5474
+ while (i < term.length) {
5475
+ var termChar = term[i];
5476
+
5477
+ if ($.inArray(termChar, separators) === -1) {
5478
+ i++;
5479
+
5480
+ continue;
5481
+ }
5482
+
5483
+ var part = term.substr(0, i);
5484
+ var partParams = $.extend({}, params, {
5485
+ term: part
5486
+ });
5487
+
5488
+ var data = createTag(partParams);
5489
+
5490
+ if (data == null) {
5491
+ i++;
5492
+ continue;
5493
+ }
5494
+
5495
+ callback(data);
5496
+
5497
+ // Reset the term to not include the tokenized portion
5498
+ term = term.substr(i + 1) || '';
5499
+ i = 0;
5500
+ }
5501
+
5502
+ return {
5503
+ term: term
5504
+ };
5505
+ };
5506
+
5507
+ return Tokenizer;
5508
+ });
5509
+
5510
+ S2.define('select2/data/minimumInputLength',[
5511
+
5512
+ ], function () {
5513
+ function MinimumInputLength (decorated, $e, options) {
5514
+ this.minimumInputLength = options.get('minimumInputLength');
5515
+
5516
+ decorated.call(this, $e, options);
5517
+ }
5518
+
5519
+ MinimumInputLength.prototype.query = function (decorated, params, callback) {
5520
+ params.term = params.term || '';
5521
+
5522
+ if (params.term.length < this.minimumInputLength) {
5523
+ this.trigger('results:message', {
5524
+ message: 'inputTooShort',
5525
+ args: {
5526
+ minimum: this.minimumInputLength,
5527
+ input: params.term,
5528
+ params: params
5529
+ }
5530
+ });
5531
+
5532
+ return;
5533
+ }
5534
+
5535
+ decorated.call(this, params, callback);
5536
+ };
5537
+
5538
+ return MinimumInputLength;
5539
+ });
5540
+
5541
+ S2.define('select2/data/maximumInputLength',[
5542
+
5543
+ ], function () {
5544
+ function MaximumInputLength (decorated, $e, options) {
5545
+ this.maximumInputLength = options.get('maximumInputLength');
5546
+
5547
+ decorated.call(this, $e, options);
5548
+ }
5549
+
5550
+ MaximumInputLength.prototype.query = function (decorated, params, callback) {
5551
+ params.term = params.term || '';
5552
+
5553
+ if (this.maximumInputLength > 0 &&
5554
+ params.term.length > this.maximumInputLength) {
5555
+ this.trigger('results:message', {
5556
+ message: 'inputTooLong',
5557
+ args: {
5558
+ maximum: this.maximumInputLength,
5559
+ input: params.term,
5560
+ params: params
5561
+ }
5562
+ });
5563
+
5564
+ return;
5565
+ }
5566
+
5567
+ decorated.call(this, params, callback);
5568
+ };
5569
+
5570
+ return MaximumInputLength;
5571
+ });
5572
+
5573
+ S2.define('select2/data/maximumSelectionLength',[
5574
+
5575
+ ], function (){
5576
+ function MaximumSelectionLength (decorated, $e, options) {
5577
+ this.maximumSelectionLength = options.get('maximumSelectionLength');
5578
+
5579
+ decorated.call(this, $e, options);
5580
+ }
5581
+
5582
+ MaximumSelectionLength.prototype.query =
5583
+ function (decorated, params, callback) {
5584
+ var self = this;
5585
+
5586
+ this.current(function (currentData) {
5587
+ var count = currentData != null ? currentData.length : 0;
5588
+ if (self.maximumSelectionLength > 0 &&
5589
+ count >= self.maximumSelectionLength) {
5590
+ self.trigger('results:message', {
5591
+ message: 'maximumSelected',
5592
+ args: {
5593
+ maximum: self.maximumSelectionLength
5594
+ }
5595
+ });
5596
+ return;
5597
+ }
5598
+ decorated.call(self, params, callback);
5599
+ });
5600
+ };
5601
+
5602
+ return MaximumSelectionLength;
5603
+ });
5604
+
5605
+ S2.define('select2/dropdown',[
5606
+ 'jquery',
5607
+ './utils'
5608
+ ], function ($, Utils) {
5609
+ function Dropdown ($element, options) {
5610
+ this.$element = $element;
5611
+ this.options = options;
5612
+
5613
+ Dropdown.__super__.constructor.call(this);
5614
+ }
5615
+
5616
+ Utils.Extend(Dropdown, Utils.Observable);
5617
+
5618
+ Dropdown.prototype.render = function () {
5619
+ var $dropdown = $(
5620
+ '<span class="select2-dropdown">' +
5621
+ '<span class="select2-results"></span>' +
5622
+ '</span>'
5623
+ );
5624
+
5625
+ $dropdown.attr('dir', this.options.get('dir'));
5626
+
5627
+ this.$dropdown = $dropdown;
5628
+
5629
+ return $dropdown;
5630
+ };
5631
+
5632
+ Dropdown.prototype.bind = function () {
5633
+ // Should be implemented in subclasses
5634
+ };
5635
+
5636
+ Dropdown.prototype.position = function ($dropdown, $container) {
5637
+ // Should be implmented in subclasses
5638
+ };
5639
+
5640
+ Dropdown.prototype.destroy = function () {
5641
+ // Remove the dropdown from the DOM
5642
+ this.$dropdown.remove();
5643
+ };
5644
+
5645
+ return Dropdown;
5646
+ });
5647
+
5648
+ S2.define('select2/dropdown/search',[
5649
+ 'jquery',
5650
+ '../utils'
5651
+ ], function ($, Utils) {
5652
+ function Search () { }
5653
+
5654
+ Search.prototype.render = function (decorated) {
5655
+ var $rendered = decorated.call(this);
5656
+
5657
+ var $search = $(
5658
+ '<span class="select2-search select2-search--dropdown">' +
5659
+ '<input class="select2-search__field" type="search" tabindex="-1"' +
5660
+ ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
5661
+ ' spellcheck="false" role="textbox" />' +
5662
+ '</span>'
5663
+ );
5664
+
5665
+ this.$searchContainer = $search;
5666
+ this.$search = $search.find('input');
5667
+
5668
+ $rendered.prepend($search);
5669
+
5670
+ return $rendered;
5671
+ };
5672
+
5673
+ Search.prototype.bind = function (decorated, container, $container) {
5674
+ var self = this;
5675
+
5676
+ decorated.call(this, container, $container);
5677
+
5678
+ this.$search.on('keydown', function (evt) {
5679
+ self.trigger('keypress', evt);
5680
+
5681
+ self._keyUpPrevented = evt.isDefaultPrevented();
5682
+ });
5683
+
5684
+ // Workaround for browsers which do not support the `input` event
5685
+ // This will prevent double-triggering of events for browsers which support
5686
+ // both the `keyup` and `input` events.
5687
+ this.$search.on('input', function (evt) {
5688
+ // Unbind the duplicated `keyup` event
5689
+ $(this).off('keyup');
5690
+ });
5691
+
5692
+ this.$search.on('keyup input', function (evt) {
5693
+ self.handleSearch(evt);
5694
+ });
5695
+
5696
+ container.on('open', function () {
5697
+ self.$search.attr('tabindex', 0);
5698
+
5699
+ self.$search.focus();
5700
+
5701
+ window.setTimeout(function () {
5702
+ self.$search.focus();
5703
+ }, 0);
5704
+ });
5705
+
5706
+ container.on('close', function () {
5707
+ self.$search.attr('tabindex', -1);
5708
+
5709
+ self.$search.val('');
5710
+ });
5711
+
5712
+ container.on('focus', function () {
5713
+ if (!container.isOpen()) {
5714
+ self.$search.focus();
5715
+ }
5716
+ });
5717
+
5718
+ container.on('results:all', function (params) {
5719
+ if (params.query.term == null || params.query.term === '') {
5720
+ var showSearch = self.showSearch(params);
5721
+
5722
+ if (showSearch) {
5723
+ self.$searchContainer.removeClass('select2-search--hide');
5724
+ } else {
5725
+ self.$searchContainer.addClass('select2-search--hide');
5726
+ }
5727
+ }
5728
+ });
5729
+ };
5730
+
5731
+ Search.prototype.handleSearch = function (evt) {
5732
+ if (!this._keyUpPrevented) {
5733
+ var input = this.$search.val();
5734
+
5735
+ this.trigger('query', {
5736
+ term: input
5737
+ });
5738
+ }
5739
+
5740
+ this._keyUpPrevented = false;
5741
+ };
5742
+
5743
+ Search.prototype.showSearch = function (_, params) {
5744
+ return true;
5745
+ };
5746
+
5747
+ return Search;
5748
+ });
5749
+
5750
+ S2.define('select2/dropdown/hidePlaceholder',[
5751
+
5752
+ ], function () {
5753
+ function HidePlaceholder (decorated, $element, options, dataAdapter) {
5754
+ this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
5755
+
5756
+ decorated.call(this, $element, options, dataAdapter);
5757
+ }
5758
+
5759
+ HidePlaceholder.prototype.append = function (decorated, data) {
5760
+ data.results = this.removePlaceholder(data.results);
5761
+
5762
+ decorated.call(this, data);
5763
+ };
5764
+
5765
+ HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
5766
+ if (typeof placeholder === 'string') {
5767
+ placeholder = {
5768
+ id: '',
5769
+ text: placeholder
5770
+ };
5771
+ }
5772
+
5773
+ return placeholder;
5774
+ };
5775
+
5776
+ HidePlaceholder.prototype.removePlaceholder = function (_, data) {
5777
+ var modifiedData = data.slice(0);
5778
+
5779
+ for (var d = data.length - 1; d >= 0; d--) {
5780
+ var item = data[d];
5781
+
5782
+ if (this.placeholder.id === item.id) {
5783
+ modifiedData.splice(d, 1);
5784
+ }
5785
+ }
5786
+
5787
+ return modifiedData;
5788
+ };
5789
+
5790
+ return HidePlaceholder;
5791
+ });
5792
+
5793
+ S2.define('select2/dropdown/infiniteScroll',[
5794
+ 'jquery'
5795
+ ], function ($) {
5796
+ function InfiniteScroll (decorated, $element, options, dataAdapter) {
5797
+ this.lastParams = {};
5798
+
5799
+ decorated.call(this, $element, options, dataAdapter);
5800
+
5801
+ this.$loadingMore = this.createLoadingMore();
5802
+ this.loading = false;
5803
+ }
5804
+
5805
+ InfiniteScroll.prototype.append = function (decorated, data) {
5806
+ this.$loadingMore.remove();
5807
+ this.loading = false;
5808
+
5809
+ decorated.call(this, data);
5810
+
5811
+ if (this.showLoadingMore(data)) {
5812
+ this.$results.append(this.$loadingMore);
5813
+ }
5814
+ };
5815
+
5816
+ InfiniteScroll.prototype.bind = function (decorated, container, $container) {
5817
+ var self = this;
5818
+
5819
+ decorated.call(this, container, $container);
5820
+
5821
+ container.on('query', function (params) {
5822
+ self.lastParams = params;
5823
+ self.loading = true;
5824
+ });
5825
+
5826
+ container.on('query:append', function (params) {
5827
+ self.lastParams = params;
5828
+ self.loading = true;
5829
+ });
5830
+
5831
+ this.$results.on('scroll', function () {
5832
+ var isLoadMoreVisible = $.contains(
5833
+ document.documentElement,
5834
+ self.$loadingMore[0]
5835
+ );
5836
+
5837
+ if (self.loading || !isLoadMoreVisible) {
5838
+ return;
5839
+ }
5840
+
5841
+ var currentOffset = self.$results.offset().top +
5842
+ self.$results.outerHeight(false);
5843
+ var loadingMoreOffset = self.$loadingMore.offset().top +
5844
+ self.$loadingMore.outerHeight(false);
5845
+
5846
+ if (currentOffset + 50 >= loadingMoreOffset) {
5847
+ self.loadMore();
5848
+ }
5849
+ });
5850
+ };
5851
+
5852
+ InfiniteScroll.prototype.loadMore = function () {
5853
+ this.loading = true;
5854
+
5855
+ var params = $.extend({}, {page: 1}, this.lastParams);
5856
+
5857
+ params.page++;
5858
+
5859
+ this.trigger('query:append', params);
5860
+ };
5861
+
5862
+ InfiniteScroll.prototype.showLoadingMore = function (_, data) {
5863
+ return data.pagination && data.pagination.more;
5864
+ };
5865
+
5866
+ InfiniteScroll.prototype.createLoadingMore = function () {
5867
+ var $option = $(
5868
+ '<li ' +
5869
+ 'class="select2-results__option select2-results__option--load-more"' +
5870
+ 'role="treeitem" aria-disabled="true"></li>'
5871
+ );
5872
+
5873
+ var message = this.options.get('translations').get('loadingMore');
5874
+
5875
+ $option.html(message(this.lastParams));
5876
+
5877
+ return $option;
5878
+ };
5879
+
5880
+ return InfiniteScroll;
5881
+ });
5882
+
5883
+ S2.define('select2/dropdown/attachBody',[
5884
+ 'jquery',
5885
+ '../utils'
5886
+ ], function ($, Utils) {
5887
+ function AttachBody (decorated, $element, options) {
5888
+ this.$dropdownParent = options.get('dropdownParent') || $(document.body);
5889
+
5890
+ decorated.call(this, $element, options);
5891
+ }
5892
+
5893
+ AttachBody.prototype.bind = function (decorated, container, $container) {
5894
+ var self = this;
5895
+
5896
+ var setupResultsEvents = false;
5897
+
5898
+ decorated.call(this, container, $container);
5899
+
5900
+ container.on('open', function () {
5901
+ self._showDropdown();
5902
+ self._attachPositioningHandler(container);
5903
+
5904
+ if (!setupResultsEvents) {
5905
+ setupResultsEvents = true;
5906
+
5907
+ container.on('results:all', function () {
5908
+ self._positionDropdown();
5909
+ self._resizeDropdown();
5910
+ });
5911
+
5912
+ container.on('results:append', function () {
5913
+ self._positionDropdown();
5914
+ self._resizeDropdown();
5915
+ });
5916
+ }
5917
+ });
5918
+
5919
+ container.on('close', function () {
5920
+ self._hideDropdown();
5921
+ self._detachPositioningHandler(container);
5922
+ });
5923
+
5924
+ this.$dropdownContainer.on('mousedown', function (evt) {
5925
+ evt.stopPropagation();
5926
+ });
5927
+ };
5928
+
5929
+ AttachBody.prototype.destroy = function (decorated) {
5930
+ decorated.call(this);
5931
+
5932
+ this.$dropdownContainer.remove();
5933
+ };
5934
+
5935
+ AttachBody.prototype.position = function (decorated, $dropdown, $container) {
5936
+ // Clone all of the container classes
5937
+ $dropdown.attr('class', $container.attr('class'));
5938
+
5939
+ $dropdown.removeClass('select2');
5940
+ $dropdown.addClass('select2-container--open');
5941
+
5942
+ $dropdown.css({
5943
+ position: 'absolute',
5944
+ top: -999999
5945
+ });
5946
+
5947
+ this.$container = $container;
5948
+ };
5949
+
5950
+ AttachBody.prototype.render = function (decorated) {
5951
+ var $container = $('<span></span>');
5952
+
5953
+ var $dropdown = decorated.call(this);
5954
+ $container.append($dropdown);
5955
+
5956
+ this.$dropdownContainer = $container;
5957
+
5958
+ return $container;
5959
+ };
5960
+
5961
+ AttachBody.prototype._hideDropdown = function (decorated) {
5962
+ this.$dropdownContainer.detach();
5963
+ };
5964
+
5965
+ AttachBody.prototype._attachPositioningHandler =
5966
+ function (decorated, container) {
5967
+ var self = this;
5968
+
5969
+ var scrollEvent = 'scroll.select2.' + container.id;
5970
+ var resizeEvent = 'resize.select2.' + container.id;
5971
+ var orientationEvent = 'orientationchange.select2.' + container.id;
5972
+
5973
+ var $watchers = this.$container.parents().filter(Utils.hasScroll);
5974
+ $watchers.each(function () {
5975
+ $(this).data('select2-scroll-position', {
5976
+ x: $(this).scrollLeft(),
5977
+ y: $(this).scrollTop()
5978
+ });
5979
+ });
5980
+
5981
+ $watchers.on(scrollEvent, function (ev) {
5982
+ var position = $(this).data('select2-scroll-position');
5983
+ $(this).scrollTop(position.y);
5984
+ });
5985
+
5986
+ $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
5987
+ function (e) {
5988
+ self._positionDropdown();
5989
+ self._resizeDropdown();
5990
+ });
5991
+ };
5992
+
5993
+ AttachBody.prototype._detachPositioningHandler =
5994
+ function (decorated, container) {
5995
+ var scrollEvent = 'scroll.select2.' + container.id;
5996
+ var resizeEvent = 'resize.select2.' + container.id;
5997
+ var orientationEvent = 'orientationchange.select2.' + container.id;
5998
+
5999
+ var $watchers = this.$container.parents().filter(Utils.hasScroll);
6000
+ $watchers.off(scrollEvent);
6001
+
6002
+ $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
6003
+ };
6004
+
6005
+ AttachBody.prototype._positionDropdown = function () {
6006
+ var $window = $(window);
6007
+
6008
+ var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
6009
+ var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
6010
+
6011
+ var newDirection = null;
6012
+
6013
+ var offset = this.$container.offset();
6014
+
6015
+ offset.bottom = offset.top + this.$container.outerHeight(false);
6016
+
6017
+ var container = {
6018
+ height: this.$container.outerHeight(false)
6019
+ };
6020
+
6021
+ container.top = offset.top;
6022
+ container.bottom = offset.top + container.height;
6023
+
6024
+ var dropdown = {
6025
+ height: this.$dropdown.outerHeight(false)
6026
+ };
6027
+
6028
+ var viewport = {
6029
+ top: $window.scrollTop(),
6030
+ bottom: $window.scrollTop() + $window.height()
6031
+ };
6032
+
6033
+ var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
6034
+ var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
6035
+
6036
+ var css = {
6037
+ left: offset.left,
6038
+ top: container.bottom
6039
+ };
6040
+
6041
+ // Determine what the parent element is to use for calciulating the offset
6042
+ var $offsetParent = this.$dropdownParent;
6043
+
6044
+ // For statically positoned elements, we need to get the element
6045
+ // that is determining the offset
6046
+ if ($offsetParent.css('position') === 'static') {
6047
+ $offsetParent = $offsetParent.offsetParent();
6048
+ }
6049
+
6050
+ var parentOffset = $offsetParent.offset();
6051
+
6052
+ css.top -= parentOffset.top;
6053
+ css.left -= parentOffset.left;
6054
+
6055
+ if (!isCurrentlyAbove && !isCurrentlyBelow) {
6056
+ newDirection = 'below';
6057
+ }
6058
+
6059
+ if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
6060
+ newDirection = 'above';
6061
+ } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
6062
+ newDirection = 'below';
6063
+ }
6064
+
6065
+ if (newDirection == 'above' ||
6066
+ (isCurrentlyAbove && newDirection !== 'below')) {
6067
+ css.top = container.top - parentOffset.top - dropdown.height;
6068
+ }
6069
+
6070
+ if (newDirection != null) {
6071
+ this.$dropdown
6072
+ .removeClass('select2-dropdown--below select2-dropdown--above')
6073
+ .addClass('select2-dropdown--' + newDirection);
6074
+ this.$container
6075
+ .removeClass('select2-container--below select2-container--above')
6076
+ .addClass('select2-container--' + newDirection);
6077
+ }
6078
+
6079
+ this.$dropdownContainer.css(css);
6080
+ };
6081
+
6082
+ AttachBody.prototype._resizeDropdown = function () {
6083
+ var css = {
6084
+ width: this.$container.outerWidth(false) + 'px'
6085
+ };
6086
+
6087
+ if (this.options.get('dropdownAutoWidth')) {
6088
+ css.minWidth = css.width;
6089
+ css.position = 'relative';
6090
+ css.width = 'auto';
6091
+ }
6092
+
6093
+ this.$dropdown.css(css);
6094
+ };
6095
+
6096
+ AttachBody.prototype._showDropdown = function (decorated) {
6097
+ this.$dropdownContainer.appendTo(this.$dropdownParent);
6098
+
6099
+ this._positionDropdown();
6100
+ this._resizeDropdown();
6101
+ };
6102
+
6103
+ return AttachBody;
6104
+ });
6105
+
6106
+ S2.define('select2/dropdown/minimumResultsForSearch',[
6107
+
6108
+ ], function () {
6109
+ function countResults (data) {
6110
+ var count = 0;
6111
+
6112
+ for (var d = 0; d < data.length; d++) {
6113
+ var item = data[d];
6114
+
6115
+ if (item.children) {
6116
+ count += countResults(item.children);
6117
+ } else {
6118
+ count++;
6119
+ }
6120
+ }
6121
+
6122
+ return count;
6123
+ }
6124
+
6125
+ function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
6126
+ this.minimumResultsForSearch = options.get('minimumResultsForSearch');
6127
+
6128
+ if (this.minimumResultsForSearch < 0) {
6129
+ this.minimumResultsForSearch = Infinity;
6130
+ }
6131
+
6132
+ decorated.call(this, $element, options, dataAdapter);
6133
+ }
6134
+
6135
+ MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
6136
+ if (countResults(params.data.results) < this.minimumResultsForSearch) {
6137
+ return false;
6138
+ }
6139
+
6140
+ return decorated.call(this, params);
6141
+ };
6142
+
6143
+ return MinimumResultsForSearch;
6144
+ });
6145
+
6146
+ S2.define('select2/dropdown/selectOnClose',[
6147
+
6148
+ ], function () {
6149
+ function SelectOnClose () { }
6150
+
6151
+ SelectOnClose.prototype.bind = function (decorated, container, $container) {
6152
+ var self = this;
6153
+
6154
+ decorated.call(this, container, $container);
6155
+
6156
+ container.on('close', function (params) {
6157
+ self._handleSelectOnClose(params);
6158
+ });
6159
+ };
6160
+
6161
+ SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
6162
+ if (params && params.originalSelect2Event != null) {
6163
+ var event = params.originalSelect2Event;
6164
+
6165
+ // Don't select an item if the close event was triggered from a select or
6166
+ // unselect event
6167
+ if (event._type === 'select' || event._type === 'unselect') {
6168
+ return;
6169
+ }
6170
+ }
6171
+
6172
+ var $highlightedResults = this.getHighlightedResults();
6173
+
6174
+ // Only select highlighted results
6175
+ if ($highlightedResults.length < 1) {
6176
+ return;
6177
+ }
6178
+
6179
+ var data = $highlightedResults.data('data');
6180
+
6181
+ // Don't re-select already selected resulte
6182
+ if (
6183
+ (data.element != null && data.element.selected) ||
6184
+ (data.element == null && data.selected)
6185
+ ) {
6186
+ return;
6187
+ }
6188
+
6189
+ this.trigger('select', {
6190
+ data: data
6191
+ });
6192
+ };
6193
+
6194
+ return SelectOnClose;
6195
+ });
6196
+
6197
+ S2.define('select2/dropdown/closeOnSelect',[
6198
+
6199
+ ], function () {
6200
+ function CloseOnSelect () { }
6201
+
6202
+ CloseOnSelect.prototype.bind = function (decorated, container, $container) {
6203
+ var self = this;
6204
+
6205
+ decorated.call(this, container, $container);
6206
+
6207
+ container.on('select', function (evt) {
6208
+ self._selectTriggered(evt);
6209
+ });
6210
+
6211
+ container.on('unselect', function (evt) {
6212
+ self._selectTriggered(evt);
6213
+ });
6214
+ };
6215
+
6216
+ CloseOnSelect.prototype._selectTriggered = function (_, evt) {
6217
+ var originalEvent = evt.originalEvent;
6218
+
6219
+ // Don't close if the control key is being held
6220
+ if (originalEvent && originalEvent.ctrlKey) {
6221
+ return;
6222
+ }
6223
+
6224
+ this.trigger('close', {
6225
+ originalEvent: originalEvent,
6226
+ originalSelect2Event: evt
6227
+ });
6228
+ };
6229
+
6230
+ return CloseOnSelect;
6231
+ });
6232
+
6233
+ S2.define('select2/i18n/en',[],function () {
6234
+ // English
6235
+ return {
6236
+ errorLoading: function () {
6237
+ return 'The results could not be loaded.';
6238
+ },
6239
+ inputTooLong: function (args) {
6240
+ var overChars = args.input.length - args.maximum;
6241
+
6242
+ var message = 'Please delete ' + overChars + ' character';
6243
+
6244
+ if (overChars != 1) {
6245
+ message += 's';
6246
+ }
6247
+
6248
+ return message;
6249
+ },
6250
+ inputTooShort: function (args) {
6251
+ var remainingChars = args.minimum - args.input.length;
6252
+
6253
+ var message = 'Please enter ' + remainingChars + ' or more characters';
6254
+
6255
+ return message;
6256
+ },
6257
+ loadingMore: function () {
6258
+ return 'Loading more results…';
6259
+ },
6260
+ maximumSelected: function (args) {
6261
+ var message = 'You can only select ' + args.maximum + ' item';
6262
+
6263
+ if (args.maximum != 1) {
6264
+ message += 's';
6265
+ }
6266
+
6267
+ return message;
6268
+ },
6269
+ noResults: function () {
6270
+ return 'No results found';
6271
+ },
6272
+ searching: function () {
6273
+ return 'Searching…';
6274
+ }
6275
+ };
6276
+ });
6277
+
6278
+ S2.define('select2/defaults',[
6279
+ 'jquery',
6280
+ 'require',
6281
+
6282
+ './results',
6283
+
6284
+ './selection/single',
6285
+ './selection/multiple',
6286
+ './selection/placeholder',
6287
+ './selection/allowClear',
6288
+ './selection/search',
6289
+ './selection/eventRelay',
6290
+
6291
+ './utils',
6292
+ './translation',
6293
+ './diacritics',
6294
+
6295
+ './data/select',
6296
+ './data/array',
6297
+ './data/ajax',
6298
+ './data/tags',
6299
+ './data/tokenizer',
6300
+ './data/minimumInputLength',
6301
+ './data/maximumInputLength',
6302
+ './data/maximumSelectionLength',
6303
+
6304
+ './dropdown',
6305
+ './dropdown/search',
6306
+ './dropdown/hidePlaceholder',
6307
+ './dropdown/infiniteScroll',
6308
+ './dropdown/attachBody',
6309
+ './dropdown/minimumResultsForSearch',
6310
+ './dropdown/selectOnClose',
6311
+ './dropdown/closeOnSelect',
6312
+
6313
+ './i18n/en'
6314
+ ], function ($, require,
6315
+
6316
+ ResultsList,
6317
+
6318
+ SingleSelection, MultipleSelection, Placeholder, AllowClear,
6319
+ SelectionSearch, EventRelay,
6320
+
6321
+ Utils, Translation, DIACRITICS,
6322
+
6323
+ SelectData, ArrayData, AjaxData, Tags, Tokenizer,
6324
+ MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
6325
+
6326
+ Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
6327
+ AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
6328
+
6329
+ EnglishTranslation) {
6330
+ function Defaults () {
6331
+ this.reset();
6332
+ }
6333
+
6334
+ Defaults.prototype.apply = function (options) {
6335
+ options = $.extend(true, {}, this.defaults, options);
6336
+
6337
+ if (options.dataAdapter == null) {
6338
+ if (options.ajax != null) {
6339
+ options.dataAdapter = AjaxData;
6340
+ } else if (options.data != null) {
6341
+ options.dataAdapter = ArrayData;
6342
+ } else {
6343
+ options.dataAdapter = SelectData;
6344
+ }
6345
+
6346
+ if (options.minimumInputLength > 0) {
6347
+ options.dataAdapter = Utils.Decorate(
6348
+ options.dataAdapter,
6349
+ MinimumInputLength
6350
+ );
6351
+ }
6352
+
6353
+ if (options.maximumInputLength > 0) {
6354
+ options.dataAdapter = Utils.Decorate(
6355
+ options.dataAdapter,
6356
+ MaximumInputLength
6357
+ );
6358
+ }
6359
+
6360
+ if (options.maximumSelectionLength > 0) {
6361
+ options.dataAdapter = Utils.Decorate(
6362
+ options.dataAdapter,
6363
+ MaximumSelectionLength
6364
+ );
6365
+ }
6366
+
6367
+ if (options.tags) {
6368
+ options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
6369
+ }
6370
+
6371
+ if (options.tokenSeparators != null || options.tokenizer != null) {
6372
+ options.dataAdapter = Utils.Decorate(
6373
+ options.dataAdapter,
6374
+ Tokenizer
6375
+ );
6376
+ }
6377
+
6378
+ if (options.query != null) {
6379
+ var Query = require(options.amdBase + 'compat/query');
6380
+
6381
+ options.dataAdapter = Utils.Decorate(
6382
+ options.dataAdapter,
6383
+ Query
6384
+ );
6385
+ }
6386
+
6387
+ if (options.initSelection != null) {
6388
+ var InitSelection = require(options.amdBase + 'compat/initSelection');
6389
+
6390
+ options.dataAdapter = Utils.Decorate(
6391
+ options.dataAdapter,
6392
+ InitSelection
6393
+ );
6394
+ }
6395
+ }
6396
+
6397
+ if (options.resultsAdapter == null) {
6398
+ options.resultsAdapter = ResultsList;
6399
+
6400
+ if (options.ajax != null) {
6401
+ options.resultsAdapter = Utils.Decorate(
6402
+ options.resultsAdapter,
6403
+ InfiniteScroll
6404
+ );
6405
+ }
6406
+
6407
+ if (options.placeholder != null) {
6408
+ options.resultsAdapter = Utils.Decorate(
6409
+ options.resultsAdapter,
6410
+ HidePlaceholder
6411
+ );
6412
+ }
6413
+
6414
+ if (options.selectOnClose) {
6415
+ options.resultsAdapter = Utils.Decorate(
6416
+ options.resultsAdapter,
6417
+ SelectOnClose
6418
+ );
6419
+ }
6420
+ }
6421
+
6422
+ if (options.dropdownAdapter == null) {
6423
+ if (options.multiple) {
6424
+ options.dropdownAdapter = Dropdown;
6425
+ } else {
6426
+ var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
6427
+
6428
+ options.dropdownAdapter = SearchableDropdown;
6429
+ }
6430
+
6431
+ if (options.minimumResultsForSearch !== 0) {
6432
+ options.dropdownAdapter = Utils.Decorate(
6433
+ options.dropdownAdapter,
6434
+ MinimumResultsForSearch
6435
+ );
6436
+ }
6437
+
6438
+ if (options.closeOnSelect) {
6439
+ options.dropdownAdapter = Utils.Decorate(
6440
+ options.dropdownAdapter,
6441
+ CloseOnSelect
6442
+ );
6443
+ }
6444
+
6445
+ if (
6446
+ options.dropdownCssClass != null ||
6447
+ options.dropdownCss != null ||
6448
+ options.adaptDropdownCssClass != null
6449
+ ) {
6450
+ var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
6451
+
6452
+ options.dropdownAdapter = Utils.Decorate(
6453
+ options.dropdownAdapter,
6454
+ DropdownCSS
6455
+ );
6456
+ }
6457
+
6458
+ options.dropdownAdapter = Utils.Decorate(
6459
+ options.dropdownAdapter,
6460
+ AttachBody
6461
+ );
6462
+ }
6463
+
6464
+ if (options.selectionAdapter == null) {
6465
+ if (options.multiple) {
6466
+ options.selectionAdapter = MultipleSelection;
6467
+ } else {
6468
+ options.selectionAdapter = SingleSelection;
6469
+ }
6470
+
6471
+ // Add the placeholder mixin if a placeholder was specified
6472
+ if (options.placeholder != null) {
6473
+ options.selectionAdapter = Utils.Decorate(
6474
+ options.selectionAdapter,
6475
+ Placeholder
6476
+ );
6477
+ }
6478
+
6479
+ if (options.allowClear) {
6480
+ options.selectionAdapter = Utils.Decorate(
6481
+ options.selectionAdapter,
6482
+ AllowClear
6483
+ );
6484
+ }
6485
+
6486
+ if (options.multiple) {
6487
+ options.selectionAdapter = Utils.Decorate(
6488
+ options.selectionAdapter,
6489
+ SelectionSearch
6490
+ );
6491
+ }
6492
+
6493
+ if (
6494
+ options.containerCssClass != null ||
6495
+ options.containerCss != null ||
6496
+ options.adaptContainerCssClass != null
6497
+ ) {
6498
+ var ContainerCSS = require(options.amdBase + 'compat/containerCss');
6499
+
6500
+ options.selectionAdapter = Utils.Decorate(
6501
+ options.selectionAdapter,
6502
+ ContainerCSS
6503
+ );
6504
+ }
6505
+
6506
+ options.selectionAdapter = Utils.Decorate(
6507
+ options.selectionAdapter,
6508
+ EventRelay
6509
+ );
6510
+ }
6511
+
6512
+ if (typeof options.language === 'string') {
6513
+ // Check if the language is specified with a region
6514
+ if (options.language.indexOf('-') > 0) {
6515
+ // Extract the region information if it is included
6516
+ var languageParts = options.language.split('-');
6517
+ var baseLanguage = languageParts[0];
6518
+
6519
+ options.language = [options.language, baseLanguage];
6520
+ } else {
6521
+ options.language = [options.language];
6522
+ }
6523
+ }
6524
+
6525
+ if ($.isArray(options.language)) {
6526
+ var languages = new Translation();
6527
+ options.language.push('en');
6528
+
6529
+ var languageNames = options.language;
6530
+
6531
+ for (var l = 0; l < languageNames.length; l++) {
6532
+ var name = languageNames[l];
6533
+ var language = {};
6534
+
6535
+ try {
6536
+ // Try to load it with the original name
6537
+ language = Translation.loadPath(name);
6538
+ } catch (e) {
6539
+ try {
6540
+ // If we couldn't load it, check if it wasn't the full path
6541
+ name = this.defaults.amdLanguageBase + name;
6542
+ language = Translation.loadPath(name);
6543
+ } catch (ex) {
6544
+ // The translation could not be loaded at all. Sometimes this is
6545
+ // because of a configuration problem, other times this can be
6546
+ // because of how Select2 helps load all possible translation files.
6547
+ if (options.debug && window.console && console.warn) {
6548
+ console.warn(
6549
+ 'Select2: The language file for "' + name + '" could not be ' +
6550
+ 'automatically loaded. A fallback will be used instead.'
6551
+ );
6552
+ }
6553
+
6554
+ continue;
6555
+ }
6556
+ }
6557
+
6558
+ languages.extend(language);
6559
+ }
6560
+
6561
+ options.translations = languages;
6562
+ } else {
6563
+ var baseTranslation = Translation.loadPath(
6564
+ this.defaults.amdLanguageBase + 'en'
6565
+ );
6566
+ var customTranslation = new Translation(options.language);
6567
+
6568
+ customTranslation.extend(baseTranslation);
6569
+
6570
+ options.translations = customTranslation;
6571
+ }
6572
+
6573
+ return options;
6574
+ };
6575
+
6576
+ Defaults.prototype.reset = function () {
6577
+ function stripDiacritics (text) {
6578
+ // Used 'uni range + named function' from http://jsperf.com/diacritics/18
6579
+ function match(a) {
6580
+ return DIACRITICS[a] || a;
6581
+ }
6582
+
6583
+ return text.replace(/[^\u0000-\u007E]/g, match);
6584
+ }
6585
+
6586
+ function matcher (params, data) {
6587
+ // Always return the object if there is nothing to compare
6588
+ if ($.trim(params.term) === '') {
6589
+ return data;
6590
+ }
6591
+
6592
+ // Do a recursive check for options with children
6593
+ if (data.children && data.children.length > 0) {
6594
+ // Clone the data object if there are children
6595
+ // This is required as we modify the object to remove any non-matches
6596
+ var match = $.extend(true, {}, data);
6597
+
6598
+ // Check each child of the option
6599
+ for (var c = data.children.length - 1; c >= 0; c--) {
6600
+ var child = data.children[c];
6601
+
6602
+ var matches = matcher(params, child);
6603
+
6604
+ // If there wasn't a match, remove the object in the array
6605
+ if (matches == null) {
6606
+ match.children.splice(c, 1);
6607
+ }
6608
+ }
6609
+
6610
+ // If any children matched, return the new object
6611
+ if (match.children.length > 0) {
6612
+ return match;
6613
+ }
6614
+
6615
+ // If there were no matching children, check just the plain object
6616
+ return matcher(params, match);
6617
+ }
6618
+
6619
+ var original = stripDiacritics(data.text).toUpperCase();
6620
+ var term = stripDiacritics(params.term).toUpperCase();
6621
+
6622
+ // Check if the text contains the term
6623
+ if (original.indexOf(term) > -1) {
6624
+ return data;
6625
+ }
6626
+
6627
+ // If it doesn't contain the term, don't return anything
6628
+ return null;
6629
+ }
6630
+
6631
+ this.defaults = {
6632
+ amdBase: './',
6633
+ amdLanguageBase: './i18n/',
6634
+ closeOnSelect: true,
6635
+ debug: false,
6636
+ dropdownAutoWidth: false,
6637
+ escapeMarkup: Utils.escapeMarkup,
6638
+ language: EnglishTranslation,
6639
+ matcher: matcher,
6640
+ minimumInputLength: 0,
6641
+ maximumInputLength: 0,
6642
+ maximumSelectionLength: 0,
6643
+ minimumResultsForSearch: 0,
6644
+ selectOnClose: false,
6645
+ sorter: function (data) {
6646
+ return data;
6647
+ },
6648
+ templateResult: function (result) {
6649
+ return result.text;
6650
+ },
6651
+ templateSelection: function (selection) {
6652
+ return selection.text;
6653
+ },
6654
+ theme: 'default',
6655
+ width: 'resolve'
6656
+ };
6657
+ };
6658
+
6659
+ Defaults.prototype.set = function (key, value) {
6660
+ var camelKey = $.camelCase(key);
6661
+
6662
+ var data = {};
6663
+ data[camelKey] = value;
6664
+
6665
+ var convertedData = Utils._convertData(data);
6666
+
6667
+ $.extend(this.defaults, convertedData);
6668
+ };
6669
+
6670
+ var defaults = new Defaults();
6671
+
6672
+ return defaults;
6673
+ });
6674
+
6675
+ S2.define('select2/options',[
6676
+ 'require',
6677
+ 'jquery',
6678
+ './defaults',
6679
+ './utils'
6680
+ ], function (require, $, Defaults, Utils) {
6681
+ function Options (options, $element) {
6682
+ this.options = options;
6683
+
6684
+ if ($element != null) {
6685
+ this.fromElement($element);
6686
+ }
6687
+
6688
+ this.options = Defaults.apply(this.options);
6689
+
6690
+ if ($element && $element.is('input')) {
6691
+ var InputCompat = require(this.get('amdBase') + 'compat/inputData');
6692
+
6693
+ this.options.dataAdapter = Utils.Decorate(
6694
+ this.options.dataAdapter,
6695
+ InputCompat
6696
+ );
6697
+ }
6698
+ }
6699
+
6700
+ Options.prototype.fromElement = function ($e) {
6701
+ var excludedData = ['select2'];
6702
+
6703
+ if (this.options.multiple == null) {
6704
+ this.options.multiple = $e.prop('multiple');
6705
+ }
6706
+
6707
+ if (this.options.disabled == null) {
6708
+ this.options.disabled = $e.prop('disabled');
6709
+ }
6710
+
6711
+ if (this.options.language == null) {
6712
+ if ($e.prop('lang')) {
6713
+ this.options.language = $e.prop('lang').toLowerCase();
6714
+ } else if ($e.closest('[lang]').prop('lang')) {
6715
+ this.options.language = $e.closest('[lang]').prop('lang');
6716
+ }
6717
+ }
6718
+
6719
+ if (this.options.dir == null) {
6720
+ if ($e.prop('dir')) {
6721
+ this.options.dir = $e.prop('dir');
6722
+ } else if ($e.closest('[dir]').prop('dir')) {
6723
+ this.options.dir = $e.closest('[dir]').prop('dir');
6724
+ } else {
6725
+ this.options.dir = 'ltr';
6726
+ }
6727
+ }
6728
+
6729
+ $e.prop('disabled', this.options.disabled);
6730
+ $e.prop('multiple', this.options.multiple);
6731
+
6732
+ if ($e.data('select2Tags')) {
6733
+ if (this.options.debug && window.console && console.warn) {
6734
+ console.warn(
6735
+ 'Select2: The `data-select2-tags` attribute has been changed to ' +
6736
+ 'use the `data-data` and `data-tags="true"` attributes and will be ' +
6737
+ 'removed in future versions of Select2.'
6738
+ );
6739
+ }
6740
+
6741
+ $e.data('data', $e.data('select2Tags'));
6742
+ $e.data('tags', true);
6743
+ }
6744
+
6745
+ if ($e.data('ajaxUrl')) {
6746
+ if (this.options.debug && window.console && console.warn) {
6747
+ console.warn(
6748
+ 'Select2: The `data-ajax-url` attribute has been changed to ' +
6749
+ '`data-ajax--url` and support for the old attribute will be removed' +
6750
+ ' in future versions of Select2.'
6751
+ );
6752
+ }
6753
+
6754
+ $e.attr('ajax--url', $e.data('ajaxUrl'));
6755
+ $e.data('ajax--url', $e.data('ajaxUrl'));
6756
+ }
6757
+
6758
+ var dataset = {};
6759
+
6760
+ // Prefer the element's `dataset` attribute if it exists
6761
+ // jQuery 1.x does not correctly handle data attributes with multiple dashes
6762
+ if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
6763
+ dataset = $.extend(true, {}, $e[0].dataset, $e.data());
6764
+ } else {
6765
+ dataset = $e.data();
6766
+ }
6767
+
6768
+ var data = $.extend(true, {}, dataset);
6769
+
6770
+ data = Utils._convertData(data);
6771
+
6772
+ for (var key in data) {
6773
+ if ($.inArray(key, excludedData) > -1) {
6774
+ continue;
6775
+ }
6776
+
6777
+ if ($.isPlainObject(this.options[key])) {
6778
+ $.extend(this.options[key], data[key]);
6779
+ } else {
6780
+ this.options[key] = data[key];
6781
+ }
6782
+ }
6783
+
6784
+ return this;
6785
+ };
6786
+
6787
+ Options.prototype.get = function (key) {
6788
+ return this.options[key];
6789
+ };
6790
+
6791
+ Options.prototype.set = function (key, val) {
6792
+ this.options[key] = val;
6793
+ };
6794
+
6795
+ return Options;
6796
+ });
6797
+
6798
+ S2.define('select2/core',[
6799
+ 'jquery',
6800
+ './options',
6801
+ './utils',
6802
+ './keys'
6803
+ ], function ($, Options, Utils, KEYS) {
6804
+ var Select2 = function ($element, options) {
6805
+ if ($element.data('select2') != null) {
6806
+ $element.data('select2').destroy();
6807
+ }
6808
+
6809
+ this.$element = $element;
6810
+
6811
+ this.id = this._generateId($element);
6812
+
6813
+ options = options || {};
6814
+
6815
+ this.options = new Options(options, $element);
6816
+
6817
+ Select2.__super__.constructor.call(this);
6818
+
6819
+ // Set up the tabindex
6820
+
6821
+ var tabindex = $element.attr('tabindex') || 0;
6822
+ $element.data('old-tabindex', tabindex);
6823
+ $element.attr('tabindex', '-1');
6824
+
6825
+ // Set up containers and adapters
6826
+
6827
+ var DataAdapter = this.options.get('dataAdapter');
6828
+ this.dataAdapter = new DataAdapter($element, this.options);
6829
+
6830
+ var $container = this.render();
6831
+
6832
+ this._placeContainer($container);
6833
+
6834
+ var SelectionAdapter = this.options.get('selectionAdapter');
6835
+ this.selection = new SelectionAdapter($element, this.options);
6836
+ this.$selection = this.selection.render();
6837
+
6838
+ this.selection.position(this.$selection, $container);
6839
+
6840
+ var DropdownAdapter = this.options.get('dropdownAdapter');
6841
+ this.dropdown = new DropdownAdapter($element, this.options);
6842
+ this.$dropdown = this.dropdown.render();
6843
+
6844
+ this.dropdown.position(this.$dropdown, $container);
6845
+
6846
+ var ResultsAdapter = this.options.get('resultsAdapter');
6847
+ this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
6848
+ this.$results = this.results.render();
6849
+
6850
+ this.results.position(this.$results, this.$dropdown);
6851
+
6852
+ // Bind events
6853
+
6854
+ var self = this;
6855
+
6856
+ // Bind the container to all of the adapters
6857
+ this._bindAdapters();
6858
+
6859
+ // Register any DOM event handlers
6860
+ this._registerDomEvents();
6861
+
6862
+ // Register any internal event handlers
6863
+ this._registerDataEvents();
6864
+ this._registerSelectionEvents();
6865
+ this._registerDropdownEvents();
6866
+ this._registerResultsEvents();
6867
+ this._registerEvents();
6868
+
6869
+ // Set the initial state
6870
+ this.dataAdapter.current(function (initialData) {
6871
+ self.trigger('selection:update', {
6872
+ data: initialData
6873
+ });
6874
+ });
6875
+
6876
+ // Hide the original select
6877
+ $element.addClass('select2-hidden-accessible');
6878
+ $element.attr('aria-hidden', 'true');
6879
+
6880
+ // Synchronize any monitored attributes
6881
+ this._syncAttributes();
6882
+
6883
+ $element.data('select2', this);
6884
+ };
6885
+
6886
+ Utils.Extend(Select2, Utils.Observable);
6887
+
6888
+ Select2.prototype._generateId = function ($element) {
6889
+ var id = '';
6890
+
6891
+ if ($element.attr('id') != null) {
6892
+ id = $element.attr('id');
6893
+ } else if ($element.attr('name') != null) {
6894
+ id = $element.attr('name') + '-' + Utils.generateChars(2);
6895
+ } else {
6896
+ id = Utils.generateChars(4);
6897
+ }
6898
+
6899
+ id = id.replace(/(:|\.|\[|\]|,)/g, '');
6900
+ id = 'select2-' + id;
6901
+
6902
+ return id;
6903
+ };
6904
+
6905
+ Select2.prototype._placeContainer = function ($container) {
6906
+ $container.insertAfter(this.$element);
6907
+
6908
+ var width = this._resolveWidth(this.$element, this.options.get('width'));
6909
+
6910
+ if (width != null) {
6911
+ $container.css('width', width);
6912
+ }
6913
+ };
6914
+
6915
+ Select2.prototype._resolveWidth = function ($element, method) {
6916
+ var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
6917
+
6918
+ if (method == 'resolve') {
6919
+ var styleWidth = this._resolveWidth($element, 'style');
6920
+
6921
+ if (styleWidth != null) {
6922
+ return styleWidth;
6923
+ }
6924
+
6925
+ return this._resolveWidth($element, 'element');
6926
+ }
6927
+
6928
+ if (method == 'element') {
6929
+ var elementWidth = $element.outerWidth(false);
6930
+
6931
+ if (elementWidth <= 0) {
6932
+ return 'auto';
6933
+ }
6934
+
6935
+ return elementWidth + 'px';
6936
+ }
6937
+
6938
+ if (method == 'style') {
6939
+ var style = $element.attr('style');
6940
+
6941
+ if (typeof(style) !== 'string') {
6942
+ return null;
6943
+ }
6944
+
6945
+ var attrs = style.split(';');
6946
+
6947
+ for (var i = 0, l = attrs.length; i < l; i = i + 1) {
6948
+ var attr = attrs[i].replace(/\s/g, '');
6949
+ var matches = attr.match(WIDTH);
6950
+
6951
+ if (matches !== null && matches.length >= 1) {
6952
+ return matches[1];
6953
+ }
6954
+ }
6955
+
6956
+ return null;
6957
+ }
6958
+
6959
+ return method;
6960
+ };
6961
+
6962
+ Select2.prototype._bindAdapters = function () {
6963
+ this.dataAdapter.bind(this, this.$container);
6964
+ this.selection.bind(this, this.$container);
6965
+
6966
+ this.dropdown.bind(this, this.$container);
6967
+ this.results.bind(this, this.$container);
6968
+ };
6969
+
6970
+ Select2.prototype._registerDomEvents = function () {
6971
+ var self = this;
6972
+
6973
+ this.$element.on('change.select2', function () {
6974
+ self.dataAdapter.current(function (data) {
6975
+ self.trigger('selection:update', {
6976
+ data: data
6977
+ });
6978
+ });
6979
+ });
6980
+
6981
+ this.$element.on('focus.select2', function (evt) {
6982
+ self.trigger('focus', evt);
6983
+ });
6984
+
6985
+ this._syncA = Utils.bind(this._syncAttributes, this);
6986
+ this._syncS = Utils.bind(this._syncSubtree, this);
6987
+
6988
+ if (this.$element[0].attachEvent) {
6989
+ this.$element[0].attachEvent('onpropertychange', this._syncA);
6990
+ }
6991
+
6992
+ var observer = window.MutationObserver ||
6993
+ window.WebKitMutationObserver ||
6994
+ window.MozMutationObserver
6995
+ ;
6996
+
6997
+ if (observer != null) {
6998
+ this._observer = new observer(function (mutations) {
6999
+ $.each(mutations, self._syncA);
7000
+ $.each(mutations, self._syncS);
7001
+ });
7002
+ this._observer.observe(this.$element[0], {
7003
+ attributes: true,
7004
+ childList: true,
7005
+ subtree: false
7006
+ });
7007
+ } else if (this.$element[0].addEventListener) {
7008
+ this.$element[0].addEventListener(
7009
+ 'DOMAttrModified',
7010
+ self._syncA,
7011
+ false
7012
+ );
7013
+ this.$element[0].addEventListener(
7014
+ 'DOMNodeInserted',
7015
+ self._syncS,
7016
+ false
7017
+ );
7018
+ this.$element[0].addEventListener(
7019
+ 'DOMNodeRemoved',
7020
+ self._syncS,
7021
+ false
7022
+ );
7023
+ }
7024
+ };
7025
+
7026
+ Select2.prototype._registerDataEvents = function () {
7027
+ var self = this;
7028
+
7029
+ this.dataAdapter.on('*', function (name, params) {
7030
+ self.trigger(name, params);
7031
+ });
7032
+ };
7033
+
7034
+ Select2.prototype._registerSelectionEvents = function () {
7035
+ var self = this;
7036
+ var nonRelayEvents = ['toggle', 'focus'];
7037
+
7038
+ this.selection.on('toggle', function () {
7039
+ self.toggleDropdown();
7040
+ });
7041
+
7042
+ this.selection.on('focus', function (params) {
7043
+ self.focus(params);
7044
+ });
7045
+
7046
+ this.selection.on('*', function (name, params) {
7047
+ if ($.inArray(name, nonRelayEvents) !== -1) {
7048
+ return;
7049
+ }
7050
+
7051
+ self.trigger(name, params);
7052
+ });
7053
+ };
7054
+
7055
+ Select2.prototype._registerDropdownEvents = function () {
7056
+ var self = this;
7057
+
7058
+ this.dropdown.on('*', function (name, params) {
7059
+ self.trigger(name, params);
7060
+ });
7061
+ };
7062
+
7063
+ Select2.prototype._registerResultsEvents = function () {
7064
+ var self = this;
7065
+
7066
+ this.results.on('*', function (name, params) {
7067
+ self.trigger(name, params);
7068
+ });
7069
+ };
7070
+
7071
+ Select2.prototype._registerEvents = function () {
7072
+ var self = this;
7073
+
7074
+ this.on('open', function () {
7075
+ self.$container.addClass('select2-container--open');
7076
+ });
7077
+
7078
+ this.on('close', function () {
7079
+ self.$container.removeClass('select2-container--open');
7080
+ });
7081
+
7082
+ this.on('enable', function () {
7083
+ self.$container.removeClass('select2-container--disabled');
7084
+ });
7085
+
7086
+ this.on('disable', function () {
7087
+ self.$container.addClass('select2-container--disabled');
7088
+ });
7089
+
7090
+ this.on('blur', function () {
7091
+ self.$container.removeClass('select2-container--focus');
7092
+ });
7093
+
7094
+ this.on('query', function (params) {
7095
+ if (!self.isOpen()) {
7096
+ self.trigger('open', {});
7097
+ }
7098
+
7099
+ this.dataAdapter.query(params, function (data) {
7100
+ self.trigger('results:all', {
7101
+ data: data,
7102
+ query: params
7103
+ });
7104
+ });
7105
+ });
7106
+
7107
+ this.on('query:append', function (params) {
7108
+ this.dataAdapter.query(params, function (data) {
7109
+ self.trigger('results:append', {
7110
+ data: data,
7111
+ query: params
7112
+ });
7113
+ });
7114
+ });
7115
+
7116
+ this.on('keypress', function (evt) {
7117
+ var key = evt.which;
7118
+
7119
+ if (self.isOpen()) {
7120
+ if (key === KEYS.ESC || key === KEYS.TAB ||
7121
+ (key === KEYS.UP && evt.altKey)) {
7122
+ self.close();
7123
+
7124
+ evt.preventDefault();
7125
+ } else if (key === KEYS.ENTER) {
7126
+ self.trigger('results:select', {});
7127
+
7128
+ evt.preventDefault();
7129
+ } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
7130
+ self.trigger('results:toggle', {});
7131
+
7132
+ evt.preventDefault();
7133
+ } else if (key === KEYS.UP) {
7134
+ self.trigger('results:previous', {});
7135
+
7136
+ evt.preventDefault();
7137
+ } else if (key === KEYS.DOWN) {
7138
+ self.trigger('results:next', {});
7139
+
7140
+ evt.preventDefault();
7141
+ }
7142
+ } else {
7143
+ if (key === KEYS.ENTER || key === KEYS.SPACE ||
7144
+ (key === KEYS.DOWN && evt.altKey)) {
7145
+ self.open();
7146
+
7147
+ evt.preventDefault();
7148
+ }
7149
+ }
7150
+ });
7151
+ };
7152
+
7153
+ Select2.prototype._syncAttributes = function () {
7154
+ this.options.set('disabled', this.$element.prop('disabled'));
7155
+
7156
+ if (this.options.get('disabled')) {
7157
+ if (this.isOpen()) {
7158
+ this.close();
7159
+ }
7160
+
7161
+ this.trigger('disable', {});
7162
+ } else {
7163
+ this.trigger('enable', {});
7164
+ }
7165
+ };
7166
+
7167
+ Select2.prototype._syncSubtree = function (evt, mutations) {
7168
+ var changed = false;
7169
+ var self = this;
7170
+
7171
+ // Ignore any mutation events raised for elements that aren't options or
7172
+ // optgroups. This handles the case when the select element is destroyed
7173
+ if (
7174
+ evt && evt.target && (
7175
+ evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
7176
+ )
7177
+ ) {
7178
+ return;
7179
+ }
7180
+
7181
+ if (!mutations) {
7182
+ // If mutation events aren't supported, then we can only assume that the
7183
+ // change affected the selections
7184
+ changed = true;
7185
+ } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
7186
+ for (var n = 0; n < mutations.addedNodes.length; n++) {
7187
+ var node = mutations.addedNodes[n];
7188
+
7189
+ if (node.selected) {
7190
+ changed = true;
7191
+ }
7192
+ }
7193
+ } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
7194
+ changed = true;
7195
+ }
7196
+
7197
+ // Only re-pull the data if we think there is a change
7198
+ if (changed) {
7199
+ this.dataAdapter.current(function (currentData) {
7200
+ self.trigger('selection:update', {
7201
+ data: currentData
7202
+ });
7203
+ });
7204
+ }
7205
+ };
7206
+
7207
+ /**
7208
+ * Override the trigger method to automatically trigger pre-events when
7209
+ * there are events that can be prevented.
7210
+ */
7211
+ Select2.prototype.trigger = function (name, args) {
7212
+ var actualTrigger = Select2.__super__.trigger;
7213
+ var preTriggerMap = {
7214
+ 'open': 'opening',
7215
+ 'close': 'closing',
7216
+ 'select': 'selecting',
7217
+ 'unselect': 'unselecting'
7218
+ };
7219
+
7220
+ if (args === undefined) {
7221
+ args = {};
7222
+ }
7223
+
7224
+ if (name in preTriggerMap) {
7225
+ var preTriggerName = preTriggerMap[name];
7226
+ var preTriggerArgs = {
7227
+ prevented: false,
7228
+ name: name,
7229
+ args: args
7230
+ };
7231
+
7232
+ actualTrigger.call(this, preTriggerName, preTriggerArgs);
7233
+
7234
+ if (preTriggerArgs.prevented) {
7235
+ args.prevented = true;
7236
+
7237
+ return;
7238
+ }
7239
+ }
7240
+
7241
+ actualTrigger.call(this, name, args);
7242
+ };
7243
+
7244
+ Select2.prototype.toggleDropdown = function () {
7245
+ if (this.options.get('disabled')) {
7246
+ return;
7247
+ }
7248
+
7249
+ if (this.isOpen()) {
7250
+ this.close();
7251
+ } else {
7252
+ this.open();
7253
+ }
7254
+ };
7255
+
7256
+ Select2.prototype.open = function () {
7257
+ if (this.isOpen()) {
7258
+ return;
7259
+ }
7260
+
7261
+ this.trigger('query', {});
7262
+ };
7263
+
7264
+ Select2.prototype.close = function () {
7265
+ if (!this.isOpen()) {
7266
+ return;
7267
+ }
7268
+
7269
+ this.trigger('close', {});
7270
+ };
7271
+
7272
+ Select2.prototype.isOpen = function () {
7273
+ return this.$container.hasClass('select2-container--open');
7274
+ };
7275
+
7276
+ Select2.prototype.hasFocus = function () {
7277
+ return this.$container.hasClass('select2-container--focus');
7278
+ };
7279
+
7280
+ Select2.prototype.focus = function (data) {
7281
+ // No need to re-trigger focus events if we are already focused
7282
+ if (this.hasFocus()) {
7283
+ return;
7284
+ }
7285
+
7286
+ this.$container.addClass('select2-container--focus');
7287
+ this.trigger('focus', {});
7288
+ };
7289
+
7290
+ Select2.prototype.enable = function (args) {
7291
+ if (this.options.get('debug') && window.console && console.warn) {
7292
+ console.warn(
7293
+ 'Select2: The `select2("enable")` method has been deprecated and will' +
7294
+ ' be removed in later Select2 versions. Use $element.prop("disabled")' +
7295
+ ' instead.'
7296
+ );
7297
+ }
7298
+
7299
+ if (args == null || args.length === 0) {
7300
+ args = [true];
7301
+ }
7302
+
7303
+ var disabled = !args[0];
7304
+
7305
+ this.$element.prop('disabled', disabled);
7306
+ };
7307
+
7308
+ Select2.prototype.data = function () {
7309
+ if (this.options.get('debug') &&
7310
+ arguments.length > 0 && window.console && console.warn) {
7311
+ console.warn(
7312
+ 'Select2: Data can no longer be set using `select2("data")`. You ' +
7313
+ 'should consider setting the value instead using `$element.val()`.'
7314
+ );
7315
+ }
7316
+
7317
+ var data = [];
7318
+
7319
+ this.dataAdapter.current(function (currentData) {
7320
+ data = currentData;
7321
+ });
7322
+
7323
+ return data;
7324
+ };
7325
+
7326
+ Select2.prototype.val = function (args) {
7327
+ if (this.options.get('debug') && window.console && console.warn) {
7328
+ console.warn(
7329
+ 'Select2: The `select2("val")` method has been deprecated and will be' +
7330
+ ' removed in later Select2 versions. Use $element.val() instead.'
7331
+ );
7332
+ }
7333
+
7334
+ if (args == null || args.length === 0) {
7335
+ return this.$element.val();
7336
+ }
7337
+
7338
+ var newVal = args[0];
7339
+
7340
+ if ($.isArray(newVal)) {
7341
+ newVal = $.map(newVal, function (obj) {
7342
+ return obj.toString();
7343
+ });
7344
+ }
7345
+
7346
+ this.$element.val(newVal).trigger('change');
7347
+ };
7348
+
7349
+ Select2.prototype.destroy = function () {
7350
+ this.$container.remove();
7351
+
7352
+ if (this.$element[0].detachEvent) {
7353
+ this.$element[0].detachEvent('onpropertychange', this._syncA);
7354
+ }
7355
+
7356
+ if (this._observer != null) {
7357
+ this._observer.disconnect();
7358
+ this._observer = null;
7359
+ } else if (this.$element[0].removeEventListener) {
7360
+ this.$element[0]
7361
+ .removeEventListener('DOMAttrModified', this._syncA, false);
7362
+ this.$element[0]
7363
+ .removeEventListener('DOMNodeInserted', this._syncS, false);
7364
+ this.$element[0]
7365
+ .removeEventListener('DOMNodeRemoved', this._syncS, false);
7366
+ }
7367
+
7368
+ this._syncA = null;
7369
+ this._syncS = null;
7370
+
7371
+ this.$element.off('.select2');
7372
+ this.$element.attr('tabindex', this.$element.data('old-tabindex'));
7373
+
7374
+ this.$element.removeClass('select2-hidden-accessible');
7375
+ this.$element.attr('aria-hidden', 'false');
7376
+ this.$element.removeData('select2');
7377
+
7378
+ this.dataAdapter.destroy();
7379
+ this.selection.destroy();
7380
+ this.dropdown.destroy();
7381
+ this.results.destroy();
7382
+
7383
+ this.dataAdapter = null;
7384
+ this.selection = null;
7385
+ this.dropdown = null;
7386
+ this.results = null;
7387
+ };
7388
+
7389
+ Select2.prototype.render = function () {
7390
+ var $container = $(
7391
+ '<span class="select2 select2-container">' +
7392
+ '<span class="selection"></span>' +
7393
+ '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
7394
+ '</span>'
7395
+ );
7396
+
7397
+ $container.attr('dir', this.options.get('dir'));
7398
+
7399
+ this.$container = $container;
7400
+
7401
+ this.$container.addClass('select2-container--' + this.options.get('theme'));
7402
+
7403
+ $container.data('element', this.$element);
7404
+
7405
+ return $container;
7406
+ };
7407
+
7408
+ return Select2;
7409
+ });
7410
+
7411
+ S2.define('jquery-mousewheel',[
7412
+ 'jquery'
7413
+ ], function ($) {
7414
+ // Used to shim jQuery.mousewheel for non-full builds.
7415
+ return $;
7416
+ });
7417
+
7418
+ S2.define('jquery.select2',[
7419
+ 'jquery',
7420
+ 'jquery-mousewheel',
7421
+
7422
+ './select2/core',
7423
+ './select2/defaults'
7424
+ ], function ($, _, Select2, Defaults) {
7425
+ if ($.fn.select2 == null) {
7426
+ // All methods that should return the element
7427
+ var thisMethods = ['open', 'close', 'destroy'];
7428
+
7429
+ $.fn.select2 = function (options) {
7430
+ options = options || {};
7431
+
7432
+ if (typeof options === 'object') {
7433
+ this.each(function () {
7434
+ var instanceOptions = $.extend(true, {}, options);
7435
+
7436
+ var instance = new Select2($(this), instanceOptions);
7437
+ });
7438
+
7439
+ return this;
7440
+ } else if (typeof options === 'string') {
7441
+ var ret;
7442
+ var args = Array.prototype.slice.call(arguments, 1);
7443
+
7444
+ this.each(function () {
7445
+ var instance = $(this).data('select2');
7446
+
7447
+ if (instance == null && window.console && console.error) {
7448
+ console.error(
7449
+ 'The select2(\'' + options + '\') method was called on an ' +
7450
+ 'element that is not using Select2.'
7451
+ );
7452
+ }
7453
+
7454
+ ret = instance[options].apply(instance, args);
7455
+ });
7456
+
7457
+ // Check if we should be returning `this`
7458
+ if ($.inArray(options, thisMethods) > -1) {
7459
+ return this;
7460
+ }
7461
+
7462
+ return ret;
7463
+ } else {
7464
+ throw new Error('Invalid arguments for Select2: ' + options);
7465
+ }
7466
+ };
7467
+ }
7468
+
7469
+ if ($.fn.select2.defaults == null) {
7470
+ $.fn.select2.defaults = Defaults;
7471
+ }
7472
+
7473
+ return Select2;
7474
+ });
7475
+
7476
+ // Return the AMD loader configuration so it can be used outside of this file
7477
+ return {
7478
+ define: S2.define,
7479
+ require: S2.require
7480
+ };
7481
+ }());
7482
+
7483
+ // Autoload the jQuery bindings
7484
+ // We know that all of the modules exist above this, so we're safe
7485
+ var select2 = S2.require('jquery.select2');
7486
+
7487
+ // Hold the AMD module references on the jQuery function that was just loaded
7488
+ // This allows Select2 to use the internal loader outside of this file, such
7489
+ // as in the language files.
7490
+ jQuery.fn.select2.amd = S2;
7491
+
7492
+ // Return the Select2 instance for anyone who is importing it.
7493
+ return select2;
7494
+ }));
7495
 
7496
 
7497
  /***/ },
assets/js/{public.820cdc99.js → public.8173fe64.js} RENAMED
@@ -1816,7 +1816,7 @@
1816
  * Dual licensed under the MIT and GPL licenses.
1817
  * http://benalman.com/about/license/
1818
  */
1819
- $.fn.serializeObject = function (coerce) {
1820
  var obj = {};
1821
  var coerce_types = { true: !0, false: !1, null: null };
1822
 
@@ -1936,7 +1936,7 @@
1936
  });
1937
 
1938
  form.parsley().on('form:submit', function (parsley) {
1939
- var form_data = form.serializeObject() || {};
1940
  // check if we're on the same domain
1941
  if (isSameDomain(window.MailPoetForm.ajax_url) === false) {
1942
  // non ajax post request
1816
  * Dual licensed under the MIT and GPL licenses.
1817
  * http://benalman.com/about/license/
1818
  */
1819
+ $.fn.mailpoetSerializeObject = function (coerce) {
1820
  var obj = {};
1821
  var coerce_types = { true: !0, false: !1, null: null };
1822
 
1936
  });
1937
 
1938
  form.parsley().on('form:submit', function (parsley) {
1939
+ var form_data = form.mailpoetSerializeObject() || {};
1940
  // check if we're on the same domain
1941
  if (isSameDomain(window.MailPoetForm.ajax_url) === false) {
1942
  // non ajax post request
assets/js/{vendor.f03e722d.js → vendor.17b09b6c.js} RENAMED
@@ -76,7 +76,7 @@
76
  /******/ script.charset = 'utf-8';
77
  /******/ script.async = true;
78
 
79
- /******/ script.src = __webpack_require__.p + "" + ({"0":"admin","1":"admin_vendor","2":"form_editor","3":"mailpoet","4":"newsletter_editor"}[chunkId]||chunkId) + "." + {"0":"7f0a02d1","1":"fa2d1dd7","2":"28c23e1a","3":"6fead39d","4":"e7c440c6"}[chunkId] + ".chunk.js";
80
  /******/ head.appendChild(script);
81
  /******/ }
82
  /******/ };
76
  /******/ script.charset = 'utf-8';
77
  /******/ script.async = true;
78
 
79
+ /******/ script.src = __webpack_require__.p + "" + ({"0":"admin","1":"admin_vendor","2":"form_editor","3":"mailpoet","4":"newsletter_editor"}[chunkId]||chunkId) + "." + {"0":"912a26a8","1":"66f57ed3","2":"612beb34","3":"3dd11c86","4":"c4722da5"}[chunkId] + ".chunk.js";
80
  /******/ head.appendChild(script);
81
  /******/ }
82
  /******/ };
lang/index.php CHANGED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+
3
+ // Silence is golden
lang/mailpoet-ca.mo CHANGED
Binary file
lang/mailpoet-da_DK.mo CHANGED
Binary file
lang/mailpoet-de_DE.mo CHANGED
Binary file
lang/mailpoet-en_GB.mo CHANGED
Binary file
lang/mailpoet-es_ES.mo CHANGED
Binary file
lang/mailpoet-fa_IR.mo CHANGED
Binary file
lang/mailpoet-fr_CA.mo CHANGED
Binary file
lang/mailpoet-fr_FR.mo CHANGED
Binary file
lang/mailpoet-it_IT.mo CHANGED
Binary file
lang/mailpoet-ja.mo CHANGED
Binary file
lang/mailpoet-nl_NL.mo CHANGED
Binary file
lang/mailpoet-pl_PL.mo CHANGED
Binary file
lang/mailpoet-pt_BR.mo CHANGED
Binary file
lang/mailpoet-pt_PT.mo CHANGED
Binary file
lang/mailpoet-ru_RU.mo CHANGED
Binary file
lang/mailpoet-sv_SE.mo CHANGED
Binary file
lang/mailpoet-tr_TR.mo CHANGED
Binary file
lang/mailpoet.pot CHANGED
@@ -4,7 +4,7 @@ msgid ""
4
  msgstr ""
5
  "Project-Id-Version: \n"
6
  "Report-Msgid-Bugs-To: http://support.mailpoet.com/\n"
7
- "POT-Creation-Date: 2017-10-24 10:09:38+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -82,6 +82,7 @@ msgid "Email"
82
  msgstr ""
83
 
84
  #: lib/API/JSON/v1/Forms.php:80
 
85
  msgid "Submit"
86
  msgstr ""
87
 
@@ -438,7 +439,7 @@ msgid "Premium"
438
  msgstr ""
439
 
440
  #: lib/Config/Menu.php:276 lib/Config/Menu.php:277 views/update.html:16
441
- #: views/welcome.html:16
442
  msgid "Welcome"
443
  msgstr ""
444
 
@@ -1739,6 +1740,315 @@ msgid ""
1739
  "the plugin."
1740
  msgstr ""
1741
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1742
  #: views/form/editor.html:5
1743
  msgid "Form"
1744
  msgstr ""
@@ -5181,7 +5491,7 @@ msgstr ""
5181
  msgid "Greetings, humans."
5182
  msgstr ""
5183
 
5184
- #: views/update.html:8 views/welcome.html:8
5185
  msgid ""
5186
  "Thanks for using MailPoet! We really appreciate all of your love, "
5187
  "affection, [link]and (good) plugin reviews.[/link]"
@@ -5203,51 +5513,90 @@ msgstr ""
5203
  msgid "View all changes"
5204
  msgstr ""
5205
 
5206
- #: views/update.html:41
5207
  msgid "Do Your Part to Make MailPoet Better"
5208
  msgstr ""
5209
 
5210
- #: views/update.html:46
5211
  msgid "Yes, share my data anonymously."
5212
  msgstr ""
5213
 
5214
- #: views/update.html:49
5215
  msgid ""
5216
  "By sharing your data with us, you can help us understand what our users "
5217
  "like (and don't like)."
5218
  msgstr ""
5219
 
5220
- #: views/update.html:50
5221
  msgid "We use it to prioritize and develop new plugin features."
5222
  msgstr ""
5223
 
5224
- #: views/update.html:51
5225
  msgid ""
5226
  "Share your data to help shape the future of MailPoet! [link]Read "
5227
  "more.[/link]"
5228
  msgstr ""
5229
 
5230
- #: views/update.html:61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5231
  msgid "Care to Give Your Opinion?"
5232
  msgstr ""
5233
 
5234
- #: views/update.html:70 views/welcome.html:85
5235
  msgid "Awesome! Now, take me to MailPoet"
5236
  msgstr ""
5237
 
5238
- #: views/welcome.html:13
 
 
 
 
5239
  msgid "MailPoet Logo"
5240
  msgstr ""
5241
 
5242
- #: views/welcome.html:17
5243
  msgid "What's new"
5244
  msgstr ""
5245
 
5246
- #: views/welcome.html:23
5247
  msgid "Coming this Fall to a WordPress plugin page near you"
5248
  msgstr ""
5249
 
5250
- #: views/welcome.html:24
5251
  msgid ""
5252
  "The highly-anticipated sequel to Dead Poets Society, Introduction to "
5253
  "MailPoet will keep you on the edge of your seat. \"Five out of five "
@@ -5255,11 +5604,11 @@ msgid ""
5255
  "aspiring email poets.\""
5256
  msgstr ""
5257
 
5258
- #: views/welcome.html:27
5259
  msgid "But first, watch this video"
5260
  msgstr ""
5261
 
5262
- #: views/welcome.html:28
5263
  msgid ""
5264
  "Wait a second. Don't click that big blue button just yet. Yeah, we're "
5265
  "talking to you. Before you do anything, you should really watch this video. "
@@ -5268,11 +5617,11 @@ msgid ""
5268
  "after all..."
5269
  msgstr ""
5270
 
5271
- #: views/welcome.html:31
5272
  msgid "Explanatory videos are boring, we know"
5273
  msgstr ""
5274
 
5275
- #: views/welcome.html:32
5276
  msgid ""
5277
  "But this video is really important! We promise. Over the course of three "
5278
  "minutes, you'll learn how to send your first newsletter, manage your lists, "
@@ -5280,67 +5629,38 @@ msgid ""
5280
  "that good. So get watching."
5281
  msgstr ""
5282
 
5283
- #: views/welcome.html:44
5284
- msgid "Want to Make MailPoet Even Better?"
5285
- msgstr ""
5286
-
5287
- #: views/welcome.html:46
5288
  msgid "Documentation Is One Click Away"
5289
  msgstr ""
5290
 
5291
- #: views/welcome.html:47
5292
  msgid ""
5293
  "Simply click on the blue circle in the bottom right corner of any of the "
5294
  "MailPoet pages to access our documentation."
5295
  msgstr ""
5296
 
5297
- #: views/welcome.html:47
5298
  msgid "Voilà!"
5299
  msgstr ""
5300
 
5301
- #: views/welcome.html:50
5302
  msgid "Sharing is Caring"
5303
  msgstr ""
5304
 
5305
- #: views/welcome.html:51
5306
  msgid ""
5307
  "By sharing your data <i>anonymously</i> with us, you can help us understand "
5308
  "how people use MailPoet and what sort of features they like and don't like."
5309
  msgstr ""
5310
 
5311
- #: views/welcome.html:51
5312
  msgid "Find out more"
5313
  msgstr ""
5314
 
5315
- #: views/welcome.html:56
5316
  msgid "Yes, I want to help!"
5317
  msgstr ""
5318
 
5319
- #: views/welcome.html:66 views/welcome.html:70
5320
- msgid "Subscribe To Our Newsletter"
5321
- msgstr ""
5322
-
5323
- #: views/welcome.html:67
5324
- msgid "About once a month, we send out a pretty cool newsletter ourselves."
5325
- msgstr ""
5326
-
5327
- #: views/welcome.html:68
5328
- msgid ""
5329
- "Sign up to get a curated selection of awesome links, tips and tricks for "
5330
- "using MailPoet, special offers, and important plugin updates!"
5331
- msgstr ""
5332
-
5333
- #: views/welcome.html:74
5334
- msgid "Learn the Ropes"
5335
- msgstr ""
5336
-
5337
- #: views/welcome.html:75
5338
- msgid ""
5339
- "New to MailPoet? Check out our brand new email course. Over the course of a "
5340
- "week, we'll teach you how to create and send your first MailPoet email "
5341
- "newsletter. Sign up below!"
5342
- msgstr ""
5343
-
5344
  #: lib/API/JSON/v1/Services.php:144
5345
  msgctxt "Error code (inside parentheses)"
5346
  msgid "code: %s"
@@ -5366,6 +5686,18 @@ msgctxt "segments per page (screen options)"
5366
  msgid "Number of segments per page"
5367
  msgstr ""
5368
 
 
 
 
 
 
 
 
 
 
 
 
 
5369
  #: views/form/templates/settings/field_form.hbs:37
5370
  msgctxt "Form input type"
5371
  msgid "Select"
4
  msgstr ""
5
  "Project-Id-Version: \n"
6
  "Report-Msgid-Bugs-To: http://support.mailpoet.com/\n"
7
+ "POT-Creation-Date: 2017-10-31 16:04:34+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
82
  msgstr ""
83
 
84
  #: lib/API/JSON/v1/Forms.php:80
85
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:284
86
  msgid "Submit"
87
  msgstr ""
88
 
439
  msgstr ""
440
 
441
  #: lib/Config/Menu.php:276 lib/Config/Menu.php:277 views/update.html:16
442
+ #: views/welcome.html:12
443
  msgid "Welcome"
444
  msgstr ""
445
 
1740
  "the plugin."
1741
  msgstr ""
1742
 
1743
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/internationalized-plugin.php:11
1744
+ msgid "This is a dummy plugin"
1745
+ msgstr ""
1746
+
1747
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:42
1748
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:72
1749
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:80
1750
+ msgid "There was an error when reading this WXR file"
1751
+ msgstr ""
1752
+
1753
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:43
1754
+ msgid ""
1755
+ "Details are shown above. The importer will now try again with a different "
1756
+ "parser..."
1757
+ msgstr ""
1758
+
1759
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:84
1760
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:89
1761
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:306
1762
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:495
1763
+ msgid "This does not appear to be a WXR file, missing/invalid WXR version number"
1764
+ msgstr ""
1765
+
1766
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:132
1767
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:141
1768
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:192
1769
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:196
1770
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:205
1771
+ msgid "Sorry, there has been an error."
1772
+ msgstr ""
1773
+
1774
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:133
1775
+ msgid "The file does not exist, please try again."
1776
+ msgstr ""
1777
+
1778
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:176
1779
+ msgid "All done."
1780
+ msgstr ""
1781
+
1782
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:176
1783
+ msgid "Have fun!"
1784
+ msgstr ""
1785
+
1786
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:177
1787
+ msgid "Remember to update the passwords and roles of imported users."
1788
+ msgstr ""
1789
+
1790
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:197
1791
+ msgid ""
1792
+ "The export file could not be found at <code>%s</code>. It is likely that "
1793
+ "this was caused by a permissions problem."
1794
+ msgstr ""
1795
+
1796
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:213
1797
+ msgid ""
1798
+ "This WXR file (version %s) may not be supported by this version of the "
1799
+ "importer. Please consider updating."
1800
+ msgstr ""
1801
+
1802
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:238
1803
+ msgid ""
1804
+ "Failed to import author %s. Their posts will be attributed to the current "
1805
+ "user."
1806
+ msgstr ""
1807
+
1808
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:264
1809
+ msgid "Assign Authors"
1810
+ msgstr ""
1811
+
1812
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:265
1813
+ msgid ""
1814
+ "To make it easier for you to edit and save the imported content, you may "
1815
+ "want to reassign the author of the imported item to an existing user of "
1816
+ "this site. For example, you may want to import all the entries as "
1817
+ "<code>admin</code>s entries."
1818
+ msgstr ""
1819
+
1820
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:267
1821
+ msgid ""
1822
+ "If a new user is created by WordPress, a new password will be randomly "
1823
+ "generated and the new user&#8217;s role will be set as %s. Manually "
1824
+ "changing the new user&#8217;s details will be necessary."
1825
+ msgstr ""
1826
+
1827
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:277
1828
+ msgid "Import Attachments"
1829
+ msgstr ""
1830
+
1831
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:280
1832
+ msgid "Download and import file attachments"
1833
+ msgstr ""
1834
+
1835
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:297
1836
+ msgid "Import author:"
1837
+ msgstr ""
1838
+
1839
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:308
1840
+ msgid "or create new user with login name:"
1841
+ msgstr ""
1842
+
1843
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:311
1844
+ msgid "as a new user:"
1845
+ msgstr ""
1846
+
1847
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:319
1848
+ msgid "assign posts to an existing user:"
1849
+ msgstr ""
1850
+
1851
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:321
1852
+ msgid "or assign posts to an existing user:"
1853
+ msgstr ""
1854
+
1855
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:322
1856
+ msgid "- Select -"
1857
+ msgstr ""
1858
+
1859
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:372
1860
+ msgid ""
1861
+ "Failed to create new user for %s. Their posts will be attributed to the "
1862
+ "current user."
1863
+ msgstr ""
1864
+
1865
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:424
1866
+ msgid "Failed to import category %s"
1867
+ msgstr ""
1868
+
1869
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:467
1870
+ msgid "Failed to import post tag %s"
1871
+ msgstr ""
1872
+
1873
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:516
1874
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:738
1875
+ msgid "Failed to import %s %s"
1876
+ msgstr ""
1877
+
1878
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:605
1879
+ msgid "Failed to import &#8220;%s&#8221;: Invalid post type %s"
1880
+ msgstr ""
1881
+
1882
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:642
1883
+ msgid "%s &#8220;%s&#8221; already exists."
1884
+ msgstr ""
1885
+
1886
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:704
1887
+ msgid "Failed to import %s &#8220;%s&#8221;"
1888
+ msgstr ""
1889
+
1890
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:869
1891
+ msgid "Menu item skipped due to missing menu slug"
1892
+ msgstr ""
1893
+
1894
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:876
1895
+ msgid "Menu item skipped due to invalid menu slug: %s"
1896
+ msgstr ""
1897
+
1898
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:939
1899
+ msgid "Fetching attachments is not enabled"
1900
+ msgstr ""
1901
+
1902
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:952
1903
+ msgid "Invalid file type"
1904
+ msgstr ""
1905
+
1906
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:996
1907
+ msgid "Remote server did not respond"
1908
+ msgstr ""
1909
+
1910
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1002
1911
+ msgid "Remote server returned error response %1$d %2$s"
1912
+ msgstr ""
1913
+
1914
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1009
1915
+ msgid "Remote file is incorrect size"
1916
+ msgstr ""
1917
+
1918
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1014
1919
+ msgid "Zero size file downloaded"
1920
+ msgstr ""
1921
+
1922
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1020
1923
+ msgid "Remote file is too large, limit is %s"
1924
+ msgstr ""
1925
+
1926
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1119
1927
+ msgid "Import WordPress"
1928
+ msgstr ""
1929
+
1930
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1126
1931
+ msgid ""
1932
+ "A new version of this importer is available. Please update to version %s to "
1933
+ "ensure compatibility with newer export files."
1934
+ msgstr ""
1935
+
1936
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1141
1937
+ msgid ""
1938
+ "Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import "
1939
+ "the posts, pages, comments, custom fields, categories, and tags into this "
1940
+ "site."
1941
+ msgstr ""
1942
+
1943
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1142
1944
+ msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
1945
+ msgstr ""
1946
+
1947
+ #: vendor_backup/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1216
1948
+ msgid ""
1949
+ "Import <strong>posts, pages, comments, custom fields, categories, and "
1950
+ "tags</strong> from a WordPress export file."
1951
+ msgstr ""
1952
+
1953
+ #: vendor_backup/lucatume/wp-browser/src/data/themedir1/internationalized-theme/functions.php:7
1954
+ msgid "This is a dummy theme"
1955
+ msgstr ""
1956
+
1957
+ #: vendor_backup/wp-cli/core-command/src/Core_Command.php:644
1958
+ msgid "Wildcard DNS may not be configured correctly."
1959
+ msgstr ""
1960
+
1961
+ #: vendor_backup/wp-cli/cron-command/src/Cron_Event_Command.php:428
1962
+ msgid "%s year"
1963
+ msgid_plural "%s years"
1964
+ msgstr[0] ""
1965
+ msgstr[1] ""
1966
+
1967
+ #: vendor_backup/wp-cli/cron-command/src/Cron_Event_Command.php:429
1968
+ msgid "%s month"
1969
+ msgid_plural "%s months"
1970
+ msgstr[0] ""
1971
+ msgstr[1] ""
1972
+
1973
+ #: vendor_backup/wp-cli/cron-command/src/Cron_Event_Command.php:430
1974
+ msgid "%s week"
1975
+ msgid_plural "%s weeks"
1976
+ msgstr[0] ""
1977
+ msgstr[1] ""
1978
+
1979
+ #: vendor_backup/wp-cli/cron-command/src/Cron_Event_Command.php:431
1980
+ msgid "%s day"
1981
+ msgid_plural "%s days"
1982
+ msgstr[0] ""
1983
+ msgstr[1] ""
1984
+
1985
+ #: vendor_backup/wp-cli/cron-command/src/Cron_Event_Command.php:432
1986
+ msgid "%s hour"
1987
+ msgid_plural "%s hours"
1988
+ msgstr[0] ""
1989
+ msgstr[1] ""
1990
+
1991
+ #: vendor_backup/wp-cli/cron-command/src/Cron_Event_Command.php:433
1992
+ msgid "%s minute"
1993
+ msgid_plural "%s minutes"
1994
+ msgstr[0] ""
1995
+ msgstr[1] ""
1996
+
1997
+ #: vendor_backup/wp-cli/cron-command/src/Cron_Event_Command.php:434
1998
+ msgid "%s second"
1999
+ msgid_plural "%s seconds"
2000
+ msgstr[0] ""
2001
+ msgstr[1] ""
2002
+
2003
+ #: vendor_backup/wp-cli/entity-command/src/Site_Command.php:118
2004
+ msgid "Uncategorized"
2005
+ msgstr ""
2006
+
2007
+ #: vendor_backup/wp-cli/export-command/src/Export_Command.php:324
2008
+ msgid "Invalid start ID: %d"
2009
+ msgstr ""
2010
+
2011
+ #: vendor_backup/wp-cli/export-command/src/WP_Export_File_Writer.php:15
2012
+ #: vendor_backup/wp-cli/export-command/src/WP_Export_Split_Files_Writer.php:63
2013
+ msgid "WP Export: error opening %s for writing."
2014
+ msgstr ""
2015
+
2016
+ #: vendor_backup/wp-cli/export-command/src/WP_Export_File_Writer.php:32
2017
+ #: vendor_backup/wp-cli/export-command/src/WP_Export_Split_Files_Writer.php:51
2018
+ msgid "WP Export: error writing to export file."
2019
+ msgstr ""
2020
+
2021
+ #: vendor_backup/wp-cli/export-command/src/WP_Export_Query.php:337
2022
+ msgid "Term is missing a parent: %s (%d)"
2023
+ msgstr ""
2024
+
2025
+ #: vendor_backup/wp-cli/export-command/src/WP_Export_XML_Over_HTTP.php:19
2026
+ #: vendor_backup/wp-cli/export-command/src/WP_Export_XML_Over_HTTP.php:23
2027
+ msgid "Export Error"
2028
+ msgstr ""
2029
+
2030
+ #: vendor_backup/wp-cli/extension-command/src/WP_CLI/CommandWithUpgrade.php:605
2031
+ msgid " Try again"
2032
+ msgstr ""
2033
+
2034
+ #: vendor_backup/wp-cli/extension-command/src/WP_CLI/CommandWithUpgrade.php:610
2035
+ msgid "API error. Try Again."
2036
+ msgstr ""
2037
+
2038
+ #: vendor_backup/wp-cli/media-command/src/Media_Command.php:129
2039
+ msgid "image"
2040
+ msgid_plural "images"
2041
+ msgstr[0] ""
2042
+ msgstr[1] ""
2043
+
2044
+ #: vendor_backup/wp-cli/wp-cli/php/utils-wp.php:171
2045
+ msgid "Inactive Widgets"
2046
+ msgstr ""
2047
+
2048
+ #: vendor_backup/wp-cli/wp-cli/php/utils-wp.php:174
2049
+ msgid "Drag widgets here to remove them from the sidebar but keep their settings."
2050
+ msgstr ""
2051
+
2052
  #: views/form/editor.html:5
2053
  msgid "Form"
2054
  msgstr ""
5491
  msgid "Greetings, humans."
5492
  msgstr ""
5493
 
5494
+ #: views/update.html:8
5495
  msgid ""
5496
  "Thanks for using MailPoet! We really appreciate all of your love, "
5497
  "affection, [link]and (good) plugin reviews.[/link]"
5513
  msgid "View all changes"
5514
  msgstr ""
5515
 
5516
+ #: views/update.html:42
5517
  msgid "Do Your Part to Make MailPoet Better"
5518
  msgstr ""
5519
 
5520
+ #: views/update.html:47
5521
  msgid "Yes, share my data anonymously."
5522
  msgstr ""
5523
 
5524
+ #: views/update.html:50
5525
  msgid ""
5526
  "By sharing your data with us, you can help us understand what our users "
5527
  "like (and don't like)."
5528
  msgstr ""
5529
 
5530
+ #: views/update.html:51
5531
  msgid "We use it to prioritize and develop new plugin features."
5532
  msgstr ""
5533
 
5534
+ #: views/update.html:52
5535
  msgid ""
5536
  "Share your data to help shape the future of MailPoet! [link]Read "
5537
  "more.[/link]"
5538
  msgstr ""
5539
 
5540
+ #: views/update.html:64 views/update.html:67
5541
+ msgid "Subscribe To Our Newsletter"
5542
+ msgstr ""
5543
+
5544
+ #: views/update.html:65
5545
+ msgid "About once a month, we send out a pretty cool newsletter ourselves."
5546
+ msgstr ""
5547
+
5548
+ #: views/update.html:66
5549
+ msgid ""
5550
+ "Sign up to get a curated selection of awesome links, tips and tricks for "
5551
+ "using MailPoet, special offers, and important plugin updates!"
5552
+ msgstr ""
5553
+
5554
+ #: views/update.html:74
5555
+ msgid "Learn the Ropes"
5556
+ msgstr ""
5557
+
5558
+ #: views/update.html:75
5559
+ msgid ""
5560
+ "New to MailPoet? Check out our brand new email course. Over the course of a "
5561
+ "week, we'll teach you how to create and send your first MailPoet email "
5562
+ "newsletter. Sign up below!"
5563
+ msgstr ""
5564
+
5565
+ #: views/update.html:83
5566
+ msgid "Leave a Review, Make Us Happy"
5567
+ msgstr ""
5568
+
5569
+ #: views/update.html:84
5570
+ msgid ""
5571
+ "We love to read reviews, either critical or positive. Take 3 minutes and "
5572
+ "make our day. [link]Write a review[/link]. :)"
5573
+ msgstr ""
5574
+
5575
+ #: views/update.html:95
5576
  msgid "Care to Give Your Opinion?"
5577
  msgstr ""
5578
 
5579
+ #: views/update.html:116 views/welcome.html:60
5580
  msgid "Awesome! Now, take me to MailPoet"
5581
  msgstr ""
5582
 
5583
+ #: views/welcome.html:8
5584
+ msgid "The new MailPoet. Simply better. And with regular updates."
5585
+ msgstr ""
5586
+
5587
+ #: views/welcome.html:9
5588
  msgid "MailPoet Logo"
5589
  msgstr ""
5590
 
5591
+ #: views/welcome.html:13
5592
  msgid "What's new"
5593
  msgstr ""
5594
 
5595
+ #: views/welcome.html:19
5596
  msgid "Coming this Fall to a WordPress plugin page near you"
5597
  msgstr ""
5598
 
5599
+ #: views/welcome.html:20
5600
  msgid ""
5601
  "The highly-anticipated sequel to Dead Poets Society, Introduction to "
5602
  "MailPoet will keep you on the edge of your seat. \"Five out of five "
5604
  "aspiring email poets.\""
5605
  msgstr ""
5606
 
5607
+ #: views/welcome.html:23
5608
  msgid "But first, watch this video"
5609
  msgstr ""
5610
 
5611
+ #: views/welcome.html:24
5612
  msgid ""
5613
  "Wait a second. Don't click that big blue button just yet. Yeah, we're "
5614
  "talking to you. Before you do anything, you should really watch this video. "
5617
  "after all..."
5618
  msgstr ""
5619
 
5620
+ #: views/welcome.html:27
5621
  msgid "Explanatory videos are boring, we know"
5622
  msgstr ""
5623
 
5624
+ #: views/welcome.html:28
5625
  msgid ""
5626
  "But this video is really important! We promise. Over the course of three "
5627
  "minutes, you'll learn how to send your first newsletter, manage your lists, "
5629
  "that good. So get watching."
5630
  msgstr ""
5631
 
5632
+ #: views/welcome.html:41
 
 
 
 
5633
  msgid "Documentation Is One Click Away"
5634
  msgstr ""
5635
 
5636
+ #: views/welcome.html:42
5637
  msgid ""
5638
  "Simply click on the blue circle in the bottom right corner of any of the "
5639
  "MailPoet pages to access our documentation."
5640
  msgstr ""
5641
 
5642
+ #: views/welcome.html:42
5643
  msgid "Voilà!"
5644
  msgstr ""
5645
 
5646
+ #: views/welcome.html:45
5647
  msgid "Sharing is Caring"
5648
  msgstr ""
5649
 
5650
+ #: views/welcome.html:46
5651
  msgid ""
5652
  "By sharing your data <i>anonymously</i> with us, you can help us understand "
5653
  "how people use MailPoet and what sort of features they like and don't like."
5654
  msgstr ""
5655
 
5656
+ #: views/welcome.html:46
5657
  msgid "Find out more"
5658
  msgstr ""
5659
 
5660
+ #: views/welcome.html:51
5661
  msgid "Yes, I want to help!"
5662
  msgstr ""
5663
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5664
  #: lib/API/JSON/v1/Services.php:144
5665
  msgctxt "Error code (inside parentheses)"
5666
  msgid "code: %s"
5686
  msgid "Number of segments per page"
5687
  msgstr ""
5688
 
5689
+ #: vendor_backup/wp-cli/core-command/src/Core_Command.php:427
5690
+ #: vendor_backup/wp-cli/core-command/src/Core_Command.php:500
5691
+ msgctxt "Default network name"
5692
+ msgid "%s Sites"
5693
+ msgstr ""
5694
+
5695
+ #: vendor_backup/wp-cli/entity-command/src/Site_Command.php:121
5696
+ #. translators: Default category slug
5697
+ msgctxt "Default category slug"
5698
+ msgid "Uncategorized"
5699
+ msgstr ""
5700
+
5701
  #: views/form/templates/settings/field_form.hbs:37
5702
  msgctxt "Form input type"
5703
  msgid "Select"
lib/Newsletter/Editor/MetaInformationManager.php CHANGED
@@ -43,7 +43,7 @@ class MetaInformationManager {
43
  // Get categories
44
  $categories = wp_get_post_terms(
45
  $post_id,
46
- array('post_tag', 'category'),
47
  array('fields' => 'names')
48
  );
49
  if(!empty($categories)) {
43
  // Get categories
44
  $categories = wp_get_post_terms(
45
  $post_id,
46
+ array('category'),
47
  array('fields' => 'names')
48
  );
49
  if(!empty($categories)) {
mailpoet.php CHANGED
@@ -3,8 +3,8 @@
3
  if(!defined('ABSPATH')) exit;
4
 
5
  /*
6
- * Plugin Name: MailPoet 3 (new)
7
- * Version: 3.0.8
8
  * Plugin URI: http://www.mailpoet.com
9
  * Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
10
  * Author: MailPoet
@@ -20,7 +20,7 @@ if(!defined('ABSPATH')) exit;
20
  */
21
 
22
  $mailpoet_plugin = array(
23
- 'version' => '3.0.8',
24
  'filename' => __FILE__,
25
  'path' => dirname(__FILE__),
26
  'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',
3
  if(!defined('ABSPATH')) exit;
4
 
5
  /*
6
+ * Plugin Name: MailPoet 3 (New)
7
+ * Version: 3.0.9
8
  * Plugin URI: http://www.mailpoet.com
9
  * Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
10
  * Author: MailPoet
20
  */
21
 
22
  $mailpoet_plugin = array(
23
+ 'version' => '3.0.9',
24
  'filename' => __FILE__,
25
  'path' => dirname(__FILE__),
26
  'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: newsletter, email, welcome email, post notification, autoresponder, signup
4
  Requires at least: 4.6
5
  Tested up to: 4.8
6
  Requires PHP: 5.3
7
- Stable tag: 3.0.8
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -114,6 +114,11 @@ Stop by our [support site](https://www.mailpoet.com/support).
114
 
115
  == Changelog ==
116
 
 
 
 
 
 
117
  = 3.0.8 - 2017-10-24 =
118
  * Improved: unsubscribe link now works in browser and email previews;
119
  * Improved: relative URLs in images are replaced by absolute URLs. Thanks Xavier!
4
  Requires at least: 4.6
5
  Tested up to: 4.8
6
  Requires PHP: 5.3
7
+ Stable tag: 3.0.9
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
114
 
115
  == Changelog ==
116
 
117
+ = 3.0.9 - 2017-10-31 =
118
+ * Improved: search forms in listings ignore preceding and trailing whitespace;
119
+ * Fixed: tags aren't shown within categories for automated latest content posts anymore. Thanks Gregor!
120
+ * Fixed: our subscription form no longer conflicts with themes/plugins that use jQuery Serialize Object function. Thanks Albert!
121
+
122
  = 3.0.8 - 2017-10-24 =
123
  * Improved: unsubscribe link now works in browser and email previews;
124
  * Improved: relative URLs in images are replaced by absolute URLs. Thanks Xavier!
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit89b5109a621c1c9ab7158823ea8308fa::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitf9d2a4b18144ddc75d068b570a0c9a57::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit89b5109a621c1c9ab7158823ea8308fa
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit89b5109a621c1c9ab7158823ea8308fa
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit89b5109a621c1c9ab7158823ea8308fa', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit89b5109a621c1c9ab7158823ea8308fa', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInit89b5109a621c1c9ab7158823ea8308fa::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit89b5109a621c1c9ab7158823ea8308fa
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInit89b5109a621c1c9ab7158823ea8308fa::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequire89b5109a621c1c9ab7158823ea8308fa($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequire89b5109a621c1c9ab7158823ea8308fa($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitf9d2a4b18144ddc75d068b570a0c9a57
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInitf9d2a4b18144ddc75d068b570a0c9a57', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitf9d2a4b18144ddc75d068b570a0c9a57', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInitf9d2a4b18144ddc75d068b570a0c9a57::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInitf9d2a4b18144ddc75d068b570a0c9a57::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequiref9d2a4b18144ddc75d068b570a0c9a57($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequiref9d2a4b18144ddc75d068b570a0c9a57($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit89b5109a621c1c9ab7158823ea8308fa
8
  {
9
  public static $files = array (
10
  '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@@ -840,10 +840,10 @@ class ComposerStaticInit89b5109a621c1c9ab7158823ea8308fa
840
  public static function getInitializer(ClassLoader $loader)
841
  {
842
  return \Closure::bind(function () use ($loader) {
843
- $loader->prefixLengthsPsr4 = ComposerStaticInit89b5109a621c1c9ab7158823ea8308fa::$prefixLengthsPsr4;
844
- $loader->prefixDirsPsr4 = ComposerStaticInit89b5109a621c1c9ab7158823ea8308fa::$prefixDirsPsr4;
845
- $loader->prefixesPsr0 = ComposerStaticInit89b5109a621c1c9ab7158823ea8308fa::$prefixesPsr0;
846
- $loader->classMap = ComposerStaticInit89b5109a621c1c9ab7158823ea8308fa::$classMap;
847
 
848
  }, null, ClassLoader::class);
849
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInitf9d2a4b18144ddc75d068b570a0c9a57
8
  {
9
  public static $files = array (
10
  '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
840
  public static function getInitializer(ClassLoader $loader)
841
  {
842
  return \Closure::bind(function () use ($loader) {
843
+ $loader->prefixLengthsPsr4 = ComposerStaticInitf9d2a4b18144ddc75d068b570a0c9a57::$prefixLengthsPsr4;
844
+ $loader->prefixDirsPsr4 = ComposerStaticInitf9d2a4b18144ddc75d068b570a0c9a57::$prefixDirsPsr4;
845
+ $loader->prefixesPsr0 = ComposerStaticInitf9d2a4b18144ddc75d068b570a0c9a57::$prefixesPsr0;
846
+ $loader->classMap = ComposerStaticInitf9d2a4b18144ddc75d068b570a0c9a57::$classMap;
847
 
848
  }, null, ClassLoader::class);
849
  }
views/form/templates/settings/field_form.hbs CHANGED
@@ -70,7 +70,7 @@
70
 
71
  $('#form_field_new').parsley().on('form:submit', function(parsley) {
72
  // get data
73
- var data = $(this.$element).serializeObject();
74
 
75
  // save custom field
76
  MailPoet.Ajax.post({
70
 
71
  $('#form_field_new').parsley().on('form:submit', function(parsley) {
72
  // get data
73
+ var data = $(this.$element).mailpoetSerializeObject();
74
 
75
  // save custom field
76
  MailPoet.Ajax.post({
views/settings.html CHANGED
@@ -80,7 +80,7 @@
80
 
81
  function saveSettings() {
82
  // serialize form data
83
- var settings_data = $('#mailpoet_settings_form').serializeObject();
84
 
85
  // show loading screen
86
  MailPoet.Modal.loading(true);
80
 
81
  function saveSettings() {
82
  // serialize form data
83
+ var settings_data = $('#mailpoet_settings_form').mailpoetSerializeObject();
84
 
85
  // show loading screen
86
  MailPoet.Modal.loading(true);
views/settings/mta.html CHANGED
@@ -699,7 +699,7 @@
699
  // get test email and include it in data
700
  var recipient = $('#mailpoet_mta_test_email').val();
701
 
702
- var settings = jQuery('#mailpoet_settings_form').serializeObject();
703
  var mailer = settings.mta;
704
 
705
  mailer.method = getMethodFromGroup($('#mta_group').val());
699
  // get test email and include it in data
700
  var recipient = $('#mailpoet_mta_test_email').val();
701
 
702
+ var settings = jQuery('#mailpoet_settings_form').mailpoetSerializeObject();
703
  var mailer = settings.mta;
704
 
705
  mailer.method = getMethodFromGroup($('#mta_group').val());
views/update.html CHANGED
@@ -35,33 +35,79 @@
35
  </div>
36
 
37
  <hr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
- <% if(not settings.analytics.enabled) %>
40
- <div class="feature-section one-col mailpoet_centered">
41
- <h2><%= __('Do Your Part to Make MailPoet Better') %></h2>
42
- <div class="lead-description">
 
 
 
 
 
43
 
44
- <label>
45
- <input type="checkbox" id="mailpoet_analytics_enabled" value="1">&nbsp;
46
- <%= __('Yes, share my data anonymously.') %>
47
- </label>
 
48
  </div>
49
- <p class="top-space-triple"><%= __("By sharing your data with us, you can help us understand what our users like (and don't like).") %>
50
- <%= __('We use it to prioritize and develop new plugin features.') %><br>
51
- <%= __('Share your data to help shape the future of MailPoet! [link]Read more.[/link]')
52
- |replaceLinkTags('http://beta.docs.mailpoet.com/article/130-sharing-your-data-with-us', {'target' : '_blank'})
 
 
 
 
53
  |raw
54
  %>
 
 
 
55
  </div>
56
-
57
- <hr>
58
- <% endif %>
59
 
60
  <div class="feature-section one-col mailpoet_centered">
61
  <h2><%= __('Care to Give Your Opinion?') %></h2>
62
 
63
- <script type="text/javascript" charset="utf-8" src="https://secure.polldaddy.com/p/9853786.js"></script>
64
- <noscript><a href="https://polldaddy.com/poll/9853786/">I installed this plugin because I...</a></noscript>
 
 
 
 
 
 
 
 
 
 
 
 
65
  </div>
66
 
67
  <hr>
@@ -97,7 +143,15 @@
97
  );
98
  }
99
  });
100
- })
 
 
 
 
 
 
 
 
101
  });
102
 
103
  </script>
35
  </div>
36
 
37
  <hr>
38
+ <div id="mailpoet_random_order">
39
+ <div>
40
+ <% if(not settings.analytics.enabled) %>
41
+ <div class="feature-section one-col mailpoet_centered">
42
+ <h2><%= __('Do Your Part to Make MailPoet Better') %></h2>
43
+ <div class="lead-description">
44
+
45
+ <label>
46
+ <input type="checkbox" id="mailpoet_analytics_enabled" value="1">&nbsp;
47
+ <%= __('Yes, share my data anonymously.') %>
48
+ </label>
49
+ </div>
50
+ <p class="top-space-triple"><%= __("By sharing your data with us, you can help us understand what our users like (and don't like).") %>
51
+ <%= __('We use it to prioritize and develop new plugin features.') %><br>
52
+ <%= __('Share your data to help shape the future of MailPoet! [link]Read more.[/link]')
53
+ |replaceLinkTags('http://beta.docs.mailpoet.com/article/130-sharing-your-data-with-us', {'target' : '_blank'})
54
+ |raw
55
+ %>
56
+ </p>
57
+ </div>
58
+ <hr>
59
+ <% endif %>
60
+ </div>
61
 
62
+ <div>
63
+ <div class="feature-section one-col mailpoet_centered">
64
+ <h2><%= __("Subscribe To Our Newsletter") %></h2>
65
+ <p><%= __("About once a month, we send out a pretty cool newsletter ourselves.") %></p>
66
+ <p><%= __("Sign up to get a curated selection of awesome links, tips and tricks for using MailPoet, special offers, and important plugin updates!") %></p>
67
+ <iframe width="380" scrolling="no" frameborder="0" src="http://www.mailpoet.com/?wysija-page=1&controller=subscribers&action=wysija_outter&wysija_form=5&external_site=1&wysijap=subscriptions-3" class="iframe-wysija" vspace="0" tabindex="0" style="border-style: none; visibility: visible; background-color: #f1f1f1!important;" marginwidth="0" marginheight="0" hspace="0" allowtransparency="true" title="<%= __("Subscribe To Our Newsletter") %>"></iframe>
68
+ </div>
69
+ <hr>
70
+ </div>
71
 
72
+ <div>
73
+ <div class="feature-section one-col mailpoet_centered">
74
+ <h2><%= __("Learn the Ropes") %></h2>
75
+ <p><%= __("New to MailPoet? Check out our brand new email course. Over the course of a week, we'll teach you how to create and send your first MailPoet email newsletter. Sign up below!") %></p>
76
+ <iframe width="380" height="100%" scrolling="no" frameborder="0" src="http://newsletters.mailpoet.com?mailpoet_form_iframe=4" class="mailpoet_form_iframe" vspace="0" tabindex="0" onload="if(window['MailPoet']) MailPoet.Iframe.autoSize(this);" marginwidth="0" marginheight="0" hspace="0" allowtransparency="true"></iframe>
77
  </div>
78
+ <hr>
79
+ </div>
80
+
81
+ <div>
82
+ <div class="feature-section one-col mailpoet_centered">
83
+ <h2><%= __("Leave a Review, Make Us Happy") %></h2>
84
+ <p><%= __('We love to read reviews, either critical or positive. Take 3 minutes and make our day. [link]Write a review[/link]. :)')
85
+ |replaceLinkTags('https://wordpress.org/support/plugin/mailpoet/reviews/', {'target' : '_blank'})
86
  |raw
87
  %>
88
+ </p>
89
+ </div>
90
+ <hr>
91
  </div>
92
+ </div>
 
 
93
 
94
  <div class="feature-section one-col mailpoet_centered">
95
  <h2><%= __('Care to Give Your Opinion?') %></h2>
96
 
97
+ <div class="pd-embed" id="pd_1508246191"></div>
98
+ <script type="text/javascript">
99
+ var _polldaddy = [] || _polldaddy;
100
+
101
+ _polldaddy.push( {
102
+ type: "iframe",
103
+ auto: "1",
104
+ domain: "mailpoet.polldaddy.com/s/",
105
+ id: "what-s-one-feature-that-s-missing-in-mailpoet-1",
106
+ placeholder: "pd_1508246191"
107
+ } );
108
+
109
+ (function(d,c,j){if(!document.getElementById(j)){var pd=d.createElement(c),s;pd.id=j;pd.src=('https:'==document.location.protocol)?'https://polldaddy.com/survey.js':'http://i0.poll.fm/survey.js';s=document.getElementsByTagName(c)[0];s.parentNode.insertBefore(pd,s);}}(document,'script','pd-embed'));
110
+ </script>
111
  </div>
112
 
113
  <hr>
143
  );
144
  }
145
  });
146
+ });
147
+
148
+ var $random = $('#mailpoet_random_order');
149
+ var divs = $random.children().toArray();
150
+ $random.empty();
151
+ _.shuffle(divs).forEach(function(div) {
152
+ $random.append(div)
153
+ });
154
+
155
  });
156
 
157
  </script>
views/welcome.html CHANGED
@@ -5,11 +5,7 @@
5
  <div class="wrap mailpoet-about-wrap">
6
  <h1><%= __('Greetings, humans.') %></h1>
7
 
8
- <p class="about-text"><%= __('Thanks for using MailPoet! We really appreciate all of your love, affection, [link]and (good) plugin reviews.[/link]')
9
- |replaceLinkTags('https://wordpress.org/support/plugin/mailpoet/reviews/', {'target' : '_blank'})
10
- |raw
11
- %>
12
- </p>
13
  <div class="mailpoet-logo"><img src="<%= image_url('welcome_template/mailpoet-logo.png') %>" alt="<%= __('MailPoet Logo') %>" /></div>
14
 
15
  <h2 class="nav-tab-wrapper wp-clearfix">
@@ -41,7 +37,6 @@
41
  <hr>
42
 
43
  <div class="feature-section two-col">
44
- <h2><%= __('Want to Make MailPoet Even Better?') %></h2>
45
  <div class="col">
46
  <h3><%= __('Documentation Is One Click Away') %></h3>
47
  <p><%= __('Simply click on the blue circle in the bottom right corner of any of the MailPoet pages to access our documentation.') %> <em><%= __('Voilà!') %></em>
@@ -61,26 +56,6 @@
61
 
62
  <hr>
63
 
64
- <div class="feature-section two-col">
65
- <div class="col">
66
- <h3><%= __("Subscribe To Our Newsletter") %></h3>
67
- <p><%= __("About once a month, we send out a pretty cool newsletter ourselves.") %></p>
68
- <p><%= __("Sign up to get a curated selection of awesome links, tips and tricks for using MailPoet, special offers, and important plugin updates!") %></p>
69
- <p>
70
- <iframe width="380" scrolling="no" frameborder="0" src="http://www.mailpoet.com/?wysija-page=1&controller=subscribers&action=wysija_outter&wysija_form=5&external_site=1&wysijap=subscriptions-3" class="iframe-wysija" vspace="0" tabindex="0" style="border-style: none; display:block; visibility: visible; background-color: #f1f1f1!important;" marginwidth="0" marginheight="0" hspace="0" allowtransparency="true" title="<%= __("Subscribe To Our Newsletter") %>"></iframe>
71
- </p>
72
- </div>
73
- <div class="col">
74
- <h3><%= __("Learn the Ropes") %></h3>
75
- <p><%= __("New to MailPoet? Check out our brand new email course. Over the course of a week, we'll teach you how to create and send your first MailPoet email newsletter. Sign up below!") %></p>
76
- <p>
77
- <iframe width="100%" height="100%" scrolling="no" frameborder="0" src="http://newsletters.mailpoet.com?mailpoet_form_iframe=4" class="mailpoet_form_iframe" vspace="0" tabindex="0" onload="if(window['MailPoet']) MailPoet.Iframe.autoSize(this);" marginwidth="0" marginheight="0" hspace="0" allowtransparency="true"></iframe>
78
- </p>
79
- </div>
80
- </div>
81
-
82
- <hr>
83
-
84
  <div class="feature-section one-col mailpoet_centered">
85
  <a class="button button-primary go-to-plugin" href="admin.php?page=mailpoet-newsletters"><%= __("Awesome! Now, take me to MailPoet") %> &rarr;</a>
86
  </div>
5
  <div class="wrap mailpoet-about-wrap">
6
  <h1><%= __('Greetings, humans.') %></h1>
7
 
8
+ <p class="about-text"><%= __('The new MailPoet. Simply better. And with regular updates.') %></p>
 
 
 
 
9
  <div class="mailpoet-logo"><img src="<%= image_url('welcome_template/mailpoet-logo.png') %>" alt="<%= __('MailPoet Logo') %>" /></div>
10
 
11
  <h2 class="nav-tab-wrapper wp-clearfix">
37
  <hr>
38
 
39
  <div class="feature-section two-col">
 
40
  <div class="col">
41
  <h3><%= __('Documentation Is One Click Away') %></h3>
42
  <p><%= __('Simply click on the blue circle in the bottom right corner of any of the MailPoet pages to access our documentation.') %> <em><%= __('Voilà!') %></em>
56
 
57
  <hr>
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  <div class="feature-section one-col mailpoet_centered">
60
  <a class="button button-primary go-to-plugin" href="admin.php?page=mailpoet-newsletters"><%= __("Awesome! Now, take me to MailPoet") %> &rarr;</a>
61
  </div>