1(function() { if (window.define) { var define = window.define; } if (window.require) { var require = window.require; } if (window.jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) { var define = jQuery.fn.select2.amd.define; var require = jQuery.fn.select2.amd.require; }/** 2 * @license almond 0.2.9 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved. 3 * Available via the MIT or new BSD license. 4 * see: http://github.com/jrburke/almond for details 5 */ 6//Going sloppy to avoid 'use strict' string cost, but strict practices should 7//be followed. 8 /*jslint sloppy: true */ 9 /*global setTimeout: false */ 10 11 var requirejs, require, define; 12 (function (undef) { 13 var main, req, makeMap, handlers, 14 defined = {}, 15 waiting = {}, 16 config = {}, 17 defining = {}, 18 hasOwn = Object.prototype.hasOwnProperty, 19 aps = [].slice, 20 jsSuffixRegExp = /\.js$/; 21 22 function hasProp(obj, prop) { 23 return hasOwn.call(obj, prop); 24 } 25 26 /** 27 * Given a relative module name, like ./something, normalize it to 28 * a real name that can be mapped to a path. 29 * @param {String} name the relative name 30 * @param {String} baseName a real name that the name arg is relative 31 * to. 32 * @returns {String} normalized name 33 */ 34 function normalize(name, baseName) { 35 var nameParts, nameSegment, mapValue, foundMap, lastIndex, 36 foundI, foundStarMap, starI, i, j, part, 37 baseParts = baseName && baseName.split("/"), 38 map = config.map, 39 starMap = (map && map['*']) || {}; 40 41 //Adjust any relative paths. 42 if (name && name.charAt(0) === ".") { 43 //If have a base name, try to normalize against it, 44 //otherwise, assume it is a top-level require that will 45 //be relative to baseUrl in the end. 46 if (baseName) { 47 //Convert baseName to array, and lop off the last part, 48 //so that . matches that "directory" and not name of the baseName's 49 //module. For instance, baseName of "one/two/three", maps to 50 //"one/two/three.js", but we want the directory, "one/two" for 51 //this normalization. 52 baseParts = baseParts.slice(0, baseParts.length - 1); 53 name = name.split('/'); 54 lastIndex = name.length - 1; 55 56 // Node .js allowance: 57 if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { 58 name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); 59 } 60 61 name = baseParts.concat(name); 62 63 //start trimDots 64 for (i = 0; i < name.length; i += 1) { 65 part = name[i]; 66 if (part === ".") { 67 name.splice(i, 1); 68 i -= 1; 69 } else if (part === "..") { 70 if (i === 1 && (name[2] === '..' || name[0] === '..')) { 71 //End of the line. Keep at least one non-dot 72 //path segment at the front so it can be mapped 73 //correctly to disk. Otherwise, there is likely 74 //no path mapping for a path starting with '..'. 75 //This can still fail, but catches the most reasonable 76 //uses of .. 77 break; 78 } else if (i > 0) { 79 name.splice(i - 1, 2); 80 i -= 2; 81 } 82 } 83 } 84 //end trimDots 85 86 name = name.join("/"); 87 } else if (name.indexOf('./') === 0) { 88 // No baseName, so this is ID is resolved relative 89 // to baseUrl, pull off the leading dot. 90 name = name.substring(2); 91 } 92 } 93 94 //Apply map config if available. 95 if ((baseParts || starMap) && map) {
vendor: 18,550 bytes, lines 96-636
96 nameParts = name.split('/'); 97 98 for (i = nameParts.length; i > 0; i -= 1) { 99 nameSegment = nameParts.slice(0, i).join("/"); 100 101 if (baseParts) { 102 //Find the longest baseName segment match in the config. 103 //So, do joins on the biggest to smallest lengths of baseParts. 104 for (j = baseParts.length; j > 0; j -= 1) { 105 mapValue = map[baseParts.slice(0, j).join('/')]; 106 107 //baseName segment has config, find if it has one for 108 //this name. 109 if (mapValue) { 110 mapValue = mapValue[nameSegment]; 111 if (mapValue) { 112 //Match, update name to the new value. 113 foundMap = mapValue; 114 foundI = i; 115 break; 116 } 117 } 118 } 119 } 120 121 if (foundMap) { 122 break; 123 } 124 125 //Check for a star map match, but just hold on to it, 126 //if there is a shorter segment match later in a matching 127 //config, then favor over this star map. 128 if (!foundStarMap && starMap && starMap[nameSegment]) { 129 foundStarMap = starMap[nameSegment]; 130 starI = i; 131 } 132 } 133 134 if (!foundMap && foundStarMap) { 135 foundMap = foundStarMap; 136 foundI = starI; 137 } 138 139 if (foundMap) { 140 nameParts.splice(0, foundI, foundMap); 141 name = nameParts.join('/'); 142 } 143 } 144 145 return name; 146 } 147 148 function makeRequire(relName, forceSync) { 149 return function () { 150 //A version of a require function that passes a moduleName 151 //value for items that may need to 152 //look up paths relative to the moduleName 153 return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync])); 154 }; 155 } 156 157 function makeNormalize(relName) { 158 return function (name) { 159 return normalize(name, relName); 160 }; 161 } 162 163 function makeLoad(depName) { 164 return function (value) { 165 defined[depName] = value; 166 }; 167 } 168 169 function callDep(name) { 170 if (hasProp(waiting, name)) { 171 var args = waiting[name]; 172 delete waiting[name]; 173 defining[name] = true; 174 main.apply(undef, args); 175 } 176 177 if (!hasProp(defined, name) && !hasProp(defining, name)) { 178 throw new Error('No ' + name); 179 } 180 return defined[name]; 181 } 182 183 //Turns a plugin!resource to [plugin, resource] 184 //with the plugin being undefined if the name 185 //did not have a plugin prefix. 186 function splitPrefix(name) { 187 var prefix, 188 index = name ? name.indexOf('!') : -1; 189 if (index > -1) { 190 prefix = name.substring(0, index); 191 name = name.substring(index + 1, name.length); 192 } 193 return [prefix, name]; 194 } 195 196 /** 197 * Makes a name map, normalizing the name, and using a plugin 198 * for normalization if necessary. Grabs a ref to plugin 199 * too, as an optimization. 200 */ 201 makeMap = function (name, relName) { 202 var plugin, 203 parts = splitPrefix(name), 204 prefix = parts[0]; 205 206 name = parts[1]; 207 208 if (prefix) { 209 prefix = normalize(prefix, relName); 210 plugin = callDep(prefix); 211 } 212 213 //Normalize according 214 if (prefix) { 215 if (plugin && plugin.normalize) { 216 name = plugin.normalize(name, makeNormalize(relName)); 217 } else { 218 name = normalize(name, relName); 219 } 220 } else { 221 name = normalize(name, relName); 222 parts = splitPrefix(name); 223 prefix = parts[0]; 224 name = parts[1]; 225 if (prefix) { 226 plugin = callDep(prefix); 227 } 228 } 229 230 //Using ridiculous property names for space reasons 231 return { 232 f: prefix ? prefix + '!' + name : name, //fullName 233 n: name, 234 pr: prefix, 235 p: plugin 236 }; 237 }; 238 239 function makeConfig(name) { 240 return function () { 241 return (config && config.config && config.config[name]) || {}; 242 }; 243 } 244 245 handlers = { 246 require: function (name) { 247 return makeRequire(name); 248 }, 249 exports: function (name) { 250 var e = defined[name]; 251 if (typeof e !== 'undefined') { 252 return e; 253 } else { 254 return (defined[name] = {}); 255 } 256 }, 257 module: function (name) { 258 return { 259 id: name, 260 uri: '', 261 exports: defined[name], 262 config: makeConfig(name) 263 }; 264 } 265 }; 266 267 main = function (name, deps, callback, relName) { 268 var cjsModule, depName, ret, map, i, 269 args = [], 270 callbackType = typeof callback, 271 usingExports; 272 273 //Use name if no relName 274 relName = relName || name; 275 276 //Call the callback to define the module, if necessary. 277 if (callbackType === 'undefined' || callbackType === 'function') { 278 //Pull out the defined dependencies and pass the ordered 279 //values to the callback. 280 //Default to [require, exports, module] if no deps 281 deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; 282 for (i = 0; i < deps.length; i += 1) { 283 map = makeMap(deps[i], relName); 284 depName = map.f; 285 286 //Fast path CommonJS standard dependencies. 287 if (depName === "require") { 288 args[i] = handlers.require(name); 289 } else if (depName === "exports") { 290 //CommonJS module spec 1.1 291 args[i] = handlers.exports(name); 292 usingExports = true; 293 } else if (depName === "module") { 294 //CommonJS module spec 1.1 295 cjsModule = args[i] = handlers.module(name); 296 } else if (hasProp(defined, depName) || 297 hasProp(waiting, depName) || 298 hasProp(defining, depName)) { 299 args[i] = callDep(depName); 300 } else if (map.p) { 301 map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); 302 args[i] = defined[depName]; 303 } else { 304 throw new Error(name + ' missing ' + depName); 305 } 306 } 307 308 ret = callback ? callback.apply(defined[name], args) : undefined; 309 310 if (name) { 311 //If setting exports via "module" is in play, 312 //favor that over return value and exports. After that, 313 //favor a non-undefined return value over exports use. 314 if (cjsModule && cjsModule.exports !== undef && 315 cjsModule.exports !== defined[name]) { 316 defined[name] = cjsModule.exports; 317 } else if (ret !== undef || !usingExports) { 318 //Use the return value from the function. 319 defined[name] = ret; 320 } 321 } 322 } else if (name) { 323 //May just be an object definition for the module. Only 324 //worry about defining if have a module name. 325 defined[name] = callback; 326 } 327 }; 328 329 requirejs = require = req = function (deps, callback, relName, forceSync, alt) { 330 if (typeof deps === "string") { 331 if (handlers[deps]) { 332 //callback in this case is really relName 333 return handlers[deps](callback); 334 } 335 //Just return the module wanted. In this scenario, the 336 //deps arg is the module name, and second arg (if passed) 337 //is just the relName. 338 //Normalize module name, if it contains . or .. 339 return callDep(makeMap(deps, callback).f); 340 } else if (!deps.splice) { 341 //deps is a config object, not an array. 342 config = deps; 343 if (config.deps) { 344 req(config.deps, config.callback); 345 } 346 if (!callback) { 347 return; 348 } 349 350 if (callback.splice) { 351 //callback is an array, which means it is a dependency list. 352 //Adjust args if there are dependencies 353 deps = callback; 354 callback = relName; 355 relName = null; 356 } else { 357 deps = undef; 358 } 359 } 360 361 //Support require(['a']) 362 callback = callback || function () {}; 363 364 //If relName is a function, it is an errback handler, 365 //so remove it. 366 if (typeof relName === 'function') { 367 relName = forceSync; 368 forceSync = alt; 369 } 370 371 //Simulate async callback; 372 if (forceSync) { 373 main(undef, deps, callback, relName); 374 } else { 375 //Using a non-zero value because of concern for what old browsers 376 //do, and latest browsers "upgrade" to 4 if lower value is used: 377 //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout: 378 //If want a value immediately, use require('id') instead -- something 379 //that works in almond on the global level, but not guaranteed and 380 //unlikely to work in other AMD implementations. 381 setTimeout(function () { 382 main(undef, deps, callback, relName); 383 }, 4); 384 } 385 386 return req; 387 }; 388 389 /** 390 * Just drops the config on the floor, but returns req in case 391 * the config return value is used. 392 */ 393 req.config = function (cfg) { 394 return req(cfg); 395 }; 396 397 /** 398 * Expose module registry for debugging and tooling 399 */ 400 requirejs._defined = defined; 401 402 define = function (name, deps, callback) { 403 404 //This module may not have dependencies 405 if (!deps.splice) { 406 //deps is not an array, so probably means 407 //an object literal or factory function for 408 //the value. Adjust args. 409 callback = deps; 410 deps = []; 411 } 412 413 if (!hasProp(defined, name) && !hasProp(waiting, name)) { 414 waiting[name] = [name, deps, callback]; 415 } 416 }; 417 418 define.amd = { 419 jQuery: true 420 }; 421 }()); 422 423 define("almond", function(){}); 424 425 define('jquery',[],function () { 426 var _$ = jQuery || $; 427 428 if (_$ == null && console && console.error) { 429 console.error( 430 'Select2: An instance of jQuery or a jQuery-compatible library was not ' + 431 'found. Make sure that you are including jQuery before Select2 on your ' + 432 'web page.' 433 ); 434 } 435 436 return _$; 437 }); 438 439 define('select2/utils',[], function () { 440 var Utils = {}; 441 442 Utils.Extend = function (ChildClass, SuperClass) { 443 var __hasProp = {}.hasOwnProperty; 444 445 function BaseConstructor () { 446 this.constructor = ChildClass; 447 } 448 449 for (var key in SuperClass) { 450 if (__hasProp.call(SuperClass, key)) { 451 ChildClass[key] = SuperClass[key]; 452 } 453 } 454 455 BaseConstructor.prototype = SuperClass.prototype; 456 ChildClass.prototype = new BaseConstructor(); 457 ChildClass.__super__ = SuperClass.prototype; 458 459 return ChildClass; 460 }; 461 462 function getMethods (theClass) { 463 var proto = theClass.prototype; 464 465 var methods = []; 466 467 for (var methodName in proto) { 468 var m = proto[methodName]; 469 470 if (typeof m !== 'function') { 471 continue; 472 } 473 474 if (methodName === 'constructor') { 475 continue; 476 } 477 478 methods.push(methodName); 479 } 480 481 return methods; 482 } 483 484 Utils.Decorate = function (SuperClass, DecoratorClass) { 485 var decoratedMethods = getMethods(DecoratorClass); 486 var superMethods = getMethods(SuperClass); 487 488 function DecoratedClass () { 489 var unshift = Array.prototype.unshift; 490 491 var argCount = DecoratorClass.prototype.constructor.length; 492 493 var calledConstructor = SuperClass.prototype.constructor; 494 495 if (argCount > 0) { 496 unshift.call(arguments, SuperClass.prototype.constructor); 497 498 calledConstructor = DecoratorClass.prototype.constructor; 499 } 500 501 calledConstructor.apply(this, arguments); 502 } 503 504 DecoratorClass.displayName = SuperClass.displayName; 505 506 function ctr () { 507 this.constructor = DecoratedClass; 508 } 509 510 DecoratedClass.prototype = new ctr(); 511 512 for (var m = 0; m < superMethods.length; m++) { 513 var superMethod = superMethods[m]; 514 515 DecoratedClass.prototype[superMethod] = 516 SuperClass.prototype[superMethod]; 517 } 518 519 var calledMethod = function (methodName) { 520 // Stub out the original method if it's not decorating an actual method 521 var originalMethod = function () {}; 522 523 if (methodName in DecoratedClass.prototype) { 524 originalMethod = DecoratedClass.prototype[methodName]; 525 } 526 527 var decoratedMethod = DecoratorClass.prototype[methodName]; 528 529 return function () { 530 var unshift = Array.prototype.unshift; 531 532 unshift.call(arguments, originalMethod); 533 534 return decoratedMethod.apply(this, arguments); 535 }; 536 }; 537 538 for (var d = 0; d < decoratedMethods.length; d++) { 539 var decoratedMethod = decoratedMethods[d]; 540 541 DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod); 542 } 543 544 return DecoratedClass; 545 }; 546 547 var Observable = function () { 548 this.listeners = {}; 549 }; 550 551 Observable.prototype.on = function (event, callback) { 552 this.listeners = this.listeners || {}; 553 554 if (event in this.listeners) { 555 this.listeners[event].push(callback); 556 } else { 557 this.listeners[event] = [callback]; 558 } 559 }; 560 561 Observable.prototype.trigger = function (event) { 562 var slice = Array.prototype.slice; 563 564 this.listeners = this.listeners || {}; 565 566 if (event in this.listeners) { 567 this.invoke(this.listeners[event], slice.call(arguments, 1)); 568 } 569 570 if ('*' in this.listeners) { 571 this.invoke(this.listeners['*'], arguments); 572 } 573 }; 574 575 Observable.prototype.invoke = function (listeners, params) { 576 for (var i = 0, len = listeners.length; i < len; i++) { 577 listeners[i].apply(this, params); 578 } 579 }; 580 581 Utils.Observable = Observable; 582 583 Utils.generateChars = function (length) { 584 var chars = ''; 585 586 for (var i = 0; i < length; i++) { 587 var randomChar = Math.floor(Math.random() * 36); 588 chars += randomChar.toString(36); 589 } 590 591 return chars; 592 }; 593 594 Utils.bind = function (func, context) { 595 return function () { 596 func.apply(context, arguments); 597 }; 598 }; 599 600 Utils._convertData = function (data) { 601 for (var originalKey in data) { 602 var keys = originalKey.split('-'); 603 604 var dataLevel = data; 605 606 if (keys.length === 1) { 607 continue; 608 } 609 610 for (var k = 0; k < keys.length; k++) { 611 var key = keys[k]; 612 613 // Lowercase the first letter 614 // By default, dash-separated becomes camelCase 615 key = key.substring(0, 1).toLowerCase() + key.substring(1); 616 617 if (!(key in dataLevel)) { 618 dataLevel[key] = {}; 619 } 620 621 if (k == keys.length - 1) { 622 dataLevel[key] = data[originalKey]; 623 } 624 625 dataLevel = dataLevel[key]; 626 } 627 628 delete data[originalKey]; 629 } 630 631 return data; 632 }; 633 634 Utils.hasScroll = function (index, el) { 635 // Adapted from the function created by @ShadowScripter 636 // and adapted by @BillBarry on the Stack Exchange Code Review website.
vendor: 49,852 bytes, lines 637-2321
637 // The original code can be found at 638 // http://codereview.stackexchange.com/q/13338 639 // and was designed to be used with the Sizzle selector engine. 640 641 var $el = $(el); 642 var overflowX = el.style.overflowX; 643 var overflowY = el.style.overflowY; 644 645 //Check both x and y declarations 646 if (overflowX === overflowY && 647 (overflowY === 'hidden' || overflowY === 'visible')) { 648 return false; 649 } 650 651 if (overflowX === 'scroll' || overflowY === 'scroll') { 652 return true; 653 } 654 655 return ($el.innerHeight() < el.scrollHeight || 656 $el.innerWidth() < el.scrollWidth); 657 }; 658 659 return Utils; 660 }); 661 662 define('select2/results',[ 663 'jquery', 664 './utils' 665 ], function ($, Utils) { 666 function Results ($element, options, dataAdapter) { 667 this.$element = $element; 668 this.data = dataAdapter; 669 this.options = options; 670 671 Results.__super__.constructor.call(this); 672 } 673 674 Utils.Extend(Results, Utils.Observable); 675 676 Results.prototype.render = function () { 677 var $results = $( 678 '<ul class="select2-results__options" role="tree"></ul>' 679 ); 680 681 if (this.options.get('multiple')) { 682 $results.attr('aria-multiselectable', 'true'); 683 } 684 685 this.$results = $results; 686 687 return $results; 688 }; 689 690 Results.prototype.clear = function () { 691 this.$results.empty(); 692 }; 693 694 Results.prototype.displayMessage = function (params) { 695 this.clear(); 696 this.hideLoading(); 697 698 var $message = $( 699 '<li role="treeitem" class="select2-results__option"></li>' 700 ); 701 702 var message = this.options.get('translations').get(params.message); 703 704 $message.text(message(params.args)); 705 706 this.$results.append($message); 707 }; 708 709 Results.prototype.append = function (data) { 710 this.hideLoading(); 711 712 var $options = []; 713 714 if (data.results == null || data.results.length === 0) { 715 if (this.$results.children().length === 0) { 716 this.trigger('results:message', { 717 message: 'noResults' 718 }); 719 } 720 721 return; 722 } 723 724 data.results = this.sort(data.results); 725 726 for (var d = 0; d < data.results.length; d++) { 727 var item = data.results[d]; 728 729 var $option = this.option(item); 730 731 $options.push($option); 732 } 733 734 this.$results.append($options); 735 }; 736 737 Results.prototype.position = function ($results, $dropdown) { 738 var $resultsContainer = $dropdown.find('.select2-results'); 739 $resultsContainer.append($results); 740 }; 741 742 Results.prototype.sort = function (data) { 743 var sorter = this.options.get('sorter'); 744 745 return sorter(data); 746 }; 747 748 Results.prototype.setClasses = function () { 749 var self = this; 750 751 this.data.current(function (selected) { 752 var selectedIds = $.map(selected, function (s) { 753 return s.id.toString(); 754 }); 755 756 var $options = self.$results 757 .find('.select2-results__option[aria-selected]'); 758 759 $options.each(function () { 760 var $option = $(this); 761 762 var item = $.data(this, 'data'); 763 764 if (item.id != null && selectedIds.indexOf(item.id.toString()) > -1) { 765 $option.attr('aria-selected', 'true'); 766 } else { 767 $option.attr('aria-selected', 'false'); 768 } 769 }); 770 771 var $selected = $options.filter('[aria-selected=true]'); 772 773 // Check if there are any selected options 774 if ($selected.length > 0) { 775 // If there are selected options, highlight the first 776 $selected.first().trigger('mouseenter'); 777 } else { 778 // If there are no selected options, highlight the first option 779 // in the dropdown 780 $options.first().trigger('mouseenter'); 781 } 782 }); 783 }; 784 785 Results.prototype.showLoading = function (params) { 786 this.hideLoading(); 787 788 var loadingMore = this.options.get('translations').get('searching'); 789 790 var loading = { 791 disabled: true, 792 loading: true, 793 text: loadingMore(params) 794 }; 795 var $loading = this.option(loading); 796 $loading.className += ' loading-results'; 797 798 this.$results.prepend($loading); 799 }; 800 801 Results.prototype.hideLoading = function () { 802 this.$results.find('.loading-results').remove(); 803 }; 804 805 Results.prototype.option = function (data) { 806 var option = document.createElement('li'); 807 option.className = 'select2-results__option'; 808 809 var attrs = { 810 'role': 'treeitem', 811 'aria-selected': 'false' 812 }; 813 814 if (data.disabled) { 815 delete attrs['aria-selected']; 816 attrs['aria-disabled'] = 'true'; 817 } 818 819 if (data.id == null) { 820 delete attrs['aria-selected']; 821 } 822 823 if (data._resultId != null) { 824 option.id = data._resultId; 825 } 826 827 if (data.children) { 828 attrs.role = 'group'; 829 attrs['aria-label'] = data.text; 830 delete attrs['aria-selected']; 831 } 832 833 for (var attr in attrs) { 834 var val = attrs[attr]; 835 836 option.setAttribute(attr, val); 837 } 838 839 if (data.children) { 840 var $option = $(option); 841 842 var label = document.createElement('strong'); 843 label.className = 'select2-results__group'; 844 845 var $label = $(label); 846 this.template(data, label); 847 848 var $children = []; 849 850 for (var c = 0; c < data.children.length; c++) { 851 var child = data.children[c]; 852 853 var $child = this.option(child); 854 855 $children.push($child); 856 } 857 858 var $childrenContainer = $('<ul></ul>', { 859 'class': 'select2-results__options select2-results__options--nested' 860 }); 861 862 $childrenContainer.append($children); 863 864 $option.append(label); 865 $option.append($childrenContainer); 866 } else { 867 this.template(data, option); 868 } 869 870 $.data(option, 'data', data); 871 872 return option; 873 }; 874 875 Results.prototype.bind = function (container, $container) { 876 var self = this; 877 878 var id = container.id + '-results'; 879 880 this.$results.attr('id', id); 881 882 container.on('results:all', function (params) { 883 self.clear(); 884 self.append(params.data); 885 886 if (container.isOpen()) { 887 self.setClasses(); 888 } 889 }); 890 891 container.on('results:append', function (params) { 892 self.append(params.data); 893 894 if (container.isOpen()) { 895 self.setClasses(); 896 } 897 }); 898 899 container.on('query', function (params) { 900 self.showLoading(params); 901 }); 902 903 container.on('select', function () { 904 if (!container.isOpen()) { 905 return; 906 } 907 908 self.setClasses(); 909 }); 910 911 container.on('unselect', function () { 912 if (!container.isOpen()) { 913 return; 914 } 915 916 self.setClasses(); 917 }); 918 919 container.on('open', function () { 920 // When the dropdown is open, aria-expended="true" 921 self.$results.attr('aria-expanded', 'true'); 922 self.$results.attr('aria-hidden', 'false'); 923 924 self.setClasses(); 925 self.ensureHighlightVisible(); 926 }); 927 928 container.on('close', function () { 929 // When the dropdown is closed, aria-expended="false" 930 self.$results.attr('aria-expanded', 'false'); 931 self.$results.attr('aria-hidden', 'true'); 932 self.$results.removeAttr('aria-activedescendant'); 933 }); 934 935 container.on('results:select', function () { 936 var $highlighted = self.getHighlightedResults(); 937 938 if ($highlighted.length === 0) { 939 return; 940 } 941 942 var data = $highlighted.data('data'); 943 944 if ($highlighted.attr('aria-selected') == 'true') { 945 if (self.options.get('multiple')) { 946 self.trigger('unselect', { 947 data: data 948 }); 949 } else { 950 self.trigger('close'); 951 } 952 } else { 953 self.trigger('select', { 954 data: data 955 }); 956 } 957 }); 958 959 container.on('results:previous', function () { 960 var $highlighted = self.getHighlightedResults(); 961 962 var $options = self.$results.find('[aria-selected]'); 963 964 var currentIndex = $options.index($highlighted); 965 966 // If we are already at te top, don't move further 967 if (currentIndex === 0) { 968 return; 969 } 970 971 var nextIndex = currentIndex - 1; 972 973 // If none are highlighted, highlight the first 974 if ($highlighted.length === 0) { 975 nextIndex = 0; 976 } 977 978 var $next = $options.eq(nextIndex); 979 980 $next.trigger('mouseenter'); 981 982 var currentOffset = self.$results.offset().top; 983 var nextTop = $next.offset().top; 984 var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset); 985 986 if (nextIndex === 0) { 987 self.$results.scrollTop(0); 988 } else if (nextTop - currentOffset < 0) { 989 self.$results.scrollTop(nextOffset); 990 } 991 }); 992 993 container.on('results:next', function () { 994 var $highlighted = self.getHighlightedResults(); 995 996 var $options = self.$results.find('[aria-selected]'); 997 998 var currentIndex = $options.index($highlighted); 999 1000 var nextIndex = currentIndex + 1; 1001 1002 // If we are at the last option, stay there 1003 if (nextIndex >= $options.length) { 1004 return; 1005 } 1006 1007 var $next = $options.eq(nextIndex); 1008 1009 $next.trigger('mouseenter'); 1010 1011 var currentOffset = self.$results.offset().top + 1012 self.$results.outerHeight(false); 1013 var nextBottom = $next.offset().top + $next.outerHeight(false); 1014 var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset; 1015 1016 if (nextIndex === 0) { 1017 self.$results.scrollTop(0); 1018 } else if (nextBottom > currentOffset) { 1019 self.$results.scrollTop(nextOffset); 1020 } 1021 }); 1022 1023 container.on('results:focus', function (params) { 1024 params.element.addClass('select2-results__option--highlighted'); 1025 }); 1026 1027 container.on('results:message', function (params) { 1028 self.displayMessage(params); 1029 }); 1030 1031 if ($.fn.mousewheel) { 1032 this.$results.on('mousewheel', function (e) { 1033 var top = self.$results.scrollTop(); 1034 1035 var bottom = ( 1036 self.$results.get(0).scrollHeight - 1037 self.$results.scrollTop() + 1038 e.deltaY 1039 ); 1040 1041 var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0; 1042 var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height(); 1043 1044 if (isAtTop) { 1045 self.$results.scrollTop(0); 1046 1047 e.preventDefault(); 1048 e.stopPropagation(); 1049 } else if (isAtBottom) { 1050 self.$results.scrollTop( 1051 self.$results.get(0).scrollHeight - self.$results.height() 1052 ); 1053 1054 e.preventDefault(); 1055 e.stopPropagation(); 1056 } 1057 }); 1058 } 1059 1060 this.$results.on('mouseup', '.select2-results__option[aria-selected]', 1061 function (evt) { 1062 var $this = $(this); 1063 1064 var data = $this.data('data'); 1065 1066 if ($this.attr('aria-selected') === 'true') { 1067 if (self.options.get('multiple')) { 1068 self.trigger('unselect', { 1069 originalEvent: evt, 1070 data: data 1071 }); 1072 } else { 1073 self.trigger('close'); 1074 } 1075 1076 return; 1077 } 1078 1079 self.trigger('select', { 1080 originalEvent: evt, 1081 data: data 1082 }); 1083 }); 1084 1085 this.$results.on('mouseenter', '.select2-results__option[aria-selected]', 1086 function (evt) { 1087 var data = $(this).data('data'); 1088 1089 self.getHighlightedResults() 1090 .removeClass('select2-results__option--highlighted'); 1091 1092 self.trigger('results:focus', { 1093 data: data, 1094 element: $(this) 1095 }); 1096 }); 1097 }; 1098 1099 Results.prototype.getHighlightedResults = function () { 1100 var $highlighted = this.$results 1101 .find('.select2-results__option--highlighted'); 1102 1103 return $highlighted; 1104 }; 1105 1106 Results.prototype.destroy = function () { 1107 this.$results.remove(); 1108 }; 1109 1110 Results.prototype.ensureHighlightVisible = function () { 1111 var $highlighted = this.getHighlightedResults(); 1112 1113 if ($highlighted.length === 0) { 1114 return; 1115 } 1116 1117 var $options = this.$results.find('[aria-selected]'); 1118 1119 var currentIndex = $options.index($highlighted); 1120 1121 var currentOffset = this.$results.offset().top; 1122 var nextTop = $highlighted.offset().top; 1123 var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset); 1124 1125 var offsetDelta = nextTop - currentOffset; 1126 nextOffset -= $highlighted.outerHeight(false) * 2; 1127 1128 if (currentIndex <= 2) { 1129 this.$results.scrollTop(0); 1130 } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) { 1131 this.$results.scrollTop(nextOffset); 1132 } 1133 }; 1134 1135 Results.prototype.template = function (result, container) { 1136 var template = this.options.get('templateResult'); 1137 1138 var content = template(result); 1139 1140 if (content == null) { 1141 container.style.display = 'none'; 1142 } else { 1143 container.innerHTML = content; 1144 } 1145 }; 1146 1147 return Results; 1148 }); 1149 1150 define('select2/keys',[ 1151 1152 ], function () { 1153 var KEYS = { 1154 BACKSPACE: 8, 1155 TAB: 9, 1156 ENTER: 13, 1157 SHIFT: 16, 1158 CTRL: 17, 1159 ALT: 18, 1160 ESC: 27, 1161 SPACE: 32, 1162 PAGE_UP: 33, 1163 PAGE_DOWN: 34, 1164 END: 35, 1165 HOME: 36, 1166 LEFT: 37, 1167 UP: 38, 1168 RIGHT: 39, 1169 DOWN: 40, 1170 DELETE: 46, 1171 1172 isArrow: function (k) { 1173 k = k.which ? k.which : k; 1174 1175 switch (k) { 1176 case KEY.LEFT: 1177 case KEY.RIGHT: 1178 case KEY.UP: 1179 case KEY.DOWN: 1180 return true; 1181 } 1182 1183 return false; 1184 } 1185 }; 1186 1187 return KEYS; 1188 }); 1189 1190 define('select2/selection/base',[ 1191 'jquery', 1192 '../utils', 1193 '../keys' 1194 ], function ($, Utils, KEYS) { 1195 function BaseSelection ($element, options) { 1196 this.$element = $element; 1197 this.options = options; 1198 1199 BaseSelection.__super__.constructor.call(this); 1200 } 1201 1202 Utils.Extend(BaseSelection, Utils.Observable); 1203 1204 BaseSelection.prototype.render = function () { 1205 var $selection = $( 1206 '<span class="select2-selection" tabindex="0" role="combobox" ' + 1207 'aria-autocomplete="list" aria-haspopup="true" aria-expanded="false">' + 1208 '</span>' 1209 ); 1210 1211 $selection.attr('title', this.$element.attr('title')); 1212 1213 this.$selection = $selection; 1214 1215 return $selection; 1216 }; 1217 1218 BaseSelection.prototype.bind = function (container, $container) { 1219 var self = this; 1220 1221 var id = container.id + '-container'; 1222 var resultsId = container.id + '-results'; 1223 1224 this.container = container; 1225 1226 this.$selection.attr('aria-owns', resultsId); 1227 1228 this.$selection.on('keydown', function (evt) { 1229 self.trigger('keypress', evt); 1230 1231 if (evt.which === KEYS.SPACE) { 1232 evt.preventDefault(); 1233 } 1234 }); 1235 1236 container.on('results:focus', function (params) { 1237 self.$selection.attr('aria-activedescendant', params.data._resultId); 1238 }); 1239 1240 container.on('selection:update', function (params) { 1241 self.update(params.data); 1242 }); 1243 1244 container.on('open', function () { 1245 // When the dropdown is open, aria-expanded="true" 1246 self.$selection.attr('aria-expanded', 'true'); 1247 1248 self._attachCloseHandler(container); 1249 }); 1250 1251 container.on('close', function () { 1252 // When the dropdown is closed, aria-expanded="false" 1253 self.$selection.attr('aria-expanded', 'false'); 1254 self.$selection.removeAttr('aria-activedescendant'); 1255 1256 self.$selection.focus(); 1257 1258 self._detachCloseHandler(container); 1259 }); 1260 1261 container.on('enable', function () { 1262 self.$selection.attr('tabindex', '0'); 1263 }); 1264 1265 container.on('disable', function () { 1266 self.$selection.attr('tabindex', '-1'); 1267 }); 1268 }; 1269 1270 BaseSelection.prototype._attachCloseHandler = function (container) { 1271 var self = this; 1272 1273 $(document.body).on('mousedown.select2.' + container.id, function (e) { 1274 var $target = $(e.target); 1275 1276 var $select = $target.closest('.select2'); 1277 1278 var $all = $('.select2.select2-container--open'); 1279 1280 $all.each(function () { 1281 var $this = $(this); 1282 1283 if (this == $select[0]) { 1284 return; 1285 } 1286 1287 var $element = $this.data('element'); 1288 1289 $element.select2('close'); 1290 }); 1291 }); 1292 }; 1293 1294 BaseSelection.prototype._detachCloseHandler = function (container) { 1295 $(document.body).off('mousedown.select2.' + container.id); 1296 }; 1297 1298 BaseSelection.prototype.position = function ($selection, $container) { 1299 var $selectionContainer = $container.find('.selection'); 1300 $selectionContainer.append($selection); 1301 }; 1302 1303 BaseSelection.prototype.destroy = function () { 1304 this._detachCloseHandler(this.container); 1305 }; 1306 1307 BaseSelection.prototype.update = function (data) { 1308 throw new Error('The `update` method must be defined in child classes.'); 1309 }; 1310 1311 return BaseSelection; 1312 }); 1313 1314 define('select2/selection/single',[ 1315 'jquery', 1316 './base', 1317 '../utils', 1318 '../keys' 1319 ], function ($, BaseSelection, Utils, KEYS) { 1320 function SingleSelection () { 1321 SingleSelection.__super__.constructor.apply(this, arguments); 1322 } 1323 1324 Utils.Extend(SingleSelection, BaseSelection); 1325 1326 SingleSelection.prototype.render = function () { 1327 var $selection = SingleSelection.__super__.render.call(this); 1328 1329 $selection.addClass('select2-selection--single'); 1330 1331 $selection.html( 1332 '<span class="select2-selection__rendered"></span>' + 1333 '<span class="select2-selection__arrow" role="presentation">' + 1334 '<b role="presentation"></b>' + 1335 '</span>' 1336 ); 1337 1338 return $selection; 1339 }; 1340 1341 SingleSelection.prototype.bind = function (container, $container) { 1342 var self = this; 1343 1344 SingleSelection.__super__.bind.apply(this, arguments); 1345 1346 var id = container.id + '-container'; 1347 1348 this.$selection.find('.select2-selection__rendered').attr('id', id); 1349 this.$selection.attr('aria-labelledby', id); 1350 1351 this.$selection.on('mousedown', function (evt) { 1352 // Only respond to left clicks 1353 if (evt.which !== 1) { 1354 return; 1355 } 1356 1357 self.trigger('toggle', { 1358 originalEvent: evt 1359 }); 1360 }); 1361 1362 this.$selection.on('focus', function (evt) { 1363 // User focuses on the container 1364 }); 1365 1366 this.$selection.on('blur', function (evt) { 1367 // User exits the container 1368 }); 1369 1370 container.on('selection:update', function (params) { 1371 self.update(params.data); 1372 }); 1373 }; 1374 1375 SingleSelection.prototype.clear = function () { 1376 this.$selection.find('.select2-selection__rendered').empty(); 1377 }; 1378 1379 SingleSelection.prototype.display = function (data) { 1380 var template = this.options.get('templateSelection'); 1381 1382 return template(data); 1383 }; 1384 1385 SingleSelection.prototype.selectionContainer = function () { 1386 return $('<span></span>'); 1387 }; 1388 1389 SingleSelection.prototype.update = function (data) { 1390 if (data.length === 0) { 1391 this.clear(); 1392 return; 1393 } 1394 1395 var selection = data[0]; 1396 1397 var formatted = this.display(selection); 1398 1399 this.$selection.find('.select2-selection__rendered').html(formatted); 1400 }; 1401 1402 return SingleSelection; 1403 }); 1404 1405 define('select2/selection/multiple',[ 1406 'jquery', 1407 './base', 1408 '../utils' 1409 ], function ($, BaseSelection, Utils) { 1410 function MultipleSelection ($element, options) { 1411 MultipleSelection.__super__.constructor.apply(this, arguments); 1412 } 1413 1414 Utils.Extend(MultipleSelection, BaseSelection); 1415 1416 MultipleSelection.prototype.render = function () { 1417 var $selection = MultipleSelection.__super__.render.call(this); 1418 1419 $selection.addClass('select2-selection--multiple'); 1420 1421 $selection.html( 1422 '<ul class="select2-selection__rendered"></ul>' 1423 ); 1424 1425 return $selection; 1426 }; 1427 1428 MultipleSelection.prototype.bind = function (container, $container) { 1429 var self = this; 1430 1431 MultipleSelection.__super__.bind.apply(this, arguments); 1432 1433 this.$selection.on('click', function (evt) { 1434 self.trigger('toggle', { 1435 originalEvent: evt 1436 }); 1437 }); 1438 1439 this.$selection.on('click', '.select2-selection__choice__remove', 1440 function (evt) { 1441 var $remove = $(this); 1442 var $selection = $remove.parent(); 1443 1444 var data = $selection.data('data'); 1445 1446 self.trigger('unselect', { 1447 originalEvent: evt, 1448 data: data 1449 }); 1450 }); 1451 }; 1452 1453 MultipleSelection.prototype.clear = function () { 1454 this.$selection.find('.select2-selection__rendered').empty(); 1455 }; 1456 1457 MultipleSelection.prototype.display = function (data) { 1458 var template = this.options.get('templateSelection'); 1459 1460 return template(data); 1461 }; 1462 1463 MultipleSelection.prototype.selectionContainer = function () { 1464 var $container = $( 1465 '<li class="select2-selection__choice">' + 1466 '<span class="select2-selection__choice__remove" role="presentation">' + 1467 '×' + 1468 '</span>' + 1469 '</li>' 1470 ); 1471 1472 return $container; 1473 }; 1474 1475 MultipleSelection.prototype.update = function (data) { 1476 this.clear(); 1477 1478 if (data.length === 0) { 1479 return; 1480 } 1481 1482 var $selections = []; 1483 1484 for (var d = 0; d < data.length; d++) { 1485 var selection = data[d]; 1486 1487 var formatted = this.display(selection); 1488 var $selection = this.selectionContainer(); 1489 1490 $selection.append(formatted); 1491 $selection.data('data', selection); 1492 1493 $selections.push($selection); 1494 } 1495 1496 this.$selection.find('.select2-selection__rendered').append($selections); 1497 }; 1498 1499 return MultipleSelection; 1500 }); 1501 1502 define('select2/selection/placeholder',[ 1503 '../utils' 1504 ], function (Utils) { 1505 function Placeholder (decorated, $element, options) { 1506 this.placeholder = this.normalizePlaceholder(options.get('placeholder')); 1507 1508 decorated.call(this, $element, options); 1509 } 1510 1511 Placeholder.prototype.normalizePlaceholder = function (_, placeholder) { 1512 if (typeof placeholder === 'string') { 1513 placeholder = { 1514 id: '', 1515 text: placeholder 1516 }; 1517 } 1518 1519 return placeholder; 1520 }; 1521 1522 Placeholder.prototype.createPlaceholder = function (decorated, placeholder) { 1523 var $placeholder = this.selectionContainer(); 1524 1525 $placeholder.html(this.display(placeholder)); 1526 $placeholder.addClass('select2-selection__placeholder') 1527 .removeClass('select2-selection__choice'); 1528 1529 return $placeholder; 1530 }; 1531 1532 Placeholder.prototype.update = function (decorated, data) { 1533 var singlePlaceholder = ( 1534 data.length == 1 && data[0].id != this.placeholder.id 1535 ); 1536 var multipleSelections = data.length > 1; 1537 1538 if (multipleSelections || singlePlaceholder) { 1539 return decorated.call(this, data); 1540 } 1541 1542 this.clear(); 1543 1544 var $placeholder = this.createPlaceholder(this.placeholder); 1545 1546 this.$selection.find('.select2-selection__rendered').append($placeholder); 1547 }; 1548 1549 return Placeholder; 1550 }); 1551 1552 define('select2/selection/allowClear',[ 1553 'jquery' 1554 ], function ($) { 1555 function AllowClear () { } 1556 1557 AllowClear.prototype.bind = function (decorated, container, $container) { 1558 var self = this; 1559 1560 decorated.call(this, container, $container); 1561 1562 this.$selection.on('mousedown', '.select2-selection__clear', 1563 function (evt) { 1564 // Ignore the event if it is disabled 1565 if (self.options.get('disabled')) { 1566 return; 1567 } 1568 1569 evt.stopPropagation(); 1570 1571 var data = $(this).data('data'); 1572 1573 for (var d = 0; d < data.length; d++) { 1574 var unselectData = { 1575 data: data[d] 1576 }; 1577 1578 // Trigger the `unselect` event, so people can prevent it from being 1579 // cleared. 1580 self.trigger('unselect', unselectData); 1581 1582 // If the event was prevented, don't clear it out. 1583 if (unselectData.prevented) { 1584 return; 1585 } 1586 } 1587 1588 self.$element.val(self.placeholder.id).trigger('change'); 1589 1590 self.trigger('toggle'); 1591 }); 1592 }; 1593 1594 AllowClear.prototype.update = function (decorated, data) { 1595 decorated.call(this, data); 1596 1597 if (this.$selection.find('.select2-selection__placeholder').length > 0 || 1598 data.length === 0) { 1599 return; 1600 } 1601 1602 var $remove = $( 1603 '<span class="select2-selection__clear">' + 1604 '×' + 1605 '</span>' 1606 ); 1607 $remove.data('data', data); 1608 1609 this.$selection.find('.select2-selection__rendered').append($remove); 1610 }; 1611 1612 return AllowClear; 1613 }); 1614 1615 define('select2/selection/search',[ 1616 'jquery', 1617 '../utils', 1618 '../keys' 1619 ], function ($, Utils, KEYS) { 1620 function Search (decorated, $element, options) { 1621 decorated.call(this, $element, options); 1622 } 1623 1624 Search.prototype.render = function (decorated) { 1625 var $search = $( 1626 '<li class="select2-search select2-search--inline">' + 1627 '<input class="select2-search__field" type="search" tabindex="-1"' + 1628 ' role="textbox" />' + 1629 '</li>' 1630 ); 1631 1632 this.$searchContainer = $search; 1633 this.$search = $search.find('input'); 1634 1635 var $rendered = decorated.call(this); 1636 1637 return $rendered; 1638 }; 1639 1640 Search.prototype.bind = function (decorated, container, $container) { 1641 var self = this; 1642 1643 decorated.call(this, container, $container); 1644 1645 container.on('open', function () { 1646 self.$search.attr('tabindex', 0); 1647 1648 self.$search.focus(); 1649 }); 1650 1651 container.on('close', function () { 1652 self.$search.attr('tabindex', -1); 1653 1654 self.$search.val(''); 1655 }); 1656 1657 container.on('enable', function () { 1658 self.$search.prop('disabled', false); 1659 }); 1660 1661 container.on('disable', function () { 1662 self.$search.prop('disabled', true); 1663 }); 1664 1665 this.$selection.on('keydown', '.select2-search--inline', function (evt) { 1666 evt.stopPropagation(); 1667 1668 self.trigger('keypress', evt); 1669 1670 self._keyUpPrevented = evt.isDefaultPrevented(); 1671 1672 var key = evt.which; 1673 1674 if (key === KEYS.BACKSPACE && self.$search.val() === '') { 1675 var $previousChoice = self.$searchContainer 1676 .prev('.select2-selection__choice'); 1677 1678 if ($previousChoice.length > 0) { 1679 var item = $previousChoice.data('data'); 1680 1681 self.searchRemoveChoice(item); 1682 } 1683 } 1684 }); 1685 1686 this.$selection.on('keyup', '.select2-search--inline', function (evt) { 1687 self.handleSearch(evt); 1688 }); 1689 }; 1690 1691 Search.prototype.createPlaceholder = function (decorated, placeholder) { 1692 this.$search.attr('placeholder', placeholder.text); 1693 }; 1694 1695 Search.prototype.update = function (decorated, data) { 1696 this.$search.attr('placeholder', ''); 1697 1698 decorated.call(this, data); 1699 1700 this.$selection.find('.select2-selection__rendered') 1701 .append(this.$searchContainer); 1702 1703 this.resizeSearch(); 1704 }; 1705 1706 Search.prototype.handleSearch = function () { 1707 this.resizeSearch(); 1708 1709 if (!this._keyUpPrevented) { 1710 var input = this.$search.val(); 1711 1712 this.trigger('query', { 1713 term: input 1714 }); 1715 } 1716 1717 this._keyUpPrevented = false; 1718 }; 1719 1720 Search.prototype.searchRemoveChoice = function (decorated, item) { 1721 this.trigger('unselect', { 1722 data: item 1723 }); 1724 1725 this.trigger('open'); 1726 1727 this.$search.val(item.text + ' '); 1728 }; 1729 1730 Search.prototype.resizeSearch = function () { 1731 this.$search.css('width', '25px'); 1732 1733 var width = ''; 1734 1735 if (this.$search.attr('placeholder') !== '') { 1736 width = this.$selection.find('.select2-selection__rendered').innerWidth(); 1737 } else { 1738 var minimumWidth = this.$search.val().length + 1; 1739 1740 width = (minimumWidth * 0.75) + 'em'; 1741 } 1742 1743 this.$search.css('width', width); 1744 }; 1745 1746 return Search; 1747 }); 1748 1749 define('select2/selection/eventRelay',[ 1750 'jquery' 1751 ], function ($) { 1752 function EventRelay () { } 1753 1754 EventRelay.prototype.bind = function (decorated, container, $container) { 1755 var self = this; 1756 var relayEvents = [ 1757 'open', 'opening', 1758 'close', 'closing', 1759 'select', 'selecting', 1760 'unselect', 'unselecting' 1761 ]; 1762 1763 var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting']; 1764 1765 decorated.call(this, container, $container); 1766 1767 container.on('*', function (name, params) { 1768 // Ignore events that should not be relayed 1769 if (relayEvents.indexOf(name) === -1) { 1770 return; 1771 } 1772 1773 // The parameters should always be an object 1774 params = params || {}; 1775 1776 // Generate the jQuery event for the Select2 event 1777 var evt = $.Event('select2:' + name, { 1778 params: params 1779 }); 1780 1781 self.$element.trigger(evt); 1782 1783 // Only handle preventable events if it was one 1784 if (preventableEvents.indexOf(name) === -1) { 1785 return; 1786 } 1787 1788 params.prevented = evt.isDefaultPrevented(); 1789 }); 1790 }; 1791 1792 return EventRelay; 1793 }); 1794 1795 define('select2/translation',[ 1796 'jquery' 1797 ], function ($) { 1798 function Translation (dict) { 1799 this.dict = dict || {}; 1800 } 1801 1802 Translation.prototype.all = function () { 1803 return this.dict; 1804 }; 1805 1806 Translation.prototype.get = function (key) { 1807 return this.dict[key]; 1808 }; 1809 1810 Translation.prototype.extend = function (translation) { 1811 this.dict = $.extend({}, translation.all(), this.dict); 1812 }; 1813 1814 // Static functions 1815 1816 Translation._cache = {}; 1817 1818 Translation.loadPath = function (path) { 1819 if (!(path in Translation._cache)) { 1820 var translations = require(path); 1821 1822 Translation._cache[path] = translations; 1823 } 1824 1825 return new Translation(Translation._cache[path]); 1826 }; 1827 1828 return Translation; 1829 }); 1830 1831 define('select2/diacritics',[ 1832 1833 ], function () { 1834 var diacritics = { 1835 '\u24B6': 'A', 1836 '\uFF21': 'A', 1837 '\u00C0': 'A', 1838 '\u00C1': 'A', 1839 '\u00C2': 'A', 1840 '\u1EA6': 'A', 1841 '\u1EA4': 'A', 1842 '\u1EAA': 'A', 1843 '\u1EA8': 'A', 1844 '\u00C3': 'A', 1845 '\u0100': 'A', 1846 '\u0102': 'A', 1847 '\u1EB0': 'A', 1848 '\u1EAE': 'A', 1849 '\u1EB4': 'A', 1850 '\u1EB2': 'A', 1851 '\u0226': 'A', 1852 '\u01E0': 'A', 1853 '\u00C4': 'A', 1854 '\u01DE': 'A', 1855 '\u1EA2': 'A', 1856 '\u00C5': 'A', 1857 '\u01FA': 'A', 1858 '\u01CD': 'A', 1859 '\u0200': 'A', 1860 '\u0202': 'A', 1861 '\u1EA0': 'A', 1862 '\u1EAC': 'A', 1863 '\u1EB6': 'A', 1864 '\u1E00': 'A', 1865 '\u0104': 'A', 1866 '\u023A': 'A', 1867 '\u2C6F': 'A', 1868 '\uA732': 'AA', 1869 '\u00C6': 'AE', 1870 '\u01FC': 'AE', 1871 '\u01E2': 'AE', 1872 '\uA734': 'AO', 1873 '\uA736': 'AU', 1874 '\uA738': 'AV', 1875 '\uA73A': 'AV', 1876 '\uA73C': 'AY', 1877 '\u24B7': 'B', 1878 '\uFF22': 'B', 1879 '\u1E02': 'B', 1880 '\u1E04': 'B', 1881 '\u1E06': 'B', 1882 '\u0243': 'B', 1883 '\u0182': 'B', 1884 '\u0181': 'B', 1885 '\u24B8': 'C', 1886 '\uFF23': 'C', 1887 '\u0106': 'C', 1888 '\u0108': 'C', 1889 '\u010A': 'C', 1890 '\u010C': 'C', 1891 '\u00C7': 'C', 1892 '\u1E08': 'C', 1893 '\u0187': 'C', 1894 '\u023B': 'C', 1895 '\uA73E': 'C', 1896 '\u24B9': 'D', 1897 '\uFF24': 'D', 1898 '\u1E0A': 'D', 1899 '\u010E': 'D', 1900 '\u1E0C': 'D', 1901 '\u1E10': 'D', 1902 '\u1E12': 'D', 1903 '\u1E0E': 'D', 1904 '\u0110': 'D', 1905 '\u018B': 'D', 1906 '\u018A': 'D', 1907 '\u0189': 'D', 1908 '\uA779': 'D', 1909 '\u01F1': 'DZ', 1910 '\u01C4': 'DZ', 1911 '\u01F2': 'Dz', 1912 '\u01C5': 'Dz', 1913 '\u24BA': 'E', 1914 '\uFF25': 'E', 1915 '\u00C8': 'E', 1916 '\u00C9': 'E', 1917 '\u00CA': 'E', 1918 '\u1EC0': 'E', 1919 '\u1EBE': 'E', 1920 '\u1EC4': 'E', 1921 '\u1EC2': 'E', 1922 '\u1EBC': 'E', 1923 '\u0112': 'E', 1924 '\u1E14': 'E', 1925 '\u1E16': 'E', 1926 '\u0114': 'E', 1927 '\u0116': 'E', 1928 '\u00CB': 'E', 1929 '\u1EBA': 'E', 1930 '\u011A': 'E', 1931 '\u0204': 'E', 1932 '\u0206': 'E', 1933 '\u1EB8': 'E', 1934 '\u1EC6': 'E', 1935 '\u0228': 'E', 1936 '\u1E1C': 'E', 1937 '\u0118': 'E', 1938 '\u1E18': 'E', 1939 '\u1E1A': 'E', 1940 '\u0190': 'E', 1941 '\u018E': 'E', 1942 '\u24BB': 'F', 1943 '\uFF26': 'F', 1944 '\u1E1E': 'F', 1945 '\u0191': 'F', 1946 '\uA77B': 'F', 1947 '\u24BC': 'G', 1948 '\uFF27': 'G', 1949 '\u01F4': 'G', 1950 '\u011C': 'G', 1951 '\u1E20': 'G', 1952 '\u011E': 'G', 1953 '\u0120': 'G', 1954 '\u01E6': 'G', 1955 '\u0122': 'G', 1956 '\u01E4': 'G', 1957 '\u0193': 'G', 1958 '\uA7A0': 'G', 1959 '\uA77D': 'G', 1960 '\uA77E': 'G', 1961 '\u24BD': 'H', 1962 '\uFF28': 'H', 1963 '\u0124': 'H', 1964 '\u1E22': 'H', 1965 '\u1E26': 'H', 1966 '\u021E': 'H', 1967 '\u1E24': 'H', 1968 '\u1E28': 'H', 1969 '\u1E2A': 'H', 1970 '\u0126': 'H', 1971 '\u2C67': 'H', 1972 '\u2C75': 'H', 1973 '\uA78D': 'H', 1974 '\u24BE': 'I', 1975 '\uFF29': 'I', 1976 '\u00CC': 'I', 1977 '\u00CD': 'I', 1978 '\u00CE': 'I', 1979 '\u0128': 'I', 1980 '\u012A': 'I', 1981 '\u012C': 'I', 1982 '\u0130': 'I', 1983 '\u00CF': 'I', 1984 '\u1E2E': 'I', 1985 '\u1EC8': 'I', 1986 '\u01CF': 'I', 1987 '\u0208': 'I', 1988 '\u020A': 'I', 1989 '\u1ECA': 'I', 1990 '\u012E': 'I', 1991 '\u1E2C': 'I', 1992 '\u0197': 'I', 1993 '\u24BF': 'J', 1994 '\uFF2A': 'J', 1995 '\u0134': 'J', 1996 '\u0248': 'J', 1997 '\u24C0': 'K', 1998 '\uFF2B': 'K', 1999 '\u1E30': 'K', 2000 '\u01E8': 'K', 2001 '\u1E32': 'K', 2002 '\u0136': 'K', 2003 '\u1E34': 'K', 2004 '\u0198': 'K', 2005 '\u2C69': 'K', 2006 '\uA740': 'K', 2007 '\uA742': 'K', 2008 '\uA744': 'K', 2009 '\uA7A2': 'K', 2010 '\u24C1': 'L', 2011 '\uFF2C': 'L', 2012 '\u013F': 'L', 2013 '\u0139': 'L', 2014 '\u013D': 'L', 2015 '\u1E36': 'L', 2016 '\u1E38': 'L', 2017 '\u013B': 'L', 2018 '\u1E3C': 'L', 2019 '\u1E3A': 'L', 2020 '\u0141': 'L', 2021 '\u023D': 'L', 2022 '\u2C62': 'L', 2023 '\u2C60': 'L', 2024 '\uA748': 'L', 2025 '\uA746': 'L', 2026 '\uA780': 'L', 2027 '\u01C7': 'LJ', 2028 '\u01C8': 'Lj', 2029 '\u24C2': 'M', 2030 '\uFF2D': 'M', 2031 '\u1E3E': 'M', 2032 '\u1E40': 'M', 2033 '\u1E42': 'M', 2034 '\u2C6E': 'M', 2035 '\u019C': 'M', 2036 '\u24C3': 'N', 2037 '\uFF2E': 'N', 2038 '\u01F8': 'N', 2039 '\u0143': 'N', 2040 '\u00D1': 'N', 2041 '\u1E44': 'N', 2042 '\u0147': 'N', 2043 '\u1E46': 'N', 2044 '\u0145': 'N', 2045 '\u1E4A': 'N', 2046 '\u1E48': 'N', 2047 '\u0220': 'N', 2048 '\u019D': 'N', 2049 '\uA790': 'N', 2050 '\uA7A4': 'N', 2051 '\u01CA': 'NJ', 2052 '\u01CB': 'Nj', 2053 '\u24C4': 'O', 2054 '\uFF2F': 'O', 2055 '\u00D2': 'O', 2056 '\u00D3': 'O', 2057 '\u00D4': 'O', 2058 '\u1ED2': 'O', 2059 '\u1ED0': 'O', 2060 '\u1ED6': 'O', 2061 '\u1ED4': 'O', 2062 '\u00D5': 'O', 2063 '\u1E4C': 'O', 2064 '\u022C': 'O', 2065 '\u1E4E': 'O', 2066 '\u014C': 'O', 2067 '\u1E50': 'O', 2068 '\u1E52': 'O', 2069 '\u014E': 'O', 2070 '\u022E': 'O', 2071 '\u0230': 'O', 2072 '\u00D6': 'O', 2073 '\u022A': 'O', 2074 '\u1ECE': 'O', 2075 '\u0150': 'O', 2076 '\u01D1': 'O', 2077 '\u020C': 'O', 2078 '\u020E': 'O', 2079 '\u01A0': 'O', 2080 '\u1EDC': 'O', 2081 '\u1EDA': 'O', 2082 '\u1EE0': 'O', 2083 '\u1EDE': 'O', 2084 '\u1EE2': 'O', 2085 '\u1ECC': 'O', 2086 '\u1ED8': 'O', 2087 '\u01EA': 'O', 2088 '\u01EC': 'O', 2089 '\u00D8': 'O', 2090 '\u01FE': 'O', 2091 '\u0186': 'O', 2092 '\u019F': 'O', 2093 '\uA74A': 'O', 2094 '\uA74C': 'O', 2095 '\u01A2': 'OI', 2096 '\uA74E': 'OO', 2097 '\u0222': 'OU', 2098 '\u24C5': 'P', 2099 '\uFF30': 'P', 2100 '\u1E54': 'P', 2101 '\u1E56': 'P', 2102 '\u01A4': 'P', 2103 '\u2C63': 'P', 2104 '\uA750': 'P', 2105 '\uA752': 'P', 2106 '\uA754': 'P', 2107 '\u24C6': 'Q', 2108 '\uFF31': 'Q', 2109 '\uA756': 'Q', 2110 '\uA758': 'Q', 2111 '\u024A': 'Q', 2112 '\u24C7': 'R', 2113 '\uFF32': 'R', 2114 '\u0154': 'R', 2115 '\u1E58': 'R', 2116 '\u0158': 'R', 2117 '\u0210': 'R', 2118 '\u0212': 'R', 2119 '\u1E5A': 'R', 2120 '\u1E5C': 'R', 2121 '\u0156': 'R', 2122 '\u1E5E': 'R', 2123 '\u024C': 'R', 2124 '\u2C64': 'R', 2125 '\uA75A': 'R', 2126 '\uA7A6': 'R', 2127 '\uA782': 'R', 2128 '\u24C8': 'S', 2129 '\uFF33': 'S', 2130 '\u1E9E': 'S', 2131 '\u015A': 'S', 2132 '\u1E64': 'S', 2133 '\u015C': 'S', 2134 '\u1E60': 'S', 2135 '\u0160': 'S', 2136 '\u1E66': 'S', 2137 '\u1E62': 'S', 2138 '\u1E68': 'S', 2139 '\u0218': 'S', 2140 '\u015E': 'S', 2141 '\u2C7E': 'S', 2142 '\uA7A8': 'S', 2143 '\uA784': 'S', 2144 '\u24C9': 'T', 2145 '\uFF34': 'T', 2146 '\u1E6A': 'T', 2147 '\u0164': 'T', 2148 '\u1E6C': 'T', 2149 '\u021A': 'T', 2150 '\u0162': 'T', 2151 '\u1E70': 'T', 2152 '\u1E6E': 'T', 2153 '\u0166': 'T', 2154 '\u01AC': 'T', 2155 '\u01AE': 'T', 2156 '\u023E': 'T', 2157 '\uA786': 'T', 2158 '\uA728': 'TZ', 2159 '\u24CA': 'U', 2160 '\uFF35': 'U', 2161 '\u00D9': 'U', 2162 '\u00DA': 'U', 2163 '\u00DB': 'U', 2164 '\u0168': 'U', 2165 '\u1E78': 'U', 2166 '\u016A': 'U', 2167 '\u1E7A': 'U', 2168 '\u016C': 'U', 2169 '\u00DC': 'U', 2170 '\u01DB': 'U', 2171 '\u01D7': 'U', 2172 '\u01D5': 'U', 2173 '\u01D9': 'U', 2174 '\u1EE6': 'U', 2175 '\u016E': 'U', 2176 '\u0170': 'U', 2177 '\u01D3': 'U', 2178 '\u0214': 'U', 2179 '\u0216': 'U', 2180 '\u01AF': 'U', 2181 '\u1EEA': 'U', 2182 '\u1EE8': 'U', 2183 '\u1EEE': 'U', 2184 '\u1EEC': 'U', 2185 '\u1EF0': 'U', 2186 '\u1EE4': 'U', 2187 '\u1E72': 'U', 2188 '\u0172': 'U', 2189 '\u1E76': 'U', 2190 '\u1E74': 'U', 2191 '\u0244': 'U', 2192 '\u24CB': 'V', 2193 '\uFF36': 'V', 2194 '\u1E7C': 'V', 2195 '\u1E7E': 'V', 2196 '\u01B2': 'V', 2197 '\uA75E': 'V', 2198 '\u0245': 'V', 2199 '\uA760': 'VY', 2200 '\u24CC': 'W', 2201 '\uFF37': 'W', 2202 '\u1E80': 'W', 2203 '\u1E82': 'W', 2204 '\u0174': 'W', 2205 '\u1E86': 'W', 2206 '\u1E84': 'W', 2207 '\u1E88': 'W', 2208 '\u2C72': 'W', 2209 '\u24CD': 'X', 2210 '\uFF38': 'X', 2211 '\u1E8A': 'X', 2212 '\u1E8C': 'X', 2213 '\u24CE': 'Y', 2214 '\uFF39': 'Y', 2215 '\u1EF2': 'Y', 2216 '\u00DD': 'Y', 2217 '\u0176': 'Y', 2218 '\u1EF8': 'Y', 2219 '\u0232': 'Y', 2220 '\u1E8E': 'Y', 2221 '\u0178': 'Y', 2222 '\u1EF6': 'Y', 2223 '\u1EF4': 'Y', 2224 '\u01B3': 'Y', 2225 '\u024E': 'Y', 2226 '\u1EFE': 'Y', 2227 '\u24CF': 'Z', 2228 '\uFF3A': 'Z', 2229 '\u0179': 'Z', 2230 '\u1E90': 'Z', 2231 '\u017B': 'Z', 2232 '\u017D': 'Z', 2233 '\u1E92': 'Z', 2234 '\u1E94': 'Z', 2235 '\u01B5': 'Z', 2236 '\u0224': 'Z', 2237 '\u2C7F': 'Z', 2238 '\u2C6B': 'Z', 2239 '\uA762': 'Z', 2240 '\u24D0': 'a', 2241 '\uFF41': 'a', 2242 '\u1E9A': 'a', 2243 '\u00E0': 'a', 2244 '\u00E1': 'a', 2245 '\u00E2': 'a', 2246 '\u1EA7': 'a', 2247 '\u1EA5': 'a', 2248 '\u1EAB': 'a', 2249 '\u1EA9': 'a', 2250 '\u00E3': 'a', 2251 '\u0101': 'a', 2252 '\u0103': 'a', 2253 '\u1EB1': 'a', 2254 '\u1EAF': 'a', 2255 '\u1EB5': 'a', 2256 '\u1EB3': 'a', 2257 '\u0227': 'a', 2258 '\u01E1': 'a', 2259 '\u00E4': 'a', 2260 '\u01DF': 'a', 2261 '\u1EA3': 'a', 2262 '\u00E5': 'a', 2263 '\u01FB': 'a', 2264 '\u01CE': 'a', 2265 '\u0201': 'a', 2266 '\u0203': 'a', 2267 '\u1EA1': 'a', 2268 '\u1EAD': 'a', 2269 '\u1EB7': 'a', 2270 '\u1E01': 'a', 2271 '\u0105': 'a', 2272 '\u2C65': 'a', 2273 '\u0250': 'a', 2274 '\uA733': 'aa', 2275 '\u00E6': 'ae', 2276 '\u01FD': 'ae', 2277 '\u01E3': 'ae', 2278 '\uA735': 'ao', 2279 '\uA737': 'au', 2280 '\uA739': 'av', 2281 '\uA73B': 'av', 2282 '\uA73D': 'ay', 2283 '\u24D1': 'b', 2284 '\uFF42': 'b', 2285 '\u1E03': 'b', 2286 '\u1E05': 'b', 2287 '\u1E07': 'b', 2288 '\u0180': 'b', 2289 '\u0183': 'b', 2290 '\u0253': 'b', 2291 '\u24D2': 'c', 2292 '\uFF43': 'c', 2293 '\u0107': 'c', 2294 '\u0109': 'c', 2295 '\u010B': 'c', 2296 '\u010D': 'c', 2297 '\u00E7': 'c', 2298 '\u1E09': 'c', 2299 '\u0188': 'c', 2300 '\u023C': 'c', 2301 '\uA73F': 'c', 2302 '\u2184': 'c', 2303 '\u24D3': 'd', 2304 '\uFF44': 'd', 2305 '\u1E0B': 'd', 2306 '\u010F': 'd', 2307 '\u1E0D': 'd', 2308 '\u1E11': 'd', 2309 '\u1E13': 'd', 2310 '\u1E0F': 'd', 2311 '\u0111': 'd', 2312 '\u018C': 'd', 2313 '\u0256': 'd', 2314 '\u0257': 'd', 2315 '\uA77A': 'd', 2316 '\u01F3': 'dz', 2317 '\u01C6': 'dz', 2318 '\u24D4': 'e', 2319 '\uFF45': 'e', 2320 '\u00E8': 'e', 2321
2321 '\u00E9': 'e', 2322 '\u00EA': 'e', 2323 '\u1EC1': 'e', 2324 '\u1EBF': 'e', 2325 '\u1EC5': 'e', 2326 '\u1EC3': 'e', 2327 '\u1EBD': 'e', 2328 '\u0113': 'e', 2329 '\u1E15': 'e', 2330 '\u1E17': 'e', 2331 '\u0115': 'e', 2332 '\u0117': 'e', 2333 '\u00EB': 'e', 2334 '\u1EBB': 'e', 2335 '\u011B': 'e', 2336 '\u0205': 'e', 2337 '\u0207': 'e', 2338 '\u1EB9': 'e', 2339 '\u1EC7': 'e', 2340 '\u0229': 'e', 2341 '\u1E1D': 'e', 2342 '\u0119': 'e', 2343 '\u1E19': 'e', 2344 '\u1E1B': 'e', 2345 '\u0247': 'e', 2346 '\u025B': 'e', 2347 '\u01DD': 'e', 2348 '\u24D5': 'f', 2349 '\uFF46': 'f', 2350 '\u1E1F': 'f', 2351 '\u0192': 'f', 2352 '\uA77C': 'f', 2353 '\u24D6': 'g', 2354 '\uFF47': 'g', 2355 '\u01F5': 'g', 2356 '\u011D': 'g', 2357 '\u1E21': 'g', 2358 '\u011F': 'g', 2359 '\u0121': 'g', 2360 '\u01E7': 'g', 2361 '\u0123': 'g', 2362 '\u01E5': 'g', 2363 '\u0260': 'g', 2364 '\uA7A1': 'g', 2365 '\u1D79': 'g', 2366 '\uA77F': 'g', 2367 '\u24D7': 'h', 2368 '\uFF48': 'h', 2369 '\u0125': 'h', 2370 '\u1E23': 'h', 2371 '\u1E27': 'h', 2372 '\u021F': 'h', 2373 '\u1E25': 'h', 2374 '\u1E29': 'h', 2375 '\u1E2B': 'h', 2376 '\u1E96': 'h', 2377 '\u0127': 'h', 2378 '\u2C68': 'h', 2379 '\u2C76': 'h', 2380 '\u0265': 'h', 2381 '\u0195': 'hv', 2382 '\u24D8': 'i', 2383 '\uFF49': 'i', 2384 '\u00EC': 'i', 2385 '\u00ED': 'i', 2386 '\u00EE': 'i', 2387 '\u0129': 'i', 2388 '\u012B': 'i', 2389 '\u012D': 'i', 2390 '\u00EF': 'i', 2391 '\u1E2F': 'i', 2392 '\u1EC9': 'i', 2393 '\u01D0': 'i', 2394 '\u0209': 'i', 2395 '\u020B': 'i', 2396 '\u1ECB': 'i', 2397 '\u012F': 'i', 2398 '\u1E2D': 'i', 2399 '\u0268': 'i', 2400 '\u0131': 'i', 2401 '\u24D9': 'j', 2402 '\uFF4A': 'j', 2403 '\u0135': 'j', 2404 '\u01F0': 'j', 2405 '\u0249': 'j', 2406 '\u24DA': 'k', 2407 '\uFF4B': 'k', 2408 '\u1E31': 'k', 2409 '\u01E9': 'k', 2410 '\u1E33': 'k', 2411 '\u0137': 'k', 2412 '\u1E35': 'k', 2413 '\u0199': 'k', 2414 '\u2C6A': 'k', 2415 '\uA741': 'k', 2416 '\uA743': 'k', 2417 '\uA745': 'k', 2418 '\uA7A3': 'k', 2419 '\u24DB': 'l', 2420 '\uFF4C': 'l', 2421 '\u0140': 'l', 2422 '\u013A': 'l', 2423 '\u013E': 'l', 2424 '\u1E37': 'l', 2425 '\u1E39': 'l', 2426 '\u013C': 'l', 2427 '\u1E3D': 'l', 2428 '\u1E3B': 'l', 2429 '\u017F': 'l', 2430 '\u0142': 'l', 2431 '\u019A': 'l', 2432 '\u026B': 'l', 2433 '\u2C61': 'l', 2434 '\uA749': 'l', 2435 '\uA781': 'l', 2436 '\uA747': 'l', 2437 '\u01C9': 'lj', 2438 '\u24DC': 'm', 2439 '\uFF4D': 'm', 2440 '\u1E3F': 'm', 2441 '\u1E41': 'm', 2442 '\u1E43': 'm', 2443 '\u0271': 'm', 2444 '\u026F': 'm', 2445 '\u24DD': 'n', 2446 '\uFF4E': 'n', 2447 '\u01F9': 'n', 2448 '\u0144': 'n', 2449 '\u00F1': 'n', 2450 '\u1E45': 'n', 2451 '\u0148': 'n', 2452 '\u1E47': 'n', 2453 '\u0146': 'n', 2454 '\u1E4B': 'n', 2455 '\u1E49': 'n', 2456 '\u019E': 'n', 2457 '\u0272': 'n', 2458 '\u0149': 'n', 2459 '\uA791': 'n', 2460 '\uA7A5': 'n', 2461 '\u01CC': 'nj', 2462 '\u24DE': 'o', 2463 '\uFF4F': 'o', 2464 '\u00F2': 'o', 2465 '\u00F3': 'o', 2466 '\u00F4': 'o', 2467 '\u1ED3': 'o', 2468 '\u1ED1': 'o', 2469 '\u1ED7': 'o', 2470 '\u1ED5': 'o', 2471 '\u00F5': 'o', 2472 '\u1E4D': 'o', 2473 '\u022D': 'o', 2474 '\u1E4F': 'o', 2475 '\u014D': 'o', 2476 '\u1E51': 'o', 2477 '\u1E53': 'o', 2478 '\u014F': 'o', 2479 '\u022F': 'o', 2480 '\u0231': 'o', 2481 '\u00F6': 'o', 2482 '\u022B': 'o', 2483 '\u1ECF': 'o', 2484 '\u0151': 'o', 2485 '\u01D2': 'o', 2486 '\u020D': 'o', 2487 '\u020F': 'o', 2488 '\u01A1': 'o', 2489 '\u1EDD': 'o', 2490 '\u1EDB': 'o', 2491 '\u1EE1': 'o', 2492 '\u1EDF': 'o', 2493 '\u1EE3': 'o', 2494 '\u1ECD': 'o', 2495 '\u1ED9': 'o', 2496 '\u01EB': 'o', 2497 '\u01ED': 'o', 2498 '\u00F8': 'o', 2499 '\u01FF': 'o', 2500 '\u0254': 'o', 2501 '\uA74B': 'o', 2502 '\uA74D': 'o', 2503 '\u0275': 'o', 2504 '\u01A3': 'oi', 2505 '\u0223': 'ou', 2506 '\uA74F': 'oo', 2507 '\u24DF': 'p', 2508 '\uFF50': 'p', 2509 '\u1E55': 'p', 2510 '\u1E57': 'p', 2511 '\u01A5': 'p', 2512 '\u1D7D': 'p', 2513 '\uA751': 'p', 2514 '\uA753': 'p', 2515 '\uA755': 'p', 2516 '\u24E0': 'q', 2517 '\uFF51': 'q', 2518 '\u024B': 'q', 2519 '\uA757': 'q', 2520 '\uA759': 'q', 2521 '\u24E1': 'r', 2522 '\uFF52': 'r', 2523 '\u0155': 'r', 2524 '\u1E59': 'r', 2525 '\u0159': 'r', 2526 '\u0211': 'r', 2527 '\u0213': 'r', 2528 '\u1E5B': 'r', 2529 '\u1E5D': 'r', 2530 '\u0157': 'r', 2531 '\u1E5F': 'r', 2532 '\u024D': 'r', 2533 '\u027D': 'r', 2534 '\uA75B': 'r', 2535 '\uA7A7': 'r', 2536 '\uA783': 'r',
vendor: 69,381 bytes, lines 2537-4792
2537 '\u24E2': 's', 2538 '\uFF53': 's', 2539 '\u00DF': 's', 2540 '\u015B': 's', 2541 '\u1E65': 's', 2542 '\u015D': 's', 2543 '\u1E61': 's', 2544 '\u0161': 's', 2545 '\u1E67': 's', 2546 '\u1E63': 's', 2547 '\u1E69': 's', 2548 '\u0219': 's', 2549 '\u015F': 's', 2550 '\u023F': 's', 2551 '\uA7A9': 's', 2552 '\uA785': 's', 2553 '\u1E9B': 's', 2554 '\u24E3': 't', 2555 '\uFF54': 't', 2556 '\u1E6B': 't', 2557 '\u1E97': 't', 2558 '\u0165': 't', 2559 '\u1E6D': 't', 2560 '\u021B': 't', 2561 '\u0163': 't', 2562 '\u1E71': 't', 2563 '\u1E6F': 't', 2564 '\u0167': 't', 2565 '\u01AD': 't', 2566 '\u0288': 't', 2567 '\u2C66': 't', 2568 '\uA787': 't', 2569 '\uA729': 'tz', 2570 '\u24E4': 'u', 2571 '\uFF55': 'u', 2572 '\u00F9': 'u', 2573 '\u00FA': 'u', 2574 '\u00FB': 'u', 2575 '\u0169': 'u', 2576 '\u1E79': 'u', 2577 '\u016B': 'u', 2578 '\u1E7B': 'u', 2579 '\u016D': 'u', 2580 '\u00FC': 'u', 2581 '\u01DC': 'u', 2582 '\u01D8': 'u', 2583 '\u01D6': 'u', 2584 '\u01DA': 'u', 2585 '\u1EE7': 'u', 2586 '\u016F': 'u', 2587 '\u0171': 'u', 2588 '\u01D4': 'u', 2589 '\u0215': 'u', 2590 '\u0217': 'u', 2591 '\u01B0': 'u', 2592 '\u1EEB': 'u', 2593 '\u1EE9': 'u', 2594 '\u1EEF': 'u', 2595 '\u1EED': 'u', 2596 '\u1EF1': 'u', 2597 '\u1EE5': 'u', 2598 '\u1E73': 'u', 2599 '\u0173': 'u', 2600 '\u1E77': 'u', 2601 '\u1E75': 'u', 2602 '\u0289': 'u', 2603 '\u24E5': 'v', 2604 '\uFF56': 'v', 2605 '\u1E7D': 'v', 2606 '\u1E7F': 'v', 2607 '\u028B': 'v', 2608 '\uA75F': 'v', 2609 '\u028C': 'v', 2610 '\uA761': 'vy', 2611 '\u24E6': 'w', 2612 '\uFF57': 'w', 2613 '\u1E81': 'w', 2614 '\u1E83': 'w', 2615 '\u0175': 'w', 2616 '\u1E87': 'w', 2617 '\u1E85': 'w', 2618 '\u1E98': 'w', 2619 '\u1E89': 'w', 2620 '\u2C73': 'w', 2621 '\u24E7': 'x', 2622 '\uFF58': 'x', 2623 '\u1E8B': 'x', 2624 '\u1E8D': 'x', 2625 '\u24E8': 'y', 2626 '\uFF59': 'y', 2627 '\u1EF3': 'y', 2628 '\u00FD': 'y', 2629 '\u0177': 'y', 2630 '\u1EF9': 'y', 2631 '\u0233': 'y', 2632 '\u1E8F': 'y', 2633 '\u00FF': 'y', 2634 '\u1EF7': 'y', 2635 '\u1E99': 'y', 2636 '\u1EF5': 'y', 2637 '\u01B4': 'y', 2638 '\u024F': 'y', 2639 '\u1EFF': 'y', 2640 '\u24E9': 'z', 2641 '\uFF5A': 'z', 2642 '\u017A': 'z', 2643 '\u1E91': 'z', 2644 '\u017C': 'z', 2645 '\u017E': 'z', 2646 '\u1E93': 'z', 2647 '\u1E95': 'z', 2648 '\u01B6': 'z', 2649 '\u0225': 'z', 2650 '\u0240': 'z', 2651 '\u2C6C': 'z', 2652 '\uA763': 'z', 2653 '\u0386': '\u0391', 2654 '\u0388': '\u0395', 2655 '\u0389': '\u0397', 2656 '\u038A': '\u0399', 2657 '\u03AA': '\u0399', 2658 '\u038C': '\u039F', 2659 '\u038E': '\u03A5', 2660 '\u03AB': '\u03A5', 2661 '\u038F': '\u03A9', 2662 '\u03AC': '\u03B1', 2663 '\u03AD': '\u03B5', 2664 '\u03AE': '\u03B7', 2665 '\u03AF': '\u03B9', 2666 '\u03CA': '\u03B9', 2667 '\u0390': '\u03B9', 2668 '\u03CC': '\u03BF', 2669 '\u03CD': '\u03C5', 2670 '\u03CB': '\u03C5', 2671 '\u03B0': '\u03C5', 2672 '\u03C9': '\u03C9', 2673 '\u03C2': '\u03C3' 2674 }; 2675 2676 return diacritics; 2677 }); 2678 2679 define('select2/data/base',[ 2680 '../utils' 2681 ], function (Utils) { 2682 function BaseAdapter ($element, options) { 2683 BaseAdapter.__super__.constructor.call(this); 2684 } 2685 2686 Utils.Extend(BaseAdapter, Utils.Observable); 2687 2688 BaseAdapter.prototype.current = function (callback) { 2689 throw new Error('The `current` method must be defined in child classes.'); 2690 }; 2691 2692 BaseAdapter.prototype.query = function (params, callback) { 2693 throw new Error('The `query` method must be defined in child classes.'); 2694 }; 2695 2696 BaseAdapter.prototype.bind = function (container, $container) { 2697 // Can be implemented in subclasses 2698 }; 2699 2700 BaseAdapter.prototype.destroy = function () { 2701 // Can be implemented in subclasses 2702 }; 2703 2704 BaseAdapter.prototype.generateResultId = function (container, data) { 2705 var id = container.id + '-result-'; 2706 2707 id += Utils.generateChars(4); 2708 2709 if (data.id != null) { 2710 id += '-' + data.id.toString(); 2711 } else { 2712 id += '-' + Utils.generateChars(4); 2713 } 2714 return id; 2715 }; 2716 2717 return BaseAdapter; 2718 }); 2719 2720 define('select2/data/select',[ 2721 './base', 2722 '../utils', 2723 'jquery' 2724 ], function (BaseAdapter, Utils, $) { 2725 function SelectAdapter ($element, options) { 2726 this.$element = $element; 2727 this.options = options; 2728 2729 SelectAdapter.__super__.constructor.call(this); 2730 } 2731 2732 Utils.Extend(SelectAdapter, BaseAdapter); 2733 2734 SelectAdapter.prototype.current = function (callback) { 2735 var data = []; 2736 var self = this; 2737 2738 this.$element.find(':selected').each(function () { 2739 var $option = $(this); 2740 2741 var option = self.item($option); 2742 2743 data.push(option); 2744 }); 2745 2746 callback(data); 2747 }; 2748 2749 SelectAdapter.prototype.select = function (data) { 2750 var self = this; 2751 2752 // If data.element is a DOM nose, use it instead 2753 if ($(data.element).is('option')) { 2754 data.element.selected = true; 2755 2756 this.$element.trigger('change'); 2757 2758 return; 2759 } 2760 2761 if (this.$element.prop('multiple')) { 2762 this.current(function (currentData) { 2763 var val = []; 2764 2765 data = [data]; 2766 data.push.apply(data, currentData); 2767 2768 for (var d = 0; d < data.length; d++) { 2769 id = data[d].id; 2770 2771 if (val.indexOf(id) === -1) { 2772 val.push(id); 2773 } 2774 } 2775 2776 self.$element.val(val); 2777 self.$element.trigger('change'); 2778 }); 2779 } else { 2780 var val = data.id; 2781 2782 this.$element.val(val); 2783 2784 this.$element.trigger('change'); 2785 } 2786 }; 2787 2788 SelectAdapter.prototype.unselect = function (data) { 2789 var self = this; 2790 2791 if (!this.$element.prop('multiple')) { 2792 return; 2793 } 2794 2795 if ($(data.element).is('option')) { 2796 data.element.selected = false; 2797 2798 this.$element.trigger('change'); 2799 2800 return; 2801 } 2802 2803 this.current(function (currentData) { 2804 var val = []; 2805 2806 for (var d = 0; d < currentData.length; d++) { 2807 id = currentData[d].id; 2808 2809 if (id !== data.id && val.indexOf(id) === -1) { 2810 val.push(id); 2811 } 2812 } 2813 2814 self.$element.val(val); 2815 2816 self.$element.trigger('change'); 2817 }); 2818 }; 2819 2820 SelectAdapter.prototype.bind = function (container, $container) { 2821 var self = this; 2822 2823 this.container = container; 2824 2825 container.on('select', function (params) { 2826 self.select(params.data); 2827 }); 2828 2829 container.on('unselect', function (params) { 2830 self.unselect(params.data); 2831 }); 2832 }; 2833 2834 SelectAdapter.prototype.destroy = function () { 2835 // Remove anything added to child elements 2836 this.$element.find('*').each(function () { 2837 // Remove any custom data set by Select2 2838 $.removeData(this, 'data'); 2839 }); 2840 }; 2841 2842 SelectAdapter.prototype.query = function (params, callback) { 2843 var data = []; 2844 var self = this; 2845 2846 var $options = this.$element.children(); 2847 2848 $options.each(function () { 2849 var $option = $(this); 2850 2851 if (!$option.is('option') && !$option.is('optgroup')) { 2852 return; 2853 } 2854 2855 var option = self.item($option); 2856 2857 var matches = self.matches(params, option); 2858 2859 if (matches !== null) { 2860 data.push(matches); 2861 } 2862 }); 2863 2864 callback({ 2865 results: data 2866 }); 2867 }; 2868 2869 SelectAdapter.prototype.option = function (data) { 2870 var option; 2871 2872 if (data.children) { 2873 option = document.createElement('optgroup'); 2874 option.label = data.text; 2875 } else { 2876 option = document.createElement('option'); 2877 option.innerText = data.text; 2878 } 2879 2880 if (data.id) { 2881 option.value = data.id; 2882 } 2883 2884 if (data.disabled) { 2885 option.disabled = true; 2886 } 2887 2888 if (data.selected) { 2889 option.selected = true; 2890 } 2891 2892 var $option = $(option); 2893 2894 var normalizedData = this._normalizeItem(data); 2895 normalizedData.element = option; 2896 2897 // Override the option's data with the combined data 2898 $.data(option, 'data', normalizedData); 2899 2900 return $option; 2901 }; 2902 2903 SelectAdapter.prototype.item = function ($option) { 2904 var data = {}; 2905 2906 data = $.data($option[0], 'data'); 2907 2908 if (data != null) { 2909 return data; 2910 } 2911 2912 if ($option.is('option')) { 2913 data = { 2914 id: $option.val(), 2915 text: $option.html(), 2916 disabled: $option.prop('disabled'), 2917 selected: $option.prop('selected') 2918 }; 2919 } else if ($option.is('optgroup')) { 2920 data = { 2921 text: $option.prop('label'), 2922 children: [] 2923 }; 2924 2925 var $children = $option.children('option'); 2926 var children = []; 2927 2928 for (var c = 0; c < $children.length; c++) { 2929 var $child = $($children[c]); 2930 2931 var child = this.item($child); 2932 2933 children.push(child); 2934 } 2935 2936 data.children = children; 2937 } 2938 2939 data = this._normalizeItem(data); 2940 data.element = $option[0]; 2941 2942 $.data($option[0], 'data', data); 2943 2944 return data; 2945 }; 2946 2947 SelectAdapter.prototype._normalizeItem = function (item) { 2948 if (!$.isPlainObject(item)) { 2949 item = { 2950 id: item, 2951 text: item 2952 }; 2953 } 2954 2955 item = $.extend({}, { 2956 text: '' 2957 }, item); 2958 2959 var defaults = { 2960 selected: false, 2961 disabled: false 2962 }; 2963 2964 if (item.id != null) { 2965 item.id = item.id.toString(); 2966 } 2967 2968 if (item.text != null) { 2969 item.text = item.text.toString(); 2970 } 2971 2972 if (item._resultId == null && item.id && this.container != null) { 2973 item._resultId = this.generateResultId(this.container, item); 2974 } 2975 2976 return $.extend({}, defaults, item); 2977 }; 2978 2979 SelectAdapter.prototype.matches = function (params, data) { 2980 var matcher = this.options.get('matcher'); 2981 2982 return matcher(params, data); 2983 }; 2984 2985 return SelectAdapter; 2986 }); 2987 2988 define('select2/data/array',[ 2989 './select', 2990 '../utils', 2991 'jquery' 2992 ], function (SelectAdapter, Utils, $) { 2993 function ArrayAdapter ($element, options) { 2994 var data = options.get('data') || []; 2995 2996 ArrayAdapter.__super__.constructor.call(this, $element, options); 2997 2998 $element.append(this.convertToOptions(data)); 2999 } 3000 3001 Utils.Extend(ArrayAdapter, SelectAdapter); 3002 3003 ArrayAdapter.prototype.select = function (data) { 3004 var $option = this.$element.find('option[value="' + data.id + '"]'); 3005 3006 if ($option.length === 0) { 3007 $option = this.option(data); 3008 3009 this.$element.append($option); 3010 } 3011 3012 ArrayAdapter.__super__.select.call(this, data); 3013 }; 3014 3015 ArrayAdapter.prototype.convertToOptions = function (data) { 3016 var self = this; 3017 3018 var $existing = this.$element.find('option'); 3019 var existingIds = $existing.map(function () { 3020 return self.item($(this)).id; 3021 }).get(); 3022 3023 var $options = []; 3024 3025 // Filter out all items except for the one passed in the argument 3026 function onlyItem (item) { 3027 return function () { 3028 return $(this).val() == item.id; 3029 }; 3030 } 3031 3032 for (var d = 0; d < data.length; d++) { 3033 var item = this._normalizeItem(data[d]); 3034 3035 // Skip items which were pre-loaded, only merge the data 3036 if (existingIds.indexOf(item.id) >= 0) { 3037 var $existingOption = $existing.filter(onlyItem(item)); 3038 3039 var existingData = this.item($existingOption); 3040 var newData = $.extend(true, {}, existingData, item); 3041 3042 var $newOption = this.option(existingData); 3043 3044 $existingOption.replaceWith($newOption); 3045 3046 continue; 3047 } 3048 3049 var $option = this.option(item); 3050 3051 if (item.children) { 3052 var $children = this.convertToOptions(item.children); 3053 3054 $option.append($children); 3055 } 3056 3057 $options.push($option); 3058 } 3059 3060 return $options; 3061 }; 3062 3063 return ArrayAdapter; 3064 }); 3065 3066 define('select2/data/ajax',[ 3067 './array', 3068 '../utils', 3069 'jquery' 3070 ], function (ArrayAdapter, Utils, $) { 3071 function AjaxAdapter ($element, options) { 3072 this.ajaxOptions = options.get('ajax'); 3073 3074 if (this.ajaxOptions.processResults != null) { 3075 this.processResults = this.ajaxOptions.processResults; 3076 } 3077 3078 ArrayAdapter.__super__.constructor.call(this, $element, options); 3079 } 3080 3081 Utils.Extend(AjaxAdapter, ArrayAdapter); 3082 3083 AjaxAdapter.prototype.processResults = function (results) { 3084 return results; 3085 }; 3086 3087 AjaxAdapter.prototype.query = function (params, callback) { 3088 var matches = []; 3089 var self = this; 3090 3091 if (this._request) { 3092 this._request.abort(); 3093 this._request = null; 3094 } 3095 3096 var options = $.extend({ 3097 type: 'GET' 3098 }, this.ajaxOptions); 3099 3100 if (typeof options.url === 'function') { 3101 options.url = options.url(params); 3102 } 3103 3104 if (typeof options.data === 'function') { 3105 options.data = options.data(params); 3106 } 3107 3108 function request () { 3109 var $request = $.ajax(options); 3110 3111 $request.success(function (data) { 3112 var results = self.processResults(data, params); 3113 3114 if (console && console.error) { 3115 // Check to make sure that the response included a `results` key. 3116 if (!results || !results.results || !$.isArray(results.results)) { 3117 console.error( 3118 'Select2: The AJAX results did not return an array in the ' + 3119 '`results` key of the response.' 3120 ); 3121 } 3122 } 3123 3124 callback(results); 3125 }); 3126 3127 self._request = $request; 3128 } 3129 3130 if (this.ajaxOptions.delay && params.term !== '') { 3131 if (this._queryTimeout) { 3132 window.clearTimeout(this._queryTimeout); 3133 } 3134 3135 this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay); 3136 } else { 3137 request(); 3138 } 3139 }; 3140 3141 return AjaxAdapter; 3142 }); 3143 3144 define('select2/data/tags',[ 3145 'jquery' 3146 ], function ($) { 3147 function Tags (decorated, $element, options) { 3148 var tags = options.get('tags'); 3149 3150 var createTag = options.get('createTag'); 3151 3152 if (createTag !== undefined) { 3153 this.createTag = createTag; 3154 } 3155 3156 decorated.call(this, $element, options); 3157 3158 if ($.isArray(tags)) { 3159 for (var t = 0; t < tags.length; t++) { 3160 var tag = tags[t]; 3161 var item = this._normalizeItem(tag); 3162 3163 var $option = this.option(item); 3164 3165 this.$element.append($option); 3166 } 3167 } 3168 } 3169 3170 Tags.prototype.query = function (decorated, params, callback) { 3171 var self = this; 3172 3173 this._removeOldTags(); 3174 3175 if (params.term == null || params.term === '' || params.page != null) { 3176 decorated.call(this, params, callback); 3177 return; 3178 } 3179 3180 function wrapper (obj, child) { 3181 var data = obj.results; 3182 3183 for (var i = 0; i < data.length; i++) { 3184 var option = data[i]; 3185 3186 var checkChildren = ( 3187 option.children != null && 3188 !wrapper({ 3189 results: option.children 3190 }, true) 3191 ); 3192 3193 var checkText = option.text === params.term; 3194 3195 if (checkText || checkChildren) { 3196 if (child) { 3197 return false; 3198 } 3199 3200 obj.data = data; 3201 callback(obj); 3202 3203 return; 3204 } 3205 } 3206 3207 if (child) { 3208 return true; 3209 } 3210 3211 var tag = self.createTag(params); 3212 3213 if (tag != null) { 3214 var $option = self.option(tag); 3215 $option.attr('data-select2-tag', true); 3216 3217 self.$element.append($option); 3218 3219 self.insertTag(data, tag); 3220 } 3221 3222 obj.results = data; 3223 3224 callback(obj); 3225 } 3226 3227 decorated.call(this, params, wrapper); 3228 }; 3229 3230 Tags.prototype.createTag = function (decorated, params) { 3231 return { 3232 id: params.term, 3233 text: params.term 3234 }; 3235 }; 3236 3237 Tags.prototype.insertTag = function (_, data, tag) { 3238 data.unshift(tag); 3239 }; 3240 3241 Tags.prototype._removeOldTags = function (_) { 3242 var tag = this._lastTag; 3243 3244 var $options = this.$element.find('option[data-select2-tag]'); 3245 3246 $options.each(function () { 3247 if (this.selected) { 3248 return; 3249 } 3250 3251 $(this).remove(); 3252 }); 3253 }; 3254 3255 return Tags; 3256 }); 3257 3258 define('select2/data/tokenizer',[ 3259 'jquery' 3260 ], function ($) { 3261 function Tokenizer (decorated, $element, options) { 3262 var tokenizer = options.get('tokenizer'); 3263 3264 if (tokenizer !== undefined) { 3265 this.tokenizer = tokenizer; 3266 } 3267 3268 decorated.call(this, $element, options); 3269 } 3270 3271 Tokenizer.prototype.bind = function (decorated, container, $container) { 3272 decorated.call(this, container, $container); 3273 3274 this.$search = container.dropdown.$search || container.selection.$search || 3275 $container.find('.select2-search__field'); 3276 }; 3277 3278 Tokenizer.prototype.query = function (decorated, params, callback) { 3279 var self = this; 3280 3281 function select (data) { 3282 self.select(data); 3283 } 3284 3285 params.term = params.term || ''; 3286 3287 var tokenData = this.tokenizer(params, this.options, select); 3288 3289 if (tokenData.term !== params.term) { 3290 // Replace the search term if we have the search box 3291 if (this.$search.length) { 3292 this.$search.val(tokenData.term); 3293 this.$search.focus(); 3294 } 3295 3296 params.term = tokenData.term; 3297 } 3298 3299 decorated.call(this, params, callback); 3300 }; 3301 3302 Tokenizer.prototype.tokenizer = function (_, params, options, callback) { 3303 var separators = options.get('tokenSeparators') || []; 3304 var term = params.term; 3305 var i = 0; 3306 3307 var createTag = this.createTag || function (params) { 3308 return { 3309 id: params.term, 3310 text: params.term 3311 }; 3312 }; 3313 3314 while (i < term.length) { 3315 var termChar = term[i]; 3316 3317 if (separators.indexOf(termChar) === -1) { 3318 i++; 3319 3320 continue; 3321 } 3322 3323 var part = term.substr(0, i); 3324 var partParams = $.extend({}, params, { 3325 term: part 3326 }); 3327 3328 var data = createTag(partParams); 3329 3330 callback(data); 3331 3332 // Reset the term to not include the tokenized portion 3333 term = term.substr(i + 1) || ''; 3334 i = 0; 3335 } 3336 3337 return { 3338 term: term 3339 }; 3340 }; 3341 3342 return Tokenizer; 3343 }); 3344 3345 define('select2/data/minimumInputLength',[ 3346 3347 ], function () { 3348 function MinimumInputLength (decorated, $e, options) { 3349 this.minimumInputLength = options.get('minimumInputLength'); 3350 3351 decorated.call(this, $e, options); 3352 } 3353 3354 MinimumInputLength.prototype.query = function (decorated, params, callback) { 3355 params.term = params.term || ''; 3356 3357 if (params.term.length < this.minimumInputLength) { 3358 this.trigger('results:message', { 3359 message: 'inputTooShort', 3360 args: { 3361 minimum: this.minimumInputLength, 3362 input: params.term, 3363 params: params 3364 } 3365 }); 3366 3367 return; 3368 } 3369 3370 decorated.call(this, params, callback); 3371 }; 3372 3373 return MinimumInputLength; 3374 }); 3375 3376 define('select2/data/maximumInputLength',[ 3377 3378 ], function () { 3379 function MaximumInputLength (decorated, $e, options) { 3380 this.maximumInputLength = options.get('maximumInputLength'); 3381 3382 decorated.call(this, $e, options); 3383 } 3384 3385 MaximumInputLength.prototype.query = function (decorated, params, callback) { 3386 params.term = params.term || ''; 3387 3388 if (this.maximumInputLength > 0 && 3389 params.term.length > this.maximumInputLength) { 3390 this.trigger('results:message', { 3391 message: 'inputTooLong', 3392 args: { 3393 minimum: this.maximumInputLength, 3394 input: params.term, 3395 params: params 3396 } 3397 }); 3398 3399 return; 3400 } 3401 3402 decorated.call(this, params, callback); 3403 }; 3404 3405 return MaximumInputLength; 3406 }); 3407 3408 define('select2/data/maximumSelectionLength',[ 3409 3410 ], function (){ 3411 function MaximumSelectionLength (decorated, $e, options) { 3412 this.maximumSelectionLength = options.get('maximumSelectionLength'); 3413 3414 decorated.call(this, $e, options); 3415 } 3416 3417 MaximumSelectionLength.prototype.query = 3418 function (decorated, params, callback) { 3419 var self = this; 3420 3421 this.current(function (currentData) { 3422 var count = currentData != null ? currentData.length : 0; 3423 if (self.maximumSelectionLength > 0 && 3424 count >= self.maximumSelectionLength) { 3425 self.trigger('results:message', { 3426 message: 'maximumSelected', 3427 args: { 3428 maximum: self.maximumSelectionLength 3429 } 3430 }); 3431 return; 3432 } 3433 decorated.call(self, params, callback); 3434 }); 3435 }; 3436 3437 return MaximumSelectionLength; 3438 }); 3439 3440 define('select2/dropdown',[ 3441 'jquery', 3442 './utils' 3443 ], function ($, Utils) { 3444 function Dropdown ($element, options) { 3445 this.$element = $element; 3446 this.options = options; 3447 3448 Dropdown.__super__.constructor.call(this); 3449 } 3450 3451 Utils.Extend(Dropdown, Utils.Observable); 3452 3453 Dropdown.prototype.render = function () { 3454 var $dropdown = $( 3455 '<span class="select2-dropdown">' + 3456 '<span class="select2-results"></span>' + 3457 '</span>' 3458 ); 3459 3460 $dropdown.attr('dir', this.options.get('dir')); 3461 3462 this.$dropdown = $dropdown; 3463 3464 return $dropdown; 3465 }; 3466 3467 Dropdown.prototype.position = function ($dropdown, $container) { 3468 // Should be implmented in subclasses 3469 }; 3470 3471 Dropdown.prototype.destroy = function () { 3472 // Remove the dropdown from the DOM 3473 this.$dropdown.remove(); 3474 }; 3475 3476 Dropdown.prototype.bind = function (container, $container) { 3477 var self = this; 3478 3479 container.on('select', function (params) { 3480 self._onSelect(params); 3481 }); 3482 3483 container.on('unselect', function (params) { 3484 self._onUnSelect(params); 3485 }); 3486 }; 3487 3488 Dropdown.prototype._onSelect = function () { 3489 this.trigger('close'); 3490 }; 3491 3492 Dropdown.prototype._onUnSelect = function () { 3493 this.trigger('close'); 3494 }; 3495 3496 return Dropdown; 3497 }); 3498 3499 define('select2/dropdown/search',[ 3500 'jquery', 3501 '../utils' 3502 ], function ($, Utils) { 3503 function Search () { } 3504 3505 Search.prototype.render = function (decorated) { 3506 var $rendered = decorated.call(this); 3507 3508 var $search = $( 3509 '<span class="select2-search select2-search--dropdown">' + 3510 '<input class="select2-search__field" type="search" tabindex="-1"' + 3511 ' role="textbox" />' + 3512 '</span>' 3513 ); 3514 3515 this.$searchContainer = $search; 3516 this.$search = $search.find('input'); 3517 3518 $rendered.prepend($search); 3519 3520 return $rendered; 3521 }; 3522 3523 Search.prototype.bind = function (decorated, container, $container) { 3524 var self = this; 3525 3526 decorated.call(this, container, $container); 3527 3528 this.$search.on('keydown', function (evt) { 3529 self.trigger('keypress', evt); 3530 3531 self._keyUpPrevented = evt.isDefaultPrevented(); 3532 }); 3533 3534 this.$search.on('keyup', function (evt) { 3535 self.handleSearch(evt); 3536 }); 3537 3538 container.on('open', function () { 3539 self.$search.attr('tabindex', 0); 3540 3541 self.$search.focus(); 3542 3543 window.setTimeout(function () { 3544 self.$search.focus(); 3545 }, 0); 3546 }); 3547 3548 container.on('close', function () { 3549 self.$search.attr('tabindex', -1); 3550 3551 self.$search.val(''); 3552 }); 3553 3554 container.on('results:all', function (params) { 3555 if (params.query.term == null || params.query.term === '') { 3556 var showSearch = self.showSearch(params); 3557 3558 if (showSearch) { 3559 self.$searchContainer.removeClass('select2-search--hide'); 3560 } else { 3561 self.$searchContainer.addClass('select2-search--hide'); 3562 } 3563 } 3564 }); 3565 }; 3566 3567 Search.prototype.handleSearch = function (evt) { 3568 if (!this._keyUpPrevented) { 3569 var input = this.$search.val(); 3570 3571 this.trigger('query', { 3572 term: input 3573 }); 3574 } 3575 3576 this._keyUpPrevented = false; 3577 }; 3578 3579 Search.prototype.showSearch = function (_, params) { 3580 return true; 3581 }; 3582 3583 return Search; 3584 }); 3585 3586 define('select2/dropdown/hidePlaceholder',[ 3587 3588 ], function () { 3589 function HidePlaceholder (decorated, $element, options, dataAdapter) { 3590 this.placeholder = this.normalizePlaceholder(options.get('placeholder')); 3591 3592 decorated.call(this, $element, options, dataAdapter); 3593 } 3594 3595 HidePlaceholder.prototype.append = function (decorated, data) { 3596 data.results = this.removePlaceholder(data.results); 3597 3598 decorated.call(this, data); 3599 }; 3600 3601 HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) { 3602 if (typeof placeholder === 'string') { 3603 placeholder = { 3604 id: '', 3605 text: placeholder 3606 }; 3607 } 3608 3609 return placeholder; 3610 }; 3611 3612 HidePlaceholder.prototype.removePlaceholder = function (_, data) { 3613 var modifiedData = data.slice(0); 3614 3615 for (var d = data.length - 1; d >= 0; d--) { 3616 var item = data[d]; 3617 3618 if (this.placeholder.id === item.id) { 3619 modifiedData.splice(d, 1); 3620 } 3621 } 3622 3623 return modifiedData; 3624 }; 3625 3626 return HidePlaceholder; 3627 }); 3628 3629 define('select2/dropdown/infiniteScroll',[ 3630 'jquery' 3631 ], function ($) { 3632 function InfiniteScroll (decorated, $element, options, dataAdapter) { 3633 this.lastParams = {}; 3634 3635 decorated.call(this, $element, options, dataAdapter); 3636 3637 this.$loadingMore = this.createLoadingMore(); 3638 this.loading = false; 3639 } 3640 3641 InfiniteScroll.prototype.append = function (decorated, data) { 3642 this.$loadingMore.remove(); 3643 this.loading = false; 3644 3645 decorated.call(this, data); 3646 3647 if (this.showLoadingMore(data)) { 3648 this.$results.append(this.$loadingMore); 3649 } 3650 }; 3651 3652 InfiniteScroll.prototype.bind = function (decorated, container, $container) { 3653 var self = this; 3654 3655 decorated.call(this, container, $container); 3656 3657 container.on('query', function (params) { 3658 self.lastParams = params; 3659 self.loading = true; 3660 }); 3661 3662 container.on('query:append', function (params) { 3663 self.lastParams = params; 3664 self.loading = true; 3665 }); 3666 3667 this.$results.on('scroll', function () { 3668 var isLoadMoreVisible = $.contains( 3669 document.documentElement, 3670 self.$loadingMore[0] 3671 ); 3672 3673 if (self.loading || !isLoadMoreVisible) { 3674 return; 3675 } 3676 3677 var currentOffset = self.$results.offset().top + 3678 self.$results.outerHeight(false); 3679 var loadingMoreOffset = self.$loadingMore.offset().top + 3680 self.$loadingMore.outerHeight(false); 3681 3682 if (currentOffset + 50 >= loadingMoreOffset) { 3683 self.loadMore(); 3684 } 3685 }); 3686 }; 3687 3688 InfiniteScroll.prototype.loadMore = function () { 3689 this.loading = true; 3690 3691 var params = $.extend({}, {page: 1}, this.lastParams); 3692 3693 params.page++; 3694 3695 this.trigger('query:append', params); 3696 }; 3697 3698 InfiniteScroll.prototype.showLoadingMore = function (_, data) { 3699 return data.pagination && data.pagination.more; 3700 }; 3701 3702 InfiniteScroll.prototype.createLoadingMore = function () { 3703 var $option = $( 3704 '<li class="option load-more" role="treeitem"></li>' 3705 ); 3706 3707 var message = this.options.get('translations').get('loadingMore'); 3708 3709 $option.html(message(this.lastParams)); 3710 3711 return $option; 3712 }; 3713 3714 return InfiniteScroll; 3715 }); 3716 3717 define('select2/dropdown/attachBody',[ 3718 'jquery', 3719 '../utils' 3720 ], function ($, Utils) { 3721 function AttachBody (decorated, $element, options) { 3722 this.$dropdownParent = options.get('dropdownParent') || document.body; 3723 3724 decorated.call(this, $element, options); 3725 } 3726 3727 AttachBody.prototype.bind = function (decorated, container, $container) { 3728 var self = this; 3729 3730 var setupResultsEvents = false; 3731 3732 decorated.call(this, container, $container); 3733 3734 container.on('open', function () { 3735 self._showDropdown(); 3736 self._attachPositioningHandler(container); 3737 3738 if (!setupResultsEvents) { 3739 setupResultsEvents = true; 3740 3741 container.on('results:all', function () { 3742 self._positionDropdown(); 3743 self._resizeDropdown(); 3744 }); 3745 3746 container.on('results:append', function () { 3747 self._positionDropdown(); 3748 self._resizeDropdown(); 3749 }); 3750 } 3751 }); 3752 3753 container.on('close', function () { 3754 self._hideDropdown(); 3755 self._detachPositioningHandler(container); 3756 }); 3757 3758 this.$dropdownContainer.on('mousedown', function (evt) { 3759 evt.stopPropagation(); 3760 }); 3761 }; 3762 3763 AttachBody.prototype.position = function (decorated, $dropdown, $container) { 3764 // Clone all of the container classes 3765 $dropdown.attr('class', $container.attr('class')); 3766 3767 $dropdown.removeClass('select2'); 3768 $dropdown.addClass('select2-container--open'); 3769 3770 $dropdown.css({ 3771 position: 'absolute', 3772 top: -999999 3773 }); 3774 3775 this.$container = $container; 3776 }; 3777 3778 AttachBody.prototype.render = function (decorated) { 3779 var $container = $('<span></span>'); 3780 3781 var $dropdown = decorated.call(this); 3782 $container.append($dropdown); 3783 3784 this.$dropdownContainer = $container; 3785 3786 return $container; 3787 }; 3788 3789 AttachBody.prototype._hideDropdown = function (decorated) { 3790 this.$dropdownContainer.detach(); 3791 }; 3792 3793 AttachBody.prototype._attachPositioningHandler = function (container) { 3794 var self = this; 3795 3796 var scrollEvent = 'scroll.select2.' + container.id; 3797 var resizeEvent = 'resize.select2.' + container.id; 3798 var orientationEvent = 'orientationchange.select2.' + container.id; 3799 3800 $watchers = this.$container.parents().filter(Utils.hasScroll); 3801 $watchers.each(function () { 3802 $(this).data('select2-scroll-position', { 3803 x: $(this).scrollLeft(), 3804 y: $(this).scrollTop() 3805 }); 3806 }); 3807 3808 $watchers.on(scrollEvent, function (ev) { 3809 var position = $(this).data('select2-scroll-position'); 3810 $(this).scrollTop(position.y); 3811 }); 3812 3813 $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent, 3814 function (e) { 3815 self._positionDropdown(); 3816 self._resizeDropdown(); 3817 }); 3818 }; 3819 3820 AttachBody.prototype._detachPositioningHandler = function (container) { 3821 var scrollEvent = 'scroll.select2.' + container.id; 3822 var resizeEvent = 'resize.select2.' + container.id; 3823 var orientationEvent = 'orientationchange.select2.' + container.id; 3824 3825 $watchers = this.$container.parents().filter(Utils.hasScroll); 3826 $watchers.off(scrollEvent); 3827 3828 $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent); 3829 }; 3830 3831 AttachBody.prototype._positionDropdown = function () { 3832 var $window = $(window); 3833 3834 var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above'); 3835 var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below'); 3836 3837 var newDirection = null; 3838 3839 var position = this.$container.position(); 3840 var offset = this.$container.offset(); 3841 3842 offset.bottom = offset.top + this.$container.outerHeight(false); 3843 3844 var container = { 3845 height: this.$container.outerHeight(false) 3846 }; 3847 3848 container.top = offset.top; 3849 container.bottom = offset.top + container.height; 3850 3851 var dropdown = { 3852 height: this.$dropdown.outerHeight(false) 3853 }; 3854 3855 var viewport = { 3856 top: $window.scrollTop(), 3857 bottom: $window.scrollTop() + $window.height() 3858 }; 3859 3860 var enoughRoomAbove = viewport.top < (offset.top - dropdown.height); 3861 var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height); 3862 3863 var css = { 3864 left: offset.left, 3865 top: container.bottom 3866 }; 3867 3868 if (!isCurrentlyAbove && !isCurrentlyBelow) { 3869 newDirection = 'below'; 3870 } 3871 3872 if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) { 3873 newDirection = 'above'; 3874 } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) { 3875 newDirection = 'below'; 3876 } 3877 3878 if (newDirection == 'above' || 3879 (isCurrentlyAbove && newDirection !== 'below')) { 3880 css.top = container.top - dropdown.height; 3881 } 3882 3883 if (newDirection != null) { 3884 this.$dropdown 3885 .removeClass('select2-dropdown--below select2-dropdown--above') 3886 .addClass('select2-dropdown--' + newDirection); 3887 this.$container 3888 .removeClass('select2-container--below select2-container--above') 3889 .addClass('select2-container--' + newDirection); 3890 } 3891 3892 this.$dropdownContainer.css(css); 3893 }; 3894 3895 AttachBody.prototype._resizeDropdown = function () { 3896 this.$dropdownContainer.width(); 3897 3898 this.$dropdown.css({ 3899 width: this.$container.outerWidth(false) + 'px' 3900 }); 3901 }; 3902 3903 AttachBody.prototype._showDropdown = function (decorated) { 3904 this.$dropdownContainer.appendTo(this.$dropdownParent); 3905 3906 this._positionDropdown(); 3907 this._resizeDropdown(); 3908 }; 3909 3910 return AttachBody; 3911 }); 3912 3913 define('select2/dropdown/minimumResultsForSearch',[ 3914 3915 ], function () { 3916 function countResults (data) { 3917 count = 0; 3918 3919 for (var d = 0; d < data.length; d++) { 3920 var item = data[d]; 3921 3922 if (item.children) { 3923 count += countResults(item.children); 3924 } else { 3925 count++; 3926 } 3927 } 3928 3929 return count; 3930 } 3931 3932 function MinimumResultsForSearch (decorated, $element, options, dataAdapter) { 3933 this.minimumResultsForSearch = options.get('minimumResultsForSearch'); 3934 3935 decorated.call(this, $element, options, dataAdapter); 3936 } 3937 3938 MinimumResultsForSearch.prototype.showSearch = function (decorated, params) { 3939 if (countResults(params.data.results) < this.minimumResultsForSearch) { 3940 return false; 3941 } 3942 3943 return decorated.call(this, params); 3944 }; 3945 3946 return MinimumResultsForSearch; 3947 }); 3948 3949 define('select2/dropdown/selectOnClose',[ 3950 3951 ], function () { 3952 function SelectOnClose () { } 3953 3954 SelectOnClose.prototype.bind = function (decorated, container, $container) { 3955 var self = this; 3956 3957 decorated.call(this, container, $container); 3958 3959 container.on('close', function () { 3960 self._handleSelectOnClose(); 3961 }); 3962 }; 3963 3964 SelectOnClose.prototype._handleSelectOnClose = function () { 3965 var $highlightedResults = this.getHighlightedResults(); 3966 3967 if ($highlightedResults.length < 1) { 3968 return; 3969 } 3970 3971 $highlightedResults.trigger('mouseup'); 3972 }; 3973 3974 return SelectOnClose; 3975 }); 3976 3977 define('select2/i18n/en',[],function () { 3978 // English 3979 return { 3980 errorLoading: function () { 3981 return 'The results could not be loaded.'; 3982 }, 3983 inputTooLong: function (args) { 3984 var overChars = args.input.length - args.maximum; 3985 3986 var message = 'Please delete ' + overChars + ' character'; 3987 3988 if (overChars != 1) { 3989 message += 's'; 3990 } 3991 3992 return message; 3993 }, 3994 inputTooShort: function (args) { 3995 var remainingChars = args.minimum - args.input.length; 3996 var n = remainingChars; 3997 var message = 'Please enter ' + remainingChars + ' or more characters'; 3998 message = "ÐожалÑйÑÑа, введиÑе еÑе " + n + " Ñимвол" + (n == 1 ? "" : ((n > 1)&&(n < 5) ? "а" : "ов")); 3999 return message; 4000 }, 4001 loadingMore: function () { 4002 return 'ÐагÑÑзка даннÑÑ ...'; 4003 }, 4004 maximumSelected: function (args) { 4005 var message = 'You can only select ' + args.maximum + ' item'; 4006 4007 if (args.maximum != 1) { 4008 message += 's'; 4009 } 4010 4011 return message; 4012 }, 4013 noResults: function () { 4014 return 'Совпадений не найдено'; 4015 }, 4016 searching: function () { 4017 return 'ÐоиÑкâ¦'; 4018 } 4019 }; 4020 }); 4021 4022 define('select2/defaults',[ 4023 'jquery', 4024 './results', 4025 4026 './selection/single', 4027 './selection/multiple', 4028 './selection/placeholder', 4029 './selection/allowClear', 4030 './selection/search', 4031 './selection/eventRelay', 4032 4033 './utils', 4034 './translation', 4035 './diacritics', 4036 4037 './data/select', 4038 './data/array', 4039 './data/ajax', 4040 './data/tags', 4041 './data/tokenizer', 4042 './data/minimumInputLength', 4043 './data/maximumInputLength', 4044 './data/maximumSelectionLength', 4045 4046 './dropdown', 4047 './dropdown/search', 4048 './dropdown/hidePlaceholder', 4049 './dropdown/infiniteScroll', 4050 './dropdown/attachBody', 4051 './dropdown/minimumResultsForSearch', 4052 './dropdown/selectOnClose', 4053 4054 './i18n/en' 4055 ], function ($, ResultsList, 4056 4057 SingleSelection, MultipleSelection, Placeholder, AllowClear, 4058 SelectionSearch, EventRelay, 4059 4060 Utils, Translation, DIACRITICS, 4061 4062 SelectData, ArrayData, AjaxData, Tags, Tokenizer, 4063 MinimumInputLength, MaximumInputLength, MaximumSelectionLength, 4064 4065 Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll, 4066 AttachBody, MinimumResultsForSearch, SelectOnClose, 4067 4068 EnglishTranslation) { 4069 function Defaults () { 4070 this.reset(); 4071 } 4072 4073 Defaults.prototype.apply = function (options) { 4074 options = $.extend({}, this.defaults, options); 4075 4076 if (options.dataAdapter == null) { 4077 if (options.ajax != null) { 4078 options.dataAdapter = AjaxData; 4079 } else if (options.data != null) { 4080 options.dataAdapter = ArrayData; 4081 } else { 4082 options.dataAdapter = SelectData; 4083 } 4084 4085 if (options.minimumInputLength > 0) { 4086 options.dataAdapter = Utils.Decorate( 4087 options.dataAdapter, 4088 MinimumInputLength 4089 ); 4090 } 4091 4092 if (options.maximumInputLength > 0) { 4093 options.dataAdapter = Utils.Decorate( 4094 options.dataAdapter, 4095 MaximumInputLength 4096 ); 4097 } 4098 4099 if (options.maximumSelectionLength > 0) { 4100 options.dataAdapter = Utils.Decorate( 4101 options.dataAdapter, 4102 MaximumSelectionLength 4103 ); 4104 } 4105 4106 if (options.tags != null) { 4107 options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags); 4108 } 4109 4110 if (options.tokenSeparators != null || options.tokenizer != null) { 4111 options.dataAdapter = Utils.Decorate( 4112 options.dataAdapter, 4113 Tokenizer 4114 ); 4115 } 4116 4117 if (options.query != null) { 4118 var Query = require(options.amdBase + 'compat/query'); 4119 4120 options.dataAdapter = Utils.Decorate( 4121 options.dataAdapter, 4122 Query 4123 ); 4124 } 4125 4126 if (options.initSelection != null) { 4127 var InitSelection = require(options.amdBase + 'compat/initSelection'); 4128 4129 options.dataAdapter = Utils.Decorate( 4130 options.dataAdapter, 4131 InitSelection 4132 ); 4133 } 4134 } 4135 4136 if (options.resultsAdapter == null) { 4137 options.resultsAdapter = ResultsList; 4138 4139 if (options.ajax != null) { 4140 options.resultsAdapter = Utils.Decorate( 4141 options.resultsAdapter, 4142 InfiniteScroll 4143 ); 4144 } 4145 4146 if (options.placeholder != null) { 4147 options.resultsAdapter = Utils.Decorate( 4148 options.resultsAdapter, 4149 HidePlaceholder 4150 ); 4151 } 4152 4153 if (options.selectOnClose) { 4154 options.resultsAdapter = Utils.Decorate( 4155 options.resultsAdapter, 4156 SelectOnClose 4157 ); 4158 } 4159 } 4160 4161 if (options.dropdownAdapter == null) { 4162 if (options.multiple) { 4163 options.dropdownAdapter = Dropdown; 4164 } else { 4165 var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch); 4166 4167 options.dropdownAdapter = SearchableDropdown; 4168 } 4169 4170 if (options.minimumResultsForSearch > 0) { 4171 options.dropdownAdapter = Utils.Decorate( 4172 options.dropdownAdapter, 4173 MinimumResultsForSearch 4174 ); 4175 } 4176 4177 options.dropdownAdapter = Utils.Decorate( 4178 options.dropdownAdapter, 4179 AttachBody 4180 ); 4181 } 4182 4183 if (options.selectionAdapter == null) { 4184 if (options.multiple) { 4185 options.selectionAdapter = MultipleSelection; 4186 } else { 4187 options.selectionAdapter = SingleSelection; 4188 } 4189 4190 // Add the placeholder mixin if a placeholder was specified 4191 if (options.placeholder != null) { 4192 options.selectionAdapter = Utils.Decorate( 4193 options.selectionAdapter, 4194 Placeholder 4195 ); 4196 4197 if (options.allowClear) { 4198 options.selectionAdapter = Utils.Decorate( 4199 options.selectionAdapter, 4200 AllowClear 4201 ); 4202 } 4203 } 4204 4205 if (options.multiple) { 4206 options.selectionAdapter = Utils.Decorate( 4207 options.selectionAdapter, 4208 SelectionSearch 4209 ); 4210 } 4211 4212 options.selectionAdapter = Utils.Decorate( 4213 options.selectionAdapter, 4214 EventRelay 4215 ); 4216 } 4217 4218 if (typeof options.language === 'string') { 4219 // Check if the lanugage is specified with a region 4220 if (options.language.indexOf('-') > 0) { 4221 // Extract the region information if it is included 4222 var languageParts = options.language.split('-'); 4223 var baseLanguage = languageParts[0]; 4224 4225 options.language = [options.language, baseLanguage]; 4226 } else { 4227 options.language = [options.language]; 4228 } 4229 } 4230 4231 if ($.isArray(options.language)) { 4232 var languages = new Translation(); 4233 options.language.push('en'); 4234 4235 var languageNames = options.language; 4236 4237 for (var l = 0; l < languageNames.length; l++) { 4238 var name = languageNames[l]; 4239 var language = {}; 4240 4241 try { 4242 // Try to load it with the original name 4243 language = Translation.loadPath(name); 4244 } catch (e) { 4245 try { 4246 // If we couldn't load it, check if it wasn't the full path 4247 name = this.defaults.amdLanguageBase + name; 4248 language = Translation.loadPath(name); 4249 } catch (ex) { 4250 // The translation could not be loaded at all. Sometimes this is 4251 // because of a configuration problem, other times this can be 4252 // because of how Select2 helps load all possible translation files. 4253 if (console && console.warn) { 4254 console.warn( 4255 'Select2: The lanugage file for "' + name + '" could not be ' + 4256 'automatically loaded. A fallback will be used instead.' 4257 ); 4258 } 4259 4260 continue; 4261 } 4262 } 4263 4264 languages.extend(language); 4265 } 4266 4267 options.translations = languages; 4268 } else { 4269 options.translations = new Translation(options.language); 4270 } 4271 4272 return options; 4273 }; 4274 4275 Defaults.prototype.reset = function () { 4276 function stripDiacritics (text) { 4277 // Used 'uni range + named function' from http://jsperf.com/diacritics/18 4278 function match(a) { 4279 return DIACRITICS[a] || a; 4280 } 4281 4282 return text.replace(/[^\u0000-\u007E]/g, match); 4283 } 4284 4285 function matcher (params, data) { 4286 // Always return the object if there is nothing to compare 4287 if ($.trim(params.term) === '') { 4288 return data; 4289 } 4290 4291 // Do a recursive check for options with children 4292 if (data.children && data.children.length > 0) { 4293 // Clone the data object if there are children 4294 // This is required as we modify the object to remove any non-matches 4295 var match = $.extend(true, {}, data); 4296 4297 // Check each child of the option 4298 for (var c = data.children.length - 1; c >= 0; c--) { 4299 var child = data.children[c]; 4300 4301 var matches = matcher(params, child); 4302 4303 // If there wasn't a match, remove the object in the array 4304 if (matches == null) { 4305 match.children.splice(c, 1); 4306 } 4307 } 4308 4309 // If any children matched, return the new object 4310 if (match.children.length > 0) { 4311 return match; 4312 } 4313 4314 // If there were no matching children, check just the plain object 4315 return matcher(params, match); 4316 } 4317 4318 var original = stripDiacritics(data.text).toUpperCase(); 4319 var term = stripDiacritics(params.term).toUpperCase(); 4320 4321 // Check if the text contains the term 4322 if (original.indexOf(term) > -1) { 4323 return data; 4324 } 4325 4326 // If it doesn't contain the term, don't return anything 4327 return null; 4328 } 4329 4330 this.defaults = { 4331 amdBase: 'select2/', 4332 amdLanguageBase: 'select2/i18n/', 4333 language: EnglishTranslation, 4334 matcher: matcher, 4335 minimumInputLength: 0, 4336 maximumInputLength: 0, 4337 maximumSelectionLength: 0, 4338 minimumResultsForSearch: 0, 4339 selectOnClose: false, 4340 sorter: function (data) { 4341 return data; 4342 }, 4343 templateResult: function (result) { 4344 return result.text; 4345 }, 4346 templateSelection: function (selection) { 4347 return selection.text; 4348 }, 4349 theme: 'default', 4350 width: 'resolve' 4351 }; 4352 }; 4353 4354 Defaults.prototype.set = function (key, value) { 4355 var camelKey = $.camelCase(key); 4356 4357 var data = {}; 4358 data[camelKey] = value; 4359 4360 var convertedData = Utils._convertData(data); 4361 4362 $.extend(this.defaults, convertedData); 4363 }; 4364 4365 var defaults = new Defaults(); 4366 4367 return defaults; 4368 }); 4369 4370 define('select2/options',[ 4371 'jquery', 4372 './defaults', 4373 './utils' 4374 ], function ($, Defaults, Utils) { 4375 function Options (options, $element) { 4376 this.options = options; 4377 4378 if ($element != null) { 4379 this.fromElement($element); 4380 } 4381 4382 this.options = Defaults.apply(this.options); 4383 } 4384 4385 Options.prototype.fromElement = function ($e) { 4386 var excludedData = ['select2']; 4387 4388 if (this.options.multiple == null) { 4389 this.options.multiple = $e.prop('multiple'); 4390 } 4391 4392 if (this.options.disabled == null) { 4393 this.options.disabled = $e.prop('disabled'); 4394 } 4395 4396 if (this.options.language == null) { 4397 if ($e.prop('lang')) { 4398 this.options.language = $e.prop('lang').toLowerCase(); 4399 } else if ($e.closest('[lang]').prop('lang')) { 4400 this.options.language = $e.closest('[lang]').prop('lang'); 4401 } 4402 } 4403 4404 if (this.options.dir == null) { 4405 if ($e.prop('dir')) { 4406 this.options.dir = $e.prop('dir'); 4407 } else if ($e.closest('[dir]').prop('dir')) { 4408 this.options.dir = $e.closest('[dir]').prop('dir'); 4409 } else { 4410 this.options.dir = 'ltr'; 4411 } 4412 } 4413 4414 $e.prop('disabled', this.options.disabled); 4415 $e.prop('multiple', this.options.multiple); 4416 4417 if ($e.data('select2-tags')) { 4418 if (console && console.warn) { 4419 console.warn( 4420 'Select2: The `data-select2-tags` attribute has been changed to ' + 4421 'use the `data-data` and `data-tags="true"` attributes and will be ' + 4422 'removed in future versions of Select2.' 4423 ); 4424 } 4425 4426 $e.data('data', $e.data('select2-tags')); 4427 $e.data('tags', true); 4428 } 4429 4430 if ($e.data('ajax-url')) { 4431 if (console && console.warn) { 4432 console.warn( 4433 'Select2: The `data-ajax-url` attribute has been changed to ' + 4434 '`data-ajax--url` and support for the old attribute will be removed' + 4435 ' in future versions of Select2.' 4436 ); 4437 } 4438 4439 $e.data('ajax--url', $e.data('ajax-url')); 4440 } 4441 4442 var data = $e.data(); 4443 4444 data = Utils._convertData(data); 4445 4446 for (var key in data) { 4447 if (excludedData.indexOf(key) > -1) { 4448 continue; 4449 } 4450 4451 if ($.isPlainObject(this.options[key])) { 4452 $.extend(this.options[key], data[key]); 4453 } else { 4454 this.options[key] = data[key]; 4455 } 4456 } 4457 4458 return this; 4459 }; 4460 4461 Options.prototype.get = function (key) { 4462 return this.options[key]; 4463 }; 4464 4465 Options.prototype.set = function (key, val) { 4466 this.options[key] = val; 4467 }; 4468 4469 return Options; 4470 }); 4471 4472 define('select2/core',[ 4473 'jquery', 4474 './options', 4475 './utils', 4476 './keys' 4477 ], function ($, Options, Utils, KEYS) { 4478 var Select2 = function ($element, options) { 4479 if ($element.data('select2') != null) { 4480 $element.data('select2').destroy(); 4481 } 4482 4483 this.$element = $element; 4484 4485 this.id = this._generateId($element); 4486 4487 options = options || {}; 4488 4489 this.options = new Options(options, $element); 4490 4491 Select2.__super__.constructor.call(this); 4492 4493 // Set up containers and adapters 4494 4495 var DataAdapter = this.options.get('dataAdapter'); 4496 this.data = new DataAdapter($element, this.options); 4497 4498 var $container = this.render(); 4499 4500 this._placeContainer($container); 4501 4502 var SelectionAdapter = this.options.get('selectionAdapter'); 4503 this.selection = new SelectionAdapter($element, this.options); 4504 this.$selection = this.selection.render(); 4505 4506 this.selection.position(this.$selection, $container); 4507 4508 var DropdownAdapter = this.options.get('dropdownAdapter'); 4509 this.dropdown = new DropdownAdapter($element, this.options); 4510 this.$dropdown = this.dropdown.render(); 4511 4512 this.dropdown.position(this.$dropdown, $container); 4513 4514 var ResultsAdapter = this.options.get('resultsAdapter'); 4515 this.results = new ResultsAdapter($element, this.options, this.data); 4516 this.$results = this.results.render(); 4517 4518 this.results.position(this.$results, this.$dropdown); 4519 4520 // Bind events 4521 4522 var self = this; 4523 4524 // Bind the container to all of the adapters 4525 this._bindAdapters(); 4526 4527 // Register any DOM event handlers 4528 this._registerDomEvents(); 4529 4530 // Register any internal event handlers 4531 this._registerDataEvents(); 4532 this._registerSelectionEvents(); 4533 this._registerDropdownEvents(); 4534 this._registerResultsEvents(); 4535 this._registerEvents(); 4536 4537 // Set the initial state 4538 this.data.current(function (initialData) { 4539 self.trigger('selection:update', { 4540 data: initialData 4541 }); 4542 }); 4543 4544 // Hide the original select 4545 $element.hide(); 4546 4547 // Synchronize any monitored attributes 4548 this._syncAttributes(); 4549 4550 this._tabindex = $element.attr('tabindex') || 0; 4551 4552 $element.attr('tabindex', '-1'); 4553 4554 $element.data('select2', this); 4555 }; 4556 4557 Utils.Extend(Select2, Utils.Observable); 4558 4559 Select2.prototype._generateId = function ($element) { 4560 var id = ''; 4561 4562 if ($element.attr('id') != null) { 4563 id = $element.attr('id'); 4564 } else if ($element.attr('name') != null) { 4565 id = $element.attr('name') + '-' + Utils.generateChars(2); 4566 } else { 4567 id = Utils.generateChars(4); 4568 } 4569 4570 id = 'select2-' + id; 4571 4572 return id; 4573 }; 4574 4575 Select2.prototype._placeContainer = function ($container) { 4576 $container.insertAfter(this.$element); 4577 4578 var width = this._resolveWidth(this.$element, this.options.get('width')); 4579 4580 if (width != null) { 4581 $container.css('width', width); 4582 } 4583 }; 4584 4585 Select2.prototype._resolveWidth = function ($element, method) { 4586 var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i; 4587 4588 if (method == 'resolve') { 4589 var styleWidth = this._resolveWidth($element, 'style'); 4590 4591 if (styleWidth != null) { 4592 return styleWidth; 4593 } 4594 4595 return this._resolveWidth($element, 'element'); 4596 } 4597 4598 if (method == 'element') { 4599 var elementWidth = $element.outerWidth(false); 4600 4601 if (elementWidth <= 0) { 4602 return 'auto'; 4603 } 4604 4605 return elementWidth + 'px'; 4606 } 4607 4608 if (method == 'style') { 4609 var style = $element.attr('style'); 4610 4611 if (typeof(style) !== 'string') { 4612 return null; 4613 } 4614 4615 var attrs = style.split(';'); 4616 4617 for (i = 0, l = attrs.length; i < l; i = i + 1) { 4618 attr = attrs[i].replace(/\s/g, ''); 4619 var matches = attr.match(WIDTH); 4620 4621 if (matches !== null && matches.length >= 1) { 4622 return matches[1]; 4623 } 4624 } 4625 4626 return null; 4627 } 4628 4629 return method; 4630 }; 4631 4632 Select2.prototype._bindAdapters = function () { 4633 this.data.bind(this, this.$container); 4634 this.selection.bind(this, this.$container); 4635 4636 this.dropdown.bind(this, this.$container); 4637 this.results.bind(this, this.$container); 4638 }; 4639 4640 Select2.prototype._registerDomEvents = function () { 4641 var self = this; 4642 4643 this.$element.on('change.select2', function () { 4644 self.data.current(function (data) { 4645 self.trigger('selection:update', { 4646 data: data 4647 }); 4648 }); 4649 }); 4650 4651 this._sync = Utils.bind(this._syncAttributes, this); 4652 4653 if (this.$element[0].attachEvent) { 4654 this.$element[0].attachEvent('onpropertychange', this._sync); 4655 } 4656 4657 var observer = window.MutationObserver || 4658 window.WebKitMutationObserver || 4659 window.MozMutationObserver 4660 ; 4661 4662 if (observer != null) { 4663 this._observer = new observer(function (mutations) { 4664 $.each(mutations, self._sync); 4665 }); 4666 this._observer.observe(this.$element[0], { 4667 attributes: true, 4668 subtree: false 4669 }); 4670 } 4671 }; 4672 4673 Select2.prototype._registerDataEvents = function () { 4674 var self = this; 4675 4676 this.data.on('*', function (name, params) { 4677 self.trigger(name, params); 4678 }); 4679 }; 4680 4681 Select2.prototype._registerSelectionEvents = function () { 4682 var self = this; 4683 var nonRelayEvents = ['toggle']; 4684 4685 this.selection.on('toggle', function () { 4686 self.toggleDropdown(); 4687 }); 4688 4689 this.selection.on('*', function (name, params) { 4690 if (nonRelayEvents.indexOf(name) !== -1) { 4691 return; 4692 } 4693 4694 self.trigger(name, params); 4695 }); 4696 }; 4697 4698 Select2.prototype._registerDropdownEvents = function () { 4699 var self = this; 4700 4701 this.dropdown.on('*', function (name, params) { 4702 self.trigger(name, params); 4703 }); 4704 }; 4705 4706 Select2.prototype._registerResultsEvents = function () { 4707 var self = this; 4708 4709 this.results.on('*', function (name, params) { 4710 self.trigger(name, params); 4711 }); 4712 }; 4713 4714 Select2.prototype._registerEvents = function () { 4715 var self = this; 4716 4717 this.on('open', function () { 4718 self.$container.addClass('select2-container--open'); 4719 }); 4720 4721 this.on('close', function () { 4722 self.$container.removeClass('select2-container--open'); 4723 }); 4724 4725 this.on('enable', function () { 4726 self.$container.removeClass('select2-container--disabled'); 4727 }); 4728 4729 this.on('disable', function () { 4730 self.$container.addClass('select2-container--disabled'); 4731 }); 4732 4733 this.on('query', function (params) { 4734 this.data.query(params, function (data) { 4735 self.trigger('results:all', { 4736 data: data, 4737 query: params 4738 }); 4739 }); 4740 }); 4741 4742 this.on('query:append', function (params) { 4743 this.data.query(params, function (data) { 4744 self.trigger('results:append', { 4745 data: data, 4746 query: params 4747 }); 4748 }); 4749 }); 4750 4751 this.on('keypress', function (evt) { 4752 var key = evt.which; 4753 4754 if (self.isOpen()) { 4755 if (key === KEYS.ENTER) { 4756 self.trigger('results:select'); 4757 4758 evt.preventDefault(); 4759 } else if (key === KEYS.UP) { 4760 self.trigger('results:previous'); 4761 4762 evt.preventDefault(); 4763 } else if (key === KEYS.DOWN) { 4764 self.trigger('results:next'); 4765 4766 evt.preventDefault(); 4767 } else if (key === KEYS.ESC || key === KEYS.TAB) { 4768 self.close(); 4769 4770 evt.preventDefault(); 4771 } 4772 } else { 4773 if (key === KEYS.ENTER || key === KEYS.SPACE || 4774 ((key === KEYS.DOWN || key === KEYS.UP) && evt.altKey)) { 4775 self.open(); 4776 4777 evt.preventDefault(); 4778 } 4779 } 4780 }); 4781 }; 4782 4783 Select2.prototype._syncAttributes = function () { 4784 this.options.set('disabled', this.$element.prop('disabled')); 4785 4786 if (this.options.get('disabled')) { 4787 if (this.isOpen()) { 4788 this.close(); 4789 } 4790 4791 this.trigger('disable'); 4792
4792 } else { 4793 this.trigger('enable'); 4794 } 4795 }; 4796 4797 /** 4798 * Override the trigger method to automatically trigger pre-events when 4799 * there are events that can be prevented. 4800 */ 4801 Select2.prototype.trigger = function (name, args) { 4802 var actualTrigger = Select2.__super__.trigger; 4803 var preTriggerMap = { 4804 'open': 'opening', 4805 'close': 'closing', 4806 'select': 'selecting', 4807 'unselect': 'unselecting' 4808 }; 4809 4810 if (name in preTriggerMap) { 4811 var preTriggerName = preTriggerMap[name]; 4812 var preTriggerArgs = { 4813 prevented: false, 4814 name: name, 4815 args: args 4816 }; 4817 4818 actualTrigger.call(this, preTriggerName, preTriggerArgs); 4819 4820 if (preTriggerArgs.prevented) { 4821 args.prevented = true; 4822 4823 return; 4824 } 4825 } 4826 4827 actualTrigger.call(this, name, args); 4828 }; 4829 4830 Select2.prototype.toggleDropdown = function () { 4831 if (this.options.get('disabled')) { 4832 return; 4833 } 4834 4835 if (this.isOpen()) { 4836 this.close(); 4837 } else { 4838 this.open(); 4839 } 4840 }; 4841 4842 Select2.prototype.open = function () { 4843 if (this.isOpen()) { 4844 return; 4845 } 4846 4847 this.trigger('query', {}); 4848 4849 this.trigger('open'); 4850 }; 4851 4852 Select2.prototype.close = function () { 4853 if (!this.isOpen()) { 4854 return; 4855 } 4856 4857 this.trigger('close'); 4858 }; 4859 4860 Select2.prototype.isOpen = function () { 4861 return this.$container.hasClass('select2-container--open'); 4862 }; 4863 4864 Select2.prototype.enable = function (args) { 4865 if (console && console.warn) { 4866 console.warn( 4867 'Select2: The `select2("enable")` method has been deprecated and will' + 4868 ' be removed in later Select2 versions. Use $element.prop("disabled")' + 4869 ' instead.' 4870 ); 4871 } 4872 4873 if (args.length === 0) { 4874 args = [true]; 4875 } 4876 4877 var disabled = !args[0]; 4878 4879 this.$element.prop('disabled', disabled); 4880 }; 4881 4882 Select2.prototype.val = function (args) { 4883 4884 if (args.length === 0) { 4885 return this.$element.val(); 4886 } 4887 4888 var newVal = args[0]; 4889 4890 if ($.isArray(newVal)) { 4891 newVal = $.map(newVal, function (obj) { 4892 return obj.toString(); 4893 }); 4894 } 4895 4896 this.$element.val(newVal).trigger('change'); 4897 }; 4898 4899 Select2.prototype.destroy = function () { 4900 this.$container.remove(); 4901 4902 if (this.$element[0].detachEvent) { 4903 this.$element[0].detachEvent('onpropertychange', this._sync); 4904 } 4905 4906 if (this._observer != null) { 4907 this._observer.disconnect(); 4908 this._observer = null; 4909 } 4910 4911 this._sync = null; 4912 4913 this.$element.off('.select2'); 4914 this.$element.attr('tabindex', this._tabindex); 4915 4916 this.$element.show(); 4917 this.$element.removeData('select2'); 4918 4919 this.data.destroy(); 4920 this.selection.destroy(); 4921 this.dropdown.destroy(); 4922 this.results.destroy(); 4923 4924 this.data = null; 4925 this.selection = null; 4926 this.dropdown = null; 4927 this.results = null; 4928 }; 4929 4930 Select2.prototype.render = function () { 4931 var $container = $( 4932 '<span class="select2 select2-container">' + 4933 '<span class="selection"></span>' + 4934 '<span class="dropdown-wrapper" aria-hidden="true"></span>' + 4935 '</span>' 4936 ); 4937 4938 $container.attr('dir', this.options.get('dir')); 4939 4940 this.$container = $container; 4941 4942 this.$container.addClass('select2-container--' + this.options.get('theme')); 4943 4944 $container.data('element', this.$element); 4945 4946 return $container; 4947 }; 4948 4949 return Select2; 4950 }); 4951 4952 define('jquery.select2',[ 4953 'jquery', 4954 './select2/core', 4955 './select2/defaults' 4956 ], function ($, Select2, Defaults) { 4957 // Force jQuery.mousewheel to be loaded if it hasn't already 4958 try { 4959 require('jquery.mousewheel'); 4960 } catch (Exception) { } 4961 4962 if ($.fn.select2 == null) { 4963 $.fn.select2 = function (options) { 4964 options = options || {}; 4965 4966 if (typeof options === 'object') { 4967 this.each(function () { 4968 var instanceOptions = $.extend({}, options, true); 4969 4970 var instance = new Select2($(this), instanceOptions); 4971 }); 4972 4973 return this; 4974 } else if (typeof options === 'string') { 4975 var instance = this.data('select2'); 4976 var args = Array.prototype.slice.call(arguments, 1); 4977 4978 return instance[options](args); 4979 } else { 4980 throw new Error('Invalid arguments for Select2: ' + options); 4981 } 4982 }; 4983 } 4984 4985 if ($.fn.select2.defaults == null) { 4986 $.fn.select2.defaults = Defaults; 4987 } 4988 4989 return Select2; 4990 }); 4991 4992 require('jquery.select2'); jQuery.fn.select2.amd = { define: define, require: require }; }());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.