MailPoet Newsletters (New) - Version 3.2.1

Version Description

  • 2017-11-21 =
  • Fixed: Safari bug asking subscribers to leave the first field empty in MailPoet subscription forms;
  • Fixed: JavaScript error is not thrown when test email can't be sent;
Download this release

Release Info

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

Code changes from version 3.2.0 to 3.2.1

assets/js/{admin.5976c78a.js → admin.4d4f5142.js} RENAMED
@@ -11712,7 +11712,7 @@ webpackJsonp([0],{
11712
 
11713
  return _react2['default'].createElement(
11714
  'h2',
11715
- { className: 'nav-tab-wrapper' },
11716
  tabs
11717
  );
11718
  }
11712
 
11713
  return _react2['default'].createElement(
11714
  'h2',
11715
+ { className: 'nav-tab-wrapper', 'data-automation-id': 'newsletters_listing_tabs' },
11716
  tabs
11717
  );
11718
  }
assets/js/{admin_vendor.9865021f.js → admin_vendor.e5ae56f3.js} RENAMED
@@ -30947,7 +30947,7 @@ webpackJsonp([1],[
30947
 
30948
  return _react2['default'].createElement(
30949
  'tr',
30950
- { className: row_classes },
30951
  checkbox,
30952
  this.props.onRenderItem(this.props.item, actions)
30953
  );
@@ -34082,5752 +34082,5752 @@ webpackJsonp([1],[
34082
  /* 289 */
34083
  /***/ function(module, exports, __webpack_require__) {
34084
 
34085
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;var require;/*!
34086
- * Select2 4.0.5
34087
- * https://select2.github.io
34088
- *
34089
- * Released under the MIT license
34090
- * https://github.com/select2/select2/blob/master/LICENSE.md
34091
- */
34092
- (function (factory) {
34093
- if (true) {
34094
- // AMD. Register as an anonymous module.
34095
- !(__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__));
34096
- } else if (typeof module === 'object' && module.exports) {
34097
- // Node/CommonJS
34098
- module.exports = function (root, jQuery) {
34099
- if (jQuery === undefined) {
34100
- // require('jQuery') returns a factory that requires window to
34101
- // build a jQuery instance, we normalize how we use modules
34102
- // that require this pattern but the window provided is a noop
34103
- // if it's defined (how jquery works)
34104
- if (typeof window !== 'undefined') {
34105
- jQuery = require('jquery');
34106
- }
34107
- else {
34108
- jQuery = require('jquery')(root);
34109
- }
34110
- }
34111
- factory(jQuery);
34112
- return jQuery;
34113
- };
34114
- } else {
34115
- // Browser globals
34116
- factory(jQuery);
34117
- }
34118
- } (function (jQuery) {
34119
- // This is needed so we can catch the AMD loader configuration and use it
34120
- // The inner file should be wrapped (by `banner.start.js`) in a function that
34121
- // returns the AMD loader references.
34122
- var S2 =(function () {
34123
- // Restore the Select2 AMD loader so it can be used
34124
- // Needed mostly in the language files, where the loader is not inserted
34125
- if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
34126
- var S2 = jQuery.fn.select2.amd;
34127
- }
34128
- var S2;(function () { if (!S2 || !S2.requirejs) {
34129
- if (!S2) { S2 = {}; } else { require = S2; }
34130
- /**
34131
- * @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
34132
- * Released under MIT license, http://github.com/requirejs/almond/LICENSE
34133
- */
34134
- //Going sloppy to avoid 'use strict' string cost, but strict practices should
34135
- //be followed.
34136
- /*global setTimeout: false */
34137
-
34138
- var requirejs, require, define;
34139
- (function (undef) {
34140
- var main, req, makeMap, handlers,
34141
- defined = {},
34142
- waiting = {},
34143
- config = {},
34144
- defining = {},
34145
- hasOwn = Object.prototype.hasOwnProperty,
34146
- aps = [].slice,
34147
- jsSuffixRegExp = /\.js$/;
34148
-
34149
- function hasProp(obj, prop) {
34150
- return hasOwn.call(obj, prop);
34151
- }
34152
-
34153
- /**
34154
- * Given a relative module name, like ./something, normalize it to
34155
- * a real name that can be mapped to a path.
34156
- * @param {String} name the relative name
34157
- * @param {String} baseName a real name that the name arg is relative
34158
- * to.
34159
- * @returns {String} normalized name
34160
- */
34161
- function normalize(name, baseName) {
34162
- var nameParts, nameSegment, mapValue, foundMap, lastIndex,
34163
- foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
34164
- baseParts = baseName && baseName.split("/"),
34165
- map = config.map,
34166
- starMap = (map && map['*']) || {};
34167
-
34168
- //Adjust any relative paths.
34169
- if (name) {
34170
- name = name.split('/');
34171
- lastIndex = name.length - 1;
34172
-
34173
- // If wanting node ID compatibility, strip .js from end
34174
- // of IDs. Have to do this here, and not in nameToUrl
34175
- // because node allows either .js or non .js to map
34176
- // to same file.
34177
- if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
34178
- name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
34179
- }
34180
-
34181
- // Starts with a '.' so need the baseName
34182
- if (name[0].charAt(0) === '.' && baseParts) {
34183
- //Convert baseName to array, and lop off the last part,
34184
- //so that . matches that 'directory' and not name of the baseName's
34185
- //module. For instance, baseName of 'one/two/three', maps to
34186
- //'one/two/three.js', but we want the directory, 'one/two' for
34187
- //this normalization.
34188
- normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
34189
- name = normalizedBaseParts.concat(name);
34190
- }
34191
-
34192
- //start trimDots
34193
- for (i = 0; i < name.length; i++) {
34194
- part = name[i];
34195
- if (part === '.') {
34196
- name.splice(i, 1);
34197
- i -= 1;
34198
- } else if (part === '..') {
34199
- // If at the start, or previous value is still ..,
34200
- // keep them so that when converted to a path it may
34201
- // still work when converted to a path, even though
34202
- // as an ID it is less than ideal. In larger point
34203
- // releases, may be better to just kick out an error.
34204
- if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
34205
- continue;
34206
- } else if (i > 0) {
34207
- name.splice(i - 1, 2);
34208
- i -= 2;
34209
- }
34210
- }
34211
- }
34212
- //end trimDots
34213
-
34214
- name = name.join('/');
34215
- }
34216
-
34217
- //Apply map config if available.
34218
- if ((baseParts || starMap) && map) {
34219
- nameParts = name.split('/');
34220
-
34221
- for (i = nameParts.length; i > 0; i -= 1) {
34222
- nameSegment = nameParts.slice(0, i).join("/");
34223
-
34224
- if (baseParts) {
34225
- //Find the longest baseName segment match in the config.
34226
- //So, do joins on the biggest to smallest lengths of baseParts.
34227
- for (j = baseParts.length; j > 0; j -= 1) {
34228
- mapValue = map[baseParts.slice(0, j).join('/')];
34229
-
34230
- //baseName segment has config, find if it has one for
34231
- //this name.
34232
- if (mapValue) {
34233
- mapValue = mapValue[nameSegment];
34234
- if (mapValue) {
34235
- //Match, update name to the new value.
34236
- foundMap = mapValue;
34237
- foundI = i;
34238
- break;
34239
- }
34240
- }
34241
- }
34242
- }
34243
-
34244
- if (foundMap) {
34245
- break;
34246
- }
34247
-
34248
- //Check for a star map match, but just hold on to it,
34249
- //if there is a shorter segment match later in a matching
34250
- //config, then favor over this star map.
34251
- if (!foundStarMap && starMap && starMap[nameSegment]) {
34252
- foundStarMap = starMap[nameSegment];
34253
- starI = i;
34254
- }
34255
- }
34256
-
34257
- if (!foundMap && foundStarMap) {
34258
- foundMap = foundStarMap;
34259
- foundI = starI;
34260
- }
34261
-
34262
- if (foundMap) {
34263
- nameParts.splice(0, foundI, foundMap);
34264
- name = nameParts.join('/');
34265
- }
34266
- }
34267
-
34268
- return name;
34269
- }
34270
-
34271
- function makeRequire(relName, forceSync) {
34272
- return function () {
34273
- //A version of a require function that passes a moduleName
34274
- //value for items that may need to
34275
- //look up paths relative to the moduleName
34276
- var args = aps.call(arguments, 0);
34277
-
34278
- //If first arg is not require('string'), and there is only
34279
- //one arg, it is the array form without a callback. Insert
34280
- //a null so that the following concat is correct.
34281
- if (typeof args[0] !== 'string' && args.length === 1) {
34282
- args.push(null);
34283
- }
34284
- return req.apply(undef, args.concat([relName, forceSync]));
34285
- };
34286
- }
34287
-
34288
- function makeNormalize(relName) {
34289
- return function (name) {
34290
- return normalize(name, relName);
34291
- };
34292
- }
34293
-
34294
- function makeLoad(depName) {
34295
- return function (value) {
34296
- defined[depName] = value;
34297
- };
34298
- }
34299
-
34300
- function callDep(name) {
34301
- if (hasProp(waiting, name)) {
34302
- var args = waiting[name];
34303
- delete waiting[name];
34304
- defining[name] = true;
34305
- main.apply(undef, args);
34306
- }
34307
-
34308
- if (!hasProp(defined, name) && !hasProp(defining, name)) {
34309
- throw new Error('No ' + name);
34310
- }
34311
- return defined[name];
34312
- }
34313
-
34314
- //Turns a plugin!resource to [plugin, resource]
34315
- //with the plugin being undefined if the name
34316
- //did not have a plugin prefix.
34317
- function splitPrefix(name) {
34318
- var prefix,
34319
- index = name ? name.indexOf('!') : -1;
34320
- if (index > -1) {
34321
- prefix = name.substring(0, index);
34322
- name = name.substring(index + 1, name.length);
34323
- }
34324
- return [prefix, name];
34325
- }
34326
-
34327
- //Creates a parts array for a relName where first part is plugin ID,
34328
- //second part is resource ID. Assumes relName has already been normalized.
34329
- function makeRelParts(relName) {
34330
- return relName ? splitPrefix(relName) : [];
34331
- }
34332
-
34333
- /**
34334
- * Makes a name map, normalizing the name, and using a plugin
34335
- * for normalization if necessary. Grabs a ref to plugin
34336
- * too, as an optimization.
34337
- */
34338
- makeMap = function (name, relParts) {
34339
- var plugin,
34340
- parts = splitPrefix(name),
34341
- prefix = parts[0],
34342
- relResourceName = relParts[1];
34343
-
34344
- name = parts[1];
34345
-
34346
- if (prefix) {
34347
- prefix = normalize(prefix, relResourceName);
34348
- plugin = callDep(prefix);
34349
- }
34350
-
34351
- //Normalize according
34352
- if (prefix) {
34353
- if (plugin && plugin.normalize) {
34354
- name = plugin.normalize(name, makeNormalize(relResourceName));
34355
- } else {
34356
- name = normalize(name, relResourceName);
34357
- }
34358
- } else {
34359
- name = normalize(name, relResourceName);
34360
- parts = splitPrefix(name);
34361
- prefix = parts[0];
34362
- name = parts[1];
34363
- if (prefix) {
34364
- plugin = callDep(prefix);
34365
- }
34366
- }
34367
-
34368
- //Using ridiculous property names for space reasons
34369
- return {
34370
- f: prefix ? prefix + '!' + name : name, //fullName
34371
- n: name,
34372
- pr: prefix,
34373
- p: plugin
34374
- };
34375
- };
34376
-
34377
- function makeConfig(name) {
34378
- return function () {
34379
- return (config && config.config && config.config[name]) || {};
34380
- };
34381
- }
34382
-
34383
- handlers = {
34384
- require: function (name) {
34385
- return makeRequire(name);
34386
- },
34387
- exports: function (name) {
34388
- var e = defined[name];
34389
- if (typeof e !== 'undefined') {
34390
- return e;
34391
- } else {
34392
- return (defined[name] = {});
34393
- }
34394
- },
34395
- module: function (name) {
34396
- return {
34397
- id: name,
34398
- uri: '',
34399
- exports: defined[name],
34400
- config: makeConfig(name)
34401
- };
34402
- }
34403
- };
34404
-
34405
- main = function (name, deps, callback, relName) {
34406
- var cjsModule, depName, ret, map, i, relParts,
34407
- args = [],
34408
- callbackType = typeof callback,
34409
- usingExports;
34410
-
34411
- //Use name if no relName
34412
- relName = relName || name;
34413
- relParts = makeRelParts(relName);
34414
-
34415
- //Call the callback to define the module, if necessary.
34416
- if (callbackType === 'undefined' || callbackType === 'function') {
34417
- //Pull out the defined dependencies and pass the ordered
34418
- //values to the callback.
34419
- //Default to [require, exports, module] if no deps
34420
- deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
34421
- for (i = 0; i < deps.length; i += 1) {
34422
- map = makeMap(deps[i], relParts);
34423
- depName = map.f;
34424
-
34425
- //Fast path CommonJS standard dependencies.
34426
- if (depName === "require") {
34427
- args[i] = handlers.require(name);
34428
- } else if (depName === "exports") {
34429
- //CommonJS module spec 1.1
34430
- args[i] = handlers.exports(name);
34431
- usingExports = true;
34432
- } else if (depName === "module") {
34433
- //CommonJS module spec 1.1
34434
- cjsModule = args[i] = handlers.module(name);
34435
- } else if (hasProp(defined, depName) ||
34436
- hasProp(waiting, depName) ||
34437
- hasProp(defining, depName)) {
34438
- args[i] = callDep(depName);
34439
- } else if (map.p) {
34440
- map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
34441
- args[i] = defined[depName];
34442
- } else {
34443
- throw new Error(name + ' missing ' + depName);
34444
- }
34445
- }
34446
-
34447
- ret = callback ? callback.apply(defined[name], args) : undefined;
34448
-
34449
- if (name) {
34450
- //If setting exports via "module" is in play,
34451
- //favor that over return value and exports. After that,
34452
- //favor a non-undefined return value over exports use.
34453
- if (cjsModule && cjsModule.exports !== undef &&
34454
- cjsModule.exports !== defined[name]) {
34455
- defined[name] = cjsModule.exports;
34456
- } else if (ret !== undef || !usingExports) {
34457
- //Use the return value from the function.
34458
- defined[name] = ret;
34459
- }
34460
- }
34461
- } else if (name) {
34462
- //May just be an object definition for the module. Only
34463
- //worry about defining if have a module name.
34464
- defined[name] = callback;
34465
- }
34466
- };
34467
-
34468
- requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
34469
- if (typeof deps === "string") {
34470
- if (handlers[deps]) {
34471
- //callback in this case is really relName
34472
- return handlers[deps](callback);
34473
- }
34474
- //Just return the module wanted. In this scenario, the
34475
- //deps arg is the module name, and second arg (if passed)
34476
- //is just the relName.
34477
- //Normalize module name, if it contains . or ..
34478
- return callDep(makeMap(deps, makeRelParts(callback)).f);
34479
- } else if (!deps.splice) {
34480
- //deps is a config object, not an array.
34481
- config = deps;
34482
- if (config.deps) {
34483
- req(config.deps, config.callback);
34484
- }
34485
- if (!callback) {
34486
- return;
34487
- }
34488
-
34489
- if (callback.splice) {
34490
- //callback is an array, which means it is a dependency list.
34491
- //Adjust args if there are dependencies
34492
- deps = callback;
34493
- callback = relName;
34494
- relName = null;
34495
- } else {
34496
- deps = undef;
34497
- }
34498
- }
34499
-
34500
- //Support require(['a'])
34501
- callback = callback || function () {};
34502
-
34503
- //If relName is a function, it is an errback handler,
34504
- //so remove it.
34505
- if (typeof relName === 'function') {
34506
- relName = forceSync;
34507
- forceSync = alt;
34508
- }
34509
-
34510
- //Simulate async callback;
34511
- if (forceSync) {
34512
- main(undef, deps, callback, relName);
34513
- } else {
34514
- //Using a non-zero value because of concern for what old browsers
34515
- //do, and latest browsers "upgrade" to 4 if lower value is used:
34516
- //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
34517
- //If want a value immediately, use require('id') instead -- something
34518
- //that works in almond on the global level, but not guaranteed and
34519
- //unlikely to work in other AMD implementations.
34520
- setTimeout(function () {
34521
- main(undef, deps, callback, relName);
34522
- }, 4);
34523
- }
34524
-
34525
- return req;
34526
- };
34527
-
34528
- /**
34529
- * Just drops the config on the floor, but returns req in case
34530
- * the config return value is used.
34531
- */
34532
- req.config = function (cfg) {
34533
- return req(cfg);
34534
- };
34535
-
34536
- /**
34537
- * Expose module registry for debugging and tooling
34538
- */
34539
- requirejs._defined = defined;
34540
-
34541
- define = function (name, deps, callback) {
34542
- if (typeof name !== 'string') {
34543
- throw new Error('See almond README: incorrect module build, no module name');
34544
- }
34545
-
34546
- //This module may not have dependencies
34547
- if (!deps.splice) {
34548
- //deps is not an array, so probably means
34549
- //an object literal or factory function for
34550
- //the value. Adjust args.
34551
- callback = deps;
34552
- deps = [];
34553
- }
34554
-
34555
- if (!hasProp(defined, name) && !hasProp(waiting, name)) {
34556
- waiting[name] = [name, deps, callback];
34557
- }
34558
- };
34559
-
34560
- define.amd = {
34561
- jQuery: true
34562
- };
34563
- }());
34564
-
34565
- S2.requirejs = requirejs;S2.require = require;S2.define = define;
34566
- }
34567
- }());
34568
- S2.define("almond", function(){});
34569
-
34570
- /* global jQuery:false, $:false */
34571
- S2.define('jquery',[],function () {
34572
- var _$ = jQuery || $;
34573
-
34574
- if (_$ == null && console && console.error) {
34575
- console.error(
34576
- 'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
34577
- 'found. Make sure that you are including jQuery before Select2 on your ' +
34578
- 'web page.'
34579
- );
34580
- }
34581
-
34582
- return _$;
34583
- });
34584
-
34585
- S2.define('select2/utils',[
34586
- 'jquery'
34587
- ], function ($) {
34588
- var Utils = {};
34589
-
34590
- Utils.Extend = function (ChildClass, SuperClass) {
34591
- var __hasProp = {}.hasOwnProperty;
34592
-
34593
- function BaseConstructor () {
34594
- this.constructor = ChildClass;
34595
- }
34596
-
34597
- for (var key in SuperClass) {
34598
- if (__hasProp.call(SuperClass, key)) {
34599
- ChildClass[key] = SuperClass[key];
34600
- }
34601
- }
34602
-
34603
- BaseConstructor.prototype = SuperClass.prototype;
34604
- ChildClass.prototype = new BaseConstructor();
34605
- ChildClass.__super__ = SuperClass.prototype;
34606
-
34607
- return ChildClass;
34608
- };
34609
-
34610
- function getMethods (theClass) {
34611
- var proto = theClass.prototype;
34612
-
34613
- var methods = [];
34614
-
34615
- for (var methodName in proto) {
34616
- var m = proto[methodName];
34617
-
34618
- if (typeof m !== 'function') {
34619
- continue;
34620
- }
34621
-
34622
- if (methodName === 'constructor') {
34623
- continue;
34624
- }
34625
-
34626
- methods.push(methodName);
34627
- }
34628
-
34629
- return methods;
34630
- }
34631
-
34632
- Utils.Decorate = function (SuperClass, DecoratorClass) {
34633
- var decoratedMethods = getMethods(DecoratorClass);
34634
- var superMethods = getMethods(SuperClass);
34635
-
34636
- function DecoratedClass () {
34637
- var unshift = Array.prototype.unshift;
34638
-
34639
- var argCount = DecoratorClass.prototype.constructor.length;
34640
-
34641
- var calledConstructor = SuperClass.prototype.constructor;
34642
-
34643
- if (argCount > 0) {
34644
- unshift.call(arguments, SuperClass.prototype.constructor);
34645
-
34646
- calledConstructor = DecoratorClass.prototype.constructor;
34647
- }
34648
-
34649
- calledConstructor.apply(this, arguments);
34650
- }
34651
-
34652
- DecoratorClass.displayName = SuperClass.displayName;
34653
-
34654
- function ctr () {
34655
- this.constructor = DecoratedClass;
34656
- }
34657
-
34658
- DecoratedClass.prototype = new ctr();
34659
-
34660
- for (var m = 0; m < superMethods.length; m++) {
34661
- var superMethod = superMethods[m];
34662
-
34663
- DecoratedClass.prototype[superMethod] =
34664
- SuperClass.prototype[superMethod];
34665
- }
34666
-
34667
- var calledMethod = function (methodName) {
34668
- // Stub out the original method if it's not decorating an actual method
34669
- var originalMethod = function () {};
34670
-
34671
- if (methodName in DecoratedClass.prototype) {
34672
- originalMethod = DecoratedClass.prototype[methodName];
34673
- }
34674
-
34675
- var decoratedMethod = DecoratorClass.prototype[methodName];
34676
-
34677
- return function () {
34678
- var unshift = Array.prototype.unshift;
34679
-
34680
- unshift.call(arguments, originalMethod);
34681
-
34682
- return decoratedMethod.apply(this, arguments);
34683
- };
34684
- };
34685
-
34686
- for (var d = 0; d < decoratedMethods.length; d++) {
34687
- var decoratedMethod = decoratedMethods[d];
34688
-
34689
- DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
34690
- }
34691
-
34692
- return DecoratedClass;
34693
- };
34694
-
34695
- var Observable = function () {
34696
- this.listeners = {};
34697
- };
34698
-
34699
- Observable.prototype.on = function (event, callback) {
34700
- this.listeners = this.listeners || {};
34701
-
34702
- if (event in this.listeners) {
34703
- this.listeners[event].push(callback);
34704
- } else {
34705
- this.listeners[event] = [callback];
34706
- }
34707
- };
34708
-
34709
- Observable.prototype.trigger = function (event) {
34710
- var slice = Array.prototype.slice;
34711
- var params = slice.call(arguments, 1);
34712
-
34713
- this.listeners = this.listeners || {};
34714
-
34715
- // Params should always come in as an array
34716
- if (params == null) {
34717
- params = [];
34718
- }
34719
-
34720
- // If there are no arguments to the event, use a temporary object
34721
- if (params.length === 0) {
34722
- params.push({});
34723
- }
34724
-
34725
- // Set the `_type` of the first object to the event
34726
- params[0]._type = event;
34727
-
34728
- if (event in this.listeners) {
34729
- this.invoke(this.listeners[event], slice.call(arguments, 1));
34730
- }
34731
-
34732
- if ('*' in this.listeners) {
34733
- this.invoke(this.listeners['*'], arguments);
34734
- }
34735
- };
34736
-
34737
- Observable.prototype.invoke = function (listeners, params) {
34738
- for (var i = 0, len = listeners.length; i < len; i++) {
34739
- listeners[i].apply(this, params);
34740
- }
34741
- };
34742
-
34743
- Utils.Observable = Observable;
34744
-
34745
- Utils.generateChars = function (length) {
34746
- var chars = '';
34747
-
34748
- for (var i = 0; i < length; i++) {
34749
- var randomChar = Math.floor(Math.random() * 36);
34750
- chars += randomChar.toString(36);
34751
- }
34752
-
34753
- return chars;
34754
- };
34755
-
34756
- Utils.bind = function (func, context) {
34757
- return function () {
34758
- func.apply(context, arguments);
34759
- };
34760
- };
34761
-
34762
- Utils._convertData = function (data) {
34763
- for (var originalKey in data) {
34764
- var keys = originalKey.split('-');
34765
-
34766
- var dataLevel = data;
34767
-
34768
- if (keys.length === 1) {
34769
- continue;
34770
- }
34771
-
34772
- for (var k = 0; k < keys.length; k++) {
34773
- var key = keys[k];
34774
-
34775
- // Lowercase the first letter
34776
- // By default, dash-separated becomes camelCase
34777
- key = key.substring(0, 1).toLowerCase() + key.substring(1);
34778
-
34779
- if (!(key in dataLevel)) {
34780
- dataLevel[key] = {};
34781
- }
34782
-
34783
- if (k == keys.length - 1) {
34784
- dataLevel[key] = data[originalKey];
34785
- }
34786
-
34787
- dataLevel = dataLevel[key];
34788
- }
34789
-
34790
- delete data[originalKey];
34791
- }
34792
-
34793
- return data;
34794
- };
34795
-
34796
- Utils.hasScroll = function (index, el) {
34797
- // Adapted from the function created by @ShadowScripter
34798
- // and adapted by @BillBarry on the Stack Exchange Code Review website.
34799
- // The original code can be found at
34800
- // http://codereview.stackexchange.com/q/13338
34801
- // and was designed to be used with the Sizzle selector engine.
34802
-
34803
- var $el = $(el);
34804
- var overflowX = el.style.overflowX;
34805
- var overflowY = el.style.overflowY;
34806
-
34807
- //Check both x and y declarations
34808
- if (overflowX === overflowY &&
34809
- (overflowY === 'hidden' || overflowY === 'visible')) {
34810
- return false;
34811
- }
34812
-
34813
- if (overflowX === 'scroll' || overflowY === 'scroll') {
34814
- return true;
34815
- }
34816
-
34817
- return ($el.innerHeight() < el.scrollHeight ||
34818
- $el.innerWidth() < el.scrollWidth);
34819
- };
34820
-
34821
- Utils.escapeMarkup = function (markup) {
34822
- var replaceMap = {
34823
- '\\': '&#92;',
34824
- '&': '&amp;',
34825
- '<': '&lt;',
34826
- '>': '&gt;',
34827
- '"': '&quot;',
34828
- '\'': '&#39;',
34829
- '/': '&#47;'
34830
- };
34831
-
34832
- // Do not try to escape the markup if it's not a string
34833
- if (typeof markup !== 'string') {
34834
- return markup;
34835
- }
34836
-
34837
- return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
34838
- return replaceMap[match];
34839
- });
34840
- };
34841
-
34842
- // Append an array of jQuery nodes to a given element.
34843
- Utils.appendMany = function ($element, $nodes) {
34844
- // jQuery 1.7.x does not support $.fn.append() with an array
34845
- // Fall back to a jQuery object collection using $.fn.add()
34846
- if ($.fn.jquery.substr(0, 3) === '1.7') {
34847
- var $jqNodes = $();
34848
-
34849
- $.map($nodes, function (node) {
34850
- $jqNodes = $jqNodes.add(node);
34851
- });
34852
-
34853
- $nodes = $jqNodes;
34854
- }
34855
-
34856
- $element.append($nodes);
34857
- };
34858
-
34859
- return Utils;
34860
- });
34861
-
34862
- S2.define('select2/results',[
34863
- 'jquery',
34864
- './utils'
34865
- ], function ($, Utils) {
34866
- function Results ($element, options, dataAdapter) {
34867
- this.$element = $element;
34868
- this.data = dataAdapter;
34869
- this.options = options;
34870
-
34871
- Results.__super__.constructor.call(this);
34872
- }
34873
-
34874
- Utils.Extend(Results, Utils.Observable);
34875
-
34876
- Results.prototype.render = function () {
34877
- var $results = $(
34878
- '<ul class="select2-results__options" role="tree"></ul>'
34879
- );
34880
-
34881
- if (this.options.get('multiple')) {
34882
- $results.attr('aria-multiselectable', 'true');
34883
- }
34884
-
34885
- this.$results = $results;
34886
-
34887
- return $results;
34888
- };
34889
-
34890
- Results.prototype.clear = function () {
34891
- this.$results.empty();
34892
- };
34893
-
34894
- Results.prototype.displayMessage = function (params) {
34895
- var escapeMarkup = this.options.get('escapeMarkup');
34896
-
34897
- this.clear();
34898
- this.hideLoading();
34899
-
34900
- var $message = $(
34901
- '<li role="treeitem" aria-live="assertive"' +
34902
- ' class="select2-results__option"></li>'
34903
- );
34904
-
34905
- var message = this.options.get('translations').get(params.message);
34906
-
34907
- $message.append(
34908
- escapeMarkup(
34909
- message(params.args)
34910
- )
34911
- );
34912
-
34913
- $message[0].className += ' select2-results__message';
34914
-
34915
- this.$results.append($message);
34916
- };
34917
-
34918
- Results.prototype.hideMessages = function () {
34919
- this.$results.find('.select2-results__message').remove();
34920
- };
34921
-
34922
- Results.prototype.append = function (data) {
34923
- this.hideLoading();
34924
-
34925
- var $options = [];
34926
-
34927
- if (data.results == null || data.results.length === 0) {
34928
- if (this.$results.children().length === 0) {
34929
- this.trigger('results:message', {
34930
- message: 'noResults'
34931
- });
34932
- }
34933
-
34934
- return;
34935
- }
34936
-
34937
- data.results = this.sort(data.results);
34938
-
34939
- for (var d = 0; d < data.results.length; d++) {
34940
- var item = data.results[d];
34941
-
34942
- var $option = this.option(item);
34943
-
34944
- $options.push($option);
34945
- }
34946
-
34947
- this.$results.append($options);
34948
- };
34949
-
34950
- Results.prototype.position = function ($results, $dropdown) {
34951
- var $resultsContainer = $dropdown.find('.select2-results');
34952
- $resultsContainer.append($results);
34953
- };
34954
-
34955
- Results.prototype.sort = function (data) {
34956
- var sorter = this.options.get('sorter');
34957
-
34958
- return sorter(data);
34959
- };
34960
-
34961
- Results.prototype.highlightFirstItem = function () {
34962
- var $options = this.$results
34963
- .find('.select2-results__option[aria-selected]');
34964
-
34965
- var $selected = $options.filter('[aria-selected=true]');
34966
-
34967
- // Check if there are any selected options
34968
- if ($selected.length > 0) {
34969
- // If there are selected options, highlight the first
34970
- $selected.first().trigger('mouseenter');
34971
- } else {
34972
- // If there are no selected options, highlight the first option
34973
- // in the dropdown
34974
- $options.first().trigger('mouseenter');
34975
- }
34976
-
34977
- this.ensureHighlightVisible();
34978
- };
34979
-
34980
- Results.prototype.setClasses = function () {
34981
- var self = this;
34982
-
34983
- this.data.current(function (selected) {
34984
- var selectedIds = $.map(selected, function (s) {
34985
- return s.id.toString();
34986
- });
34987
-
34988
- var $options = self.$results
34989
- .find('.select2-results__option[aria-selected]');
34990
-
34991
- $options.each(function () {
34992
- var $option = $(this);
34993
-
34994
- var item = $.data(this, 'data');
34995
-
34996
- // id needs to be converted to a string when comparing
34997
- var id = '' + item.id;
34998
-
34999
- if ((item.element != null && item.element.selected) ||
35000
- (item.element == null && $.inArray(id, selectedIds) > -1)) {
35001
- $option.attr('aria-selected', 'true');
35002
- } else {
35003
- $option.attr('aria-selected', 'false');
35004
- }
35005
- });
35006
-
35007
- });
35008
- };
35009
-
35010
- Results.prototype.showLoading = function (params) {
35011
- this.hideLoading();
35012
-
35013
- var loadingMore = this.options.get('translations').get('searching');
35014
-
35015
- var loading = {
35016
- disabled: true,
35017
- loading: true,
35018
- text: loadingMore(params)
35019
- };
35020
- var $loading = this.option(loading);
35021
- $loading.className += ' loading-results';
35022
-
35023
- this.$results.prepend($loading);
35024
- };
35025
-
35026
- Results.prototype.hideLoading = function () {
35027
- this.$results.find('.loading-results').remove();
35028
- };
35029
-
35030
- Results.prototype.option = function (data) {
35031
- var option = document.createElement('li');
35032
- option.className = 'select2-results__option';
35033
-
35034
- var attrs = {
35035
- 'role': 'treeitem',
35036
- 'aria-selected': 'false'
35037
- };
35038
-
35039
- if (data.disabled) {
35040
- delete attrs['aria-selected'];
35041
- attrs['aria-disabled'] = 'true';
35042
- }
35043
-
35044
- if (data.id == null) {
35045
- delete attrs['aria-selected'];
35046
- }
35047
-
35048
- if (data._resultId != null) {
35049
- option.id = data._resultId;
35050
- }
35051
-
35052
- if (data.title) {
35053
- option.title = data.title;
35054
- }
35055
-
35056
- if (data.children) {
35057
- attrs.role = 'group';
35058
- attrs['aria-label'] = data.text;
35059
- delete attrs['aria-selected'];
35060
- }
35061
-
35062
- for (var attr in attrs) {
35063
- var val = attrs[attr];
35064
-
35065
- option.setAttribute(attr, val);
35066
- }
35067
-
35068
- if (data.children) {
35069
- var $option = $(option);
35070
-
35071
- var label = document.createElement('strong');
35072
- label.className = 'select2-results__group';
35073
-
35074
- var $label = $(label);
35075
- this.template(data, label);
35076
-
35077
- var $children = [];
35078
-
35079
- for (var c = 0; c < data.children.length; c++) {
35080
- var child = data.children[c];
35081
-
35082
- var $child = this.option(child);
35083
-
35084
- $children.push($child);
35085
- }
35086
-
35087
- var $childrenContainer = $('<ul></ul>', {
35088
- 'class': 'select2-results__options select2-results__options--nested'
35089
- });
35090
-
35091
- $childrenContainer.append($children);
35092
-
35093
- $option.append(label);
35094
- $option.append($childrenContainer);
35095
- } else {
35096
- this.template(data, option);
35097
- }
35098
-
35099
- $.data(option, 'data', data);
35100
-
35101
- return option;
35102
- };
35103
-
35104
- Results.prototype.bind = function (container, $container) {
35105
- var self = this;
35106
-
35107
- var id = container.id + '-results';
35108
-
35109
- this.$results.attr('id', id);
35110
-
35111
- container.on('results:all', function (params) {
35112
- self.clear();
35113
- self.append(params.data);
35114
-
35115
- if (container.isOpen()) {
35116
- self.setClasses();
35117
- self.highlightFirstItem();
35118
- }
35119
- });
35120
-
35121
- container.on('results:append', function (params) {
35122
- self.append(params.data);
35123
-
35124
- if (container.isOpen()) {
35125
- self.setClasses();
35126
- }
35127
- });
35128
-
35129
- container.on('query', function (params) {
35130
- self.hideMessages();
35131
- self.showLoading(params);
35132
- });
35133
-
35134
- container.on('select', function () {
35135
- if (!container.isOpen()) {
35136
- return;
35137
- }
35138
-
35139
- self.setClasses();
35140
- self.highlightFirstItem();
35141
- });
35142
-
35143
- container.on('unselect', function () {
35144
- if (!container.isOpen()) {
35145
- return;
35146
- }
35147
-
35148
- self.setClasses();
35149
- self.highlightFirstItem();
35150
- });
35151
-
35152
- container.on('open', function () {
35153
- // When the dropdown is open, aria-expended="true"
35154
- self.$results.attr('aria-expanded', 'true');
35155
- self.$results.attr('aria-hidden', 'false');
35156
-
35157
- self.setClasses();
35158
- self.ensureHighlightVisible();
35159
- });
35160
-
35161
- container.on('close', function () {
35162
- // When the dropdown is closed, aria-expended="false"
35163
- self.$results.attr('aria-expanded', 'false');
35164
- self.$results.attr('aria-hidden', 'true');
35165
- self.$results.removeAttr('aria-activedescendant');
35166
- });
35167
-
35168
- container.on('results:toggle', function () {
35169
- var $highlighted = self.getHighlightedResults();
35170
-
35171
- if ($highlighted.length === 0) {
35172
- return;
35173
- }
35174
-
35175
- $highlighted.trigger('mouseup');
35176
- });
35177
-
35178
- container.on('results:select', function () {
35179
- var $highlighted = self.getHighlightedResults();
35180
-
35181
- if ($highlighted.length === 0) {
35182
- return;
35183
- }
35184
-
35185
- var data = $highlighted.data('data');
35186
-
35187
- if ($highlighted.attr('aria-selected') == 'true') {
35188
- self.trigger('close', {});
35189
- } else {
35190
- self.trigger('select', {
35191
- data: data
35192
- });
35193
- }
35194
- });
35195
-
35196
- container.on('results:previous', function () {
35197
- var $highlighted = self.getHighlightedResults();
35198
-
35199
- var $options = self.$results.find('[aria-selected]');
35200
-
35201
- var currentIndex = $options.index($highlighted);
35202
-
35203
- // If we are already at te top, don't move further
35204
- if (currentIndex === 0) {
35205
- return;
35206
- }
35207
-
35208
- var nextIndex = currentIndex - 1;
35209
-
35210
- // If none are highlighted, highlight the first
35211
- if ($highlighted.length === 0) {
35212
- nextIndex = 0;
35213
- }
35214
-
35215
- var $next = $options.eq(nextIndex);
35216
-
35217
- $next.trigger('mouseenter');
35218
-
35219
- var currentOffset = self.$results.offset().top;
35220
- var nextTop = $next.offset().top;
35221
- var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
35222
-
35223
- if (nextIndex === 0) {
35224
- self.$results.scrollTop(0);
35225
- } else if (nextTop - currentOffset < 0) {
35226
- self.$results.scrollTop(nextOffset);
35227
- }
35228
- });
35229
-
35230
- container.on('results:next', function () {
35231
- var $highlighted = self.getHighlightedResults();
35232
-
35233
- var $options = self.$results.find('[aria-selected]');
35234
-
35235
- var currentIndex = $options.index($highlighted);
35236
-
35237
- var nextIndex = currentIndex + 1;
35238
-
35239
- // If we are at the last option, stay there
35240
- if (nextIndex >= $options.length) {
35241
- return;
35242
- }
35243
-
35244
- var $next = $options.eq(nextIndex);
35245
-
35246
- $next.trigger('mouseenter');
35247
-
35248
- var currentOffset = self.$results.offset().top +
35249
- self.$results.outerHeight(false);
35250
- var nextBottom = $next.offset().top + $next.outerHeight(false);
35251
- var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
35252
-
35253
- if (nextIndex === 0) {
35254
- self.$results.scrollTop(0);
35255
- } else if (nextBottom > currentOffset) {
35256
- self.$results.scrollTop(nextOffset);
35257
- }
35258
- });
35259
-
35260
- container.on('results:focus', function (params) {
35261
- params.element.addClass('select2-results__option--highlighted');
35262
- });
35263
-
35264
- container.on('results:message', function (params) {
35265
- self.displayMessage(params);
35266
- });
35267
-
35268
- if ($.fn.mousewheel) {
35269
- this.$results.on('mousewheel', function (e) {
35270
- var top = self.$results.scrollTop();
35271
-
35272
- var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
35273
-
35274
- var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
35275
- var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
35276
-
35277
- if (isAtTop) {
35278
- self.$results.scrollTop(0);
35279
-
35280
- e.preventDefault();
35281
- e.stopPropagation();
35282
- } else if (isAtBottom) {
35283
- self.$results.scrollTop(
35284
- self.$results.get(0).scrollHeight - self.$results.height()
35285
- );
35286
-
35287
- e.preventDefault();
35288
- e.stopPropagation();
35289
- }
35290
- });
35291
- }
35292
-
35293
- this.$results.on('mouseup', '.select2-results__option[aria-selected]',
35294
- function (evt) {
35295
- var $this = $(this);
35296
-
35297
- var data = $this.data('data');
35298
-
35299
- if ($this.attr('aria-selected') === 'true') {
35300
- if (self.options.get('multiple')) {
35301
- self.trigger('unselect', {
35302
- originalEvent: evt,
35303
- data: data
35304
- });
35305
- } else {
35306
- self.trigger('close', {});
35307
- }
35308
-
35309
- return;
35310
- }
35311
-
35312
- self.trigger('select', {
35313
- originalEvent: evt,
35314
- data: data
35315
- });
35316
- });
35317
-
35318
- this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
35319
- function (evt) {
35320
- var data = $(this).data('data');
35321
-
35322
- self.getHighlightedResults()
35323
- .removeClass('select2-results__option--highlighted');
35324
-
35325
- self.trigger('results:focus', {
35326
- data: data,
35327
- element: $(this)
35328
- });
35329
- });
35330
- };
35331
-
35332
- Results.prototype.getHighlightedResults = function () {
35333
- var $highlighted = this.$results
35334
- .find('.select2-results__option--highlighted');
35335
-
35336
- return $highlighted;
35337
- };
35338
-
35339
- Results.prototype.destroy = function () {
35340
- this.$results.remove();
35341
- };
35342
-
35343
- Results.prototype.ensureHighlightVisible = function () {
35344
- var $highlighted = this.getHighlightedResults();
35345
-
35346
- if ($highlighted.length === 0) {
35347
- return;
35348
- }
35349
-
35350
- var $options = this.$results.find('[aria-selected]');
35351
-
35352
- var currentIndex = $options.index($highlighted);
35353
-
35354
- var currentOffset = this.$results.offset().top;
35355
- var nextTop = $highlighted.offset().top;
35356
- var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
35357
-
35358
- var offsetDelta = nextTop - currentOffset;
35359
- nextOffset -= $highlighted.outerHeight(false) * 2;
35360
-
35361
- if (currentIndex <= 2) {
35362
- this.$results.scrollTop(0);
35363
- } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
35364
- this.$results.scrollTop(nextOffset);
35365
- }
35366
- };
35367
-
35368
- Results.prototype.template = function (result, container) {
35369
- var template = this.options.get('templateResult');
35370
- var escapeMarkup = this.options.get('escapeMarkup');
35371
-
35372
- var content = template(result, container);
35373
-
35374
- if (content == null) {
35375
- container.style.display = 'none';
35376
- } else if (typeof content === 'string') {
35377
- container.innerHTML = escapeMarkup(content);
35378
- } else {
35379
- $(container).append(content);
35380
- }
35381
- };
35382
-
35383
- return Results;
35384
- });
35385
-
35386
- S2.define('select2/keys',[
35387
-
35388
- ], function () {
35389
- var KEYS = {
35390
- BACKSPACE: 8,
35391
- TAB: 9,
35392
- ENTER: 13,
35393
- SHIFT: 16,
35394
- CTRL: 17,
35395
- ALT: 18,
35396
- ESC: 27,
35397
- SPACE: 32,
35398
- PAGE_UP: 33,
35399
- PAGE_DOWN: 34,
35400
- END: 35,
35401
- HOME: 36,
35402
- LEFT: 37,
35403
- UP: 38,
35404
- RIGHT: 39,
35405
- DOWN: 40,
35406
- DELETE: 46
35407
- };
35408
-
35409
- return KEYS;
35410
- });
35411
-
35412
- S2.define('select2/selection/base',[
35413
- 'jquery',
35414
- '../utils',
35415
- '../keys'
35416
- ], function ($, Utils, KEYS) {
35417
- function BaseSelection ($element, options) {
35418
- this.$element = $element;
35419
- this.options = options;
35420
-
35421
- BaseSelection.__super__.constructor.call(this);
35422
- }
35423
-
35424
- Utils.Extend(BaseSelection, Utils.Observable);
35425
-
35426
- BaseSelection.prototype.render = function () {
35427
- var $selection = $(
35428
- '<span class="select2-selection" role="combobox" ' +
35429
- ' aria-haspopup="true" aria-expanded="false">' +
35430
- '</span>'
35431
- );
35432
-
35433
- this._tabindex = 0;
35434
-
35435
- if (this.$element.data('old-tabindex') != null) {
35436
- this._tabindex = this.$element.data('old-tabindex');
35437
- } else if (this.$element.attr('tabindex') != null) {
35438
- this._tabindex = this.$element.attr('tabindex');
35439
- }
35440
-
35441
- $selection.attr('title', this.$element.attr('title'));
35442
- $selection.attr('tabindex', this._tabindex);
35443
-
35444
- this.$selection = $selection;
35445
-
35446
- return $selection;
35447
- };
35448
-
35449
- BaseSelection.prototype.bind = function (container, $container) {
35450
- var self = this;
35451
-
35452
- var id = container.id + '-container';
35453
- var resultsId = container.id + '-results';
35454
-
35455
- this.container = container;
35456
-
35457
- this.$selection.on('focus', function (evt) {
35458
- self.trigger('focus', evt);
35459
- });
35460
-
35461
- this.$selection.on('blur', function (evt) {
35462
- self._handleBlur(evt);
35463
- });
35464
-
35465
- this.$selection.on('keydown', function (evt) {
35466
- self.trigger('keypress', evt);
35467
-
35468
- if (evt.which === KEYS.SPACE) {
35469
- evt.preventDefault();
35470
- }
35471
- });
35472
-
35473
- container.on('results:focus', function (params) {
35474
- self.$selection.attr('aria-activedescendant', params.data._resultId);
35475
- });
35476
-
35477
- container.on('selection:update', function (params) {
35478
- self.update(params.data);
35479
- });
35480
-
35481
- container.on('open', function () {
35482
- // When the dropdown is open, aria-expanded="true"
35483
- self.$selection.attr('aria-expanded', 'true');
35484
- self.$selection.attr('aria-owns', resultsId);
35485
-
35486
- self._attachCloseHandler(container);
35487
- });
35488
-
35489
- container.on('close', function () {
35490
- // When the dropdown is closed, aria-expanded="false"
35491
- self.$selection.attr('aria-expanded', 'false');
35492
- self.$selection.removeAttr('aria-activedescendant');
35493
- self.$selection.removeAttr('aria-owns');
35494
-
35495
- self.$selection.focus();
35496
-
35497
- self._detachCloseHandler(container);
35498
- });
35499
-
35500
- container.on('enable', function () {
35501
- self.$selection.attr('tabindex', self._tabindex);
35502
- });
35503
-
35504
- container.on('disable', function () {
35505
- self.$selection.attr('tabindex', '-1');
35506
- });
35507
- };
35508
-
35509
- BaseSelection.prototype._handleBlur = function (evt) {
35510
- var self = this;
35511
-
35512
- // This needs to be delayed as the active element is the body when the tab
35513
- // key is pressed, possibly along with others.
35514
- window.setTimeout(function () {
35515
- // Don't trigger `blur` if the focus is still in the selection
35516
- if (
35517
- (document.activeElement == self.$selection[0]) ||
35518
- ($.contains(self.$selection[0], document.activeElement))
35519
- ) {
35520
- return;
35521
- }
35522
-
35523
- self.trigger('blur', evt);
35524
- }, 1);
35525
- };
35526
-
35527
- BaseSelection.prototype._attachCloseHandler = function (container) {
35528
- var self = this;
35529
-
35530
- $(document.body).on('mousedown.select2.' + container.id, function (e) {
35531
- var $target = $(e.target);
35532
-
35533
- var $select = $target.closest('.select2');
35534
-
35535
- var $all = $('.select2.select2-container--open');
35536
-
35537
- $all.each(function () {
35538
- var $this = $(this);
35539
-
35540
- if (this == $select[0]) {
35541
- return;
35542
- }
35543
-
35544
- var $element = $this.data('element');
35545
-
35546
- $element.select2('close');
35547
- });
35548
- });
35549
- };
35550
-
35551
- BaseSelection.prototype._detachCloseHandler = function (container) {
35552
- $(document.body).off('mousedown.select2.' + container.id);
35553
- };
35554
-
35555
- BaseSelection.prototype.position = function ($selection, $container) {
35556
- var $selectionContainer = $container.find('.selection');
35557
- $selectionContainer.append($selection);
35558
- };
35559
-
35560
- BaseSelection.prototype.destroy = function () {
35561
- this._detachCloseHandler(this.container);
35562
- };
35563
-
35564
- BaseSelection.prototype.update = function (data) {
35565
- throw new Error('The `update` method must be defined in child classes.');
35566
- };
35567
-
35568
- return BaseSelection;
35569
- });
35570
-
35571
- S2.define('select2/selection/single',[
35572
- 'jquery',
35573
- './base',
35574
- '../utils',
35575
- '../keys'
35576
- ], function ($, BaseSelection, Utils, KEYS) {
35577
- function SingleSelection () {
35578
- SingleSelection.__super__.constructor.apply(this, arguments);
35579
- }
35580
-
35581
- Utils.Extend(SingleSelection, BaseSelection);
35582
-
35583
- SingleSelection.prototype.render = function () {
35584
- var $selection = SingleSelection.__super__.render.call(this);
35585
-
35586
- $selection.addClass('select2-selection--single');
35587
-
35588
- $selection.html(
35589
- '<span class="select2-selection__rendered"></span>' +
35590
- '<span class="select2-selection__arrow" role="presentation">' +
35591
- '<b role="presentation"></b>' +
35592
- '</span>'
35593
- );
35594
-
35595
- return $selection;
35596
- };
35597
-
35598
- SingleSelection.prototype.bind = function (container, $container) {
35599
- var self = this;
35600
-
35601
- SingleSelection.__super__.bind.apply(this, arguments);
35602
-
35603
- var id = container.id + '-container';
35604
-
35605
- this.$selection.find('.select2-selection__rendered').attr('id', id);
35606
- this.$selection.attr('aria-labelledby', id);
35607
-
35608
- this.$selection.on('mousedown', function (evt) {
35609
- // Only respond to left clicks
35610
- if (evt.which !== 1) {
35611
- return;
35612
- }
35613
-
35614
- self.trigger('toggle', {
35615
- originalEvent: evt
35616
- });
35617
- });
35618
-
35619
- this.$selection.on('focus', function (evt) {
35620
- // User focuses on the container
35621
- });
35622
-
35623
- this.$selection.on('blur', function (evt) {
35624
- // User exits the container
35625
- });
35626
-
35627
- container.on('focus', function (evt) {
35628
- if (!container.isOpen()) {
35629
- self.$selection.focus();
35630
- }
35631
- });
35632
-
35633
- container.on('selection:update', function (params) {
35634
- self.update(params.data);
35635
- });
35636
- };
35637
-
35638
- SingleSelection.prototype.clear = function () {
35639
- this.$selection.find('.select2-selection__rendered').empty();
35640
- };
35641
-
35642
- SingleSelection.prototype.display = function (data, container) {
35643
- var template = this.options.get('templateSelection');
35644
- var escapeMarkup = this.options.get('escapeMarkup');
35645
-
35646
- return escapeMarkup(template(data, container));
35647
- };
35648
-
35649
- SingleSelection.prototype.selectionContainer = function () {
35650
- return $('<span></span>');
35651
- };
35652
-
35653
- SingleSelection.prototype.update = function (data) {
35654
- if (data.length === 0) {
35655
- this.clear();
35656
- return;
35657
- }
35658
-
35659
- var selection = data[0];
35660
-
35661
- var $rendered = this.$selection.find('.select2-selection__rendered');
35662
- var formatted = this.display(selection, $rendered);
35663
-
35664
- $rendered.empty().append(formatted);
35665
- $rendered.prop('title', selection.title || selection.text);
35666
- };
35667
-
35668
- return SingleSelection;
35669
- });
35670
-
35671
- S2.define('select2/selection/multiple',[
35672
- 'jquery',
35673
- './base',
35674
- '../utils'
35675
- ], function ($, BaseSelection, Utils) {
35676
- function MultipleSelection ($element, options) {
35677
- MultipleSelection.__super__.constructor.apply(this, arguments);
35678
- }
35679
-
35680
- Utils.Extend(MultipleSelection, BaseSelection);
35681
-
35682
- MultipleSelection.prototype.render = function () {
35683
- var $selection = MultipleSelection.__super__.render.call(this);
35684
-
35685
- $selection.addClass('select2-selection--multiple');
35686
-
35687
- $selection.html(
35688
- '<ul class="select2-selection__rendered"></ul>'
35689
- );
35690
-
35691
- return $selection;
35692
- };
35693
-
35694
- MultipleSelection.prototype.bind = function (container, $container) {
35695
- var self = this;
35696
-
35697
- MultipleSelection.__super__.bind.apply(this, arguments);
35698
-
35699
- this.$selection.on('click', function (evt) {
35700
- self.trigger('toggle', {
35701
- originalEvent: evt
35702
- });
35703
- });
35704
-
35705
- this.$selection.on(
35706
- 'click',
35707
- '.select2-selection__choice__remove',
35708
- function (evt) {
35709
- // Ignore the event if it is disabled
35710
- if (self.options.get('disabled')) {
35711
- return;
35712
- }
35713
-
35714
- var $remove = $(this);
35715
- var $selection = $remove.parent();
35716
-
35717
- var data = $selection.data('data');
35718
-
35719
- self.trigger('unselect', {
35720
- originalEvent: evt,
35721
- data: data
35722
- });
35723
- }
35724
- );
35725
- };
35726
-
35727
- MultipleSelection.prototype.clear = function () {
35728
- this.$selection.find('.select2-selection__rendered').empty();
35729
- };
35730
-
35731
- MultipleSelection.prototype.display = function (data, container) {
35732
- var template = this.options.get('templateSelection');
35733
- var escapeMarkup = this.options.get('escapeMarkup');
35734
-
35735
- return escapeMarkup(template(data, container));
35736
- };
35737
-
35738
- MultipleSelection.prototype.selectionContainer = function () {
35739
- var $container = $(
35740
- '<li class="select2-selection__choice">' +
35741
- '<span class="select2-selection__choice__remove" role="presentation">' +
35742
- '&times;' +
35743
- '</span>' +
35744
- '</li>'
35745
- );
35746
-
35747
- return $container;
35748
- };
35749
-
35750
- MultipleSelection.prototype.update = function (data) {
35751
- this.clear();
35752
-
35753
- if (data.length === 0) {
35754
- return;
35755
- }
35756
-
35757
- var $selections = [];
35758
-
35759
- for (var d = 0; d < data.length; d++) {
35760
- var selection = data[d];
35761
-
35762
- var $selection = this.selectionContainer();
35763
- var formatted = this.display(selection, $selection);
35764
-
35765
- $selection.append(formatted);
35766
- $selection.prop('title', selection.title || selection.text);
35767
-
35768
- $selection.data('data', selection);
35769
-
35770
- $selections.push($selection);
35771
- }
35772
-
35773
- var $rendered = this.$selection.find('.select2-selection__rendered');
35774
-
35775
- Utils.appendMany($rendered, $selections);
35776
- };
35777
-
35778
- return MultipleSelection;
35779
- });
35780
-
35781
- S2.define('select2/selection/placeholder',[
35782
- '../utils'
35783
- ], function (Utils) {
35784
- function Placeholder (decorated, $element, options) {
35785
- this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
35786
-
35787
- decorated.call(this, $element, options);
35788
- }
35789
-
35790
- Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
35791
- if (typeof placeholder === 'string') {
35792
- placeholder = {
35793
- id: '',
35794
- text: placeholder
35795
- };
35796
- }
35797
-
35798
- return placeholder;
35799
- };
35800
-
35801
- Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
35802
- var $placeholder = this.selectionContainer();
35803
-
35804
- $placeholder.html(this.display(placeholder));
35805
- $placeholder.addClass('select2-selection__placeholder')
35806
- .removeClass('select2-selection__choice');
35807
-
35808
- return $placeholder;
35809
- };
35810
-
35811
- Placeholder.prototype.update = function (decorated, data) {
35812
- var singlePlaceholder = (
35813
- data.length == 1 && data[0].id != this.placeholder.id
35814
- );
35815
- var multipleSelections = data.length > 1;
35816
-
35817
- if (multipleSelections || singlePlaceholder) {
35818
- return decorated.call(this, data);
35819
- }
35820
-
35821
- this.clear();
35822
-
35823
- var $placeholder = this.createPlaceholder(this.placeholder);
35824
-
35825
- this.$selection.find('.select2-selection__rendered').append($placeholder);
35826
- };
35827
-
35828
- return Placeholder;
35829
- });
35830
-
35831
- S2.define('select2/selection/allowClear',[
35832
- 'jquery',
35833
- '../keys'
35834
- ], function ($, KEYS) {
35835
- function AllowClear () { }
35836
-
35837
- AllowClear.prototype.bind = function (decorated, container, $container) {
35838
- var self = this;
35839
-
35840
- decorated.call(this, container, $container);
35841
-
35842
- if (this.placeholder == null) {
35843
- if (this.options.get('debug') && window.console && console.error) {
35844
- console.error(
35845
- 'Select2: The `allowClear` option should be used in combination ' +
35846
- 'with the `placeholder` option.'
35847
- );
35848
- }
35849
- }
35850
-
35851
- this.$selection.on('mousedown', '.select2-selection__clear',
35852
- function (evt) {
35853
- self._handleClear(evt);
35854
- });
35855
-
35856
- container.on('keypress', function (evt) {
35857
- self._handleKeyboardClear(evt, container);
35858
- });
35859
- };
35860
-
35861
- AllowClear.prototype._handleClear = function (_, evt) {
35862
- // Ignore the event if it is disabled
35863
- if (this.options.get('disabled')) {
35864
- return;
35865
- }
35866
-
35867
- var $clear = this.$selection.find('.select2-selection__clear');
35868
-
35869
- // Ignore the event if nothing has been selected
35870
- if ($clear.length === 0) {
35871
- return;
35872
- }
35873
-
35874
- evt.stopPropagation();
35875
-
35876
- var data = $clear.data('data');
35877
-
35878
- for (var d = 0; d < data.length; d++) {
35879
- var unselectData = {
35880
- data: data[d]
35881
- };
35882
-
35883
- // Trigger the `unselect` event, so people can prevent it from being
35884
- // cleared.
35885
- this.trigger('unselect', unselectData);
35886
-
35887
- // If the event was prevented, don't clear it out.
35888
- if (unselectData.prevented) {
35889
- return;
35890
- }
35891
- }
35892
-
35893
- this.$element.val(this.placeholder.id).trigger('change');
35894
-
35895
- this.trigger('toggle', {});
35896
- };
35897
-
35898
- AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
35899
- if (container.isOpen()) {
35900
- return;
35901
- }
35902
-
35903
- if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
35904
- this._handleClear(evt);
35905
- }
35906
- };
35907
-
35908
- AllowClear.prototype.update = function (decorated, data) {
35909
- decorated.call(this, data);
35910
-
35911
- if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
35912
- data.length === 0) {
35913
- return;
35914
- }
35915
-
35916
- var $remove = $(
35917
- '<span class="select2-selection__clear">' +
35918
- '&times;' +
35919
- '</span>'
35920
- );
35921
- $remove.data('data', data);
35922
-
35923
- this.$selection.find('.select2-selection__rendered').prepend($remove);
35924
- };
35925
-
35926
- return AllowClear;
35927
- });
35928
-
35929
- S2.define('select2/selection/search',[
35930
- 'jquery',
35931
- '../utils',
35932
- '../keys'
35933
- ], function ($, Utils, KEYS) {
35934
- function Search (decorated, $element, options) {
35935
- decorated.call(this, $element, options);
35936
- }
35937
-
35938
- Search.prototype.render = function (decorated) {
35939
- var $search = $(
35940
- '<li class="select2-search select2-search--inline">' +
35941
- '<input class="select2-search__field" type="search" tabindex="-1"' +
35942
- ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
35943
- ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
35944
- '</li>'
35945
- );
35946
-
35947
- this.$searchContainer = $search;
35948
- this.$search = $search.find('input');
35949
-
35950
- var $rendered = decorated.call(this);
35951
-
35952
- this._transferTabIndex();
35953
-
35954
- return $rendered;
35955
- };
35956
-
35957
- Search.prototype.bind = function (decorated, container, $container) {
35958
- var self = this;
35959
-
35960
- decorated.call(this, container, $container);
35961
-
35962
- container.on('open', function () {
35963
- self.$search.trigger('focus');
35964
- });
35965
-
35966
- container.on('close', function () {
35967
- self.$search.val('');
35968
- self.$search.removeAttr('aria-activedescendant');
35969
- self.$search.trigger('focus');
35970
- });
35971
-
35972
- container.on('enable', function () {
35973
- self.$search.prop('disabled', false);
35974
-
35975
- self._transferTabIndex();
35976
- });
35977
-
35978
- container.on('disable', function () {
35979
- self.$search.prop('disabled', true);
35980
- });
35981
-
35982
- container.on('focus', function (evt) {
35983
- self.$search.trigger('focus');
35984
- });
35985
-
35986
- container.on('results:focus', function (params) {
35987
- self.$search.attr('aria-activedescendant', params.id);
35988
- });
35989
-
35990
- this.$selection.on('focusin', '.select2-search--inline', function (evt) {
35991
- self.trigger('focus', evt);
35992
- });
35993
-
35994
- this.$selection.on('focusout', '.select2-search--inline', function (evt) {
35995
- self._handleBlur(evt);
35996
- });
35997
-
35998
- this.$selection.on('keydown', '.select2-search--inline', function (evt) {
35999
- evt.stopPropagation();
36000
-
36001
- self.trigger('keypress', evt);
36002
-
36003
- self._keyUpPrevented = evt.isDefaultPrevented();
36004
-
36005
- var key = evt.which;
36006
-
36007
- if (key === KEYS.BACKSPACE && self.$search.val() === '') {
36008
- var $previousChoice = self.$searchContainer
36009
- .prev('.select2-selection__choice');
36010
-
36011
- if ($previousChoice.length > 0) {
36012
- var item = $previousChoice.data('data');
36013
-
36014
- self.searchRemoveChoice(item);
36015
-
36016
- evt.preventDefault();
36017
- }
36018
- }
36019
- });
36020
-
36021
- // Try to detect the IE version should the `documentMode` property that
36022
- // is stored on the document. This is only implemented in IE and is
36023
- // slightly cleaner than doing a user agent check.
36024
- // This property is not available in Edge, but Edge also doesn't have
36025
- // this bug.
36026
- var msie = document.documentMode;
36027
- var disableInputEvents = msie && msie <= 11;
36028
-
36029
- // Workaround for browsers which do not support the `input` event
36030
- // This will prevent double-triggering of events for browsers which support
36031
- // both the `keyup` and `input` events.
36032
- this.$selection.on(
36033
- 'input.searchcheck',
36034
- '.select2-search--inline',
36035
- function (evt) {
36036
- // IE will trigger the `input` event when a placeholder is used on a
36037
- // search box. To get around this issue, we are forced to ignore all
36038
- // `input` events in IE and keep using `keyup`.
36039
- if (disableInputEvents) {
36040
- self.$selection.off('input.search input.searchcheck');
36041
- return;
36042
- }
36043
-
36044
- // Unbind the duplicated `keyup` event
36045
- self.$selection.off('keyup.search');
36046
- }
36047
- );
36048
-
36049
- this.$selection.on(
36050
- 'keyup.search input.search',
36051
- '.select2-search--inline',
36052
- function (evt) {
36053
- // IE will trigger the `input` event when a placeholder is used on a
36054
- // search box. To get around this issue, we are forced to ignore all
36055
- // `input` events in IE and keep using `keyup`.
36056
- if (disableInputEvents && evt.type === 'input') {
36057
- self.$selection.off('input.search input.searchcheck');
36058
- return;
36059
- }
36060
-
36061
- var key = evt.which;
36062
-
36063
- // We can freely ignore events from modifier keys
36064
- if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
36065
- return;
36066
- }
36067
-
36068
- // Tabbing will be handled during the `keydown` phase
36069
- if (key == KEYS.TAB) {
36070
- return;
36071
- }
36072
-
36073
- self.handleSearch(evt);
36074
- }
36075
- );
36076
- };
36077
-
36078
- /**
36079
- * This method will transfer the tabindex attribute from the rendered
36080
- * selection to the search box. This allows for the search box to be used as
36081
- * the primary focus instead of the selection container.
36082
- *
36083
- * @private
36084
- */
36085
- Search.prototype._transferTabIndex = function (decorated) {
36086
- this.$search.attr('tabindex', this.$selection.attr('tabindex'));
36087
- this.$selection.attr('tabindex', '-1');
36088
- };
36089
-
36090
- Search.prototype.createPlaceholder = function (decorated, placeholder) {
36091
- this.$search.attr('placeholder', placeholder.text);
36092
- };
36093
-
36094
- Search.prototype.update = function (decorated, data) {
36095
- var searchHadFocus = this.$search[0] == document.activeElement;
36096
-
36097
- this.$search.attr('placeholder', '');
36098
-
36099
- decorated.call(this, data);
36100
-
36101
- this.$selection.find('.select2-selection__rendered')
36102
- .append(this.$searchContainer);
36103
-
36104
- this.resizeSearch();
36105
- if (searchHadFocus) {
36106
- this.$search.focus();
36107
- }
36108
- };
36109
-
36110
- Search.prototype.handleSearch = function () {
36111
- this.resizeSearch();
36112
-
36113
- if (!this._keyUpPrevented) {
36114
- var input = this.$search.val();
36115
-
36116
- this.trigger('query', {
36117
- term: input
36118
- });
36119
- }
36120
-
36121
- this._keyUpPrevented = false;
36122
- };
36123
-
36124
- Search.prototype.searchRemoveChoice = function (decorated, item) {
36125
- this.trigger('unselect', {
36126
- data: item
36127
- });
36128
-
36129
- this.$search.val(item.text);
36130
- this.handleSearch();
36131
- };
36132
-
36133
- Search.prototype.resizeSearch = function () {
36134
- this.$search.css('width', '25px');
36135
-
36136
- var width = '';
36137
-
36138
- if (this.$search.attr('placeholder') !== '') {
36139
- width = this.$selection.find('.select2-selection__rendered').innerWidth();
36140
- } else {
36141
- var minimumWidth = this.$search.val().length + 1;
36142
-
36143
- width = (minimumWidth * 0.75) + 'em';
36144
- }
36145
-
36146
- this.$search.css('width', width);
36147
- };
36148
-
36149
- return Search;
36150
- });
36151
-
36152
- S2.define('select2/selection/eventRelay',[
36153
- 'jquery'
36154
- ], function ($) {
36155
- function EventRelay () { }
36156
-
36157
- EventRelay.prototype.bind = function (decorated, container, $container) {
36158
- var self = this;
36159
- var relayEvents = [
36160
- 'open', 'opening',
36161
- 'close', 'closing',
36162
- 'select', 'selecting',
36163
- 'unselect', 'unselecting'
36164
- ];
36165
-
36166
- var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
36167
-
36168
- decorated.call(this, container, $container);
36169
-
36170
- container.on('*', function (name, params) {
36171
- // Ignore events that should not be relayed
36172
- if ($.inArray(name, relayEvents) === -1) {
36173
- return;
36174
- }
36175
-
36176
- // The parameters should always be an object
36177
- params = params || {};
36178
-
36179
- // Generate the jQuery event for the Select2 event
36180
- var evt = $.Event('select2:' + name, {
36181
- params: params
36182
- });
36183
-
36184
- self.$element.trigger(evt);
36185
-
36186
- // Only handle preventable events if it was one
36187
- if ($.inArray(name, preventableEvents) === -1) {
36188
- return;
36189
- }
36190
-
36191
- params.prevented = evt.isDefaultPrevented();
36192
- });
36193
- };
36194
-
36195
- return EventRelay;
36196
- });
36197
-
36198
- S2.define('select2/translation',[
36199
- 'jquery',
36200
- 'require'
36201
- ], function ($, require) {
36202
- function Translation (dict) {
36203
- this.dict = dict || {};
36204
- }
36205
-
36206
- Translation.prototype.all = function () {
36207
- return this.dict;
36208
- };
36209
-
36210
- Translation.prototype.get = function (key) {
36211
- return this.dict[key];
36212
- };
36213
-
36214
- Translation.prototype.extend = function (translation) {
36215
- this.dict = $.extend({}, translation.all(), this.dict);
36216
- };
36217
-
36218
- // Static functions
36219
-
36220
- Translation._cache = {};
36221
-
36222
- Translation.loadPath = function (path) {
36223
- if (!(path in Translation._cache)) {
36224
- var translations = require(path);
36225
-
36226
- Translation._cache[path] = translations;
36227
- }
36228
-
36229
- return new Translation(Translation._cache[path]);
36230
- };
36231
-
36232
- return Translation;
36233
- });
36234
-
36235
- S2.define('select2/diacritics',[
36236
-
36237
- ], function () {
36238
- var diacritics = {
36239
- '\u24B6': 'A',
36240
- '\uFF21': 'A',
36241
- '\u00C0': 'A',
36242
- '\u00C1': 'A',
36243
- '\u00C2': 'A',
36244
- '\u1EA6': 'A',
36245
- '\u1EA4': 'A',
36246
- '\u1EAA': 'A',
36247
- '\u1EA8': 'A',
36248
- '\u00C3': 'A',
36249
- '\u0100': 'A',
36250
- '\u0102': 'A',
36251
- '\u1EB0': 'A',
36252
- '\u1EAE': 'A',
36253
- '\u1EB4': 'A',
36254
- '\u1EB2': 'A',
36255
- '\u0226': 'A',
36256
- '\u01E0': 'A',
36257
- '\u00C4': 'A',
36258
- '\u01DE': 'A',
36259
- '\u1EA2': 'A',
36260
- '\u00C5': 'A',
36261
- '\u01FA': 'A',
36262
- '\u01CD': 'A',
36263
- '\u0200': 'A',
36264
- '\u0202': 'A',
36265
- '\u1EA0': 'A',
36266
- '\u1EAC': 'A',
36267
- '\u1EB6': 'A',
36268
- '\u1E00': 'A',
36269
- '\u0104': 'A',
36270
- '\u023A': 'A',
36271
- '\u2C6F': 'A',
36272
- '\uA732': 'AA',
36273
- '\u00C6': 'AE',
36274
- '\u01FC': 'AE',
36275
- '\u01E2': 'AE',
36276
- '\uA734': 'AO',
36277
- '\uA736': 'AU',
36278
- '\uA738': 'AV',
36279
- '\uA73A': 'AV',
36280
- '\uA73C': 'AY',
36281
- '\u24B7': 'B',
36282
- '\uFF22': 'B',
36283
- '\u1E02': 'B',
36284
- '\u1E04': 'B',
36285
- '\u1E06': 'B',
36286
- '\u0243': 'B',
36287
- '\u0182': 'B',
36288
- '\u0181': 'B',
36289
- '\u24B8': 'C',
36290
- '\uFF23': 'C',
36291
- '\u0106': 'C',
36292
- '\u0108': 'C',
36293
- '\u010A': 'C',
36294
- '\u010C': 'C',
36295
- '\u00C7': 'C',
36296
- '\u1E08': 'C',
36297
- '\u0187': 'C',
36298
- '\u023B': 'C',
36299
- '\uA73E': 'C',
36300
- '\u24B9': 'D',
36301
- '\uFF24': 'D',
36302
- '\u1E0A': 'D',
36303
- '\u010E': 'D',
36304
- '\u1E0C': 'D',
36305
- '\u1E10': 'D',
36306
- '\u1E12': 'D',
36307
- '\u1E0E': 'D',
36308
- '\u0110': 'D',
36309
- '\u018B': 'D',
36310
- '\u018A': 'D',
36311
- '\u0189': 'D',
36312
- '\uA779': 'D',
36313
- '\u01F1': 'DZ',
36314
- '\u01C4': 'DZ',
36315
- '\u01F2': 'Dz',
36316
- '\u01C5': 'Dz',
36317
- '\u24BA': 'E',
36318
- '\uFF25': 'E',
36319
- '\u00C8': 'E',
36320
- '\u00C9': 'E',
36321
- '\u00CA': 'E',
36322
- '\u1EC0': 'E',
36323
- '\u1EBE': 'E',
36324
- '\u1EC4': 'E',
36325
- '\u1EC2': 'E',
36326
- '\u1EBC': 'E',
36327
- '\u0112': 'E',
36328
- '\u1E14': 'E',
36329
- '\u1E16': 'E',
36330
- '\u0114': 'E',
36331
- '\u0116': 'E',
36332
- '\u00CB': 'E',
36333
- '\u1EBA': 'E',
36334
- '\u011A': 'E',
36335
- '\u0204': 'E',
36336
- '\u0206': 'E',
36337
- '\u1EB8': 'E',
36338
- '\u1EC6': 'E',
36339
- '\u0228': 'E',
36340
- '\u1E1C': 'E',
36341
- '\u0118': 'E',
36342
- '\u1E18': 'E',
36343
- '\u1E1A': 'E',
36344
- '\u0190': 'E',
36345
- '\u018E': 'E',
36346
- '\u24BB': 'F',
36347
- '\uFF26': 'F',
36348
- '\u1E1E': 'F',
36349
- '\u0191': 'F',
36350
- '\uA77B': 'F',
36351
- '\u24BC': 'G',
36352
- '\uFF27': 'G',
36353
- '\u01F4': 'G',
36354
- '\u011C': 'G',
36355
- '\u1E20': 'G',
36356
- '\u011E': 'G',
36357
- '\u0120': 'G',
36358
- '\u01E6': 'G',
36359
- '\u0122': 'G',
36360
- '\u01E4': 'G',
36361
- '\u0193': 'G',
36362
- '\uA7A0': 'G',
36363
- '\uA77D': 'G',
36364
- '\uA77E': 'G',
36365
- '\u24BD': 'H',
36366
- '\uFF28': 'H',
36367
- '\u0124': 'H',
36368
- '\u1E22': 'H',
36369
- '\u1E26': 'H',
36370
- '\u021E': 'H',
36371
- '\u1E24': 'H',
36372
- '\u1E28': 'H',
36373
- '\u1E2A': 'H',
36374
- '\u0126': 'H',
36375
- '\u2C67': 'H',
36376
- '\u2C75': 'H',
36377
- '\uA78D': 'H',
36378
- '\u24BE': 'I',
36379
- '\uFF29': 'I',
36380
- '\u00CC': 'I',
36381
- '\u00CD': 'I',
36382
- '\u00CE': 'I',
36383
- '\u0128': 'I',
36384
- '\u012A': 'I',
36385
- '\u012C': 'I',
36386
- '\u0130': 'I',
36387
- '\u00CF': 'I',
36388
- '\u1E2E': 'I',
36389
- '\u1EC8': 'I',
36390
- '\u01CF': 'I',
36391
- '\u0208': 'I',
36392
- '\u020A': 'I',
36393
- '\u1ECA': 'I',
36394
- '\u012E': 'I',
36395
- '\u1E2C': 'I',
36396
- '\u0197': 'I',
36397
- '\u24BF': 'J',
36398
- '\uFF2A': 'J',
36399
- '\u0134': 'J',
36400
- '\u0248': 'J',
36401
- '\u24C0': 'K',
36402
- '\uFF2B': 'K',
36403
- '\u1E30': 'K',
36404
- '\u01E8': 'K',
36405
- '\u1E32': 'K',
36406
- '\u0136': 'K',
36407
- '\u1E34': 'K',
36408
- '\u0198': 'K',
36409
- '\u2C69': 'K',
36410
- '\uA740': 'K',
36411
- '\uA742': 'K',
36412
- '\uA744': 'K',
36413
- '\uA7A2': 'K',
36414
- '\u24C1': 'L',
36415
- '\uFF2C': 'L',
36416
- '\u013F': 'L',
36417
- '\u0139': 'L',
36418
- '\u013D': 'L',
36419
- '\u1E36': 'L',
36420
- '\u1E38': 'L',
36421
- '\u013B': 'L',
36422
- '\u1E3C': 'L',
36423
- '\u1E3A': 'L',
36424
- '\u0141': 'L',
36425
- '\u023D': 'L',
36426
- '\u2C62': 'L',
36427
- '\u2C60': 'L',
36428
- '\uA748': 'L',
36429
- '\uA746': 'L',
36430
- '\uA780': 'L',
36431
- '\u01C7': 'LJ',
36432
- '\u01C8': 'Lj',
36433
- '\u24C2': 'M',
36434
- '\uFF2D': 'M',
36435
- '\u1E3E': 'M',
36436
- '\u1E40': 'M',
36437
- '\u1E42': 'M',
36438
- '\u2C6E': 'M',
36439
- '\u019C': 'M',
36440
- '\u24C3': 'N',
36441
- '\uFF2E': 'N',
36442
- '\u01F8': 'N',
36443
- '\u0143': 'N',
36444
- '\u00D1': 'N',
36445
- '\u1E44': 'N',
36446
- '\u0147': 'N',
36447
- '\u1E46': 'N',
36448
- '\u0145': 'N',
36449
- '\u1E4A': 'N',
36450
- '\u1E48': 'N',
36451
- '\u0220': 'N',
36452
- '\u019D': 'N',
36453
- '\uA790': 'N',
36454
- '\uA7A4': 'N',
36455
- '\u01CA': 'NJ',
36456
- '\u01CB': 'Nj',
36457
- '\u24C4': 'O',
36458
- '\uFF2F': 'O',
36459
- '\u00D2': 'O',
36460
- '\u00D3': 'O',
36461
- '\u00D4': 'O',
36462
- '\u1ED2': 'O',
36463
- '\u1ED0': 'O',
36464
- '\u1ED6': 'O',
36465
- '\u1ED4': 'O',
36466
- '\u00D5': 'O',
36467
- '\u1E4C': 'O',
36468
- '\u022C': 'O',
36469
- '\u1E4E': 'O',
36470
- '\u014C': 'O',
36471
- '\u1E50': 'O',
36472
- '\u1E52': 'O',
36473
- '\u014E': 'O',
36474
- '\u022E': 'O',
36475
- '\u0230': 'O',
36476
- '\u00D6': 'O',
36477
- '\u022A': 'O',
36478
- '\u1ECE': 'O',
36479
- '\u0150': 'O',
36480
- '\u01D1': 'O',
36481
- '\u020C': 'O',
36482
- '\u020E': 'O',
36483
- '\u01A0': 'O',
36484
- '\u1EDC': 'O',
36485
- '\u1EDA': 'O',
36486
- '\u1EE0': 'O',
36487
- '\u1EDE': 'O',
36488
- '\u1EE2': 'O',
36489
- '\u1ECC': 'O',
36490
- '\u1ED8': 'O',
36491
- '\u01EA': 'O',
36492
- '\u01EC': 'O',
36493
- '\u00D8': 'O',
36494
- '\u01FE': 'O',
36495
- '\u0186': 'O',
36496
- '\u019F': 'O',
36497
- '\uA74A': 'O',
36498
- '\uA74C': 'O',
36499
- '\u01A2': 'OI',
36500
- '\uA74E': 'OO',
36501
- '\u0222': 'OU',
36502
- '\u24C5': 'P',
36503
- '\uFF30': 'P',
36504
- '\u1E54': 'P',
36505
- '\u1E56': 'P',
36506
- '\u01A4': 'P',
36507
- '\u2C63': 'P',
36508
- '\uA750': 'P',
36509
- '\uA752': 'P',
36510
- '\uA754': 'P',
36511
- '\u24C6': 'Q',
36512
- '\uFF31': 'Q',
36513
- '\uA756': 'Q',
36514
- '\uA758': 'Q',
36515
- '\u024A': 'Q',
36516
- '\u24C7': 'R',
36517
- '\uFF32': 'R',
36518
- '\u0154': 'R',
36519
- '\u1E58': 'R',
36520
- '\u0158': 'R',
36521
- '\u0210': 'R',
36522
- '\u0212': 'R',
36523
- '\u1E5A': 'R',
36524
- '\u1E5C': 'R',
36525
- '\u0156': 'R',
36526
- '\u1E5E': 'R',
36527
- '\u024C': 'R',
36528
- '\u2C64': 'R',
36529
- '\uA75A': 'R',
36530
- '\uA7A6': 'R',
36531
- '\uA782': 'R',
36532
- '\u24C8': 'S',
36533
- '\uFF33': 'S',
36534
- '\u1E9E': 'S',
36535
- '\u015A': 'S',
36536
- '\u1E64': 'S',
36537
- '\u015C': 'S',
36538
- '\u1E60': 'S',
36539
- '\u0160': 'S',
36540
- '\u1E66': 'S',
36541
- '\u1E62': 'S',
36542
- '\u1E68': 'S',
36543
- '\u0218': 'S',
36544
- '\u015E': 'S',
36545
- '\u2C7E': 'S',
36546
- '\uA7A8': 'S',
36547
- '\uA784': 'S',
36548
- '\u24C9': 'T',
36549
- '\uFF34': 'T',
36550
- '\u1E6A': 'T',
36551
- '\u0164': 'T',
36552
- '\u1E6C': 'T',
36553
- '\u021A': 'T',
36554
- '\u0162': 'T',
36555
- '\u1E70': 'T',
36556
- '\u1E6E': 'T',
36557
- '\u0166': 'T',
36558
- '\u01AC': 'T',
36559
- '\u01AE': 'T',
36560
- '\u023E': 'T',
36561
- '\uA786': 'T',
36562
- '\uA728': 'TZ',
36563
- '\u24CA': 'U',
36564
- '\uFF35': 'U',
36565
- '\u00D9': 'U',
36566
- '\u00DA': 'U',
36567
- '\u00DB': 'U',
36568
- '\u0168': 'U',
36569
- '\u1E78': 'U',
36570
- '\u016A': 'U',
36571
- '\u1E7A': 'U',
36572
- '\u016C': 'U',
36573
- '\u00DC': 'U',
36574
- '\u01DB': 'U',
36575
- '\u01D7': 'U',
36576
- '\u01D5': 'U',
36577
- '\u01D9': 'U',
36578
- '\u1EE6': 'U',
36579
- '\u016E': 'U',
36580
- '\u0170': 'U',
36581
- '\u01D3': 'U',
36582
- '\u0214': 'U',
36583
- '\u0216': 'U',
36584
- '\u01AF': 'U',
36585
- '\u1EEA': 'U',
36586
- '\u1EE8': 'U',
36587
- '\u1EEE': 'U',
36588
- '\u1EEC': 'U',
36589
- '\u1EF0': 'U',
36590
- '\u1EE4': 'U',
36591
- '\u1E72': 'U',
36592
- '\u0172': 'U',
36593
- '\u1E76': 'U',
36594
- '\u1E74': 'U',
36595
- '\u0244': 'U',
36596
- '\u24CB': 'V',
36597
- '\uFF36': 'V',
36598
- '\u1E7C': 'V',
36599
- '\u1E7E': 'V',
36600
- '\u01B2': 'V',
36601
- '\uA75E': 'V',
36602
- '\u0245': 'V',
36603
- '\uA760': 'VY',
36604
- '\u24CC': 'W',
36605
- '\uFF37': 'W',
36606
- '\u1E80': 'W',
36607
- '\u1E82': 'W',
36608
- '\u0174': 'W',
36609
- '\u1E86': 'W',
36610
- '\u1E84': 'W',
36611
- '\u1E88': 'W',
36612
- '\u2C72': 'W',
36613
- '\u24CD': 'X',
36614
- '\uFF38': 'X',
36615
- '\u1E8A': 'X',
36616
- '\u1E8C': 'X',
36617
- '\u24CE': 'Y',
36618
- '\uFF39': 'Y',
36619
- '\u1EF2': 'Y',
36620
- '\u00DD': 'Y',
36621
- '\u0176': 'Y',
36622
- '\u1EF8': 'Y',
36623
- '\u0232': 'Y',
36624
- '\u1E8E': 'Y',
36625
- '\u0178': 'Y',
36626
- '\u1EF6': 'Y',
36627
- '\u1EF4': 'Y',
36628
- '\u01B3': 'Y',
36629
- '\u024E': 'Y',
36630
- '\u1EFE': 'Y',
36631
- '\u24CF': 'Z',
36632
- '\uFF3A': 'Z',
36633
- '\u0179': 'Z',
36634
- '\u1E90': 'Z',
36635
- '\u017B': 'Z',
36636
- '\u017D': 'Z',
36637
- '\u1E92': 'Z',
36638
- '\u1E94': 'Z',
36639
- '\u01B5': 'Z',
36640
- '\u0224': 'Z',
36641
- '\u2C7F': 'Z',
36642
- '\u2C6B': 'Z',
36643
- '\uA762': 'Z',
36644
- '\u24D0': 'a',
36645
- '\uFF41': 'a',
36646
- '\u1E9A': 'a',
36647
- '\u00E0': 'a',
36648
- '\u00E1': 'a',
36649
- '\u00E2': 'a',
36650
- '\u1EA7': 'a',
36651
- '\u1EA5': 'a',
36652
- '\u1EAB': 'a',
36653
- '\u1EA9': 'a',
36654
- '\u00E3': 'a',
36655
- '\u0101': 'a',
36656
- '\u0103': 'a',
36657
- '\u1EB1': 'a',
36658
- '\u1EAF': 'a',
36659
- '\u1EB5': 'a',
36660
- '\u1EB3': 'a',
36661
- '\u0227': 'a',
36662
- '\u01E1': 'a',
36663
- '\u00E4': 'a',
36664
- '\u01DF': 'a',
36665
- '\u1EA3': 'a',
36666
- '\u00E5': 'a',
36667
- '\u01FB': 'a',
36668
- '\u01CE': 'a',
36669
- '\u0201': 'a',
36670
- '\u0203': 'a',
36671
- '\u1EA1': 'a',
36672
- '\u1EAD': 'a',
36673
- '\u1EB7': 'a',
36674
- '\u1E01': 'a',
36675
- '\u0105': 'a',
36676
- '\u2C65': 'a',
36677
- '\u0250': 'a',
36678
- '\uA733': 'aa',
36679
- '\u00E6': 'ae',
36680
- '\u01FD': 'ae',
36681
- '\u01E3': 'ae',
36682
- '\uA735': 'ao',
36683
- '\uA737': 'au',
36684
- '\uA739': 'av',
36685
- '\uA73B': 'av',
36686
- '\uA73D': 'ay',
36687
- '\u24D1': 'b',
36688
- '\uFF42': 'b',
36689
- '\u1E03': 'b',
36690
- '\u1E05': 'b',
36691
- '\u1E07': 'b',
36692
- '\u0180': 'b',
36693
- '\u0183': 'b',
36694
- '\u0253': 'b',
36695
- '\u24D2': 'c',
36696
- '\uFF43': 'c',
36697
- '\u0107': 'c',
36698
- '\u0109': 'c',
36699
- '\u010B': 'c',
36700
- '\u010D': 'c',
36701
- '\u00E7': 'c',
36702
- '\u1E09': 'c',
36703
- '\u0188': 'c',
36704
- '\u023C': 'c',
36705
- '\uA73F': 'c',
36706
- '\u2184': 'c',
36707
- '\u24D3': 'd',
36708
- '\uFF44': 'd',
36709
- '\u1E0B': 'd',
36710
- '\u010F': 'd',
36711
- '\u1E0D': 'd',
36712
- '\u1E11': 'd',
36713
- '\u1E13': 'd',
36714
- '\u1E0F': 'd',
36715
- '\u0111': 'd',
36716
- '\u018C': 'd',
36717
- '\u0256': 'd',
36718
- '\u0257': 'd',
36719
- '\uA77A': 'd',
36720
- '\u01F3': 'dz',
36721
- '\u01C6': 'dz',
36722
- '\u24D4': 'e',
36723
- '\uFF45': 'e',
36724
- '\u00E8': 'e',
36725
- '\u00E9': 'e',
36726
- '\u00EA': 'e',
36727
- '\u1EC1': 'e',
36728
- '\u1EBF': 'e',
36729
- '\u1EC5': 'e',
36730
- '\u1EC3': 'e',
36731
- '\u1EBD': 'e',
36732
- '\u0113': 'e',
36733
- '\u1E15': 'e',
36734
- '\u1E17': 'e',
36735
- '\u0115': 'e',
36736
- '\u0117': 'e',
36737
- '\u00EB': 'e',
36738
- '\u1EBB': 'e',
36739
- '\u011B': 'e',
36740
- '\u0205': 'e',
36741
- '\u0207': 'e',
36742
- '\u1EB9': 'e',
36743
- '\u1EC7': 'e',
36744
- '\u0229': 'e',
36745
- '\u1E1D': 'e',
36746
- '\u0119': 'e',
36747
- '\u1E19': 'e',
36748
- '\u1E1B': 'e',
36749
- '\u0247': 'e',
36750
- '\u025B': 'e',
36751
- '\u01DD': 'e',
36752
- '\u24D5': 'f',
36753
- '\uFF46': 'f',
36754
- '\u1E1F': 'f',
36755
- '\u0192': 'f',
36756
- '\uA77C': 'f',
36757
- '\u24D6': 'g',
36758
- '\uFF47': 'g',
36759
- '\u01F5': 'g',
36760
- '\u011D': 'g',
36761
- '\u1E21': 'g',
36762
- '\u011F': 'g',
36763
- '\u0121': 'g',
36764
- '\u01E7': 'g',
36765
- '\u0123': 'g',
36766
- '\u01E5': 'g',
36767
- '\u0260': 'g',
36768
- '\uA7A1': 'g',
36769
- '\u1D79': 'g',
36770
- '\uA77F': 'g',
36771
- '\u24D7': 'h',
36772
- '\uFF48': 'h',
36773
- '\u0125': 'h',
36774
- '\u1E23': 'h',
36775
- '\u1E27': 'h',
36776
- '\u021F': 'h',
36777
- '\u1E25': 'h',
36778
- '\u1E29': 'h',
36779
- '\u1E2B': 'h',
36780
- '\u1E96': 'h',
36781
- '\u0127': 'h',
36782
- '\u2C68': 'h',
36783
- '\u2C76': 'h',
36784
- '\u0265': 'h',
36785
- '\u0195': 'hv',
36786
- '\u24D8': 'i',
36787
- '\uFF49': 'i',
36788
- '\u00EC': 'i',
36789
- '\u00ED': 'i',
36790
- '\u00EE': 'i',
36791
- '\u0129': 'i',
36792
- '\u012B': 'i',
36793
- '\u012D': 'i',
36794
- '\u00EF': 'i',
36795
- '\u1E2F': 'i',
36796
- '\u1EC9': 'i',
36797
- '\u01D0': 'i',
36798
- '\u0209': 'i',
36799
- '\u020B': 'i',
36800
- '\u1ECB': 'i',
36801
- '\u012F': 'i',
36802
- '\u1E2D': 'i',
36803
- '\u0268': 'i',
36804
- '\u0131': 'i',
36805
- '\u24D9': 'j',
36806
- '\uFF4A': 'j',
36807
- '\u0135': 'j',
36808
- '\u01F0': 'j',
36809
- '\u0249': 'j',
36810
- '\u24DA': 'k',
36811
- '\uFF4B': 'k',
36812
- '\u1E31': 'k',
36813
- '\u01E9': 'k',
36814
- '\u1E33': 'k',
36815
- '\u0137': 'k',
36816
- '\u1E35': 'k',
36817
- '\u0199': 'k',
36818
- '\u2C6A': 'k',
36819
- '\uA741': 'k',
36820
- '\uA743': 'k',
36821
- '\uA745': 'k',
36822
- '\uA7A3': 'k',
36823
- '\u24DB': 'l',
36824
- '\uFF4C': 'l',
36825
- '\u0140': 'l',
36826
- '\u013A': 'l',
36827
- '\u013E': 'l',
36828
- '\u1E37': 'l',
36829
- '\u1E39': 'l',
36830
- '\u013C': 'l',
36831
- '\u1E3D': 'l',
36832
- '\u1E3B': 'l',
36833
- '\u017F': 'l',
36834
- '\u0142': 'l',
36835
- '\u019A': 'l',
36836
- '\u026B': 'l',
36837
- '\u2C61': 'l',
36838
- '\uA749': 'l',
36839
- '\uA781': 'l',
36840
- '\uA747': 'l',
36841
- '\u01C9': 'lj',
36842
- '\u24DC': 'm',
36843
- '\uFF4D': 'm',
36844
- '\u1E3F': 'm',
36845
- '\u1E41': 'm',
36846
- '\u1E43': 'm',
36847
- '\u0271': 'm',
36848
- '\u026F': 'm',
36849
- '\u24DD': 'n',
36850
- '\uFF4E': 'n',
36851
- '\u01F9': 'n',
36852
- '\u0144': 'n',
36853
- '\u00F1': 'n',
36854
- '\u1E45': 'n',
36855
- '\u0148': 'n',
36856
- '\u1E47': 'n',
36857
- '\u0146': 'n',
36858
- '\u1E4B': 'n',
36859
- '\u1E49': 'n',
36860
- '\u019E': 'n',
36861
- '\u0272': 'n',
36862
- '\u0149': 'n',
36863
- '\uA791': 'n',
36864
- '\uA7A5': 'n',
36865
- '\u01CC': 'nj',
36866
- '\u24DE': 'o',
36867
- '\uFF4F': 'o',
36868
- '\u00F2': 'o',
36869
- '\u00F3': 'o',
36870
- '\u00F4': 'o',
36871
- '\u1ED3': 'o',
36872
- '\u1ED1': 'o',
36873
- '\u1ED7': 'o',
36874
- '\u1ED5': 'o',
36875
- '\u00F5': 'o',
36876
- '\u1E4D': 'o',
36877
- '\u022D': 'o',
36878
- '\u1E4F': 'o',
36879
- '\u014D': 'o',
36880
- '\u1E51': 'o',
36881
- '\u1E53': 'o',
36882
- '\u014F': 'o',
36883
- '\u022F': 'o',
36884
- '\u0231': 'o',
36885
- '\u00F6': 'o',
36886
- '\u022B': 'o',
36887
- '\u1ECF': 'o',
36888
- '\u0151': 'o',
36889
- '\u01D2': 'o',
36890
- '\u020D': 'o',
36891
- '\u020F': 'o',
36892
- '\u01A1': 'o',
36893
- '\u1EDD': 'o',
36894
- '\u1EDB': 'o',
36895
- '\u1EE1': 'o',
36896
- '\u1EDF': 'o',
36897
- '\u1EE3': 'o',
36898
- '\u1ECD': 'o',
36899
- '\u1ED9': 'o',
36900
- '\u01EB': 'o',
36901
- '\u01ED': 'o',
36902
- '\u00F8': 'o',
36903
- '\u01FF': 'o',
36904
- '\u0254': 'o',
36905
- '\uA74B': 'o',
36906
- '\uA74D': 'o',
36907
- '\u0275': 'o',
36908
- '\u01A3': 'oi',
36909
- '\u0223': 'ou',
36910
- '\uA74F': 'oo',
36911
- '\u24DF': 'p',
36912
- '\uFF50': 'p',
36913
- '\u1E55': 'p',
36914
- '\u1E57': 'p',
36915
- '\u01A5': 'p',
36916
- '\u1D7D': 'p',
36917
- '\uA751': 'p',
36918
- '\uA753': 'p',
36919
- '\uA755': 'p',
36920
- '\u24E0': 'q',
36921
- '\uFF51': 'q',
36922
- '\u024B': 'q',
36923
- '\uA757': 'q',
36924
- '\uA759': 'q',
36925
- '\u24E1': 'r',
36926
- '\uFF52': 'r',
36927
- '\u0155': 'r',
36928
- '\u1E59': 'r',
36929
- '\u0159': 'r',
36930
- '\u0211': 'r',
36931
- '\u0213': 'r',
36932
- '\u1E5B': 'r',
36933
- '\u1E5D': 'r',
36934
- '\u0157': 'r',
36935
- '\u1E5F': 'r',
36936
- '\u024D': 'r',
36937
- '\u027D': 'r',
36938
- '\uA75B': 'r',
36939
- '\uA7A7': 'r',
36940
- '\uA783': 'r',
36941
- '\u24E2': 's',
36942
- '\uFF53': 's',
36943
- '\u00DF': 's',
36944
- '\u015B': 's',
36945
- '\u1E65': 's',
36946
- '\u015D': 's',
36947
- '\u1E61': 's',
36948
- '\u0161': 's',
36949
- '\u1E67': 's',
36950
- '\u1E63': 's',
36951
- '\u1E69': 's',
36952
- '\u0219': 's',
36953
- '\u015F': 's',
36954
- '\u023F': 's',
36955
- '\uA7A9': 's',
36956
- '\uA785': 's',
36957
- '\u1E9B': 's',
36958
- '\u24E3': 't',
36959
- '\uFF54': 't',
36960
- '\u1E6B': 't',
36961
- '\u1E97': 't',
36962
- '\u0165': 't',
36963
- '\u1E6D': 't',
36964
- '\u021B': 't',
36965
- '\u0163': 't',
36966
- '\u1E71': 't',
36967
- '\u1E6F': 't',
36968
- '\u0167': 't',
36969
- '\u01AD': 't',
36970
- '\u0288': 't',
36971
- '\u2C66': 't',
36972
- '\uA787': 't',
36973
- '\uA729': 'tz',
36974
- '\u24E4': 'u',
36975
- '\uFF55': 'u',
36976
- '\u00F9': 'u',
36977
- '\u00FA': 'u',
36978
- '\u00FB': 'u',
36979
- '\u0169': 'u',
36980
- '\u1E79': 'u',
36981
- '\u016B': 'u',
36982
- '\u1E7B': 'u',
36983
- '\u016D': 'u',
36984
- '\u00FC': 'u',
36985
- '\u01DC': 'u',
36986
- '\u01D8': 'u',
36987
- '\u01D6': 'u',
36988
- '\u01DA': 'u',
36989
- '\u1EE7': 'u',
36990
- '\u016F': 'u',
36991
- '\u0171': 'u',
36992
- '\u01D4': 'u',
36993
- '\u0215': 'u',
36994
- '\u0217': 'u',
36995
- '\u01B0': 'u',
36996
- '\u1EEB': 'u',
36997
- '\u1EE9': 'u',
36998
- '\u1EEF': 'u',
36999
- '\u1EED': 'u',
37000
- '\u1EF1': 'u',
37001
- '\u1EE5': 'u',
37002
- '\u1E73': 'u',
37003
- '\u0173': 'u',
37004
- '\u1E77': 'u',
37005
- '\u1E75': 'u',
37006
- '\u0289': 'u',
37007
- '\u24E5': 'v',
37008
- '\uFF56': 'v',
37009
- '\u1E7D': 'v',
37010
- '\u1E7F': 'v',
37011
- '\u028B': 'v',
37012
- '\uA75F': 'v',
37013
- '\u028C': 'v',
37014
- '\uA761': 'vy',
37015
- '\u24E6': 'w',
37016
- '\uFF57': 'w',
37017
- '\u1E81': 'w',
37018
- '\u1E83': 'w',
37019
- '\u0175': 'w',
37020
- '\u1E87': 'w',
37021
- '\u1E85': 'w',
37022
- '\u1E98': 'w',
37023
- '\u1E89': 'w',
37024
- '\u2C73': 'w',
37025
- '\u24E7': 'x',
37026
- '\uFF58': 'x',
37027
- '\u1E8B': 'x',
37028
- '\u1E8D': 'x',
37029
- '\u24E8': 'y',
37030
- '\uFF59': 'y',
37031
- '\u1EF3': 'y',
37032
- '\u00FD': 'y',
37033
- '\u0177': 'y',
37034
- '\u1EF9': 'y',
37035
- '\u0233': 'y',
37036
- '\u1E8F': 'y',
37037
- '\u00FF': 'y',
37038
- '\u1EF7': 'y',
37039
- '\u1E99': 'y',
37040
- '\u1EF5': 'y',
37041
- '\u01B4': 'y',
37042
- '\u024F': 'y',
37043
- '\u1EFF': 'y',
37044
- '\u24E9': 'z',
37045
- '\uFF5A': 'z',
37046
- '\u017A': 'z',
37047
- '\u1E91': 'z',
37048
- '\u017C': 'z',
37049
- '\u017E': 'z',
37050
- '\u1E93': 'z',
37051
- '\u1E95': 'z',
37052
- '\u01B6': 'z',
37053
- '\u0225': 'z',
37054
- '\u0240': 'z',
37055
- '\u2C6C': 'z',
37056
- '\uA763': 'z',
37057
- '\u0386': '\u0391',
37058
- '\u0388': '\u0395',
37059
- '\u0389': '\u0397',
37060
- '\u038A': '\u0399',
37061
- '\u03AA': '\u0399',
37062
- '\u038C': '\u039F',
37063
- '\u038E': '\u03A5',
37064
- '\u03AB': '\u03A5',
37065
- '\u038F': '\u03A9',
37066
- '\u03AC': '\u03B1',
37067
- '\u03AD': '\u03B5',
37068
- '\u03AE': '\u03B7',
37069
- '\u03AF': '\u03B9',
37070
- '\u03CA': '\u03B9',
37071
- '\u0390': '\u03B9',
37072
- '\u03CC': '\u03BF',
37073
- '\u03CD': '\u03C5',
37074
- '\u03CB': '\u03C5',
37075
- '\u03B0': '\u03C5',
37076
- '\u03C9': '\u03C9',
37077
- '\u03C2': '\u03C3'
37078
- };
37079
-
37080
- return diacritics;
37081
- });
37082
-
37083
- S2.define('select2/data/base',[
37084
- '../utils'
37085
- ], function (Utils) {
37086
- function BaseAdapter ($element, options) {
37087
- BaseAdapter.__super__.constructor.call(this);
37088
- }
37089
-
37090
- Utils.Extend(BaseAdapter, Utils.Observable);
37091
-
37092
- BaseAdapter.prototype.current = function (callback) {
37093
- throw new Error('The `current` method must be defined in child classes.');
37094
- };
37095
-
37096
- BaseAdapter.prototype.query = function (params, callback) {
37097
- throw new Error('The `query` method must be defined in child classes.');
37098
- };
37099
-
37100
- BaseAdapter.prototype.bind = function (container, $container) {
37101
- // Can be implemented in subclasses
37102
- };
37103
-
37104
- BaseAdapter.prototype.destroy = function () {
37105
- // Can be implemented in subclasses
37106
- };
37107
-
37108
- BaseAdapter.prototype.generateResultId = function (container, data) {
37109
- var id = container.id + '-result-';
37110
-
37111
- id += Utils.generateChars(4);
37112
-
37113
- if (data.id != null) {
37114
- id += '-' + data.id.toString();
37115
- } else {
37116
- id += '-' + Utils.generateChars(4);
37117
- }
37118
- return id;
37119
- };
37120
-
37121
- return BaseAdapter;
37122
- });
37123
-
37124
- S2.define('select2/data/select',[
37125
- './base',
37126
- '../utils',
37127
- 'jquery'
37128
- ], function (BaseAdapter, Utils, $) {
37129
- function SelectAdapter ($element, options) {
37130
- this.$element = $element;
37131
- this.options = options;
37132
-
37133
- SelectAdapter.__super__.constructor.call(this);
37134
- }
37135
-
37136
- Utils.Extend(SelectAdapter, BaseAdapter);
37137
-
37138
- SelectAdapter.prototype.current = function (callback) {
37139
- var data = [];
37140
- var self = this;
37141
-
37142
- this.$element.find(':selected').each(function () {
37143
- var $option = $(this);
37144
-
37145
- var option = self.item($option);
37146
-
37147
- data.push(option);
37148
- });
37149
-
37150
- callback(data);
37151
- };
37152
-
37153
- SelectAdapter.prototype.select = function (data) {
37154
- var self = this;
37155
-
37156
- data.selected = true;
37157
-
37158
- // If data.element is a DOM node, use it instead
37159
- if ($(data.element).is('option')) {
37160
- data.element.selected = true;
37161
-
37162
- this.$element.trigger('change');
37163
-
37164
- return;
37165
- }
37166
-
37167
- if (this.$element.prop('multiple')) {
37168
- this.current(function (currentData) {
37169
- var val = [];
37170
-
37171
- data = [data];
37172
- data.push.apply(data, currentData);
37173
-
37174
- for (var d = 0; d < data.length; d++) {
37175
- var id = data[d].id;
37176
-
37177
- if ($.inArray(id, val) === -1) {
37178
- val.push(id);
37179
- }
37180
- }
37181
-
37182
- self.$element.val(val);
37183
- self.$element.trigger('change');
37184
- });
37185
- } else {
37186
- var val = data.id;
37187
-
37188
- this.$element.val(val);
37189
- this.$element.trigger('change');
37190
- }
37191
- };
37192
-
37193
- SelectAdapter.prototype.unselect = function (data) {
37194
- var self = this;
37195
-
37196
- if (!this.$element.prop('multiple')) {
37197
- return;
37198
- }
37199
-
37200
- data.selected = false;
37201
-
37202
- if ($(data.element).is('option')) {
37203
- data.element.selected = false;
37204
-
37205
- this.$element.trigger('change');
37206
-
37207
- return;
37208
- }
37209
-
37210
- this.current(function (currentData) {
37211
- var val = [];
37212
-
37213
- for (var d = 0; d < currentData.length; d++) {
37214
- var id = currentData[d].id;
37215
-
37216
- if (id !== data.id && $.inArray(id, val) === -1) {
37217
- val.push(id);
37218
- }
37219
- }
37220
-
37221
- self.$element.val(val);
37222
-
37223
- self.$element.trigger('change');
37224
- });
37225
- };
37226
-
37227
- SelectAdapter.prototype.bind = function (container, $container) {
37228
- var self = this;
37229
-
37230
- this.container = container;
37231
-
37232
- container.on('select', function (params) {
37233
- self.select(params.data);
37234
- });
37235
-
37236
- container.on('unselect', function (params) {
37237
- self.unselect(params.data);
37238
- });
37239
- };
37240
-
37241
- SelectAdapter.prototype.destroy = function () {
37242
- // Remove anything added to child elements
37243
- this.$element.find('*').each(function () {
37244
- // Remove any custom data set by Select2
37245
- $.removeData(this, 'data');
37246
- });
37247
- };
37248
-
37249
- SelectAdapter.prototype.query = function (params, callback) {
37250
- var data = [];
37251
- var self = this;
37252
-
37253
- var $options = this.$element.children();
37254
-
37255
- $options.each(function () {
37256
- var $option = $(this);
37257
-
37258
- if (!$option.is('option') && !$option.is('optgroup')) {
37259
- return;
37260
- }
37261
-
37262
- var option = self.item($option);
37263
-
37264
- var matches = self.matches(params, option);
37265
-
37266
- if (matches !== null) {
37267
- data.push(matches);
37268
- }
37269
- });
37270
-
37271
- callback({
37272
- results: data
37273
- });
37274
- };
37275
-
37276
- SelectAdapter.prototype.addOptions = function ($options) {
37277
- Utils.appendMany(this.$element, $options);
37278
- };
37279
-
37280
- SelectAdapter.prototype.option = function (data) {
37281
- var option;
37282
-
37283
- if (data.children) {
37284
- option = document.createElement('optgroup');
37285
- option.label = data.text;
37286
- } else {
37287
- option = document.createElement('option');
37288
-
37289
- if (option.textContent !== undefined) {
37290
- option.textContent = data.text;
37291
- } else {
37292
- option.innerText = data.text;
37293
- }
37294
- }
37295
-
37296
- if (data.id !== undefined) {
37297
- option.value = data.id;
37298
- }
37299
-
37300
- if (data.disabled) {
37301
- option.disabled = true;
37302
- }
37303
-
37304
- if (data.selected) {
37305
- option.selected = true;
37306
- }
37307
-
37308
- if (data.title) {
37309
- option.title = data.title;
37310
- }
37311
-
37312
- var $option = $(option);
37313
-
37314
- var normalizedData = this._normalizeItem(data);
37315
- normalizedData.element = option;
37316
-
37317
- // Override the option's data with the combined data
37318
- $.data(option, 'data', normalizedData);
37319
-
37320
- return $option;
37321
- };
37322
-
37323
- SelectAdapter.prototype.item = function ($option) {
37324
- var data = {};
37325
-
37326
- data = $.data($option[0], 'data');
37327
-
37328
- if (data != null) {
37329
- return data;
37330
- }
37331
-
37332
- if ($option.is('option')) {
37333
- data = {
37334
- id: $option.val(),
37335
- text: $option.text(),
37336
- disabled: $option.prop('disabled'),
37337
- selected: $option.prop('selected'),
37338
- title: $option.prop('title')
37339
- };
37340
- } else if ($option.is('optgroup')) {
37341
- data = {
37342
- text: $option.prop('label'),
37343
- children: [],
37344
- title: $option.prop('title')
37345
- };
37346
-
37347
- var $children = $option.children('option');
37348
- var children = [];
37349
-
37350
- for (var c = 0; c < $children.length; c++) {
37351
- var $child = $($children[c]);
37352
-
37353
- var child = this.item($child);
37354
-
37355
- children.push(child);
37356
- }
37357
-
37358
- data.children = children;
37359
- }
37360
-
37361
- data = this._normalizeItem(data);
37362
- data.element = $option[0];
37363
-
37364
- $.data($option[0], 'data', data);
37365
-
37366
- return data;
37367
- };
37368
-
37369
- SelectAdapter.prototype._normalizeItem = function (item) {
37370
- if (!$.isPlainObject(item)) {
37371
- item = {
37372
- id: item,
37373
- text: item
37374
- };
37375
- }
37376
-
37377
- item = $.extend({}, {
37378
- text: ''
37379
- }, item);
37380
-
37381
- var defaults = {
37382
- selected: false,
37383
- disabled: false
37384
- };
37385
-
37386
- if (item.id != null) {
37387
- item.id = item.id.toString();
37388
- }
37389
-
37390
- if (item.text != null) {
37391
- item.text = item.text.toString();
37392
- }
37393
-
37394
- if (item._resultId == null && item.id && this.container != null) {
37395
- item._resultId = this.generateResultId(this.container, item);
37396
- }
37397
-
37398
- return $.extend({}, defaults, item);
37399
- };
37400
-
37401
- SelectAdapter.prototype.matches = function (params, data) {
37402
- var matcher = this.options.get('matcher');
37403
-
37404
- return matcher(params, data);
37405
- };
37406
-
37407
- return SelectAdapter;
37408
- });
37409
-
37410
- S2.define('select2/data/array',[
37411
- './select',
37412
- '../utils',
37413
- 'jquery'
37414
- ], function (SelectAdapter, Utils, $) {
37415
- function ArrayAdapter ($element, options) {
37416
- var data = options.get('data') || [];
37417
-
37418
- ArrayAdapter.__super__.constructor.call(this, $element, options);
37419
-
37420
- this.addOptions(this.convertToOptions(data));
37421
- }
37422
-
37423
- Utils.Extend(ArrayAdapter, SelectAdapter);
37424
-
37425
- ArrayAdapter.prototype.select = function (data) {
37426
- var $option = this.$element.find('option').filter(function (i, elm) {
37427
- return elm.value == data.id.toString();
37428
- });
37429
-
37430
- if ($option.length === 0) {
37431
- $option = this.option(data);
37432
-
37433
- this.addOptions($option);
37434
- }
37435
-
37436
- ArrayAdapter.__super__.select.call(this, data);
37437
- };
37438
-
37439
- ArrayAdapter.prototype.convertToOptions = function (data) {
37440
- var self = this;
37441
-
37442
- var $existing = this.$element.find('option');
37443
- var existingIds = $existing.map(function () {
37444
- return self.item($(this)).id;
37445
- }).get();
37446
-
37447
- var $options = [];
37448
-
37449
- // Filter out all items except for the one passed in the argument
37450
- function onlyItem (item) {
37451
- return function () {
37452
- return $(this).val() == item.id;
37453
- };
37454
- }
37455
-
37456
- for (var d = 0; d < data.length; d++) {
37457
- var item = this._normalizeItem(data[d]);
37458
-
37459
- // Skip items which were pre-loaded, only merge the data
37460
- if ($.inArray(item.id, existingIds) >= 0) {
37461
- var $existingOption = $existing.filter(onlyItem(item));
37462
-
37463
- var existingData = this.item($existingOption);
37464
- var newData = $.extend(true, {}, item, existingData);
37465
-
37466
- var $newOption = this.option(newData);
37467
-
37468
- $existingOption.replaceWith($newOption);
37469
-
37470
- continue;
37471
- }
37472
-
37473
- var $option = this.option(item);
37474
-
37475
- if (item.children) {
37476
- var $children = this.convertToOptions(item.children);
37477
-
37478
- Utils.appendMany($option, $children);
37479
- }
37480
-
37481
- $options.push($option);
37482
- }
37483
-
37484
- return $options;
37485
- };
37486
-
37487
- return ArrayAdapter;
37488
- });
37489
-
37490
- S2.define('select2/data/ajax',[
37491
- './array',
37492
- '../utils',
37493
- 'jquery'
37494
- ], function (ArrayAdapter, Utils, $) {
37495
- function AjaxAdapter ($element, options) {
37496
- this.ajaxOptions = this._applyDefaults(options.get('ajax'));
37497
-
37498
- if (this.ajaxOptions.processResults != null) {
37499
- this.processResults = this.ajaxOptions.processResults;
37500
- }
37501
-
37502
- AjaxAdapter.__super__.constructor.call(this, $element, options);
37503
- }
37504
-
37505
- Utils.Extend(AjaxAdapter, ArrayAdapter);
37506
-
37507
- AjaxAdapter.prototype._applyDefaults = function (options) {
37508
- var defaults = {
37509
- data: function (params) {
37510
- return $.extend({}, params, {
37511
- q: params.term
37512
- });
37513
- },
37514
- transport: function (params, success, failure) {
37515
- var $request = $.ajax(params);
37516
-
37517
- $request.then(success);
37518
- $request.fail(failure);
37519
-
37520
- return $request;
37521
- }
37522
- };
37523
-
37524
- return $.extend({}, defaults, options, true);
37525
- };
37526
-
37527
- AjaxAdapter.prototype.processResults = function (results) {
37528
- return results;
37529
- };
37530
-
37531
- AjaxAdapter.prototype.query = function (params, callback) {
37532
- var matches = [];
37533
- var self = this;
37534
-
37535
- if (this._request != null) {
37536
- // JSONP requests cannot always be aborted
37537
- if ($.isFunction(this._request.abort)) {
37538
- this._request.abort();
37539
- }
37540
-
37541
- this._request = null;
37542
- }
37543
-
37544
- var options = $.extend({
37545
- type: 'GET'
37546
- }, this.ajaxOptions);
37547
-
37548
- if (typeof options.url === 'function') {
37549
- options.url = options.url.call(this.$element, params);
37550
- }
37551
-
37552
- if (typeof options.data === 'function') {
37553
- options.data = options.data.call(this.$element, params);
37554
- }
37555
-
37556
- function request () {
37557
- var $request = options.transport(options, function (data) {
37558
- var results = self.processResults(data, params);
37559
-
37560
- if (self.options.get('debug') && window.console && console.error) {
37561
- // Check to make sure that the response included a `results` key.
37562
- if (!results || !results.results || !$.isArray(results.results)) {
37563
- console.error(
37564
- 'Select2: The AJAX results did not return an array in the ' +
37565
- '`results` key of the response.'
37566
- );
37567
- }
37568
- }
37569
-
37570
- callback(results);
37571
- }, function () {
37572
- // Attempt to detect if a request was aborted
37573
- // Only works if the transport exposes a status property
37574
- if ($request.status && $request.status === '0') {
37575
- return;
37576
- }
37577
-
37578
- self.trigger('results:message', {
37579
- message: 'errorLoading'
37580
- });
37581
- });
37582
-
37583
- self._request = $request;
37584
- }
37585
-
37586
- if (this.ajaxOptions.delay && params.term != null) {
37587
- if (this._queryTimeout) {
37588
- window.clearTimeout(this._queryTimeout);
37589
- }
37590
-
37591
- this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
37592
- } else {
37593
- request();
37594
- }
37595
- };
37596
-
37597
- return AjaxAdapter;
37598
- });
37599
-
37600
- S2.define('select2/data/tags',[
37601
- 'jquery'
37602
- ], function ($) {
37603
- function Tags (decorated, $element, options) {
37604
- var tags = options.get('tags');
37605
-
37606
- var createTag = options.get('createTag');
37607
-
37608
- if (createTag !== undefined) {
37609
- this.createTag = createTag;
37610
- }
37611
-
37612
- var insertTag = options.get('insertTag');
37613
-
37614
- if (insertTag !== undefined) {
37615
- this.insertTag = insertTag;
37616
- }
37617
-
37618
- decorated.call(this, $element, options);
37619
-
37620
- if ($.isArray(tags)) {
37621
- for (var t = 0; t < tags.length; t++) {
37622
- var tag = tags[t];
37623
- var item = this._normalizeItem(tag);
37624
-
37625
- var $option = this.option(item);
37626
-
37627
- this.$element.append($option);
37628
- }
37629
- }
37630
- }
37631
-
37632
- Tags.prototype.query = function (decorated, params, callback) {
37633
- var self = this;
37634
-
37635
- this._removeOldTags();
37636
-
37637
- if (params.term == null || params.page != null) {
37638
- decorated.call(this, params, callback);
37639
- return;
37640
- }
37641
-
37642
- function wrapper (obj, child) {
37643
- var data = obj.results;
37644
-
37645
- for (var i = 0; i < data.length; i++) {
37646
- var option = data[i];
37647
-
37648
- var checkChildren = (
37649
- option.children != null &&
37650
- !wrapper({
37651
- results: option.children
37652
- }, true)
37653
- );
37654
-
37655
- var optionText = (option.text || '').toUpperCase();
37656
- var paramsTerm = (params.term || '').toUpperCase();
37657
-
37658
- var checkText = optionText === paramsTerm;
37659
-
37660
- if (checkText || checkChildren) {
37661
- if (child) {
37662
- return false;
37663
- }
37664
-
37665
- obj.data = data;
37666
- callback(obj);
37667
-
37668
- return;
37669
- }
37670
- }
37671
-
37672
- if (child) {
37673
- return true;
37674
- }
37675
-
37676
- var tag = self.createTag(params);
37677
-
37678
- if (tag != null) {
37679
- var $option = self.option(tag);
37680
- $option.attr('data-select2-tag', true);
37681
-
37682
- self.addOptions([$option]);
37683
-
37684
- self.insertTag(data, tag);
37685
- }
37686
-
37687
- obj.results = data;
37688
-
37689
- callback(obj);
37690
- }
37691
-
37692
- decorated.call(this, params, wrapper);
37693
- };
37694
-
37695
- Tags.prototype.createTag = function (decorated, params) {
37696
- var term = $.trim(params.term);
37697
-
37698
- if (term === '') {
37699
- return null;
37700
- }
37701
-
37702
- return {
37703
- id: term,
37704
- text: term
37705
- };
37706
- };
37707
-
37708
- Tags.prototype.insertTag = function (_, data, tag) {
37709
- data.unshift(tag);
37710
- };
37711
-
37712
- Tags.prototype._removeOldTags = function (_) {
37713
- var tag = this._lastTag;
37714
-
37715
- var $options = this.$element.find('option[data-select2-tag]');
37716
-
37717
- $options.each(function () {
37718
- if (this.selected) {
37719
- return;
37720
- }
37721
-
37722
- $(this).remove();
37723
- });
37724
- };
37725
-
37726
- return Tags;
37727
- });
37728
-
37729
- S2.define('select2/data/tokenizer',[
37730
- 'jquery'
37731
- ], function ($) {
37732
- function Tokenizer (decorated, $element, options) {
37733
- var tokenizer = options.get('tokenizer');
37734
-
37735
- if (tokenizer !== undefined) {
37736
- this.tokenizer = tokenizer;
37737
- }
37738
-
37739
- decorated.call(this, $element, options);
37740
- }
37741
-
37742
- Tokenizer.prototype.bind = function (decorated, container, $container) {
37743
- decorated.call(this, container, $container);
37744
-
37745
- this.$search = container.dropdown.$search || container.selection.$search ||
37746
- $container.find('.select2-search__field');
37747
- };
37748
-
37749
- Tokenizer.prototype.query = function (decorated, params, callback) {
37750
- var self = this;
37751
-
37752
- function createAndSelect (data) {
37753
- // Normalize the data object so we can use it for checks
37754
- var item = self._normalizeItem(data);
37755
-
37756
- // Check if the data object already exists as a tag
37757
- // Select it if it doesn't
37758
- var $existingOptions = self.$element.find('option').filter(function () {
37759
- return $(this).val() === item.id;
37760
- });
37761
-
37762
- // If an existing option wasn't found for it, create the option
37763
- if (!$existingOptions.length) {
37764
- var $option = self.option(item);
37765
- $option.attr('data-select2-tag', true);
37766
-
37767
- self._removeOldTags();
37768
- self.addOptions([$option]);
37769
- }
37770
-
37771
- // Select the item, now that we know there is an option for it
37772
- select(item);
37773
- }
37774
-
37775
- function select (data) {
37776
- self.trigger('select', {
37777
- data: data
37778
- });
37779
- }
37780
-
37781
- params.term = params.term || '';
37782
-
37783
- var tokenData = this.tokenizer(params, this.options, createAndSelect);
37784
-
37785
- if (tokenData.term !== params.term) {
37786
- // Replace the search term if we have the search box
37787
- if (this.$search.length) {
37788
- this.$search.val(tokenData.term);
37789
- this.$search.focus();
37790
- }
37791
-
37792
- params.term = tokenData.term;
37793
- }
37794
-
37795
- decorated.call(this, params, callback);
37796
- };
37797
-
37798
- Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
37799
- var separators = options.get('tokenSeparators') || [];
37800
- var term = params.term;
37801
- var i = 0;
37802
-
37803
- var createTag = this.createTag || function (params) {
37804
- return {
37805
- id: params.term,
37806
- text: params.term
37807
- };
37808
- };
37809
-
37810
- while (i < term.length) {
37811
- var termChar = term[i];
37812
-
37813
- if ($.inArray(termChar, separators) === -1) {
37814
- i++;
37815
-
37816
- continue;
37817
- }
37818
-
37819
- var part = term.substr(0, i);
37820
- var partParams = $.extend({}, params, {
37821
- term: part
37822
- });
37823
-
37824
- var data = createTag(partParams);
37825
-
37826
- if (data == null) {
37827
- i++;
37828
- continue;
37829
- }
37830
-
37831
- callback(data);
37832
-
37833
- // Reset the term to not include the tokenized portion
37834
- term = term.substr(i + 1) || '';
37835
- i = 0;
37836
- }
37837
-
37838
- return {
37839
- term: term
37840
- };
37841
- };
37842
-
37843
- return Tokenizer;
37844
- });
37845
-
37846
- S2.define('select2/data/minimumInputLength',[
37847
-
37848
- ], function () {
37849
- function MinimumInputLength (decorated, $e, options) {
37850
- this.minimumInputLength = options.get('minimumInputLength');
37851
-
37852
- decorated.call(this, $e, options);
37853
- }
37854
-
37855
- MinimumInputLength.prototype.query = function (decorated, params, callback) {
37856
- params.term = params.term || '';
37857
-
37858
- if (params.term.length < this.minimumInputLength) {
37859
- this.trigger('results:message', {
37860
- message: 'inputTooShort',
37861
- args: {
37862
- minimum: this.minimumInputLength,
37863
- input: params.term,
37864
- params: params
37865
- }
37866
- });
37867
-
37868
- return;
37869
- }
37870
-
37871
- decorated.call(this, params, callback);
37872
- };
37873
-
37874
- return MinimumInputLength;
37875
- });
37876
-
37877
- S2.define('select2/data/maximumInputLength',[
37878
-
37879
- ], function () {
37880
- function MaximumInputLength (decorated, $e, options) {
37881
- this.maximumInputLength = options.get('maximumInputLength');
37882
-
37883
- decorated.call(this, $e, options);
37884
- }
37885
-
37886
- MaximumInputLength.prototype.query = function (decorated, params, callback) {
37887
- params.term = params.term || '';
37888
-
37889
- if (this.maximumInputLength > 0 &&
37890
- params.term.length > this.maximumInputLength) {
37891
- this.trigger('results:message', {
37892
- message: 'inputTooLong',
37893
- args: {
37894
- maximum: this.maximumInputLength,
37895
- input: params.term,
37896
- params: params
37897
- }
37898
- });
37899
-
37900
- return;
37901
- }
37902
-
37903
- decorated.call(this, params, callback);
37904
- };
37905
-
37906
- return MaximumInputLength;
37907
- });
37908
-
37909
- S2.define('select2/data/maximumSelectionLength',[
37910
-
37911
- ], function (){
37912
- function MaximumSelectionLength (decorated, $e, options) {
37913
- this.maximumSelectionLength = options.get('maximumSelectionLength');
37914
-
37915
- decorated.call(this, $e, options);
37916
- }
37917
-
37918
- MaximumSelectionLength.prototype.query =
37919
- function (decorated, params, callback) {
37920
- var self = this;
37921
-
37922
- this.current(function (currentData) {
37923
- var count = currentData != null ? currentData.length : 0;
37924
- if (self.maximumSelectionLength > 0 &&
37925
- count >= self.maximumSelectionLength) {
37926
- self.trigger('results:message', {
37927
- message: 'maximumSelected',
37928
- args: {
37929
- maximum: self.maximumSelectionLength
37930
- }
37931
- });
37932
- return;
37933
- }
37934
- decorated.call(self, params, callback);
37935
- });
37936
- };
37937
-
37938
- return MaximumSelectionLength;
37939
- });
37940
-
37941
- S2.define('select2/dropdown',[
37942
- 'jquery',
37943
- './utils'
37944
- ], function ($, Utils) {
37945
- function Dropdown ($element, options) {
37946
- this.$element = $element;
37947
- this.options = options;
37948
-
37949
- Dropdown.__super__.constructor.call(this);
37950
- }
37951
-
37952
- Utils.Extend(Dropdown, Utils.Observable);
37953
-
37954
- Dropdown.prototype.render = function () {
37955
- var $dropdown = $(
37956
- '<span class="select2-dropdown">' +
37957
- '<span class="select2-results"></span>' +
37958
- '</span>'
37959
- );
37960
-
37961
- $dropdown.attr('dir', this.options.get('dir'));
37962
-
37963
- this.$dropdown = $dropdown;
37964
-
37965
- return $dropdown;
37966
- };
37967
-
37968
- Dropdown.prototype.bind = function () {
37969
- // Should be implemented in subclasses
37970
- };
37971
-
37972
- Dropdown.prototype.position = function ($dropdown, $container) {
37973
- // Should be implmented in subclasses
37974
- };
37975
-
37976
- Dropdown.prototype.destroy = function () {
37977
- // Remove the dropdown from the DOM
37978
- this.$dropdown.remove();
37979
- };
37980
-
37981
- return Dropdown;
37982
- });
37983
-
37984
- S2.define('select2/dropdown/search',[
37985
- 'jquery',
37986
- '../utils'
37987
- ], function ($, Utils) {
37988
- function Search () { }
37989
-
37990
- Search.prototype.render = function (decorated) {
37991
- var $rendered = decorated.call(this);
37992
-
37993
- var $search = $(
37994
- '<span class="select2-search select2-search--dropdown">' +
37995
- '<input class="select2-search__field" type="search" tabindex="-1"' +
37996
- ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
37997
- ' spellcheck="false" role="textbox" />' +
37998
- '</span>'
37999
- );
38000
-
38001
- this.$searchContainer = $search;
38002
- this.$search = $search.find('input');
38003
-
38004
- $rendered.prepend($search);
38005
-
38006
- return $rendered;
38007
- };
38008
-
38009
- Search.prototype.bind = function (decorated, container, $container) {
38010
- var self = this;
38011
-
38012
- decorated.call(this, container, $container);
38013
-
38014
- this.$search.on('keydown', function (evt) {
38015
- self.trigger('keypress', evt);
38016
-
38017
- self._keyUpPrevented = evt.isDefaultPrevented();
38018
- });
38019
-
38020
- // Workaround for browsers which do not support the `input` event
38021
- // This will prevent double-triggering of events for browsers which support
38022
- // both the `keyup` and `input` events.
38023
- this.$search.on('input', function (evt) {
38024
- // Unbind the duplicated `keyup` event
38025
- $(this).off('keyup');
38026
- });
38027
-
38028
- this.$search.on('keyup input', function (evt) {
38029
- self.handleSearch(evt);
38030
- });
38031
-
38032
- container.on('open', function () {
38033
- self.$search.attr('tabindex', 0);
38034
-
38035
- self.$search.focus();
38036
-
38037
- window.setTimeout(function () {
38038
- self.$search.focus();
38039
- }, 0);
38040
- });
38041
-
38042
- container.on('close', function () {
38043
- self.$search.attr('tabindex', -1);
38044
-
38045
- self.$search.val('');
38046
- });
38047
-
38048
- container.on('focus', function () {
38049
- if (!container.isOpen()) {
38050
- self.$search.focus();
38051
- }
38052
- });
38053
-
38054
- container.on('results:all', function (params) {
38055
- if (params.query.term == null || params.query.term === '') {
38056
- var showSearch = self.showSearch(params);
38057
-
38058
- if (showSearch) {
38059
- self.$searchContainer.removeClass('select2-search--hide');
38060
- } else {
38061
- self.$searchContainer.addClass('select2-search--hide');
38062
- }
38063
- }
38064
- });
38065
- };
38066
-
38067
- Search.prototype.handleSearch = function (evt) {
38068
- if (!this._keyUpPrevented) {
38069
- var input = this.$search.val();
38070
-
38071
- this.trigger('query', {
38072
- term: input
38073
- });
38074
- }
38075
-
38076
- this._keyUpPrevented = false;
38077
- };
38078
-
38079
- Search.prototype.showSearch = function (_, params) {
38080
- return true;
38081
- };
38082
-
38083
- return Search;
38084
- });
38085
-
38086
- S2.define('select2/dropdown/hidePlaceholder',[
38087
-
38088
- ], function () {
38089
- function HidePlaceholder (decorated, $element, options, dataAdapter) {
38090
- this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
38091
-
38092
- decorated.call(this, $element, options, dataAdapter);
38093
- }
38094
-
38095
- HidePlaceholder.prototype.append = function (decorated, data) {
38096
- data.results = this.removePlaceholder(data.results);
38097
-
38098
- decorated.call(this, data);
38099
- };
38100
-
38101
- HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
38102
- if (typeof placeholder === 'string') {
38103
- placeholder = {
38104
- id: '',
38105
- text: placeholder
38106
- };
38107
- }
38108
-
38109
- return placeholder;
38110
- };
38111
-
38112
- HidePlaceholder.prototype.removePlaceholder = function (_, data) {
38113
- var modifiedData = data.slice(0);
38114
-
38115
- for (var d = data.length - 1; d >= 0; d--) {
38116
- var item = data[d];
38117
-
38118
- if (this.placeholder.id === item.id) {
38119
- modifiedData.splice(d, 1);
38120
- }
38121
- }
38122
-
38123
- return modifiedData;
38124
- };
38125
-
38126
- return HidePlaceholder;
38127
- });
38128
-
38129
- S2.define('select2/dropdown/infiniteScroll',[
38130
- 'jquery'
38131
- ], function ($) {
38132
- function InfiniteScroll (decorated, $element, options, dataAdapter) {
38133
- this.lastParams = {};
38134
-
38135
- decorated.call(this, $element, options, dataAdapter);
38136
-
38137
- this.$loadingMore = this.createLoadingMore();
38138
- this.loading = false;
38139
- }
38140
-
38141
- InfiniteScroll.prototype.append = function (decorated, data) {
38142
- this.$loadingMore.remove();
38143
- this.loading = false;
38144
-
38145
- decorated.call(this, data);
38146
-
38147
- if (this.showLoadingMore(data)) {
38148
- this.$results.append(this.$loadingMore);
38149
- }
38150
- };
38151
-
38152
- InfiniteScroll.prototype.bind = function (decorated, container, $container) {
38153
- var self = this;
38154
-
38155
- decorated.call(this, container, $container);
38156
-
38157
- container.on('query', function (params) {
38158
- self.lastParams = params;
38159
- self.loading = true;
38160
- });
38161
-
38162
- container.on('query:append', function (params) {
38163
- self.lastParams = params;
38164
- self.loading = true;
38165
- });
38166
-
38167
- this.$results.on('scroll', function () {
38168
- var isLoadMoreVisible = $.contains(
38169
- document.documentElement,
38170
- self.$loadingMore[0]
38171
- );
38172
-
38173
- if (self.loading || !isLoadMoreVisible) {
38174
- return;
38175
- }
38176
-
38177
- var currentOffset = self.$results.offset().top +
38178
- self.$results.outerHeight(false);
38179
- var loadingMoreOffset = self.$loadingMore.offset().top +
38180
- self.$loadingMore.outerHeight(false);
38181
-
38182
- if (currentOffset + 50 >= loadingMoreOffset) {
38183
- self.loadMore();
38184
- }
38185
- });
38186
- };
38187
-
38188
- InfiniteScroll.prototype.loadMore = function () {
38189
- this.loading = true;
38190
-
38191
- var params = $.extend({}, {page: 1}, this.lastParams);
38192
-
38193
- params.page++;
38194
-
38195
- this.trigger('query:append', params);
38196
- };
38197
-
38198
- InfiniteScroll.prototype.showLoadingMore = function (_, data) {
38199
- return data.pagination && data.pagination.more;
38200
- };
38201
-
38202
- InfiniteScroll.prototype.createLoadingMore = function () {
38203
- var $option = $(
38204
- '<li ' +
38205
- 'class="select2-results__option select2-results__option--load-more"' +
38206
- 'role="treeitem" aria-disabled="true"></li>'
38207
- );
38208
-
38209
- var message = this.options.get('translations').get('loadingMore');
38210
-
38211
- $option.html(message(this.lastParams));
38212
-
38213
- return $option;
38214
- };
38215
-
38216
- return InfiniteScroll;
38217
- });
38218
-
38219
- S2.define('select2/dropdown/attachBody',[
38220
- 'jquery',
38221
- '../utils'
38222
- ], function ($, Utils) {
38223
- function AttachBody (decorated, $element, options) {
38224
- this.$dropdownParent = options.get('dropdownParent') || $(document.body);
38225
-
38226
- decorated.call(this, $element, options);
38227
- }
38228
-
38229
- AttachBody.prototype.bind = function (decorated, container, $container) {
38230
- var self = this;
38231
-
38232
- var setupResultsEvents = false;
38233
-
38234
- decorated.call(this, container, $container);
38235
-
38236
- container.on('open', function () {
38237
- self._showDropdown();
38238
- self._attachPositioningHandler(container);
38239
-
38240
- if (!setupResultsEvents) {
38241
- setupResultsEvents = true;
38242
-
38243
- container.on('results:all', function () {
38244
- self._positionDropdown();
38245
- self._resizeDropdown();
38246
- });
38247
-
38248
- container.on('results:append', function () {
38249
- self._positionDropdown();
38250
- self._resizeDropdown();
38251
- });
38252
- }
38253
- });
38254
-
38255
- container.on('close', function () {
38256
- self._hideDropdown();
38257
- self._detachPositioningHandler(container);
38258
- });
38259
-
38260
- this.$dropdownContainer.on('mousedown', function (evt) {
38261
- evt.stopPropagation();
38262
- });
38263
- };
38264
-
38265
- AttachBody.prototype.destroy = function (decorated) {
38266
- decorated.call(this);
38267
-
38268
- this.$dropdownContainer.remove();
38269
- };
38270
-
38271
- AttachBody.prototype.position = function (decorated, $dropdown, $container) {
38272
- // Clone all of the container classes
38273
- $dropdown.attr('class', $container.attr('class'));
38274
-
38275
- $dropdown.removeClass('select2');
38276
- $dropdown.addClass('select2-container--open');
38277
-
38278
- $dropdown.css({
38279
- position: 'absolute',
38280
- top: -999999
38281
- });
38282
-
38283
- this.$container = $container;
38284
- };
38285
-
38286
- AttachBody.prototype.render = function (decorated) {
38287
- var $container = $('<span></span>');
38288
-
38289
- var $dropdown = decorated.call(this);
38290
- $container.append($dropdown);
38291
-
38292
- this.$dropdownContainer = $container;
38293
-
38294
- return $container;
38295
- };
38296
-
38297
- AttachBody.prototype._hideDropdown = function (decorated) {
38298
- this.$dropdownContainer.detach();
38299
- };
38300
-
38301
- AttachBody.prototype._attachPositioningHandler =
38302
- function (decorated, container) {
38303
- var self = this;
38304
-
38305
- var scrollEvent = 'scroll.select2.' + container.id;
38306
- var resizeEvent = 'resize.select2.' + container.id;
38307
- var orientationEvent = 'orientationchange.select2.' + container.id;
38308
-
38309
- var $watchers = this.$container.parents().filter(Utils.hasScroll);
38310
- $watchers.each(function () {
38311
- $(this).data('select2-scroll-position', {
38312
- x: $(this).scrollLeft(),
38313
- y: $(this).scrollTop()
38314
- });
38315
- });
38316
-
38317
- $watchers.on(scrollEvent, function (ev) {
38318
- var position = $(this).data('select2-scroll-position');
38319
- $(this).scrollTop(position.y);
38320
- });
38321
-
38322
- $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
38323
- function (e) {
38324
- self._positionDropdown();
38325
- self._resizeDropdown();
38326
- });
38327
- };
38328
-
38329
- AttachBody.prototype._detachPositioningHandler =
38330
- function (decorated, container) {
38331
- var scrollEvent = 'scroll.select2.' + container.id;
38332
- var resizeEvent = 'resize.select2.' + container.id;
38333
- var orientationEvent = 'orientationchange.select2.' + container.id;
38334
-
38335
- var $watchers = this.$container.parents().filter(Utils.hasScroll);
38336
- $watchers.off(scrollEvent);
38337
-
38338
- $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
38339
- };
38340
-
38341
- AttachBody.prototype._positionDropdown = function () {
38342
- var $window = $(window);
38343
-
38344
- var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
38345
- var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
38346
-
38347
- var newDirection = null;
38348
-
38349
- var offset = this.$container.offset();
38350
-
38351
- offset.bottom = offset.top + this.$container.outerHeight(false);
38352
-
38353
- var container = {
38354
- height: this.$container.outerHeight(false)
38355
- };
38356
-
38357
- container.top = offset.top;
38358
- container.bottom = offset.top + container.height;
38359
-
38360
- var dropdown = {
38361
- height: this.$dropdown.outerHeight(false)
38362
- };
38363
-
38364
- var viewport = {
38365
- top: $window.scrollTop(),
38366
- bottom: $window.scrollTop() + $window.height()
38367
- };
38368
-
38369
- var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
38370
- var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
38371
-
38372
- var css = {
38373
- left: offset.left,
38374
- top: container.bottom
38375
- };
38376
-
38377
- // Determine what the parent element is to use for calciulating the offset
38378
- var $offsetParent = this.$dropdownParent;
38379
-
38380
- // For statically positoned elements, we need to get the element
38381
- // that is determining the offset
38382
- if ($offsetParent.css('position') === 'static') {
38383
- $offsetParent = $offsetParent.offsetParent();
38384
- }
38385
-
38386
- var parentOffset = $offsetParent.offset();
38387
-
38388
- css.top -= parentOffset.top;
38389
- css.left -= parentOffset.left;
38390
-
38391
- if (!isCurrentlyAbove && !isCurrentlyBelow) {
38392
- newDirection = 'below';
38393
- }
38394
-
38395
- if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
38396
- newDirection = 'above';
38397
- } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
38398
- newDirection = 'below';
38399
- }
38400
-
38401
- if (newDirection == 'above' ||
38402
- (isCurrentlyAbove && newDirection !== 'below')) {
38403
- css.top = container.top - parentOffset.top - dropdown.height;
38404
- }
38405
-
38406
- if (newDirection != null) {
38407
- this.$dropdown
38408
- .removeClass('select2-dropdown--below select2-dropdown--above')
38409
- .addClass('select2-dropdown--' + newDirection);
38410
- this.$container
38411
- .removeClass('select2-container--below select2-container--above')
38412
- .addClass('select2-container--' + newDirection);
38413
- }
38414
-
38415
- this.$dropdownContainer.css(css);
38416
- };
38417
-
38418
- AttachBody.prototype._resizeDropdown = function () {
38419
- var css = {
38420
- width: this.$container.outerWidth(false) + 'px'
38421
- };
38422
-
38423
- if (this.options.get('dropdownAutoWidth')) {
38424
- css.minWidth = css.width;
38425
- css.position = 'relative';
38426
- css.width = 'auto';
38427
- }
38428
-
38429
- this.$dropdown.css(css);
38430
- };
38431
-
38432
- AttachBody.prototype._showDropdown = function (decorated) {
38433
- this.$dropdownContainer.appendTo(this.$dropdownParent);
38434
-
38435
- this._positionDropdown();
38436
- this._resizeDropdown();
38437
- };
38438
-
38439
- return AttachBody;
38440
- });
38441
-
38442
- S2.define('select2/dropdown/minimumResultsForSearch',[
38443
-
38444
- ], function () {
38445
- function countResults (data) {
38446
- var count = 0;
38447
-
38448
- for (var d = 0; d < data.length; d++) {
38449
- var item = data[d];
38450
-
38451
- if (item.children) {
38452
- count += countResults(item.children);
38453
- } else {
38454
- count++;
38455
- }
38456
- }
38457
-
38458
- return count;
38459
- }
38460
-
38461
- function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
38462
- this.minimumResultsForSearch = options.get('minimumResultsForSearch');
38463
-
38464
- if (this.minimumResultsForSearch < 0) {
38465
- this.minimumResultsForSearch = Infinity;
38466
- }
38467
-
38468
- decorated.call(this, $element, options, dataAdapter);
38469
- }
38470
-
38471
- MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
38472
- if (countResults(params.data.results) < this.minimumResultsForSearch) {
38473
- return false;
38474
- }
38475
-
38476
- return decorated.call(this, params);
38477
- };
38478
-
38479
- return MinimumResultsForSearch;
38480
- });
38481
-
38482
- S2.define('select2/dropdown/selectOnClose',[
38483
-
38484
- ], function () {
38485
- function SelectOnClose () { }
38486
-
38487
- SelectOnClose.prototype.bind = function (decorated, container, $container) {
38488
- var self = this;
38489
-
38490
- decorated.call(this, container, $container);
38491
-
38492
- container.on('close', function (params) {
38493
- self._handleSelectOnClose(params);
38494
- });
38495
- };
38496
-
38497
- SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
38498
- if (params && params.originalSelect2Event != null) {
38499
- var event = params.originalSelect2Event;
38500
-
38501
- // Don't select an item if the close event was triggered from a select or
38502
- // unselect event
38503
- if (event._type === 'select' || event._type === 'unselect') {
38504
- return;
38505
- }
38506
- }
38507
-
38508
- var $highlightedResults = this.getHighlightedResults();
38509
-
38510
- // Only select highlighted results
38511
- if ($highlightedResults.length < 1) {
38512
- return;
38513
- }
38514
-
38515
- var data = $highlightedResults.data('data');
38516
-
38517
- // Don't re-select already selected resulte
38518
- if (
38519
- (data.element != null && data.element.selected) ||
38520
- (data.element == null && data.selected)
38521
- ) {
38522
- return;
38523
- }
38524
-
38525
- this.trigger('select', {
38526
- data: data
38527
- });
38528
- };
38529
-
38530
- return SelectOnClose;
38531
- });
38532
-
38533
- S2.define('select2/dropdown/closeOnSelect',[
38534
-
38535
- ], function () {
38536
- function CloseOnSelect () { }
38537
-
38538
- CloseOnSelect.prototype.bind = function (decorated, container, $container) {
38539
- var self = this;
38540
-
38541
- decorated.call(this, container, $container);
38542
-
38543
- container.on('select', function (evt) {
38544
- self._selectTriggered(evt);
38545
- });
38546
-
38547
- container.on('unselect', function (evt) {
38548
- self._selectTriggered(evt);
38549
- });
38550
- };
38551
-
38552
- CloseOnSelect.prototype._selectTriggered = function (_, evt) {
38553
- var originalEvent = evt.originalEvent;
38554
-
38555
- // Don't close if the control key is being held
38556
- if (originalEvent && originalEvent.ctrlKey) {
38557
- return;
38558
- }
38559
-
38560
- this.trigger('close', {
38561
- originalEvent: originalEvent,
38562
- originalSelect2Event: evt
38563
- });
38564
- };
38565
-
38566
- return CloseOnSelect;
38567
- });
38568
-
38569
- S2.define('select2/i18n/en',[],function () {
38570
- // English
38571
- return {
38572
- errorLoading: function () {
38573
- return 'The results could not be loaded.';
38574
- },
38575
- inputTooLong: function (args) {
38576
- var overChars = args.input.length - args.maximum;
38577
-
38578
- var message = 'Please delete ' + overChars + ' character';
38579
-
38580
- if (overChars != 1) {
38581
- message += 's';
38582
- }
38583
-
38584
- return message;
38585
- },
38586
- inputTooShort: function (args) {
38587
- var remainingChars = args.minimum - args.input.length;
38588
-
38589
- var message = 'Please enter ' + remainingChars + ' or more characters';
38590
-
38591
- return message;
38592
- },
38593
- loadingMore: function () {
38594
- return 'Loading more results…';
38595
- },
38596
- maximumSelected: function (args) {
38597
- var message = 'You can only select ' + args.maximum + ' item';
38598
-
38599
- if (args.maximum != 1) {
38600
- message += 's';
38601
- }
38602
-
38603
- return message;
38604
- },
38605
- noResults: function () {
38606
- return 'No results found';
38607
- },
38608
- searching: function () {
38609
- return 'Searching…';
38610
- }
38611
- };
38612
- });
38613
-
38614
- S2.define('select2/defaults',[
38615
- 'jquery',
38616
- 'require',
38617
-
38618
- './results',
38619
-
38620
- './selection/single',
38621
- './selection/multiple',
38622
- './selection/placeholder',
38623
- './selection/allowClear',
38624
- './selection/search',
38625
- './selection/eventRelay',
38626
-
38627
- './utils',
38628
- './translation',
38629
- './diacritics',
38630
-
38631
- './data/select',
38632
- './data/array',
38633
- './data/ajax',
38634
- './data/tags',
38635
- './data/tokenizer',
38636
- './data/minimumInputLength',
38637
- './data/maximumInputLength',
38638
- './data/maximumSelectionLength',
38639
-
38640
- './dropdown',
38641
- './dropdown/search',
38642
- './dropdown/hidePlaceholder',
38643
- './dropdown/infiniteScroll',
38644
- './dropdown/attachBody',
38645
- './dropdown/minimumResultsForSearch',
38646
- './dropdown/selectOnClose',
38647
- './dropdown/closeOnSelect',
38648
-
38649
- './i18n/en'
38650
- ], function ($, require,
38651
-
38652
- ResultsList,
38653
-
38654
- SingleSelection, MultipleSelection, Placeholder, AllowClear,
38655
- SelectionSearch, EventRelay,
38656
-
38657
- Utils, Translation, DIACRITICS,
38658
-
38659
- SelectData, ArrayData, AjaxData, Tags, Tokenizer,
38660
- MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
38661
-
38662
- Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
38663
- AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
38664
-
38665
- EnglishTranslation) {
38666
- function Defaults () {
38667
- this.reset();
38668
- }
38669
-
38670
- Defaults.prototype.apply = function (options) {
38671
- options = $.extend(true, {}, this.defaults, options);
38672
-
38673
- if (options.dataAdapter == null) {
38674
- if (options.ajax != null) {
38675
- options.dataAdapter = AjaxData;
38676
- } else if (options.data != null) {
38677
- options.dataAdapter = ArrayData;
38678
- } else {
38679
- options.dataAdapter = SelectData;
38680
- }
38681
-
38682
- if (options.minimumInputLength > 0) {
38683
- options.dataAdapter = Utils.Decorate(
38684
- options.dataAdapter,
38685
- MinimumInputLength
38686
- );
38687
- }
38688
-
38689
- if (options.maximumInputLength > 0) {
38690
- options.dataAdapter = Utils.Decorate(
38691
- options.dataAdapter,
38692
- MaximumInputLength
38693
- );
38694
- }
38695
-
38696
- if (options.maximumSelectionLength > 0) {
38697
- options.dataAdapter = Utils.Decorate(
38698
- options.dataAdapter,
38699
- MaximumSelectionLength
38700
- );
38701
- }
38702
-
38703
- if (options.tags) {
38704
- options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
38705
- }
38706
-
38707
- if (options.tokenSeparators != null || options.tokenizer != null) {
38708
- options.dataAdapter = Utils.Decorate(
38709
- options.dataAdapter,
38710
- Tokenizer
38711
- );
38712
- }
38713
-
38714
- if (options.query != null) {
38715
- var Query = require(options.amdBase + 'compat/query');
38716
-
38717
- options.dataAdapter = Utils.Decorate(
38718
- options.dataAdapter,
38719
- Query
38720
- );
38721
- }
38722
-
38723
- if (options.initSelection != null) {
38724
- var InitSelection = require(options.amdBase + 'compat/initSelection');
38725
-
38726
- options.dataAdapter = Utils.Decorate(
38727
- options.dataAdapter,
38728
- InitSelection
38729
- );
38730
- }
38731
- }
38732
-
38733
- if (options.resultsAdapter == null) {
38734
- options.resultsAdapter = ResultsList;
38735
-
38736
- if (options.ajax != null) {
38737
- options.resultsAdapter = Utils.Decorate(
38738
- options.resultsAdapter,
38739
- InfiniteScroll
38740
- );
38741
- }
38742
-
38743
- if (options.placeholder != null) {
38744
- options.resultsAdapter = Utils.Decorate(
38745
- options.resultsAdapter,
38746
- HidePlaceholder
38747
- );
38748
- }
38749
-
38750
- if (options.selectOnClose) {
38751
- options.resultsAdapter = Utils.Decorate(
38752
- options.resultsAdapter,
38753
- SelectOnClose
38754
- );
38755
- }
38756
- }
38757
-
38758
- if (options.dropdownAdapter == null) {
38759
- if (options.multiple) {
38760
- options.dropdownAdapter = Dropdown;
38761
- } else {
38762
- var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
38763
-
38764
- options.dropdownAdapter = SearchableDropdown;
38765
- }
38766
-
38767
- if (options.minimumResultsForSearch !== 0) {
38768
- options.dropdownAdapter = Utils.Decorate(
38769
- options.dropdownAdapter,
38770
- MinimumResultsForSearch
38771
- );
38772
- }
38773
-
38774
- if (options.closeOnSelect) {
38775
- options.dropdownAdapter = Utils.Decorate(
38776
- options.dropdownAdapter,
38777
- CloseOnSelect
38778
- );
38779
- }
38780
-
38781
- if (
38782
- options.dropdownCssClass != null ||
38783
- options.dropdownCss != null ||
38784
- options.adaptDropdownCssClass != null
38785
- ) {
38786
- var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
38787
-
38788
- options.dropdownAdapter = Utils.Decorate(
38789
- options.dropdownAdapter,
38790
- DropdownCSS
38791
- );
38792
- }
38793
-
38794
- options.dropdownAdapter = Utils.Decorate(
38795
- options.dropdownAdapter,
38796
- AttachBody
38797
- );
38798
- }
38799
-
38800
- if (options.selectionAdapter == null) {
38801
- if (options.multiple) {
38802
- options.selectionAdapter = MultipleSelection;
38803
- } else {
38804
- options.selectionAdapter = SingleSelection;
38805
- }
38806
-
38807
- // Add the placeholder mixin if a placeholder was specified
38808
- if (options.placeholder != null) {
38809
- options.selectionAdapter = Utils.Decorate(
38810
- options.selectionAdapter,
38811
- Placeholder
38812
- );
38813
- }
38814
-
38815
- if (options.allowClear) {
38816
- options.selectionAdapter = Utils.Decorate(
38817
- options.selectionAdapter,
38818
- AllowClear
38819
- );
38820
- }
38821
-
38822
- if (options.multiple) {
38823
- options.selectionAdapter = Utils.Decorate(
38824
- options.selectionAdapter,
38825
- SelectionSearch
38826
- );
38827
- }
38828
-
38829
- if (
38830
- options.containerCssClass != null ||
38831
- options.containerCss != null ||
38832
- options.adaptContainerCssClass != null
38833
- ) {
38834
- var ContainerCSS = require(options.amdBase + 'compat/containerCss');
38835
-
38836
- options.selectionAdapter = Utils.Decorate(
38837
- options.selectionAdapter,
38838
- ContainerCSS
38839
- );
38840
- }
38841
-
38842
- options.selectionAdapter = Utils.Decorate(
38843
- options.selectionAdapter,
38844
- EventRelay
38845
- );
38846
- }
38847
-
38848
- if (typeof options.language === 'string') {
38849
- // Check if the language is specified with a region
38850
- if (options.language.indexOf('-') > 0) {
38851
- // Extract the region information if it is included
38852
- var languageParts = options.language.split('-');
38853
- var baseLanguage = languageParts[0];
38854
-
38855
- options.language = [options.language, baseLanguage];
38856
- } else {
38857
- options.language = [options.language];
38858
- }
38859
- }
38860
-
38861
- if ($.isArray(options.language)) {
38862
- var languages = new Translation();
38863
- options.language.push('en');
38864
-
38865
- var languageNames = options.language;
38866
-
38867
- for (var l = 0; l < languageNames.length; l++) {
38868
- var name = languageNames[l];
38869
- var language = {};
38870
-
38871
- try {
38872
- // Try to load it with the original name
38873
- language = Translation.loadPath(name);
38874
- } catch (e) {
38875
- try {
38876
- // If we couldn't load it, check if it wasn't the full path
38877
- name = this.defaults.amdLanguageBase + name;
38878
- language = Translation.loadPath(name);
38879
- } catch (ex) {
38880
- // The translation could not be loaded at all. Sometimes this is
38881
- // because of a configuration problem, other times this can be
38882
- // because of how Select2 helps load all possible translation files.
38883
- if (options.debug && window.console && console.warn) {
38884
- console.warn(
38885
- 'Select2: The language file for "' + name + '" could not be ' +
38886
- 'automatically loaded. A fallback will be used instead.'
38887
- );
38888
- }
38889
-
38890
- continue;
38891
- }
38892
- }
38893
-
38894
- languages.extend(language);
38895
- }
38896
-
38897
- options.translations = languages;
38898
- } else {
38899
- var baseTranslation = Translation.loadPath(
38900
- this.defaults.amdLanguageBase + 'en'
38901
- );
38902
- var customTranslation = new Translation(options.language);
38903
-
38904
- customTranslation.extend(baseTranslation);
38905
-
38906
- options.translations = customTranslation;
38907
- }
38908
-
38909
- return options;
38910
- };
38911
-
38912
- Defaults.prototype.reset = function () {
38913
- function stripDiacritics (text) {
38914
- // Used 'uni range + named function' from http://jsperf.com/diacritics/18
38915
- function match(a) {
38916
- return DIACRITICS[a] || a;
38917
- }
38918
-
38919
- return text.replace(/[^\u0000-\u007E]/g, match);
38920
- }
38921
-
38922
- function matcher (params, data) {
38923
- // Always return the object if there is nothing to compare
38924
- if ($.trim(params.term) === '') {
38925
- return data;
38926
- }
38927
-
38928
- // Do a recursive check for options with children
38929
- if (data.children && data.children.length > 0) {
38930
- // Clone the data object if there are children
38931
- // This is required as we modify the object to remove any non-matches
38932
- var match = $.extend(true, {}, data);
38933
-
38934
- // Check each child of the option
38935
- for (var c = data.children.length - 1; c >= 0; c--) {
38936
- var child = data.children[c];
38937
-
38938
- var matches = matcher(params, child);
38939
-
38940
- // If there wasn't a match, remove the object in the array
38941
- if (matches == null) {
38942
- match.children.splice(c, 1);
38943
- }
38944
- }
38945
-
38946
- // If any children matched, return the new object
38947
- if (match.children.length > 0) {
38948
- return match;
38949
- }
38950
-
38951
- // If there were no matching children, check just the plain object
38952
- return matcher(params, match);
38953
- }
38954
-
38955
- var original = stripDiacritics(data.text).toUpperCase();
38956
- var term = stripDiacritics(params.term).toUpperCase();
38957
-
38958
- // Check if the text contains the term
38959
- if (original.indexOf(term) > -1) {
38960
- return data;
38961
- }
38962
-
38963
- // If it doesn't contain the term, don't return anything
38964
- return null;
38965
- }
38966
-
38967
- this.defaults = {
38968
- amdBase: './',
38969
- amdLanguageBase: './i18n/',
38970
- closeOnSelect: true,
38971
- debug: false,
38972
- dropdownAutoWidth: false,
38973
- escapeMarkup: Utils.escapeMarkup,
38974
- language: EnglishTranslation,
38975
- matcher: matcher,
38976
- minimumInputLength: 0,
38977
- maximumInputLength: 0,
38978
- maximumSelectionLength: 0,
38979
- minimumResultsForSearch: 0,
38980
- selectOnClose: false,
38981
- sorter: function (data) {
38982
- return data;
38983
- },
38984
- templateResult: function (result) {
38985
- return result.text;
38986
- },
38987
- templateSelection: function (selection) {
38988
- return selection.text;
38989
- },
38990
- theme: 'default',
38991
- width: 'resolve'
38992
- };
38993
- };
38994
-
38995
- Defaults.prototype.set = function (key, value) {
38996
- var camelKey = $.camelCase(key);
38997
-
38998
- var data = {};
38999
- data[camelKey] = value;
39000
-
39001
- var convertedData = Utils._convertData(data);
39002
-
39003
- $.extend(this.defaults, convertedData);
39004
- };
39005
-
39006
- var defaults = new Defaults();
39007
-
39008
- return defaults;
39009
- });
39010
-
39011
- S2.define('select2/options',[
39012
- 'require',
39013
- 'jquery',
39014
- './defaults',
39015
- './utils'
39016
- ], function (require, $, Defaults, Utils) {
39017
- function Options (options, $element) {
39018
- this.options = options;
39019
-
39020
- if ($element != null) {
39021
- this.fromElement($element);
39022
- }
39023
-
39024
- this.options = Defaults.apply(this.options);
39025
-
39026
- if ($element && $element.is('input')) {
39027
- var InputCompat = require(this.get('amdBase') + 'compat/inputData');
39028
-
39029
- this.options.dataAdapter = Utils.Decorate(
39030
- this.options.dataAdapter,
39031
- InputCompat
39032
- );
39033
- }
39034
- }
39035
-
39036
- Options.prototype.fromElement = function ($e) {
39037
- var excludedData = ['select2'];
39038
-
39039
- if (this.options.multiple == null) {
39040
- this.options.multiple = $e.prop('multiple');
39041
- }
39042
-
39043
- if (this.options.disabled == null) {
39044
- this.options.disabled = $e.prop('disabled');
39045
- }
39046
-
39047
- if (this.options.language == null) {
39048
- if ($e.prop('lang')) {
39049
- this.options.language = $e.prop('lang').toLowerCase();
39050
- } else if ($e.closest('[lang]').prop('lang')) {
39051
- this.options.language = $e.closest('[lang]').prop('lang');
39052
- }
39053
- }
39054
-
39055
- if (this.options.dir == null) {
39056
- if ($e.prop('dir')) {
39057
- this.options.dir = $e.prop('dir');
39058
- } else if ($e.closest('[dir]').prop('dir')) {
39059
- this.options.dir = $e.closest('[dir]').prop('dir');
39060
- } else {
39061
- this.options.dir = 'ltr';
39062
- }
39063
- }
39064
-
39065
- $e.prop('disabled', this.options.disabled);
39066
- $e.prop('multiple', this.options.multiple);
39067
-
39068
- if ($e.data('select2Tags')) {
39069
- if (this.options.debug && window.console && console.warn) {
39070
- console.warn(
39071
- 'Select2: The `data-select2-tags` attribute has been changed to ' +
39072
- 'use the `data-data` and `data-tags="true"` attributes and will be ' +
39073
- 'removed in future versions of Select2.'
39074
- );
39075
- }
39076
-
39077
- $e.data('data', $e.data('select2Tags'));
39078
- $e.data('tags', true);
39079
- }
39080
-
39081
- if ($e.data('ajaxUrl')) {
39082
- if (this.options.debug && window.console && console.warn) {
39083
- console.warn(
39084
- 'Select2: The `data-ajax-url` attribute has been changed to ' +
39085
- '`data-ajax--url` and support for the old attribute will be removed' +
39086
- ' in future versions of Select2.'
39087
- );
39088
- }
39089
-
39090
- $e.attr('ajax--url', $e.data('ajaxUrl'));
39091
- $e.data('ajax--url', $e.data('ajaxUrl'));
39092
- }
39093
-
39094
- var dataset = {};
39095
-
39096
- // Prefer the element's `dataset` attribute if it exists
39097
- // jQuery 1.x does not correctly handle data attributes with multiple dashes
39098
- if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
39099
- dataset = $.extend(true, {}, $e[0].dataset, $e.data());
39100
- } else {
39101
- dataset = $e.data();
39102
- }
39103
-
39104
- var data = $.extend(true, {}, dataset);
39105
-
39106
- data = Utils._convertData(data);
39107
-
39108
- for (var key in data) {
39109
- if ($.inArray(key, excludedData) > -1) {
39110
- continue;
39111
- }
39112
-
39113
- if ($.isPlainObject(this.options[key])) {
39114
- $.extend(this.options[key], data[key]);
39115
- } else {
39116
- this.options[key] = data[key];
39117
- }
39118
- }
39119
-
39120
- return this;
39121
- };
39122
-
39123
- Options.prototype.get = function (key) {
39124
- return this.options[key];
39125
- };
39126
-
39127
- Options.prototype.set = function (key, val) {
39128
- this.options[key] = val;
39129
- };
39130
-
39131
- return Options;
39132
- });
39133
-
39134
- S2.define('select2/core',[
39135
- 'jquery',
39136
- './options',
39137
- './utils',
39138
- './keys'
39139
- ], function ($, Options, Utils, KEYS) {
39140
- var Select2 = function ($element, options) {
39141
- if ($element.data('select2') != null) {
39142
- $element.data('select2').destroy();
39143
- }
39144
-
39145
- this.$element = $element;
39146
-
39147
- this.id = this._generateId($element);
39148
-
39149
- options = options || {};
39150
-
39151
- this.options = new Options(options, $element);
39152
-
39153
- Select2.__super__.constructor.call(this);
39154
-
39155
- // Set up the tabindex
39156
-
39157
- var tabindex = $element.attr('tabindex') || 0;
39158
- $element.data('old-tabindex', tabindex);
39159
- $element.attr('tabindex', '-1');
39160
-
39161
- // Set up containers and adapters
39162
-
39163
- var DataAdapter = this.options.get('dataAdapter');
39164
- this.dataAdapter = new DataAdapter($element, this.options);
39165
-
39166
- var $container = this.render();
39167
-
39168
- this._placeContainer($container);
39169
-
39170
- var SelectionAdapter = this.options.get('selectionAdapter');
39171
- this.selection = new SelectionAdapter($element, this.options);
39172
- this.$selection = this.selection.render();
39173
-
39174
- this.selection.position(this.$selection, $container);
39175
-
39176
- var DropdownAdapter = this.options.get('dropdownAdapter');
39177
- this.dropdown = new DropdownAdapter($element, this.options);
39178
- this.$dropdown = this.dropdown.render();
39179
-
39180
- this.dropdown.position(this.$dropdown, $container);
39181
-
39182
- var ResultsAdapter = this.options.get('resultsAdapter');
39183
- this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
39184
- this.$results = this.results.render();
39185
-
39186
- this.results.position(this.$results, this.$dropdown);
39187
-
39188
- // Bind events
39189
-
39190
- var self = this;
39191
-
39192
- // Bind the container to all of the adapters
39193
- this._bindAdapters();
39194
-
39195
- // Register any DOM event handlers
39196
- this._registerDomEvents();
39197
-
39198
- // Register any internal event handlers
39199
- this._registerDataEvents();
39200
- this._registerSelectionEvents();
39201
- this._registerDropdownEvents();
39202
- this._registerResultsEvents();
39203
- this._registerEvents();
39204
-
39205
- // Set the initial state
39206
- this.dataAdapter.current(function (initialData) {
39207
- self.trigger('selection:update', {
39208
- data: initialData
39209
- });
39210
- });
39211
-
39212
- // Hide the original select
39213
- $element.addClass('select2-hidden-accessible');
39214
- $element.attr('aria-hidden', 'true');
39215
-
39216
- // Synchronize any monitored attributes
39217
- this._syncAttributes();
39218
-
39219
- $element.data('select2', this);
39220
- };
39221
-
39222
- Utils.Extend(Select2, Utils.Observable);
39223
-
39224
- Select2.prototype._generateId = function ($element) {
39225
- var id = '';
39226
-
39227
- if ($element.attr('id') != null) {
39228
- id = $element.attr('id');
39229
- } else if ($element.attr('name') != null) {
39230
- id = $element.attr('name') + '-' + Utils.generateChars(2);
39231
- } else {
39232
- id = Utils.generateChars(4);
39233
- }
39234
-
39235
- id = id.replace(/(:|\.|\[|\]|,)/g, '');
39236
- id = 'select2-' + id;
39237
-
39238
- return id;
39239
- };
39240
-
39241
- Select2.prototype._placeContainer = function ($container) {
39242
- $container.insertAfter(this.$element);
39243
-
39244
- var width = this._resolveWidth(this.$element, this.options.get('width'));
39245
-
39246
- if (width != null) {
39247
- $container.css('width', width);
39248
- }
39249
- };
39250
-
39251
- Select2.prototype._resolveWidth = function ($element, method) {
39252
- var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
39253
-
39254
- if (method == 'resolve') {
39255
- var styleWidth = this._resolveWidth($element, 'style');
39256
-
39257
- if (styleWidth != null) {
39258
- return styleWidth;
39259
- }
39260
-
39261
- return this._resolveWidth($element, 'element');
39262
- }
39263
-
39264
- if (method == 'element') {
39265
- var elementWidth = $element.outerWidth(false);
39266
-
39267
- if (elementWidth <= 0) {
39268
- return 'auto';
39269
- }
39270
-
39271
- return elementWidth + 'px';
39272
- }
39273
-
39274
- if (method == 'style') {
39275
- var style = $element.attr('style');
39276
-
39277
- if (typeof(style) !== 'string') {
39278
- return null;
39279
- }
39280
-
39281
- var attrs = style.split(';');
39282
-
39283
- for (var i = 0, l = attrs.length; i < l; i = i + 1) {
39284
- var attr = attrs[i].replace(/\s/g, '');
39285
- var matches = attr.match(WIDTH);
39286
-
39287
- if (matches !== null && matches.length >= 1) {
39288
- return matches[1];
39289
- }
39290
- }
39291
-
39292
- return null;
39293
- }
39294
-
39295
- return method;
39296
- };
39297
-
39298
- Select2.prototype._bindAdapters = function () {
39299
- this.dataAdapter.bind(this, this.$container);
39300
- this.selection.bind(this, this.$container);
39301
-
39302
- this.dropdown.bind(this, this.$container);
39303
- this.results.bind(this, this.$container);
39304
- };
39305
-
39306
- Select2.prototype._registerDomEvents = function () {
39307
- var self = this;
39308
-
39309
- this.$element.on('change.select2', function () {
39310
- self.dataAdapter.current(function (data) {
39311
- self.trigger('selection:update', {
39312
- data: data
39313
- });
39314
- });
39315
- });
39316
-
39317
- this.$element.on('focus.select2', function (evt) {
39318
- self.trigger('focus', evt);
39319
- });
39320
-
39321
- this._syncA = Utils.bind(this._syncAttributes, this);
39322
- this._syncS = Utils.bind(this._syncSubtree, this);
39323
-
39324
- if (this.$element[0].attachEvent) {
39325
- this.$element[0].attachEvent('onpropertychange', this._syncA);
39326
- }
39327
-
39328
- var observer = window.MutationObserver ||
39329
- window.WebKitMutationObserver ||
39330
- window.MozMutationObserver
39331
- ;
39332
-
39333
- if (observer != null) {
39334
- this._observer = new observer(function (mutations) {
39335
- $.each(mutations, self._syncA);
39336
- $.each(mutations, self._syncS);
39337
- });
39338
- this._observer.observe(this.$element[0], {
39339
- attributes: true,
39340
- childList: true,
39341
- subtree: false
39342
- });
39343
- } else if (this.$element[0].addEventListener) {
39344
- this.$element[0].addEventListener(
39345
- 'DOMAttrModified',
39346
- self._syncA,
39347
- false
39348
- );
39349
- this.$element[0].addEventListener(
39350
- 'DOMNodeInserted',
39351
- self._syncS,
39352
- false
39353
- );
39354
- this.$element[0].addEventListener(
39355
- 'DOMNodeRemoved',
39356
- self._syncS,
39357
- false
39358
- );
39359
- }
39360
- };
39361
-
39362
- Select2.prototype._registerDataEvents = function () {
39363
- var self = this;
39364
-
39365
- this.dataAdapter.on('*', function (name, params) {
39366
- self.trigger(name, params);
39367
- });
39368
- };
39369
-
39370
- Select2.prototype._registerSelectionEvents = function () {
39371
- var self = this;
39372
- var nonRelayEvents = ['toggle', 'focus'];
39373
-
39374
- this.selection.on('toggle', function () {
39375
- self.toggleDropdown();
39376
- });
39377
-
39378
- this.selection.on('focus', function (params) {
39379
- self.focus(params);
39380
- });
39381
-
39382
- this.selection.on('*', function (name, params) {
39383
- if ($.inArray(name, nonRelayEvents) !== -1) {
39384
- return;
39385
- }
39386
-
39387
- self.trigger(name, params);
39388
- });
39389
- };
39390
-
39391
- Select2.prototype._registerDropdownEvents = function () {
39392
- var self = this;
39393
-
39394
- this.dropdown.on('*', function (name, params) {
39395
- self.trigger(name, params);
39396
- });
39397
- };
39398
-
39399
- Select2.prototype._registerResultsEvents = function () {
39400
- var self = this;
39401
-
39402
- this.results.on('*', function (name, params) {
39403
- self.trigger(name, params);
39404
- });
39405
- };
39406
-
39407
- Select2.prototype._registerEvents = function () {
39408
- var self = this;
39409
-
39410
- this.on('open', function () {
39411
- self.$container.addClass('select2-container--open');
39412
- });
39413
-
39414
- this.on('close', function () {
39415
- self.$container.removeClass('select2-container--open');
39416
- });
39417
-
39418
- this.on('enable', function () {
39419
- self.$container.removeClass('select2-container--disabled');
39420
- });
39421
-
39422
- this.on('disable', function () {
39423
- self.$container.addClass('select2-container--disabled');
39424
- });
39425
-
39426
- this.on('blur', function () {
39427
- self.$container.removeClass('select2-container--focus');
39428
- });
39429
-
39430
- this.on('query', function (params) {
39431
- if (!self.isOpen()) {
39432
- self.trigger('open', {});
39433
- }
39434
-
39435
- this.dataAdapter.query(params, function (data) {
39436
- self.trigger('results:all', {
39437
- data: data,
39438
- query: params
39439
- });
39440
- });
39441
- });
39442
-
39443
- this.on('query:append', function (params) {
39444
- this.dataAdapter.query(params, function (data) {
39445
- self.trigger('results:append', {
39446
- data: data,
39447
- query: params
39448
- });
39449
- });
39450
- });
39451
-
39452
- this.on('keypress', function (evt) {
39453
- var key = evt.which;
39454
-
39455
- if (self.isOpen()) {
39456
- if (key === KEYS.ESC || key === KEYS.TAB ||
39457
- (key === KEYS.UP && evt.altKey)) {
39458
- self.close();
39459
-
39460
- evt.preventDefault();
39461
- } else if (key === KEYS.ENTER) {
39462
- self.trigger('results:select', {});
39463
-
39464
- evt.preventDefault();
39465
- } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
39466
- self.trigger('results:toggle', {});
39467
-
39468
- evt.preventDefault();
39469
- } else if (key === KEYS.UP) {
39470
- self.trigger('results:previous', {});
39471
-
39472
- evt.preventDefault();
39473
- } else if (key === KEYS.DOWN) {
39474
- self.trigger('results:next', {});
39475
-
39476
- evt.preventDefault();
39477
- }
39478
- } else {
39479
- if (key === KEYS.ENTER || key === KEYS.SPACE ||
39480
- (key === KEYS.DOWN && evt.altKey)) {
39481
- self.open();
39482
-
39483
- evt.preventDefault();
39484
- }
39485
- }
39486
- });
39487
- };
39488
-
39489
- Select2.prototype._syncAttributes = function () {
39490
- this.options.set('disabled', this.$element.prop('disabled'));
39491
-
39492
- if (this.options.get('disabled')) {
39493
- if (this.isOpen()) {
39494
- this.close();
39495
- }
39496
-
39497
- this.trigger('disable', {});
39498
- } else {
39499
- this.trigger('enable', {});
39500
- }
39501
- };
39502
-
39503
- Select2.prototype._syncSubtree = function (evt, mutations) {
39504
- var changed = false;
39505
- var self = this;
39506
-
39507
- // Ignore any mutation events raised for elements that aren't options or
39508
- // optgroups. This handles the case when the select element is destroyed
39509
- if (
39510
- evt && evt.target && (
39511
- evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
39512
- )
39513
- ) {
39514
- return;
39515
- }
39516
-
39517
- if (!mutations) {
39518
- // If mutation events aren't supported, then we can only assume that the
39519
- // change affected the selections
39520
- changed = true;
39521
- } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
39522
- for (var n = 0; n < mutations.addedNodes.length; n++) {
39523
- var node = mutations.addedNodes[n];
39524
-
39525
- if (node.selected) {
39526
- changed = true;
39527
- }
39528
- }
39529
- } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
39530
- changed = true;
39531
- }
39532
-
39533
- // Only re-pull the data if we think there is a change
39534
- if (changed) {
39535
- this.dataAdapter.current(function (currentData) {
39536
- self.trigger('selection:update', {
39537
- data: currentData
39538
- });
39539
- });
39540
- }
39541
- };
39542
-
39543
- /**
39544
- * Override the trigger method to automatically trigger pre-events when
39545
- * there are events that can be prevented.
39546
- */
39547
- Select2.prototype.trigger = function (name, args) {
39548
- var actualTrigger = Select2.__super__.trigger;
39549
- var preTriggerMap = {
39550
- 'open': 'opening',
39551
- 'close': 'closing',
39552
- 'select': 'selecting',
39553
- 'unselect': 'unselecting'
39554
- };
39555
-
39556
- if (args === undefined) {
39557
- args = {};
39558
- }
39559
-
39560
- if (name in preTriggerMap) {
39561
- var preTriggerName = preTriggerMap[name];
39562
- var preTriggerArgs = {
39563
- prevented: false,
39564
- name: name,
39565
- args: args
39566
- };
39567
-
39568
- actualTrigger.call(this, preTriggerName, preTriggerArgs);
39569
-
39570
- if (preTriggerArgs.prevented) {
39571
- args.prevented = true;
39572
-
39573
- return;
39574
- }
39575
- }
39576
-
39577
- actualTrigger.call(this, name, args);
39578
- };
39579
-
39580
- Select2.prototype.toggleDropdown = function () {
39581
- if (this.options.get('disabled')) {
39582
- return;
39583
- }
39584
-
39585
- if (this.isOpen()) {
39586
- this.close();
39587
- } else {
39588
- this.open();
39589
- }
39590
- };
39591
-
39592
- Select2.prototype.open = function () {
39593
- if (this.isOpen()) {
39594
- return;
39595
- }
39596
-
39597
- this.trigger('query', {});
39598
- };
39599
-
39600
- Select2.prototype.close = function () {
39601
- if (!this.isOpen()) {
39602
- return;
39603
- }
39604
-
39605
- this.trigger('close', {});
39606
- };
39607
-
39608
- Select2.prototype.isOpen = function () {
39609
- return this.$container.hasClass('select2-container--open');
39610
- };
39611
-
39612
- Select2.prototype.hasFocus = function () {
39613
- return this.$container.hasClass('select2-container--focus');
39614
- };
39615
-
39616
- Select2.prototype.focus = function (data) {
39617
- // No need to re-trigger focus events if we are already focused
39618
- if (this.hasFocus()) {
39619
- return;
39620
- }
39621
-
39622
- this.$container.addClass('select2-container--focus');
39623
- this.trigger('focus', {});
39624
- };
39625
-
39626
- Select2.prototype.enable = function (args) {
39627
- if (this.options.get('debug') && window.console && console.warn) {
39628
- console.warn(
39629
- 'Select2: The `select2("enable")` method has been deprecated and will' +
39630
- ' be removed in later Select2 versions. Use $element.prop("disabled")' +
39631
- ' instead.'
39632
- );
39633
- }
39634
-
39635
- if (args == null || args.length === 0) {
39636
- args = [true];
39637
- }
39638
-
39639
- var disabled = !args[0];
39640
-
39641
- this.$element.prop('disabled', disabled);
39642
- };
39643
-
39644
- Select2.prototype.data = function () {
39645
- if (this.options.get('debug') &&
39646
- arguments.length > 0 && window.console && console.warn) {
39647
- console.warn(
39648
- 'Select2: Data can no longer be set using `select2("data")`. You ' +
39649
- 'should consider setting the value instead using `$element.val()`.'
39650
- );
39651
- }
39652
-
39653
- var data = [];
39654
-
39655
- this.dataAdapter.current(function (currentData) {
39656
- data = currentData;
39657
- });
39658
-
39659
- return data;
39660
- };
39661
-
39662
- Select2.prototype.val = function (args) {
39663
- if (this.options.get('debug') && window.console && console.warn) {
39664
- console.warn(
39665
- 'Select2: The `select2("val")` method has been deprecated and will be' +
39666
- ' removed in later Select2 versions. Use $element.val() instead.'
39667
- );
39668
- }
39669
-
39670
- if (args == null || args.length === 0) {
39671
- return this.$element.val();
39672
- }
39673
-
39674
- var newVal = args[0];
39675
-
39676
- if ($.isArray(newVal)) {
39677
- newVal = $.map(newVal, function (obj) {
39678
- return obj.toString();
39679
- });
39680
- }
39681
-
39682
- this.$element.val(newVal).trigger('change');
39683
- };
39684
-
39685
- Select2.prototype.destroy = function () {
39686
- this.$container.remove();
39687
-
39688
- if (this.$element[0].detachEvent) {
39689
- this.$element[0].detachEvent('onpropertychange', this._syncA);
39690
- }
39691
-
39692
- if (this._observer != null) {
39693
- this._observer.disconnect();
39694
- this._observer = null;
39695
- } else if (this.$element[0].removeEventListener) {
39696
- this.$element[0]
39697
- .removeEventListener('DOMAttrModified', this._syncA, false);
39698
- this.$element[0]
39699
- .removeEventListener('DOMNodeInserted', this._syncS, false);
39700
- this.$element[0]
39701
- .removeEventListener('DOMNodeRemoved', this._syncS, false);
39702
- }
39703
-
39704
- this._syncA = null;
39705
- this._syncS = null;
39706
-
39707
- this.$element.off('.select2');
39708
- this.$element.attr('tabindex', this.$element.data('old-tabindex'));
39709
-
39710
- this.$element.removeClass('select2-hidden-accessible');
39711
- this.$element.attr('aria-hidden', 'false');
39712
- this.$element.removeData('select2');
39713
-
39714
- this.dataAdapter.destroy();
39715
- this.selection.destroy();
39716
- this.dropdown.destroy();
39717
- this.results.destroy();
39718
-
39719
- this.dataAdapter = null;
39720
- this.selection = null;
39721
- this.dropdown = null;
39722
- this.results = null;
39723
- };
39724
-
39725
- Select2.prototype.render = function () {
39726
- var $container = $(
39727
- '<span class="select2 select2-container">' +
39728
- '<span class="selection"></span>' +
39729
- '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
39730
- '</span>'
39731
- );
39732
-
39733
- $container.attr('dir', this.options.get('dir'));
39734
-
39735
- this.$container = $container;
39736
-
39737
- this.$container.addClass('select2-container--' + this.options.get('theme'));
39738
-
39739
- $container.data('element', this.$element);
39740
-
39741
- return $container;
39742
- };
39743
-
39744
- return Select2;
39745
- });
39746
-
39747
- S2.define('jquery-mousewheel',[
39748
- 'jquery'
39749
- ], function ($) {
39750
- // Used to shim jQuery.mousewheel for non-full builds.
39751
- return $;
39752
- });
39753
-
39754
- S2.define('jquery.select2',[
39755
- 'jquery',
39756
- 'jquery-mousewheel',
39757
-
39758
- './select2/core',
39759
- './select2/defaults'
39760
- ], function ($, _, Select2, Defaults) {
39761
- if ($.fn.select2 == null) {
39762
- // All methods that should return the element
39763
- var thisMethods = ['open', 'close', 'destroy'];
39764
-
39765
- $.fn.select2 = function (options) {
39766
- options = options || {};
39767
-
39768
- if (typeof options === 'object') {
39769
- this.each(function () {
39770
- var instanceOptions = $.extend(true, {}, options);
39771
-
39772
- var instance = new Select2($(this), instanceOptions);
39773
- });
39774
-
39775
- return this;
39776
- } else if (typeof options === 'string') {
39777
- var ret;
39778
- var args = Array.prototype.slice.call(arguments, 1);
39779
-
39780
- this.each(function () {
39781
- var instance = $(this).data('select2');
39782
-
39783
- if (instance == null && window.console && console.error) {
39784
- console.error(
39785
- 'The select2(\'' + options + '\') method was called on an ' +
39786
- 'element that is not using Select2.'
39787
- );
39788
- }
39789
-
39790
- ret = instance[options].apply(instance, args);
39791
- });
39792
-
39793
- // Check if we should be returning `this`
39794
- if ($.inArray(options, thisMethods) > -1) {
39795
- return this;
39796
- }
39797
-
39798
- return ret;
39799
- } else {
39800
- throw new Error('Invalid arguments for Select2: ' + options);
39801
- }
39802
- };
39803
- }
39804
-
39805
- if ($.fn.select2.defaults == null) {
39806
- $.fn.select2.defaults = Defaults;
39807
- }
39808
-
39809
- return Select2;
39810
- });
39811
-
39812
- // Return the AMD loader configuration so it can be used outside of this file
39813
- return {
39814
- define: S2.define,
39815
- require: S2.require
39816
- };
39817
- }());
39818
-
39819
- // Autoload the jQuery bindings
39820
- // We know that all of the modules exist above this, so we're safe
39821
- var select2 = S2.require('jquery.select2');
39822
-
39823
- // Hold the AMD module references on the jQuery function that was just loaded
39824
- // This allows Select2 to use the internal loader outside of this file, such
39825
- // as in the language files.
39826
- jQuery.fn.select2.amd = S2;
39827
-
39828
- // Return the Select2 instance for anyone who is importing it.
39829
- return select2;
39830
- }));
39831
 
39832
 
39833
  /***/ },
@@ -40804,7 +40804,7 @@ webpackJsonp([1],[
40804
  /***/ function(module, exports, __webpack_require__) {
40805
 
40806
  var require;/* WEBPACK VAR INJECTION */(function(module) {//! moment.js
40807
- //! version : 2.19.2
40808
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
40809
  //! license : MIT
40810
  //! momentjs.com
@@ -41619,7 +41619,7 @@ webpackJsonp([1],[
41619
 
41620
  function set$1 (mom, unit, value) {
41621
  if (mom.isValid() && !isNaN(value)) {
41622
- if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
41623
  mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
41624
  }
41625
  else {
@@ -42725,11 +42725,10 @@ webpackJsonp([1],[
42725
 
42726
  function updateLocale(name, config) {
42727
  if (config != null) {
42728
- var locale, tmpLocale, parentConfig = baseConfig;
42729
  // MERGE
42730
- tmpLocale = loadLocale(name);
42731
- if (tmpLocale != null) {
42732
- parentConfig = tmpLocale._config;
42733
  }
42734
  config = mergeConfigs(parentConfig, config);
42735
  locale = new Locale(config);
@@ -45283,7 +45282,7 @@ webpackJsonp([1],[
45283
  // Side effect imports
45284
 
45285
 
45286
- hooks.version = '2.19.2';
45287
 
45288
  setHookCallback(createLocal);
45289
 
30947
 
30948
  return _react2['default'].createElement(
30949
  'tr',
30950
+ { className: row_classes, 'data-automation-id': 'listing_item_' + this.props.item.id },
30951
  checkbox,
30952
  this.props.onRenderItem(this.props.item, actions)
30953
  );
34082
  /* 289 */
34083
  /***/ function(module, exports, __webpack_require__) {
34084
 
34085
+ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;var require;/*!
34086
+ * Select2 4.0.4
34087
+ * https://select2.github.io
34088
+ *
34089
+ * Released under the MIT license
34090
+ * https://github.com/select2/select2/blob/master/LICENSE.md
34091
+ */
34092
+ (function (factory) {
34093
+ if (true) {
34094
+ // AMD. Register as an anonymous module.
34095
+ !(__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__));
34096
+ } else if (typeof module === 'object' && module.exports) {
34097
+ // Node/CommonJS
34098
+ module.exports = function (root, jQuery) {
34099
+ if (jQuery === undefined) {
34100
+ // require('jQuery') returns a factory that requires window to
34101
+ // build a jQuery instance, we normalize how we use modules
34102
+ // that require this pattern but the window provided is a noop
34103
+ // if it's defined (how jquery works)
34104
+ if (typeof window !== 'undefined') {
34105
+ jQuery = require('jquery');
34106
+ }
34107
+ else {
34108
+ jQuery = require('jquery')(root);
34109
+ }
34110
+ }
34111
+ factory(jQuery);
34112
+ return jQuery;
34113
+ };
34114
+ } else {
34115
+ // Browser globals
34116
+ factory(jQuery);
34117
+ }
34118
+ } (function (jQuery) {
34119
+ // This is needed so we can catch the AMD loader configuration and use it
34120
+ // The inner file should be wrapped (by `banner.start.js`) in a function that
34121
+ // returns the AMD loader references.
34122
+ var S2 =(function () {
34123
+ // Restore the Select2 AMD loader so it can be used
34124
+ // Needed mostly in the language files, where the loader is not inserted
34125
+ if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
34126
+ var S2 = jQuery.fn.select2.amd;
34127
+ }
34128
+ var S2;(function () { if (!S2 || !S2.requirejs) {
34129
+ if (!S2) { S2 = {}; } else { require = S2; }
34130
+ /**
34131
+ * @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
34132
+ * Released under MIT license, http://github.com/requirejs/almond/LICENSE
34133
+ */
34134
+ //Going sloppy to avoid 'use strict' string cost, but strict practices should
34135
+ //be followed.
34136
+ /*global setTimeout: false */
34137
+
34138
+ var requirejs, require, define;
34139
+ (function (undef) {
34140
+ var main, req, makeMap, handlers,
34141
+ defined = {},
34142
+ waiting = {},
34143
+ config = {},
34144
+ defining = {},
34145
+ hasOwn = Object.prototype.hasOwnProperty,
34146
+ aps = [].slice,
34147
+ jsSuffixRegExp = /\.js$/;
34148
+
34149
+ function hasProp(obj, prop) {
34150
+ return hasOwn.call(obj, prop);
34151
+ }
34152
+
34153
+ /**
34154
+ * Given a relative module name, like ./something, normalize it to
34155
+ * a real name that can be mapped to a path.
34156
+ * @param {String} name the relative name
34157
+ * @param {String} baseName a real name that the name arg is relative
34158
+ * to.
34159
+ * @returns {String} normalized name
34160
+ */
34161
+ function normalize(name, baseName) {
34162
+ var nameParts, nameSegment, mapValue, foundMap, lastIndex,
34163
+ foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
34164
+ baseParts = baseName && baseName.split("/"),
34165
+ map = config.map,
34166
+ starMap = (map && map['*']) || {};
34167
+
34168
+ //Adjust any relative paths.
34169
+ if (name) {
34170
+ name = name.split('/');
34171
+ lastIndex = name.length - 1;
34172
+
34173
+ // If wanting node ID compatibility, strip .js from end
34174
+ // of IDs. Have to do this here, and not in nameToUrl
34175
+ // because node allows either .js or non .js to map
34176
+ // to same file.
34177
+ if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
34178
+ name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
34179
+ }
34180
+
34181
+ // Starts with a '.' so need the baseName
34182
+ if (name[0].charAt(0) === '.' && baseParts) {
34183
+ //Convert baseName to array, and lop off the last part,
34184
+ //so that . matches that 'directory' and not name of the baseName's
34185
+ //module. For instance, baseName of 'one/two/three', maps to
34186
+ //'one/two/three.js', but we want the directory, 'one/two' for
34187
+ //this normalization.
34188
+ normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
34189
+ name = normalizedBaseParts.concat(name);
34190
+ }
34191
+
34192
+ //start trimDots
34193
+ for (i = 0; i < name.length; i++) {
34194
+ part = name[i];
34195
+ if (part === '.') {
34196
+ name.splice(i, 1);
34197
+ i -= 1;
34198
+ } else if (part === '..') {
34199
+ // If at the start, or previous value is still ..,
34200
+ // keep them so that when converted to a path it may
34201
+ // still work when converted to a path, even though
34202
+ // as an ID it is less than ideal. In larger point
34203
+ // releases, may be better to just kick out an error.
34204
+ if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
34205
+ continue;
34206
+ } else if (i > 0) {
34207
+ name.splice(i - 1, 2);
34208
+ i -= 2;
34209
+ }
34210
+ }
34211
+ }
34212
+ //end trimDots
34213
+
34214
+ name = name.join('/');
34215
+ }
34216
+
34217
+ //Apply map config if available.
34218
+ if ((baseParts || starMap) && map) {
34219
+ nameParts = name.split('/');
34220
+
34221
+ for (i = nameParts.length; i > 0; i -= 1) {
34222
+ nameSegment = nameParts.slice(0, i).join("/");
34223
+
34224
+ if (baseParts) {
34225
+ //Find the longest baseName segment match in the config.
34226
+ //So, do joins on the biggest to smallest lengths of baseParts.
34227
+ for (j = baseParts.length; j > 0; j -= 1) {
34228
+ mapValue = map[baseParts.slice(0, j).join('/')];
34229
+
34230
+ //baseName segment has config, find if it has one for
34231
+ //this name.
34232
+ if (mapValue) {
34233
+ mapValue = mapValue[nameSegment];
34234
+ if (mapValue) {
34235
+ //Match, update name to the new value.
34236
+ foundMap = mapValue;
34237
+ foundI = i;
34238
+ break;
34239
+ }
34240
+ }
34241
+ }
34242
+ }
34243
+
34244
+ if (foundMap) {
34245
+ break;
34246
+ }
34247
+
34248
+ //Check for a star map match, but just hold on to it,
34249
+ //if there is a shorter segment match later in a matching
34250
+ //config, then favor over this star map.
34251
+ if (!foundStarMap && starMap && starMap[nameSegment]) {
34252
+ foundStarMap = starMap[nameSegment];
34253
+ starI = i;
34254
+ }
34255
+ }
34256
+
34257
+ if (!foundMap && foundStarMap) {
34258
+ foundMap = foundStarMap;
34259
+ foundI = starI;
34260
+ }
34261
+
34262
+ if (foundMap) {
34263
+ nameParts.splice(0, foundI, foundMap);
34264
+ name = nameParts.join('/');
34265
+ }
34266
+ }
34267
+
34268
+ return name;
34269
+ }
34270
+
34271
+ function makeRequire(relName, forceSync) {
34272
+ return function () {
34273
+ //A version of a require function that passes a moduleName
34274
+ //value for items that may need to
34275
+ //look up paths relative to the moduleName
34276
+ var args = aps.call(arguments, 0);
34277
+
34278
+ //If first arg is not require('string'), and there is only
34279
+ //one arg, it is the array form without a callback. Insert
34280
+ //a null so that the following concat is correct.
34281
+ if (typeof args[0] !== 'string' && args.length === 1) {
34282
+ args.push(null);
34283
+ }
34284
+ return req.apply(undef, args.concat([relName, forceSync]));
34285
+ };
34286
+ }
34287
+
34288
+ function makeNormalize(relName) {
34289
+ return function (name) {
34290
+ return normalize(name, relName);
34291
+ };
34292
+ }
34293
+
34294
+ function makeLoad(depName) {
34295
+ return function (value) {
34296
+ defined[depName] = value;
34297
+ };
34298
+ }
34299
+
34300
+ function callDep(name) {
34301
+ if (hasProp(waiting, name)) {
34302
+ var args = waiting[name];
34303
+ delete waiting[name];
34304
+ defining[name] = true;
34305
+ main.apply(undef, args);
34306
+ }
34307
+
34308
+ if (!hasProp(defined, name) && !hasProp(defining, name)) {
34309
+ throw new Error('No ' + name);
34310
+ }
34311
+ return defined[name];
34312
+ }
34313
+
34314
+ //Turns a plugin!resource to [plugin, resource]
34315
+ //with the plugin being undefined if the name
34316
+ //did not have a plugin prefix.
34317
+ function splitPrefix(name) {
34318
+ var prefix,
34319
+ index = name ? name.indexOf('!') : -1;
34320
+ if (index > -1) {
34321
+ prefix = name.substring(0, index);
34322
+ name = name.substring(index + 1, name.length);
34323
+ }
34324
+ return [prefix, name];
34325
+ }
34326
+
34327
+ //Creates a parts array for a relName where first part is plugin ID,
34328
+ //second part is resource ID. Assumes relName has already been normalized.
34329
+ function makeRelParts(relName) {
34330
+ return relName ? splitPrefix(relName) : [];
34331
+ }
34332
+
34333
+ /**
34334
+ * Makes a name map, normalizing the name, and using a plugin
34335
+ * for normalization if necessary. Grabs a ref to plugin
34336
+ * too, as an optimization.
34337
+ */
34338
+ makeMap = function (name, relParts) {
34339
+ var plugin,
34340
+ parts = splitPrefix(name),
34341
+ prefix = parts[0],
34342
+ relResourceName = relParts[1];
34343
+
34344
+ name = parts[1];
34345
+
34346
+ if (prefix) {
34347
+ prefix = normalize(prefix, relResourceName);
34348
+ plugin = callDep(prefix);
34349
+ }
34350
+
34351
+ //Normalize according
34352
+ if (prefix) {
34353
+ if (plugin && plugin.normalize) {
34354
+ name = plugin.normalize(name, makeNormalize(relResourceName));
34355
+ } else {
34356
+ name = normalize(name, relResourceName);
34357
+ }
34358
+ } else {
34359
+ name = normalize(name, relResourceName);
34360
+ parts = splitPrefix(name);
34361
+ prefix = parts[0];
34362
+ name = parts[1];
34363
+ if (prefix) {
34364
+ plugin = callDep(prefix);
34365
+ }
34366
+ }
34367
+
34368
+ //Using ridiculous property names for space reasons
34369
+ return {
34370
+ f: prefix ? prefix + '!' + name : name, //fullName
34371
+ n: name,
34372
+ pr: prefix,
34373
+ p: plugin
34374
+ };
34375
+ };
34376
+
34377
+ function makeConfig(name) {
34378
+ return function () {
34379
+ return (config && config.config && config.config[name]) || {};
34380
+ };
34381
+ }
34382
+
34383
+ handlers = {
34384
+ require: function (name) {
34385
+ return makeRequire(name);
34386
+ },
34387
+ exports: function (name) {
34388
+ var e = defined[name];
34389
+ if (typeof e !== 'undefined') {
34390
+ return e;
34391
+ } else {
34392
+ return (defined[name] = {});
34393
+ }
34394
+ },
34395
+ module: function (name) {
34396
+ return {
34397
+ id: name,
34398
+ uri: '',
34399
+ exports: defined[name],
34400
+ config: makeConfig(name)
34401
+ };
34402
+ }
34403
+ };
34404
+
34405
+ main = function (name, deps, callback, relName) {
34406
+ var cjsModule, depName, ret, map, i, relParts,
34407
+ args = [],
34408
+ callbackType = typeof callback,
34409
+ usingExports;
34410
+
34411
+ //Use name if no relName
34412
+ relName = relName || name;
34413
+ relParts = makeRelParts(relName);
34414
+
34415
+ //Call the callback to define the module, if necessary.
34416
+ if (callbackType === 'undefined' || callbackType === 'function') {
34417
+ //Pull out the defined dependencies and pass the ordered
34418
+ //values to the callback.
34419
+ //Default to [require, exports, module] if no deps
34420
+ deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
34421
+ for (i = 0; i < deps.length; i += 1) {
34422
+ map = makeMap(deps[i], relParts);
34423
+ depName = map.f;
34424
+
34425
+ //Fast path CommonJS standard dependencies.
34426
+ if (depName === "require") {
34427
+ args[i] = handlers.require(name);
34428
+ } else if (depName === "exports") {
34429
+ //CommonJS module spec 1.1
34430
+ args[i] = handlers.exports(name);
34431
+ usingExports = true;
34432
+ } else if (depName === "module") {
34433
+ //CommonJS module spec 1.1
34434
+ cjsModule = args[i] = handlers.module(name);
34435
+ } else if (hasProp(defined, depName) ||
34436
+ hasProp(waiting, depName) ||
34437
+ hasProp(defining, depName)) {
34438
+ args[i] = callDep(depName);
34439
+ } else if (map.p) {
34440
+ map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
34441
+ args[i] = defined[depName];
34442
+ } else {
34443
+ throw new Error(name + ' missing ' + depName);
34444
+ }
34445
+ }
34446
+
34447
+ ret = callback ? callback.apply(defined[name], args) : undefined;
34448
+
34449
+ if (name) {
34450
+ //If setting exports via "module" is in play,
34451
+ //favor that over return value and exports. After that,
34452
+ //favor a non-undefined return value over exports use.
34453
+ if (cjsModule && cjsModule.exports !== undef &&
34454
+ cjsModule.exports !== defined[name]) {
34455
+ defined[name] = cjsModule.exports;
34456
+ } else if (ret !== undef || !usingExports) {
34457
+ //Use the return value from the function.
34458
+ defined[name] = ret;
34459
+ }
34460
+ }
34461
+ } else if (name) {
34462
+ //May just be an object definition for the module. Only
34463
+ //worry about defining if have a module name.
34464
+ defined[name] = callback;
34465
+ }
34466
+ };
34467
+
34468
+ requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
34469
+ if (typeof deps === "string") {
34470
+ if (handlers[deps]) {
34471
+ //callback in this case is really relName
34472
+ return handlers[deps](callback);
34473
+ }
34474
+ //Just return the module wanted. In this scenario, the
34475
+ //deps arg is the module name, and second arg (if passed)
34476
+ //is just the relName.
34477
+ //Normalize module name, if it contains . or ..
34478
+ return callDep(makeMap(deps, makeRelParts(callback)).f);
34479
+ } else if (!deps.splice) {
34480
+ //deps is a config object, not an array.
34481
+ config = deps;
34482
+ if (config.deps) {
34483
+ req(config.deps, config.callback);
34484
+ }
34485
+ if (!callback) {
34486
+ return;
34487
+ }
34488
+
34489
+ if (callback.splice) {
34490
+ //callback is an array, which means it is a dependency list.
34491
+ //Adjust args if there are dependencies
34492
+ deps = callback;
34493
+ callback = relName;
34494
+ relName = null;
34495
+ } else {
34496
+ deps = undef;
34497
+ }
34498
+ }
34499
+
34500
+ //Support require(['a'])
34501
+ callback = callback || function () {};
34502
+
34503
+ //If relName is a function, it is an errback handler,
34504
+ //so remove it.
34505
+ if (typeof relName === 'function') {
34506
+ relName = forceSync;
34507
+ forceSync = alt;
34508
+ }
34509
+
34510
+ //Simulate async callback;
34511
+ if (forceSync) {
34512
+ main(undef, deps, callback, relName);
34513
+ } else {
34514
+ //Using a non-zero value because of concern for what old browsers
34515
+ //do, and latest browsers "upgrade" to 4 if lower value is used:
34516
+ //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
34517
+ //If want a value immediately, use require('id') instead -- something
34518
+ //that works in almond on the global level, but not guaranteed and
34519
+ //unlikely to work in other AMD implementations.
34520
+ setTimeout(function () {
34521
+ main(undef, deps, callback, relName);
34522
+ }, 4);
34523
+ }
34524
+
34525
+ return req;
34526
+ };
34527
+
34528
+ /**
34529
+ * Just drops the config on the floor, but returns req in case
34530
+ * the config return value is used.
34531
+ */
34532
+ req.config = function (cfg) {
34533
+ return req(cfg);
34534
+ };
34535
+
34536
+ /**
34537
+ * Expose module registry for debugging and tooling
34538
+ */
34539
+ requirejs._defined = defined;
34540
+
34541
+ define = function (name, deps, callback) {
34542
+ if (typeof name !== 'string') {
34543
+ throw new Error('See almond README: incorrect module build, no module name');
34544
+ }
34545
+
34546
+ //This module may not have dependencies
34547
+ if (!deps.splice) {
34548
+ //deps is not an array, so probably means
34549
+ //an object literal or factory function for
34550
+ //the value. Adjust args.
34551
+ callback = deps;
34552
+ deps = [];
34553
+ }
34554
+
34555
+ if (!hasProp(defined, name) && !hasProp(waiting, name)) {
34556
+ waiting[name] = [name, deps, callback];
34557
+ }
34558
+ };
34559
+
34560
+ define.amd = {
34561
+ jQuery: true
34562
+ };
34563
+ }());
34564
+
34565
+ S2.requirejs = requirejs;S2.require = require;S2.define = define;
34566
+ }
34567
+ }());
34568
+ S2.define("almond", function(){});
34569
+
34570
+ /* global jQuery:false, $:false */
34571
+ S2.define('jquery',[],function () {
34572
+ var _$ = jQuery || $;
34573
+
34574
+ if (_$ == null && console && console.error) {
34575
+ console.error(
34576
+ 'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
34577
+ 'found. Make sure that you are including jQuery before Select2 on your ' +
34578
+ 'web page.'
34579
+ );
34580
+ }
34581
+
34582
+ return _$;
34583
+ });
34584
+
34585
+ S2.define('select2/utils',[
34586
+ 'jquery'
34587
+ ], function ($) {
34588
+ var Utils = {};
34589
+
34590
+ Utils.Extend = function (ChildClass, SuperClass) {
34591
+ var __hasProp = {}.hasOwnProperty;
34592
+
34593
+ function BaseConstructor () {
34594
+ this.constructor = ChildClass;
34595
+ }
34596
+
34597
+ for (var key in SuperClass) {
34598
+ if (__hasProp.call(SuperClass, key)) {
34599
+ ChildClass[key] = SuperClass[key];
34600
+ }
34601
+ }
34602
+
34603
+ BaseConstructor.prototype = SuperClass.prototype;
34604
+ ChildClass.prototype = new BaseConstructor();
34605
+ ChildClass.__super__ = SuperClass.prototype;
34606
+
34607
+ return ChildClass;
34608
+ };
34609
+
34610
+ function getMethods (theClass) {
34611
+ var proto = theClass.prototype;
34612
+
34613
+ var methods = [];
34614
+
34615
+ for (var methodName in proto) {
34616
+ var m = proto[methodName];
34617
+
34618
+ if (typeof m !== 'function') {
34619
+ continue;
34620
+ }
34621
+
34622
+ if (methodName === 'constructor') {
34623
+ continue;
34624
+ }
34625
+
34626
+ methods.push(methodName);
34627
+ }
34628
+
34629
+ return methods;
34630
+ }
34631
+
34632
+ Utils.Decorate = function (SuperClass, DecoratorClass) {
34633
+ var decoratedMethods = getMethods(DecoratorClass);
34634
+ var superMethods = getMethods(SuperClass);
34635
+
34636
+ function DecoratedClass () {
34637
+ var unshift = Array.prototype.unshift;
34638
+
34639
+ var argCount = DecoratorClass.prototype.constructor.length;
34640
+
34641
+ var calledConstructor = SuperClass.prototype.constructor;
34642
+
34643
+ if (argCount > 0) {
34644
+ unshift.call(arguments, SuperClass.prototype.constructor);
34645
+
34646
+ calledConstructor = DecoratorClass.prototype.constructor;
34647
+ }
34648
+
34649
+ calledConstructor.apply(this, arguments);
34650
+ }
34651
+
34652
+ DecoratorClass.displayName = SuperClass.displayName;
34653
+
34654
+ function ctr () {
34655
+ this.constructor = DecoratedClass;
34656
+ }
34657
+
34658
+ DecoratedClass.prototype = new ctr();
34659
+
34660
+ for (var m = 0; m < superMethods.length; m++) {
34661
+ var superMethod = superMethods[m];
34662
+
34663
+ DecoratedClass.prototype[superMethod] =
34664
+ SuperClass.prototype[superMethod];
34665
+ }
34666
+
34667
+ var calledMethod = function (methodName) {
34668
+ // Stub out the original method if it's not decorating an actual method
34669
+ var originalMethod = function () {};
34670
+
34671
+ if (methodName in DecoratedClass.prototype) {
34672
+ originalMethod = DecoratedClass.prototype[methodName];
34673
+ }
34674
+
34675
+ var decoratedMethod = DecoratorClass.prototype[methodName];
34676
+
34677
+ return function () {
34678
+ var unshift = Array.prototype.unshift;
34679
+
34680
+ unshift.call(arguments, originalMethod);
34681
+
34682
+ return decoratedMethod.apply(this, arguments);
34683
+ };
34684
+ };
34685
+
34686
+ for (var d = 0; d < decoratedMethods.length; d++) {
34687
+ var decoratedMethod = decoratedMethods[d];
34688
+
34689
+ DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
34690
+ }
34691
+
34692
+ return DecoratedClass;
34693
+ };
34694
+
34695
+ var Observable = function () {
34696
+ this.listeners = {};
34697
+ };
34698
+
34699
+ Observable.prototype.on = function (event, callback) {
34700
+ this.listeners = this.listeners || {};
34701
+
34702
+ if (event in this.listeners) {
34703
+ this.listeners[event].push(callback);
34704
+ } else {
34705
+ this.listeners[event] = [callback];
34706
+ }
34707
+ };
34708
+
34709
+ Observable.prototype.trigger = function (event) {
34710
+ var slice = Array.prototype.slice;
34711
+ var params = slice.call(arguments, 1);
34712
+
34713
+ this.listeners = this.listeners || {};
34714
+
34715
+ // Params should always come in as an array
34716
+ if (params == null) {
34717
+ params = [];
34718
+ }
34719
+
34720
+ // If there are no arguments to the event, use a temporary object
34721
+ if (params.length === 0) {
34722
+ params.push({});
34723
+ }
34724
+
34725
+ // Set the `_type` of the first object to the event
34726
+ params[0]._type = event;
34727
+
34728
+ if (event in this.listeners) {
34729
+ this.invoke(this.listeners[event], slice.call(arguments, 1));
34730
+ }
34731
+
34732
+ if ('*' in this.listeners) {
34733
+ this.invoke(this.listeners['*'], arguments);
34734
+ }
34735
+ };
34736
+
34737
+ Observable.prototype.invoke = function (listeners, params) {
34738
+ for (var i = 0, len = listeners.length; i < len; i++) {
34739
+ listeners[i].apply(this, params);
34740
+ }
34741
+ };
34742
+
34743
+ Utils.Observable = Observable;
34744
+
34745
+ Utils.generateChars = function (length) {
34746
+ var chars = '';
34747
+
34748
+ for (var i = 0; i < length; i++) {
34749
+ var randomChar = Math.floor(Math.random() * 36);
34750
+ chars += randomChar.toString(36);
34751
+ }
34752
+
34753
+ return chars;
34754
+ };
34755
+
34756
+ Utils.bind = function (func, context) {
34757
+ return function () {
34758
+ func.apply(context, arguments);
34759
+ };
34760
+ };
34761
+
34762
+ Utils._convertData = function (data) {
34763
+ for (var originalKey in data) {
34764
+ var keys = originalKey.split('-');
34765
+
34766
+ var dataLevel = data;
34767
+
34768
+ if (keys.length === 1) {
34769
+ continue;
34770
+ }
34771
+
34772
+ for (var k = 0; k < keys.length; k++) {
34773
+ var key = keys[k];
34774
+
34775
+ // Lowercase the first letter
34776
+ // By default, dash-separated becomes camelCase
34777
+ key = key.substring(0, 1).toLowerCase() + key.substring(1);
34778
+
34779
+ if (!(key in dataLevel)) {
34780
+ dataLevel[key] = {};
34781
+ }
34782
+
34783
+ if (k == keys.length - 1) {
34784
+ dataLevel[key] = data[originalKey];
34785
+ }
34786
+
34787
+ dataLevel = dataLevel[key];
34788
+ }
34789
+
34790
+ delete data[originalKey];
34791
+ }
34792
+
34793
+ return data;
34794
+ };
34795
+
34796
+ Utils.hasScroll = function (index, el) {
34797
+ // Adapted from the function created by @ShadowScripter
34798
+ // and adapted by @BillBarry on the Stack Exchange Code Review website.
34799
+ // The original code can be found at
34800
+ // http://codereview.stackexchange.com/q/13338
34801
+ // and was designed to be used with the Sizzle selector engine.
34802
+
34803
+ var $el = $(el);
34804
+ var overflowX = el.style.overflowX;
34805
+ var overflowY = el.style.overflowY;
34806
+
34807
+ //Check both x and y declarations
34808
+ if (overflowX === overflowY &&
34809
+ (overflowY === 'hidden' || overflowY === 'visible')) {
34810
+ return false;
34811
+ }
34812
+
34813
+ if (overflowX === 'scroll' || overflowY === 'scroll') {
34814
+ return true;
34815
+ }
34816
+
34817
+ return ($el.innerHeight() < el.scrollHeight ||
34818
+ $el.innerWidth() < el.scrollWidth);
34819
+ };
34820
+
34821
+ Utils.escapeMarkup = function (markup) {
34822
+ var replaceMap = {
34823
+ '\\': '&#92;',
34824
+ '&': '&amp;',
34825
+ '<': '&lt;',
34826
+ '>': '&gt;',
34827
+ '"': '&quot;',
34828
+ '\'': '&#39;',
34829
+ '/': '&#47;'
34830
+ };
34831
+
34832
+ // Do not try to escape the markup if it's not a string
34833
+ if (typeof markup !== 'string') {
34834
+ return markup;
34835
+ }
34836
+
34837
+ return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
34838
+ return replaceMap[match];
34839
+ });
34840
+ };
34841
+
34842
+ // Append an array of jQuery nodes to a given element.
34843
+ Utils.appendMany = function ($element, $nodes) {
34844
+ // jQuery 1.7.x does not support $.fn.append() with an array
34845
+ // Fall back to a jQuery object collection using $.fn.add()
34846
+ if ($.fn.jquery.substr(0, 3) === '1.7') {
34847
+ var $jqNodes = $();
34848
+
34849
+ $.map($nodes, function (node) {
34850
+ $jqNodes = $jqNodes.add(node);
34851
+ });
34852
+
34853
+ $nodes = $jqNodes;
34854
+ }
34855
+
34856
+ $element.append($nodes);
34857
+ };
34858
+
34859
+ return Utils;
34860
+ });
34861
+
34862
+ S2.define('select2/results',[
34863
+ 'jquery',
34864
+ './utils'
34865
+ ], function ($, Utils) {
34866
+ function Results ($element, options, dataAdapter) {
34867
+ this.$element = $element;
34868
+ this.data = dataAdapter;
34869
+ this.options = options;
34870
+
34871
+ Results.__super__.constructor.call(this);
34872
+ }
34873
+
34874
+ Utils.Extend(Results, Utils.Observable);
34875
+
34876
+ Results.prototype.render = function () {
34877
+ var $results = $(
34878
+ '<ul class="select2-results__options" role="tree"></ul>'
34879
+ );
34880
+
34881
+ if (this.options.get('multiple')) {
34882
+ $results.attr('aria-multiselectable', 'true');
34883
+ }
34884
+
34885
+ this.$results = $results;
34886
+
34887
+ return $results;
34888
+ };
34889
+
34890
+ Results.prototype.clear = function () {
34891
+ this.$results.empty();
34892
+ };
34893
+
34894
+ Results.prototype.displayMessage = function (params) {
34895
+ var escapeMarkup = this.options.get('escapeMarkup');
34896
+
34897
+ this.clear();
34898
+ this.hideLoading();
34899
+
34900
+ var $message = $(
34901
+ '<li role="treeitem" aria-live="assertive"' +
34902
+ ' class="select2-results__option"></li>'
34903
+ );
34904
+
34905
+ var message = this.options.get('translations').get(params.message);
34906
+
34907
+ $message.append(
34908
+ escapeMarkup(
34909
+ message(params.args)
34910
+ )
34911
+ );
34912
+
34913
+ $message[0].className += ' select2-results__message';
34914
+
34915
+ this.$results.append($message);
34916
+ };
34917
+
34918
+ Results.prototype.hideMessages = function () {
34919
+ this.$results.find('.select2-results__message').remove();
34920
+ };
34921
+
34922
+ Results.prototype.append = function (data) {
34923
+ this.hideLoading();
34924
+
34925
+ var $options = [];
34926
+
34927
+ if (data.results == null || data.results.length === 0) {
34928
+ if (this.$results.children().length === 0) {
34929
+ this.trigger('results:message', {
34930
+ message: 'noResults'
34931
+ });
34932
+ }
34933
+
34934
+ return;
34935
+ }
34936
+
34937
+ data.results = this.sort(data.results);
34938
+
34939
+ for (var d = 0; d < data.results.length; d++) {
34940
+ var item = data.results[d];
34941
+
34942
+ var $option = this.option(item);
34943
+
34944
+ $options.push($option);
34945
+ }
34946
+
34947
+ this.$results.append($options);
34948
+ };
34949
+
34950
+ Results.prototype.position = function ($results, $dropdown) {
34951
+ var $resultsContainer = $dropdown.find('.select2-results');
34952
+ $resultsContainer.append($results);
34953
+ };
34954
+
34955
+ Results.prototype.sort = function (data) {
34956
+ var sorter = this.options.get('sorter');
34957
+
34958
+ return sorter(data);
34959
+ };
34960
+
34961
+ Results.prototype.highlightFirstItem = function () {
34962
+ var $options = this.$results
34963
+ .find('.select2-results__option[aria-selected]');
34964
+
34965
+ var $selected = $options.filter('[aria-selected=true]');
34966
+
34967
+ // Check if there are any selected options
34968
+ if ($selected.length > 0) {
34969
+ // If there are selected options, highlight the first
34970
+ $selected.first().trigger('mouseenter');
34971
+ } else {
34972
+ // If there are no selected options, highlight the first option
34973
+ // in the dropdown
34974
+ $options.first().trigger('mouseenter');
34975
+ }
34976
+
34977
+ this.ensureHighlightVisible();
34978
+ };
34979
+
34980
+ Results.prototype.setClasses = function () {
34981
+ var self = this;
34982
+
34983
+ this.data.current(function (selected) {
34984
+ var selectedIds = $.map(selected, function (s) {
34985
+ return s.id.toString();
34986
+ });
34987
+
34988
+ var $options = self.$results
34989
+ .find('.select2-results__option[aria-selected]');
34990
+
34991
+ $options.each(function () {
34992
+ var $option = $(this);
34993
+
34994
+ var item = $.data(this, 'data');
34995
+
34996
+ // id needs to be converted to a string when comparing
34997
+ var id = '' + item.id;
34998
+
34999
+ if ((item.element != null && item.element.selected) ||
35000
+ (item.element == null && $.inArray(id, selectedIds) > -1)) {
35001
+ $option.attr('aria-selected', 'true');
35002
+ } else {
35003
+ $option.attr('aria-selected', 'false');
35004
+ }
35005
+ });
35006
+
35007
+ });
35008
+ };
35009
+
35010
+ Results.prototype.showLoading = function (params) {
35011
+ this.hideLoading();
35012
+
35013
+ var loadingMore = this.options.get('translations').get('searching');
35014
+
35015
+ var loading = {
35016
+ disabled: true,
35017
+ loading: true,
35018
+ text: loadingMore(params)
35019
+ };
35020
+ var $loading = this.option(loading);
35021
+ $loading.className += ' loading-results';
35022
+
35023
+ this.$results.prepend($loading);
35024
+ };
35025
+
35026
+ Results.prototype.hideLoading = function () {
35027
+ this.$results.find('.loading-results').remove();
35028
+ };
35029
+
35030
+ Results.prototype.option = function (data) {
35031
+ var option = document.createElement('li');
35032
+ option.className = 'select2-results__option';
35033
+
35034
+ var attrs = {
35035
+ 'role': 'treeitem',
35036
+ 'aria-selected': 'false'
35037
+ };
35038
+
35039
+ if (data.disabled) {
35040
+ delete attrs['aria-selected'];
35041
+ attrs['aria-disabled'] = 'true';
35042
+ }
35043
+
35044
+ if (data.id == null) {
35045
+ delete attrs['aria-selected'];
35046
+ }
35047
+
35048
+ if (data._resultId != null) {
35049
+ option.id = data._resultId;
35050
+ }
35051
+
35052
+ if (data.title) {
35053
+ option.title = data.title;
35054
+ }
35055
+
35056
+ if (data.children) {
35057
+ attrs.role = 'group';
35058
+ attrs['aria-label'] = data.text;
35059
+ delete attrs['aria-selected'];
35060
+ }
35061
+
35062
+ for (var attr in attrs) {
35063
+ var val = attrs[attr];
35064
+
35065
+ option.setAttribute(attr, val);
35066
+ }
35067
+
35068
+ if (data.children) {
35069
+ var $option = $(option);
35070
+
35071
+ var label = document.createElement('strong');
35072
+ label.className = 'select2-results__group';
35073
+
35074
+ var $label = $(label);
35075
+ this.template(data, label);
35076
+
35077
+ var $children = [];
35078
+
35079
+ for (var c = 0; c < data.children.length; c++) {
35080
+ var child = data.children[c];
35081
+
35082
+ var $child = this.option(child);
35083
+
35084
+ $children.push($child);
35085
+ }
35086
+
35087
+ var $childrenContainer = $('<ul></ul>', {
35088
+ 'class': 'select2-results__options select2-results__options--nested'
35089
+ });
35090
+
35091
+ $childrenContainer.append($children);
35092
+
35093
+ $option.append(label);
35094
+ $option.append($childrenContainer);
35095
+ } else {
35096
+ this.template(data, option);
35097
+ }
35098
+
35099
+ $.data(option, 'data', data);
35100
+
35101
+ return option;
35102
+ };
35103
+
35104
+ Results.prototype.bind = function (container, $container) {
35105
+ var self = this;
35106
+
35107
+ var id = container.id + '-results';
35108
+
35109
+ this.$results.attr('id', id);
35110
+
35111
+ container.on('results:all', function (params) {
35112
+ self.clear();
35113
+ self.append(params.data);
35114
+
35115
+ if (container.isOpen()) {
35116
+ self.setClasses();
35117
+ self.highlightFirstItem();
35118
+ }
35119
+ });
35120
+
35121
+ container.on('results:append', function (params) {
35122
+ self.append(params.data);
35123
+
35124
+ if (container.isOpen()) {
35125
+ self.setClasses();
35126
+ }
35127
+ });
35128
+
35129
+ container.on('query', function (params) {
35130
+ self.hideMessages();
35131
+ self.showLoading(params);
35132
+ });
35133
+
35134
+ container.on('select', function () {
35135
+ if (!container.isOpen()) {
35136
+ return;
35137
+ }
35138
+
35139
+ self.setClasses();
35140
+ self.highlightFirstItem();
35141
+ });
35142
+
35143
+ container.on('unselect', function () {
35144
+ if (!container.isOpen()) {
35145
+ return;
35146
+ }
35147
+
35148
+ self.setClasses();
35149
+ self.highlightFirstItem();
35150
+ });
35151
+
35152
+ container.on('open', function () {
35153
+ // When the dropdown is open, aria-expended="true"
35154
+ self.$results.attr('aria-expanded', 'true');
35155
+ self.$results.attr('aria-hidden', 'false');
35156
+
35157
+ self.setClasses();
35158
+ self.ensureHighlightVisible();
35159
+ });
35160
+
35161
+ container.on('close', function () {
35162
+ // When the dropdown is closed, aria-expended="false"
35163
+ self.$results.attr('aria-expanded', 'false');
35164
+ self.$results.attr('aria-hidden', 'true');
35165
+ self.$results.removeAttr('aria-activedescendant');
35166
+ });
35167
+
35168
+ container.on('results:toggle', function () {
35169
+ var $highlighted = self.getHighlightedResults();
35170
+
35171
+ if ($highlighted.length === 0) {
35172
+ return;
35173
+ }
35174
+
35175
+ $highlighted.trigger('mouseup');
35176
+ });
35177
+
35178
+ container.on('results:select', function () {
35179
+ var $highlighted = self.getHighlightedResults();
35180
+
35181
+ if ($highlighted.length === 0) {
35182
+ return;
35183
+ }
35184
+
35185
+ var data = $highlighted.data('data');
35186
+
35187
+ if ($highlighted.attr('aria-selected') == 'true') {
35188
+ self.trigger('close', {});
35189
+ } else {
35190
+ self.trigger('select', {
35191
+ data: data
35192
+ });
35193
+ }
35194
+ });
35195
+
35196
+ container.on('results:previous', function () {
35197
+ var $highlighted = self.getHighlightedResults();
35198
+
35199
+ var $options = self.$results.find('[aria-selected]');
35200
+
35201
+ var currentIndex = $options.index($highlighted);
35202
+
35203
+ // If we are already at te top, don't move further
35204
+ if (currentIndex === 0) {
35205
+ return;
35206
+ }
35207
+
35208
+ var nextIndex = currentIndex - 1;
35209
+
35210
+ // If none are highlighted, highlight the first
35211
+ if ($highlighted.length === 0) {
35212
+ nextIndex = 0;
35213
+ }
35214
+
35215
+ var $next = $options.eq(nextIndex);
35216
+
35217
+ $next.trigger('mouseenter');
35218
+
35219
+ var currentOffset = self.$results.offset().top;
35220
+ var nextTop = $next.offset().top;
35221
+ var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
35222
+
35223
+ if (nextIndex === 0) {
35224
+ self.$results.scrollTop(0);
35225
+ } else if (nextTop - currentOffset < 0) {
35226
+ self.$results.scrollTop(nextOffset);
35227
+ }
35228
+ });
35229
+
35230
+ container.on('results:next', function () {
35231
+ var $highlighted = self.getHighlightedResults();
35232
+
35233
+ var $options = self.$results.find('[aria-selected]');
35234
+
35235
+ var currentIndex = $options.index($highlighted);
35236
+
35237
+ var nextIndex = currentIndex + 1;
35238
+
35239
+ // If we are at the last option, stay there
35240
+ if (nextIndex >= $options.length) {
35241
+ return;
35242
+ }
35243
+
35244
+ var $next = $options.eq(nextIndex);
35245
+
35246
+ $next.trigger('mouseenter');
35247
+
35248
+ var currentOffset = self.$results.offset().top +
35249
+ self.$results.outerHeight(false);
35250
+ var nextBottom = $next.offset().top + $next.outerHeight(false);
35251
+ var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
35252
+
35253
+ if (nextIndex === 0) {
35254
+ self.$results.scrollTop(0);
35255
+ } else if (nextBottom > currentOffset) {
35256
+ self.$results.scrollTop(nextOffset);
35257
+ }
35258
+ });
35259
+
35260
+ container.on('results:focus', function (params) {
35261
+ params.element.addClass('select2-results__option--highlighted');
35262
+ });
35263
+
35264
+ container.on('results:message', function (params) {
35265
+ self.displayMessage(params);
35266
+ });
35267
+
35268
+ if ($.fn.mousewheel) {
35269
+ this.$results.on('mousewheel', function (e) {
35270
+ var top = self.$results.scrollTop();
35271
+
35272
+ var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
35273
+
35274
+ var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
35275
+ var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
35276
+
35277
+ if (isAtTop) {
35278
+ self.$results.scrollTop(0);
35279
+
35280
+ e.preventDefault();
35281
+ e.stopPropagation();
35282
+ } else if (isAtBottom) {
35283
+ self.$results.scrollTop(
35284
+ self.$results.get(0).scrollHeight - self.$results.height()
35285
+ );
35286
+
35287
+ e.preventDefault();
35288
+ e.stopPropagation();
35289
+ }
35290
+ });
35291
+ }
35292
+
35293
+ this.$results.on('mouseup', '.select2-results__option[aria-selected]',
35294
+ function (evt) {
35295
+ var $this = $(this);
35296
+
35297
+ var data = $this.data('data');
35298
+
35299
+ if ($this.attr('aria-selected') === 'true') {
35300
+ if (self.options.get('multiple')) {
35301
+ self.trigger('unselect', {
35302
+ originalEvent: evt,
35303
+ data: data
35304
+ });
35305
+ } else {
35306
+ self.trigger('close', {});
35307
+ }
35308
+
35309
+ return;
35310
+ }
35311
+
35312
+ self.trigger('select', {
35313
+ originalEvent: evt,
35314
+ data: data
35315
+ });
35316
+ });
35317
+
35318
+ this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
35319
+ function (evt) {
35320
+ var data = $(this).data('data');
35321
+
35322
+ self.getHighlightedResults()
35323
+ .removeClass('select2-results__option--highlighted');
35324
+
35325
+ self.trigger('results:focus', {
35326
+ data: data,
35327
+ element: $(this)
35328
+ });
35329
+ });
35330
+ };
35331
+
35332
+ Results.prototype.getHighlightedResults = function () {
35333
+ var $highlighted = this.$results
35334
+ .find('.select2-results__option--highlighted');
35335
+
35336
+ return $highlighted;
35337
+ };
35338
+
35339
+ Results.prototype.destroy = function () {
35340
+ this.$results.remove();
35341
+ };
35342
+
35343
+ Results.prototype.ensureHighlightVisible = function () {
35344
+ var $highlighted = this.getHighlightedResults();
35345
+
35346
+ if ($highlighted.length === 0) {
35347
+ return;
35348
+ }
35349
+
35350
+ var $options = this.$results.find('[aria-selected]');
35351
+
35352
+ var currentIndex = $options.index($highlighted);
35353
+
35354
+ var currentOffset = this.$results.offset().top;
35355
+ var nextTop = $highlighted.offset().top;
35356
+ var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
35357
+
35358
+ var offsetDelta = nextTop - currentOffset;
35359
+ nextOffset -= $highlighted.outerHeight(false) * 2;
35360
+
35361
+ if (currentIndex <= 2) {
35362
+ this.$results.scrollTop(0);
35363
+ } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
35364
+ this.$results.scrollTop(nextOffset);
35365
+ }
35366
+ };
35367
+
35368
+ Results.prototype.template = function (result, container) {
35369
+ var template = this.options.get('templateResult');
35370
+ var escapeMarkup = this.options.get('escapeMarkup');
35371
+
35372
+ var content = template(result, container);
35373
+
35374
+ if (content == null) {
35375
+ container.style.display = 'none';
35376
+ } else if (typeof content === 'string') {
35377
+ container.innerHTML = escapeMarkup(content);
35378
+ } else {
35379
+ $(container).append(content);
35380
+ }
35381
+ };
35382
+
35383
+ return Results;
35384
+ });
35385
+
35386
+ S2.define('select2/keys',[
35387
+
35388
+ ], function () {
35389
+ var KEYS = {
35390
+ BACKSPACE: 8,
35391
+ TAB: 9,
35392
+ ENTER: 13,
35393
+ SHIFT: 16,
35394
+ CTRL: 17,
35395
+ ALT: 18,
35396
+ ESC: 27,
35397
+ SPACE: 32,
35398
+ PAGE_UP: 33,
35399
+ PAGE_DOWN: 34,
35400
+ END: 35,
35401
+ HOME: 36,
35402
+ LEFT: 37,
35403
+ UP: 38,
35404
+ RIGHT: 39,
35405
+ DOWN: 40,
35406
+ DELETE: 46
35407
+ };
35408
+
35409
+ return KEYS;
35410
+ });
35411
+
35412
+ S2.define('select2/selection/base',[
35413
+ 'jquery',
35414
+ '../utils',
35415
+ '../keys'
35416
+ ], function ($, Utils, KEYS) {
35417
+ function BaseSelection ($element, options) {
35418
+ this.$element = $element;
35419
+ this.options = options;
35420
+
35421
+ BaseSelection.__super__.constructor.call(this);
35422
+ }
35423
+
35424
+ Utils.Extend(BaseSelection, Utils.Observable);
35425
+
35426
+ BaseSelection.prototype.render = function () {
35427
+ var $selection = $(
35428
+ '<span class="select2-selection" role="combobox" ' +
35429
+ ' aria-haspopup="true" aria-expanded="false">' +
35430
+ '</span>'
35431
+ );
35432
+
35433
+ this._tabindex = 0;
35434
+
35435
+ if (this.$element.data('old-tabindex') != null) {
35436
+ this._tabindex = this.$element.data('old-tabindex');
35437
+ } else if (this.$element.attr('tabindex') != null) {
35438
+ this._tabindex = this.$element.attr('tabindex');
35439
+ }
35440
+
35441
+ $selection.attr('title', this.$element.attr('title'));
35442
+ $selection.attr('tabindex', this._tabindex);
35443
+
35444
+ this.$selection = $selection;
35445
+
35446
+ return $selection;
35447
+ };
35448
+
35449
+ BaseSelection.prototype.bind = function (container, $container) {
35450
+ var self = this;
35451
+
35452
+ var id = container.id + '-container';
35453
+ var resultsId = container.id + '-results';
35454
+
35455
+ this.container = container;
35456
+
35457
+ this.$selection.on('focus', function (evt) {
35458
+ self.trigger('focus', evt);
35459
+ });
35460
+
35461
+ this.$selection.on('blur', function (evt) {
35462
+ self._handleBlur(evt);
35463
+ });
35464
+
35465
+ this.$selection.on('keydown', function (evt) {
35466
+ self.trigger('keypress', evt);
35467
+
35468
+ if (evt.which === KEYS.SPACE) {
35469
+ evt.preventDefault();
35470
+ }
35471
+ });
35472
+
35473
+ container.on('results:focus', function (params) {
35474
+ self.$selection.attr('aria-activedescendant', params.data._resultId);
35475
+ });
35476
+
35477
+ container.on('selection:update', function (params) {
35478
+ self.update(params.data);
35479
+ });
35480
+
35481
+ container.on('open', function () {
35482
+ // When the dropdown is open, aria-expanded="true"
35483
+ self.$selection.attr('aria-expanded', 'true');
35484
+ self.$selection.attr('aria-owns', resultsId);
35485
+
35486
+ self._attachCloseHandler(container);
35487
+ });
35488
+
35489
+ container.on('close', function () {
35490
+ // When the dropdown is closed, aria-expanded="false"
35491
+ self.$selection.attr('aria-expanded', 'false');
35492
+ self.$selection.removeAttr('aria-activedescendant');
35493
+ self.$selection.removeAttr('aria-owns');
35494
+
35495
+ self.$selection.focus();
35496
+
35497
+ self._detachCloseHandler(container);
35498
+ });
35499
+
35500
+ container.on('enable', function () {
35501
+ self.$selection.attr('tabindex', self._tabindex);
35502
+ });
35503
+
35504
+ container.on('disable', function () {
35505
+ self.$selection.attr('tabindex', '-1');
35506
+ });
35507
+ };
35508
+
35509
+ BaseSelection.prototype._handleBlur = function (evt) {
35510
+ var self = this;
35511
+
35512
+ // This needs to be delayed as the active element is the body when the tab
35513
+ // key is pressed, possibly along with others.
35514
+ window.setTimeout(function () {
35515
+ // Don't trigger `blur` if the focus is still in the selection
35516
+ if (
35517
+ (document.activeElement == self.$selection[0]) ||
35518
+ ($.contains(self.$selection[0], document.activeElement))
35519
+ ) {
35520
+ return;
35521
+ }
35522
+
35523
+ self.trigger('blur', evt);
35524
+ }, 1);
35525
+ };
35526
+
35527
+ BaseSelection.prototype._attachCloseHandler = function (container) {
35528
+ var self = this;
35529
+
35530
+ $(document.body).on('mousedown.select2.' + container.id, function (e) {
35531
+ var $target = $(e.target);
35532
+
35533
+ var $select = $target.closest('.select2');
35534
+
35535
+ var $all = $('.select2.select2-container--open');
35536
+
35537
+ $all.each(function () {
35538
+ var $this = $(this);
35539
+
35540
+ if (this == $select[0]) {
35541
+ return;
35542
+ }
35543
+
35544
+ var $element = $this.data('element');
35545
+
35546
+ $element.select2('close');
35547
+ });
35548
+ });
35549
+ };
35550
+
35551
+ BaseSelection.prototype._detachCloseHandler = function (container) {
35552
+ $(document.body).off('mousedown.select2.' + container.id);
35553
+ };
35554
+
35555
+ BaseSelection.prototype.position = function ($selection, $container) {
35556
+ var $selectionContainer = $container.find('.selection');
35557
+ $selectionContainer.append($selection);
35558
+ };
35559
+
35560
+ BaseSelection.prototype.destroy = function () {
35561
+ this._detachCloseHandler(this.container);
35562
+ };
35563
+
35564
+ BaseSelection.prototype.update = function (data) {
35565
+ throw new Error('The `update` method must be defined in child classes.');
35566
+ };
35567
+
35568
+ return BaseSelection;
35569
+ });
35570
+
35571
+ S2.define('select2/selection/single',[
35572
+ 'jquery',
35573
+ './base',
35574
+ '../utils',
35575
+ '../keys'
35576
+ ], function ($, BaseSelection, Utils, KEYS) {
35577
+ function SingleSelection () {
35578
+ SingleSelection.__super__.constructor.apply(this, arguments);
35579
+ }
35580
+
35581
+ Utils.Extend(SingleSelection, BaseSelection);
35582
+
35583
+ SingleSelection.prototype.render = function () {
35584
+ var $selection = SingleSelection.__super__.render.call(this);
35585
+
35586
+ $selection.addClass('select2-selection--single');
35587
+
35588
+ $selection.html(
35589
+ '<span class="select2-selection__rendered"></span>' +
35590
+ '<span class="select2-selection__arrow" role="presentation">' +
35591
+ '<b role="presentation"></b>' +
35592
+ '</span>'
35593
+ );
35594
+
35595
+ return $selection;
35596
+ };
35597
+
35598
+ SingleSelection.prototype.bind = function (container, $container) {
35599
+ var self = this;
35600
+
35601
+ SingleSelection.__super__.bind.apply(this, arguments);
35602
+
35603
+ var id = container.id + '-container';
35604
+
35605
+ this.$selection.find('.select2-selection__rendered').attr('id', id);
35606
+ this.$selection.attr('aria-labelledby', id);
35607
+
35608
+ this.$selection.on('mousedown', function (evt) {
35609
+ // Only respond to left clicks
35610
+ if (evt.which !== 1) {
35611
+ return;
35612
+ }
35613
+
35614
+ self.trigger('toggle', {
35615
+ originalEvent: evt
35616
+ });
35617
+ });
35618
+
35619
+ this.$selection.on('focus', function (evt) {
35620
+ // User focuses on the container
35621
+ });
35622
+
35623
+ this.$selection.on('blur', function (evt) {
35624
+ // User exits the container
35625
+ });
35626
+
35627
+ container.on('focus', function (evt) {
35628
+ if (!container.isOpen()) {
35629
+ self.$selection.focus();
35630
+ }
35631
+ });
35632
+
35633
+ container.on('selection:update', function (params) {
35634
+ self.update(params.data);
35635
+ });
35636
+ };
35637
+
35638
+ SingleSelection.prototype.clear = function () {
35639
+ this.$selection.find('.select2-selection__rendered').empty();
35640
+ };
35641
+
35642
+ SingleSelection.prototype.display = function (data, container) {
35643
+ var template = this.options.get('templateSelection');
35644
+ var escapeMarkup = this.options.get('escapeMarkup');
35645
+
35646
+ return escapeMarkup(template(data, container));
35647
+ };
35648
+
35649
+ SingleSelection.prototype.selectionContainer = function () {
35650
+ return $('<span></span>');
35651
+ };
35652
+
35653
+ SingleSelection.prototype.update = function (data) {
35654
+ if (data.length === 0) {
35655
+ this.clear();
35656
+ return;
35657
+ }
35658
+
35659
+ var selection = data[0];
35660
+
35661
+ var $rendered = this.$selection.find('.select2-selection__rendered');
35662
+ var formatted = this.display(selection, $rendered);
35663
+
35664
+ $rendered.empty().append(formatted);
35665
+ $rendered.prop('title', selection.title || selection.text);
35666
+ };
35667
+
35668
+ return SingleSelection;
35669
+ });
35670
+
35671
+ S2.define('select2/selection/multiple',[
35672
+ 'jquery',
35673
+ './base',
35674
+ '../utils'
35675
+ ], function ($, BaseSelection, Utils) {
35676
+ function MultipleSelection ($element, options) {
35677
+ MultipleSelection.__super__.constructor.apply(this, arguments);
35678
+ }
35679
+
35680
+ Utils.Extend(MultipleSelection, BaseSelection);
35681
+
35682
+ MultipleSelection.prototype.render = function () {
35683
+ var $selection = MultipleSelection.__super__.render.call(this);
35684
+
35685
+ $selection.addClass('select2-selection--multiple');
35686
+
35687
+ $selection.html(
35688
+ '<ul class="select2-selection__rendered"></ul>'
35689
+ );
35690
+
35691
+ return $selection;
35692
+ };
35693
+
35694
+ MultipleSelection.prototype.bind = function (container, $container) {
35695
+ var self = this;
35696
+
35697
+ MultipleSelection.__super__.bind.apply(this, arguments);
35698
+
35699
+ this.$selection.on('click', function (evt) {
35700
+ self.trigger('toggle', {
35701
+ originalEvent: evt
35702
+ });
35703
+ });
35704
+
35705
+ this.$selection.on(
35706
+ 'click',
35707
+ '.select2-selection__choice__remove',
35708
+ function (evt) {
35709
+ // Ignore the event if it is disabled
35710
+ if (self.options.get('disabled')) {
35711
+ return;
35712
+ }
35713
+
35714
+ var $remove = $(this);
35715
+ var $selection = $remove.parent();
35716
+
35717
+ var data = $selection.data('data');
35718
+
35719
+ self.trigger('unselect', {
35720
+ originalEvent: evt,
35721
+ data: data
35722
+ });
35723
+ }
35724
+ );
35725
+ };
35726
+
35727
+ MultipleSelection.prototype.clear = function () {
35728
+ this.$selection.find('.select2-selection__rendered').empty();
35729
+ };
35730
+
35731
+ MultipleSelection.prototype.display = function (data, container) {
35732
+ var template = this.options.get('templateSelection');
35733
+ var escapeMarkup = this.options.get('escapeMarkup');
35734
+
35735
+ return escapeMarkup(template(data, container));
35736
+ };
35737
+
35738
+ MultipleSelection.prototype.selectionContainer = function () {
35739
+ var $container = $(
35740
+ '<li class="select2-selection__choice">' +
35741
+ '<span class="select2-selection__choice__remove" role="presentation">' +
35742
+ '&times;' +
35743
+ '</span>' +
35744
+ '</li>'
35745
+ );
35746
+
35747
+ return $container;
35748
+ };
35749
+
35750
+ MultipleSelection.prototype.update = function (data) {
35751
+ this.clear();
35752
+
35753
+ if (data.length === 0) {
35754
+ return;
35755
+ }
35756
+
35757
+ var $selections = [];
35758
+
35759
+ for (var d = 0; d < data.length; d++) {
35760
+ var selection = data[d];
35761
+
35762
+ var $selection = this.selectionContainer();
35763
+ var formatted = this.display(selection, $selection);
35764
+
35765
+ $selection.append(formatted);
35766
+ $selection.prop('title', selection.title || selection.text);
35767
+
35768
+ $selection.data('data', selection);
35769
+
35770
+ $selections.push($selection);
35771
+ }
35772
+
35773
+ var $rendered = this.$selection.find('.select2-selection__rendered');
35774
+
35775
+ Utils.appendMany($rendered, $selections);
35776
+ };
35777
+
35778
+ return MultipleSelection;
35779
+ });
35780
+
35781
+ S2.define('select2/selection/placeholder',[
35782
+ '../utils'
35783
+ ], function (Utils) {
35784
+ function Placeholder (decorated, $element, options) {
35785
+ this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
35786
+
35787
+ decorated.call(this, $element, options);
35788
+ }
35789
+
35790
+ Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
35791
+ if (typeof placeholder === 'string') {
35792
+ placeholder = {
35793
+ id: '',
35794
+ text: placeholder
35795
+ };
35796
+ }
35797
+
35798
+ return placeholder;
35799
+ };
35800
+
35801
+ Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
35802
+ var $placeholder = this.selectionContainer();
35803
+
35804
+ $placeholder.html(this.display(placeholder));
35805
+ $placeholder.addClass('select2-selection__placeholder')
35806
+ .removeClass('select2-selection__choice');
35807
+
35808
+ return $placeholder;
35809
+ };
35810
+
35811
+ Placeholder.prototype.update = function (decorated, data) {
35812
+ var singlePlaceholder = (
35813
+ data.length == 1 && data[0].id != this.placeholder.id
35814
+ );
35815
+ var multipleSelections = data.length > 1;
35816
+
35817
+ if (multipleSelections || singlePlaceholder) {
35818
+ return decorated.call(this, data);
35819
+ }
35820
+
35821
+ this.clear();
35822
+
35823
+ var $placeholder = this.createPlaceholder(this.placeholder);
35824
+
35825
+ this.$selection.find('.select2-selection__rendered').append($placeholder);
35826
+ };
35827
+
35828
+ return Placeholder;
35829
+ });
35830
+
35831
+ S2.define('select2/selection/allowClear',[
35832
+ 'jquery',
35833
+ '../keys'
35834
+ ], function ($, KEYS) {
35835
+ function AllowClear () { }
35836
+
35837
+ AllowClear.prototype.bind = function (decorated, container, $container) {
35838
+ var self = this;
35839
+
35840
+ decorated.call(this, container, $container);
35841
+
35842
+ if (this.placeholder == null) {
35843
+ if (this.options.get('debug') && window.console && console.error) {
35844
+ console.error(
35845
+ 'Select2: The `allowClear` option should be used in combination ' +
35846
+ 'with the `placeholder` option.'
35847
+ );
35848
+ }
35849
+ }
35850
+
35851
+ this.$selection.on('mousedown', '.select2-selection__clear',
35852
+ function (evt) {
35853
+ self._handleClear(evt);
35854
+ });
35855
+
35856
+ container.on('keypress', function (evt) {
35857
+ self._handleKeyboardClear(evt, container);
35858
+ });
35859
+ };
35860
+
35861
+ AllowClear.prototype._handleClear = function (_, evt) {
35862
+ // Ignore the event if it is disabled
35863
+ if (this.options.get('disabled')) {
35864
+ return;
35865
+ }
35866
+
35867
+ var $clear = this.$selection.find('.select2-selection__clear');
35868
+
35869
+ // Ignore the event if nothing has been selected
35870
+ if ($clear.length === 0) {
35871
+ return;
35872
+ }
35873
+
35874
+ evt.stopPropagation();
35875
+
35876
+ var data = $clear.data('data');
35877
+
35878
+ for (var d = 0; d < data.length; d++) {
35879
+ var unselectData = {
35880
+ data: data[d]
35881
+ };
35882
+
35883
+ // Trigger the `unselect` event, so people can prevent it from being
35884
+ // cleared.
35885
+ this.trigger('unselect', unselectData);
35886
+
35887
+ // If the event was prevented, don't clear it out.
35888
+ if (unselectData.prevented) {
35889
+ return;
35890
+ }
35891
+ }
35892
+
35893
+ this.$element.val(this.placeholder.id).trigger('change');
35894
+
35895
+ this.trigger('toggle', {});
35896
+ };
35897
+
35898
+ AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
35899
+ if (container.isOpen()) {
35900
+ return;
35901
+ }
35902
+
35903
+ if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
35904
+ this._handleClear(evt);
35905
+ }
35906
+ };
35907
+
35908
+ AllowClear.prototype.update = function (decorated, data) {
35909
+ decorated.call(this, data);
35910
+
35911
+ if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
35912
+ data.length === 0) {
35913
+ return;
35914
+ }
35915
+
35916
+ var $remove = $(
35917
+ '<span class="select2-selection__clear">' +
35918
+ '&times;' +
35919
+ '</span>'
35920
+ );
35921
+ $remove.data('data', data);
35922
+
35923
+ this.$selection.find('.select2-selection__rendered').prepend($remove);
35924
+ };
35925
+
35926
+ return AllowClear;
35927
+ });
35928
+
35929
+ S2.define('select2/selection/search',[
35930
+ 'jquery',
35931
+ '../utils',
35932
+ '../keys'
35933
+ ], function ($, Utils, KEYS) {
35934
+ function Search (decorated, $element, options) {
35935
+ decorated.call(this, $element, options);
35936
+ }
35937
+
35938
+ Search.prototype.render = function (decorated) {
35939
+ var $search = $(
35940
+ '<li class="select2-search select2-search--inline">' +
35941
+ '<input class="select2-search__field" type="search" tabindex="-1"' +
35942
+ ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
35943
+ ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
35944
+ '</li>'
35945
+ );
35946
+
35947
+ this.$searchContainer = $search;
35948
+ this.$search = $search.find('input');
35949
+
35950
+ var $rendered = decorated.call(this);
35951
+
35952
+ this._transferTabIndex();
35953
+
35954
+ return $rendered;
35955
+ };
35956
+
35957
+ Search.prototype.bind = function (decorated, container, $container) {
35958
+ var self = this;
35959
+
35960
+ decorated.call(this, container, $container);
35961
+
35962
+ container.on('open', function () {
35963
+ self.$search.trigger('focus');
35964
+ });
35965
+
35966
+ container.on('close', function () {
35967
+ self.$search.val('');
35968
+ self.$search.removeAttr('aria-activedescendant');
35969
+ self.$search.trigger('focus');
35970
+ });
35971
+
35972
+ container.on('enable', function () {
35973
+ self.$search.prop('disabled', false);
35974
+
35975
+ self._transferTabIndex();
35976
+ });
35977
+
35978
+ container.on('disable', function () {
35979
+ self.$search.prop('disabled', true);
35980
+ });
35981
+
35982
+ container.on('focus', function (evt) {
35983
+ self.$search.trigger('focus');
35984
+ });
35985
+
35986
+ container.on('results:focus', function (params) {
35987
+ self.$search.attr('aria-activedescendant', params.id);
35988
+ });
35989
+
35990
+ this.$selection.on('focusin', '.select2-search--inline', function (evt) {
35991
+ self.trigger('focus', evt);
35992
+ });
35993
+
35994
+ this.$selection.on('focusout', '.select2-search--inline', function (evt) {
35995
+ self._handleBlur(evt);
35996
+ });
35997
+
35998
+ this.$selection.on('keydown', '.select2-search--inline', function (evt) {
35999
+ evt.stopPropagation();
36000
+
36001
+ self.trigger('keypress', evt);
36002
+
36003
+ self._keyUpPrevented = evt.isDefaultPrevented();
36004
+
36005
+ var key = evt.which;
36006
+
36007
+ if (key === KEYS.BACKSPACE && self.$search.val() === '') {
36008
+ var $previousChoice = self.$searchContainer
36009
+ .prev('.select2-selection__choice');
36010
+
36011
+ if ($previousChoice.length > 0) {
36012
+ var item = $previousChoice.data('data');
36013
+
36014
+ self.searchRemoveChoice(item);
36015
+
36016
+ evt.preventDefault();
36017
+ }
36018
+ }
36019
+ });
36020
+
36021
+ // Try to detect the IE version should the `documentMode` property that
36022
+ // is stored on the document. This is only implemented in IE and is
36023
+ // slightly cleaner than doing a user agent check.
36024
+ // This property is not available in Edge, but Edge also doesn't have
36025
+ // this bug.
36026
+ var msie = document.documentMode;
36027
+ var disableInputEvents = msie && msie <= 11;
36028
+
36029
+ // Workaround for browsers which do not support the `input` event
36030
+ // This will prevent double-triggering of events for browsers which support
36031
+ // both the `keyup` and `input` events.
36032
+ this.$selection.on(
36033
+ 'input.searchcheck',
36034
+ '.select2-search--inline',
36035
+ function (evt) {
36036
+ // IE will trigger the `input` event when a placeholder is used on a
36037
+ // search box. To get around this issue, we are forced to ignore all
36038
+ // `input` events in IE and keep using `keyup`.
36039
+ if (disableInputEvents) {
36040
+ self.$selection.off('input.search input.searchcheck');
36041
+ return;
36042
+ }
36043
+
36044
+ // Unbind the duplicated `keyup` event
36045
+ self.$selection.off('keyup.search');
36046
+ }
36047
+ );
36048
+
36049
+ this.$selection.on(
36050
+ 'keyup.search input.search',
36051
+ '.select2-search--inline',
36052
+ function (evt) {
36053
+ // IE will trigger the `input` event when a placeholder is used on a
36054
+ // search box. To get around this issue, we are forced to ignore all
36055
+ // `input` events in IE and keep using `keyup`.
36056
+ if (disableInputEvents && evt.type === 'input') {
36057
+ self.$selection.off('input.search input.searchcheck');
36058
+ return;
36059
+ }
36060
+
36061
+ var key = evt.which;
36062
+
36063
+ // We can freely ignore events from modifier keys
36064
+ if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
36065
+ return;
36066
+ }
36067
+
36068
+ // Tabbing will be handled during the `keydown` phase
36069
+ if (key == KEYS.TAB) {
36070
+ return;
36071
+ }
36072
+
36073
+ self.handleSearch(evt);
36074
+ }
36075
+ );
36076
+ };
36077
+
36078
+ /**
36079
+ * This method will transfer the tabindex attribute from the rendered
36080
+ * selection to the search box. This allows for the search box to be used as
36081
+ * the primary focus instead of the selection container.
36082
+ *
36083
+ * @private
36084
+ */
36085
+ Search.prototype._transferTabIndex = function (decorated) {
36086
+ this.$search.attr('tabindex', this.$selection.attr('tabindex'));
36087
+ this.$selection.attr('tabindex', '-1');
36088
+ };
36089
+
36090
+ Search.prototype.createPlaceholder = function (decorated, placeholder) {
36091
+ this.$search.attr('placeholder', placeholder.text);
36092
+ };
36093
+
36094
+ Search.prototype.update = function (decorated, data) {
36095
+ var searchHadFocus = this.$search[0] == document.activeElement;
36096
+
36097
+ this.$search.attr('placeholder', '');
36098
+
36099
+ decorated.call(this, data);
36100
+
36101
+ this.$selection.find('.select2-selection__rendered')
36102
+ .append(this.$searchContainer);
36103
+
36104
+ this.resizeSearch();
36105
+ if (searchHadFocus) {
36106
+ this.$search.focus();
36107
+ }
36108
+ };
36109
+
36110
+ Search.prototype.handleSearch = function () {
36111
+ this.resizeSearch();
36112
+
36113
+ if (!this._keyUpPrevented) {
36114
+ var input = this.$search.val();
36115
+
36116
+ this.trigger('query', {
36117
+ term: input
36118
+ });
36119
+ }
36120
+
36121
+ this._keyUpPrevented = false;
36122
+ };
36123
+
36124
+ Search.prototype.searchRemoveChoice = function (decorated, item) {
36125
+ this.trigger('unselect', {
36126
+ data: item
36127
+ });
36128
+
36129
+ this.$search.val(item.text);
36130
+ this.handleSearch();
36131
+ };
36132
+
36133
+ Search.prototype.resizeSearch = function () {
36134
+ this.$search.css('width', '25px');
36135
+
36136
+ var width = '';
36137
+
36138
+ if (this.$search.attr('placeholder') !== '') {
36139
+ width = this.$selection.find('.select2-selection__rendered').innerWidth();
36140
+ } else {
36141
+ var minimumWidth = this.$search.val().length + 1;
36142
+
36143
+ width = (minimumWidth * 0.75) + 'em';
36144
+ }
36145
+
36146
+ this.$search.css('width', width);
36147
+ };
36148
+
36149
+ return Search;
36150
+ });
36151
+
36152
+ S2.define('select2/selection/eventRelay',[
36153
+ 'jquery'
36154
+ ], function ($) {
36155
+ function EventRelay () { }
36156
+
36157
+ EventRelay.prototype.bind = function (decorated, container, $container) {
36158
+ var self = this;
36159
+ var relayEvents = [
36160
+ 'open', 'opening',
36161
+ 'close', 'closing',
36162
+ 'select', 'selecting',
36163
+ 'unselect', 'unselecting'
36164
+ ];
36165
+
36166
+ var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
36167
+
36168
+ decorated.call(this, container, $container);
36169
+
36170
+ container.on('*', function (name, params) {
36171
+ // Ignore events that should not be relayed
36172
+ if ($.inArray(name, relayEvents) === -1) {
36173
+ return;
36174
+ }
36175
+
36176
+ // The parameters should always be an object
36177
+ params = params || {};
36178
+
36179
+ // Generate the jQuery event for the Select2 event
36180
+ var evt = $.Event('select2:' + name, {
36181
+ params: params
36182
+ });
36183
+
36184
+ self.$element.trigger(evt);
36185
+
36186
+ // Only handle preventable events if it was one
36187
+ if ($.inArray(name, preventableEvents) === -1) {
36188
+ return;
36189
+ }
36190
+
36191
+ params.prevented = evt.isDefaultPrevented();
36192
+ });
36193
+ };
36194
+
36195
+ return EventRelay;
36196
+ });
36197
+
36198
+ S2.define('select2/translation',[
36199
+ 'jquery',
36200
+ 'require'
36201
+ ], function ($, require) {
36202
+ function Translation (dict) {
36203
+ this.dict = dict || {};
36204
+ }
36205
+
36206
+ Translation.prototype.all = function () {
36207
+ return this.dict;
36208
+ };
36209
+
36210
+ Translation.prototype.get = function (key) {
36211
+ return this.dict[key];
36212
+ };
36213
+
36214
+ Translation.prototype.extend = function (translation) {
36215
+ this.dict = $.extend({}, translation.all(), this.dict);
36216
+ };
36217
+
36218
+ // Static functions
36219
+
36220
+ Translation._cache = {};
36221
+
36222
+ Translation.loadPath = function (path) {
36223
+ if (!(path in Translation._cache)) {
36224
+ var translations = require(path);
36225
+
36226
+ Translation._cache[path] = translations;
36227
+ }
36228
+
36229
+ return new Translation(Translation._cache[path]);
36230
+ };
36231
+
36232
+ return Translation;
36233
+ });
36234
+
36235
+ S2.define('select2/diacritics',[
36236
+
36237
+ ], function () {
36238
+ var diacritics = {
36239
+ '\u24B6': 'A',
36240
+ '\uFF21': 'A',
36241
+ '\u00C0': 'A',
36242
+ '\u00C1': 'A',
36243
+ '\u00C2': 'A',
36244
+ '\u1EA6': 'A',
36245
+ '\u1EA4': 'A',
36246
+ '\u1EAA': 'A',
36247
+ '\u1EA8': 'A',
36248
+ '\u00C3': 'A',
36249
+ '\u0100': 'A',
36250
+ '\u0102': 'A',
36251
+ '\u1EB0': 'A',
36252
+ '\u1EAE': 'A',
36253
+ '\u1EB4': 'A',
36254
+ '\u1EB2': 'A',
36255
+ '\u0226': 'A',
36256
+ '\u01E0': 'A',
36257
+ '\u00C4': 'A',
36258
+ '\u01DE': 'A',
36259
+ '\u1EA2': 'A',
36260
+ '\u00C5': 'A',
36261
+ '\u01FA': 'A',
36262
+ '\u01CD': 'A',
36263
+ '\u0200': 'A',
36264
+ '\u0202': 'A',
36265
+ '\u1EA0': 'A',
36266
+ '\u1EAC': 'A',
36267
+ '\u1EB6': 'A',
36268
+ '\u1E00': 'A',
36269
+ '\u0104': 'A',
36270
+ '\u023A': 'A',
36271
+ '\u2C6F': 'A',
36272
+ '\uA732': 'AA',
36273
+ '\u00C6': 'AE',
36274
+ '\u01FC': 'AE',
36275
+ '\u01E2': 'AE',
36276
+ '\uA734': 'AO',
36277
+ '\uA736': 'AU',
36278
+ '\uA738': 'AV',
36279
+ '\uA73A': 'AV',
36280
+ '\uA73C': 'AY',
36281
+ '\u24B7': 'B',
36282
+ '\uFF22': 'B',
36283
+ '\u1E02': 'B',
36284
+ '\u1E04': 'B',
36285
+ '\u1E06': 'B',
36286
+ '\u0243': 'B',
36287
+ '\u0182': 'B',
36288
+ '\u0181': 'B',
36289
+ '\u24B8': 'C',
36290
+ '\uFF23': 'C',
36291
+ '\u0106': 'C',
36292
+ '\u0108': 'C',
36293
+ '\u010A': 'C',
36294
+ '\u010C': 'C',
36295
+ '\u00C7': 'C',
36296
+ '\u1E08': 'C',
36297
+ '\u0187': 'C',
36298
+ '\u023B': 'C',
36299
+ '\uA73E': 'C',
36300
+ '\u24B9': 'D',
36301
+ '\uFF24': 'D',
36302
+ '\u1E0A': 'D',
36303
+ '\u010E': 'D',
36304
+ '\u1E0C': 'D',
36305
+ '\u1E10': 'D',
36306
+ '\u1E12': 'D',
36307
+ '\u1E0E': 'D',
36308
+ '\u0110': 'D',
36309
+ '\u018B': 'D',
36310
+ '\u018A': 'D',
36311
+ '\u0189': 'D',
36312
+ '\uA779': 'D',
36313
+ '\u01F1': 'DZ',
36314
+ '\u01C4': 'DZ',
36315
+ '\u01F2': 'Dz',
36316
+ '\u01C5': 'Dz',
36317
+ '\u24BA': 'E',
36318
+ '\uFF25': 'E',
36319
+ '\u00C8': 'E',
36320
+ '\u00C9': 'E',
36321
+ '\u00CA': 'E',
36322
+ '\u1EC0': 'E',
36323
+ '\u1EBE': 'E',
36324
+ '\u1EC4': 'E',
36325
+ '\u1EC2': 'E',
36326
+ '\u1EBC': 'E',
36327
+ '\u0112': 'E',
36328
+ '\u1E14': 'E',
36329
+ '\u1E16': 'E',
36330
+ '\u0114': 'E',
36331
+ '\u0116': 'E',
36332
+ '\u00CB': 'E',
36333
+ '\u1EBA': 'E',
36334
+ '\u011A': 'E',
36335
+ '\u0204': 'E',
36336
+ '\u0206': 'E',
36337
+ '\u1EB8': 'E',
36338
+ '\u1EC6': 'E',
36339
+ '\u0228': 'E',
36340
+ '\u1E1C': 'E',
36341
+ '\u0118': 'E',
36342
+ '\u1E18': 'E',
36343
+ '\u1E1A': 'E',
36344
+ '\u0190': 'E',
36345
+ '\u018E': 'E',
36346
+ '\u24BB': 'F',
36347
+ '\uFF26': 'F',
36348
+ '\u1E1E': 'F',
36349
+ '\u0191': 'F',
36350
+ '\uA77B': 'F',
36351
+ '\u24BC': 'G',
36352
+ '\uFF27': 'G',
36353
+ '\u01F4': 'G',
36354
+ '\u011C': 'G',
36355
+ '\u1E20': 'G',
36356
+ '\u011E': 'G',
36357
+ '\u0120': 'G',
36358
+ '\u01E6': 'G',
36359
+ '\u0122': 'G',
36360
+ '\u01E4': 'G',
36361
+ '\u0193': 'G',
36362
+ '\uA7A0': 'G',
36363
+ '\uA77D': 'G',
36364
+ '\uA77E': 'G',
36365
+ '\u24BD': 'H',
36366
+ '\uFF28': 'H',
36367
+ '\u0124': 'H',
36368
+ '\u1E22': 'H',
36369
+ '\u1E26': 'H',
36370
+ '\u021E': 'H',
36371
+ '\u1E24': 'H',
36372
+ '\u1E28': 'H',
36373
+ '\u1E2A': 'H',
36374
+ '\u0126': 'H',
36375
+ '\u2C67': 'H',
36376
+ '\u2C75': 'H',
36377
+ '\uA78D': 'H',
36378
+ '\u24BE': 'I',
36379
+ '\uFF29': 'I',
36380
+ '\u00CC': 'I',
36381
+ '\u00CD': 'I',
36382
+ '\u00CE': 'I',
36383
+ '\u0128': 'I',
36384
+ '\u012A': 'I',
36385
+ '\u012C': 'I',
36386
+ '\u0130': 'I',
36387
+ '\u00CF': 'I',
36388
+ '\u1E2E': 'I',
36389
+ '\u1EC8': 'I',
36390
+ '\u01CF': 'I',
36391
+ '\u0208': 'I',
36392
+ '\u020A': 'I',
36393
+ '\u1ECA': 'I',
36394
+ '\u012E': 'I',
36395
+ '\u1E2C': 'I',
36396
+ '\u0197': 'I',
36397
+ '\u24BF': 'J',
36398
+ '\uFF2A': 'J',
36399
+ '\u0134': 'J',
36400
+ '\u0248': 'J',
36401
+ '\u24C0': 'K',
36402
+ '\uFF2B': 'K',
36403
+ '\u1E30': 'K',
36404
+ '\u01E8': 'K',
36405
+ '\u1E32': 'K',
36406
+ '\u0136': 'K',
36407
+ '\u1E34': 'K',
36408
+ '\u0198': 'K',
36409
+ '\u2C69': 'K',
36410
+ '\uA740': 'K',
36411
+ '\uA742': 'K',
36412
+ '\uA744': 'K',
36413
+ '\uA7A2': 'K',
36414
+ '\u24C1': 'L',
36415
+ '\uFF2C': 'L',
36416
+ '\u013F': 'L',
36417
+ '\u0139': 'L',
36418
+ '\u013D': 'L',
36419
+ '\u1E36': 'L',
36420
+ '\u1E38': 'L',
36421
+ '\u013B': 'L',
36422
+ '\u1E3C': 'L',
36423
+ '\u1E3A': 'L',
36424
+ '\u0141': 'L',
36425
+ '\u023D': 'L',
36426
+ '\u2C62': 'L',
36427
+ '\u2C60': 'L',
36428
+ '\uA748': 'L',
36429
+ '\uA746': 'L',
36430
+ '\uA780': 'L',
36431
+ '\u01C7': 'LJ',
36432
+ '\u01C8': 'Lj',
36433
+ '\u24C2': 'M',
36434
+ '\uFF2D': 'M',
36435
+ '\u1E3E': 'M',
36436
+ '\u1E40': 'M',
36437
+ '\u1E42': 'M',
36438
+ '\u2C6E': 'M',
36439
+ '\u019C': 'M',
36440
+ '\u24C3': 'N',
36441
+ '\uFF2E': 'N',
36442
+ '\u01F8': 'N',
36443
+ '\u0143': 'N',
36444
+ '\u00D1': 'N',
36445
+ '\u1E44': 'N',
36446
+ '\u0147': 'N',
36447
+ '\u1E46': 'N',
36448
+ '\u0145': 'N',
36449
+ '\u1E4A': 'N',
36450
+ '\u1E48': 'N',
36451
+ '\u0220': 'N',
36452
+ '\u019D': 'N',
36453
+ '\uA790': 'N',
36454
+ '\uA7A4': 'N',
36455
+ '\u01CA': 'NJ',
36456
+ '\u01CB': 'Nj',
36457
+ '\u24C4': 'O',
36458
+ '\uFF2F': 'O',
36459
+ '\u00D2': 'O',
36460
+ '\u00D3': 'O',
36461
+ '\u00D4': 'O',
36462
+ '\u1ED2': 'O',
36463
+ '\u1ED0': 'O',
36464
+ '\u1ED6': 'O',
36465
+ '\u1ED4': 'O',
36466
+ '\u00D5': 'O',
36467
+ '\u1E4C': 'O',
36468
+ '\u022C': 'O',
36469
+ '\u1E4E': 'O',
36470
+ '\u014C': 'O',
36471
+ '\u1E50': 'O',
36472
+ '\u1E52': 'O',
36473
+ '\u014E': 'O',
36474
+ '\u022E': 'O',
36475
+ '\u0230': 'O',
36476
+ '\u00D6': 'O',
36477
+ '\u022A': 'O',
36478
+ '\u1ECE': 'O',
36479
+ '\u0150': 'O',
36480
+ '\u01D1': 'O',
36481
+ '\u020C': 'O',
36482
+ '\u020E': 'O',
36483
+ '\u01A0': 'O',
36484
+ '\u1EDC': 'O',
36485
+ '\u1EDA': 'O',
36486
+ '\u1EE0': 'O',
36487
+ '\u1EDE': 'O',
36488
+ '\u1EE2': 'O',
36489
+ '\u1ECC': 'O',
36490
+ '\u1ED8': 'O',
36491
+ '\u01EA': 'O',
36492
+ '\u01EC': 'O',
36493
+ '\u00D8': 'O',
36494
+ '\u01FE': 'O',
36495
+ '\u0186': 'O',
36496
+ '\u019F': 'O',
36497
+ '\uA74A': 'O',
36498
+ '\uA74C': 'O',
36499
+ '\u01A2': 'OI',
36500
+ '\uA74E': 'OO',
36501
+ '\u0222': 'OU',
36502
+ '\u24C5': 'P',
36503
+ '\uFF30': 'P',
36504
+ '\u1E54': 'P',
36505
+ '\u1E56': 'P',
36506
+ '\u01A4': 'P',
36507
+ '\u2C63': 'P',
36508
+ '\uA750': 'P',
36509
+ '\uA752': 'P',
36510
+ '\uA754': 'P',
36511
+ '\u24C6': 'Q',
36512
+ '\uFF31': 'Q',
36513
+ '\uA756': 'Q',
36514
+ '\uA758': 'Q',
36515
+ '\u024A': 'Q',
36516
+ '\u24C7': 'R',
36517
+ '\uFF32': 'R',
36518
+ '\u0154': 'R',
36519
+ '\u1E58': 'R',
36520
+ '\u0158': 'R',
36521
+ '\u0210': 'R',
36522
+ '\u0212': 'R',
36523
+ '\u1E5A': 'R',
36524
+ '\u1E5C': 'R',
36525
+ '\u0156': 'R',
36526
+ '\u1E5E': 'R',
36527
+ '\u024C': 'R',
36528
+ '\u2C64': 'R',
36529
+ '\uA75A': 'R',
36530
+ '\uA7A6': 'R',
36531
+ '\uA782': 'R',
36532
+ '\u24C8': 'S',
36533
+ '\uFF33': 'S',
36534
+ '\u1E9E': 'S',
36535
+ '\u015A': 'S',
36536
+ '\u1E64': 'S',
36537
+ '\u015C': 'S',
36538
+ '\u1E60': 'S',
36539
+ '\u0160': 'S',
36540
+ '\u1E66': 'S',
36541
+ '\u1E62': 'S',
36542
+ '\u1E68': 'S',
36543
+ '\u0218': 'S',
36544
+ '\u015E': 'S',
36545
+ '\u2C7E': 'S',
36546
+ '\uA7A8': 'S',
36547
+ '\uA784': 'S',
36548
+ '\u24C9': 'T',
36549
+ '\uFF34': 'T',
36550
+ '\u1E6A': 'T',
36551
+ '\u0164': 'T',
36552
+ '\u1E6C': 'T',
36553
+ '\u021A': 'T',
36554
+ '\u0162': 'T',
36555
+ '\u1E70': 'T',
36556
+ '\u1E6E': 'T',
36557
+ '\u0166': 'T',
36558
+ '\u01AC': 'T',
36559
+ '\u01AE': 'T',
36560
+ '\u023E': 'T',
36561
+ '\uA786': 'T',
36562
+ '\uA728': 'TZ',
36563
+ '\u24CA': 'U',
36564
+ '\uFF35': 'U',
36565
+ '\u00D9': 'U',
36566
+ '\u00DA': 'U',
36567
+ '\u00DB': 'U',
36568
+ '\u0168': 'U',
36569
+ '\u1E78': 'U',
36570
+ '\u016A': 'U',
36571
+ '\u1E7A': 'U',
36572
+ '\u016C': 'U',
36573
+ '\u00DC': 'U',
36574
+ '\u01DB': 'U',
36575
+ '\u01D7': 'U',
36576
+ '\u01D5': 'U',
36577
+ '\u01D9': 'U',
36578
+ '\u1EE6': 'U',
36579
+ '\u016E': 'U',
36580
+ '\u0170': 'U',
36581
+ '\u01D3': 'U',
36582
+ '\u0214': 'U',
36583
+ '\u0216': 'U',
36584
+ '\u01AF': 'U',
36585
+ '\u1EEA': 'U',
36586
+ '\u1EE8': 'U',
36587
+ '\u1EEE': 'U',
36588
+ '\u1EEC': 'U',
36589
+ '\u1EF0': 'U',
36590
+ '\u1EE4': 'U',
36591
+ '\u1E72': 'U',
36592
+ '\u0172': 'U',
36593
+ '\u1E76': 'U',
36594
+ '\u1E74': 'U',
36595
+ '\u0244': 'U',
36596
+ '\u24CB': 'V',
36597
+ '\uFF36': 'V',
36598
+ '\u1E7C': 'V',
36599
+ '\u1E7E': 'V',
36600
+ '\u01B2': 'V',
36601
+ '\uA75E': 'V',
36602
+ '\u0245': 'V',
36603
+ '\uA760': 'VY',
36604
+ '\u24CC': 'W',
36605
+ '\uFF37': 'W',
36606
+ '\u1E80': 'W',
36607
+ '\u1E82': 'W',
36608
+ '\u0174': 'W',
36609
+ '\u1E86': 'W',
36610
+ '\u1E84': 'W',
36611
+ '\u1E88': 'W',
36612
+ '\u2C72': 'W',
36613
+ '\u24CD': 'X',
36614
+ '\uFF38': 'X',
36615
+ '\u1E8A': 'X',
36616
+ '\u1E8C': 'X',
36617
+ '\u24CE': 'Y',
36618
+ '\uFF39': 'Y',
36619
+ '\u1EF2': 'Y',
36620
+ '\u00DD': 'Y',
36621
+ '\u0176': 'Y',
36622
+ '\u1EF8': 'Y',
36623
+ '\u0232': 'Y',
36624
+ '\u1E8E': 'Y',
36625
+ '\u0178': 'Y',
36626
+ '\u1EF6': 'Y',
36627
+ '\u1EF4': 'Y',
36628
+ '\u01B3': 'Y',
36629
+ '\u024E': 'Y',
36630
+ '\u1EFE': 'Y',
36631
+ '\u24CF': 'Z',
36632
+ '\uFF3A': 'Z',
36633
+ '\u0179': 'Z',
36634
+ '\u1E90': 'Z',
36635
+ '\u017B': 'Z',
36636
+ '\u017D': 'Z',
36637
+ '\u1E92': 'Z',
36638
+ '\u1E94': 'Z',
36639
+ '\u01B5': 'Z',
36640
+ '\u0224': 'Z',
36641
+ '\u2C7F': 'Z',
36642
+ '\u2C6B': 'Z',
36643
+ '\uA762': 'Z',
36644
+ '\u24D0': 'a',
36645
+ '\uFF41': 'a',
36646
+ '\u1E9A': 'a',
36647
+ '\u00E0': 'a',
36648
+ '\u00E1': 'a',
36649
+ '\u00E2': 'a',
36650
+ '\u1EA7': 'a',
36651
+ '\u1EA5': 'a',
36652
+ '\u1EAB': 'a',
36653
+ '\u1EA9': 'a',
36654
+ '\u00E3': 'a',
36655
+ '\u0101': 'a',
36656
+ '\u0103': 'a',
36657
+ '\u1EB1': 'a',
36658
+ '\u1EAF': 'a',
36659
+ '\u1EB5': 'a',
36660
+ '\u1EB3': 'a',
36661
+ '\u0227': 'a',
36662
+ '\u01E1': 'a',
36663
+ '\u00E4': 'a',
36664
+ '\u01DF': 'a',
36665
+ '\u1EA3': 'a',
36666
+ '\u00E5': 'a',
36667
+ '\u01FB': 'a',
36668
+ '\u01CE': 'a',
36669
+ '\u0201': 'a',
36670
+ '\u0203': 'a',
36671
+ '\u1EA1': 'a',
36672
+ '\u1EAD': 'a',
36673
+ '\u1EB7': 'a',
36674
+ '\u1E01': 'a',
36675
+ '\u0105': 'a',
36676
+ '\u2C65': 'a',
36677
+ '\u0250': 'a',
36678
+ '\uA733': 'aa',
36679
+ '\u00E6': 'ae',
36680
+ '\u01FD': 'ae',
36681
+ '\u01E3': 'ae',
36682
+ '\uA735': 'ao',
36683
+ '\uA737': 'au',
36684
+ '\uA739': 'av',
36685
+ '\uA73B': 'av',
36686
+ '\uA73D': 'ay',
36687
+ '\u24D1': 'b',
36688
+ '\uFF42': 'b',
36689
+ '\u1E03': 'b',
36690
+ '\u1E05': 'b',
36691
+ '\u1E07': 'b',
36692
+ '\u0180': 'b',
36693
+ '\u0183': 'b',
36694
+ '\u0253': 'b',
36695
+ '\u24D2': 'c',
36696
+ '\uFF43': 'c',
36697
+ '\u0107': 'c',
36698
+ '\u0109': 'c',
36699
+ '\u010B': 'c',
36700
+ '\u010D': 'c',
36701
+ '\u00E7': 'c',
36702
+ '\u1E09': 'c',
36703
+ '\u0188': 'c',
36704
+ '\u023C': 'c',
36705
+ '\uA73F': 'c',
36706
+ '\u2184': 'c',
36707
+ '\u24D3': 'd',
36708
+ '\uFF44': 'd',
36709
+ '\u1E0B': 'd',
36710
+ '\u010F': 'd',
36711
+ '\u1E0D': 'd',
36712
+ '\u1E11': 'd',
36713
+ '\u1E13': 'd',
36714
+ '\u1E0F': 'd',
36715
+ '\u0111': 'd',
36716
+ '\u018C': 'd',
36717
+ '\u0256': 'd',
36718
+ '\u0257': 'd',
36719
+ '\uA77A': 'd',
36720
+ '\u01F3': 'dz',
36721
+ '\u01C6': 'dz',
36722
+ '\u24D4': 'e',
36723
+ '\uFF45': 'e',
36724
+ '\u00E8': 'e',
36725
+ '\u00E9': 'e',
36726
+ '\u00EA': 'e',
36727
+ '\u1EC1': 'e',
36728
+ '\u1EBF': 'e',
36729
+ '\u1EC5': 'e',
36730
+ '\u1EC3': 'e',
36731
+ '\u1EBD': 'e',
36732
+ '\u0113': 'e',
36733
+ '\u1E15': 'e',
36734
+ '\u1E17': 'e',
36735
+ '\u0115': 'e',
36736
+ '\u0117': 'e',
36737
+ '\u00EB': 'e',
36738
+ '\u1EBB': 'e',
36739
+ '\u011B': 'e',
36740
+ '\u0205': 'e',
36741
+ '\u0207': 'e',
36742
+ '\u1EB9': 'e',
36743
+ '\u1EC7': 'e',
36744
+ '\u0229': 'e',
36745
+ '\u1E1D': 'e',
36746
+ '\u0119': 'e',
36747
+ '\u1E19': 'e',
36748
+ '\u1E1B': 'e',
36749
+ '\u0247': 'e',
36750
+ '\u025B': 'e',
36751
+ '\u01DD': 'e',
36752
+ '\u24D5': 'f',
36753
+ '\uFF46': 'f',
36754
+ '\u1E1F': 'f',
36755
+ '\u0192': 'f',
36756
+ '\uA77C': 'f',
36757
+ '\u24D6': 'g',
36758
+ '\uFF47': 'g',
36759
+ '\u01F5': 'g',
36760
+ '\u011D': 'g',
36761
+ '\u1E21': 'g',
36762
+ '\u011F': 'g',
36763
+ '\u0121': 'g',
36764
+ '\u01E7': 'g',
36765
+ '\u0123': 'g',
36766
+ '\u01E5': 'g',
36767
+ '\u0260': 'g',
36768
+ '\uA7A1': 'g',
36769
+ '\u1D79': 'g',
36770
+ '\uA77F': 'g',
36771
+ '\u24D7': 'h',
36772
+ '\uFF48': 'h',
36773
+ '\u0125': 'h',
36774
+ '\u1E23': 'h',
36775
+ '\u1E27': 'h',
36776
+ '\u021F': 'h',
36777
+ '\u1E25': 'h',
36778
+ '\u1E29': 'h',
36779
+ '\u1E2B': 'h',
36780
+ '\u1E96': 'h',
36781
+ '\u0127': 'h',
36782
+ '\u2C68': 'h',
36783
+ '\u2C76': 'h',
36784
+ '\u0265': 'h',
36785
+ '\u0195': 'hv',
36786
+ '\u24D8': 'i',
36787
+ '\uFF49': 'i',
36788
+ '\u00EC': 'i',
36789
+ '\u00ED': 'i',
36790
+ '\u00EE': 'i',
36791
+ '\u0129': 'i',
36792
+ '\u012B': 'i',
36793
+ '\u012D': 'i',
36794
+ '\u00EF': 'i',
36795
+ '\u1E2F': 'i',
36796
+ '\u1EC9': 'i',
36797
+ '\u01D0': 'i',
36798
+ '\u0209': 'i',
36799
+ '\u020B': 'i',
36800
+ '\u1ECB': 'i',
36801
+ '\u012F': 'i',
36802
+ '\u1E2D': 'i',
36803
+ '\u0268': 'i',
36804
+ '\u0131': 'i',
36805
+ '\u24D9': 'j',
36806
+ '\uFF4A': 'j',
36807
+ '\u0135': 'j',
36808
+ '\u01F0': 'j',
36809
+ '\u0249': 'j',
36810
+ '\u24DA': 'k',
36811
+ '\uFF4B': 'k',
36812
+ '\u1E31': 'k',
36813
+ '\u01E9': 'k',
36814
+ '\u1E33': 'k',
36815
+ '\u0137': 'k',
36816
+ '\u1E35': 'k',
36817
+ '\u0199': 'k',
36818
+ '\u2C6A': 'k',
36819
+ '\uA741': 'k',
36820
+ '\uA743': 'k',
36821
+ '\uA745': 'k',
36822
+ '\uA7A3': 'k',
36823
+ '\u24DB': 'l',
36824
+ '\uFF4C': 'l',
36825
+ '\u0140': 'l',
36826
+ '\u013A': 'l',
36827
+ '\u013E': 'l',
36828
+ '\u1E37': 'l',
36829
+ '\u1E39': 'l',
36830
+ '\u013C': 'l',
36831
+ '\u1E3D': 'l',
36832
+ '\u1E3B': 'l',
36833
+ '\u017F': 'l',
36834
+ '\u0142': 'l',
36835
+ '\u019A': 'l',
36836
+ '\u026B': 'l',
36837
+ '\u2C61': 'l',
36838
+ '\uA749': 'l',
36839
+ '\uA781': 'l',
36840
+ '\uA747': 'l',
36841
+ '\u01C9': 'lj',
36842
+ '\u24DC': 'm',
36843
+ '\uFF4D': 'm',
36844
+ '\u1E3F': 'm',
36845
+ '\u1E41': 'm',
36846
+ '\u1E43': 'm',
36847
+ '\u0271': 'm',
36848
+ '\u026F': 'm',
36849
+ '\u24DD': 'n',
36850
+ '\uFF4E': 'n',
36851
+ '\u01F9': 'n',
36852
+ '\u0144': 'n',
36853
+ '\u00F1': 'n',
36854
+ '\u1E45': 'n',
36855
+ '\u0148': 'n',
36856
+ '\u1E47': 'n',
36857
+ '\u0146': 'n',
36858
+ '\u1E4B': 'n',
36859
+ '\u1E49': 'n',
36860
+ '\u019E': 'n',
36861
+ '\u0272': 'n',
36862
+ '\u0149': 'n',
36863
+ '\uA791': 'n',
36864
+ '\uA7A5': 'n',
36865
+ '\u01CC': 'nj',
36866
+ '\u24DE': 'o',
36867
+ '\uFF4F': 'o',
36868
+ '\u00F2': 'o',
36869
+ '\u00F3': 'o',
36870
+ '\u00F4': 'o',
36871
+ '\u1ED3': 'o',
36872
+ '\u1ED1': 'o',
36873
+ '\u1ED7': 'o',
36874
+ '\u1ED5': 'o',
36875
+ '\u00F5': 'o',
36876
+ '\u1E4D': 'o',
36877
+ '\u022D': 'o',
36878
+ '\u1E4F': 'o',
36879
+ '\u014D': 'o',
36880
+ '\u1E51': 'o',
36881
+ '\u1E53': 'o',
36882
+ '\u014F': 'o',
36883
+ '\u022F': 'o',
36884
+ '\u0231': 'o',
36885
+ '\u00F6': 'o',
36886
+ '\u022B': 'o',
36887
+ '\u1ECF': 'o',
36888
+ '\u0151': 'o',
36889
+ '\u01D2': 'o',
36890
+ '\u020D': 'o',
36891
+ '\u020F': 'o',
36892
+ '\u01A1': 'o',
36893
+ '\u1EDD': 'o',
36894
+ '\u1EDB': 'o',
36895
+ '\u1EE1': 'o',
36896
+ '\u1EDF': 'o',
36897
+ '\u1EE3': 'o',
36898
+ '\u1ECD': 'o',
36899
+ '\u1ED9': 'o',
36900
+ '\u01EB': 'o',
36901
+ '\u01ED': 'o',
36902
+ '\u00F8': 'o',
36903
+ '\u01FF': 'o',
36904
+ '\u0254': 'o',
36905
+ '\uA74B': 'o',
36906
+ '\uA74D': 'o',
36907
+ '\u0275': 'o',
36908
+ '\u01A3': 'oi',
36909
+ '\u0223': 'ou',
36910
+ '\uA74F': 'oo',
36911
+ '\u24DF': 'p',
36912
+ '\uFF50': 'p',
36913
+ '\u1E55': 'p',
36914
+ '\u1E57': 'p',
36915
+ '\u01A5': 'p',
36916
+ '\u1D7D': 'p',
36917
+ '\uA751': 'p',
36918
+ '\uA753': 'p',
36919
+ '\uA755': 'p',
36920
+ '\u24E0': 'q',
36921
+ '\uFF51': 'q',
36922
+ '\u024B': 'q',
36923
+ '\uA757': 'q',
36924
+ '\uA759': 'q',
36925
+ '\u24E1': 'r',
36926
+ '\uFF52': 'r',
36927
+ '\u0155': 'r',
36928
+ '\u1E59': 'r',
36929
+ '\u0159': 'r',
36930
+ '\u0211': 'r',
36931
+ '\u0213': 'r',
36932
+ '\u1E5B': 'r',
36933
+ '\u1E5D': 'r',
36934
+ '\u0157': 'r',
36935
+ '\u1E5F': 'r',
36936
+ '\u024D': 'r',
36937
+ '\u027D': 'r',
36938
+ '\uA75B': 'r',
36939
+ '\uA7A7': 'r',
36940
+ '\uA783': 'r',
36941
+ '\u24E2': 's',
36942
+ '\uFF53': 's',
36943
+ '\u00DF': 's',
36944
+ '\u015B': 's',
36945
+ '\u1E65': 's',
36946
+ '\u015D': 's',
36947
+ '\u1E61': 's',
36948
+ '\u0161': 's',
36949
+ '\u1E67': 's',
36950
+ '\u1E63': 's',
36951
+ '\u1E69': 's',
36952
+ '\u0219': 's',
36953
+ '\u015F': 's',
36954
+ '\u023F': 's',
36955
+ '\uA7A9': 's',
36956
+ '\uA785': 's',
36957
+ '\u1E9B': 's',
36958
+ '\u24E3': 't',
36959
+ '\uFF54': 't',
36960
+ '\u1E6B': 't',
36961
+ '\u1E97': 't',
36962
+ '\u0165': 't',
36963
+ '\u1E6D': 't',
36964
+ '\u021B': 't',
36965
+ '\u0163': 't',
36966
+ '\u1E71': 't',
36967
+ '\u1E6F': 't',
36968
+ '\u0167': 't',
36969
+ '\u01AD': 't',
36970
+ '\u0288': 't',
36971
+ '\u2C66': 't',
36972
+ '\uA787': 't',
36973
+ '\uA729': 'tz',
36974
+ '\u24E4': 'u',
36975
+ '\uFF55': 'u',
36976
+ '\u00F9': 'u',
36977
+ '\u00FA': 'u',
36978
+ '\u00FB': 'u',
36979
+ '\u0169': 'u',
36980
+ '\u1E79': 'u',
36981
+ '\u016B': 'u',
36982
+ '\u1E7B': 'u',
36983
+ '\u016D': 'u',
36984
+ '\u00FC': 'u',
36985
+ '\u01DC': 'u',
36986
+ '\u01D8': 'u',
36987
+ '\u01D6': 'u',
36988
+ '\u01DA': 'u',
36989
+ '\u1EE7': 'u',
36990
+ '\u016F': 'u',
36991
+ '\u0171': 'u',
36992
+ '\u01D4': 'u',
36993
+ '\u0215': 'u',
36994
+ '\u0217': 'u',
36995
+ '\u01B0': 'u',
36996
+ '\u1EEB': 'u',
36997
+ '\u1EE9': 'u',
36998
+ '\u1EEF': 'u',
36999
+ '\u1EED': 'u',
37000
+ '\u1EF1': 'u',
37001
+ '\u1EE5': 'u',
37002
+ '\u1E73': 'u',
37003
+ '\u0173': 'u',
37004
+ '\u1E77': 'u',
37005
+ '\u1E75': 'u',
37006
+ '\u0289': 'u',
37007
+ '\u24E5': 'v',
37008
+ '\uFF56': 'v',
37009
+ '\u1E7D': 'v',
37010
+ '\u1E7F': 'v',
37011
+ '\u028B': 'v',
37012
+ '\uA75F': 'v',
37013
+ '\u028C': 'v',
37014
+ '\uA761': 'vy',
37015
+ '\u24E6': 'w',
37016
+ '\uFF57': 'w',
37017
+ '\u1E81': 'w',
37018
+ '\u1E83': 'w',
37019
+ '\u0175': 'w',
37020
+ '\u1E87': 'w',
37021
+ '\u1E85': 'w',
37022
+ '\u1E98': 'w',
37023
+ '\u1E89': 'w',
37024
+ '\u2C73': 'w',
37025
+ '\u24E7': 'x',
37026
+ '\uFF58': 'x',
37027
+ '\u1E8B': 'x',
37028
+ '\u1E8D': 'x',
37029
+ '\u24E8': 'y',
37030
+ '\uFF59': 'y',
37031
+ '\u1EF3': 'y',
37032
+ '\u00FD': 'y',
37033
+ '\u0177': 'y',
37034
+ '\u1EF9': 'y',
37035
+ '\u0233': 'y',
37036
+ '\u1E8F': 'y',
37037
+ '\u00FF': 'y',
37038
+ '\u1EF7': 'y',
37039
+ '\u1E99': 'y',
37040
+ '\u1EF5': 'y',
37041
+ '\u01B4': 'y',
37042
+ '\u024F': 'y',
37043
+ '\u1EFF': 'y',
37044
+ '\u24E9': 'z',
37045
+ '\uFF5A': 'z',
37046
+ '\u017A': 'z',
37047
+ '\u1E91': 'z',
37048
+ '\u017C': 'z',
37049
+ '\u017E': 'z',
37050
+ '\u1E93': 'z',
37051
+ '\u1E95': 'z',
37052
+ '\u01B6': 'z',
37053
+ '\u0225': 'z',
37054
+ '\u0240': 'z',
37055
+ '\u2C6C': 'z',
37056
+ '\uA763': 'z',
37057
+ '\u0386': '\u0391',
37058
+ '\u0388': '\u0395',
37059
+ '\u0389': '\u0397',
37060
+ '\u038A': '\u0399',
37061
+ '\u03AA': '\u0399',
37062
+ '\u038C': '\u039F',
37063
+ '\u038E': '\u03A5',
37064
+ '\u03AB': '\u03A5',
37065
+ '\u038F': '\u03A9',
37066
+ '\u03AC': '\u03B1',
37067
+ '\u03AD': '\u03B5',
37068
+ '\u03AE': '\u03B7',
37069
+ '\u03AF': '\u03B9',
37070
+ '\u03CA': '\u03B9',
37071
+ '\u0390': '\u03B9',
37072
+ '\u03CC': '\u03BF',
37073
+ '\u03CD': '\u03C5',
37074
+ '\u03CB': '\u03C5',
37075
+ '\u03B0': '\u03C5',
37076
+ '\u03C9': '\u03C9',
37077
+ '\u03C2': '\u03C3'
37078
+ };
37079
+
37080
+ return diacritics;
37081
+ });
37082
+
37083
+ S2.define('select2/data/base',[
37084
+ '../utils'
37085
+ ], function (Utils) {
37086
+ function BaseAdapter ($element, options) {
37087
+ BaseAdapter.__super__.constructor.call(this);
37088
+ }
37089
+
37090
+ Utils.Extend(BaseAdapter, Utils.Observable);
37091
+
37092
+ BaseAdapter.prototype.current = function (callback) {
37093
+ throw new Error('The `current` method must be defined in child classes.');
37094
+ };
37095
+
37096
+ BaseAdapter.prototype.query = function (params, callback) {
37097
+ throw new Error('The `query` method must be defined in child classes.');
37098
+ };
37099
+
37100
+ BaseAdapter.prototype.bind = function (container, $container) {
37101
+ // Can be implemented in subclasses
37102
+ };
37103
+
37104
+ BaseAdapter.prototype.destroy = function () {
37105
+ // Can be implemented in subclasses
37106
+ };
37107
+
37108
+ BaseAdapter.prototype.generateResultId = function (container, data) {
37109
+ var id = container.id + '-result-';
37110
+
37111
+ id += Utils.generateChars(4);
37112
+
37113
+ if (data.id != null) {
37114
+ id += '-' + data.id.toString();
37115
+ } else {
37116
+ id += '-' + Utils.generateChars(4);
37117
+ }
37118
+ return id;
37119
+ };
37120
+
37121
+ return BaseAdapter;
37122
+ });
37123
+
37124
+ S2.define('select2/data/select',[
37125
+ './base',
37126
+ '../utils',
37127
+ 'jquery'
37128
+ ], function (BaseAdapter, Utils, $) {
37129
+ function SelectAdapter ($element, options) {
37130
+ this.$element = $element;
37131
+ this.options = options;
37132
+
37133
+ SelectAdapter.__super__.constructor.call(this);
37134
+ }
37135
+
37136
+ Utils.Extend(SelectAdapter, BaseAdapter);
37137
+
37138
+ SelectAdapter.prototype.current = function (callback) {
37139
+ var data = [];
37140
+ var self = this;
37141
+
37142
+ this.$element.find(':selected').each(function () {
37143
+ var $option = $(this);
37144
+
37145
+ var option = self.item($option);
37146
+
37147
+ data.push(option);
37148
+ });
37149
+
37150
+ callback(data);
37151
+ };
37152
+
37153
+ SelectAdapter.prototype.select = function (data) {
37154
+ var self = this;
37155
+
37156
+ data.selected = true;
37157
+
37158
+ // If data.element is a DOM node, use it instead
37159
+ if ($(data.element).is('option')) {
37160
+ data.element.selected = true;
37161
+
37162
+ this.$element.trigger('change');
37163
+
37164
+ return;
37165
+ }
37166
+
37167
+ if (this.$element.prop('multiple')) {
37168
+ this.current(function (currentData) {
37169
+ var val = [];
37170
+
37171
+ data = [data];
37172
+ data.push.apply(data, currentData);
37173
+
37174
+ for (var d = 0; d < data.length; d++) {
37175
+ var id = data[d].id;
37176
+
37177
+ if ($.inArray(id, val) === -1) {
37178
+ val.push(id);
37179
+ }
37180
+ }
37181
+
37182
+ self.$element.val(val);
37183
+ self.$element.trigger('change');
37184
+ });
37185
+ } else {
37186
+ var val = data.id;
37187
+
37188
+ this.$element.val(val);
37189
+ this.$element.trigger('change');
37190
+ }
37191
+ };
37192
+
37193
+ SelectAdapter.prototype.unselect = function (data) {
37194
+ var self = this;
37195
+
37196
+ if (!this.$element.prop('multiple')) {
37197
+ return;
37198
+ }
37199
+
37200
+ data.selected = false;
37201
+
37202
+ if ($(data.element).is('option')) {
37203
+ data.element.selected = false;
37204
+
37205
+ this.$element.trigger('change');
37206
+
37207
+ return;
37208
+ }
37209
+
37210
+ this.current(function (currentData) {
37211
+ var val = [];
37212
+
37213
+ for (var d = 0; d < currentData.length; d++) {
37214
+ var id = currentData[d].id;
37215
+
37216
+ if (id !== data.id && $.inArray(id, val) === -1) {
37217
+ val.push(id);
37218
+ }
37219
+ }
37220
+
37221
+ self.$element.val(val);
37222
+
37223
+ self.$element.trigger('change');
37224
+ });
37225
+ };
37226
+
37227
+ SelectAdapter.prototype.bind = function (container, $container) {
37228
+ var self = this;
37229
+
37230
+ this.container = container;
37231
+
37232
+ container.on('select', function (params) {
37233
+ self.select(params.data);
37234
+ });
37235
+
37236
+ container.on('unselect', function (params) {
37237
+ self.unselect(params.data);
37238
+ });
37239
+ };
37240
+
37241
+ SelectAdapter.prototype.destroy = function () {
37242
+ // Remove anything added to child elements
37243
+ this.$element.find('*').each(function () {
37244
+ // Remove any custom data set by Select2
37245
+ $.removeData(this, 'data');
37246
+ });
37247
+ };
37248
+
37249
+ SelectAdapter.prototype.query = function (params, callback) {
37250
+ var data = [];
37251
+ var self = this;
37252
+
37253
+ var $options = this.$element.children();
37254
+
37255
+ $options.each(function () {
37256
+ var $option = $(this);
37257
+
37258
+ if (!$option.is('option') && !$option.is('optgroup')) {
37259
+ return;
37260
+ }
37261
+
37262
+ var option = self.item($option);
37263
+
37264
+ var matches = self.matches(params, option);
37265
+
37266
+ if (matches !== null) {
37267
+ data.push(matches);
37268
+ }
37269
+ });
37270
+
37271
+ callback({
37272
+ results: data
37273
+ });
37274
+ };
37275
+
37276
+ SelectAdapter.prototype.addOptions = function ($options) {
37277
+ Utils.appendMany(this.$element, $options);
37278
+ };
37279
+
37280
+ SelectAdapter.prototype.option = function (data) {
37281
+ var option;
37282
+
37283
+ if (data.children) {
37284
+ option = document.createElement('optgroup');
37285
+ option.label = data.text;
37286
+ } else {
37287
+ option = document.createElement('option');
37288
+
37289
+ if (option.textContent !== undefined) {
37290
+ option.textContent = data.text;
37291
+ } else {
37292
+ option.innerText = data.text;
37293
+ }
37294
+ }
37295
+
37296
+ if (data.id !== undefined) {
37297
+ option.value = data.id;
37298
+ }
37299
+
37300
+ if (data.disabled) {
37301
+ option.disabled = true;
37302
+ }
37303
+
37304
+ if (data.selected) {
37305
+ option.selected = true;
37306
+ }
37307
+
37308
+ if (data.title) {
37309
+ option.title = data.title;
37310
+ }
37311
+
37312
+ var $option = $(option);
37313
+
37314
+ var normalizedData = this._normalizeItem(data);
37315
+ normalizedData.element = option;
37316
+
37317
+ // Override the option's data with the combined data
37318
+ $.data(option, 'data', normalizedData);
37319
+
37320
+ return $option;
37321
+ };
37322
+
37323
+ SelectAdapter.prototype.item = function ($option) {
37324
+ var data = {};
37325
+
37326
+ data = $.data($option[0], 'data');
37327
+
37328
+ if (data != null) {
37329
+ return data;
37330
+ }
37331
+
37332
+ if ($option.is('option')) {
37333
+ data = {
37334
+ id: $option.val(),
37335
+ text: $option.text(),
37336
+ disabled: $option.prop('disabled'),
37337
+ selected: $option.prop('selected'),
37338
+ title: $option.prop('title')
37339
+ };
37340
+ } else if ($option.is('optgroup')) {
37341
+ data = {
37342
+ text: $option.prop('label'),
37343
+ children: [],
37344
+ title: $option.prop('title')
37345
+ };
37346
+
37347
+ var $children = $option.children('option');
37348
+ var children = [];
37349
+
37350
+ for (var c = 0; c < $children.length; c++) {
37351
+ var $child = $($children[c]);
37352
+
37353
+ var child = this.item($child);
37354
+
37355
+ children.push(child);
37356
+ }
37357
+
37358
+ data.children = children;
37359
+ }
37360
+
37361
+ data = this._normalizeItem(data);
37362
+ data.element = $option[0];
37363
+
37364
+ $.data($option[0], 'data', data);
37365
+
37366
+ return data;
37367
+ };
37368
+
37369
+ SelectAdapter.prototype._normalizeItem = function (item) {
37370
+ if (!$.isPlainObject(item)) {
37371
+ item = {
37372
+ id: item,
37373
+ text: item
37374
+ };
37375
+ }
37376
+
37377
+ item = $.extend({}, {
37378
+ text: ''
37379
+ }, item);
37380
+
37381
+ var defaults = {
37382
+ selected: false,
37383
+ disabled: false
37384
+ };
37385
+
37386
+ if (item.id != null) {
37387
+ item.id = item.id.toString();
37388
+ }
37389
+
37390
+ if (item.text != null) {
37391
+ item.text = item.text.toString();
37392
+ }
37393
+
37394
+ if (item._resultId == null && item.id && this.container != null) {
37395
+ item._resultId = this.generateResultId(this.container, item);
37396
+ }
37397
+
37398
+ return $.extend({}, defaults, item);
37399
+ };
37400
+
37401
+ SelectAdapter.prototype.matches = function (params, data) {
37402
+ var matcher = this.options.get('matcher');
37403
+
37404
+ return matcher(params, data);
37405
+ };
37406
+
37407
+ return SelectAdapter;
37408
+ });
37409
+
37410
+ S2.define('select2/data/array',[
37411
+ './select',
37412
+ '../utils',
37413
+ 'jquery'
37414
+ ], function (SelectAdapter, Utils, $) {
37415
+ function ArrayAdapter ($element, options) {
37416
+ var data = options.get('data') || [];
37417
+
37418
+ ArrayAdapter.__super__.constructor.call(this, $element, options);
37419
+
37420
+ this.addOptions(this.convertToOptions(data));
37421
+ }
37422
+
37423
+ Utils.Extend(ArrayAdapter, SelectAdapter);
37424
+
37425
+ ArrayAdapter.prototype.select = function (data) {
37426
+ var $option = this.$element.find('option').filter(function (i, elm) {
37427
+ return elm.value == data.id.toString();
37428
+ });
37429
+
37430
+ if ($option.length === 0) {
37431
+ $option = this.option(data);
37432
+
37433
+ this.addOptions($option);
37434
+ }
37435
+
37436
+ ArrayAdapter.__super__.select.call(this, data);
37437
+ };
37438
+
37439
+ ArrayAdapter.prototype.convertToOptions = function (data) {
37440
+ var self = this;
37441
+
37442
+ var $existing = this.$element.find('option');
37443
+ var existingIds = $existing.map(function () {
37444
+ return self.item($(this)).id;
37445
+ }).get();
37446
+
37447
+ var $options = [];
37448
+
37449
+ // Filter out all items except for the one passed in the argument
37450
+ function onlyItem (item) {
37451
+ return function () {
37452
+ return $(this).val() == item.id;
37453
+ };
37454
+ }
37455
+
37456
+ for (var d = 0; d < data.length; d++) {
37457
+ var item = this._normalizeItem(data[d]);
37458
+
37459
+ // Skip items which were pre-loaded, only merge the data
37460
+ if ($.inArray(item.id, existingIds) >= 0) {
37461
+ var $existingOption = $existing.filter(onlyItem(item));
37462
+
37463
+ var existingData = this.item($existingOption);
37464
+ var newData = $.extend(true, {}, item, existingData);
37465
+
37466
+ var $newOption = this.option(newData);
37467
+
37468
+ $existingOption.replaceWith($newOption);
37469
+
37470
+ continue;
37471
+ }
37472
+
37473
+ var $option = this.option(item);
37474
+
37475
+ if (item.children) {
37476
+ var $children = this.convertToOptions(item.children);
37477
+
37478
+ Utils.appendMany($option, $children);
37479
+ }
37480
+
37481
+ $options.push($option);
37482
+ }
37483
+
37484
+ return $options;
37485
+ };
37486
+
37487
+ return ArrayAdapter;
37488
+ });
37489
+
37490
+ S2.define('select2/data/ajax',[
37491
+ './array',
37492
+ '../utils',
37493
+ 'jquery'
37494
+ ], function (ArrayAdapter, Utils, $) {
37495
+ function AjaxAdapter ($element, options) {
37496
+ this.ajaxOptions = this._applyDefaults(options.get('ajax'));
37497
+
37498
+ if (this.ajaxOptions.processResults != null) {
37499
+ this.processResults = this.ajaxOptions.processResults;
37500
+ }
37501
+
37502
+ AjaxAdapter.__super__.constructor.call(this, $element, options);
37503
+ }
37504
+
37505
+ Utils.Extend(AjaxAdapter, ArrayAdapter);
37506
+
37507
+ AjaxAdapter.prototype._applyDefaults = function (options) {
37508
+ var defaults = {
37509
+ data: function (params) {
37510
+ return $.extend({}, params, {
37511
+ q: params.term
37512
+ });
37513
+ },
37514
+ transport: function (params, success, failure) {
37515
+ var $request = $.ajax(params);
37516
+
37517
+ $request.then(success);
37518
+ $request.fail(failure);
37519
+
37520
+ return $request;
37521
+ }
37522
+ };
37523
+
37524
+ return $.extend({}, defaults, options, true);
37525
+ };
37526
+
37527
+ AjaxAdapter.prototype.processResults = function (results) {
37528
+ return results;
37529
+ };
37530
+
37531
+ AjaxAdapter.prototype.query = function (params, callback) {
37532
+ var matches = [];
37533
+ var self = this;
37534
+
37535
+ if (this._request != null) {
37536
+ // JSONP requests cannot always be aborted
37537
+ if ($.isFunction(this._request.abort)) {
37538
+ this._request.abort();
37539
+ }
37540
+
37541
+ this._request = null;
37542
+ }
37543
+
37544
+ var options = $.extend({
37545
+ type: 'GET'
37546
+ }, this.ajaxOptions);
37547
+
37548
+ if (typeof options.url === 'function') {
37549
+ options.url = options.url.call(this.$element, params);
37550
+ }
37551
+
37552
+ if (typeof options.data === 'function') {
37553
+ options.data = options.data.call(this.$element, params);
37554
+ }
37555
+
37556
+ function request () {
37557
+ var $request = options.transport(options, function (data) {
37558
+ var results = self.processResults(data, params);
37559
+
37560
+ if (self.options.get('debug') && window.console && console.error) {
37561
+ // Check to make sure that the response included a `results` key.
37562
+ if (!results || !results.results || !$.isArray(results.results)) {
37563
+ console.error(
37564
+ 'Select2: The AJAX results did not return an array in the ' +
37565
+ '`results` key of the response.'
37566
+ );
37567
+ }
37568
+ }
37569
+
37570
+ callback(results);
37571
+ }, function () {
37572
+ // Attempt to detect if a request was aborted
37573
+ // Only works if the transport exposes a status property
37574
+ if ($request.status && $request.status === '0') {
37575
+ return;
37576
+ }
37577
+
37578
+ self.trigger('results:message', {
37579
+ message: 'errorLoading'
37580
+ });
37581
+ });
37582
+
37583
+ self._request = $request;
37584
+ }
37585
+
37586
+ if (this.ajaxOptions.delay && params.term != null) {
37587
+ if (this._queryTimeout) {
37588
+ window.clearTimeout(this._queryTimeout);
37589
+ }
37590
+
37591
+ this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
37592
+ } else {
37593
+ request();
37594
+ }
37595
+ };
37596
+
37597
+ return AjaxAdapter;
37598
+ });
37599
+
37600
+ S2.define('select2/data/tags',[
37601
+ 'jquery'
37602
+ ], function ($) {
37603
+ function Tags (decorated, $element, options) {
37604
+ var tags = options.get('tags');
37605
+
37606
+ var createTag = options.get('createTag');
37607
+
37608
+ if (createTag !== undefined) {
37609
+ this.createTag = createTag;
37610
+ }
37611
+
37612
+ var insertTag = options.get('insertTag');
37613
+
37614
+ if (insertTag !== undefined) {
37615
+ this.insertTag = insertTag;
37616
+ }
37617
+
37618
+ decorated.call(this, $element, options);
37619
+
37620
+ if ($.isArray(tags)) {
37621
+ for (var t = 0; t < tags.length; t++) {
37622
+ var tag = tags[t];
37623
+ var item = this._normalizeItem(tag);
37624
+
37625
+ var $option = this.option(item);
37626
+
37627
+ this.$element.append($option);
37628
+ }
37629
+ }
37630
+ }
37631
+
37632
+ Tags.prototype.query = function (decorated, params, callback) {
37633
+ var self = this;
37634
+
37635
+ this._removeOldTags();
37636
+
37637
+ if (params.term == null || params.page != null) {
37638
+ decorated.call(this, params, callback);
37639
+ return;
37640
+ }
37641
+
37642
+ function wrapper (obj, child) {
37643
+ var data = obj.results;
37644
+
37645
+ for (var i = 0; i < data.length; i++) {
37646
+ var option = data[i];
37647
+
37648
+ var checkChildren = (
37649
+ option.children != null &&
37650
+ !wrapper({
37651
+ results: option.children
37652
+ }, true)
37653
+ );
37654
+
37655
+ var optionText = (option.text || '').toUpperCase();
37656
+ var paramsTerm = (params.term || '').toUpperCase();
37657
+
37658
+ var checkText = optionText === paramsTerm;
37659
+
37660
+ if (checkText || checkChildren) {
37661
+ if (child) {
37662
+ return false;
37663
+ }
37664
+
37665
+ obj.data = data;
37666
+ callback(obj);
37667
+
37668
+ return;
37669
+ }
37670
+ }
37671
+
37672
+ if (child) {
37673
+ return true;
37674
+ }
37675
+
37676
+ var tag = self.createTag(params);
37677
+
37678
+ if (tag != null) {
37679
+ var $option = self.option(tag);
37680
+ $option.attr('data-select2-tag', true);
37681
+
37682
+ self.addOptions([$option]);
37683
+
37684
+ self.insertTag(data, tag);
37685
+ }
37686
+
37687
+ obj.results = data;
37688
+
37689
+ callback(obj);
37690
+ }
37691
+
37692
+ decorated.call(this, params, wrapper);
37693
+ };
37694
+
37695
+ Tags.prototype.createTag = function (decorated, params) {
37696
+ var term = $.trim(params.term);
37697
+
37698
+ if (term === '') {
37699
+ return null;
37700
+ }
37701
+
37702
+ return {
37703
+ id: term,
37704
+ text: term
37705
+ };
37706
+ };
37707
+
37708
+ Tags.prototype.insertTag = function (_, data, tag) {
37709
+ data.unshift(tag);
37710
+ };
37711
+
37712
+ Tags.prototype._removeOldTags = function (_) {
37713
+ var tag = this._lastTag;
37714
+
37715
+ var $options = this.$element.find('option[data-select2-tag]');
37716
+
37717
+ $options.each(function () {
37718
+ if (this.selected) {
37719
+ return;
37720
+ }
37721
+
37722
+ $(this).remove();
37723
+ });
37724
+ };
37725
+
37726
+ return Tags;
37727
+ });
37728
+
37729
+ S2.define('select2/data/tokenizer',[
37730
+ 'jquery'
37731
+ ], function ($) {
37732
+ function Tokenizer (decorated, $element, options) {
37733
+ var tokenizer = options.get('tokenizer');
37734
+
37735
+ if (tokenizer !== undefined) {
37736
+ this.tokenizer = tokenizer;
37737
+ }
37738
+
37739
+ decorated.call(this, $element, options);
37740
+ }
37741
+
37742
+ Tokenizer.prototype.bind = function (decorated, container, $container) {
37743
+ decorated.call(this, container, $container);
37744
+
37745
+ this.$search = container.dropdown.$search || container.selection.$search ||
37746
+ $container.find('.select2-search__field');
37747
+ };
37748
+
37749
+ Tokenizer.prototype.query = function (decorated, params, callback) {
37750
+ var self = this;
37751
+
37752
+ function createAndSelect (data) {
37753
+ // Normalize the data object so we can use it for checks
37754
+ var item = self._normalizeItem(data);
37755
+
37756
+ // Check if the data object already exists as a tag
37757
+ // Select it if it doesn't
37758
+ var $existingOptions = self.$element.find('option').filter(function () {
37759
+ return $(this).val() === item.id;
37760
+ });
37761
+
37762
+ // If an existing option wasn't found for it, create the option
37763
+ if (!$existingOptions.length) {
37764
+ var $option = self.option(item);
37765
+ $option.attr('data-select2-tag', true);
37766
+
37767
+ self._removeOldTags();
37768
+ self.addOptions([$option]);
37769
+ }
37770
+
37771
+ // Select the item, now that we know there is an option for it
37772
+ select(item);
37773
+ }
37774
+
37775
+ function select (data) {
37776
+ self.trigger('select', {
37777
+ data: data
37778
+ });
37779
+ }
37780
+
37781
+ params.term = params.term || '';
37782
+
37783
+ var tokenData = this.tokenizer(params, this.options, createAndSelect);
37784
+
37785
+ if (tokenData.term !== params.term) {
37786
+ // Replace the search term if we have the search box
37787
+ if (this.$search.length) {
37788
+ this.$search.val(tokenData.term);
37789
+ this.$search.focus();
37790
+ }
37791
+
37792
+ params.term = tokenData.term;
37793
+ }
37794
+
37795
+ decorated.call(this, params, callback);
37796
+ };
37797
+
37798
+ Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
37799
+ var separators = options.get('tokenSeparators') || [];
37800
+ var term = params.term;
37801
+ var i = 0;
37802
+
37803
+ var createTag = this.createTag || function (params) {
37804
+ return {
37805
+ id: params.term,
37806
+ text: params.term
37807
+ };
37808
+ };
37809
+
37810
+ while (i < term.length) {
37811
+ var termChar = term[i];
37812
+
37813
+ if ($.inArray(termChar, separators) === -1) {
37814
+ i++;
37815
+
37816
+ continue;
37817
+ }
37818
+
37819
+ var part = term.substr(0, i);
37820
+ var partParams = $.extend({}, params, {
37821
+ term: part
37822
+ });
37823
+
37824
+ var data = createTag(partParams);
37825
+
37826
+ if (data == null) {
37827
+ i++;
37828
+ continue;
37829
+ }
37830
+
37831
+ callback(data);
37832
+
37833
+ // Reset the term to not include the tokenized portion
37834
+ term = term.substr(i + 1) || '';
37835
+ i = 0;
37836
+ }
37837
+
37838
+ return {
37839
+ term: term
37840
+ };
37841
+ };
37842
+
37843
+ return Tokenizer;
37844
+ });
37845
+
37846
+ S2.define('select2/data/minimumInputLength',[
37847
+
37848
+ ], function () {
37849
+ function MinimumInputLength (decorated, $e, options) {
37850
+ this.minimumInputLength = options.get('minimumInputLength');
37851
+
37852
+ decorated.call(this, $e, options);
37853
+ }
37854
+
37855
+ MinimumInputLength.prototype.query = function (decorated, params, callback) {
37856
+ params.term = params.term || '';
37857
+
37858
+ if (params.term.length < this.minimumInputLength) {
37859
+ this.trigger('results:message', {
37860
+ message: 'inputTooShort',
37861
+ args: {
37862
+ minimum: this.minimumInputLength,
37863
+ input: params.term,
37864
+ params: params
37865
+ }
37866
+ });
37867
+
37868
+ return;
37869
+ }
37870
+
37871
+ decorated.call(this, params, callback);
37872
+ };
37873
+
37874
+ return MinimumInputLength;
37875
+ });
37876
+
37877
+ S2.define('select2/data/maximumInputLength',[
37878
+
37879
+ ], function () {
37880
+ function MaximumInputLength (decorated, $e, options) {
37881
+ this.maximumInputLength = options.get('maximumInputLength');
37882
+
37883
+ decorated.call(this, $e, options);
37884
+ }
37885
+
37886
+ MaximumInputLength.prototype.query = function (decorated, params, callback) {
37887
+ params.term = params.term || '';
37888
+
37889
+ if (this.maximumInputLength > 0 &&
37890
+ params.term.length > this.maximumInputLength) {
37891
+ this.trigger('results:message', {
37892
+ message: 'inputTooLong',
37893
+ args: {
37894
+ maximum: this.maximumInputLength,
37895
+ input: params.term,
37896
+ params: params
37897
+ }
37898
+ });
37899
+
37900
+ return;
37901
+ }
37902
+
37903
+ decorated.call(this, params, callback);
37904
+ };
37905
+
37906
+ return MaximumInputLength;
37907
+ });
37908
+
37909
+ S2.define('select2/data/maximumSelectionLength',[
37910
+
37911
+ ], function (){
37912
+ function MaximumSelectionLength (decorated, $e, options) {
37913
+ this.maximumSelectionLength = options.get('maximumSelectionLength');
37914
+
37915
+ decorated.call(this, $e, options);
37916
+ }
37917
+
37918
+ MaximumSelectionLength.prototype.query =
37919
+ function (decorated, params, callback) {
37920
+ var self = this;
37921
+
37922
+ this.current(function (currentData) {
37923
+ var count = currentData != null ? currentData.length : 0;
37924
+ if (self.maximumSelectionLength > 0 &&
37925
+ count >= self.maximumSelectionLength) {
37926
+ self.trigger('results:message', {
37927
+ message: 'maximumSelected',
37928
+ args: {
37929
+ maximum: self.maximumSelectionLength
37930
+ }
37931
+ });
37932
+ return;
37933
+ }
37934
+ decorated.call(self, params, callback);
37935
+ });
37936
+ };
37937
+
37938
+ return MaximumSelectionLength;
37939
+ });
37940
+
37941
+ S2.define('select2/dropdown',[
37942
+ 'jquery',
37943
+ './utils'
37944
+ ], function ($, Utils) {
37945
+ function Dropdown ($element, options) {
37946
+ this.$element = $element;
37947
+ this.options = options;
37948
+
37949
+ Dropdown.__super__.constructor.call(this);
37950
+ }
37951
+
37952
+ Utils.Extend(Dropdown, Utils.Observable);
37953
+
37954
+ Dropdown.prototype.render = function () {
37955
+ var $dropdown = $(
37956
+ '<span class="select2-dropdown">' +
37957
+ '<span class="select2-results"></span>' +
37958
+ '</span>'
37959
+ );
37960
+
37961
+ $dropdown.attr('dir', this.options.get('dir'));
37962
+
37963
+ this.$dropdown = $dropdown;
37964
+
37965
+ return $dropdown;
37966
+ };
37967
+
37968
+ Dropdown.prototype.bind = function () {
37969
+ // Should be implemented in subclasses
37970
+ };
37971
+
37972
+ Dropdown.prototype.position = function ($dropdown, $container) {
37973
+ // Should be implmented in subclasses
37974
+ };
37975
+
37976
+ Dropdown.prototype.destroy = function () {
37977
+ // Remove the dropdown from the DOM
37978
+ this.$dropdown.remove();
37979
+ };
37980
+
37981
+ return Dropdown;
37982
+ });
37983
+
37984
+ S2.define('select2/dropdown/search',[
37985
+ 'jquery',
37986
+ '../utils'
37987
+ ], function ($, Utils) {
37988
+ function Search () { }
37989
+
37990
+ Search.prototype.render = function (decorated) {
37991
+ var $rendered = decorated.call(this);
37992
+
37993
+ var $search = $(
37994
+ '<span class="select2-search select2-search--dropdown">' +
37995
+ '<input class="select2-search__field" type="search" tabindex="-1"' +
37996
+ ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
37997
+ ' spellcheck="false" role="textbox" />' +
37998
+ '</span>'
37999
+ );
38000
+
38001
+ this.$searchContainer = $search;
38002
+ this.$search = $search.find('input');
38003
+
38004
+ $rendered.prepend($search);
38005
+
38006
+ return $rendered;
38007
+ };
38008
+
38009
+ Search.prototype.bind = function (decorated, container, $container) {
38010
+ var self = this;
38011
+
38012
+ decorated.call(this, container, $container);
38013
+
38014
+ this.$search.on('keydown', function (evt) {
38015
+ self.trigger('keypress', evt);
38016
+
38017
+ self._keyUpPrevented = evt.isDefaultPrevented();
38018
+ });
38019
+
38020
+ // Workaround for browsers which do not support the `input` event
38021
+ // This will prevent double-triggering of events for browsers which support
38022
+ // both the `keyup` and `input` events.
38023
+ this.$search.on('input', function (evt) {
38024
+ // Unbind the duplicated `keyup` event
38025
+ $(this).off('keyup');
38026
+ });
38027
+
38028
+ this.$search.on('keyup input', function (evt) {
38029
+ self.handleSearch(evt);
38030
+ });
38031
+
38032
+ container.on('open', function () {
38033
+ self.$search.attr('tabindex', 0);
38034
+
38035
+ self.$search.focus();
38036
+
38037
+ window.setTimeout(function () {
38038
+ self.$search.focus();
38039
+ }, 0);
38040
+ });
38041
+
38042
+ container.on('close', function () {
38043
+ self.$search.attr('tabindex', -1);
38044
+
38045
+ self.$search.val('');
38046
+ });
38047
+
38048
+ container.on('focus', function () {
38049
+ if (!container.isOpen()) {
38050
+ self.$search.focus();
38051
+ }
38052
+ });
38053
+
38054
+ container.on('results:all', function (params) {
38055
+ if (params.query.term == null || params.query.term === '') {
38056
+ var showSearch = self.showSearch(params);
38057
+
38058
+ if (showSearch) {
38059
+ self.$searchContainer.removeClass('select2-search--hide');
38060
+ } else {
38061
+ self.$searchContainer.addClass('select2-search--hide');
38062
+ }
38063
+ }
38064
+ });
38065
+ };
38066
+
38067
+ Search.prototype.handleSearch = function (evt) {
38068
+ if (!this._keyUpPrevented) {
38069
+ var input = this.$search.val();
38070
+
38071
+ this.trigger('query', {
38072
+ term: input
38073
+ });
38074
+ }
38075
+
38076
+ this._keyUpPrevented = false;
38077
+ };
38078
+
38079
+ Search.prototype.showSearch = function (_, params) {
38080
+ return true;
38081
+ };
38082
+
38083
+ return Search;
38084
+ });
38085
+
38086
+ S2.define('select2/dropdown/hidePlaceholder',[
38087
+
38088
+ ], function () {
38089
+ function HidePlaceholder (decorated, $element, options, dataAdapter) {
38090
+ this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
38091
+
38092
+ decorated.call(this, $element, options, dataAdapter);
38093
+ }
38094
+
38095
+ HidePlaceholder.prototype.append = function (decorated, data) {
38096
+ data.results = this.removePlaceholder(data.results);
38097
+
38098
+ decorated.call(this, data);
38099
+ };
38100
+
38101
+ HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
38102
+ if (typeof placeholder === 'string') {
38103
+ placeholder = {
38104
+ id: '',
38105
+ text: placeholder
38106
+ };
38107
+ }
38108
+
38109
+ return placeholder;
38110
+ };
38111
+
38112
+ HidePlaceholder.prototype.removePlaceholder = function (_, data) {
38113
+ var modifiedData = data.slice(0);
38114
+
38115
+ for (var d = data.length - 1; d >= 0; d--) {
38116
+ var item = data[d];
38117
+
38118
+ if (this.placeholder.id === item.id) {
38119
+ modifiedData.splice(d, 1);
38120
+ }
38121
+ }
38122
+
38123
+ return modifiedData;
38124
+ };
38125
+
38126
+ return HidePlaceholder;
38127
+ });
38128
+
38129
+ S2.define('select2/dropdown/infiniteScroll',[
38130
+ 'jquery'
38131
+ ], function ($) {
38132
+ function InfiniteScroll (decorated, $element, options, dataAdapter) {
38133
+ this.lastParams = {};
38134
+
38135
+ decorated.call(this, $element, options, dataAdapter);
38136
+
38137
+ this.$loadingMore = this.createLoadingMore();
38138
+ this.loading = false;
38139
+ }
38140
+
38141
+ InfiniteScroll.prototype.append = function (decorated, data) {
38142
+ this.$loadingMore.remove();
38143
+ this.loading = false;
38144
+
38145
+ decorated.call(this, data);
38146
+
38147
+ if (this.showLoadingMore(data)) {
38148
+ this.$results.append(this.$loadingMore);
38149
+ }
38150
+ };
38151
+
38152
+ InfiniteScroll.prototype.bind = function (decorated, container, $container) {
38153
+ var self = this;
38154
+
38155
+ decorated.call(this, container, $container);
38156
+
38157
+ container.on('query', function (params) {
38158
+ self.lastParams = params;
38159
+ self.loading = true;
38160
+ });
38161
+
38162
+ container.on('query:append', function (params) {
38163
+ self.lastParams = params;
38164
+ self.loading = true;
38165
+ });
38166
+
38167
+ this.$results.on('scroll', function () {
38168
+ var isLoadMoreVisible = $.contains(
38169
+ document.documentElement,
38170
+ self.$loadingMore[0]
38171
+ );
38172
+
38173
+ if (self.loading || !isLoadMoreVisible) {
38174
+ return;
38175
+ }
38176
+
38177
+ var currentOffset = self.$results.offset().top +
38178
+ self.$results.outerHeight(false);
38179
+ var loadingMoreOffset = self.$loadingMore.offset().top +
38180
+ self.$loadingMore.outerHeight(false);
38181
+
38182
+ if (currentOffset + 50 >= loadingMoreOffset) {
38183
+ self.loadMore();
38184
+ }
38185
+ });
38186
+ };
38187
+
38188
+ InfiniteScroll.prototype.loadMore = function () {
38189
+ this.loading = true;
38190
+
38191
+ var params = $.extend({}, {page: 1}, this.lastParams);
38192
+
38193
+ params.page++;
38194
+
38195
+ this.trigger('query:append', params);
38196
+ };
38197
+
38198
+ InfiniteScroll.prototype.showLoadingMore = function (_, data) {
38199
+ return data.pagination && data.pagination.more;
38200
+ };
38201
+
38202
+ InfiniteScroll.prototype.createLoadingMore = function () {
38203
+ var $option = $(
38204
+ '<li ' +
38205
+ 'class="select2-results__option select2-results__option--load-more"' +
38206
+ 'role="treeitem" aria-disabled="true"></li>'
38207
+ );
38208
+
38209
+ var message = this.options.get('translations').get('loadingMore');
38210
+
38211
+ $option.html(message(this.lastParams));
38212
+
38213
+ return $option;
38214
+ };
38215
+
38216
+ return InfiniteScroll;
38217
+ });
38218
+
38219
+ S2.define('select2/dropdown/attachBody',[
38220
+ 'jquery',
38221
+ '../utils'
38222
+ ], function ($, Utils) {
38223
+ function AttachBody (decorated, $element, options) {
38224
+ this.$dropdownParent = options.get('dropdownParent') || $(document.body);
38225
+
38226
+ decorated.call(this, $element, options);
38227
+ }
38228
+
38229
+ AttachBody.prototype.bind = function (decorated, container, $container) {
38230
+ var self = this;
38231
+
38232
+ var setupResultsEvents = false;
38233
+
38234
+ decorated.call(this, container, $container);
38235
+
38236
+ container.on('open', function () {
38237
+ self._showDropdown();
38238
+ self._attachPositioningHandler(container);
38239
+
38240
+ if (!setupResultsEvents) {
38241
+ setupResultsEvents = true;
38242
+
38243
+ container.on('results:all', function () {
38244
+ self._positionDropdown();
38245
+ self._resizeDropdown();
38246
+ });
38247
+
38248
+ container.on('results:append', function () {
38249
+ self._positionDropdown();
38250
+ self._resizeDropdown();
38251
+ });
38252
+ }
38253
+ });
38254
+
38255
+ container.on('close', function () {
38256
+ self._hideDropdown();
38257
+ self._detachPositioningHandler(container);
38258
+ });
38259
+
38260
+ this.$dropdownContainer.on('mousedown', function (evt) {
38261
+ evt.stopPropagation();
38262
+ });
38263
+ };
38264
+
38265
+ AttachBody.prototype.destroy = function (decorated) {
38266
+ decorated.call(this);
38267
+
38268
+ this.$dropdownContainer.remove();
38269
+ };
38270
+
38271
+ AttachBody.prototype.position = function (decorated, $dropdown, $container) {
38272
+ // Clone all of the container classes
38273
+ $dropdown.attr('class', $container.attr('class'));
38274
+
38275
+ $dropdown.removeClass('select2');
38276
+ $dropdown.addClass('select2-container--open');
38277
+
38278
+ $dropdown.css({
38279
+ position: 'absolute',
38280
+ top: -999999
38281
+ });
38282
+
38283
+ this.$container = $container;
38284
+ };
38285
+
38286
+ AttachBody.prototype.render = function (decorated) {
38287
+ var $container = $('<span></span>');
38288
+
38289
+ var $dropdown = decorated.call(this);
38290
+ $container.append($dropdown);
38291
+
38292
+ this.$dropdownContainer = $container;
38293
+
38294
+ return $container;
38295
+ };
38296
+
38297
+ AttachBody.prototype._hideDropdown = function (decorated) {
38298
+ this.$dropdownContainer.detach();
38299
+ };
38300
+
38301
+ AttachBody.prototype._attachPositioningHandler =
38302
+ function (decorated, container) {
38303
+ var self = this;
38304
+
38305
+ var scrollEvent = 'scroll.select2.' + container.id;
38306
+ var resizeEvent = 'resize.select2.' + container.id;
38307
+ var orientationEvent = 'orientationchange.select2.' + container.id;
38308
+
38309
+ var $watchers = this.$container.parents().filter(Utils.hasScroll);
38310
+ $watchers.each(function () {
38311
+ $(this).data('select2-scroll-position', {
38312
+ x: $(this).scrollLeft(),
38313
+ y: $(this).scrollTop()
38314
+ });
38315
+ });
38316
+
38317
+ $watchers.on(scrollEvent, function (ev) {
38318
+ var position = $(this).data('select2-scroll-position');
38319
+ $(this).scrollTop(position.y);
38320
+ });
38321
+
38322
+ $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
38323
+ function (e) {
38324
+ self._positionDropdown();
38325
+ self._resizeDropdown();
38326
+ });
38327
+ };
38328
+
38329
+ AttachBody.prototype._detachPositioningHandler =
38330
+ function (decorated, container) {
38331
+ var scrollEvent = 'scroll.select2.' + container.id;
38332
+ var resizeEvent = 'resize.select2.' + container.id;
38333
+ var orientationEvent = 'orientationchange.select2.' + container.id;
38334
+
38335
+ var $watchers = this.$container.parents().filter(Utils.hasScroll);
38336
+ $watchers.off(scrollEvent);
38337
+
38338
+ $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
38339
+ };
38340
+
38341
+ AttachBody.prototype._positionDropdown = function () {
38342
+ var $window = $(window);
38343
+
38344
+ var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
38345
+ var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
38346
+
38347
+ var newDirection = null;
38348
+
38349
+ var offset = this.$container.offset();
38350
+
38351
+ offset.bottom = offset.top + this.$container.outerHeight(false);
38352
+
38353
+ var container = {
38354
+ height: this.$container.outerHeight(false)
38355
+ };
38356
+
38357
+ container.top = offset.top;
38358
+ container.bottom = offset.top + container.height;
38359
+
38360
+ var dropdown = {
38361
+ height: this.$dropdown.outerHeight(false)
38362
+ };
38363
+
38364
+ var viewport = {
38365
+ top: $window.scrollTop(),
38366
+ bottom: $window.scrollTop() + $window.height()
38367
+ };
38368
+
38369
+ var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
38370
+ var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
38371
+
38372
+ var css = {
38373
+ left: offset.left,
38374
+ top: container.bottom
38375
+ };
38376
+
38377
+ // Determine what the parent element is to use for calciulating the offset
38378
+ var $offsetParent = this.$dropdownParent;
38379
+
38380
+ // For statically positoned elements, we need to get the element
38381
+ // that is determining the offset
38382
+ if ($offsetParent.css('position') === 'static') {
38383
+ $offsetParent = $offsetParent.offsetParent();
38384
+ }
38385
+
38386
+ var parentOffset = $offsetParent.offset();
38387
+
38388
+ css.top -= parentOffset.top;
38389
+ css.left -= parentOffset.left;
38390
+
38391
+ if (!isCurrentlyAbove && !isCurrentlyBelow) {
38392
+ newDirection = 'below';
38393
+ }
38394
+
38395
+ if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
38396
+ newDirection = 'above';
38397
+ } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
38398
+ newDirection = 'below';
38399
+ }
38400
+
38401
+ if (newDirection == 'above' ||
38402
+ (isCurrentlyAbove && newDirection !== 'below')) {
38403
+ css.top = container.top - parentOffset.top - dropdown.height;
38404
+ }
38405
+
38406
+ if (newDirection != null) {
38407
+ this.$dropdown
38408
+ .removeClass('select2-dropdown--below select2-dropdown--above')
38409
+ .addClass('select2-dropdown--' + newDirection);
38410
+ this.$container
38411
+ .removeClass('select2-container--below select2-container--above')
38412
+ .addClass('select2-container--' + newDirection);
38413
+ }
38414
+
38415
+ this.$dropdownContainer.css(css);
38416
+ };
38417
+
38418
+ AttachBody.prototype._resizeDropdown = function () {
38419
+ var css = {
38420
+ width: this.$container.outerWidth(false) + 'px'
38421
+ };
38422
+
38423
+ if (this.options.get('dropdownAutoWidth')) {
38424
+ css.minWidth = css.width;
38425
+ css.position = 'relative';
38426
+ css.width = 'auto';
38427
+ }
38428
+
38429
+ this.$dropdown.css(css);
38430
+ };
38431
+
38432
+ AttachBody.prototype._showDropdown = function (decorated) {
38433
+ this.$dropdownContainer.appendTo(this.$dropdownParent);
38434
+
38435
+ this._positionDropdown();
38436
+ this._resizeDropdown();
38437
+ };
38438
+
38439
+ return AttachBody;
38440
+ });
38441
+
38442
+ S2.define('select2/dropdown/minimumResultsForSearch',[
38443
+
38444
+ ], function () {
38445
+ function countResults (data) {
38446
+ var count = 0;
38447
+
38448
+ for (var d = 0; d < data.length; d++) {
38449
+ var item = data[d];
38450
+
38451
+ if (item.children) {
38452
+ count += countResults(item.children);
38453
+ } else {
38454
+ count++;
38455
+ }
38456
+ }
38457
+
38458
+ return count;
38459
+ }
38460
+
38461
+ function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
38462
+ this.minimumResultsForSearch = options.get('minimumResultsForSearch');
38463
+
38464
+ if (this.minimumResultsForSearch < 0) {
38465
+ this.minimumResultsForSearch = Infinity;
38466
+ }
38467
+
38468
+ decorated.call(this, $element, options, dataAdapter);
38469
+ }
38470
+
38471
+ MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
38472
+ if (countResults(params.data.results) < this.minimumResultsForSearch) {
38473
+ return false;
38474
+ }
38475
+
38476
+ return decorated.call(this, params);
38477
+ };
38478
+
38479
+ return MinimumResultsForSearch;
38480
+ });
38481
+
38482
+ S2.define('select2/dropdown/selectOnClose',[
38483
+
38484
+ ], function () {
38485
+ function SelectOnClose () { }
38486
+
38487
+ SelectOnClose.prototype.bind = function (decorated, container, $container) {
38488
+ var self = this;
38489
+
38490
+ decorated.call(this, container, $container);
38491
+
38492
+ container.on('close', function (params) {
38493
+ self._handleSelectOnClose(params);
38494
+ });
38495
+ };
38496
+
38497
+ SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
38498
+ if (params && params.originalSelect2Event != null) {
38499
+ var event = params.originalSelect2Event;
38500
+
38501
+ // Don't select an item if the close event was triggered from a select or
38502
+ // unselect event
38503
+ if (event._type === 'select' || event._type === 'unselect') {
38504
+ return;
38505
+ }
38506
+ }
38507
+
38508
+ var $highlightedResults = this.getHighlightedResults();
38509
+
38510
+ // Only select highlighted results
38511
+ if ($highlightedResults.length < 1) {
38512
+ return;
38513
+ }
38514
+
38515
+ var data = $highlightedResults.data('data');
38516
+
38517
+ // Don't re-select already selected resulte
38518
+ if (
38519
+ (data.element != null && data.element.selected) ||
38520
+ (data.element == null && data.selected)
38521
+ ) {
38522
+ return;
38523
+ }
38524
+
38525
+ this.trigger('select', {
38526
+ data: data
38527
+ });
38528
+ };
38529
+
38530
+ return SelectOnClose;
38531
+ });
38532
+
38533
+ S2.define('select2/dropdown/closeOnSelect',[
38534
+
38535
+ ], function () {
38536
+ function CloseOnSelect () { }
38537
+
38538
+ CloseOnSelect.prototype.bind = function (decorated, container, $container) {
38539
+ var self = this;
38540
+
38541
+ decorated.call(this, container, $container);
38542
+
38543
+ container.on('select', function (evt) {
38544
+ self._selectTriggered(evt);
38545
+ });
38546
+
38547
+ container.on('unselect', function (evt) {
38548
+ self._selectTriggered(evt);
38549
+ });
38550
+ };
38551
+
38552
+ CloseOnSelect.prototype._selectTriggered = function (_, evt) {
38553
+ var originalEvent = evt.originalEvent;
38554
+
38555
+ // Don't close if the control key is being held
38556
+ if (originalEvent && originalEvent.ctrlKey) {
38557
+ return;
38558
+ }
38559
+
38560
+ this.trigger('close', {
38561
+ originalEvent: originalEvent,
38562
+ originalSelect2Event: evt
38563
+ });
38564
+ };
38565
+
38566
+ return CloseOnSelect;
38567
+ });
38568
+
38569
+ S2.define('select2/i18n/en',[],function () {
38570
+ // English
38571
+ return {
38572
+ errorLoading: function () {
38573
+ return 'The results could not be loaded.';
38574
+ },
38575
+ inputTooLong: function (args) {
38576
+ var overChars = args.input.length - args.maximum;
38577
+
38578
+ var message = 'Please delete ' + overChars + ' character';
38579
+
38580
+ if (overChars != 1) {
38581
+ message += 's';
38582
+ }
38583
+
38584
+ return message;
38585
+ },
38586
+ inputTooShort: function (args) {
38587
+ var remainingChars = args.minimum - args.input.length;
38588
+
38589
+ var message = 'Please enter ' + remainingChars + ' or more characters';
38590
+
38591
+ return message;
38592
+ },
38593
+ loadingMore: function () {
38594
+ return 'Loading more results…';
38595
+ },
38596
+ maximumSelected: function (args) {
38597
+ var message = 'You can only select ' + args.maximum + ' item';
38598
+
38599
+ if (args.maximum != 1) {
38600
+ message += 's';
38601
+ }
38602
+
38603
+ return message;
38604
+ },
38605
+ noResults: function () {
38606
+ return 'No results found';
38607
+ },
38608
+ searching: function () {
38609
+ return 'Searching…';
38610
+ }
38611
+ };
38612
+ });
38613
+
38614
+ S2.define('select2/defaults',[
38615
+ 'jquery',
38616
+ 'require',
38617
+
38618
+ './results',
38619
+
38620
+ './selection/single',
38621
+ './selection/multiple',
38622
+ './selection/placeholder',
38623
+ './selection/allowClear',
38624
+ './selection/search',
38625
+ './selection/eventRelay',
38626
+
38627
+ './utils',
38628
+ './translation',
38629
+ './diacritics',
38630
+
38631
+ './data/select',
38632
+ './data/array',
38633
+ './data/ajax',
38634
+ './data/tags',
38635
+ './data/tokenizer',
38636
+ './data/minimumInputLength',
38637
+ './data/maximumInputLength',
38638
+ './data/maximumSelectionLength',
38639
+
38640
+ './dropdown',
38641
+ './dropdown/search',
38642
+ './dropdown/hidePlaceholder',
38643
+ './dropdown/infiniteScroll',
38644
+ './dropdown/attachBody',
38645
+ './dropdown/minimumResultsForSearch',
38646
+ './dropdown/selectOnClose',
38647
+ './dropdown/closeOnSelect',
38648
+
38649
+ './i18n/en'
38650
+ ], function ($, require,
38651
+
38652
+ ResultsList,
38653
+
38654
+ SingleSelection, MultipleSelection, Placeholder, AllowClear,
38655
+ SelectionSearch, EventRelay,
38656
+
38657
+ Utils, Translation, DIACRITICS,
38658
+
38659
+ SelectData, ArrayData, AjaxData, Tags, Tokenizer,
38660
+ MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
38661
+
38662
+ Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
38663
+ AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
38664
+
38665
+ EnglishTranslation) {
38666
+ function Defaults () {
38667
+ this.reset();
38668
+ }
38669
+
38670
+ Defaults.prototype.apply = function (options) {
38671
+ options = $.extend(true, {}, this.defaults, options);
38672
+
38673
+ if (options.dataAdapter == null) {
38674
+ if (options.ajax != null) {
38675
+ options.dataAdapter = AjaxData;
38676
+ } else if (options.data != null) {
38677
+ options.dataAdapter = ArrayData;
38678
+ } else {
38679
+ options.dataAdapter = SelectData;
38680
+ }
38681
+
38682
+ if (options.minimumInputLength > 0) {
38683
+ options.dataAdapter = Utils.Decorate(
38684
+ options.dataAdapter,
38685
+ MinimumInputLength
38686
+ );
38687
+ }
38688
+
38689
+ if (options.maximumInputLength > 0) {
38690
+ options.dataAdapter = Utils.Decorate(
38691
+ options.dataAdapter,
38692
+ MaximumInputLength
38693
+ );
38694
+ }
38695
+
38696
+ if (options.maximumSelectionLength > 0) {
38697
+ options.dataAdapter = Utils.Decorate(
38698
+ options.dataAdapter,
38699
+ MaximumSelectionLength
38700
+ );
38701
+ }
38702
+
38703
+ if (options.tags) {
38704
+ options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
38705
+ }
38706
+
38707
+ if (options.tokenSeparators != null || options.tokenizer != null) {
38708
+ options.dataAdapter = Utils.Decorate(
38709
+ options.dataAdapter,
38710
+ Tokenizer
38711
+ );
38712
+ }
38713
+
38714
+ if (options.query != null) {
38715
+ var Query = require(options.amdBase + 'compat/query');
38716
+
38717
+ options.dataAdapter = Utils.Decorate(
38718
+ options.dataAdapter,
38719
+ Query
38720
+ );
38721
+ }
38722
+
38723
+ if (options.initSelection != null) {
38724
+ var InitSelection = require(options.amdBase + 'compat/initSelection');
38725
+
38726
+ options.dataAdapter = Utils.Decorate(
38727
+ options.dataAdapter,
38728
+ InitSelection
38729
+ );
38730
+ }
38731
+ }
38732
+
38733
+ if (options.resultsAdapter == null) {
38734
+ options.resultsAdapter = ResultsList;
38735
+
38736
+ if (options.ajax != null) {
38737
+ options.resultsAdapter = Utils.Decorate(
38738
+ options.resultsAdapter,
38739
+ InfiniteScroll
38740
+ );
38741
+ }
38742
+
38743
+ if (options.placeholder != null) {
38744
+ options.resultsAdapter = Utils.Decorate(
38745
+ options.resultsAdapter,
38746
+ HidePlaceholder
38747
+ );
38748
+ }
38749
+
38750
+ if (options.selectOnClose) {
38751
+ options.resultsAdapter = Utils.Decorate(
38752
+ options.resultsAdapter,
38753
+ SelectOnClose
38754
+ );
38755
+ }
38756
+ }
38757
+
38758
+ if (options.dropdownAdapter == null) {
38759
+ if (options.multiple) {
38760
+ options.dropdownAdapter = Dropdown;
38761
+ } else {
38762
+ var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
38763
+
38764
+ options.dropdownAdapter = SearchableDropdown;
38765
+ }
38766
+
38767
+ if (options.minimumResultsForSearch !== 0) {
38768
+ options.dropdownAdapter = Utils.Decorate(
38769
+ options.dropdownAdapter,
38770
+ MinimumResultsForSearch
38771
+ );
38772
+ }
38773
+
38774
+ if (options.closeOnSelect) {
38775
+ options.dropdownAdapter = Utils.Decorate(
38776
+ options.dropdownAdapter,
38777
+ CloseOnSelect
38778
+ );
38779
+ }
38780
+
38781
+ if (
38782
+ options.dropdownCssClass != null ||
38783
+ options.dropdownCss != null ||
38784
+ options.adaptDropdownCssClass != null
38785
+ ) {
38786
+ var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
38787
+
38788
+ options.dropdownAdapter = Utils.Decorate(
38789
+ options.dropdownAdapter,
38790
+ DropdownCSS
38791
+ );
38792
+ }
38793
+
38794
+ options.dropdownAdapter = Utils.Decorate(
38795
+ options.dropdownAdapter,
38796
+ AttachBody
38797
+ );
38798
+ }
38799
+
38800
+ if (options.selectionAdapter == null) {
38801
+ if (options.multiple) {
38802
+ options.selectionAdapter = MultipleSelection;
38803
+ } else {
38804
+ options.selectionAdapter = SingleSelection;
38805
+ }
38806
+
38807
+ // Add the placeholder mixin if a placeholder was specified
38808
+ if (options.placeholder != null) {
38809
+ options.selectionAdapter = Utils.Decorate(
38810
+ options.selectionAdapter,
38811
+ Placeholder
38812
+ );
38813
+ }
38814
+
38815
+ if (options.allowClear) {
38816
+ options.selectionAdapter = Utils.Decorate(
38817
+ options.selectionAdapter,
38818
+ AllowClear
38819
+ );
38820
+ }
38821
+
38822
+ if (options.multiple) {
38823
+ options.selectionAdapter = Utils.Decorate(
38824
+ options.selectionAdapter,
38825
+ SelectionSearch
38826
+ );
38827
+ }
38828
+
38829
+ if (
38830
+ options.containerCssClass != null ||
38831
+ options.containerCss != null ||
38832
+ options.adaptContainerCssClass != null
38833
+ ) {
38834
+ var ContainerCSS = require(options.amdBase + 'compat/containerCss');
38835
+
38836
+ options.selectionAdapter = Utils.Decorate(
38837
+ options.selectionAdapter,
38838
+ ContainerCSS
38839
+ );
38840
+ }
38841
+
38842
+ options.selectionAdapter = Utils.Decorate(
38843
+ options.selectionAdapter,
38844
+ EventRelay
38845
+ );
38846
+ }
38847
+
38848
+ if (typeof options.language === 'string') {
38849
+ // Check if the language is specified with a region
38850
+ if (options.language.indexOf('-') > 0) {
38851
+ // Extract the region information if it is included
38852
+ var languageParts = options.language.split('-');
38853
+ var baseLanguage = languageParts[0];
38854
+
38855
+ options.language = [options.language, baseLanguage];
38856
+ } else {
38857
+ options.language = [options.language];
38858
+ }
38859
+ }
38860
+
38861
+ if ($.isArray(options.language)) {
38862
+ var languages = new Translation();
38863
+ options.language.push('en');
38864
+
38865
+ var languageNames = options.language;
38866
+
38867
+ for (var l = 0; l < languageNames.length; l++) {
38868
+ var name = languageNames[l];
38869
+ var language = {};
38870
+
38871
+ try {
38872
+ // Try to load it with the original name
38873
+ language = Translation.loadPath(name);
38874
+ } catch (e) {
38875
+ try {
38876
+ // If we couldn't load it, check if it wasn't the full path
38877
+ name = this.defaults.amdLanguageBase + name;
38878
+ language = Translation.loadPath(name);
38879
+ } catch (ex) {
38880
+ // The translation could not be loaded at all. Sometimes this is
38881
+ // because of a configuration problem, other times this can be
38882
+ // because of how Select2 helps load all possible translation files.
38883
+ if (options.debug && window.console && console.warn) {
38884
+ console.warn(
38885
+ 'Select2: The language file for "' + name + '" could not be ' +
38886
+ 'automatically loaded. A fallback will be used instead.'
38887
+ );
38888
+ }
38889
+
38890
+ continue;
38891
+ }
38892
+ }
38893
+
38894
+ languages.extend(language);
38895
+ }
38896
+
38897
+ options.translations = languages;
38898
+ } else {
38899
+ var baseTranslation = Translation.loadPath(
38900
+ this.defaults.amdLanguageBase + 'en'
38901
+ );
38902
+ var customTranslation = new Translation(options.language);
38903
+
38904
+ customTranslation.extend(baseTranslation);
38905
+
38906
+ options.translations = customTranslation;
38907
+ }
38908
+
38909
+ return options;
38910
+ };
38911
+
38912
+ Defaults.prototype.reset = function () {
38913
+ function stripDiacritics (text) {
38914
+ // Used 'uni range + named function' from http://jsperf.com/diacritics/18
38915
+ function match(a) {
38916
+ return DIACRITICS[a] || a;
38917
+ }
38918
+
38919
+ return text.replace(/[^\u0000-\u007E]/g, match);
38920
+ }
38921
+
38922
+ function matcher (params, data) {
38923
+ // Always return the object if there is nothing to compare
38924
+ if ($.trim(params.term) === '') {
38925
+ return data;
38926
+ }
38927
+
38928
+ // Do a recursive check for options with children
38929
+ if (data.children && data.children.length > 0) {
38930
+ // Clone the data object if there are children
38931
+ // This is required as we modify the object to remove any non-matches
38932
+ var match = $.extend(true, {}, data);
38933
+
38934
+ // Check each child of the option
38935
+ for (var c = data.children.length - 1; c >= 0; c--) {
38936
+ var child = data.children[c];
38937
+
38938
+ var matches = matcher(params, child);
38939
+
38940
+ // If there wasn't a match, remove the object in the array
38941
+ if (matches == null) {
38942
+ match.children.splice(c, 1);
38943
+ }
38944
+ }
38945
+
38946
+ // If any children matched, return the new object
38947
+ if (match.children.length > 0) {
38948
+ return match;
38949
+ }
38950
+
38951
+ // If there were no matching children, check just the plain object
38952
+ return matcher(params, match);
38953
+ }
38954
+
38955
+ var original = stripDiacritics(data.text).toUpperCase();
38956
+ var term = stripDiacritics(params.term).toUpperCase();
38957
+
38958
+ // Check if the text contains the term
38959
+ if (original.indexOf(term) > -1) {
38960
+ return data;
38961
+ }
38962
+
38963
+ // If it doesn't contain the term, don't return anything
38964
+ return null;
38965
+ }
38966
+
38967
+ this.defaults = {
38968
+ amdBase: './',
38969
+ amdLanguageBase: './i18n/',
38970
+ closeOnSelect: true,
38971
+ debug: false,
38972
+ dropdownAutoWidth: false,
38973
+ escapeMarkup: Utils.escapeMarkup,
38974
+ language: EnglishTranslation,
38975
+ matcher: matcher,
38976
+ minimumInputLength: 0,
38977
+ maximumInputLength: 0,
38978
+ maximumSelectionLength: 0,
38979
+ minimumResultsForSearch: 0,
38980
+ selectOnClose: false,
38981
+ sorter: function (data) {
38982
+ return data;
38983
+ },
38984
+ templateResult: function (result) {
38985
+ return result.text;
38986
+ },
38987
+ templateSelection: function (selection) {
38988
+ return selection.text;
38989
+ },
38990
+ theme: 'default',
38991
+ width: 'resolve'
38992
+ };
38993
+ };
38994
+
38995
+ Defaults.prototype.set = function (key, value) {
38996
+ var camelKey = $.camelCase(key);
38997
+
38998
+ var data = {};
38999
+ data[camelKey] = value;
39000
+
39001
+ var convertedData = Utils._convertData(data);
39002
+
39003
+ $.extend(this.defaults, convertedData);
39004
+ };
39005
+
39006
+ var defaults = new Defaults();
39007
+
39008
+ return defaults;
39009
+ });
39010
+
39011
+ S2.define('select2/options',[
39012
+ 'require',
39013
+ 'jquery',
39014
+ './defaults',
39015
+ './utils'
39016
+ ], function (require, $, Defaults, Utils) {
39017
+ function Options (options, $element) {
39018
+ this.options = options;
39019
+
39020
+ if ($element != null) {
39021
+ this.fromElement($element);
39022
+ }
39023
+
39024
+ this.options = Defaults.apply(this.options);
39025
+
39026
+ if ($element && $element.is('input')) {
39027
+ var InputCompat = require(this.get('amdBase') + 'compat/inputData');
39028
+
39029
+ this.options.dataAdapter = Utils.Decorate(
39030
+ this.options.dataAdapter,
39031
+ InputCompat
39032
+ );
39033
+ }
39034
+ }
39035
+
39036
+ Options.prototype.fromElement = function ($e) {
39037
+ var excludedData = ['select2'];
39038
+
39039
+ if (this.options.multiple == null) {
39040
+ this.options.multiple = $e.prop('multiple');
39041
+ }
39042
+
39043
+ if (this.options.disabled == null) {
39044
+ this.options.disabled = $e.prop('disabled');
39045
+ }
39046
+
39047
+ if (this.options.language == null) {
39048
+ if ($e.prop('lang')) {
39049
+ this.options.language = $e.prop('lang').toLowerCase();
39050
+ } else if ($e.closest('[lang]').prop('lang')) {
39051
+ this.options.language = $e.closest('[lang]').prop('lang');
39052
+ }
39053
+ }
39054
+
39055
+ if (this.options.dir == null) {
39056
+ if ($e.prop('dir')) {
39057
+ this.options.dir = $e.prop('dir');
39058
+ } else if ($e.closest('[dir]').prop('dir')) {
39059
+ this.options.dir = $e.closest('[dir]').prop('dir');
39060
+ } else {
39061
+ this.options.dir = 'ltr';
39062
+ }
39063
+ }
39064
+
39065
+ $e.prop('disabled', this.options.disabled);
39066
+ $e.prop('multiple', this.options.multiple);
39067
+
39068
+ if ($e.data('select2Tags')) {
39069
+ if (this.options.debug && window.console && console.warn) {
39070
+ console.warn(
39071
+ 'Select2: The `data-select2-tags` attribute has been changed to ' +
39072
+ 'use the `data-data` and `data-tags="true"` attributes and will be ' +
39073
+ 'removed in future versions of Select2.'
39074
+ );
39075
+ }
39076
+
39077
+ $e.data('data', $e.data('select2Tags'));
39078
+ $e.data('tags', true);
39079
+ }
39080
+
39081
+ if ($e.data('ajaxUrl')) {
39082
+ if (this.options.debug && window.console && console.warn) {
39083
+ console.warn(
39084
+ 'Select2: The `data-ajax-url` attribute has been changed to ' +
39085
+ '`data-ajax--url` and support for the old attribute will be removed' +
39086
+ ' in future versions of Select2.'
39087
+ );
39088
+ }
39089
+
39090
+ $e.attr('ajax--url', $e.data('ajaxUrl'));
39091
+ $e.data('ajax--url', $e.data('ajaxUrl'));
39092
+ }
39093
+
39094
+ var dataset = {};
39095
+
39096
+ // Prefer the element's `dataset` attribute if it exists
39097
+ // jQuery 1.x does not correctly handle data attributes with multiple dashes
39098
+ if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
39099
+ dataset = $.extend(true, {}, $e[0].dataset, $e.data());
39100
+ } else {
39101
+ dataset = $e.data();
39102
+ }
39103
+
39104
+ var data = $.extend(true, {}, dataset);
39105
+
39106
+ data = Utils._convertData(data);
39107
+
39108
+ for (var key in data) {
39109
+ if ($.inArray(key, excludedData) > -1) {
39110
+ continue;
39111
+ }
39112
+
39113
+ if ($.isPlainObject(this.options[key])) {
39114
+ $.extend(this.options[key], data[key]);
39115
+ } else {
39116
+ this.options[key] = data[key];
39117
+ }
39118
+ }
39119
+
39120
+ return this;
39121
+ };
39122
+
39123
+ Options.prototype.get = function (key) {
39124
+ return this.options[key];
39125
+ };
39126
+
39127
+ Options.prototype.set = function (key, val) {
39128
+ this.options[key] = val;
39129
+ };
39130
+
39131
+ return Options;
39132
+ });
39133
+
39134
+ S2.define('select2/core',[
39135
+ 'jquery',
39136
+ './options',
39137
+ './utils',
39138
+ './keys'
39139
+ ], function ($, Options, Utils, KEYS) {
39140
+ var Select2 = function ($element, options) {
39141
+ if ($element.data('select2') != null) {
39142
+ $element.data('select2').destroy();
39143
+ }
39144
+
39145
+ this.$element = $element;
39146
+
39147
+ this.id = this._generateId($element);
39148
+
39149
+ options = options || {};
39150
+
39151
+ this.options = new Options(options, $element);
39152
+
39153
+ Select2.__super__.constructor.call(this);
39154
+
39155
+ // Set up the tabindex
39156
+
39157
+ var tabindex = $element.attr('tabindex') || 0;
39158
+ $element.data('old-tabindex', tabindex);
39159
+ $element.attr('tabindex', '-1');
39160
+
39161
+ // Set up containers and adapters
39162
+
39163
+ var DataAdapter = this.options.get('dataAdapter');
39164
+ this.dataAdapter = new DataAdapter($element, this.options);
39165
+
39166
+ var $container = this.render();
39167
+
39168
+ this._placeContainer($container);
39169
+
39170
+ var SelectionAdapter = this.options.get('selectionAdapter');
39171
+ this.selection = new SelectionAdapter($element, this.options);
39172
+ this.$selection = this.selection.render();
39173
+
39174
+ this.selection.position(this.$selection, $container);
39175
+
39176
+ var DropdownAdapter = this.options.get('dropdownAdapter');
39177
+ this.dropdown = new DropdownAdapter($element, this.options);
39178
+ this.$dropdown = this.dropdown.render();
39179
+
39180
+ this.dropdown.position(this.$dropdown, $container);
39181
+
39182
+ var ResultsAdapter = this.options.get('resultsAdapter');
39183
+ this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
39184
+ this.$results = this.results.render();
39185
+
39186
+ this.results.position(this.$results, this.$dropdown);
39187
+
39188
+ // Bind events
39189
+
39190
+ var self = this;
39191
+
39192
+ // Bind the container to all of the adapters
39193
+ this._bindAdapters();
39194
+
39195
+ // Register any DOM event handlers
39196
+ this._registerDomEvents();
39197
+
39198
+ // Register any internal event handlers
39199
+ this._registerDataEvents();
39200
+ this._registerSelectionEvents();
39201
+ this._registerDropdownEvents();
39202
+ this._registerResultsEvents();
39203
+ this._registerEvents();
39204
+
39205
+ // Set the initial state
39206
+ this.dataAdapter.current(function (initialData) {
39207
+ self.trigger('selection:update', {
39208
+ data: initialData
39209
+ });
39210
+ });
39211
+
39212
+ // Hide the original select
39213
+ $element.addClass('select2-hidden-accessible');
39214
+ $element.attr('aria-hidden', 'true');
39215
+
39216
+ // Synchronize any monitored attributes
39217
+ this._syncAttributes();
39218
+
39219
+ $element.data('select2', this);
39220
+ };
39221
+
39222
+ Utils.Extend(Select2, Utils.Observable);
39223
+
39224
+ Select2.prototype._generateId = function ($element) {
39225
+ var id = '';
39226
+
39227
+ if ($element.attr('id') != null) {
39228
+ id = $element.attr('id');
39229
+ } else if ($element.attr('name') != null) {
39230
+ id = $element.attr('name') + '-' + Utils.generateChars(2);
39231
+ } else {
39232
+ id = Utils.generateChars(4);
39233
+ }
39234
+
39235
+ id = id.replace(/(:|\.|\[|\]|,)/g, '');
39236
+ id = 'select2-' + id;
39237
+
39238
+ return id;
39239
+ };
39240
+
39241
+ Select2.prototype._placeContainer = function ($container) {
39242
+ $container.insertAfter(this.$element);
39243
+
39244
+ var width = this._resolveWidth(this.$element, this.options.get('width'));
39245
+
39246
+ if (width != null) {
39247
+ $container.css('width', width);
39248
+ }
39249
+ };
39250
+
39251
+ Select2.prototype._resolveWidth = function ($element, method) {
39252
+ var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
39253
+
39254
+ if (method == 'resolve') {
39255
+ var styleWidth = this._resolveWidth($element, 'style');
39256
+
39257
+ if (styleWidth != null) {
39258
+ return styleWidth;
39259
+ }
39260
+
39261
+ return this._resolveWidth($element, 'element');
39262
+ }
39263
+
39264
+ if (method == 'element') {
39265
+ var elementWidth = $element.outerWidth(false);
39266
+
39267
+ if (elementWidth <= 0) {
39268
+ return 'auto';
39269
+ }
39270
+
39271
+ return elementWidth + 'px';
39272
+ }
39273
+
39274
+ if (method == 'style') {
39275
+ var style = $element.attr('style');
39276
+
39277
+ if (typeof(style) !== 'string') {
39278
+ return null;
39279
+ }
39280
+
39281
+ var attrs = style.split(';');
39282
+
39283
+ for (var i = 0, l = attrs.length; i < l; i = i + 1) {
39284
+ var attr = attrs[i].replace(/\s/g, '');
39285
+ var matches = attr.match(WIDTH);
39286
+
39287
+ if (matches !== null && matches.length >= 1) {
39288
+ return matches[1];
39289
+ }
39290
+ }
39291
+
39292
+ return null;
39293
+ }
39294
+
39295
+ return method;
39296
+ };
39297
+
39298
+ Select2.prototype._bindAdapters = function () {
39299
+ this.dataAdapter.bind(this, this.$container);
39300
+ this.selection.bind(this, this.$container);
39301
+
39302
+ this.dropdown.bind(this, this.$container);
39303
+ this.results.bind(this, this.$container);
39304
+ };
39305
+
39306
+ Select2.prototype._registerDomEvents = function () {
39307
+ var self = this;
39308
+
39309
+ this.$element.on('change.select2', function () {
39310
+ self.dataAdapter.current(function (data) {
39311
+ self.trigger('selection:update', {
39312
+ data: data
39313
+ });
39314
+ });
39315
+ });
39316
+
39317
+ this.$element.on('focus.select2', function (evt) {
39318
+ self.trigger('focus', evt);
39319
+ });
39320
+
39321
+ this._syncA = Utils.bind(this._syncAttributes, this);
39322
+ this._syncS = Utils.bind(this._syncSubtree, this);
39323
+
39324
+ if (this.$element[0].attachEvent) {
39325
+ this.$element[0].attachEvent('onpropertychange', this._syncA);
39326
+ }
39327
+
39328
+ var observer = window.MutationObserver ||
39329
+ window.WebKitMutationObserver ||
39330
+ window.MozMutationObserver
39331
+ ;
39332
+
39333
+ if (observer != null) {
39334
+ this._observer = new observer(function (mutations) {
39335
+ $.each(mutations, self._syncA);
39336
+ $.each(mutations, self._syncS);
39337
+ });
39338
+ this._observer.observe(this.$element[0], {
39339
+ attributes: true,
39340
+ childList: true,
39341
+ subtree: false
39342
+ });
39343
+ } else if (this.$element[0].addEventListener) {
39344
+ this.$element[0].addEventListener(
39345
+ 'DOMAttrModified',
39346
+ self._syncA,
39347
+ false
39348
+ );
39349
+ this.$element[0].addEventListener(
39350
+ 'DOMNodeInserted',
39351
+ self._syncS,
39352
+ false
39353
+ );
39354
+ this.$element[0].addEventListener(
39355
+ 'DOMNodeRemoved',
39356
+ self._syncS,
39357
+ false
39358
+ );
39359
+ }
39360
+ };
39361
+
39362
+ Select2.prototype._registerDataEvents = function () {
39363
+ var self = this;
39364
+
39365
+ this.dataAdapter.on('*', function (name, params) {
39366
+ self.trigger(name, params);
39367
+ });
39368
+ };
39369
+
39370
+ Select2.prototype._registerSelectionEvents = function () {
39371
+ var self = this;
39372
+ var nonRelayEvents = ['toggle', 'focus'];
39373
+
39374
+ this.selection.on('toggle', function () {
39375
+ self.toggleDropdown();
39376
+ });
39377
+
39378
+ this.selection.on('focus', function (params) {
39379
+ self.focus(params);
39380
+ });
39381
+
39382
+ this.selection.on('*', function (name, params) {
39383
+ if ($.inArray(name, nonRelayEvents) !== -1) {
39384
+ return;
39385
+ }
39386
+
39387
+ self.trigger(name, params);
39388
+ });
39389
+ };
39390
+
39391
+ Select2.prototype._registerDropdownEvents = function () {
39392
+ var self = this;
39393
+
39394
+ this.dropdown.on('*', function (name, params) {
39395
+ self.trigger(name, params);
39396
+ });
39397
+ };
39398
+
39399
+ Select2.prototype._registerResultsEvents = function () {
39400
+ var self = this;
39401
+
39402
+ this.results.on('*', function (name, params) {
39403
+ self.trigger(name, params);
39404
+ });
39405
+ };
39406
+
39407
+ Select2.prototype._registerEvents = function () {
39408
+ var self = this;
39409
+
39410
+ this.on('open', function () {
39411
+ self.$container.addClass('select2-container--open');
39412
+ });
39413
+
39414
+ this.on('close', function () {
39415
+ self.$container.removeClass('select2-container--open');
39416
+ });
39417
+
39418
+ this.on('enable', function () {
39419
+ self.$container.removeClass('select2-container--disabled');
39420
+ });
39421
+
39422
+ this.on('disable', function () {
39423
+ self.$container.addClass('select2-container--disabled');
39424
+ });
39425
+
39426
+ this.on('blur', function () {
39427
+ self.$container.removeClass('select2-container--focus');
39428
+ });
39429
+
39430
+ this.on('query', function (params) {
39431
+ if (!self.isOpen()) {
39432
+ self.trigger('open', {});
39433
+ }
39434
+
39435
+ this.dataAdapter.query(params, function (data) {
39436
+ self.trigger('results:all', {
39437
+ data: data,
39438
+ query: params
39439
+ });
39440
+ });
39441
+ });
39442
+
39443
+ this.on('query:append', function (params) {
39444
+ this.dataAdapter.query(params, function (data) {
39445
+ self.trigger('results:append', {
39446
+ data: data,
39447
+ query: params
39448
+ });
39449
+ });
39450
+ });
39451
+
39452
+ this.on('keypress', function (evt) {
39453
+ var key = evt.which;
39454
+
39455
+ if (self.isOpen()) {
39456
+ if (key === KEYS.ESC || key === KEYS.TAB ||
39457
+ (key === KEYS.UP && evt.altKey)) {
39458
+ self.close();
39459
+
39460
+ evt.preventDefault();
39461
+ } else if (key === KEYS.ENTER) {
39462
+ self.trigger('results:select', {});
39463
+
39464
+ evt.preventDefault();
39465
+ } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
39466
+ self.trigger('results:toggle', {});
39467
+
39468
+ evt.preventDefault();
39469
+ } else if (key === KEYS.UP) {
39470
+ self.trigger('results:previous', {});
39471
+
39472
+ evt.preventDefault();
39473
+ } else if (key === KEYS.DOWN) {
39474
+ self.trigger('results:next', {});
39475
+
39476
+ evt.preventDefault();
39477
+ }
39478
+ } else {
39479
+ if (key === KEYS.ENTER || key === KEYS.SPACE ||
39480
+ (key === KEYS.DOWN && evt.altKey)) {
39481
+ self.open();
39482
+
39483
+ evt.preventDefault();
39484
+ }
39485
+ }
39486
+ });
39487
+ };
39488
+
39489
+ Select2.prototype._syncAttributes = function () {
39490
+ this.options.set('disabled', this.$element.prop('disabled'));
39491
+
39492
+ if (this.options.get('disabled')) {
39493
+ if (this.isOpen()) {
39494
+ this.close();
39495
+ }
39496
+
39497
+ this.trigger('disable', {});
39498
+ } else {
39499
+ this.trigger('enable', {});
39500
+ }
39501
+ };
39502
+
39503
+ Select2.prototype._syncSubtree = function (evt, mutations) {
39504
+ var changed = false;
39505
+ var self = this;
39506
+
39507
+ // Ignore any mutation events raised for elements that aren't options or
39508
+ // optgroups. This handles the case when the select element is destroyed
39509
+ if (
39510
+ evt && evt.target && (
39511
+ evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
39512
+ )
39513
+ ) {
39514
+ return;
39515
+ }
39516
+
39517
+ if (!mutations) {
39518
+ // If mutation events aren't supported, then we can only assume that the
39519
+ // change affected the selections
39520
+ changed = true;
39521
+ } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
39522
+ for (var n = 0; n < mutations.addedNodes.length; n++) {
39523
+ var node = mutations.addedNodes[n];
39524
+
39525
+ if (node.selected) {
39526
+ changed = true;
39527
+ }
39528
+ }
39529
+ } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
39530
+ changed = true;
39531
+ }
39532
+
39533
+ // Only re-pull the data if we think there is a change
39534
+ if (changed) {
39535
+ this.dataAdapter.current(function (currentData) {
39536
+ self.trigger('selection:update', {
39537
+ data: currentData
39538
+ });
39539
+ });
39540
+ }
39541
+ };
39542
+
39543
+ /**
39544
+ * Override the trigger method to automatically trigger pre-events when
39545
+ * there are events that can be prevented.
39546
+ */
39547
+ Select2.prototype.trigger = function (name, args) {
39548
+ var actualTrigger = Select2.__super__.trigger;
39549
+ var preTriggerMap = {
39550
+ 'open': 'opening',
39551
+ 'close': 'closing',
39552
+ 'select': 'selecting',
39553
+ 'unselect': 'unselecting'
39554
+ };
39555
+
39556
+ if (args === undefined) {
39557
+ args = {};
39558
+ }
39559
+
39560
+ if (name in preTriggerMap) {
39561
+ var preTriggerName = preTriggerMap[name];
39562
+ var preTriggerArgs = {
39563
+ prevented: false,
39564
+ name: name,
39565
+ args: args
39566
+ };
39567
+
39568
+ actualTrigger.call(this, preTriggerName, preTriggerArgs);
39569
+
39570
+ if (preTriggerArgs.prevented) {
39571
+ args.prevented = true;
39572
+
39573
+ return;
39574
+ }
39575
+ }
39576
+
39577
+ actualTrigger.call(this, name, args);
39578
+ };
39579
+
39580
+ Select2.prototype.toggleDropdown = function () {
39581
+ if (this.options.get('disabled')) {
39582
+ return;
39583
+ }
39584
+
39585
+ if (this.isOpen()) {
39586
+ this.close();
39587
+ } else {
39588
+ this.open();
39589
+ }
39590
+ };
39591
+
39592
+ Select2.prototype.open = function () {
39593
+ if (this.isOpen()) {
39594
+ return;
39595
+ }
39596
+
39597
+ this.trigger('query', {});
39598
+ };
39599
+
39600
+ Select2.prototype.close = function () {
39601
+ if (!this.isOpen()) {
39602
+ return;
39603
+ }
39604
+
39605
+ this.trigger('close', {});
39606
+ };
39607
+
39608
+ Select2.prototype.isOpen = function () {
39609
+ return this.$container.hasClass('select2-container--open');
39610
+ };
39611
+
39612
+ Select2.prototype.hasFocus = function () {
39613
+ return this.$container.hasClass('select2-container--focus');
39614
+ };
39615
+
39616
+ Select2.prototype.focus = function (data) {
39617
+ // No need to re-trigger focus events if we are already focused
39618
+ if (this.hasFocus()) {
39619
+ return;
39620
+ }
39621
+
39622
+ this.$container.addClass('select2-container--focus');
39623
+ this.trigger('focus', {});
39624
+ };
39625
+
39626
+ Select2.prototype.enable = function (args) {
39627
+ if (this.options.get('debug') && window.console && console.warn) {
39628
+ console.warn(
39629
+ 'Select2: The `select2("enable")` method has been deprecated and will' +
39630
+ ' be removed in later Select2 versions. Use $element.prop("disabled")' +
39631
+ ' instead.'
39632
+ );
39633
+ }
39634
+
39635
+ if (args == null || args.length === 0) {
39636
+ args = [true];
39637
+ }
39638
+
39639
+ var disabled = !args[0];
39640
+
39641
+ this.$element.prop('disabled', disabled);
39642
+ };
39643
+
39644
+ Select2.prototype.data = function () {
39645
+ if (this.options.get('debug') &&
39646
+ arguments.length > 0 && window.console && console.warn) {
39647
+ console.warn(
39648
+ 'Select2: Data can no longer be set using `select2("data")`. You ' +
39649
+ 'should consider setting the value instead using `$element.val()`.'
39650
+ );
39651
+ }
39652
+
39653
+ var data = [];
39654
+
39655
+ this.dataAdapter.current(function (currentData) {
39656
+ data = currentData;
39657
+ });
39658
+
39659
+ return data;
39660
+ };
39661
+
39662
+ Select2.prototype.val = function (args) {
39663
+ if (this.options.get('debug') && window.console && console.warn) {
39664
+ console.warn(
39665
+ 'Select2: The `select2("val")` method has been deprecated and will be' +
39666
+ ' removed in later Select2 versions. Use $element.val() instead.'
39667
+ );
39668
+ }
39669
+
39670
+ if (args == null || args.length === 0) {
39671
+ return this.$element.val();
39672
+ }
39673
+
39674
+ var newVal = args[0];
39675
+
39676
+ if ($.isArray(newVal)) {
39677
+ newVal = $.map(newVal, function (obj) {
39678
+ return obj.toString();
39679
+ });
39680
+ }
39681
+
39682
+ this.$element.val(newVal).trigger('change');
39683
+ };
39684
+
39685
+ Select2.prototype.destroy = function () {
39686
+ this.$container.remove();
39687
+
39688
+ if (this.$element[0].detachEvent) {
39689
+ this.$element[0].detachEvent('onpropertychange', this._syncA);
39690
+ }
39691
+
39692
+ if (this._observer != null) {
39693
+ this._observer.disconnect();
39694
+ this._observer = null;
39695
+ } else if (this.$element[0].removeEventListener) {
39696
+ this.$element[0]
39697
+ .removeEventListener('DOMAttrModified', this._syncA, false);
39698
+ this.$element[0]
39699
+ .removeEventListener('DOMNodeInserted', this._syncS, false);
39700
+ this.$element[0]
39701
+ .removeEventListener('DOMNodeRemoved', this._syncS, false);
39702
+ }
39703
+
39704
+ this._syncA = null;
39705
+ this._syncS = null;
39706
+
39707
+ this.$element.off('.select2');
39708
+ this.$element.attr('tabindex', this.$element.data('old-tabindex'));
39709
+
39710
+ this.$element.removeClass('select2-hidden-accessible');
39711
+ this.$element.attr('aria-hidden', 'false');
39712
+ this.$element.removeData('select2');
39713
+
39714
+ this.dataAdapter.destroy();
39715
+ this.selection.destroy();
39716
+ this.dropdown.destroy();
39717
+ this.results.destroy();
39718
+
39719
+ this.dataAdapter = null;
39720
+ this.selection = null;
39721
+ this.dropdown = null;
39722
+ this.results = null;
39723
+ };
39724
+
39725
+ Select2.prototype.render = function () {
39726
+ var $container = $(
39727
+ '<span class="select2 select2-container">' +
39728
+ '<span class="selection"></span>' +
39729
+ '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
39730
+ '</span>'
39731
+ );
39732
+
39733
+ $container.attr('dir', this.options.get('dir'));
39734
+
39735
+ this.$container = $container;
39736
+
39737
+ this.$container.addClass('select2-container--' + this.options.get('theme'));
39738
+
39739
+ $container.data('element', this.$element);
39740
+
39741
+ return $container;
39742
+ };
39743
+
39744
+ return Select2;
39745
+ });
39746
+
39747
+ S2.define('jquery-mousewheel',[
39748
+ 'jquery'
39749
+ ], function ($) {
39750
+ // Used to shim jQuery.mousewheel for non-full builds.
39751
+ return $;
39752
+ });
39753
+
39754
+ S2.define('jquery.select2',[
39755
+ 'jquery',
39756
+ 'jquery-mousewheel',
39757
+
39758
+ './select2/core',
39759
+ './select2/defaults'
39760
+ ], function ($, _, Select2, Defaults) {
39761
+ if ($.fn.select2 == null) {
39762
+ // All methods that should return the element
39763
+ var thisMethods = ['open', 'close', 'destroy'];
39764
+
39765
+ $.fn.select2 = function (options) {
39766
+ options = options || {};
39767
+
39768
+ if (typeof options === 'object') {
39769
+ this.each(function () {
39770
+ var instanceOptions = $.extend(true, {}, options);
39771
+
39772
+ var instance = new Select2($(this), instanceOptions);
39773
+ });
39774
+
39775
+ return this;
39776
+ } else if (typeof options === 'string') {
39777
+ var ret;
39778
+ var args = Array.prototype.slice.call(arguments, 1);
39779
+
39780
+ this.each(function () {
39781
+ var instance = $(this).data('select2');
39782
+
39783
+ if (instance == null && window.console && console.error) {
39784
+ console.error(
39785
+ 'The select2(\'' + options + '\') method was called on an ' +
39786
+ 'element that is not using Select2.'
39787
+ );
39788
+ }
39789
+
39790
+ ret = instance[options].apply(instance, args);
39791
+ });
39792
+
39793
+ // Check if we should be returning `this`
39794
+ if ($.inArray(options, thisMethods) > -1) {
39795
+ return this;
39796
+ }
39797
+
39798
+ return ret;
39799
+ } else {
39800
+ throw new Error('Invalid arguments for Select2: ' + options);
39801
+ }
39802
+ };
39803
+ }
39804
+
39805
+ if ($.fn.select2.defaults == null) {
39806
+ $.fn.select2.defaults = Defaults;
39807
+ }
39808
+
39809
+ return Select2;
39810
+ });
39811
+
39812
+ // Return the AMD loader configuration so it can be used outside of this file
39813
+ return {
39814
+ define: S2.define,
39815
+ require: S2.require
39816
+ };
39817
+ }());
39818
+
39819
+ // Autoload the jQuery bindings
39820
+ // We know that all of the modules exist above this, so we're safe
39821
+ var select2 = S2.require('jquery.select2');
39822
+
39823
+ // Hold the AMD module references on the jQuery function that was just loaded
39824
+ // This allows Select2 to use the internal loader outside of this file, such
39825
+ // as in the language files.
39826
+ jQuery.fn.select2.amd = S2;
39827
+
39828
+ // Return the Select2 instance for anyone who is importing it.
39829
+ return select2;
39830
+ }));
39831
 
39832
 
39833
  /***/ },
40804
  /***/ function(module, exports, __webpack_require__) {
40805
 
40806
  var require;/* WEBPACK VAR INJECTION */(function(module) {//! moment.js
40807
+ //! version : 2.19.1
40808
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
40809
  //! license : MIT
40810
  //! momentjs.com
41619
 
41620
  function set$1 (mom, unit, value) {
41621
  if (mom.isValid() && !isNaN(value)) {
41622
+ if (unit === 'FullYear' && isLeapYear(mom.year())) {
41623
  mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
41624
  }
41625
  else {
42725
 
42726
  function updateLocale(name, config) {
42727
  if (config != null) {
42728
+ var locale, parentConfig = baseConfig;
42729
  // MERGE
42730
+ if (locales[name] != null) {
42731
+ parentConfig = locales[name]._config;
 
42732
  }
42733
  config = mergeConfigs(parentConfig, config);
42734
  locale = new Locale(config);
45282
  // Side effect imports
45283
 
45284
 
45285
+ hooks.version = '2.19.1';
45286
 
45287
  setHookCallback(createLocal);
45288
 
assets/js/lib/mailpoet_shortcodes/plugin.js CHANGED
@@ -8,33 +8,35 @@
8
  * its placeholder into editor text.
9
  */
10
 
11
- /*jshint unused:false */
12
- /*global tinymce:true */
13
- tinymce.PluginManager.add('mailpoet_shortcodes', function(editor, url) {
14
- var appendLabelAndClose = function(shortcode) {
15
- editor.insertContent(shortcode);
16
- editor.windowManager.close();
17
- },
18
- generateOnClickFunc = function(shortcode) {
19
- return function() {
20
- appendLabelAndClose(shortcode);
21
- };
22
  };
 
23
 
24
  editor.addButton('mailpoet_shortcodes', {
25
  icon: 'mailpoet_shortcodes',
26
- onclick: function() {
27
- var shortcodes = [],
28
- configShortcodes = editor.settings.mailpoet_shortcodes;
 
 
29
 
30
- for (var segment in configShortcodes) {
31
  if (configShortcodes.hasOwnProperty(segment)) {
32
  shortcodes.push({
33
  type: 'label',
34
  text: segment
35
  });
36
 
37
- for (var i = 0; i < configShortcodes[segment].length; i += 1) {
38
  shortcodes.push({
39
  type: 'button',
40
  text: configShortcodes[segment][i].text,
8
  * its placeholder into editor text.
9
  */
10
 
11
+ /* jshint unused:false */
12
+ /* global tinymce:true */
13
+ tinymce.PluginManager.add('mailpoet_shortcodes', function (editor) {
14
+ var appendLabelAndClose = function (shortcode) {
15
+ editor.insertContent(shortcode);
16
+ editor.windowManager.close();
17
+ };
18
+ var generateOnClickFunc = function (shortcode) {
19
+ return function () {
20
+ appendLabelAndClose(shortcode);
 
21
  };
22
+ };
23
 
24
  editor.addButton('mailpoet_shortcodes', {
25
  icon: 'mailpoet_shortcodes',
26
+ onclick: function () {
27
+ var shortcodes = [];
28
+ var configShortcodes = editor.settings.mailpoet_shortcodes;
29
+ var segment;
30
+ var i;
31
 
32
+ for (segment in configShortcodes) {
33
  if (configShortcodes.hasOwnProperty(segment)) {
34
  shortcodes.push({
35
  type: 'label',
36
  text: segment
37
  });
38
 
39
+ for (i = 0; i < configShortcodes[segment].length; i += 1) {
40
  shortcodes.push({
41
  type: 'button',
42
  text: configShortcodes[segment][i].text,
assets/js/{mailpoet.0ecf7a2c.js → mailpoet.3dd11c86.js} RENAMED
@@ -23905,7 +23905,7 @@ webpackJsonp([3],[
23905
  /***/ function(module, exports, __webpack_require__) {
23906
 
23907
  var require;/* WEBPACK VAR INJECTION */(function(module) {//! moment.js
23908
- //! version : 2.19.2
23909
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
23910
  //! license : MIT
23911
  //! momentjs.com
@@ -24720,7 +24720,7 @@ webpackJsonp([3],[
24720
 
24721
  function set$1 (mom, unit, value) {
24722
  if (mom.isValid() && !isNaN(value)) {
24723
- if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
24724
  mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
24725
  }
24726
  else {
@@ -25826,11 +25826,10 @@ webpackJsonp([3],[
25826
 
25827
  function updateLocale(name, config) {
25828
  if (config != null) {
25829
- var locale, tmpLocale, parentConfig = baseConfig;
25830
  // MERGE
25831
- tmpLocale = loadLocale(name);
25832
- if (tmpLocale != null) {
25833
- parentConfig = tmpLocale._config;
25834
  }
25835
  config = mergeConfigs(parentConfig, config);
25836
  locale = new Locale(config);
@@ -28384,7 +28383,7 @@ webpackJsonp([3],[
28384
  // Side effect imports
28385
 
28386
 
28387
- hooks.version = '2.19.2';
28388
 
28389
  setHookCallback(createLocal);
28390
 
23905
  /***/ function(module, exports, __webpack_require__) {
23906
 
23907
  var require;/* WEBPACK VAR INJECTION */(function(module) {//! moment.js
23908
+ //! version : 2.19.1
23909
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
23910
  //! license : MIT
23911
  //! momentjs.com
24720
 
24721
  function set$1 (mom, unit, value) {
24722
  if (mom.isValid() && !isNaN(value)) {
24723
+ if (unit === 'FullYear' && isLeapYear(mom.year())) {
24724
  mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
24725
  }
24726
  else {
25826
 
25827
  function updateLocale(name, config) {
25828
  if (config != null) {
25829
+ var locale, parentConfig = baseConfig;
25830
  // MERGE
25831
+ if (locales[name] != null) {
25832
+ parentConfig = locales[name]._config;
 
25833
  }
25834
  config = mergeConfigs(parentConfig, config);
25835
  locale = new Locale(config);
28383
  // Side effect imports
28384
 
28385
 
28386
+ hooks.version = '2.19.1';
28387
 
28388
  setHookCallback(createLocal);
28389
 
assets/js/manifest.json CHANGED
@@ -1,10 +1,10 @@
1
  {
2
  "mp2migrator.js": "mp2migrator.e755af46.js",
3
  "public.js": "public.8173fe64.js",
4
- "admin.js": "admin.5976c78a.js",
5
- "admin_vendor.js": "admin_vendor.9865021f.js",
6
  "form_editor.js": "form_editor.612beb34.js",
7
- "mailpoet.js": "mailpoet.0ecf7a2c.js",
8
- "newsletter_editor.js": "newsletter_editor.c4722da5.js",
9
- "vendor.js": "vendor.501aa0d2.js"
10
  }
1
  {
2
  "mp2migrator.js": "mp2migrator.e755af46.js",
3
  "public.js": "public.8173fe64.js",
4
+ "admin.js": "admin.4d4f5142.js",
5
+ "admin_vendor.js": "admin_vendor.e5ae56f3.js",
6
  "form_editor.js": "form_editor.612beb34.js",
7
+ "mailpoet.js": "mailpoet.3dd11c86.js",
8
+ "newsletter_editor.js": "newsletter_editor.e7c440c6.js",
9
+ "vendor.js": "vendor.f03e722d.js"
10
  }
assets/js/{newsletter_editor.c4722da5.js → newsletter_editor.e7c440c6.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.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
  /***/ },
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
  /***/ },
assets/js/{vendor.501aa0d2.js → vendor.f03e722d.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":"5976c78a","1":"9865021f","2":"612beb34","3":"0ecf7a2c","4":"c4722da5"}[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":"4d4f5142","1":"e5ae56f3","2":"612beb34","3":"3dd11c86","4":"e7c440c6"}[chunkId] + ".chunk.js";
80
  /******/ head.appendChild(script);
81
  /******/ }
82
  /******/ };
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-11-14 19:15:24+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -291,7 +291,7 @@ msgstr ""
291
  msgid "Manage segments"
292
  msgstr ""
293
 
294
- #: lib/Config/Capabilities.php:67 lib/Config/Menu.php:610 views/premium.html:41
295
  msgid "MailPoet"
296
  msgstr ""
297
 
@@ -392,80 +392,80 @@ msgstr[1] ""
392
  msgid "Settings imported"
393
  msgstr ""
394
 
395
- #: lib/Config/Menu.php:82 lib/Config/Menu.php:83 views/newsletters.html:24
396
  msgid "Emails"
397
  msgstr ""
398
 
399
- #: lib/Config/Menu.php:107 lib/Newsletter/Shortcodes/ShortcodesHelper.php:33
400
  #: views/newsletter/templates/components/sidebar/styles.hbs:75
401
  #: views/newsletters.html:123
402
  msgid "Newsletter"
403
  msgstr ""
404
 
405
- #: lib/Config/Menu.php:108 views/newsletter/editor.html:228
406
  msgid "Newsletter Editor"
407
  msgstr ""
408
 
409
- #: lib/Config/Menu.php:120 lib/Config/Menu.php:121 views/forms.html:25
410
  #: views/mp2migration.html:14
411
  msgid "Forms"
412
  msgstr ""
413
 
414
- #: lib/Config/Menu.php:145 lib/Config/Menu.php:146
415
  msgid "Form Editor"
416
  msgstr ""
417
 
418
- #: lib/Config/Menu.php:158 lib/Config/Menu.php:159
419
  #: views/subscribers/subscribers.html:18
420
  msgid "Subscribers"
421
  msgstr ""
422
 
423
- #: lib/Config/Menu.php:183 lib/Config/Menu.php:184
424
  #: views/subscribers/importExport/import.html:7
425
  #: views/subscribers/subscribers.html:94
426
  msgid "Import"
427
  msgstr ""
428
 
429
- #: lib/Config/Menu.php:196 lib/Config/Menu.php:197
430
  #: views/subscribers/importExport/export.html:6
431
  #: views/subscribers/importExport/export.html:96
432
  #: views/subscribers/subscribers.html:95
433
  msgid "Export"
434
  msgstr ""
435
 
436
- #: lib/Config/Menu.php:209 lib/Config/Menu.php:210 views/forms.html:53
437
  #: views/newsletters.html:66 views/newsletters.html:168 views/segments.html:13
438
  #: views/subscribers/subscribers.html:66
439
  msgid "Lists"
440
  msgstr ""
441
 
442
- #: lib/Config/Menu.php:236 lib/Config/Menu.php:237 views/form/editor.html:37
443
  #: views/mp2migration.html:15 views/newsletters.html:67 views/settings.html:6
444
  msgid "Settings"
445
  msgstr ""
446
 
447
- #: lib/Config/Menu.php:249 lib/Config/Menu.php:250 views/help.html:5
448
  msgid "Help"
449
  msgstr ""
450
 
451
- #: lib/Config/Menu.php:263 lib/Config/Menu.php:264
452
  msgid "Premium"
453
  msgstr ""
454
 
455
- #: lib/Config/Menu.php:276 lib/Config/Menu.php:277 views/update.html:16
456
  #: views/welcome.html:12
457
  msgid "Welcome"
458
  msgstr ""
459
 
460
- #: lib/Config/Menu.php:289 lib/Config/Menu.php:290 views/segments.html:43
461
  msgid "Update"
462
  msgstr ""
463
 
464
- #: lib/Config/Menu.php:302
465
  msgid "Migration"
466
  msgstr ""
467
 
468
- #: lib/Config/Menu.php:532
469
  msgid "In any WordPress role"
470
  msgstr ""
471
 
@@ -1735,20 +1735,26 @@ msgstr ""
1735
  msgid "MailPoet Error:"
1736
  msgstr ""
1737
 
1738
- #: mailpoet.php:50
 
 
 
 
 
 
1739
  msgid ""
1740
  "MailPoet plugin requires PHP version 5.3.3 or newer. Please read our "
1741
  "[link]instructions[/link] on how to resolve this issue."
1742
  msgstr ""
1743
 
1744
- #: mailpoet.php:65
1745
  msgid ""
1746
  "MailPoet plugin cannot run under Microsoft's Internet Information Services "
1747
  "(IIS) web server. We recommend that you use a web server powered by Apache "
1748
  "or NGINX."
1749
  msgstr ""
1750
 
1751
- #: mailpoet.php:79
1752
  msgid ""
1753
  "MailPoet cannot start because it is missing core files. Please reinstall "
1754
  "the plugin."
@@ -5290,7 +5296,7 @@ msgstr ""
5290
  msgid "Care to Give Your Opinion?"
5291
  msgstr ""
5292
 
5293
- #: views/update.html:116 views/welcome.html:60
5294
  msgid "Awesome! Now, take me to MailPoet"
5295
  msgstr ""
5296
 
@@ -5380,22 +5386,22 @@ msgctxt "Error code (inside parentheses)"
5380
  msgid "code: %s"
5381
  msgstr ""
5382
 
5383
- #: lib/Config/Menu.php:95
5384
  msgctxt "newsletters per page (screen options)"
5385
  msgid "Number of newsletters per page"
5386
  msgstr ""
5387
 
5388
- #: lib/Config/Menu.php:133
5389
  msgctxt "forms per page (screen options)"
5390
  msgid "Number of forms per page"
5391
  msgstr ""
5392
 
5393
- #: lib/Config/Menu.php:171
5394
  msgctxt "subscribers per page (screen options)"
5395
  msgid "Number of subscribers per page"
5396
  msgstr ""
5397
 
5398
- #: lib/Config/Menu.php:222
5399
  msgctxt "segments per page (screen options)"
5400
  msgid "Number of segments per page"
5401
  msgstr ""
4
  msgstr ""
5
  "Project-Id-Version: \n"
6
  "Report-Msgid-Bugs-To: http://support.mailpoet.com/\n"
7
+ "POT-Creation-Date: 2017-11-21 15:03:40+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
291
  msgid "Manage segments"
292
  msgstr ""
293
 
294
+ #: lib/Config/Capabilities.php:67 lib/Config/Menu.php:611 views/premium.html:41
295
  msgid "MailPoet"
296
  msgstr ""
297
 
392
  msgid "Settings imported"
393
  msgstr ""
394
 
395
+ #: lib/Config/Menu.php:83 lib/Config/Menu.php:84 views/newsletters.html:24
396
  msgid "Emails"
397
  msgstr ""
398
 
399
+ #: lib/Config/Menu.php:108 lib/Newsletter/Shortcodes/ShortcodesHelper.php:33
400
  #: views/newsletter/templates/components/sidebar/styles.hbs:75
401
  #: views/newsletters.html:123
402
  msgid "Newsletter"
403
  msgstr ""
404
 
405
+ #: lib/Config/Menu.php:109 views/newsletter/editor.html:228
406
  msgid "Newsletter Editor"
407
  msgstr ""
408
 
409
+ #: lib/Config/Menu.php:121 lib/Config/Menu.php:122 views/forms.html:25
410
  #: views/mp2migration.html:14
411
  msgid "Forms"
412
  msgstr ""
413
 
414
+ #: lib/Config/Menu.php:146 lib/Config/Menu.php:147
415
  msgid "Form Editor"
416
  msgstr ""
417
 
418
+ #: lib/Config/Menu.php:159 lib/Config/Menu.php:160
419
  #: views/subscribers/subscribers.html:18
420
  msgid "Subscribers"
421
  msgstr ""
422
 
423
+ #: lib/Config/Menu.php:184 lib/Config/Menu.php:185
424
  #: views/subscribers/importExport/import.html:7
425
  #: views/subscribers/subscribers.html:94
426
  msgid "Import"
427
  msgstr ""
428
 
429
+ #: lib/Config/Menu.php:197 lib/Config/Menu.php:198
430
  #: views/subscribers/importExport/export.html:6
431
  #: views/subscribers/importExport/export.html:96
432
  #: views/subscribers/subscribers.html:95
433
  msgid "Export"
434
  msgstr ""
435
 
436
+ #: lib/Config/Menu.php:210 lib/Config/Menu.php:211 views/forms.html:53
437
  #: views/newsletters.html:66 views/newsletters.html:168 views/segments.html:13
438
  #: views/subscribers/subscribers.html:66
439
  msgid "Lists"
440
  msgstr ""
441
 
442
+ #: lib/Config/Menu.php:237 lib/Config/Menu.php:238 views/form/editor.html:37
443
  #: views/mp2migration.html:15 views/newsletters.html:67 views/settings.html:6
444
  msgid "Settings"
445
  msgstr ""
446
 
447
+ #: lib/Config/Menu.php:250 lib/Config/Menu.php:251 views/help.html:5
448
  msgid "Help"
449
  msgstr ""
450
 
451
+ #: lib/Config/Menu.php:264 lib/Config/Menu.php:265
452
  msgid "Premium"
453
  msgstr ""
454
 
455
+ #: lib/Config/Menu.php:277 lib/Config/Menu.php:278 views/update.html:16
456
  #: views/welcome.html:12
457
  msgid "Welcome"
458
  msgstr ""
459
 
460
+ #: lib/Config/Menu.php:290 lib/Config/Menu.php:291 views/segments.html:43
461
  msgid "Update"
462
  msgstr ""
463
 
464
+ #: lib/Config/Menu.php:303
465
  msgid "Migration"
466
  msgstr ""
467
 
468
+ #: lib/Config/Menu.php:533
469
  msgid "In any WordPress role"
470
  msgstr ""
471
 
1735
  msgid "MailPoet Error:"
1736
  msgstr ""
1737
 
1738
+ #: mailpoet.php:58
1739
+ msgid ""
1740
+ "MailPoet plugin requires WordPress version 4.6 or newer. Please read our "
1741
+ "[link]instructions[/link] on how to resolve this issue."
1742
+ msgstr ""
1743
+
1744
+ #: mailpoet.php:69
1745
  msgid ""
1746
  "MailPoet plugin requires PHP version 5.3.3 or newer. Please read our "
1747
  "[link]instructions[/link] on how to resolve this issue."
1748
  msgstr ""
1749
 
1750
+ #: mailpoet.php:84
1751
  msgid ""
1752
  "MailPoet plugin cannot run under Microsoft's Internet Information Services "
1753
  "(IIS) web server. We recommend that you use a web server powered by Apache "
1754
  "or NGINX."
1755
  msgstr ""
1756
 
1757
+ #: mailpoet.php:98
1758
  msgid ""
1759
  "MailPoet cannot start because it is missing core files. Please reinstall "
1760
  "the plugin."
5296
  msgid "Care to Give Your Opinion?"
5297
  msgstr ""
5298
 
5299
+ #: views/update.html:104 views/welcome.html:60
5300
  msgid "Awesome! Now, take me to MailPoet"
5301
  msgstr ""
5302
 
5386
  msgid "code: %s"
5387
  msgstr ""
5388
 
5389
+ #: lib/Config/Menu.php:96
5390
  msgctxt "newsletters per page (screen options)"
5391
  msgid "Number of newsletters per page"
5392
  msgstr ""
5393
 
5394
+ #: lib/Config/Menu.php:134
5395
  msgctxt "forms per page (screen options)"
5396
  msgid "Number of forms per page"
5397
  msgstr ""
5398
 
5399
+ #: lib/Config/Menu.php:172
5400
  msgctxt "subscribers per page (screen options)"
5401
  msgid "Number of subscribers per page"
5402
  msgstr ""
5403
 
5404
+ #: lib/Config/Menu.php:223
5405
  msgctxt "segments per page (screen options)"
5406
  msgid "Number of segments per page"
5407
  msgstr ""
lib/Config/Menu.php CHANGED
@@ -37,13 +37,14 @@ class Menu {
37
  $this->renderer = $renderer;
38
  $this->assets_url = $assets_url;
39
  $this->access_control = $access_control;
 
 
 
40
  $subscribers_feature = new SubscribersFeature();
41
  $this->subscribers_over_limit = $subscribers_feature->check();
42
  $this->checkMailPoetAPIKey();
43
  $this->checkPremiumKey();
44
- }
45
 
46
- function init() {
47
  add_action(
48
  'admin_menu',
49
  array(
37
  $this->renderer = $renderer;
38
  $this->assets_url = $assets_url;
39
  $this->access_control = $access_control;
40
+ }
41
+
42
+ function init() {
43
  $subscribers_feature = new SubscribersFeature();
44
  $this->subscribers_over_limit = $subscribers_feature->check();
45
  $this->checkMailPoetAPIKey();
46
  $this->checkPremiumKey();
 
47
 
 
48
  add_action(
49
  'admin_menu',
50
  array(
lib/Form/Renderer.php CHANGED
@@ -15,7 +15,7 @@ class Renderer {
15
  $styles = new Util\Styles(static::getStyles($form));
16
 
17
  $html = '<style type="text/css">';
18
- $html .= '.mailpoet_hp_email_label{position: absolute;left: -999em;}'; // move honeypot field out of sight
19
  $html .= $styles->render($prefix);
20
  $html .= '</style>';
21
 
@@ -41,7 +41,7 @@ class Renderer {
41
  static function renderBlocks($blocks = array(), $honeypot_enabled = true) {
42
  // add honeypot for spambots
43
  $html = ($honeypot_enabled) ?
44
- '<label class="mailpoet_hp_email_label">' . __('Please leave this field empty', 'mailpoet') . '<input autocomplete="not-really-email" type="email" name="data[email]"></label>' :
45
  '';
46
  foreach($blocks as $key => $block) {
47
  $html .= static::renderBlock($block) . PHP_EOL;
15
  $styles = new Util\Styles(static::getStyles($form));
16
 
17
  $html = '<style type="text/css">';
18
+ $html .= '.mailpoet_hp_email_label{display:none;}'; // move honeypot field out of sight
19
  $html .= $styles->render($prefix);
20
  $html .= '</style>';
21
 
41
  static function renderBlocks($blocks = array(), $honeypot_enabled = true) {
42
  // add honeypot for spambots
43
  $html = ($honeypot_enabled) ?
44
+ '<label class="mailpoet_hp_email_label">' . __('Please leave this field empty', 'mailpoet') . '<input type="email" name="data[email]"></label>' :
45
  '';
46
  foreach($blocks as $key => $block) {
47
  $html .= static::renderBlock($block) . PHP_EOL;
mailpoet.php CHANGED
@@ -4,13 +4,13 @@ if(!defined('ABSPATH')) exit;
4
 
5
  /*
6
  * Plugin Name: MailPoet 3 (New)
7
- * Version: 3.2.0
8
  * Plugin URI: http://www.mailpoet.com
9
  * Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
10
  * Author: MailPoet
11
  * Author URI: http://www.mailpoet.com
12
  * Requires at least: 4.6
13
- * Tested up to: 4.8
14
  *
15
  * Domain Path: /lang/
16
  *
@@ -20,7 +20,7 @@ if(!defined('ABSPATH')) exit;
20
  */
21
 
22
  $mailpoet_plugin = array(
23
- 'version' => '3.2.0',
24
  'filename' => __FILE__,
25
  'path' => dirname(__FILE__),
26
  'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',
@@ -34,6 +34,14 @@ function mailpoet_deactivate_plugin() {
34
  }
35
  }
36
 
 
 
 
 
 
 
 
 
37
  // Check for minimum supported PHP version
38
  if(version_compare(phpversion(), '5.3.3', '<')) {
39
  add_action('admin_notices', 'mailpoet_php_version_notice');
@@ -42,6 +50,17 @@ if(version_compare(phpversion(), '5.3.3', '<')) {
42
  return;
43
  }
44
 
 
 
 
 
 
 
 
 
 
 
 
45
  // Display PHP version error notice
46
  function mailpoet_php_version_notice() {
47
  $notice = str_replace(
4
 
5
  /*
6
  * Plugin Name: MailPoet 3 (New)
7
+ * Version: 3.2.1
8
  * Plugin URI: http://www.mailpoet.com
9
  * Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
10
  * Author: MailPoet
11
  * Author URI: http://www.mailpoet.com
12
  * Requires at least: 4.6
13
+ * Tested up to: 4.9
14
  *
15
  * Domain Path: /lang/
16
  *
20
  */
21
 
22
  $mailpoet_plugin = array(
23
+ 'version' => '3.2.1',
24
  'filename' => __FILE__,
25
  'path' => dirname(__FILE__),
26
  'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',
34
  }
35
  }
36
 
37
+ // Check for minimum supporter WP version
38
+ if(version_compare(get_bloginfo('version'), '4.6', '<')) {
39
+ add_action('admin_notices', 'mailpoet_wp_version_notice');
40
+ // deactivate the plugin
41
+ add_action('admin_init', 'mailpoet_deactivate_plugin');
42
+ return;
43
+ }
44
+
45
  // Check for minimum supported PHP version
46
  if(version_compare(phpversion(), '5.3.3', '<')) {
47
  add_action('admin_notices', 'mailpoet_php_version_notice');
50
  return;
51
  }
52
 
53
+ // Display WP version error notice
54
+ function mailpoet_wp_version_notice() {
55
+ $notice = str_replace(
56
+ '[link]',
57
+ '<a href="//beta.docs.mailpoet.com/article/152-minimum-requirements-for-mailpoet-3#wp_version" target="_blank">',
58
+ __('MailPoet plugin requires WordPress version 4.6 or newer. Please read our [link]instructions[/link] on how to resolve this issue.', 'mailpoet')
59
+ );
60
+ $notice = str_replace('[/link]', '</a>', $notice);
61
+ printf('<div class="error"><p>%1$s</p></div>', $notice);
62
+ }
63
+
64
  // Display PHP version error notice
65
  function mailpoet_php_version_notice() {
66
  $notice = str_replace(
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.2.0
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -116,6 +116,10 @@ Stop by our [support site](https://www.mailpoet.com/support).
116
 
117
  == Changelog ==
118
 
 
 
 
 
119
  = 3.2.0 - 2017-11-14 =
120
  * Added: API method to access subscriber data by email;
121
  * Added: API method to unsubscribe from lists;
4
  Requires at least: 4.6
5
  Tested up to: 4.8
6
  Requires PHP: 5.3
7
+ Stable tag: 3.2.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
116
 
117
  == Changelog ==
118
 
119
+ = 3.2.1 - 2017-11-21 =
120
+ * Fixed: Safari bug asking subscribers to leave the first field empty in MailPoet subscription forms;
121
+ * Fixed: JavaScript error is not thrown when test email can't be sent;
122
+
123
  = 3.2.0 - 2017-11-14 =
124
  * Added: API method to access subscriber data by email;
125
  * Added: API method to unsubscribe from lists;
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit9d7ecfee479df69f7a3596091bb88e6c::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitd8fb7207da8687f47a634d0fd90a38c2::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit9d7ecfee479df69f7a3596091bb88e6c
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit9d7ecfee479df69f7a3596091bb88e6c
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit9d7ecfee479df69f7a3596091bb88e6c', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit9d7ecfee479df69f7a3596091bb88e6c', '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\ComposerStaticInit9d7ecfee479df69f7a3596091bb88e6c::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit9d7ecfee479df69f7a3596091bb88e6c
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInit9d7ecfee479df69f7a3596091bb88e6c::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequire9d7ecfee479df69f7a3596091bb88e6c($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequire9d7ecfee479df69f7a3596091bb88e6c($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 ComposerAutoloaderInitd8fb7207da8687f47a634d0fd90a38c2
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInitd8fb7207da8687f47a634d0fd90a38c2', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitd8fb7207da8687f47a634d0fd90a38c2', '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\ComposerStaticInitd8fb7207da8687f47a634d0fd90a38c2::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\ComposerStaticInitd8fb7207da8687f47a634d0fd90a38c2::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequired8fb7207da8687f47a634d0fd90a38c2($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequired8fb7207da8687f47a634d0fd90a38c2($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 ComposerStaticInit9d7ecfee479df69f7a3596091bb88e6c
8
  {
9
  public static $files = array (
10
  '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@@ -841,10 +841,10 @@ class ComposerStaticInit9d7ecfee479df69f7a3596091bb88e6c
841
  public static function getInitializer(ClassLoader $loader)
842
  {
843
  return \Closure::bind(function () use ($loader) {
844
- $loader->prefixLengthsPsr4 = ComposerStaticInit9d7ecfee479df69f7a3596091bb88e6c::$prefixLengthsPsr4;
845
- $loader->prefixDirsPsr4 = ComposerStaticInit9d7ecfee479df69f7a3596091bb88e6c::$prefixDirsPsr4;
846
- $loader->prefixesPsr0 = ComposerStaticInit9d7ecfee479df69f7a3596091bb88e6c::$prefixesPsr0;
847
- $loader->classMap = ComposerStaticInit9d7ecfee479df69f7a3596091bb88e6c::$classMap;
848
 
849
  }, null, ClassLoader::class);
850
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInitd8fb7207da8687f47a634d0fd90a38c2
8
  {
9
  public static $files = array (
10
  '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
841
  public static function getInitializer(ClassLoader $loader)
842
  {
843
  return \Closure::bind(function () use ($loader) {
844
+ $loader->prefixLengthsPsr4 = ComposerStaticInitd8fb7207da8687f47a634d0fd90a38c2::$prefixLengthsPsr4;
845
+ $loader->prefixDirsPsr4 = ComposerStaticInitd8fb7207da8687f47a634d0fd90a38c2::$prefixDirsPsr4;
846
+ $loader->prefixesPsr0 = ComposerStaticInitd8fb7207da8687f47a634d0fd90a38c2::$prefixesPsr0;
847
+ $loader->classMap = ComposerStaticInitd8fb7207da8687f47a634d0fd90a38c2::$classMap;
848
 
849
  }, null, ClassLoader::class);
850
  }
views/settings/mta.html CHANGED
@@ -736,7 +736,7 @@
736
  "<%= __('The email has been sent! Check your inbox.') | escape('js') %>",
737
  { scroll: true }
738
  );
739
- trackTestEmailSent(true);
740
  }).fail(function(response) {
741
  if (response.errors.length > 0) {
742
  MailPoet.Notice.error(
@@ -744,7 +744,7 @@
744
  { scroll: true }
745
  );
746
  }
747
- trackTestEmailSent(false);
748
  });
749
  });
750
 
@@ -878,7 +878,7 @@
878
  $('#mailpoet_smtp_provider').trigger('change');
879
  $('#mailpoet_web_host').trigger('change');
880
 
881
- function trackTestEmailSent(success) {
882
  MailPoet.trackEvent(
883
  'User has sent a test email from Settings',
884
  {
736
  "<%= __('The email has been sent! Check your inbox.') | escape('js') %>",
737
  { scroll: true }
738
  );
739
+ trackTestEmailSent(mailer, true);
740
  }).fail(function(response) {
741
  if (response.errors.length > 0) {
742
  MailPoet.Notice.error(
744
  { scroll: true }
745
  );
746
  }
747
+ trackTestEmailSent(mailer, false);
748
  });
749
  });
750
 
878
  $('#mailpoet_smtp_provider').trigger('change');
879
  $('#mailpoet_web_host').trigger('change');
880
 
881
+ function trackTestEmailSent(mailer, success) {
882
  MailPoet.trackEvent(
883
  'User has sent a test email from Settings',
884
  {
views/update.html CHANGED
@@ -94,20 +94,8 @@
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_1510025011"></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: "mailpoet-interview-sign-up-form",
106
- placeholder: "pd_1510025011"
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>
94
  <div class="feature-section one-col mailpoet_centered">
95
  <h2><%= __('Care to Give Your Opinion?') %></h2>
96
 
97
+ <script type="text/javascript" charset="utf-8" src="https://secure.polldaddy.com/p/9876369.js"></script>
98
+ <noscript><a href="https://polldaddy.com/poll/9876369/">Do you have the impression that MailPoet innovates quickly?</a></noscript>
 
 
 
 
 
 
 
 
 
 
 
 
99
  </div>
100
 
101
  <hr>