1/*! 2 * SelectWoo 1.0.10
vendor: 23,608 bytes, lines 2-758
2 3 * https://github.com/woocommerce/selectWoo 4 * 5 * Released under the MIT license 6 * https://github.com/woocommerce/selectWoo/blob/master/LICENSE.md 7 */ 8(function (factory) { 9 if (typeof define === 'function' && define.amd) { 10 // AMD. Register as an anonymous module. 11 define(['jquery'], factory); 12 } else if (typeof module === 'object' && module.exports) { 13 // Node/CommonJS 14 module.exports = function (root, jQuery) { 15 if (jQuery === undefined) { 16 // require('jQuery') returns a factory that requires window to 17 // build a jQuery instance, we normalize how we use modules 18 // that require this pattern but the window provided is a noop 19 // if it's defined (how jquery works) 20 if (typeof window !== 'undefined') { 21 jQuery = require('jquery'); 22 } 23 else { 24 jQuery = require('jquery')(root); 25 } 26 } 27 factory(jQuery); 28 return jQuery; 29 }; 30 } else { 31 // Browser globals 32 factory(jQuery); 33 } 34} (function (jQuery) { 35 // This is needed so we can catch the AMD loader configuration and use it 36 // The inner file should be wrapped (by `banner.start.js`) in a function that 37 // returns the AMD loader references. 38 var S2 =(function () { 39 // Restore the Select2 AMD loader so it can be used 40 // Needed mostly in the language files, where the loader is not inserted 41 if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) { 42 var S2 = jQuery.fn.select2.amd; 43 } 44var S2;(function () { if (!S2 || !S2.requirejs) { 45if (!S2) { S2 = {}; } else { require = S2; } 46/** 47 * @license almond 0.3.3 Copyright jQuery Foundation and other contributors. 48 * Released under MIT license, http://github.com/requirejs/almond/LICENSE 49 */ 50//Going sloppy to avoid 'use strict' string cost, but strict practices should 51//be followed. 52/*global setTimeout: false */ 53 54var requirejs, require, define; 55(function (undef) { 56 var main, req, makeMap, handlers, 57 defined = {}, 58 waiting = {}, 59 config = {}, 60 defining = {}, 61 hasOwn = Object.prototype.hasOwnProperty, 62 aps = [].slice, 63 jsSuffixRegExp = /\.js$/; 64 65 function hasProp(obj, prop) { 66 return hasOwn.call(obj, prop); 67 } 68 69 /** 70 * Given a relative module name, like ./something, normalize it to 71 * a real name that can be mapped to a path. 72 * @param {String} name the relative name 73 * @param {String} baseName a real name that the name arg is relative 74 * to. 75 * @returns {String} normalized name 76 */ 77 function normalize(name, baseName) { 78 var nameParts, nameSegment, mapValue, foundMap, lastIndex, 79 foundI, foundStarMap, starI, i, j, part, normalizedBaseParts, 80 baseParts = baseName && baseName.split("/"), 81 map = config.map, 82 starMap = (map && map['*']) || {}; 83 84 //Adjust any relative paths. 85 if (name) { 86 name = name.split('/'); 87 lastIndex = name.length - 1; 88 89 // If wanting node ID compatibility, strip .js from end 90 // of IDs. Have to do this here, and not in nameToUrl 91 // because node allows either .js or non .js to map 92 // to same file. 93 if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { 94 name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); 95 } 96 97 // Starts with a '.' so need the baseName 98 if (name[0].charAt(0) === '.' && baseParts) { 99 //Convert baseName to array, and lop off the last part, 100 //so that . matches that 'directory' and not name of the baseName's 101 //module. For instance, baseName of 'one/two/three', maps to 102 //'one/two/three.js', but we want the directory, 'one/two' for 103 //this normalization. 104 normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); 105 name = normalizedBaseParts.concat(name); 106 } 107 108 //start trimDots 109 for (i = 0; i < name.length; i++) { 110 part = name[i]; 111 if (part === '.') { 112 name.splice(i, 1); 113 i -= 1; 114 } else if (part === '..') { 115 // If at the start, or previous value is still .., 116 // keep them so that when converted to a path it may 117 // still work when converted to a path, even though 118 // as an ID it is less than ideal. In larger point 119 // releases, may be better to just kick out an error. 120 if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') { 121 continue; 122 } else if (i > 0) { 123 name.splice(i - 1, 2); 124 i -= 2; 125 } 126 } 127 } 128 //end trimDots 129 130 name = name.join('/'); 131 } 132 133 //Apply map config if available. 134 if ((baseParts || starMap) && map) { 135 nameParts = name.split('/'); 136 137 for (i = nameParts.length; i > 0; i -= 1) { 138 nameSegment = nameParts.slice(0, i).join("/"); 139 140 if (baseParts) { 141 //Find the longest baseName segment match in the config. 142 //So, do joins on the biggest to smallest lengths of baseParts. 143 for (j = baseParts.length; j > 0; j -= 1) { 144 mapValue = map[baseParts.slice(0, j).join('/')]; 145 146 //baseName segment has config, find if it has one for 147 //this name. 148 if (mapValue) { 149 mapValue = mapValue[nameSegment]; 150 if (mapValue) { 151 //Match, update name to the new value. 152 foundMap = mapValue; 153 foundI = i; 154 break; 155 } 156 } 157 } 158 } 159 160 if (foundMap) { 161 break; 162 } 163 164 //Check for a star map match, but just hold on to it, 165 //if there is a shorter segment match later in a matching 166 //config, then favor over this star map. 167 if (!foundStarMap && starMap && starMap[nameSegment]) { 168 foundStarMap = starMap[nameSegment]; 169 starI = i; 170 } 171 } 172 173 if (!foundMap && foundStarMap) { 174 foundMap = foundStarMap; 175 foundI = starI; 176 } 177 178 if (foundMap) { 179 nameParts.splice(0, foundI, foundMap); 180 name = nameParts.join('/'); 181 } 182 } 183 184 return name; 185 } 186 187 function makeRequire(relName, forceSync) { 188 return function () { 189 //A version of a require function that passes a moduleName 190 //value for items that may need to 191 //look up paths relative to the moduleName 192 var args = aps.call(arguments, 0); 193 194 //If first arg is not require('string'), and there is only 195 //one arg, it is the array form without a callback. Insert 196 //a null so that the following concat is correct. 197 if (typeof args[0] !== 'string' && args.length === 1) { 198 args.push(null); 199 } 200 return req.apply(undef, args.concat([relName, forceSync])); 201 }; 202 } 203 204 function makeNormalize(relName) { 205 return function (name) { 206 return normalize(name, relName); 207 }; 208 } 209 210 function makeLoad(depName) { 211 return function (value) { 212 defined[depName] = value; 213 }; 214 } 215 216 function callDep(name) { 217 if (hasProp(waiting, name)) { 218 var args = waiting[name]; 219 delete waiting[name]; 220 defining[name] = true; 221 main.apply(undef, args); 222 } 223 224 if (!hasProp(defined, name) && !hasProp(defining, name)) { 225 throw new Error('No ' + name); 226 } 227 return defined[name]; 228 } 229 230 //Turns a plugin!resource to [plugin, resource] 231 //with the plugin being undefined if the name 232 //did not have a plugin prefix. 233 function splitPrefix(name) { 234 var prefix, 235 index = name ? name.indexOf('!') : -1; 236 if (index > -1) { 237 prefix = name.substring(0, index); 238 name = name.substring(index + 1, name.length); 239 } 240 return [prefix, name]; 241 } 242 243 //Creates a parts array for a relName where first part is plugin ID, 244 //second part is resource ID. Assumes relName has already been normalized. 245 function makeRelParts(relName) { 246 return relName ? splitPrefix(relName) : []; 247 } 248 249 /** 250 * Makes a name map, normalizing the name, and using a plugin 251 * for normalization if necessary. Grabs a ref to plugin 252 * too, as an optimization. 253 */ 254 makeMap = function (name, relParts) { 255 var plugin, 256 parts = splitPrefix(name), 257 prefix = parts[0], 258 relResourceName = relParts[1]; 259 260 name = parts[1]; 261 262 if (prefix) { 263 prefix = normalize(prefix, relResourceName); 264 plugin = callDep(prefix); 265 } 266 267 //Normalize according 268 if (prefix) { 269 if (plugin && plugin.normalize) { 270 name = plugin.normalize(name, makeNormalize(relResourceName)); 271 } else { 272 name = normalize(name, relResourceName); 273 } 274 } else { 275 name = normalize(name, relResourceName); 276 parts = splitPrefix(name); 277 prefix = parts[0]; 278 name = parts[1]; 279 if (prefix) { 280 plugin = callDep(prefix); 281 } 282 } 283 284 //Using ridiculous property names for space reasons 285 return { 286 f: prefix ? prefix + '!' + name : name, //fullName 287 n: name, 288 pr: prefix, 289 p: plugin 290 }; 291 }; 292 293 function makeConfig(name) { 294 return function () { 295 return (config && config.config && config.config[name]) || {}; 296 }; 297 } 298 299 handlers = { 300 require: function (name) { 301 return makeRequire(name); 302 }, 303 exports: function (name) { 304 var e = defined[name]; 305 if (typeof e !== 'undefined') { 306 return e; 307 } else { 308 return (defined[name] = {}); 309 } 310 }, 311 module: function (name) { 312 return { 313 id: name, 314 uri: '', 315 exports: defined[name], 316 config: makeConfig(name) 317 }; 318 } 319 }; 320 321 main = function (name, deps, callback, relName) { 322 var cjsModule, depName, ret, map, i, relParts, 323 args = [], 324 callbackType = typeof callback, 325 usingExports; 326 327 //Use name if no relName 328 relName = relName || name; 329 relParts = makeRelParts(relName); 330 331 //Call the callback to define the module, if necessary. 332 if (callbackType === 'undefined' || callbackType === 'function') { 333 //Pull out the defined dependencies and pass the ordered 334 //values to the callback. 335 //Default to [require, exports, module] if no deps 336 deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; 337 for (i = 0; i < deps.length; i += 1) { 338 map = makeMap(deps[i], relParts); 339 depName = map.f; 340 341 //Fast path CommonJS standard dependencies. 342 if (depName === "require") { 343 args[i] = handlers.require(name); 344 } else if (depName === "exports") { 345 //CommonJS module spec 1.1 346 args[i] = handlers.exports(name); 347 usingExports = true; 348 } else if (depName === "module") { 349 //CommonJS module spec 1.1 350 cjsModule = args[i] = handlers.module(name); 351 } else if (hasProp(defined, depName) || 352 hasProp(waiting, depName) || 353 hasProp(defining, depName)) { 354 args[i] = callDep(depName); 355 } else if (map.p) { 356 map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); 357 args[i] = defined[depName]; 358 } else { 359 throw new Error(name + ' missing ' + depName); 360 } 361 } 362 363 ret = callback ? callback.apply(defined[name], args) : undefined; 364 365 if (name) { 366 //If setting exports via "module" is in play, 367 //favor that over return value and exports. After that, 368 //favor a non-undefined return value over exports use. 369 if (cjsModule && cjsModule.exports !== undef && 370 cjsModule.exports !== defined[name]) { 371 defined[name] = cjsModule.exports; 372 } else if (ret !== undef || !usingExports) { 373 //Use the return value from the function. 374 defined[name] = ret; 375 } 376 } 377 } else if (name) { 378 //May just be an object definition for the module. Only 379 //worry about defining if have a module name. 380 defined[name] = callback; 381 } 382 }; 383 384 requirejs = require = req = function (deps, callback, relName, forceSync, alt) { 385 if (typeof deps === "string") { 386 if (handlers[deps]) { 387 //callback in this case is really relName 388 return handlers[deps](callback); 389 } 390 //Just return the module wanted. In this scenario, the 391 //deps arg is the module name, and second arg (if passed) 392 //is just the relName. 393 //Normalize module name, if it contains . or .. 394 return callDep(makeMap(deps, makeRelParts(callback)).f); 395 } else if (!deps.splice) { 396 //deps is a config object, not an array. 397 config = deps; 398 if (config.deps) { 399 req(config.deps, config.callback); 400 } 401 if (!callback) { 402 return; 403 } 404 405 if (callback.splice) { 406 //callback is an array, which means it is a dependency list. 407 //Adjust args if there are dependencies 408 deps = callback; 409 callback = relName; 410 relName = null; 411 } else { 412 deps = undef; 413 } 414 } 415 416 //Support require(['a']) 417 callback = callback || function () {}; 418 419 //If relName is a function, it is an errback handler, 420 //so remove it. 421 if (typeof relName === 'function') { 422 relName = forceSync; 423 forceSync = alt; 424 } 425 426 //Simulate async callback; 427 if (forceSync) { 428 main(undef, deps, callback, relName); 429 } else { 430 //Using a non-zero value because of concern for what old browsers 431 //do, and latest browsers "upgrade" to 4 if lower value is used: 432 //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout: 433 //If want a value immediately, use require('id') instead -- something 434 //that works in almond on the global level, but not guaranteed and 435 //unlikely to work in other AMD implementations. 436 setTimeout(function () { 437 main(undef, deps, callback, relName); 438 }, 4); 439 } 440 441 return req; 442 }; 443 444 /** 445 * Just drops the config on the floor, but returns req in case 446 * the config return value is used. 447 */ 448 req.config = function (cfg) { 449 return req(cfg); 450 }; 451 452 /** 453 * Expose module registry for debugging and tooling 454 */ 455 requirejs._defined = defined; 456 457 define = function (name, deps, callback) { 458 if (typeof name !== 'string') { 459 throw new Error('See almond README: incorrect module build, no module name'); 460 } 461 462 //This module may not have dependencies 463 if (!deps.splice) { 464 //deps is not an array, so probably means 465 //an object literal or factory function for 466 //the value. Adjust args. 467 callback = deps; 468 deps = []; 469 } 470 471 if (!hasProp(defined, name) && !hasProp(waiting, name)) { 472 waiting[name] = [name, deps, callback]; 473 } 474 }; 475 476 define.amd = { 477 jQuery: true 478 }; 479}()); 480 481S2.requirejs = requirejs;S2.require = require;S2.define = define; 482} 483}()); 484S2.define("almond", function(){}); 485 486/* global jQuery:false, $:false */ 487S2.define('jquery',[],function () { 488 var _$ = jQuery || $; 489 490 if (_$ == null && console && console.error) { 491 console.error( 492 'Select2: An instance of jQuery or a jQuery-compatible library was not ' + 493 'found. Make sure that you are including jQuery before Select2 on your ' + 494 'web page.' 495 ); 496 } 497 498 return _$; 499}); 500 501S2.define('select2/utils',[ 502 'jquery' 503], function ($) { 504 var Utils = {}; 505 506 Utils.Extend = function (ChildClass, SuperClass) { 507 var __hasProp = {}.hasOwnProperty; 508 509 function BaseConstructor () { 510 this.constructor = ChildClass; 511 } 512 513 for (var key in SuperClass) { 514 if (__hasProp.call(SuperClass, key)) { 515 ChildClass[key] = SuperClass[key]; 516 } 517 } 518 519 BaseConstructor.prototype = SuperClass.prototype; 520 ChildClass.prototype = new BaseConstructor(); 521 ChildClass.__super__ = SuperClass.prototype; 522 523 return ChildClass; 524 }; 525 526 function getMethods (theClass) { 527 var proto = theClass.prototype; 528 529 var methods = []; 530 531 for (var methodName in proto) { 532 var m = proto[methodName]; 533 534 if (typeof m !== 'function') { 535 continue; 536 } 537 538 if (methodName === 'constructor') { 539 continue; 540 } 541 542 methods.push(methodName); 543 } 544 545 return methods; 546 } 547 548 Utils.Decorate = function (SuperClass, DecoratorClass) { 549 var decoratedMethods = getMethods(DecoratorClass); 550 var superMethods = getMethods(SuperClass); 551 552 function DecoratedClass () { 553 var unshift = Array.prototype.unshift; 554 555 var argCount = DecoratorClass.prototype.constructor.length; 556 557 var calledConstructor = SuperClass.prototype.constructor; 558 559 if (argCount > 0) { 560 unshift.call(arguments, SuperClass.prototype.constructor); 561 562 calledConstructor = DecoratorClass.prototype.constructor; 563 } 564 565 calledConstructor.apply(this, arguments); 566 } 567 568 DecoratorClass.displayName = SuperClass.displayName; 569 570 function ctr () { 571 this.constructor = DecoratedClass; 572 } 573 574 DecoratedClass.prototype = new ctr(); 575 576 for (var m = 0; m < superMethods.length; m++) { 577 var superMethod = superMethods[m]; 578 579 DecoratedClass.prototype[superMethod] = 580 SuperClass.prototype[superMethod]; 581 } 582 583 var calledMethod = function (methodName) { 584 // Stub out the original method if it's not decorating an actual method 585 var originalMethod = function () {}; 586 587 if (methodName in DecoratedClass.prototype) { 588 originalMethod = DecoratedClass.prototype[methodName]; 589 } 590 591 var decoratedMethod = DecoratorClass.prototype[methodName]; 592 593 return function () { 594 var unshift = Array.prototype.unshift; 595 596 unshift.call(arguments, originalMethod); 597 598 return decoratedMethod.apply(this, arguments); 599 }; 600 }; 601 602 for (var d = 0; d < decoratedMethods.length; d++) { 603 var decoratedMethod = decoratedMethods[d]; 604 605 DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod); 606 } 607 608 return DecoratedClass; 609 }; 610 611 var Observable = function () { 612 this.listeners = {}; 613 }; 614 615 Observable.prototype.on = function (event, callback) { 616 this.listeners = this.listeners || {}; 617 618 if (event in this.listeners) { 619 this.listeners[event].push(callback); 620 } else { 621 this.listeners[event] = [callback]; 622 } 623 }; 624 625 Observable.prototype.trigger = function (event) { 626 var slice = Array.prototype.slice; 627 var params = slice.call(arguments, 1); 628 629 this.listeners = this.listeners || {}; 630 631 // Params should always come in as an array 632 if (params == null) { 633 params = []; 634 } 635 636 // If there are no arguments to the event, use a temporary object 637 if (params.length === 0) { 638 params.push({}); 639 } 640 641 // Set the `_type` of the first object to the event 642 params[0]._type = event; 643 644 if (event in this.listeners) { 645 this.invoke(this.listeners[event], slice.call(arguments, 1)); 646 } 647 648 if ('*' in this.listeners) { 649 this.invoke(this.listeners['*'], arguments); 650 } 651 }; 652 653 Observable.prototype.invoke = function (listeners, params) { 654 for (var i = 0, len = listeners.length; i < len; i++) { 655 listeners[i].apply(this, params); 656 } 657 }; 658 659 Utils.Observable = Observable; 660 661 Utils.generateChars = function (length) { 662 var chars = ''; 663 664 for (var i = 0; i < length; i++) { 665 var randomChar = Math.floor(Math.random() * 36); 666 chars += randomChar.toString(36); 667 } 668 669 return chars; 670 }; 671 672 Utils.bind = function (func, context) { 673 return function () { 674 func.apply(context, arguments); 675 }; 676 }; 677 678 Utils._convertData = function (data) { 679 for (var originalKey in data) { 680 var keys = originalKey.split('-'); 681 682 var dataLevel = data; 683 684 if (keys.length === 1) { 685 continue; 686 } 687 688 for (var k = 0; k < keys.length; k++) { 689 var key = keys[k]; 690 691 // Lowercase the first letter 692 // By default, dash-separated becomes camelCase 693 key = key.substring(0, 1).toLowerCase() + key.substring(1); 694 695 if (!(key in dataLevel)) { 696 dataLevel[key] = {}; 697 } 698 699 if (k == keys.length - 1) { 700 dataLevel[key] = data[originalKey]; 701 } 702 703 dataLevel = dataLevel[key]; 704 } 705 706 delete data[originalKey]; 707 } 708 709 return data; 710 }; 711 712 Utils.hasScroll = function (index, el) { 713 // Adapted from the function created by @ShadowScripter 714 // and adapted by @BillBarry on the Stack Exchange Code Review website. 715 // The original code can be found at 716 // http://codereview.stackexchange.com/q/13338 717 // and was designed to be used with the Sizzle selector engine. 718 719 var $el = $(el); 720 var overflowX = el.style.overflowX; 721 var overflowY = el.style.overflowY; 722 723 //Check both x and y declarations 724 if (overflowX === overflowY && 725 (overflowY === 'hidden' || overflowY === 'visible')) { 726 return false; 727 } 728 729 if (overflowX === 'scroll' || overflowY === 'scroll') { 730 return true; 731 } 732 733 return ($el.innerHeight() < el.scrollHeight || 734 $el.innerWidth() < el.scrollWidth); 735 }; 736 737 Utils.escapeMarkup = function (markup) { 738 var replaceMap = { 739 '\\': '\', 740 '&': '&', 741 '<': '<', 742 '>': '>', 743 '"': '"', 744 '\'': ''', 745 '/': '/' 746 }; 747 748 // Do not try to escape the markup if it's not a string 749 if (typeof markup !== 'string') { 750 return markup; 751 } 752 753 return String(markup).replace(/[&<>"'\/\\]/g, function (match) { 754 return replaceMap[match]; 755 }); 756 }; 757 758
vendor: 36,313 bytes, lines 758-2128
758Utils.entityDecode = function (html) { 759 var txt = document.createElement('textarea'); 760 txt.innerHTML = html; 761 return txt.value; 762 } 763 764 // Append an array of jQuery nodes to a given element. 765 Utils.appendMany = function ($element, $nodes) { 766 // jQuery 1.7.x does not support $.fn.append() with an array 767 // Fall back to a jQuery object collection using $.fn.add() 768 if ($.fn.jquery.substr(0, 3) === '1.7') { 769 var $jqNodes = $(); 770 771 $.map($nodes, function (node) { 772 $jqNodes = $jqNodes.add(node); 773 }); 774 775 $nodes = $jqNodes; 776 } 777 778 $element.append($nodes); 779 }; 780 781 // Determine whether the browser is on a touchscreen device. 782 Utils.isTouchscreen = function() { 783 if ('undefined' === typeof Utils._isTouchscreenCache) { 784 Utils._isTouchscreenCache = 'ontouchstart' in document.documentElement; 785 } 786 return Utils._isTouchscreenCache; 787 } 788 789 return Utils; 790}); 791 792S2.define('select2/results',[ 793 'jquery', 794 './utils' 795], function ($, Utils) { 796 function Results ($element, options, dataAdapter) { 797 this.$element = $element; 798 this.data = dataAdapter; 799 this.options = options; 800 801 Results.__super__.constructor.call(this); 802 } 803 804 Utils.Extend(Results, Utils.Observable); 805 806 Results.prototype.render = function () { 807 var $results = $( 808 '<ul class="select2-results__options" role="listbox" tabindex="-1"></ul>' 809 ); 810 811 if (this.options.get('multiple')) { 812 $results.attr('aria-multiselectable', 'true'); 813 } 814 815 this.$results = $results; 816 817 return $results; 818 }; 819 820 Results.prototype.clear = function () { 821 this.$results.empty(); 822 }; 823 824 Results.prototype.displayMessage = function (params) { 825 var escapeMarkup = this.options.get('escapeMarkup'); 826 827 this.clear(); 828 this.hideLoading(); 829 830 var $message = $( 831 '<li role="alert" aria-live="assertive"' + 832 ' class="select2-results__option"></li>' 833 ); 834 835 var message = this.options.get('translations').get(params.message); 836 837 $message.append( 838 escapeMarkup( 839 message(params.args) 840 ) 841 ); 842 843 $message[0].className += ' select2-results__message'; 844 845 this.$results.append($message); 846 }; 847 848 Results.prototype.hideMessages = function () { 849 this.$results.find('.select2-results__message').remove(); 850 }; 851 852 Results.prototype.append = function (data) { 853 this.hideLoading(); 854 855 var $options = []; 856 857 if (data.results == null || data.results.length === 0) { 858 if (this.$results.children().length === 0) { 859 this.trigger('results:message', { 860 message: 'noResults' 861 }); 862 } 863 864 return; 865 } 866 867 data.results = this.sort(data.results); 868 869 for (var d = 0; d < data.results.length; d++) { 870 var item = data.results[d]; 871 872 var $option = this.option(item); 873 874 $options.push($option); 875 } 876 877 this.$results.append($options); 878 }; 879 880 Results.prototype.position = function ($results, $dropdown) { 881 var $resultsContainer = $dropdown.find('.select2-results'); 882 $resultsContainer.append($results); 883 }; 884 885 Results.prototype.sort = function (data) { 886 var sorter = this.options.get('sorter'); 887 888 return sorter(data); 889 }; 890 891 Results.prototype.highlightFirstItem = function () { 892 var $options = this.$results 893 .find('.select2-results__option[data-selected]'); 894 895 var $selected = $options.filter('[data-selected=true]'); 896 897 // Check if there are any selected options 898 if ($selected.length > 0) { 899 // If there are selected options, highlight the first 900 $selected.first().trigger('mouseenter'); 901 } else { 902 // If there are no selected options, highlight the first option 903 // in the dropdown 904 $options.first().trigger('mouseenter'); 905 } 906 907 this.ensureHighlightVisible(); 908 }; 909 910 Results.prototype.setClasses = function () { 911 var self = this; 912 913 this.data.current(function (selected) { 914 var selectedIds = $.map(selected, function (s) { 915 return s.id.toString(); 916 }); 917 918 var $options = self.$results 919 .find('.select2-results__option[data-selected]'); 920 921 $options.each(function () { 922 var $option = $(this); 923 924 var item = $.data(this, 'data'); 925 926 // id needs to be converted to a string when comparing 927 var id = '' + item.id; 928 929 if ((item.element != null && item.element.selected) || 930 (item.element == null && $.inArray(id, selectedIds) > -1)) { 931 $option.attr('data-selected', 'true'); 932 } else { 933 $option.attr('data-selected', 'false'); 934 } 935 }); 936 937 }); 938 }; 939 940 Results.prototype.showLoading = function (params) { 941 this.hideLoading(); 942 943 var loadingMore = this.options.get('translations').get('searching'); 944 945 var loading = { 946 disabled: true, 947 loading: true, 948 text: loadingMore(params) 949 }; 950 var $loading = this.option(loading); 951 $loading.className += ' loading-results'; 952 953 this.$results.prepend($loading); 954 }; 955 956 Results.prototype.hideLoading = function () { 957 this.$results.find('.loading-results').remove(); 958 }; 959 960 Results.prototype.option = function (data) { 961 var option = document.createElement('li'); 962 option.className = 'select2-results__option'; 963 964 var attrs = { 965 'role': 'option', 966 'data-selected': 'false', 967 'tabindex': -1 968 }; 969 970 if (data.disabled) { 971 delete attrs['data-selected']; 972 attrs['aria-disabled'] = 'true'; 973 } 974 975 if (data.id == null) { 976 delete attrs['data-selected']; 977 } 978 979 if (data._resultId != null) { 980 option.id = data._resultId; 981 } 982 983 if (data.title) { 984 option.title = data.title; 985 } 986 987 if (data.children) { 988 attrs['aria-label'] = data.text; 989 delete attrs['data-selected']; 990 } 991 992 for (var attr in attrs) { 993 var val = attrs[attr]; 994 995 option.setAttribute(attr, val); 996 } 997 998 if (data.children) { 999 var $option = $(option); 1000 1001 var label = document.createElement('strong'); 1002 label.className = 'select2-results__group'; 1003 1004 var $label = $(label); 1005 this.template(data, label); 1006 $label.attr('role', 'presentation'); 1007 1008 var $children = []; 1009 1010 for (var c = 0; c < data.children.length; c++) { 1011 var child = data.children[c]; 1012 1013 var $child = this.option(child); 1014 1015 $children.push($child); 1016 } 1017 1018 var $childrenContainer = $('<ul></ul>', { 1019 'class': 'select2-results__options select2-results__options--nested', 1020 'role': 'listbox' 1021 }); 1022 $childrenContainer.append($children); 1023 $option.attr('role', 'list'); 1024 1025 $option.append(label); 1026 $option.append($childrenContainer); 1027 } else { 1028 this.template(data, option); 1029 } 1030 1031 $.data(option, 'data', data); 1032 1033 return option; 1034 }; 1035 1036 Results.prototype.bind = function (container, $container) { 1037 var self = this; 1038 1039 var id = container.id + '-results'; 1040 1041 this.$results.attr('id', id); 1042 1043 container.on('results:all', function (params) { 1044 self.clear(); 1045 self.append(params.data); 1046 1047 if (container.isOpen()) { 1048 self.setClasses(); 1049 self.highlightFirstItem(); 1050 } 1051 }); 1052 1053 container.on('results:append', function (params) { 1054 self.append(params.data); 1055 1056 if (container.isOpen()) { 1057 self.setClasses(); 1058 } 1059 }); 1060 1061 container.on('query', function (params) { 1062 self.hideMessages(); 1063 self.showLoading(params); 1064 }); 1065 1066 container.on('select', function () { 1067 if (!container.isOpen()) { 1068 return; 1069 } 1070 1071 self.setClasses(); 1072 self.highlightFirstItem(); 1073 }); 1074 1075 container.on('unselect', function () { 1076 if (!container.isOpen()) { 1077 return; 1078 } 1079 1080 self.setClasses(); 1081 self.highlightFirstItem(); 1082 }); 1083 1084 container.on('open', function () { 1085 // When the dropdown is open, aria-expended="true" 1086 self.$results.attr('aria-expanded', 'true'); 1087 self.$results.attr('aria-hidden', 'false'); 1088 1089 self.setClasses(); 1090 self.ensureHighlightVisible(); 1091 1092 // NOTE: DOM's version of the object and not jQuery. 1093 var searchField = self.$results.parents( '.select2-container' ).find( 'input.select2-search__field' )[0]; 1094 if ( 'undefined' !== typeof searchField ) { 1095 searchField.focus(); 1096 } 1097 }); 1098 1099 container.on('close', function () { 1100 // When the dropdown is closed, aria-expended="false" 1101 self.$results.attr('aria-expanded', 'false'); 1102 self.$results.attr('aria-hidden', 'true'); 1103 self.$results.removeAttr('aria-activedescendant'); 1104 }); 1105 1106 container.on('results:toggle', function () { 1107 var $highlighted = self.getHighlightedResults(); 1108 1109 if ($highlighted.length === 0) { 1110 return; 1111 } 1112 1113 $highlighted.trigger('mouseup'); 1114 }); 1115 1116 container.on('results:select', function () { 1117 var $highlighted = self.getHighlightedResults(); 1118 1119 if ($highlighted.length === 0) { 1120 return; 1121 } 1122 1123 var data = $highlighted.data('data'); 1124 1125 if ($highlighted.attr('data-selected') == 'true') { 1126 self.trigger('close', {}); 1127 } else { 1128 self.trigger('select', { 1129 data: data 1130 }); 1131 } 1132 }); 1133 1134 container.on('results:previous', function () { 1135 var $highlighted = self.getHighlightedResults(); 1136 1137 var $options = self.$results.find('[data-selected]'); 1138 1139 var currentIndex = $options.index($highlighted); 1140 1141 // If we are already at te top, don't move further 1142 if (currentIndex === 0) { 1143 return; 1144 } 1145 1146 var nextIndex = currentIndex - 1; 1147 1148 // If none are highlighted, highlight the first 1149 if ($highlighted.length === 0) { 1150 nextIndex = 0; 1151 } 1152 1153 var $next = $options.eq(nextIndex); 1154 1155 $next.trigger('mouseenter'); 1156 1157 var currentOffset = self.$results.offset().top; 1158 var nextTop = $next.offset().top; 1159 var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset); 1160 1161 if (nextIndex === 0) { 1162 self.$results.scrollTop(0); 1163 } else if (nextTop - currentOffset < 0) { 1164 self.$results.scrollTop(nextOffset); 1165 } 1166 }); 1167 1168 container.on('results:next', function () { 1169 var $highlighted = self.getHighlightedResults(); 1170 1171 var $options = self.$results.find('[data-selected]'); 1172 1173 var currentIndex = $options.index($highlighted); 1174 1175 var nextIndex = currentIndex + 1; 1176 1177 // If we are at the last option, stay there 1178 if (nextIndex >= $options.length) { 1179 return; 1180 } 1181 1182 var $next = $options.eq(nextIndex); 1183 1184 $next.trigger('mouseenter'); 1185 1186 var currentOffset = self.$results.offset().top + 1187 self.$results.outerHeight(false); 1188 var nextBottom = $next.offset().top + $next.outerHeight(false); 1189 var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset; 1190 1191 if (nextIndex === 0) { 1192 self.$results.scrollTop(0); 1193 } else if (nextBottom > currentOffset) { 1194 self.$results.scrollTop(nextOffset); 1195 } 1196 }); 1197 1198 container.on('results:focus', function (params) { 1199 params.element.addClass('select2-results__option--highlighted').attr('aria-selected', 'true'); 1200 self.$results.attr('aria-activedescendant', params.element.attr('id')); 1201 }); 1202 1203 container.on('results:message', function (params) { 1204 self.displayMessage(params); 1205 }); 1206 1207 if ($.fn.mousewheel) { 1208 this.$results.on('mousewheel', function (e) { 1209 var top = self.$results.scrollTop(); 1210 1211 var bottom = self.$results.get(0).scrollHeight - top + e.deltaY; 1212 1213 var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0; 1214 var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height(); 1215 1216 if (isAtTop) { 1217 self.$results.scrollTop(0); 1218 1219 e.preventDefault(); 1220 e.stopPropagation(); 1221 } else if (isAtBottom) { 1222 self.$results.scrollTop( 1223 self.$results.get(0).scrollHeight - self.$results.height() 1224 ); 1225 1226 e.preventDefault(); 1227 e.stopPropagation(); 1228 } 1229 }); 1230 } 1231 1232 this.$results.on('mouseup', '.select2-results__option[data-selected]', 1233 function (evt) { 1234 var $this = $(this); 1235 1236 var data = $this.data('data'); 1237 1238 if ($this.attr('data-selected') === 'true') { 1239 if (self.options.get('multiple')) { 1240 self.trigger('unselect', { 1241 originalEvent: evt, 1242 data: data 1243 }); 1244 } else { 1245 self.trigger('close', {}); 1246 } 1247 1248 return; 1249 } 1250 1251 self.trigger('select', { 1252 originalEvent: evt, 1253 data: data 1254 }); 1255 }); 1256 1257 this.$results.on('mouseenter', '.select2-results__option[data-selected]', 1258 function (evt) { 1259 var data = $(this).data('data'); 1260 1261 self.getHighlightedResults() 1262 .removeClass('select2-results__option--highlighted') 1263 .attr('aria-selected', 'false'); 1264 1265 self.trigger('results:focus', { 1266 data: data, 1267 element: $(this) 1268 }); 1269 }); 1270 }; 1271 1272 Results.prototype.getHighlightedResults = function () { 1273 var $highlighted = this.$results 1274 .find('.select2-results__option--highlighted'); 1275 1276 return $highlighted; 1277 }; 1278 1279 Results.prototype.destroy = function () { 1280 this.$results.remove(); 1281 }; 1282 1283 Results.prototype.ensureHighlightVisible = function () { 1284 var $highlighted = this.getHighlightedResults(); 1285 1286 if ($highlighted.length === 0) { 1287 return; 1288 } 1289 1290 var $options = this.$results.find('[data-selected]'); 1291 1292 var currentIndex = $options.index($highlighted); 1293 1294 var currentOffset = this.$results.offset().top; 1295 var nextTop = $highlighted.offset().top; 1296 var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset); 1297 1298 var offsetDelta = nextTop - currentOffset; 1299 nextOffset -= $highlighted.outerHeight(false) * 2; 1300 1301 if (currentIndex <= 2) { 1302 this.$results.scrollTop(0); 1303 } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) { 1304 this.$results.scrollTop(nextOffset); 1305 } 1306 }; 1307 1308 Results.prototype.template = function (result, container) { 1309 var template = this.options.get('templateResult'); 1310 var escapeMarkup = this.options.get('escapeMarkup'); 1311 1312 var content = template(result, container); 1313 1314 if (content == null) { 1315 container.style.display = 'none'; 1316 } else if (typeof content === 'string') { 1317 container.innerHTML = escapeMarkup(content); 1318 } else { 1319 $(container).append(content); 1320 } 1321 }; 1322 1323 return Results; 1324}); 1325 1326S2.define('select2/keys',[ 1327 1328], function () { 1329 var KEYS = { 1330 BACKSPACE: 8, 1331 TAB: 9, 1332 ENTER: 13, 1333 SHIFT: 16, 1334 CTRL: 17, 1335 ALT: 18, 1336 ESC: 27, 1337 SPACE: 32, 1338 PAGE_UP: 33, 1339 PAGE_DOWN: 34, 1340 END: 35, 1341 HOME: 36, 1342 LEFT: 37, 1343 UP: 38, 1344 RIGHT: 39, 1345 DOWN: 40, 1346 DELETE: 46 1347 }; 1348 1349 return KEYS; 1350}); 1351 1352S2.define('select2/selection/base',[ 1353 'jquery', 1354 '../utils', 1355 '../keys' 1356], function ($, Utils, KEYS) { 1357 function BaseSelection ($element, options) { 1358 this.$element = $element; 1359 this.options = options; 1360 1361 BaseSelection.__super__.constructor.call(this); 1362 } 1363 1364 Utils.Extend(BaseSelection, Utils.Observable); 1365 1366 BaseSelection.prototype.render = function () { 1367 var $selection = $( 1368 '<span class="select2-selection" ' + 1369 ' aria-haspopup="true" aria-expanded="false">' + 1370 '</span>' 1371 ); 1372 1373 this._tabindex = 0; 1374 1375 if (this.$element.data('old-tabindex') != null) { 1376 this._tabindex = this.$element.data('old-tabindex'); 1377 } else if (this.$element.attr('tabindex') != null) { 1378 this._tabindex = this.$element.attr('tabindex'); 1379 } 1380 1381 $selection.attr('title', this.$element.attr('title')); 1382 $selection.attr('tabindex', this._tabindex); 1383 1384 this.$selection = $selection; 1385 1386 return $selection; 1387 }; 1388 1389 BaseSelection.prototype.bind = function (container, $container) { 1390 var self = this; 1391 1392 var id = container.id + '-container'; 1393 var resultsId = container.id + '-results'; 1394 var searchHidden = this.options.get('minimumResultsForSearch') === Infinity; 1395 var isRequired = this.options.get('required') === true; 1396 1397 this.container = container; 1398 1399 if (isRequired) { 1400 this.$selection.attr('aria-required', 'true') 1401 } 1402 1403 this.$selection.on('focus', function (evt) { 1404 self.trigger('focus', evt); 1405 }); 1406 1407 this.$selection.on('blur', function (evt) { 1408 self._handleBlur(evt); 1409 }); 1410 1411 this.$selection.on('keydown', function (evt) { 1412 self.trigger('keypress', evt); 1413 1414 if (evt.which === KEYS.SPACE) { 1415 evt.preventDefault(); 1416 } 1417 }); 1418 1419 container.on('results:focus', function (params) { 1420 self.$selection.attr('aria-activedescendant', params.data._resultId); 1421 }); 1422 1423 container.on('selection:update', function (params) { 1424 self.update(params.data); 1425 }); 1426 1427 container.on('open', function () { 1428 // When the dropdown is open, aria-expanded="true" 1429 self.$selection.attr('aria-expanded', 'true'); 1430 self.$selection.attr('aria-owns', resultsId); 1431 1432 self._attachCloseHandler(container); 1433 }); 1434 1435 container.on('close', function () { 1436 // When the dropdown is closed, aria-expanded="false" 1437 self.$selection.attr('aria-expanded', 'false'); 1438 self.$selection.removeAttr('aria-activedescendant'); 1439 self.$selection.removeAttr('aria-owns'); 1440 1441 // This needs to be delayed as the active element is the body when the 1442 // key is pressed. 1443 window.setTimeout(function () { 1444 self.$selection.trigger( 'focus' ); 1445 }, 1); 1446 1447 self._detachCloseHandler(container); 1448 }); 1449 1450 container.on('enable', function () { 1451 self.$selection.attr('tabindex', self._tabindex); 1452 }); 1453 1454 container.on('disable', function () { 1455 self.$selection.attr('tabindex', '-1'); 1456 }); 1457 }; 1458 1459 BaseSelection.prototype._handleBlur = function (evt) { 1460 var self = this; 1461 1462 // This needs to be delayed as the active element is the body when the tab 1463 // key is pressed, possibly along with others. 1464 window.setTimeout(function () { 1465 // Don't trigger `blur` if the focus is still in the selection 1466 if ( 1467 (document.activeElement == self.$selection[0]) || 1468 ($.contains(self.$selection[0], document.activeElement)) 1469 ) { 1470 return; 1471 } 1472 1473 self.trigger('blur', evt); 1474 }, 1); 1475 }; 1476 1477 BaseSelection.prototype._attachCloseHandler = function (container) { 1478 var self = this; 1479 1480 $(document.body).on('mousedown.select2.' + container.id, function (e) { 1481 var $target = $(e.target); 1482 1483 var $select = $target.closest('.select2'); 1484 1485 var $all = $('.select2.select2-container--open'); 1486 1487 $all.each(function () { 1488 var $this = $(this); 1489 1490 if (this == $select[0]) { 1491 return; 1492 } 1493 1494 var $element = $this.data('element'); 1495 $element.select2('close'); 1496 1497 // Remove any focus when dropdown is closed by clicking outside the select area. 1498 // Timeout of 1 required for close to finish wrapping up. 1499 setTimeout(function(){ 1500 $this.find('*:focus').trigger( 'blur' ); 1501 $target.trigger( 'focus' ); 1502 }, 1); 1503 }); 1504 }); 1505 }; 1506 1507 BaseSelection.prototype._detachCloseHandler = function (container) { 1508 $(document.body).off('mousedown.select2.' + container.id); 1509 }; 1510 1511 BaseSelection.prototype.position = function ($selection, $container) { 1512 var $selectionContainer = $container.find('.selection'); 1513 $selectionContainer.append($selection); 1514 }; 1515 1516 BaseSelection.prototype.destroy = function () { 1517 this._detachCloseHandler(this.container); 1518 }; 1519 1520 BaseSelection.prototype.update = function (data) { 1521 throw new Error('The `update` method must be defined in child classes.'); 1522 }; 1523 1524 return BaseSelection; 1525}); 1526 1527S2.define('select2/selection/single',[ 1528 'jquery', 1529 './base', 1530 '../utils', 1531 '../keys' 1532], function ($, BaseSelection, Utils, KEYS) { 1533 function SingleSelection () { 1534 SingleSelection.__super__.constructor.apply(this, arguments); 1535 } 1536 1537 Utils.Extend(SingleSelection, BaseSelection); 1538 1539 SingleSelection.prototype.render = function () { 1540 var $selection = SingleSelection.__super__.render.call(this); 1541 1542 $selection.addClass('select2-selection--single'); 1543 1544 $selection.html( 1545 '<span class="select2-selection__rendered"></span>' + 1546 '<span class="select2-selection__arrow" role="presentation">' + 1547 '<b role="presentation"></b>' + 1548 '</span>' 1549 ); 1550 1551 return $selection; 1552 }; 1553 1554 SingleSelection.prototype.bind = function (container, $container) { 1555 var self = this; 1556 1557 SingleSelection.__super__.bind.apply(this, arguments); 1558 1559 var id = container.id + '-container'; 1560 1561 var isRequired = this.options.get('required') === true; 1562 if (isRequired) { 1563 this.$selection.find('.select2-selection__rendered').attr('aria-required', 'true') 1564 } 1565 1566 this.$selection.find('.select2-selection__rendered') 1567 .attr('id', id) 1568 .attr('role', 'textbox') 1569 .attr('aria-readonly', 'true'); 1570 1571 var label = this.options.get( 'label' ); 1572 1573 if ( typeof( label ) === 'string' ) { 1574 this.$selection.attr( 'aria-label', label ); 1575 } else { 1576 this.$selection.attr( 'aria-labelledby', id ); 1577 } 1578 1579 // This makes single non-search selects work in screen readers. If it causes problems elsewhere, remove. 1580 this.$selection.attr('role', 'combobox'); 1581 1582 this.$selection.on('mousedown', function (evt) { 1583 // Only respond to left clicks 1584 if (evt.which !== 1) { 1585 return; 1586 } 1587 1588 self.trigger('toggle', { 1589 originalEvent: evt 1590 }); 1591 }); 1592 1593 this.$selection.on('focus', function (evt) { 1594 // User focuses on the container 1595 }); 1596 1597 this.$selection.on('keydown', function (evt) { 1598 // If user starts typing an alphanumeric key on the keyboard, open if not opened. 1599 if (!container.isOpen() && evt.which >= 48 && evt.which <= 90) { 1600 container.open(); 1601 } 1602 }); 1603 1604 this.$selection.on('blur', function (evt) { 1605 // User exits the container 1606 }); 1607 1608 container.on('focus', function (evt) { 1609 if (!container.isOpen()) { 1610 self.$selection.trigger( 'focus' ); 1611 } 1612 }); 1613 1614 container.on('selection:update', function (params) { 1615 self.update(params.data); 1616 }); 1617 }; 1618 1619 SingleSelection.prototype.clear = function () { 1620 this.$selection.find('.select2-selection__rendered').empty(); 1621 }; 1622 1623 SingleSelection.prototype.display = function (data, container) { 1624 var template = this.options.get('templateSelection'); 1625 var escapeMarkup = this.options.get('escapeMarkup'); 1626 1627 return escapeMarkup(template(data, container)); 1628 }; 1629 1630 SingleSelection.prototype.selectionContainer = function () { 1631 return $('<span></span>'); 1632 }; 1633 1634 SingleSelection.prototype.update = function (data) { 1635 if (data.length === 0) { 1636 this.clear(); 1637 return; 1638 } 1639 1640 var selection = data[0]; 1641 1642 var $rendered = this.$selection.find('.select2-selection__rendered'); 1643 var formatted = Utils.entityDecode(this.display(selection, $rendered)); 1644 1645 $rendered.empty().text(formatted); 1646 $rendered.prop('title', selection.title || selection.text); 1647 }; 1648 1649 return SingleSelection; 1650}); 1651 1652S2.define('select2/selection/multiple',[ 1653 'jquery', 1654 './base', 1655 '../utils' 1656], function ($, BaseSelection, Utils) { 1657 function MultipleSelection ($element, options) { 1658 MultipleSelection.__super__.constructor.apply(this, arguments); 1659 } 1660 1661 Utils.Extend(MultipleSelection, BaseSelection); 1662 1663 MultipleSelection.prototype.render = function () { 1664 var $selection = MultipleSelection.__super__.render.call(this); 1665 1666 $selection.addClass('select2-selection--multiple'); 1667 1668 $selection.html( 1669 '<ul class="select2-selection__rendered" aria-live="polite" aria-relevant="additions removals" aria-atomic="true"></ul>' 1670 ); 1671 1672 return $selection; 1673 }; 1674 1675 MultipleSelection.prototype.bind = function (container, $container) { 1676 var self = this; 1677 1678 MultipleSelection.__super__.bind.apply(this, arguments); 1679 1680 this.$selection.on('click', function (evt) { 1681 self.trigger('toggle', { 1682 originalEvent: evt 1683 }); 1684 }); 1685 1686 this.$selection.on( 1687 'click', 1688 '.select2-selection__choice__remove', 1689 function (evt) { 1690 // Ignore the event if it is disabled 1691 if (self.options.get('disabled')) { 1692 return; 1693 } 1694 1695 var $remove = $(this); 1696 var $selection = $remove.parent(); 1697 1698 var data = $selection.data('data'); 1699 1700 self.trigger('unselect', { 1701 originalEvent: evt, 1702 data: data 1703 }); 1704 } 1705 ); 1706 1707 this.$selection.on('keydown', function (evt) { 1708 // If user starts typing an alphanumeric key on the keyboard, open if not opened. 1709 if (!container.isOpen() && evt.which >= 48 && evt.which <= 90) { 1710 container.open(); 1711 } 1712 }); 1713 1714 // Focus on the search field when the container is focused instead of the main container. 1715 container.on( 'focus', function(){ 1716 self.focusOnSearch(); 1717 }); 1718 }; 1719 1720 MultipleSelection.prototype.clear = function () { 1721 this.$selection.find('.select2-selection__rendered').empty(); 1722 }; 1723 1724 MultipleSelection.prototype.display = function (data, container) { 1725 var template = this.options.get('templateSelection'); 1726 var escapeMarkup = this.options.get('escapeMarkup'); 1727 1728 return escapeMarkup(template(data, container)); 1729 }; 1730 1731 MultipleSelection.prototype.selectionContainer = function () { 1732 var $container = $( 1733 '<li class="select2-selection__choice">' + 1734 '<span class="select2-selection__choice__remove" role="presentation" aria-hidden="true">' + 1735 '×' + 1736 '</span>' + 1737 '</li>' 1738 ); 1739 1740 return $container; 1741 }; 1742 1743 /** 1744 * Focus on the search field instead of the main multiselect container. 1745 */ 1746 MultipleSelection.prototype.focusOnSearch = function() { 1747 var self = this; 1748 1749 if ('undefined' !== typeof self.$search) { 1750 // Needs 1 ms delay because of other 1 ms setTimeouts when rendering. 1751 setTimeout(function(){ 1752 // Prevent the dropdown opening again when focused from this. 1753 // This gets reset automatically when focus is triggered. 1754 self._keyUpPrevented = true; 1755 1756 self.$search.trigger( 'focus' ); 1757 }, 1); 1758 } 1759 } 1760 1761 MultipleSelection.prototype.update = function (data) { 1762 this.clear(); 1763 1764 if (data.length === 0) { 1765 return; 1766 } 1767 1768 var $selections = []; 1769 1770 for (var d = 0; d < data.length; d++) { 1771 var selection = data[d]; 1772 1773 var $selection = this.selectionContainer(); 1774 var removeItemTag = $selection.html(); 1775 var formatted = this.display(selection, $selection); 1776 if ('string' === typeof formatted) { 1777 formatted = Utils.entityDecode(formatted.trim()); 1778 } 1779 1780 $selection.text(formatted); 1781 $selection.prepend(removeItemTag); 1782 $selection.prop('title', selection.title || selection.text); 1783 1784 $selection.data('data', selection); 1785 1786 $selections.push($selection); 1787 } 1788 1789 var $rendered = this.$selection.find('.select2-selection__rendered'); 1790 1791 Utils.appendMany($rendered, $selections); 1792 }; 1793 1794 return MultipleSelection; 1795}); 1796 1797S2.define('select2/selection/placeholder',[ 1798 '../utils' 1799], function (Utils) { 1800 function Placeholder (decorated, $element, options) { 1801 this.placeholder = this.normalizePlaceholder(options.get('placeholder')); 1802 1803 decorated.call(this, $element, options); 1804 } 1805 1806 Placeholder.prototype.normalizePlaceholder = function (_, placeholder) { 1807 if (typeof placeholder === 'string') { 1808 placeholder = { 1809 id: '', 1810 text: placeholder 1811 }; 1812 } 1813 1814 return placeholder; 1815 }; 1816 1817 Placeholder.prototype.createPlaceholder = function (decorated, placeholder) { 1818 var $placeholder = this.selectionContainer(); 1819 1820 $placeholder.text(Utils.entityDecode(this.display(placeholder))); 1821 $placeholder.addClass('select2-selection__placeholder') 1822 .removeClass('select2-selection__choice'); 1823 1824 return $placeholder; 1825 }; 1826 1827 Placeholder.prototype.update = function (decorated, data) { 1828 var singlePlaceholder = ( 1829 data.length == 1 && data[0].id != this.placeholder.id 1830 ); 1831 var multipleSelections = data.length > 1; 1832 1833 if (multipleSelections || singlePlaceholder) { 1834 return decorated.call(this, data); 1835 } 1836 1837 this.clear(); 1838 1839 var $placeholder = this.createPlaceholder(this.placeholder); 1840 1841 this.$selection.find('.select2-selection__rendered').append($placeholder); 1842 }; 1843 1844 return Placeholder; 1845}); 1846 1847S2.define('select2/selection/allowClear',[ 1848 'jquery', 1849 '../keys' 1850], function ($, KEYS) { 1851 function AllowClear () { } 1852 1853 AllowClear.prototype.bind = function (decorated, container, $container) { 1854 var self = this; 1855 1856 decorated.call(this, container, $container); 1857 1858 if (this.placeholder == null) { 1859 if (this.options.get('debug') && window.console && console.error) { 1860 console.error( 1861 'Select2: The `allowClear` option should be used in combination ' + 1862 'with the `placeholder` option.' 1863 ); 1864 } 1865 } 1866 1867 this.$selection.on('mousedown', '.select2-selection__clear', 1868 function (evt) { 1869 self._handleClear(evt); 1870 }); 1871 1872 container.on('keypress', function (evt) { 1873 self._handleKeyboardClear(evt, container); 1874 }); 1875 }; 1876 1877 AllowClear.prototype._handleClear = function (_, evt) { 1878 // Ignore the event if it is disabled 1879 if (this.options.get('disabled')) { 1880 return; 1881 } 1882 1883 var $clear = this.$selection.find('.select2-selection__clear'); 1884 1885 // Ignore the event if nothing has been selected 1886 if ($clear.length === 0) { 1887 return; 1888 } 1889 1890 evt.stopPropagation(); 1891 1892 var data = $clear.data('data'); 1893 1894 for (var d = 0; d < data.length; d++) { 1895 var unselectData = { 1896 data: data[d] 1897 }; 1898 1899 // Trigger the `unselect` event, so people can prevent it from being 1900 // cleared. 1901 this.trigger('unselect', unselectData); 1902 1903 // If the event was prevented, don't clear it out. 1904 if (unselectData.prevented) { 1905 return; 1906 } 1907 } 1908 1909 this.$element.val(this.placeholder.id).trigger('change'); 1910 1911 this.trigger('toggle', {}); 1912 }; 1913 1914 AllowClear.prototype._handleKeyboardClear = function (_, evt, container) { 1915 if (container.isOpen()) { 1916 return; 1917 } 1918 1919 if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) { 1920 this._handleClear(evt); 1921 } 1922 }; 1923 1924 AllowClear.prototype.update = function (decorated, data) { 1925 decorated.call(this, data); 1926 1927 if (this.$selection.find('.select2-selection__placeholder').length > 0 || 1928 data.length === 0) { 1929 return; 1930 } 1931 1932 var $remove = $( 1933 '<span class="select2-selection__clear">' + 1934 '×' + 1935 '</span>' 1936 ); 1937 $remove.data('data', data); 1938 1939 this.$selection.find('.select2-selection__rendered').prepend($remove); 1940 }; 1941 1942 return AllowClear; 1943}); 1944 1945S2.define('select2/selection/search',[ 1946 'jquery', 1947 '../utils', 1948 '../keys' 1949], function ($, Utils, KEYS) { 1950 function Search (decorated, $element, options) { 1951 decorated.call(this, $element, options); 1952 } 1953 1954 Search.prototype.render = function (decorated) { 1955 var $search = $( 1956 '<li class="select2-search select2-search--inline">' + 1957 '<input class="select2-search__field" type="text" tabindex="-1"' + 1958 ' autocomplete="off" autocorrect="off" autocapitalize="none"' + 1959 ' spellcheck="false" role="textbox" aria-autocomplete="list" />' + 1960 '</li>' 1961 ); 1962 1963 this.$searchContainer = $search; 1964 this.$search = $search.find('input'); 1965 1966 var $rendered = decorated.call(this); 1967 1968 this._transferTabIndex(); 1969 1970 return $rendered; 1971 }; 1972 1973 Search.prototype.bind = function (decorated, container, $container) { 1974 var self = this; 1975 var resultsId = container.id + '-results'; 1976 1977 decorated.call(this, container, $container); 1978 1979 container.on('open', function () { 1980 self.$search.attr('aria-owns', resultsId); 1981 self.$search.trigger('focus'); 1982 }); 1983 1984 container.on('close', function () { 1985 self.$search.val(''); 1986 self.$search.removeAttr('aria-activedescendant'); 1987 self.$search.removeAttr('aria-owns'); 1988 self.$search.trigger('focus'); 1989 }); 1990 1991 container.on('enable', function () { 1992 self.$search.prop('disabled', false); 1993 1994 self._transferTabIndex(); 1995 }); 1996 1997 container.on('disable', function () { 1998 self.$search.prop('disabled', true); 1999 }); 2000 2001 container.on('focus', function (evt) { 2002 self.$search.trigger('focus'); 2003 }); 2004 2005 container.on('results:focus', function (params) { 2006 self.$search.attr('aria-activedescendant', params.data._resultId); 2007 }); 2008 2009 this.$selection.on('focusin', '.select2-search--inline', function (evt) { 2010 self.trigger('focus', evt); 2011 }); 2012 2013 this.$selection.on('focusout', '.select2-search--inline', function (evt) { 2014 self._handleBlur(evt); 2015 }); 2016 2017 this.$selection.on('keydown', '.select2-search--inline', function (evt) { 2018 evt.stopPropagation(); 2019 2020 self.trigger('keypress', evt); 2021 2022 self._keyUpPrevented = evt.isDefaultPrevented(); 2023 2024 var key = evt.which; 2025 2026 if (key === KEYS.BACKSPACE && self.$search.val() === '') { 2027 var $previousChoice = self.$searchContainer 2028 .prev('.select2-selection__choice'); 2029 2030 if ($previousChoice.length > 0) { 2031 var item = $previousChoice.data('data'); 2032 2033 self.searchRemoveChoice(item); 2034 2035 evt.preventDefault(); 2036 } 2037 } else if (evt.which === KEYS.ENTER) { 2038 container.open(); 2039 evt.preventDefault(); 2040 } 2041 }); 2042 2043 // Try to detect the IE version should the `documentMode` property that 2044 // is stored on the document. This is only implemented in IE and is 2045 // slightly cleaner than doing a user agent check. 2046 // This property is not available in Edge, but Edge also doesn't have 2047 // this bug. 2048 var msie = document.documentMode; 2049 var disableInputEvents = msie && msie <= 11; 2050 2051 // Workaround for browsers which do not support the `input` event 2052 // This will prevent double-triggering of events for browsers which support 2053 // both the `keyup` and `input` events. 2054 this.$selection.on( 2055 'input.searchcheck', 2056 '.select2-search--inline', 2057 function (evt) { 2058 // IE will trigger the `input` event when a placeholder is used on a 2059 // search box. To get around this issue, we are forced to ignore all 2060 // `input` events in IE and keep using `keyup`. 2061 if (disableInputEvents) { 2062 self.$selection.off('input.search input.searchcheck'); 2063 return; 2064 } 2065 2066 // Unbind the duplicated `keyup` event 2067 self.$selection.off('keyup.search'); 2068 } 2069 ); 2070 2071 this.$selection.on( 2072 'keyup.search input.search', 2073 '.select2-search--inline', 2074 function (evt) { 2075 // IE will trigger the `input` event when a placeholder is used on a 2076 // search box. To get around this issue, we are forced to ignore all 2077 // `input` events in IE and keep using `keyup`. 2078 if (disableInputEvents && evt.type === 'input') { 2079 self.$selection.off('input.search input.searchcheck'); 2080 return; 2081 } 2082 2083 var key = evt.which; 2084 2085 // We can freely ignore events from modifier keys 2086 if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) { 2087 return; 2088 } 2089 2090 // Tabbing will be handled during the `keydown` phase 2091 if (key == KEYS.TAB) { 2092 return; 2093 } 2094 2095 self.handleSearch(evt); 2096 } 2097 ); 2098 }; 2099 2100 /** 2101 * This method will transfer the tabindex attribute from the rendered 2102 * selection to the search box. This allows for the search box to be used as 2103 * the primary focus instead of the selection container. 2104 * 2105 * @private 2106 */ 2107 Search.prototype._transferTabIndex = function (decorated) { 2108 this.$search.attr('tabindex', this.$selection.attr('tabindex')); 2109 this.$selection.attr('tabindex', '-1'); 2110 }; 2111 2112 Search.prototype.createPlaceholder = function (decorated, placeholder) { 2113 this.$search.attr('placeholder', placeholder.text); 2114 }; 2115 2116 Search.prototype.update = function (decorated, data) { 2117 var searchHadFocus = this.$search[0] == document.activeElement; 2118 2119 this.$search.attr('placeholder', ''); 2120 2121 decorated.call(this, data); 2122 2123 this.$selection.find('.select2-selection__rendered') 2124 .append(this.$searchContainer); 2125 2126 this.resizeSearch(); 2127 if (searchHadFocus) { 2128 this.$search.trigger( 'focus'
vendor: 29,165 bytes, lines 2128-3566
2128); 2129 } 2130 }; 2131 2132 Search.prototype.handleSearch = function () { 2133 this.resizeSearch(); 2134 2135 if (!this._keyUpPrevented) { 2136 var input = this.$search.val(); 2137 2138 this.trigger('query', { 2139 term: input 2140 }); 2141 } 2142 2143 this._keyUpPrevented = false; 2144 }; 2145 2146 Search.prototype.searchRemoveChoice = function (decorated, item) { 2147 this.trigger('unselect', { 2148 data: item 2149 }); 2150 2151 this.$search.val(item.text); 2152 this.handleSearch(); 2153 }; 2154 2155 Search.prototype.resizeSearch = function () { 2156 this.$search.css('width', '25px'); 2157 2158 var width = ''; 2159 2160 if (this.$search.attr('placeholder') !== '') { 2161 width = this.$selection.find('.select2-selection__rendered').innerWidth(); 2162 } else { 2163 var minimumWidth = this.$search.val().length + 1; 2164 2165 width = (minimumWidth * 0.75) + 'em'; 2166 } 2167 2168 this.$search.css('width', width); 2169 }; 2170 2171 return Search; 2172}); 2173 2174S2.define('select2/selection/eventRelay',[ 2175 'jquery' 2176], function ($) { 2177 function EventRelay () { } 2178 2179 EventRelay.prototype.bind = function (decorated, container, $container) { 2180 var self = this; 2181 var relayEvents = [ 2182 'open', 'opening', 2183 'close', 'closing', 2184 'select', 'selecting', 2185 'unselect', 'unselecting' 2186 ]; 2187 2188 var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting']; 2189 2190 decorated.call(this, container, $container); 2191 2192 container.on('*', function (name, params) { 2193 // Ignore events that should not be relayed 2194 if ($.inArray(name, relayEvents) === -1) { 2195 return; 2196 } 2197 2198 // The parameters should always be an object 2199 params = params || {}; 2200 2201 // Generate the jQuery event for the Select2 event 2202 var evt = $.Event('select2:' + name, { 2203 params: params 2204 }); 2205 2206 self.$element.trigger(evt); 2207 2208 // Only handle preventable events if it was one 2209 if ($.inArray(name, preventableEvents) === -1) { 2210 return; 2211 } 2212 2213 params.prevented = evt.isDefaultPrevented(); 2214 }); 2215 }; 2216 2217 return EventRelay; 2218}); 2219 2220S2.define('select2/translation',[ 2221 'jquery', 2222 'require' 2223], function ($, require) { 2224 function Translation (dict) { 2225 this.dict = dict || {}; 2226 } 2227 2228 Translation.prototype.all = function () { 2229 return this.dict; 2230 }; 2231 2232 Translation.prototype.get = function (key) { 2233 return this.dict[key]; 2234 }; 2235 2236 Translation.prototype.extend = function (translation) { 2237 this.dict = $.extend({}, translation.all(), this.dict); 2238 }; 2239 2240 // Static functions 2241 2242 Translation._cache = {}; 2243 2244 Translation.loadPath = function (path) { 2245 if (!(path in Translation._cache)) { 2246 var translations = require(path); 2247 2248 Translation._cache[path] = translations; 2249 } 2250 2251 return new Translation(Translation._cache[path]); 2252 }; 2253 2254 return Translation; 2255}); 2256 2257S2.define('select2/diacritics',[ 2258 2259], function () { 2260 var diacritics = { 2261 '\u24B6': 'A', 2262 '\uFF21': 'A', 2263 '\u00C0': 'A', 2264 '\u00C1': 'A', 2265 '\u00C2': 'A', 2266 '\u1EA6': 'A', 2267 '\u1EA4': 'A', 2268 '\u1EAA': 'A', 2269 '\u1EA8': 'A', 2270 '\u00C3': 'A', 2271 '\u0100': 'A', 2272 '\u0102': 'A', 2273 '\u1EB0': 'A', 2274 '\u1EAE': 'A', 2275 '\u1EB4': 'A', 2276 '\u1EB2': 'A', 2277 '\u0226': 'A', 2278 '\u01E0': 'A', 2279 '\u00C4': 'A', 2280 '\u01DE': 'A', 2281 '\u1EA2': 'A', 2282 '\u00C5': 'A', 2283 '\u01FA': 'A', 2284 '\u01CD': 'A', 2285 '\u0200': 'A', 2286 '\u0202': 'A', 2287 '\u1EA0': 'A', 2288 '\u1EAC': 'A', 2289 '\u1EB6': 'A', 2290 '\u1E00': 'A', 2291 '\u0104': 'A', 2292 '\u023A': 'A', 2293 '\u2C6F': 'A', 2294 '\uA732': 'AA', 2295 '\u00C6': 'AE', 2296 '\u01FC': 'AE', 2297 '\u01E2': 'AE', 2298 '\uA734': 'AO', 2299 '\uA736': 'AU', 2300 '\uA738': 'AV', 2301 '\uA73A': 'AV', 2302 '\uA73C': 'AY', 2303 '\u24B7': 'B', 2304 '\uFF22': 'B', 2305 '\u1E02': 'B', 2306 '\u1E04': 'B', 2307 '\u1E06': 'B', 2308 '\u0243': 'B', 2309 '\u0182': 'B', 2310 '\u0181': 'B', 2311 '\u24B8': 'C', 2312 '\uFF23': 'C', 2313 '\u0106': 'C', 2314 '\u0108': 'C', 2315 '\u010A': 'C', 2316 '\u010C': 'C', 2317 '\u00C7': 'C', 2318 '\u1E08': 'C', 2319 '\u0187': 'C', 2320 '\u023B': 'C', 2321 '\uA73E': 'C', 2322 '\u24B9': 'D', 2323 '\uFF24': 'D', 2324 '\u1E0A': 'D', 2325 '\u010E': 'D', 2326 '\u1E0C': 'D', 2327 '\u1E10': 'D', 2328 '\u1E12': 'D', 2329 '\u1E0E': 'D', 2330 '\u0110': 'D', 2331 '\u018B': 'D', 2332 '\u018A': 'D', 2333 '\u0189': 'D', 2334 '\uA779': 'D', 2335 '\u01F1': 'DZ', 2336 '\u01C4': 'DZ', 2337 '\u01F2': 'Dz', 2338 '\u01C5': 'Dz', 2339 '\u24BA': 'E', 2340 '\uFF25': 'E', 2341 '\u00C8': 'E', 2342 '\u00C9': 'E', 2343 '\u00CA': 'E', 2344 '\u1EC0': 'E', 2345 '\u1EBE': 'E', 2346 '\u1EC4': 'E', 2347 '\u1EC2': 'E', 2348 '\u1EBC': 'E', 2349 '\u0112': 'E', 2350 '\u1E14': 'E', 2351 '\u1E16': 'E', 2352 '\u0114': 'E', 2353 '\u0116': 'E', 2354 '\u00CB': 'E', 2355 '\u1EBA': 'E', 2356 '\u011A': 'E', 2357 '\u0204': 'E', 2358 '\u0206': 'E', 2359 '\u1EB8': 'E', 2360 '\u1EC6': 'E', 2361 '\u0228': 'E', 2362 '\u1E1C': 'E', 2363 '\u0118': 'E', 2364 '\u1E18': 'E', 2365 '\u1E1A': 'E', 2366 '\u0190': 'E', 2367 '\u018E': 'E', 2368 '\u24BB': 'F', 2369 '\uFF26': 'F', 2370 '\u1E1E': 'F', 2371 '\u0191': 'F', 2372 '\uA77B': 'F', 2373 '\u24BC': 'G', 2374 '\uFF27': 'G', 2375 '\u01F4': 'G', 2376 '\u011C': 'G', 2377 '\u1E20': 'G', 2378 '\u011E': 'G', 2379 '\u0120': 'G', 2380 '\u01E6': 'G', 2381 '\u0122': 'G', 2382 '\u01E4': 'G', 2383 '\u0193': 'G', 2384 '\uA7A0': 'G', 2385 '\uA77D': 'G', 2386 '\uA77E': 'G', 2387 '\u24BD': 'H', 2388 '\uFF28': 'H', 2389 '\u0124': 'H', 2390 '\u1E22': 'H', 2391 '\u1E26': 'H', 2392 '\u021E': 'H', 2393 '\u1E24': 'H', 2394 '\u1E28': 'H', 2395 '\u1E2A': 'H', 2396 '\u0126': 'H', 2397 '\u2C67': 'H', 2398 '\u2C75': 'H', 2399 '\uA78D': 'H', 2400 '\u24BE': 'I', 2401 '\uFF29': 'I', 2402 '\u00CC': 'I', 2403 '\u00CD': 'I', 2404 '\u00CE': 'I', 2405 '\u0128': 'I', 2406 '\u012A': 'I', 2407 '\u012C': 'I', 2408 '\u0130': 'I', 2409 '\u00CF': 'I', 2410 '\u1E2E': 'I', 2411 '\u1EC8': 'I', 2412 '\u01CF': 'I', 2413 '\u0208': 'I', 2414 '\u020A': 'I', 2415 '\u1ECA': 'I', 2416 '\u012E': 'I', 2417 '\u1E2C': 'I', 2418 '\u0197': 'I', 2419 '\u24BF': 'J', 2420 '\uFF2A': 'J', 2421 '\u0134': 'J', 2422 '\u0248': 'J', 2423 '\u24C0': 'K', 2424 '\uFF2B': 'K', 2425 '\u1E30': 'K', 2426 '\u01E8': 'K', 2427 '\u1E32': 'K', 2428 '\u0136': 'K', 2429 '\u1E34': 'K', 2430 '\u0198': 'K', 2431 '\u2C69': 'K', 2432 '\uA740': 'K', 2433 '\uA742': 'K', 2434 '\uA744': 'K', 2435 '\uA7A2': 'K', 2436 '\u24C1': 'L', 2437 '\uFF2C': 'L', 2438 '\u013F': 'L', 2439 '\u0139': 'L', 2440 '\u013D': 'L', 2441 '\u1E36': 'L', 2442 '\u1E38': 'L', 2443 '\u013B': 'L', 2444 '\u1E3C': 'L', 2445 '\u1E3A': 'L', 2446 '\u0141': 'L', 2447 '\u023D': 'L', 2448 '\u2C62': 'L', 2449 '\u2C60': 'L', 2450 '\uA748': 'L', 2451 '\uA746': 'L', 2452 '\uA780': 'L', 2453 '\u01C7': 'LJ', 2454 '\u01C8': 'Lj', 2455 '\u24C2': 'M', 2456 '\uFF2D': 'M', 2457 '\u1E3E': 'M', 2458 '\u1E40': 'M', 2459 '\u1E42': 'M', 2460 '\u2C6E': 'M', 2461 '\u019C': 'M', 2462 '\u24C3': 'N', 2463 '\uFF2E': 'N', 2464 '\u01F8': 'N', 2465 '\u0143': 'N', 2466 '\u00D1': 'N', 2467 '\u1E44': 'N', 2468 '\u0147': 'N', 2469 '\u1E46': 'N', 2470 '\u0145': 'N', 2471 '\u1E4A': 'N', 2472 '\u1E48': 'N', 2473 '\u0220': 'N', 2474 '\u019D': 'N', 2475 '\uA790': 'N', 2476 '\uA7A4': 'N', 2477 '\u01CA': 'NJ', 2478 '\u01CB': 'Nj', 2479 '\u24C4': 'O', 2480 '\uFF2F': 'O', 2481 '\u00D2': 'O', 2482 '\u00D3': 'O', 2483 '\u00D4': 'O', 2484 '\u1ED2': 'O', 2485 '\u1ED0': 'O', 2486 '\u1ED6': 'O', 2487 '\u1ED4': 'O', 2488 '\u00D5': 'O', 2489 '\u1E4C': 'O', 2490 '\u022C': 'O', 2491 '\u1E4E': 'O', 2492 '\u014C': 'O', 2493 '\u1E50': 'O', 2494 '\u1E52': 'O', 2495 '\u014E': 'O', 2496 '\u022E': 'O', 2497 '\u0230': 'O', 2498 '\u00D6': 'O', 2499 '\u022A': 'O', 2500 '\u1ECE': 'O', 2501 '\u0150': 'O', 2502 '\u01D1': 'O', 2503 '\u020C': 'O', 2504 '\u020E': 'O', 2505 '\u01A0': 'O', 2506 '\u1EDC': 'O', 2507 '\u1EDA': 'O', 2508 '\u1EE0': 'O', 2509 '\u1EDE': 'O', 2510 '\u1EE2': 'O', 2511 '\u1ECC': 'O', 2512 '\u1ED8': 'O', 2513 '\u01EA': 'O', 2514 '\u01EC': 'O', 2515 '\u00D8': 'O', 2516 '\u01FE': 'O', 2517 '\u0186': 'O', 2518 '\u019F': 'O', 2519 '\uA74A': 'O', 2520 '\uA74C': 'O', 2521 '\u01A2': 'OI', 2522 '\uA74E': 'OO', 2523 '\u0222': 'OU', 2524 '\u24C5': 'P', 2525 '\uFF30': 'P', 2526 '\u1E54': 'P', 2527 '\u1E56': 'P', 2528 '\u01A4': 'P', 2529 '\u2C63': 'P', 2530 '\uA750': 'P', 2531 '\uA752': 'P', 2532 '\uA754': 'P', 2533 '\u24C6': 'Q', 2534 '\uFF31': 'Q', 2535 '\uA756': 'Q', 2536 '\uA758': 'Q', 2537 '\u024A': 'Q', 2538 '\u24C7': 'R', 2539 '\uFF32': 'R', 2540 '\u0154': 'R', 2541 '\u1E58': 'R', 2542 '\u0158': 'R', 2543 '\u0210': 'R', 2544 '\u0212': 'R', 2545 '\u1E5A': 'R', 2546 '\u1E5C': 'R', 2547 '\u0156': 'R', 2548 '\u1E5E': 'R', 2549 '\u024C': 'R', 2550 '\u2C64': 'R', 2551 '\uA75A': 'R', 2552 '\uA7A6': 'R', 2553 '\uA782': 'R', 2554 '\u24C8': 'S', 2555 '\uFF33': 'S', 2556 '\u1E9E': 'S', 2557 '\u015A': 'S', 2558 '\u1E64': 'S', 2559 '\u015C': 'S', 2560 '\u1E60': 'S', 2561 '\u0160': 'S', 2562 '\u1E66': 'S', 2563 '\u1E62': 'S', 2564 '\u1E68': 'S', 2565 '\u0218': 'S', 2566 '\u015E': 'S', 2567 '\u2C7E': 'S', 2568 '\uA7A8': 'S', 2569 '\uA784': 'S', 2570 '\u24C9': 'T', 2571 '\uFF34': 'T', 2572 '\u1E6A': 'T', 2573 '\u0164': 'T', 2574 '\u1E6C': 'T', 2575 '\u021A': 'T', 2576 '\u0162': 'T', 2577 '\u1E70': 'T', 2578 '\u1E6E': 'T', 2579 '\u0166': 'T', 2580 '\u01AC': 'T', 2581 '\u01AE': 'T', 2582 '\u023E': 'T', 2583 '\uA786': 'T', 2584 '\uA728': 'TZ', 2585 '\u24CA': 'U', 2586 '\uFF35': 'U', 2587 '\u00D9': 'U', 2588 '\u00DA': 'U', 2589 '\u00DB': 'U', 2590 '\u0168': 'U', 2591 '\u1E78': 'U', 2592 '\u016A': 'U', 2593 '\u1E7A': 'U', 2594 '\u016C': 'U', 2595 '\u00DC': 'U', 2596 '\u01DB': 'U', 2597 '\u01D7': 'U', 2598 '\u01D5': 'U', 2599 '\u01D9': 'U', 2600 '\u1EE6': 'U', 2601 '\u016E': 'U', 2602 '\u0170': 'U', 2603 '\u01D3': 'U', 2604 '\u0214': 'U', 2605 '\u0216': 'U', 2606 '\u01AF': 'U', 2607 '\u1EEA': 'U', 2608 '\u1EE8': 'U', 2609 '\u1EEE': 'U', 2610 '\u1EEC': 'U', 2611 '\u1EF0': 'U', 2612 '\u1EE4': 'U', 2613 '\u1E72': 'U', 2614 '\u0172': 'U', 2615 '\u1E76': 'U', 2616 '\u1E74': 'U', 2617 '\u0244': 'U', 2618 '\u24CB': 'V', 2619 '\uFF36': 'V', 2620 '\u1E7C': 'V', 2621 '\u1E7E': 'V', 2622 '\u01B2': 'V', 2623 '\uA75E': 'V', 2624 '\u0245': 'V', 2625 '\uA760': 'VY', 2626 '\u24CC': 'W', 2627 '\uFF37': 'W', 2628 '\u1E80': 'W', 2629 '\u1E82': 'W', 2630 '\u0174': 'W', 2631 '\u1E86': 'W', 2632 '\u1E84': 'W', 2633 '\u1E88': 'W', 2634 '\u2C72': 'W', 2635 '\u24CD': 'X', 2636 '\uFF38': 'X', 2637 '\u1E8A': 'X', 2638 '\u1E8C': 'X', 2639 '\u24CE': 'Y', 2640 '\uFF39': 'Y', 2641 '\u1EF2': 'Y', 2642 '\u00DD': 'Y', 2643 '\u0176': 'Y', 2644 '\u1EF8': 'Y', 2645 '\u0232': 'Y', 2646 '\u1E8E': 'Y', 2647 '\u0178': 'Y', 2648 '\u1EF6': 'Y', 2649 '\u1EF4': 'Y', 2650 '\u01B3': 'Y', 2651 '\u024E': 'Y', 2652 '\u1EFE': 'Y', 2653 '\u24CF': 'Z', 2654 '\uFF3A': 'Z', 2655 '\u0179': 'Z', 2656 '\u1E90': 'Z', 2657 '\u017B': 'Z', 2658 '\u017D': 'Z', 2659 '\u1E92': 'Z', 2660 '\u1E94': 'Z', 2661 '\u01B5': 'Z', 2662 '\u0224': 'Z', 2663 '\u2C7F': 'Z', 2664 '\u2C6B': 'Z', 2665 '\uA762': 'Z', 2666 '\u24D0': 'a', 2667 '\uFF41': 'a', 2668 '\u1E9A': 'a', 2669 '\u00E0': 'a', 2670 '\u00E1': 'a', 2671 '\u00E2': 'a', 2672 '\u1EA7': 'a', 2673 '\u1EA5': 'a', 2674 '\u1EAB': 'a', 2675 '\u1EA9': 'a', 2676 '\u00E3': 'a', 2677 '\u0101': 'a', 2678 '\u0103': 'a', 2679 '\u1EB1': 'a', 2680 '\u1EAF': 'a', 2681 '\u1EB5': 'a', 2682 '\u1EB3': 'a', 2683 '\u0227': 'a', 2684 '\u01E1': 'a', 2685 '\u00E4': 'a', 2686 '\u01DF': 'a', 2687 '\u1EA3': 'a', 2688 '\u00E5': 'a', 2689 '\u01FB': 'a', 2690 '\u01CE': 'a', 2691 '\u0201': 'a', 2692 '\u0203': 'a', 2693 '\u1EA1': 'a', 2694 '\u1EAD': 'a', 2695 '\u1EB7': 'a', 2696 '\u1E01': 'a', 2697 '\u0105': 'a', 2698 '\u2C65': 'a', 2699 '\u0250': 'a', 2700 '\uA733': 'aa', 2701 '\u00E6': 'ae', 2702 '\u01FD': 'ae', 2703 '\u01E3': 'ae', 2704 '\uA735': 'ao', 2705 '\uA737': 'au', 2706 '\uA739': 'av', 2707 '\uA73B': 'av', 2708 '\uA73D': 'ay', 2709 '\u24D1': 'b', 2710 '\uFF42': 'b', 2711 '\u1E03': 'b', 2712 '\u1E05': 'b', 2713 '\u1E07': 'b', 2714 '\u0180': 'b', 2715 '\u0183': 'b', 2716 '\u0253': 'b', 2717 '\u24D2': 'c', 2718 '\uFF43': 'c', 2719 '\u0107': 'c', 2720 '\u0109': 'c', 2721 '\u010B': 'c', 2722 '\u010D': 'c', 2723 '\u00E7': 'c', 2724 '\u1E09': 'c', 2725 '\u0188': 'c', 2726 '\u023C': 'c', 2727 '\uA73F': 'c', 2728 '\u2184': 'c', 2729 '\u24D3': 'd', 2730 '\uFF44': 'd', 2731 '\u1E0B': 'd', 2732 '\u010F': 'd', 2733 '\u1E0D': 'd', 2734 '\u1E11': 'd', 2735 '\u1E13': 'd', 2736 '\u1E0F': 'd', 2737 '\u0111': 'd', 2738 '\u018C': 'd', 2739 '\u0256': 'd', 2740 '\u0257': 'd', 2741 '\uA77A': 'd', 2742 '\u01F3': 'dz', 2743 '\u01C6': 'dz', 2744 '\u24D4': 'e', 2745 '\uFF45': 'e', 2746 '\u00E8': 'e', 2747 '\u00E9': 'e', 2748 '\u00EA': 'e', 2749 '\u1EC1': 'e', 2750 '\u1EBF': 'e', 2751 '\u1EC5': 'e', 2752 '\u1EC3': 'e', 2753 '\u1EBD': 'e', 2754 '\u0113': 'e', 2755 '\u1E15': 'e', 2756 '\u1E17': 'e', 2757 '\u0115': 'e', 2758 '\u0117': 'e', 2759 '\u00EB': 'e', 2760 '\u1EBB': 'e', 2761 '\u011B': 'e', 2762 '\u0205': 'e', 2763 '\u0207': 'e', 2764 '\u1EB9': 'e', 2765 '\u1EC7': 'e', 2766 '\u0229': 'e', 2767 '\u1E1D': 'e', 2768 '\u0119': 'e', 2769 '\u1E19': 'e', 2770 '\u1E1B': 'e', 2771 '\u0247': 'e', 2772 '\u025B': 'e', 2773 '\u01DD': 'e', 2774 '\u24D5': 'f', 2775 '\uFF46': 'f', 2776 '\u1E1F': 'f', 2777 '\u0192': 'f', 2778 '\uA77C': 'f', 2779 '\u24D6': 'g', 2780 '\uFF47': 'g', 2781 '\u01F5': 'g', 2782 '\u011D': 'g', 2783 '\u1E21': 'g', 2784 '\u011F': 'g', 2785 '\u0121': 'g', 2786 '\u01E7': 'g', 2787 '\u0123': 'g', 2788 '\u01E5': 'g', 2789 '\u0260': 'g', 2790 '\uA7A1': 'g', 2791 '\u1D79': 'g', 2792 '\uA77F': 'g', 2793 '\u24D7': 'h', 2794 '\uFF48': 'h', 2795 '\u0125': 'h', 2796 '\u1E23': 'h', 2797 '\u1E27': 'h', 2798 '\u021F': 'h', 2799 '\u1E25': 'h', 2800 '\u1E29': 'h', 2801 '\u1E2B': 'h', 2802 '\u1E96': 'h', 2803 '\u0127': 'h', 2804 '\u2C68': 'h', 2805 '\u2C76': 'h', 2806 '\u0265': 'h', 2807 '\u0195': 'hv', 2808 '\u24D8': 'i', 2809 '\uFF49': 'i', 2810 '\u00EC': 'i', 2811 '\u00ED': 'i', 2812 '\u00EE': 'i', 2813 '\u0129': 'i', 2814 '\u012B': 'i', 2815 '\u012D': 'i', 2816 '\u00EF': 'i', 2817 '\u1E2F': 'i', 2818 '\u1EC9': 'i', 2819 '\u01D0': 'i', 2820 '\u0209': 'i', 2821 '\u020B': 'i', 2822 '\u1ECB': 'i', 2823 '\u012F': 'i', 2824 '\u1E2D': 'i', 2825 '\u0268': 'i', 2826 '\u0131': 'i', 2827 '\u24D9': 'j', 2828 '\uFF4A': 'j', 2829 '\u0135': 'j', 2830 '\u01F0': 'j', 2831 '\u0249': 'j', 2832 '\u24DA': 'k', 2833 '\uFF4B': 'k', 2834 '\u1E31': 'k', 2835 '\u01E9': 'k', 2836 '\u1E33': 'k', 2837 '\u0137': 'k', 2838 '\u1E35': 'k', 2839 '\u0199': 'k', 2840 '\u2C6A': 'k', 2841 '\uA741': 'k', 2842 '\uA743': 'k', 2843 '\uA745': 'k', 2844 '\uA7A3': 'k', 2845 '\u24DB': 'l', 2846 '\uFF4C': 'l', 2847 '\u0140': 'l', 2848 '\u013A': 'l', 2849 '\u013E': 'l', 2850 '\u1E37': 'l', 2851 '\u1E39': 'l', 2852 '\u013C': 'l', 2853 '\u1E3D': 'l', 2854 '\u1E3B': 'l', 2855 '\u017F': 'l', 2856 '\u0142': 'l', 2857 '\u019A': 'l', 2858 '\u026B': 'l', 2859 '\u2C61': 'l', 2860 '\uA749': 'l', 2861 '\uA781': 'l', 2862 '\uA747': 'l', 2863 '\u01C9': 'lj', 2864 '\u24DC': 'm', 2865 '\uFF4D': 'm', 2866 '\u1E3F': 'm', 2867 '\u1E41': 'm', 2868 '\u1E43': 'm', 2869 '\u0271': 'm', 2870 '\u026F': 'm', 2871 '\u24DD': 'n', 2872 '\uFF4E': 'n', 2873 '\u01F9': 'n', 2874 '\u0144': 'n', 2875 '\u00F1': 'n', 2876 '\u1E45': 'n', 2877 '\u0148': 'n', 2878 '\u1E47': 'n', 2879 '\u0146': 'n', 2880 '\u1E4B': 'n', 2881 '\u1E49': 'n', 2882 '\u019E': 'n', 2883 '\u0272': 'n', 2884 '\u0149': 'n', 2885 '\uA791': 'n', 2886 '\uA7A5': 'n', 2887 '\u01CC': 'nj', 2888 '\u24DE': 'o', 2889 '\uFF4F': 'o', 2890 '\u00F2': 'o', 2891 '\u00F3': 'o', 2892 '\u00F4': 'o', 2893 '\u1ED3': 'o', 2894 '\u1ED1': 'o', 2895 '\u1ED7': 'o', 2896 '\u1ED5': 'o', 2897 '\u00F5': 'o', 2898 '\u1E4D': 'o', 2899 '\u022D': 'o', 2900 '\u1E4F': 'o', 2901 '\u014D': 'o', 2902 '\u1E51': 'o', 2903 '\u1E53': 'o', 2904 '\u014F': 'o', 2905 '\u022F': 'o', 2906 '\u0231': 'o', 2907 '\u00F6': 'o', 2908 '\u022B': 'o', 2909 '\u1ECF': 'o', 2910 '\u0151': 'o', 2911 '\u01D2': 'o', 2912 '\u020D': 'o', 2913 '\u020F': 'o', 2914 '\u01A1': 'o', 2915 '\u1EDD': 'o', 2916 '\u1EDB': 'o', 2917 '\u1EE1': 'o', 2918 '\u1EDF': 'o', 2919 '\u1EE3': 'o', 2920 '\u1ECD': 'o', 2921 '\u1ED9': 'o', 2922 '\u01EB': 'o', 2923 '\u01ED': 'o', 2924 '\u00F8': 'o', 2925 '\u01FF': 'o', 2926 '\u0254': 'o', 2927 '\uA74B': 'o', 2928 '\uA74D': 'o', 2929 '\u0275': 'o', 2930 '\u01A3': 'oi', 2931 '\u0223': 'ou', 2932 '\uA74F': 'oo', 2933 '\u24DF': 'p', 2934 '\uFF50': 'p', 2935 '\u1E55': 'p', 2936 '\u1E57': 'p', 2937 '\u01A5': 'p', 2938 '\u1D7D': 'p', 2939 '\uA751': 'p', 2940 '\uA753': 'p', 2941 '\uA755': 'p', 2942 '\u24E0': 'q', 2943 '\uFF51': 'q', 2944 '\u024B': 'q', 2945 '\uA757': 'q', 2946 '\uA759': 'q', 2947 '\u24E1': 'r', 2948 '\uFF52': 'r', 2949 '\u0155': 'r', 2950 '\u1E59': 'r', 2951 '\u0159': 'r', 2952 '\u0211': 'r', 2953 '\u0213': 'r', 2954 '\u1E5B': 'r', 2955 '\u1E5D': 'r', 2956 '\u0157': 'r', 2957 '\u1E5F': 'r', 2958 '\u024D': 'r', 2959 '\u027D': 'r', 2960 '\uA75B': 'r', 2961 '\uA7A7': 'r', 2962 '\uA783': 'r', 2963 '\u24E2': 's', 2964 '\uFF53': 's', 2965 '\u00DF': 's', 2966 '\u015B': 's', 2967 '\u1E65': 's', 2968 '\u015D': 's', 2969 '\u1E61': 's', 2970 '\u0161': 's', 2971 '\u1E67': 's', 2972 '\u1E63': 's', 2973 '\u1E69': 's', 2974 '\u0219': 's', 2975 '\u015F': 's', 2976 '\u023F': 's', 2977 '\uA7A9': 's', 2978 '\uA785': 's', 2979 '\u1E9B': 's', 2980 '\u24E3': 't', 2981 '\uFF54': 't', 2982 '\u1E6B': 't', 2983 '\u1E97': 't', 2984 '\u0165': 't', 2985 '\u1E6D': 't', 2986 '\u021B': 't', 2987 '\u0163': 't', 2988 '\u1E71': 't', 2989 '\u1E6F': 't', 2990 '\u0167': 't', 2991 '\u01AD': 't', 2992 '\u0288': 't', 2993 '\u2C66': 't', 2994 '\uA787': 't', 2995 '\uA729': 'tz', 2996 '\u24E4': 'u', 2997 '\uFF55': 'u', 2998 '\u00F9': 'u', 2999 '\u00FA': 'u', 3000 '\u00FB': 'u', 3001 '\u0169': 'u', 3002 '\u1E79': 'u', 3003 '\u016B': 'u', 3004 '\u1E7B': 'u', 3005 '\u016D': 'u', 3006 '\u00FC': 'u', 3007 '\u01DC': 'u', 3008 '\u01D8': 'u', 3009 '\u01D6': 'u', 3010 '\u01DA': 'u', 3011 '\u1EE7': 'u', 3012 '\u016F': 'u', 3013 '\u0171': 'u', 3014 '\u01D4': 'u', 3015 '\u0215': 'u', 3016 '\u0217': 'u', 3017 '\u01B0': 'u', 3018 '\u1EEB': 'u', 3019 '\u1EE9': 'u', 3020 '\u1EEF': 'u', 3021 '\u1EED': 'u', 3022 '\u1EF1': 'u', 3023 '\u1EE5': 'u', 3024 '\u1E73': 'u', 3025 '\u0173': 'u', 3026 '\u1E77': 'u', 3027 '\u1E75': 'u', 3028 '\u0289': 'u', 3029 '\u24E5': 'v', 3030 '\uFF56': 'v', 3031 '\u1E7D': 'v', 3032 '\u1E7F': 'v', 3033 '\u028B': 'v', 3034 '\uA75F': 'v', 3035 '\u028C': 'v', 3036 '\uA761': 'vy', 3037 '\u24E6': 'w', 3038 '\uFF57': 'w', 3039 '\u1E81': 'w', 3040 '\u1E83': 'w', 3041 '\u0175': 'w', 3042 '\u1E87': 'w', 3043 '\u1E85': 'w', 3044 '\u1E98': 'w', 3045 '\u1E89': 'w', 3046 '\u2C73': 'w', 3047 '\u24E7': 'x', 3048 '\uFF58': 'x', 3049 '\u1E8B': 'x', 3050 '\u1E8D': 'x', 3051 '\u24E8': 'y', 3052 '\uFF59': 'y', 3053 '\u1EF3': 'y', 3054 '\u00FD': 'y', 3055 '\u0177': 'y', 3056 '\u1EF9': 'y', 3057 '\u0233': 'y', 3058 '\u1E8F': 'y', 3059 '\u00FF': 'y', 3060 '\u1EF7': 'y', 3061 '\u1E99': 'y', 3062 '\u1EF5': 'y', 3063 '\u01B4': 'y', 3064 '\u024F': 'y', 3065 '\u1EFF': 'y', 3066 '\u24E9': 'z', 3067 '\uFF5A': 'z', 3068 '\u017A': 'z', 3069 '\u1E91': 'z', 3070 '\u017C': 'z', 3071 '\u017E': 'z', 3072 '\u1E93': 'z', 3073 '\u1E95': 'z', 3074 '\u01B6': 'z', 3075 '\u0225': 'z', 3076 '\u0240': 'z', 3077 '\u2C6C': 'z', 3078 '\uA763': 'z', 3079 '\u0386': '\u0391', 3080 '\u0388': '\u0395', 3081 '\u0389': '\u0397', 3082 '\u038A': '\u0399', 3083 '\u03AA': '\u0399', 3084 '\u038C': '\u039F', 3085 '\u038E': '\u03A5', 3086 '\u03AB': '\u03A5', 3087 '\u038F': '\u03A9', 3088 '\u03AC': '\u03B1', 3089 '\u03AD': '\u03B5', 3090 '\u03AE': '\u03B7', 3091 '\u03AF': '\u03B9', 3092 '\u03CA': '\u03B9', 3093 '\u0390': '\u03B9', 3094 '\u03CC': '\u03BF', 3095 '\u03CD': '\u03C5', 3096 '\u03CB': '\u03C5', 3097 '\u03B0': '\u03C5', 3098 '\u03C9': '\u03C9', 3099 '\u03C2': '\u03C3' 3100 }; 3101 3102 return diacritics; 3103}); 3104 3105S2.define('select2/data/base',[ 3106 '../utils' 3107], function (Utils) { 3108 function BaseAdapter ($element, options) { 3109 BaseAdapter.__super__.constructor.call(this); 3110 } 3111 3112 Utils.Extend(BaseAdapter, Utils.Observable); 3113 3114 BaseAdapter.prototype.current = function (callback) { 3115 throw new Error('The `current` method must be defined in child classes.'); 3116 }; 3117 3118 BaseAdapter.prototype.query = function (params, callback) { 3119 throw new Error('The `query` method must be defined in child classes.'); 3120 }; 3121 3122 BaseAdapter.prototype.bind = function (container, $container) { 3123 // Can be implemented in subclasses 3124 }; 3125 3126 BaseAdapter.prototype.destroy = function () { 3127 // Can be implemented in subclasses 3128 }; 3129 3130 BaseAdapter.prototype.generateResultId = function (container, data) { 3131 var id = ''; 3132 3133 if (container != null) { 3134 id += container.id 3135 } else { 3136 id += Utils.generateChars(4); 3137 } 3138 3139 id += '-result-'; 3140 id += Utils.generateChars(4); 3141 3142 if (data.id != null) { 3143 id += '-' + data.id.toString(); 3144 } else { 3145 id += '-' + Utils.generateChars(4); 3146 } 3147 return id; 3148 }; 3149 3150 return BaseAdapter; 3151}); 3152 3153S2.define('select2/data/select',[ 3154 './base', 3155 '../utils', 3156 'jquery' 3157], function (BaseAdapter, Utils, $) { 3158 function SelectAdapter ($element, options) { 3159 this.$element = $element; 3160 this.options = options; 3161 3162 SelectAdapter.__super__.constructor.call(this); 3163 } 3164 3165 Utils.Extend(SelectAdapter, BaseAdapter); 3166 3167 SelectAdapter.prototype.current = function (callback) { 3168 var data = []; 3169 var self = this; 3170 3171 this.$element.find(':selected').each(function () { 3172 var $option = $(this); 3173 3174 var option = self.item($option); 3175 3176 data.push(option); 3177 }); 3178 3179 callback(data); 3180 }; 3181 3182 SelectAdapter.prototype.select = function (data) { 3183 var self = this; 3184 3185 data.selected = true; 3186 3187 // If data.element is a DOM node, use it instead 3188 if ($(data.element).is('option')) { 3189 data.element.selected = true; 3190 3191 this.$element.trigger('change'); 3192 3193 return; 3194 } 3195 3196 if (this.$element.prop('multiple')) { 3197 this.current(function (currentData) { 3198 var val = []; 3199 3200 data = [data]; 3201 data.push.apply(data, currentData); 3202 3203 for (var d = 0; d < data.length; d++) { 3204 var id = data[d].id; 3205 3206 if ($.inArray(id, val) === -1) { 3207 val.push(id); 3208 } 3209 } 3210 3211 self.$element.val(val); 3212 self.$element.trigger('change'); 3213 }); 3214 } else { 3215 var val = data.id; 3216 3217 this.$element.val(val); 3218 this.$element.trigger('change'); 3219 } 3220 }; 3221 3222 SelectAdapter.prototype.unselect = function (data) { 3223 var self = this; 3224 3225 if (!this.$element.prop('multiple')) { 3226 return; 3227 } 3228 3229 data.selected = false; 3230 3231 if ($(data.element).is('option')) { 3232 data.element.selected = false; 3233 3234 this.$element.trigger('change'); 3235 3236 return; 3237 } 3238 3239 this.current(function (currentData) { 3240 var val = []; 3241 3242 for (var d = 0; d < currentData.length; d++) { 3243 var id = currentData[d].id; 3244 3245 if (id !== data.id && $.inArray(id, val) === -1) { 3246 val.push(id); 3247 } 3248 } 3249 3250 self.$element.val(val); 3251 3252 self.$element.trigger('change'); 3253 }); 3254 }; 3255 3256 SelectAdapter.prototype.bind = function (container, $container) { 3257 var self = this; 3258 3259 this.container = container; 3260 3261 container.on('select', function (params) { 3262 self.select(params.data); 3263 }); 3264 3265 container.on('unselect', function (params) { 3266 self.unselect(params.data); 3267 }); 3268 }; 3269 3270 SelectAdapter.prototype.destroy = function () { 3271 // Remove anything added to child elements 3272 this.$element.find('*').each(function () { 3273 // Remove any custom data set by Select2 3274 $.removeData(this, 'data'); 3275 }); 3276 }; 3277 3278 SelectAdapter.prototype.query = function (params, callback) { 3279 var data = []; 3280 var self = this; 3281 3282 var $options = this.$element.children(); 3283 3284 $options.each(function () { 3285 var $option = $(this); 3286 3287 if (!$option.is('option') && !$option.is('optgroup')) { 3288 return; 3289 } 3290 3291 var option = self.item($option); 3292 3293 var matches = self.matches(params, option); 3294 3295 if (matches !== null) { 3296 data.push(matches); 3297 } 3298 }); 3299 3300 callback({ 3301 results: data 3302 }); 3303 }; 3304 3305 SelectAdapter.prototype.addOptions = function ($options) { 3306 Utils.appendMany(this.$element, $options); 3307 }; 3308 3309 SelectAdapter.prototype.option = function (data) { 3310 var option; 3311 3312 if (data.children) { 3313 option = document.createElement('optgroup'); 3314 option.label = data.text; 3315 } else { 3316 option = document.createElement('option'); 3317 3318 if (option.textContent !== undefined) { 3319 option.textContent = data.text; 3320 } else { 3321 option.innerText = data.text; 3322 } 3323 } 3324 3325 if (data.id !== undefined) { 3326 option.value = data.id; 3327 } 3328 3329 if (data.disabled) { 3330 option.disabled = true; 3331 } 3332 3333 if (data.selected) { 3334 option.selected = true; 3335 } 3336 3337 if (data.title) { 3338 option.title = data.title; 3339 } 3340 3341 var $option = $(option); 3342 3343 var normalizedData = this._normalizeItem(data); 3344 normalizedData.element = option; 3345 3346 // Override the option's data with the combined data 3347 $.data(option, 'data', normalizedData); 3348 3349 return $option; 3350 }; 3351 3352 SelectAdapter.prototype.item = function ($option) { 3353 var data = {}; 3354 3355 data = $.data($option[0], 'data'); 3356 3357 if (data != null) { 3358 return data; 3359 } 3360 3361 if ($option.is('option')) { 3362 data = { 3363 id: $option.val(), 3364 text: $option.text(), 3365 disabled: $option.prop('disabled'), 3366 selected: $option.prop('selected'), 3367 title: $option.prop('title') 3368 }; 3369 } else if ($option.is('optgroup')) { 3370 data = { 3371 text: $option.prop('label'), 3372 children: [], 3373 title: $option.prop('title') 3374 }; 3375 3376 var $children = $option.children('option'); 3377 var children = []; 3378 3379 for (var c = 0; c < $children.length; c++) { 3380 var $child = $($children[c]); 3381 3382 var child = this.item($child); 3383 3384 children.push(child); 3385 } 3386 3387 data.children = children; 3388 } 3389 3390 data = this._normalizeItem(data); 3391 data.element = $option[0]; 3392 3393 $.data($option[0], 'data', data); 3394 3395 return data; 3396 }; 3397 3398 SelectAdapter.prototype._normalizeItem = function (item) { 3399 if (!$.isPlainObject(item)) { 3400 item = { 3401 id: item, 3402 text: item 3403 }; 3404 } 3405 3406 item = $.extend({}, { 3407 text: '' 3408 }, item); 3409 3410 var defaults = { 3411 selected: false, 3412 disabled: false 3413 }; 3414 3415 if (item.id != null) { 3416 item.id = item.id.toString(); 3417 } 3418 3419 if (item.text != null) { 3420 item.text = item.text.toString(); 3421 } 3422 3423 if (item._resultId == null && item.id) { 3424 item._resultId = this.generateResultId(this.container, item); 3425 } 3426 3427 return $.extend({}, defaults, item); 3428 }; 3429 3430 SelectAdapter.prototype.matches = function (params, data) { 3431 var matcher = this.options.get('matcher'); 3432 3433 return matcher(params, data); 3434 }; 3435 3436 return SelectAdapter; 3437}); 3438 3439S2.define('select2/data/array',[ 3440 './select', 3441 '../utils', 3442 'jquery' 3443], function (SelectAdapter, Utils, $) { 3444 function ArrayAdapter ($element, options) { 3445 var data = options.get('data') || []; 3446 3447 ArrayAdapter.__super__.constructor.call(this, $element, options); 3448 3449 this.addOptions(this.convertToOptions(data)); 3450 } 3451 3452 Utils.Extend(ArrayAdapter, SelectAdapter); 3453 3454 ArrayAdapter.prototype.select = function (data) { 3455 var $option = this.$element.find('option').filter(function (i, elm) { 3456 return elm.value == data.id.toString(); 3457 }); 3458 3459 if ($option.length === 0) { 3460 $option = this.option(data); 3461 3462 this.addOptions($option); 3463 } 3464 3465 ArrayAdapter.__super__.select.call(this, data); 3466 }; 3467 3468 ArrayAdapter.prototype.convertToOptions = function (data) { 3469 var self = this; 3470 3471 var $existing = this.$element.find('option'); 3472 var existingIds = $existing.map(function () { 3473 return self.item($(this)).id; 3474 }).get(); 3475 3476 var $options = []; 3477 3478 // Filter out all items except for the one passed in the argument 3479 function onlyItem (item) { 3480 return function () { 3481 return $(this).val() == item.id; 3482 }; 3483 } 3484 3485 for (var d = 0; d < data.length; d++) { 3486 var item = this._normalizeItem(data[d]); 3487 3488 // Skip items which were pre-loaded, only merge the data 3489 if ($.inArray(item.id, existingIds) >= 0) { 3490 var $existingOption = $existing.filter(onlyItem(item)); 3491 3492 var existingData = this.item($existingOption); 3493 var newData = $.extend(true, {}, item, existingData); 3494 3495 var $newOption = this.option(newData); 3496 3497 $existingOption.replaceWith($newOption); 3498 3499 continue; 3500 } 3501 3502 var $option = this.option(item); 3503 3504 if (item.children) { 3505 var $children = this.convertToOptions(item.children); 3506 3507 Utils.appendMany($option, $children); 3508 } 3509 3510 $options.push($option); 3511 } 3512 3513 return $options; 3514 }; 3515 3516 return ArrayAdapter; 3517}); 3518 3519S2.define('select2/data/ajax',[ 3520 './array', 3521 '../utils', 3522 'jquery' 3523], function (ArrayAdapter, Utils, $) { 3524 function AjaxAdapter ($element, options) { 3525 this.ajaxOptions = this._applyDefaults(options.get('ajax')); 3526 3527 if (this.ajaxOptions.processResults != null) { 3528 this.processResults = this.ajaxOptions.processResults; 3529 } 3530 3531 AjaxAdapter.__super__.constructor.call(this, $element, options); 3532 } 3533 3534 Utils.Extend(AjaxAdapter, ArrayAdapter); 3535 3536 AjaxAdapter.prototype._applyDefaults = function (options) { 3537 var defaults = { 3538 data: function (params) { 3539 return $.extend({}, params, { 3540 q: params.term 3541 }); 3542 }, 3543 transport: function (params, success, failure) { 3544 var $request = $.ajax(params); 3545 3546 $request.then(success); 3547 $request.fail(failure); 3548 3549 return $request; 3550 } 3551 }; 3552 3553 return $.extend({}, defaults, options, true); 3554 }; 3555 3556 AjaxAdapter.prototype.processResults = function (results) { 3557 return results; 3558 }; 3559 3560 AjaxAdapter.prototype.query = function (params, callback) { 3561 var matches = []; 3562 var self = this; 3563 3564 if (this._request != null) { 3565 // JSONP requests cannot always be aborted 3566 if (
vendor: 21,776 bytes, lines 3566-4438
3566'function' === typeof this._request.abort) { 3567 this._request.abort(); 3568 } 3569 3570 this._request = null; 3571 } 3572 3573 var options = $.extend({ 3574 type: 'GET' 3575 }, this.ajaxOptions); 3576 3577 if (typeof options.url === 'function') { 3578 options.url = options.url.call(this.$element, params); 3579 } 3580 3581 if (typeof options.data === 'function') { 3582 options.data = options.data.call(this.$element, params); 3583 } 3584 3585 function request () { 3586 var $request = options.transport(options, function (data) { 3587 var results = self.processResults(data, params); 3588 3589 if (self.options.get('debug') && window.console && console.error) { 3590 // Check to make sure that the response included a `results` key. 3591 if (!results || !results.results || !Array.isArray(results.results)) { 3592 console.error( 3593 'Select2: The AJAX results did not return an array in the ' + 3594 '`results` key of the response.' 3595 ); 3596 } 3597 } 3598 3599 callback(results); 3600 self.container.focusOnActiveElement(); 3601 }, function () { 3602 // Attempt to detect if a request was aborted 3603 // Only works if the transport exposes a status property 3604 if ($request.status && $request.status === '0') { 3605 return; 3606 } 3607 3608 self.trigger('results:message', { 3609 message: 'errorLoading' 3610 }); 3611 }); 3612 3613 self._request = $request; 3614 } 3615 3616 if (this.ajaxOptions.delay && params.term != null) { 3617 if (this._queryTimeout) { 3618 window.clearTimeout(this._queryTimeout); 3619 } 3620 3621 this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay); 3622 } else { 3623 request(); 3624 } 3625 }; 3626 3627 return AjaxAdapter; 3628}); 3629 3630S2.define('select2/data/tags',[ 3631 'jquery' 3632], function ($) { 3633 function Tags (decorated, $element, options) { 3634 var tags = options.get('tags'); 3635 3636 var createTag = options.get('createTag'); 3637 3638 if (createTag !== undefined) { 3639 this.createTag = createTag; 3640 } 3641 3642 var insertTag = options.get('insertTag'); 3643 3644 if (insertTag !== undefined) { 3645 this.insertTag = insertTag; 3646 } 3647 3648 decorated.call(this, $element, options); 3649 3650 if (Array.isArray(tags)) { 3651 for (var t = 0; t < tags.length; t++) { 3652 var tag = tags[t]; 3653 var item = this._normalizeItem(tag); 3654 3655 var $option = this.option(item); 3656 3657 this.$element.append($option); 3658 } 3659 } 3660 } 3661 3662 Tags.prototype.query = function (decorated, params, callback) { 3663 var self = this; 3664 3665 this._removeOldTags(); 3666 3667 if (params.term == null || params.page != null) { 3668 decorated.call(this, params, callback); 3669 return; 3670 } 3671 3672 function wrapper (obj, child) { 3673 var data = obj.results; 3674 3675 for (var i = 0; i < data.length; i++) { 3676 var option = data[i]; 3677 3678 var checkChildren = ( 3679 option.children != null && 3680 !wrapper({ 3681 results: option.children 3682 }, true) 3683 ); 3684 3685 var optionText = (option.text || '').toUpperCase(); 3686 var paramsTerm = (params.term || '').toUpperCase(); 3687 3688 var checkText = optionText === paramsTerm; 3689 3690 if (checkText || checkChildren) { 3691 if (child) { 3692 return false; 3693 } 3694 3695 obj.data = data; 3696 callback(obj); 3697 3698 return; 3699 } 3700 } 3701 3702 if (child) { 3703 return true; 3704 } 3705 3706 var tag = self.createTag(params); 3707 3708 if (tag != null) { 3709 var $option = self.option(tag); 3710 $option.attr('data-select2-tag', true); 3711 3712 self.addOptions([$option]); 3713 3714 self.insertTag(data, tag); 3715 } 3716 3717 obj.results = data; 3718 3719 callback(obj); 3720 } 3721 3722 decorated.call(this, params, wrapper); 3723 }; 3724 3725 Tags.prototype.createTag = function (decorated, params) { 3726 var term = ( params.term || 0 == params.term ) ? params.term.toString().trim() : ''; 3727 3728 if (term === '') { 3729 return null; 3730 } 3731 3732 return { 3733 id: term, 3734 text: term 3735 }; 3736 }; 3737 3738 Tags.prototype.insertTag = function (_, data, tag) { 3739 data.unshift(tag); 3740 }; 3741 3742 Tags.prototype._removeOldTags = function (_) { 3743 var tag = this._lastTag; 3744 3745 var $options = this.$element.find('option[data-select2-tag]'); 3746 3747 $options.each(function () { 3748 if (this.selected) { 3749 return; 3750 } 3751 3752 $(this).remove(); 3753 }); 3754 }; 3755 3756 return Tags; 3757}); 3758 3759S2.define('select2/data/tokenizer',[ 3760 'jquery' 3761], function ($) { 3762 function Tokenizer (decorated, $element, options) { 3763 var tokenizer = options.get('tokenizer'); 3764 3765 if (tokenizer !== undefined) { 3766 this.tokenizer = tokenizer; 3767 } 3768 3769 decorated.call(this, $element, options); 3770 } 3771 3772 Tokenizer.prototype.bind = function (decorated, container, $container) { 3773 decorated.call(this, container, $container); 3774 3775 this.$search = container.dropdown.$search || container.selection.$search || 3776 $container.find('.select2-search__field'); 3777 }; 3778 3779 Tokenizer.prototype.query = function (decorated, params, callback) { 3780 var self = this; 3781 3782 function createAndSelect (data) { 3783 // Normalize the data object so we can use it for checks 3784 var item = self._normalizeItem(data); 3785 3786 // Check if the data object already exists as a tag 3787 // Select it if it doesn't 3788 var $existingOptions = self.$element.find('option').filter(function () { 3789 return $(this).val() === item.id; 3790 }); 3791 3792 // If an existing option wasn't found for it, create the option 3793 if (!$existingOptions.length) { 3794 var $option = self.option(item); 3795 $option.attr('data-select2-tag', true); 3796 3797 self._removeOldTags(); 3798 self.addOptions([$option]); 3799 } 3800 3801 // Select the item, now that we know there is an option for it 3802 select(item); 3803 } 3804 3805 function select (data) { 3806 self.trigger('select', { 3807 data: data 3808 }); 3809 } 3810 3811 params.term = params.term || ''; 3812 3813 var tokenData = this.tokenizer(params, this.options, createAndSelect); 3814 3815 if (tokenData.term !== params.term) { 3816 // Replace the search term if we have the search box 3817 if (this.$search.length) { 3818 this.$search.val(tokenData.term); 3819 this.$search.trigger( 'focus' ); 3820 } 3821 3822 params.term = tokenData.term; 3823 } 3824 3825 decorated.call(this, params, callback); 3826 }; 3827 3828 Tokenizer.prototype.tokenizer = function (_, params, options, callback) { 3829 var separators = options.get('tokenSeparators') || []; 3830 var term = params.term; 3831 var i = 0; 3832 3833 var createTag = this.createTag || function (params) { 3834 return { 3835 id: params.term, 3836 text: params.term 3837 }; 3838 }; 3839 3840 while (i < term.length) { 3841 var termChar = term[i]; 3842 3843 if ($.inArray(termChar, separators) === -1) { 3844 i++; 3845 3846 continue; 3847 } 3848 3849 var part = term.substr(0, i); 3850 var partParams = $.extend({}, params, { 3851 term: part 3852 }); 3853 3854 var data = createTag(partParams); 3855 3856 if (data == null) { 3857 i++; 3858 continue; 3859 } 3860 3861 callback(data); 3862 3863 // Reset the term to not include the tokenized portion 3864 term = term.substr(i + 1) || ''; 3865 i = 0; 3866 } 3867 3868 return { 3869 term: term 3870 }; 3871 }; 3872 3873 return Tokenizer; 3874}); 3875 3876S2.define('select2/data/minimumInputLength',[ 3877 3878], function () { 3879 function MinimumInputLength (decorated, $e, options) { 3880 this.minimumInputLength = options.get('minimumInputLength'); 3881 3882 decorated.call(this, $e, options); 3883 } 3884 3885 MinimumInputLength.prototype.query = function (decorated, params, callback) { 3886 params.term = params.term || ''; 3887 3888 if (params.term.length < this.minimumInputLength) { 3889 this.trigger('results:message', { 3890 message: 'inputTooShort', 3891 args: { 3892 minimum: this.minimumInputLength, 3893 input: params.term, 3894 params: params 3895 } 3896 }); 3897 3898 return; 3899 } 3900 3901 decorated.call(this, params, callback); 3902 }; 3903 3904 return MinimumInputLength; 3905}); 3906 3907S2.define('select2/data/maximumInputLength',[ 3908 3909], function () { 3910 function MaximumInputLength (decorated, $e, options) { 3911 this.maximumInputLength = options.get('maximumInputLength'); 3912 3913 decorated.call(this, $e, options); 3914 } 3915 3916 MaximumInputLength.prototype.query = function (decorated, params, callback) { 3917 params.term = params.term || ''; 3918 3919 if (this.maximumInputLength > 0 && 3920 params.term.length > this.maximumInputLength) { 3921 this.trigger('results:message', { 3922 message: 'inputTooLong', 3923 args: { 3924 maximum: this.maximumInputLength, 3925 input: params.term, 3926 params: params 3927 } 3928 }); 3929 3930 return; 3931 } 3932 3933 decorated.call(this, params, callback); 3934 }; 3935 3936 return MaximumInputLength; 3937}); 3938 3939S2.define('select2/data/maximumSelectionLength',[ 3940 3941], function (){ 3942 function MaximumSelectionLength (decorated, $e, options) { 3943 this.maximumSelectionLength = options.get('maximumSelectionLength'); 3944 3945 decorated.call(this, $e, options); 3946 } 3947 3948 MaximumSelectionLength.prototype.query = 3949 function (decorated, params, callback) { 3950 var self = this; 3951 3952 this.current(function (currentData) { 3953 var count = currentData != null ? currentData.length : 0; 3954 if (self.maximumSelectionLength > 0 && 3955 count >= self.maximumSelectionLength) { 3956 self.trigger('results:message', { 3957 message: 'maximumSelected', 3958 args: { 3959 maximum: self.maximumSelectionLength 3960 } 3961 }); 3962 return; 3963 } 3964 decorated.call(self, params, callback); 3965 }); 3966 }; 3967 3968 return MaximumSelectionLength; 3969}); 3970 3971S2.define('select2/dropdown',[ 3972 'jquery', 3973 './utils' 3974], function ($, Utils) { 3975 function Dropdown ($element, options) { 3976 this.$element = $element; 3977 this.options = options; 3978 3979 Dropdown.__super__.constructor.call(this); 3980 } 3981 3982 Utils.Extend(Dropdown, Utils.Observable); 3983 3984 Dropdown.prototype.render = function () { 3985 var $dropdown = $( 3986 '<span class="select2-dropdown">' + 3987 '<span class="select2-results"></span>' + 3988 '</span>' 3989 ); 3990 3991 $dropdown.attr('dir', this.options.get('dir')); 3992 3993 this.$dropdown = $dropdown; 3994 3995 return $dropdown; 3996 }; 3997 3998 Dropdown.prototype.bind = function () { 3999 // Should be implemented in subclasses 4000 }; 4001 4002 Dropdown.prototype.position = function ($dropdown, $container) { 4003 // Should be implmented in subclasses 4004 }; 4005 4006 Dropdown.prototype.destroy = function () { 4007 // Remove the dropdown from the DOM 4008 this.$dropdown.remove(); 4009 }; 4010 4011 return Dropdown; 4012}); 4013 4014S2.define('select2/dropdown/search',[ 4015 'jquery', 4016 '../utils' 4017], function ($, Utils) { 4018 function Search () { } 4019 4020 Search.prototype.render = function (decorated) { 4021 var $rendered = decorated.call(this); 4022 4023 var $search = $( 4024 '<span class="select2-search select2-search--dropdown">' + 4025 '<input class="select2-search__field" type="text" tabindex="-1"' + 4026 ' autocomplete="off" autocorrect="off" autocapitalize="none"' + 4027 ' spellcheck="false" role="combobox" aria-autocomplete="list" aria-expanded="true" />' + 4028 '</span>' 4029 ); 4030 4031 this.$searchContainer = $search; 4032 this.$search = $search.find('input'); 4033 4034 $rendered.prepend($search); 4035 4036 return $rendered; 4037 }; 4038 4039 Search.prototype.bind = function (decorated, container, $container) { 4040 var self = this; 4041 var resultsId = container.id + '-results'; 4042 4043 decorated.call(this, container, $container); 4044 4045 this.$search.on('keydown', function (evt) { 4046 self.trigger('keypress', evt); 4047 4048 self._keyUpPrevented = evt.isDefaultPrevented(); 4049 }); 4050 4051 // Workaround for browsers which do not support the `input` event 4052 // This will prevent double-triggering of events for browsers which support 4053 // both the `keyup` and `input` events. 4054 this.$search.on('input', function (evt) { 4055 // Unbind the duplicated `keyup` event 4056 $(this).off('keyup'); 4057 }); 4058 4059 this.$search.on('keyup input', function (evt) { 4060 self.handleSearch(evt); 4061 }); 4062 4063 container.on('open', function () { 4064 self.$search.attr('tabindex', 0); 4065 self.$search.attr('aria-owns', resultsId); 4066 self.$search.trigger( 'focus' ); 4067 4068 window.setTimeout(function () { 4069 self.$search.trigger( 'focus' ); 4070 }, 0); 4071 }); 4072 4073 container.on('close', function () { 4074 self.$search.attr('tabindex', -1); 4075 self.$search.removeAttr('aria-activedescendant'); 4076 self.$search.removeAttr('aria-owns'); 4077 self.$search.val(''); 4078 }); 4079 4080 container.on('focus', function () { 4081 if (!container.isOpen()) { 4082 self.$search.trigger( 'focus' ); 4083 } 4084 }); 4085 4086 container.on('results:all', function (params) { 4087 if (params.query.term == null || params.query.term === '') { 4088 var showSearch = self.showSearch(params); 4089 4090 if (showSearch) { 4091 self.$searchContainer.removeClass('select2-search--hide'); 4092 } else { 4093 self.$searchContainer.addClass('select2-search--hide'); 4094 } 4095 } 4096 }); 4097 4098 container.on('results:focus', function (params) { 4099 self.$search.attr('aria-activedescendant', params.data._resultId); 4100 }); 4101 }; 4102 4103 Search.prototype.handleSearch = function (evt) { 4104 if (!this._keyUpPrevented) { 4105 var input = this.$search.val(); 4106 4107 this.trigger('query', { 4108 term: input 4109 }); 4110 } 4111 4112 this._keyUpPrevented = false; 4113 }; 4114 4115 Search.prototype.showSearch = function (_, params) { 4116 return true; 4117 }; 4118 4119 return Search; 4120}); 4121 4122S2.define('select2/dropdown/hidePlaceholder',[ 4123 4124], function () { 4125 function HidePlaceholder (decorated, $element, options, dataAdapter) { 4126 this.placeholder = this.normalizePlaceholder(options.get('placeholder')); 4127 4128 decorated.call(this, $element, options, dataAdapter); 4129 } 4130 4131 HidePlaceholder.prototype.append = function (decorated, data) { 4132 data.results = this.removePlaceholder(data.results); 4133 4134 decorated.call(this, data); 4135 }; 4136 4137 HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) { 4138 if (typeof placeholder === 'string') { 4139 placeholder = { 4140 id: '', 4141 text: placeholder 4142 }; 4143 } 4144 4145 return placeholder; 4146 }; 4147 4148 HidePlaceholder.prototype.removePlaceholder = function (_, data) { 4149 var modifiedData = data.slice(0); 4150 4151 for (var d = data.length - 1; d >= 0; d--) { 4152 var item = data[d]; 4153 4154 if (this.placeholder.id === item.id) { 4155 modifiedData.splice(d, 1); 4156 } 4157 } 4158 4159 return modifiedData; 4160 }; 4161 4162 return HidePlaceholder; 4163}); 4164 4165S2.define('select2/dropdown/infiniteScroll',[ 4166 'jquery' 4167], function ($) { 4168 function InfiniteScroll (decorated, $element, options, dataAdapter) { 4169 this.lastParams = {}; 4170 4171 decorated.call(this, $element, options, dataAdapter); 4172 4173 this.$loadingMore = this.createLoadingMore(); 4174 this.loading = false; 4175 } 4176 4177 InfiniteScroll.prototype.append = function (decorated, data) { 4178 this.$loadingMore.remove(); 4179 this.loading = false; 4180 4181 decorated.call(this, data); 4182 4183 if (this.showLoadingMore(data)) { 4184 this.$results.append(this.$loadingMore); 4185 } 4186 }; 4187 4188 InfiniteScroll.prototype.bind = function (decorated, container, $container) { 4189 var self = this; 4190 4191 decorated.call(this, container, $container); 4192 4193 container.on('query', function (params) { 4194 self.lastParams = params; 4195 self.loading = true; 4196 }); 4197 4198 container.on('query:append', function (params) { 4199 self.lastParams = params; 4200 self.loading = true; 4201 }); 4202 4203 this.$results.on('scroll', function () { 4204 var isLoadMoreVisible = $.contains( 4205 document.documentElement, 4206 self.$loadingMore[0] 4207 ); 4208 4209 if (self.loading || !isLoadMoreVisible) { 4210 return; 4211 } 4212 4213 var currentOffset = self.$results.offset().top + 4214 self.$results.outerHeight(false); 4215 var loadingMoreOffset = self.$loadingMore.offset().top + 4216 self.$loadingMore.outerHeight(false); 4217 4218 if (currentOffset + 50 >= loadingMoreOffset) { 4219 self.loadMore(); 4220 } 4221 }); 4222 }; 4223 4224 InfiniteScroll.prototype.loadMore = function () { 4225 this.loading = true; 4226 4227 var params = $.extend({}, {page: 1}, this.lastParams); 4228 4229 params.page++; 4230 4231 this.trigger('query:append', params); 4232 }; 4233 4234 InfiniteScroll.prototype.showLoadingMore = function (_, data) { 4235 return data.pagination && data.pagination.more; 4236 }; 4237 4238 InfiniteScroll.prototype.createLoadingMore = function () { 4239 var $option = $( 4240 '<li ' + 4241 'class="select2-results__option select2-results__option--load-more"' + 4242 'role="option" aria-disabled="true"></li>' 4243 ); 4244 4245 var message = this.options.get('translations').get('loadingMore'); 4246 4247 $option.html(message(this.lastParams)); 4248 4249 return $option; 4250 }; 4251 4252 return InfiniteScroll; 4253}); 4254 4255S2.define('select2/dropdown/attachBody',[ 4256 'jquery', 4257 '../utils' 4258], function ($, Utils) { 4259 function AttachBody (decorated, $element, options) { 4260 this.$dropdownParent = options.get('dropdownParent') || $(document.body); 4261 4262 decorated.call(this, $element, options); 4263 } 4264 4265 AttachBody.prototype.bind = function (decorated, container, $container) { 4266 var self = this; 4267 4268 var setupResultsEvents = false; 4269 4270 decorated.call(this, container, $container); 4271 4272 container.on('open', function () { 4273 self._showDropdown(); 4274 self._attachPositioningHandler(container); 4275 4276 if (!setupResultsEvents) { 4277 setupResultsEvents = true; 4278 4279 container.on('results:all', function () { 4280 self._positionDropdown(); 4281 self._resizeDropdown(); 4282 }); 4283 4284 container.on('results:append', function () { 4285 self._positionDropdown(); 4286 self._resizeDropdown(); 4287 }); 4288 } 4289 }); 4290 4291 container.on('close', function () { 4292 self._hideDropdown(); 4293 self._detachPositioningHandler(container); 4294 }); 4295 4296 this.$dropdownContainer.on('mousedown', function (evt) { 4297 evt.stopPropagation(); 4298 }); 4299 }; 4300 4301 AttachBody.prototype.destroy = function (decorated) { 4302 decorated.call(this); 4303 4304 this.$dropdownContainer.remove(); 4305 }; 4306 4307 AttachBody.prototype.position = function (decorated, $dropdown, $container) { 4308 // Clone all of the container classes 4309 $dropdown.attr('class', $container.attr('class')); 4310 4311 $dropdown.removeClass('select2'); 4312 $dropdown.addClass('select2-container--open'); 4313 4314 $dropdown.css({ 4315 position: 'absolute', 4316 top: -999999 4317 }); 4318 4319 this.$container = $container; 4320 }; 4321 4322 AttachBody.prototype.render = function (decorated) { 4323 var $container = $('<span></span>'); 4324 4325 var $dropdown = decorated.call(this); 4326 $container.append($dropdown); 4327 4328 this.$dropdownContainer = $container; 4329 4330 return $container; 4331 }; 4332 4333 AttachBody.prototype._hideDropdown = function (decorated) { 4334 this.$dropdownContainer.detach(); 4335 }; 4336 4337 AttachBody.prototype._attachPositioningHandler = 4338 function (decorated, container) { 4339 var self = this; 4340 4341 var scrollEvent = 'scroll.select2.' + container.id; 4342 var resizeEvent = 'resize.select2.' + container.id; 4343 var orientationEvent = 'orientationchange.select2.' + container.id; 4344 4345 var $watchers = this.$container.parents().filter(Utils.hasScroll); 4346 $watchers.each(function () { 4347 $(this).data('select2-scroll-position', { 4348 x: $(this).scrollLeft(), 4349 y: $(this).scrollTop() 4350 }); 4351 }); 4352 4353 $watchers.on(scrollEvent, function (ev) { 4354 var position = $(this).data('select2-scroll-position'); 4355 $(this).scrollTop(position.y); 4356 }); 4357 4358 $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent, 4359 function (e) { 4360 self._positionDropdown(); 4361 self._resizeDropdown(); 4362 }); 4363 }; 4364 4365 AttachBody.prototype._detachPositioningHandler = 4366 function (decorated, container) { 4367 var scrollEvent = 'scroll.select2.' + container.id; 4368 var resizeEvent = 'resize.select2.' + container.id; 4369 var orientationEvent = 'orientationchange.select2.' + container.id; 4370 4371 var $watchers = this.$container.parents().filter(Utils.hasScroll); 4372 $watchers.off(scrollEvent); 4373 4374 $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent); 4375 }; 4376 4377 AttachBody.prototype._positionDropdown = function () { 4378 var $window = $(window); 4379 4380 var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above'); 4381 var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below'); 4382 4383 var newDirection = null; 4384 4385 var offset = this.$container.offset(); 4386 4387 offset.bottom = offset.top + this.$container.outerHeight(false); 4388 4389 var container = { 4390 height: this.$container.outerHeight(false) 4391 }; 4392 4393 container.top = offset.top; 4394 container.bottom = offset.top + container.height; 4395 4396 var dropdown = { 4397 height: this.$dropdown.outerHeight(false) 4398 }; 4399 4400 var viewport = { 4401 top: $window.scrollTop(), 4402 bottom: $window.scrollTop() + $window.height() 4403 }; 4404 4405 var enoughRoomAbove = viewport.top < (offset.top - dropdown.height); 4406 var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height); 4407 4408 var css = { 4409 left: offset.left, 4410 top: container.bottom 4411 }; 4412 4413 // Determine what the parent element is to use for calciulating the offset 4414 var $offsetParent = this.$dropdownParent; 4415 4416 // For statically positoned elements, we need to get the element 4417 // that is determining the offset 4418 if ($offsetParent.css('position') === 'static') { 4419 $offsetParent = $offsetParent.offsetParent(); 4420 } 4421 4422 var parentOffset = $offsetParent.offset(); 4423 4424 css.left -= parentOffset.left; 4425 4426 if (!isCurrentlyAbove && !isCurrentlyBelow) { 4427 newDirection = 'below'; 4428 } 4429 4430 if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) { 4431 newDirection = 'above'; 4432 } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) { 4433 newDirection = 'below'; 4434 } 4435 4436 if (newDirection == 'above' || 4437 (isCurrentlyAbove && newDirection !== 'below')) { 4438 css.top = container
vendor: 11,273 bytes, lines 4438-4896
4438.top - dropdown.height; 4439 } 4440 4441 if (newDirection != null) { 4442 this.$dropdown 4443 .removeClass('select2-dropdown--below select2-dropdown--above') 4444 .addClass('select2-dropdown--' + newDirection); 4445 this.$container 4446 .removeClass('select2-container--below select2-container--above') 4447 .addClass('select2-container--' + newDirection); 4448 } 4449 4450 this.$dropdownContainer.css(css); 4451 }; 4452 4453 AttachBody.prototype._resizeDropdown = function () { 4454 var css = { 4455 width: this.$container.outerWidth(false) + 'px' 4456 }; 4457 4458 if (this.options.get('dropdownAutoWidth')) { 4459 css.minWidth = css.width; 4460 css.position = 'relative'; 4461 css.width = 'auto'; 4462 } 4463 4464 this.$dropdown.css(css); 4465 }; 4466 4467 AttachBody.prototype._showDropdown = function (decorated) { 4468 this.$dropdownContainer.appendTo(this.$dropdownParent); 4469 4470 this._positionDropdown(); 4471 this._resizeDropdown(); 4472 }; 4473 4474 return AttachBody; 4475}); 4476 4477S2.define('select2/dropdown/minimumResultsForSearch',[ 4478 4479], function () { 4480 function countResults (data) { 4481 var count = 0; 4482 4483 for (var d = 0; d < data.length; d++) { 4484 var item = data[d]; 4485 4486 if (item.children) { 4487 count += countResults(item.children); 4488 } else { 4489 count++; 4490 } 4491 } 4492 4493 return count; 4494 } 4495 4496 function MinimumResultsForSearch (decorated, $element, options, dataAdapter) { 4497 this.minimumResultsForSearch = options.get('minimumResultsForSearch'); 4498 4499 if (this.minimumResultsForSearch < 0) { 4500 this.minimumResultsForSearch = Infinity; 4501 } 4502 4503 decorated.call(this, $element, options, dataAdapter); 4504 } 4505 4506 MinimumResultsForSearch.prototype.showSearch = function (decorated, params) { 4507 if (countResults(params.data.results) < this.minimumResultsForSearch) { 4508 return false; 4509 } 4510 4511 return decorated.call(this, params); 4512 }; 4513 4514 return MinimumResultsForSearch; 4515}); 4516 4517S2.define('select2/dropdown/selectOnClose',[ 4518 4519], function () { 4520 function SelectOnClose () { } 4521 4522 SelectOnClose.prototype.bind = function (decorated, container, $container) { 4523 var self = this; 4524 4525 decorated.call(this, container, $container); 4526 4527 container.on('close', function (params) { 4528 self._handleSelectOnClose(params); 4529 }); 4530 }; 4531 4532 SelectOnClose.prototype._handleSelectOnClose = function (_, params) { 4533 if (params && params.originalSelect2Event != null) { 4534 var event = params.originalSelect2Event; 4535 4536 // Don't select an item if the close event was triggered from a select or 4537 // unselect event 4538 if (event._type === 'select' || event._type === 'unselect') { 4539 return; 4540 } 4541 } 4542 4543 var $highlightedResults = this.getHighlightedResults(); 4544 4545 // Only select highlighted results 4546 if ($highlightedResults.length < 1) { 4547 return; 4548 } 4549 4550 var data = $highlightedResults.data('data'); 4551 4552 // Don't re-select already selected resulte 4553 if ( 4554 (data.element != null && data.element.selected) || 4555 (data.element == null && data.selected) 4556 ) { 4557 return; 4558 } 4559 4560 this.trigger('select', { 4561 data: data 4562 }); 4563 }; 4564 4565 return SelectOnClose; 4566}); 4567 4568S2.define('select2/dropdown/closeOnSelect',[ 4569 4570], function () { 4571 function CloseOnSelect () { } 4572 4573 CloseOnSelect.prototype.bind = function (decorated, container, $container) { 4574 var self = this; 4575 4576 decorated.call(this, container, $container); 4577 4578 container.on('select', function (evt) { 4579 self._selectTriggered(evt); 4580 }); 4581 4582 container.on('unselect', function (evt) { 4583 self._selectTriggered(evt); 4584 }); 4585 }; 4586 4587 CloseOnSelect.prototype._selectTriggered = function (_, evt) { 4588 var originalEvent = evt.originalEvent; 4589 4590 // Don't close if the control key is being held 4591 if (originalEvent && originalEvent.ctrlKey) { 4592 return; 4593 } 4594 4595 this.trigger('close', { 4596 originalEvent: originalEvent, 4597 originalSelect2Event: evt 4598 }); 4599 }; 4600 4601 return CloseOnSelect; 4602}); 4603 4604S2.define('select2/i18n/en',[],function () { 4605 // English 4606 return { 4607 errorLoading: function () { 4608 return 'The results could not be loaded.'; 4609 }, 4610 inputTooLong: function (args) { 4611 var overChars = args.input.length - args.maximum; 4612 4613 var message = 'Please delete ' + overChars + ' character'; 4614 4615 if (overChars != 1) { 4616 message += 's'; 4617 } 4618 4619 return message; 4620 }, 4621 inputTooShort: function (args) { 4622 var remainingChars = args.minimum - args.input.length; 4623 4624 var message = 'Please enter ' + remainingChars + ' or more characters'; 4625 4626 return message; 4627 }, 4628 loadingMore: function () { 4629 return 'Loading more results…'; 4630 }, 4631 maximumSelected: function (args) { 4632 var message = 'You can only select ' + args.maximum + ' item'; 4633 4634 if (args.maximum != 1) { 4635 message += 's'; 4636 } 4637 4638 return message; 4639 }, 4640 noResults: function () { 4641 return 'No results found'; 4642 }, 4643 searching: function () { 4644 return 'Searching…'; 4645 } 4646 }; 4647}); 4648 4649S2.define('select2/defaults',[ 4650 'jquery', 4651 'require', 4652 4653 './results', 4654 4655 './selection/single', 4656 './selection/multiple', 4657 './selection/placeholder', 4658 './selection/allowClear', 4659 './selection/search', 4660 './selection/eventRelay', 4661 4662 './utils', 4663 './translation', 4664 './diacritics', 4665 4666 './data/select', 4667 './data/array', 4668 './data/ajax', 4669 './data/tags', 4670 './data/tokenizer', 4671 './data/minimumInputLength', 4672 './data/maximumInputLength', 4673 './data/maximumSelectionLength', 4674 4675 './dropdown', 4676 './dropdown/search', 4677 './dropdown/hidePlaceholder', 4678 './dropdown/infiniteScroll', 4679 './dropdown/attachBody', 4680 './dropdown/minimumResultsForSearch', 4681 './dropdown/selectOnClose', 4682 './dropdown/closeOnSelect', 4683 4684 './i18n/en' 4685], function ($, require, 4686 4687 ResultsList, 4688 4689 SingleSelection, MultipleSelection, Placeholder, AllowClear, 4690 SelectionSearch, EventRelay, 4691 4692 Utils, Translation, DIACRITICS, 4693 4694 SelectData, ArrayData, AjaxData, Tags, Tokenizer, 4695 MinimumInputLength, MaximumInputLength, MaximumSelectionLength, 4696 4697 Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll, 4698 AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect, 4699 4700 EnglishTranslation) { 4701 function Defaults () { 4702 this.reset(); 4703 } 4704 4705 Defaults.prototype.apply = function (options) { 4706 options = $.extend(true, {}, this.defaults, options); 4707 4708 if (options.dataAdapter == null) { 4709 if (options.ajax != null) { 4710 options.dataAdapter = AjaxData; 4711 } else if (options.data != null) { 4712 options.dataAdapter = ArrayData; 4713 } else { 4714 options.dataAdapter = SelectData; 4715 } 4716 4717 if (options.minimumInputLength > 0) { 4718 options.dataAdapter = Utils.Decorate( 4719 options.dataAdapter, 4720 MinimumInputLength 4721 ); 4722 } 4723 4724 if (options.maximumInputLength > 0) { 4725 options.dataAdapter = Utils.Decorate( 4726 options.dataAdapter, 4727 MaximumInputLength 4728 ); 4729 } 4730 4731 if (options.maximumSelectionLength > 0) { 4732 options.dataAdapter = Utils.Decorate( 4733 options.dataAdapter, 4734 MaximumSelectionLength 4735 ); 4736 } 4737 4738 if (options.tags) { 4739 options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags); 4740 } 4741 4742 if (options.tokenSeparators != null || options.tokenizer != null) { 4743 options.dataAdapter = Utils.Decorate( 4744 options.dataAdapter, 4745 Tokenizer 4746 ); 4747 } 4748 4749 if (options.query != null) { 4750 var Query = require(options.amdBase + 'compat/query'); 4751 4752 options.dataAdapter = Utils.Decorate( 4753 options.dataAdapter, 4754 Query 4755 ); 4756 } 4757 4758 if (options.initSelection != null) { 4759 var InitSelection = require(options.amdBase + 'compat/initSelection'); 4760 4761 options.dataAdapter = Utils.Decorate( 4762 options.dataAdapter, 4763 InitSelection 4764 ); 4765 } 4766 } 4767 4768 if (options.resultsAdapter == null) { 4769 options.resultsAdapter = ResultsList; 4770 4771 if (options.ajax != null) { 4772 options.resultsAdapter = Utils.Decorate( 4773 options.resultsAdapter, 4774 InfiniteScroll 4775 ); 4776 } 4777 4778 if (options.placeholder != null) { 4779 options.resultsAdapter = Utils.Decorate( 4780 options.resultsAdapter, 4781 HidePlaceholder 4782 ); 4783 } 4784 4785 if (options.selectOnClose) { 4786 options.resultsAdapter = Utils.Decorate( 4787 options.resultsAdapter, 4788 SelectOnClose 4789 ); 4790 } 4791 } 4792 4793 if (options.dropdownAdapter == null) { 4794 if (options.multiple) { 4795 options.dropdownAdapter = Dropdown; 4796 } else { 4797 var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch); 4798 4799 options.dropdownAdapter = SearchableDropdown; 4800 } 4801 4802 if (options.minimumResultsForSearch !== 0) { 4803 options.dropdownAdapter = Utils.Decorate( 4804 options.dropdownAdapter, 4805 MinimumResultsForSearch 4806 ); 4807 } 4808 4809 if (options.closeOnSelect) { 4810 options.dropdownAdapter = Utils.Decorate( 4811 options.dropdownAdapter, 4812 CloseOnSelect 4813 ); 4814 } 4815 4816 if ( 4817 options.dropdownCssClass != null || 4818 options.dropdownCss != null || 4819 options.adaptDropdownCssClass != null 4820 ) { 4821 var DropdownCSS = require(options.amdBase + 'compat/dropdownCss'); 4822 4823 options.dropdownAdapter = Utils.Decorate( 4824 options.dropdownAdapter, 4825 DropdownCSS 4826 ); 4827 } 4828 4829 options.dropdownAdapter = Utils.Decorate( 4830 options.dropdownAdapter, 4831 AttachBody 4832 ); 4833 } 4834 4835 if (options.selectionAdapter == null) { 4836 if (options.multiple) { 4837 options.selectionAdapter = MultipleSelection; 4838 } else { 4839 options.selectionAdapter = SingleSelection; 4840 } 4841 4842 // Add the placeholder mixin if a placeholder was specified 4843 if (options.placeholder != null) { 4844 options.selectionAdapter = Utils.Decorate( 4845 options.selectionAdapter, 4846 Placeholder 4847 ); 4848 } 4849 4850 if (options.allowClear) { 4851 options.selectionAdapter = Utils.Decorate( 4852 options.selectionAdapter, 4853 AllowClear 4854 ); 4855 } 4856 4857 if (options.multiple) { 4858 options.selectionAdapter = Utils.Decorate( 4859 options.selectionAdapter, 4860 SelectionSearch 4861 ); 4862 } 4863 4864 if ( 4865 options.containerCssClass != null || 4866 options.containerCss != null || 4867 options.adaptContainerCssClass != null 4868 ) { 4869 var ContainerCSS = require(options.amdBase + 'compat/containerCss'); 4870 4871 options.selectionAdapter = Utils.Decorate( 4872 options.selectionAdapter, 4873 ContainerCSS 4874 ); 4875 } 4876 4877 options.selectionAdapter = Utils.Decorate( 4878 options.selectionAdapter, 4879 EventRelay 4880 ); 4881 } 4882 4883 if (typeof options.language === 'string') { 4884 // Check if the language is specified with a region 4885 if (options.language.indexOf('-') > 0) { 4886 // Extract the region information if it is included 4887 var languageParts = options.language.split('-'); 4888 var baseLanguage = languageParts[0]; 4889 4890 options.language = [options.language, baseLanguage]; 4891 } else { 4892 options.language = [options.language]; 4893 } 4894 } 4895 4896 if (
vendor: 39,390 bytes, lines 4896-6400
4896Array.isArray(options.language)) { 4897 var languages = new Translation(); 4898 options.language.push('en'); 4899 4900 var languageNames = options.language; 4901 4902 for (var l = 0; l < languageNames.length; l++) { 4903 var name = languageNames[l]; 4904 var language = {}; 4905 4906 try { 4907 // Try to load it with the original name 4908 language = Translation.loadPath(name); 4909 } catch (e) { 4910 try { 4911 // If we couldn't load it, check if it wasn't the full path 4912 name = this.defaults.amdLanguageBase + name; 4913 language = Translation.loadPath(name); 4914 } catch (ex) { 4915 // The translation could not be loaded at all. Sometimes this is 4916 // because of a configuration problem, other times this can be 4917 // because of how Select2 helps load all possible translation files. 4918 if (options.debug && window.console && console.warn) { 4919 console.warn( 4920 'Select2: The language file for "' + name + '" could not be ' + 4921 'automatically loaded. A fallback will be used instead.' 4922 ); 4923 } 4924 4925 continue; 4926 } 4927 } 4928 4929 languages.extend(language); 4930 } 4931 4932 options.translations = languages; 4933 } else { 4934 var baseTranslation = Translation.loadPath( 4935 this.defaults.amdLanguageBase + 'en' 4936 ); 4937 var customTranslation = new Translation(options.language); 4938 4939 customTranslation.extend(baseTranslation); 4940 4941 options.translations = customTranslation; 4942 } 4943 4944 return options; 4945 }; 4946 4947 Defaults.prototype.reset = function () { 4948 function stripDiacritics (text) { 4949 // Used 'uni range + named function' from http://jsperf.com/diacritics/18 4950 function match(a) { 4951 return DIACRITICS[a] || a; 4952 } 4953 4954 return text.replace(/[^\u0000-\u007E]/g, match); 4955 } 4956 4957 function matcher (params, data) { 4958 // Always return the object if there is nothing to compare 4959 if ( params.term == null || params.term.toString().trim() === '' ) { 4960 return data; 4961 } 4962 4963 // Do a recursive check for options with children 4964 if (data.children && data.children.length > 0) { 4965 // Clone the data object if there are children 4966 // This is required as we modify the object to remove any non-matches 4967 var match = $.extend(true, {}, data); 4968 4969 // Check each child of the option 4970 for (var c = data.children.length - 1; c >= 0; c--) { 4971 var child = data.children[c]; 4972 4973 var matches = matcher(params, child); 4974 4975 // If there wasn't a match, remove the object in the array 4976 if (matches == null) { 4977 match.children.splice(c, 1); 4978 } 4979 } 4980 4981 // If any children matched, return the new object 4982 if (match.children.length > 0) { 4983 return match; 4984 } 4985 4986 // If there were no matching children, check just the plain object 4987 return matcher(params, match); 4988 } 4989 4990 var original = stripDiacritics(data.text).toUpperCase(); 4991 var term = stripDiacritics(params.term).toUpperCase(); 4992 4993 // Check if the text contains the term 4994 if (original.indexOf(term) > -1) { 4995 return data; 4996 } 4997 4998 // If it doesn't contain the term, don't return anything 4999 return null; 5000 } 5001 5002 this.defaults = { 5003 amdBase: './', 5004 amdLanguageBase: './i18n/', 5005 closeOnSelect: true, 5006 debug: false, 5007 dropdownAutoWidth: false, 5008 escapeMarkup: Utils.escapeMarkup, 5009 language: EnglishTranslation, 5010 matcher: matcher, 5011 minimumInputLength: 0, 5012 maximumInputLength: 0, 5013 maximumSelectionLength: 0, 5014 minimumResultsForSearch: 0, 5015 selectOnClose: false, 5016 sorter: function (data) { 5017 return data; 5018 }, 5019 templateResult: function (result) { 5020 return result.text; 5021 }, 5022 templateSelection: function (selection) { 5023 return selection.text; 5024 }, 5025 theme: 'default', 5026 width: 'resolve' 5027 }; 5028 }; 5029 5030 Defaults.prototype.set = function (key, value) { 5031 var camelKey = $.camelCase(key); 5032 5033 var data = {}; 5034 data[camelKey] = value; 5035 5036 var convertedData = Utils._convertData(data); 5037 5038 $.extend(this.defaults, convertedData); 5039 }; 5040 5041 var defaults = new Defaults(); 5042 5043 return defaults; 5044}); 5045 5046S2.define('select2/options',[ 5047 'require', 5048 'jquery', 5049 './defaults', 5050 './utils' 5051], function (require, $, Defaults, Utils) { 5052 function Options (options, $element) { 5053 this.options = options; 5054 5055 if ($element != null) { 5056 this.fromElement($element); 5057 } 5058 5059 this.options = Defaults.apply(this.options); 5060 5061 if ($element && $element.is('input')) { 5062 var InputCompat = require(this.get('amdBase') + 'compat/inputData'); 5063 5064 this.options.dataAdapter = Utils.Decorate( 5065 this.options.dataAdapter, 5066 InputCompat 5067 ); 5068 } 5069 } 5070 5071 Options.prototype.fromElement = function ($e) { 5072 var excludedData = ['select2']; 5073 5074 if (this.options.multiple == null) { 5075 this.options.multiple = $e.prop('multiple'); 5076 } 5077 5078 if (this.options.disabled == null) { 5079 this.options.disabled = $e.prop('disabled'); 5080 } 5081 5082 if (!this.options.required) { 5083 this.options.required = $e.prop('required'); 5084 } 5085 5086 if (this.options.language == null) { 5087 if ($e.prop('lang')) { 5088 this.options.language = $e.prop('lang').toLowerCase(); 5089 } else if ($e.closest('[lang]').prop('lang')) { 5090 this.options.language = $e.closest('[lang]').prop('lang'); 5091 } 5092 } 5093 5094 if (this.options.dir == null) { 5095 if ($e.prop('dir')) { 5096 this.options.dir = $e.prop('dir'); 5097 } else if ($e.closest('[dir]').prop('dir')) { 5098 this.options.dir = $e.closest('[dir]').prop('dir'); 5099 } else { 5100 this.options.dir = 'ltr'; 5101 } 5102 } 5103 5104 $e.prop('disabled', this.options.disabled); 5105 $e.prop('multiple', this.options.multiple); 5106 5107 if ($e.data('select2Tags')) { 5108 if (this.options.debug && window.console && console.warn) { 5109 console.warn( 5110 'Select2: The `data-select2-tags` attribute has been changed to ' + 5111 'use the `data-data` and `data-tags="true"` attributes and will be ' + 5112 'removed in future versions of Select2.' 5113 ); 5114 } 5115 5116 $e.data('data', $e.data('select2Tags')); 5117 $e.data('tags', true); 5118 } 5119 5120 if ($e.data('ajaxUrl')) { 5121 if (this.options.debug && window.console && console.warn) { 5122 console.warn( 5123 'Select2: The `data-ajax-url` attribute has been changed to ' + 5124 '`data-ajax--url` and support for the old attribute will be removed' + 5125 ' in future versions of Select2.' 5126 ); 5127 } 5128 5129 $e.attr('ajax--url', $e.data('ajaxUrl')); 5130 $e.data('ajax--url', $e.data('ajaxUrl')); 5131 } 5132 5133 var dataset = {}; 5134 5135 // Prefer the element's `dataset` attribute if it exists 5136 // jQuery 1.x does not correctly handle data attributes with multiple dashes 5137 if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) { 5138 dataset = $.extend(true, {}, $e[0].dataset, $e.data()); 5139 } else { 5140 dataset = $e.data(); 5141 } 5142 5143 var data = $.extend(true, {}, dataset); 5144 5145 data = Utils._convertData(data); 5146 5147 for (var key in data) { 5148 if ($.inArray(key, excludedData) > -1) { 5149 continue; 5150 } 5151 5152 if ($.isPlainObject(this.options[key])) { 5153 $.extend(this.options[key], data[key]); 5154 } else { 5155 this.options[key] = data[key]; 5156 } 5157 } 5158 5159 return this; 5160 }; 5161 5162 Options.prototype.get = function (key) { 5163 return this.options[key]; 5164 }; 5165 5166 Options.prototype.set = function (key, val) { 5167 this.options[key] = val; 5168 }; 5169 5170 return Options; 5171}); 5172 5173S2.define('select2/core',[ 5174 'jquery', 5175 './options', 5176 './utils', 5177 './keys' 5178], function ($, Options, Utils, KEYS) { 5179 var Select2 = function ($element, options) { 5180 if ($element.data('select2') != null) { 5181 $element.data('select2').destroy(); 5182 } 5183 5184 this.$element = $element; 5185 5186 this.id = this._generateId($element); 5187 5188 options = options || {}; 5189 5190 this.options = new Options(options, $element); 5191 5192 Select2.__super__.constructor.call(this); 5193 5194 // Set up the tabindex 5195 5196 var tabindex = $element.attr('tabindex') || 0; 5197 $element.data('old-tabindex', tabindex); 5198 $element.attr('tabindex', '-1'); 5199 5200 // Set up containers and adapters 5201 5202 var DataAdapter = this.options.get('dataAdapter'); 5203 this.dataAdapter = new DataAdapter($element, this.options); 5204 5205 var $container = this.render(); 5206 5207 this._placeContainer($container); 5208 5209 var SelectionAdapter = this.options.get('selectionAdapter'); 5210 this.selection = new SelectionAdapter($element, this.options); 5211 this.$selection = this.selection.render(); 5212 5213 this.selection.position(this.$selection, $container); 5214 5215 var DropdownAdapter = this.options.get('dropdownAdapter'); 5216 this.dropdown = new DropdownAdapter($element, this.options); 5217 this.$dropdown = this.dropdown.render(); 5218 5219 this.dropdown.position(this.$dropdown, $container); 5220 5221 var ResultsAdapter = this.options.get('resultsAdapter'); 5222 this.results = new ResultsAdapter($element, this.options, this.dataAdapter); 5223 this.$results = this.results.render(); 5224 5225 this.results.position(this.$results, this.$dropdown); 5226 5227 // Bind events 5228 5229 var self = this; 5230 5231 // Bind the container to all of the adapters 5232 this._bindAdapters(); 5233 5234 // Register any DOM event handlers 5235 this._registerDomEvents(); 5236 5237 // Register any internal event handlers 5238 this._registerDataEvents(); 5239 this._registerSelectionEvents(); 5240 this._registerDropdownEvents(); 5241 this._registerResultsEvents(); 5242 this._registerEvents(); 5243 5244 // Set the initial state 5245 this.dataAdapter.current(function (initialData) { 5246 self.trigger('selection:update', { 5247 data: initialData 5248 }); 5249 }); 5250 5251 // Hide the original select 5252 $element.addClass('select2-hidden-accessible'); 5253 $element.attr('aria-hidden', 'true'); 5254 5255 // Synchronize any monitored attributes 5256 this._syncAttributes(); 5257 5258 $element.data('select2', this); 5259 }; 5260 5261 Utils.Extend(Select2, Utils.Observable); 5262 5263 Select2.prototype._generateId = function ($element) { 5264 var id = ''; 5265 5266 if ($element.attr('id') != null) { 5267 id = $element.attr('id'); 5268 } else if ($element.attr('name') != null) { 5269 id = $element.attr('name') + '-' + Utils.generateChars(2); 5270 } else { 5271 id = Utils.generateChars(4); 5272 } 5273 5274 id = id.replace(/(:|\.|\[|\]|,)/g, ''); 5275 id = 'select2-' + id; 5276 5277 return id; 5278 }; 5279 5280 Select2.prototype._placeContainer = function ($container) { 5281 $container.insertAfter(this.$element); 5282 5283 var width = this._resolveWidth(this.$element, this.options.get('width')); 5284 5285 if (width != null) { 5286 $container.css('width', width); 5287 } 5288 }; 5289 5290 Select2.prototype._resolveWidth = function ($element, method) { 5291 var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i; 5292 5293 if (method == 'resolve') { 5294 var styleWidth = this._resolveWidth($element, 'style'); 5295 5296 if (styleWidth != null) { 5297 return styleWidth; 5298 } 5299 5300 return this._resolveWidth($element, 'element'); 5301 } 5302 5303 if (method == 'element') { 5304 var elementWidth = $element.outerWidth(false); 5305 5306 if (elementWidth <= 0) { 5307 return 'auto'; 5308 } 5309 5310 return elementWidth + 'px'; 5311 } 5312 5313 if (method == 'style') { 5314 var style = $element.attr('style'); 5315 5316 if (typeof(style) !== 'string') { 5317 return null; 5318 } 5319 5320 var attrs = style.split(';'); 5321 5322 for (var i = 0, l = attrs.length; i < l; i = i + 1) { 5323 var attr = attrs[i].replace(/\s/g, ''); 5324 var matches = attr.match(WIDTH); 5325 5326 if (matches !== null && matches.length >= 1) { 5327 return matches[1]; 5328 } 5329 } 5330 5331 return null; 5332 } 5333 5334 return method; 5335 }; 5336 5337 Select2.prototype._bindAdapters = function () { 5338 this.dataAdapter.bind(this, this.$container); 5339 this.selection.bind(this, this.$container); 5340 5341 this.dropdown.bind(this, this.$container); 5342 this.results.bind(this, this.$container); 5343 }; 5344 5345 Select2.prototype._registerDomEvents = function () { 5346 var self = this; 5347 5348 this.$element.on('change.select2', function () { 5349 self.dataAdapter.current(function (data) { 5350 self.trigger('selection:update', { 5351 data: data 5352 }); 5353 }); 5354 }); 5355 5356 this.$element.on('focus.select2', function (evt) { 5357 self.trigger('focus', evt); 5358 }); 5359 5360 this._syncA = Utils.bind(this._syncAttributes, this); 5361 this._syncS = Utils.bind(this._syncSubtree, this); 5362 5363 if (this.$element[0].attachEvent) { 5364 this.$element[0].attachEvent('onpropertychange', this._syncA); 5365 } 5366 5367 var observer = window.MutationObserver || 5368 window.WebKitMutationObserver || 5369 window.MozMutationObserver 5370 ; 5371 5372 if (observer != null) { 5373 this._observer = new observer(function (mutations) { 5374 $.each(mutations, self._syncA); 5375 $.each(mutations, self._syncS); 5376 }); 5377 this._observer.observe(this.$element[0], { 5378 attributes: true, 5379 childList: true, 5380 subtree: false 5381 }); 5382 } else if (this.$element[0].addEventListener) { 5383 this.$element[0].addEventListener( 5384 'DOMAttrModified', 5385 self._syncA, 5386 false 5387 ); 5388 this.$element[0].addEventListener( 5389 'DOMNodeInserted', 5390 self._syncS, 5391 false 5392 ); 5393 this.$element[0].addEventListener( 5394 'DOMNodeRemoved', 5395 self._syncS, 5396 false 5397 ); 5398 } 5399 }; 5400 5401 Select2.prototype._registerDataEvents = function () { 5402 var self = this; 5403 5404 this.dataAdapter.on('*', function (name, params) { 5405 self.trigger(name, params); 5406 }); 5407 }; 5408 5409 Select2.prototype._registerSelectionEvents = function () { 5410 var self = this; 5411 var nonRelayEvents = ['toggle', 'focus']; 5412 5413 this.selection.on('toggle', function () { 5414 self.toggleDropdown(); 5415 }); 5416 5417 this.selection.on('focus', function (params) { 5418 self.focus(params); 5419 }); 5420 5421 this.selection.on('*', function (name, params) { 5422 if ($.inArray(name, nonRelayEvents) !== -1) { 5423 return; 5424 } 5425 5426 self.trigger(name, params); 5427 }); 5428 }; 5429 5430 Select2.prototype._registerDropdownEvents = function () { 5431 var self = this; 5432 5433 this.dropdown.on('*', function (name, params) { 5434 self.trigger(name, params); 5435 }); 5436 }; 5437 5438 Select2.prototype._registerResultsEvents = function () { 5439 var self = this; 5440 5441 this.results.on('*', function (name, params) { 5442 self.trigger(name, params); 5443 }); 5444 }; 5445 5446 Select2.prototype._registerEvents = function () { 5447 var self = this; 5448 5449 this.on('open', function () { 5450 self.$container.addClass('select2-container--open'); 5451 }); 5452 5453 this.on('close', function () { 5454 self.$container.removeClass('select2-container--open'); 5455 }); 5456 5457 this.on('enable', function () { 5458 self.$container.removeClass('select2-container--disabled'); 5459 }); 5460 5461 this.on('disable', function () { 5462 self.$container.addClass('select2-container--disabled'); 5463 }); 5464 5465 this.on('blur', function () { 5466 self.$container.removeClass('select2-container--focus'); 5467 }); 5468 5469 this.on('query', function (params) { 5470 if (!self.isOpen()) { 5471 self.trigger('open', {}); 5472 } 5473 5474 this.dataAdapter.query(params, function (data) { 5475 self.trigger('results:all', { 5476 data: data, 5477 query: params 5478 }); 5479 }); 5480 }); 5481 5482 this.on('query:append', function (params) { 5483 this.dataAdapter.query(params, function (data) { 5484 self.trigger('results:append', { 5485 data: data, 5486 query: params 5487 }); 5488 }); 5489 }); 5490 5491 this.on('open', function(){ 5492 // Focus on the active element when opening dropdown. 5493 // Needs 1 ms delay because of other 1 ms setTimeouts when rendering. 5494 setTimeout(function(){ 5495 self.focusOnActiveElement(); 5496 }, 1); 5497 }); 5498 5499 $(document).on('keydown', function (evt) { 5500 var key = evt.which; 5501 if (self.isOpen()) { 5502 if (key === KEYS.ESC || (key === KEYS.UP && evt.altKey)) { 5503 self.close(); 5504 5505 evt.preventDefault(); 5506 } else if (key === KEYS.ENTER || key === KEYS.TAB) { 5507 self.trigger('results:select', {}); 5508 5509 evt.preventDefault(); 5510 } else if ((key === KEYS.SPACE && evt.ctrlKey)) { 5511 self.trigger('results:toggle', {}); 5512 5513 evt.preventDefault(); 5514 } else if (key === KEYS.UP) { 5515 self.trigger('results:previous', {}); 5516 5517 evt.preventDefault(); 5518 } else if (key === KEYS.DOWN) { 5519 self.trigger('results:next', {}); 5520 5521 evt.preventDefault(); 5522 } 5523 5524 var $searchField = self.$dropdown.find('.select2-search__field'); 5525 if (! $searchField.length) { 5526 $searchField = self.$container.find('.select2-search__field'); 5527 } 5528 5529 // Move the focus to the selected element on keyboard navigation. 5530 // Required for screen readers to work properly. 5531 if (key === KEYS.DOWN || key === KEYS.UP) { 5532 self.focusOnActiveElement(); 5533 } else { 5534 // Focus on the search if user starts typing. 5535 $searchField.trigger( 'focus' ); 5536 // Focus back to active selection when finished typing. 5537 // Small delay so typed character can be read by screen reader. 5538 setTimeout(function(){ 5539 self.focusOnActiveElement(); 5540 }, 1000); 5541 } 5542 } else if (self.hasFocus()) { 5543 if (key === KEYS.ENTER || key === KEYS.SPACE || 5544 key === KEYS.DOWN) { 5545 self.open(); 5546 evt.preventDefault(); 5547 } 5548 } 5549 }); 5550 }; 5551 5552 Select2.prototype.focusOnActiveElement = function () { 5553 // Don't mess with the focus on touchscreens because it causes havoc with on-screen keyboards. 5554 if (this.isOpen() && ! Utils.isTouchscreen()) { 5555 this.$results.find('li.select2-results__option--highlighted').trigger( 'focus' ); 5556 } 5557 }; 5558 5559 Select2.prototype._syncAttributes = function () { 5560 this.options.set('disabled', this.$element.prop('disabled')); 5561 5562 if (this.options.get('disabled')) { 5563 if (this.isOpen()) { 5564 this.close(); 5565 } 5566 5567 this.trigger('disable', {}); 5568 } else { 5569 this.trigger('enable', {}); 5570 } 5571 }; 5572 5573 Select2.prototype._syncSubtree = function (evt, mutations) { 5574 var changed = false; 5575 var self = this; 5576 5577 // Ignore any mutation events raised for elements that aren't options or 5578 // optgroups. This handles the case when the select element is destroyed 5579 if ( 5580 evt && evt.target && ( 5581 evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP' 5582 ) 5583 ) { 5584 return; 5585 } 5586 5587 if (!mutations) { 5588 // If mutation events aren't supported, then we can only assume that the 5589 // change affected the selections 5590 changed = true; 5591 } else if (mutations.addedNodes && mutations.addedNodes.length > 0) { 5592 for (var n = 0; n < mutations.addedNodes.length; n++) { 5593 var node = mutations.addedNodes[n]; 5594 5595 if (node.selected) { 5596 changed = true; 5597 } 5598 } 5599 } else if (mutations.removedNodes && mutations.removedNodes.length > 0) { 5600 changed = true; 5601 } 5602 5603 // Only re-pull the data if we think there is a change 5604 if (changed) { 5605 this.dataAdapter.current(function (currentData) { 5606 self.trigger('selection:update', { 5607 data: currentData 5608 }); 5609 }); 5610 } 5611 }; 5612 5613 /** 5614 * Override the trigger method to automatically trigger pre-events when 5615 * there are events that can be prevented. 5616 */ 5617 Select2.prototype.trigger = function (name, args) { 5618 var actualTrigger = Select2.__super__.trigger; 5619 var preTriggerMap = { 5620 'open': 'opening', 5621 'close': 'closing', 5622 'select': 'selecting', 5623 'unselect': 'unselecting' 5624 }; 5625 5626 if (args === undefined) { 5627 args = {}; 5628 } 5629 5630 if (name in preTriggerMap) { 5631 var preTriggerName = preTriggerMap[name]; 5632 var preTriggerArgs = { 5633 prevented: false, 5634 name: name, 5635 args: args 5636 }; 5637 5638 actualTrigger.call(this, preTriggerName, preTriggerArgs); 5639 5640 if (preTriggerArgs.prevented) { 5641 args.prevented = true; 5642 5643 return; 5644 } 5645 } 5646 5647 actualTrigger.call(this, name, args); 5648 }; 5649 5650 Select2.prototype.toggleDropdown = function () { 5651 if (this.options.get('disabled')) { 5652 return; 5653 } 5654 5655 if (this.isOpen()) { 5656 this.close(); 5657 } else { 5658 this.open(); 5659 } 5660 }; 5661 5662 Select2.prototype.open = function () { 5663 if (this.isOpen()) { 5664 return; 5665 } 5666 5667 this.trigger('query', {}); 5668 }; 5669 5670 Select2.prototype.close = function () { 5671 if (!this.isOpen()) { 5672 return; 5673 } 5674 5675 this.trigger('close', {}); 5676 }; 5677 5678 Select2.prototype.isOpen = function () { 5679 return this.$container.hasClass('select2-container--open'); 5680 }; 5681 5682 Select2.prototype.hasFocus = function () { 5683 return this.$container.hasClass('select2-container--focus'); 5684 }; 5685 5686 Select2.prototype.focus = function (data) { 5687 // No need to re-trigger focus events if we are already focused 5688 if (this.hasFocus()) { 5689 return; 5690 } 5691 5692 this.$container.addClass('select2-container--focus'); 5693 this.trigger('focus', {}); 5694 }; 5695 5696 Select2.prototype.enable = function (args) { 5697 if (this.options.get('debug') && window.console && console.warn) { 5698 console.warn( 5699 'Select2: The `select2("enable")` method has been deprecated and will' + 5700 ' be removed in later Select2 versions. Use $element.prop("disabled")' + 5701 ' instead.' 5702 ); 5703 } 5704 5705 if (args == null || args.length === 0) { 5706 args = [true]; 5707 } 5708 5709 var disabled = !args[0]; 5710 5711 this.$element.prop('disabled', disabled); 5712 }; 5713 5714 Select2.prototype.data = function () { 5715 if (this.options.get('debug') && 5716 arguments.length > 0 && window.console && console.warn) { 5717 console.warn( 5718 'Select2: Data can no longer be set using `select2("data")`. You ' + 5719 'should consider setting the value instead using `$element.val()`.' 5720 ); 5721 } 5722 5723 var data = []; 5724 5725 this.dataAdapter.current(function (currentData) { 5726 data = currentData; 5727 }); 5728 5729 return data; 5730 }; 5731 5732 Select2.prototype.val = function (args) { 5733 if (this.options.get('debug') && window.console && console.warn) { 5734 console.warn( 5735 'Select2: The `select2("val")` method has been deprecated and will be' + 5736 ' removed in later Select2 versions. Use $element.val() instead.' 5737 ); 5738 } 5739 5740 if (args == null || args.length === 0) { 5741 return this.$element.val(); 5742 } 5743 5744 var newVal = args[0]; 5745 5746 if (Array.isArray(newVal)) { 5747 newVal = $.map(newVal, function (obj) { 5748 return obj.toString(); 5749 }); 5750 } 5751 5752 this.$element.val(newVal).trigger('change'); 5753 }; 5754 5755 Select2.prototype.destroy = function () { 5756 this.$container.remove(); 5757 5758 if (this.$element[0].detachEvent) { 5759 this.$element[0].detachEvent('onpropertychange', this._syncA); 5760 } 5761 5762 if (this._observer != null) { 5763 this._observer.disconnect(); 5764 this._observer = null; 5765 } else if (this.$element[0].removeEventListener) { 5766 this.$element[0] 5767 .removeEventListener('DOMAttrModified', this._syncA, false); 5768 this.$element[0] 5769 .removeEventListener('DOMNodeInserted', this._syncS, false); 5770 this.$element[0] 5771 .removeEventListener('DOMNodeRemoved', this._syncS, false); 5772 } 5773 5774 this._syncA = null; 5775 this._syncS = null; 5776 5777 this.$element.off('.select2'); 5778 this.$element.attr('tabindex', this.$element.data('old-tabindex')); 5779 5780 this.$element.removeClass('select2-hidden-accessible'); 5781 this.$element.attr('aria-hidden', 'false'); 5782 this.$element.removeData('select2'); 5783 5784 this.dataAdapter.destroy(); 5785 this.selection.destroy(); 5786 this.dropdown.destroy(); 5787 this.results.destroy(); 5788 5789 this.dataAdapter = null; 5790 this.selection = null; 5791 this.dropdown = null; 5792 this.results = null; 5793 }; 5794 5795 Select2.prototype.render = function () { 5796 var $container = $( 5797 '<span class="select2 select2-container">' + 5798 '<span class="selection"></span>' + 5799 '<span class="dropdown-wrapper" aria-hidden="true"></span>' + 5800 '</span>' 5801 ); 5802 5803 $container.attr('dir', this.options.get('dir')); 5804 5805 this.$container = $container; 5806 5807 this.$container.addClass('select2-container--' + this.options.get('theme')); 5808 5809 $container.data('element', this.$element); 5810 5811 return $container; 5812 }; 5813 5814 return Select2; 5815}); 5816 5817S2.define('select2/compat/utils',[ 5818 'jquery' 5819], function ($) { 5820 function syncCssClasses ($dest, $src, adapter) { 5821 var classes, replacements = [], adapted; 5822 5823 classes = ( $dest.attr('class') || 0 == $dest.attr('class') ) ? $dest.attr('class').toString().trim() : ''; 5824 5825 if (classes) { 5826 classes = '' + classes; // for IE which returns object 5827 5828 $(classes.split(/\s+/)).each(function () { 5829 // Save all Select2 classes 5830 if (this.indexOf('select2-') === 0) { 5831 replacements.push(this); 5832 } 5833 }); 5834 } 5835 5836 classes = ( $src.attr('class') || 0 == $src.attr('class') ) ? $src.attr('class').toString().trim() : ''; 5837 5838 if (classes) { 5839 classes = '' + classes; // for IE which returns object 5840 5841 $(classes.split(/\s+/)).each(function () { 5842 // Only adapt non-Select2 classes 5843 if (this.indexOf('select2-') !== 0) { 5844 adapted = adapter(this); 5845 5846 if (adapted != null) { 5847 replacements.push(adapted); 5848 } 5849 } 5850 }); 5851 } 5852 5853 $dest.attr('class', replacements.join(' ')); 5854 } 5855 5856 return { 5857 syncCssClasses: syncCssClasses 5858 }; 5859}); 5860 5861S2.define('select2/compat/containerCss',[ 5862 'jquery', 5863 './utils' 5864], function ($, CompatUtils) { 5865 // No-op CSS adapter that discards all classes by default 5866 function _containerAdapter (clazz) { 5867 return null; 5868 } 5869 5870 function ContainerCSS () { } 5871 5872 ContainerCSS.prototype.render = function (decorated) { 5873 var $container = decorated.call(this); 5874 5875 var containerCssClass = this.options.get('containerCssClass') || ''; 5876 5877 if ('function' === typeof containerCssClass) { 5878 containerCssClass = containerCssClass(this.$element); 5879 } 5880 5881 var containerCssAdapter = this.options.get('adaptContainerCssClass'); 5882 containerCssAdapter = containerCssAdapter || _containerAdapter; 5883 5884 if (containerCssClass.indexOf(':all:') !== -1) { 5885 containerCssClass = containerCssClass.replace(':all:', ''); 5886 5887 var _cssAdapter = containerCssAdapter; 5888 5889 containerCssAdapter = function (clazz) { 5890 var adapted = _cssAdapter(clazz); 5891 5892 if (adapted != null) { 5893 // Append the old one along with the adapted one 5894 return adapted + ' ' + clazz; 5895 } 5896 5897 return clazz; 5898 }; 5899 } 5900 5901 var containerCss = this.options.get('containerCss') || {}; 5902 5903 if ('function' === typeof containerCss) { 5904 containerCss = containerCss(this.$element); 5905 } 5906 5907 CompatUtils.syncCssClasses($container, this.$element, containerCssAdapter); 5908 5909 $container.css(containerCss); 5910 $container.addClass(containerCssClass); 5911 5912 return $container; 5913 }; 5914 5915 return ContainerCSS; 5916}); 5917 5918S2.define('select2/compat/dropdownCss',[ 5919 'jquery', 5920 './utils' 5921], function ($, CompatUtils) { 5922 // No-op CSS adapter that discards all classes by default 5923 function _dropdownAdapter (clazz) { 5924 return null; 5925 } 5926 5927 function DropdownCSS () { } 5928 5929 DropdownCSS.prototype.render = function (decorated) { 5930 var $dropdown = decorated.call(this); 5931 5932 var dropdownCssClass = this.options.get('dropdownCssClass') || ''; 5933 5934 if ('function' === typeof dropdownCssClass) { 5935 dropdownCssClass = dropdownCssClass(this.$element); 5936 } 5937 5938 var dropdownCssAdapter = this.options.get('adaptDropdownCssClass'); 5939 dropdownCssAdapter = dropdownCssAdapter || _dropdownAdapter; 5940 5941 if (dropdownCssClass.indexOf(':all:') !== -1) { 5942 dropdownCssClass = dropdownCssClass.replace(':all:', ''); 5943 5944 var _cssAdapter = dropdownCssAdapter; 5945 5946 dropdownCssAdapter = function (clazz) { 5947 var adapted = _cssAdapter(clazz); 5948 5949 if (adapted != null) { 5950 // Append the old one along with the adapted one 5951 return adapted + ' ' + clazz; 5952 } 5953 5954 return clazz; 5955 }; 5956 } 5957 5958 var dropdownCss = this.options.get('dropdownCss') || {}; 5959 5960 if ('function' === typeof dropdownCss) { 5961 dropdownCss = dropdownCss(this.$element); 5962 } 5963 5964 CompatUtils.syncCssClasses($dropdown, this.$element, dropdownCssAdapter); 5965 5966 $dropdown.css(dropdownCss); 5967 $dropdown.addClass(dropdownCssClass); 5968 5969 return $dropdown; 5970 }; 5971 5972 return DropdownCSS; 5973}); 5974 5975S2.define('select2/compat/initSelection',[ 5976 'jquery' 5977], function ($) { 5978 function InitSelection (decorated, $element, options) { 5979 if (options.get('debug') && window.console && console.warn) { 5980 console.warn( 5981 'Select2: The `initSelection` option has been deprecated in favor' + 5982 ' of a custom data adapter that overrides the `current` method. ' + 5983 'This method is now called multiple times instead of a single ' + 5984 'time when the instance is initialized. Support will be removed ' + 5985 'for the `initSelection` option in future versions of Select2' 5986 ); 5987 } 5988 5989 this.initSelection = options.get('initSelection'); 5990 this._isInitialized = false; 5991 5992 decorated.call(this, $element, options); 5993 } 5994 5995 InitSelection.prototype.current = function (decorated, callback) { 5996 var self = this; 5997 5998 if (this._isInitialized) { 5999 decorated.call(this, callback); 6000 6001 return; 6002 } 6003 6004 this.initSelection.call(null, this.$element, function (data) { 6005 self._isInitialized = true; 6006 6007 if (!Array.isArray(data)) { 6008 data = [data]; 6009 } 6010 6011 callback(data); 6012 }); 6013 }; 6014 6015 return InitSelection; 6016}); 6017 6018S2.define('select2/compat/inputData',[ 6019 'jquery' 6020], function ($) { 6021 function InputData (decorated, $element, options) { 6022 this._currentData = []; 6023 this._valueSeparator = options.get('valueSeparator') || ','; 6024 6025 if ($element.prop('type') === 'hidden') { 6026 if (options.get('debug') && console && console.warn) { 6027 console.warn( 6028 'Select2: Using a hidden input with Select2 is no longer ' + 6029 'supported and may stop working in the future. It is recommended ' + 6030 'to use a `<select>` element instead.' 6031 ); 6032 } 6033 } 6034 6035 decorated.call(this, $element, options); 6036 } 6037 6038 InputData.prototype.current = function (_, callback) { 6039 function getSelected (data, selectedIds) { 6040 var selected = []; 6041 6042 if (data.selected || $.inArray(data.id, selectedIds) !== -1) { 6043 data.selected = true; 6044 selected.push(data); 6045 } else { 6046 data.selected = false; 6047 } 6048 6049 if (data.children) { 6050 selected.push.apply(selected, getSelected(data.children, selectedIds)); 6051 } 6052 6053 return selected; 6054 } 6055 6056 var selected = []; 6057 6058 for (var d = 0; d < this._currentData.length; d++) { 6059 var data = this._currentData[d]; 6060 6061 selected.push.apply( 6062 selected, 6063 getSelected( 6064 data, 6065 this.$element.val().split( 6066 this._valueSeparator 6067 ) 6068 ) 6069 ); 6070 } 6071 6072 callback(selected); 6073 }; 6074 6075 InputData.prototype.select = function (_, data) { 6076 if (!this.options.get('multiple')) { 6077 this.current(function (allData) { 6078 $.map(allData, function (data) { 6079 data.selected = false; 6080 }); 6081 }); 6082 6083 this.$element.val(data.id); 6084 this.$element.trigger('change'); 6085 } else { 6086 var value = this.$element.val(); 6087 value += this._valueSeparator + data.id; 6088 6089 this.$element.val(value); 6090 this.$element.trigger('change'); 6091 } 6092 }; 6093 6094 InputData.prototype.unselect = function (_, data) { 6095 var self = this; 6096 6097 data.selected = false; 6098 6099 this.current(function (allData) { 6100 var values = []; 6101 6102 for (var d = 0; d < allData.length; d++) { 6103 var item = allData[d]; 6104 6105 if (data.id == item.id) { 6106 continue; 6107 } 6108 6109 values.push(item.id); 6110 } 6111 6112 self.$element.val(values.join(self._valueSeparator)); 6113 self.$element.trigger('change'); 6114 }); 6115 }; 6116 6117 InputData.prototype.query = function (_, params, callback) { 6118 var results = []; 6119 6120 for (var d = 0; d < this._currentData.length; d++) { 6121 var data = this._currentData[d]; 6122 6123 var matches = this.matches(params, data); 6124 6125 if (matches !== null) { 6126 results.push(matches); 6127 } 6128 } 6129 6130 callback({ 6131 results: results 6132 }); 6133 }; 6134 6135 InputData.prototype.addOptions = function (_, $options) { 6136 var options = $.map($options, function ($option) { 6137 return $.data($option[0], 'data'); 6138 }); 6139 6140 this._currentData.push.apply(this._currentData, options); 6141 }; 6142 6143 return InputData; 6144}); 6145 6146S2.define('select2/compat/matcher',[ 6147 'jquery' 6148], function ($) { 6149 function oldMatcher (matcher) { 6150 function wrappedMatcher (params, data) { 6151 var match = $.extend(true, {}, data); 6152 6153 if ( params.term == null || params.term.trim() === '' ) { 6154 return match; 6155 } 6156 6157 if (data.children) { 6158 for (var c = data.children.length - 1; c >= 0; c--) { 6159 var child = data.children[c]; 6160 6161 // Check if the child object matches 6162 // The old matcher returned a boolean true or false 6163 var doesMatch = matcher(params.term, child.text, child); 6164 6165 // If the child didn't match, pop it off 6166 if (!doesMatch) { 6167 match.children.splice(c, 1); 6168 } 6169 } 6170 6171 if (match.children.length > 0) { 6172 return match; 6173 } 6174 } 6175 6176 if (matcher(params.term, data.text, data)) { 6177 return match; 6178 } 6179 6180 return null; 6181 } 6182 6183 return wrappedMatcher; 6184 } 6185 6186 return oldMatcher; 6187}); 6188 6189S2.define('select2/compat/query',[ 6190 6191], function () { 6192 function Query (decorated, $element, options) { 6193 if (options.get('debug') && window.console && console.warn) { 6194 console.warn( 6195 'Select2: The `query` option has been deprecated in favor of a ' + 6196 'custom data adapter that overrides the `query` method. Support ' + 6197 'will be removed for the `query` option in future versions of ' + 6198 'Select2.' 6199 ); 6200 } 6201 6202 decorated.call(this, $element, options); 6203 } 6204 6205 Query.prototype.query = function (_, params, callback) { 6206 params.callback = callback; 6207 6208 var query = this.options.get('query'); 6209 6210 query.call(null, params); 6211 }; 6212 6213 return Query; 6214}); 6215 6216S2.define('select2/dropdown/attachContainer',[ 6217 6218], function () { 6219 function AttachContainer (decorated, $element, options) { 6220 decorated.call(this, $element, options); 6221 } 6222 6223 AttachContainer.prototype.position = 6224 function (decorated, $dropdown, $container) { 6225 var $dropdownContainer = $container.find('.dropdown-wrapper'); 6226 $dropdownContainer.append($dropdown); 6227 6228 $dropdown.addClass('select2-dropdown--below'); 6229 $container.addClass('select2-container--below'); 6230 }; 6231 6232 return AttachContainer; 6233}); 6234 6235S2.define('select2/dropdown/stopPropagation',[ 6236 6237], function () { 6238 function StopPropagation () { } 6239 6240 StopPropagation.prototype.bind = function (decorated, container, $container) { 6241 decorated.call(this, container, $container); 6242 6243 var stoppedEvents = [ 6244 'blur', 6245 'change', 6246 'click', 6247 'dblclick', 6248 'focus', 6249 'focusin', 6250 'focusout', 6251 'input', 6252 'keydown', 6253 'keyup', 6254 'keypress', 6255 'mousedown', 6256 'mouseenter', 6257 'mouseleave', 6258 'mousemove', 6259 'mouseover', 6260 'mouseup', 6261 'search', 6262 'touchend', 6263 'touchstart' 6264 ]; 6265 6266 this.$dropdown.on(stoppedEvents.join(' '), function (evt) { 6267 evt.stopPropagation(); 6268 }); 6269 }; 6270 6271 return StopPropagation; 6272}); 6273 6274S2.define('select2/selection/stopPropagation',[ 6275 6276], function () { 6277 function StopPropagation () { } 6278 6279 StopPropagation.prototype.bind = function (decorated, container, $container) { 6280 decorated.call(this, container, $container); 6281 6282 var stoppedEvents = [ 6283 'blur', 6284 'change', 6285 'click', 6286 'dblclick', 6287 'focus', 6288 'focusin', 6289 'focusout', 6290 'input', 6291 'keydown', 6292 'keyup', 6293 'keypress', 6294 'mousedown', 6295 'mouseenter', 6296 'mouseleave', 6297 'mousemove', 6298 'mouseover', 6299 'mouseup', 6300 'search', 6301 'touchend', 6302 'touchstart' 6303 ]; 6304 6305 this.$selection.on(stoppedEvents.join(' '), function (evt) { 6306 evt.stopPropagation(); 6307 }); 6308 }; 6309 6310 return StopPropagation; 6311}); 6312 6313/*! 6314 * jQuery Mousewheel 3.1.13 6315 * 6316 * Copyright jQuery Foundation and other contributors 6317 * Released under the MIT license 6318 * http://jquery.org/license 6319 */ 6320 6321(function (factory) { 6322 if ( typeof S2.define === 'function' && S2.define.amd ) { 6323 // AMD. Register as an anonymous module. 6324 S2.define('jquery-mousewheel',['jquery'], factory); 6325 } else if (typeof exports === 'object') { 6326 // Node/CommonJS style for Browserify 6327 module.exports = factory; 6328 } else { 6329 // Browser globals 6330 factory(jQuery); 6331 } 6332}(function ($) { 6333 6334 var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'], 6335 toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ? 6336 ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'], 6337 slice = Array.prototype.slice, 6338 nullLowestDeltaTimeout, lowestDelta; 6339 6340 if ( $.event.fixHooks ) { 6341 for ( var i = toFix.length; i; ) { 6342 $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks; 6343 } 6344 } 6345 6346 var special = $.event.special.mousewheel = { 6347 version: '3.1.12', 6348 6349 setup: function() { 6350 if ( this.addEventListener ) { 6351 for ( var i = toBind.length; i; ) { 6352 this.addEventListener( toBind[--i], handler, false ); 6353 } 6354 } else { 6355 this.onmousewheel = handler; 6356 } 6357 // Store the line height and page height for this particular element 6358 $.data(this, 'mousewheel-line-height', special.getLineHeight(this)); 6359 $.data(this, 'mousewheel-page-height', special.getPageHeight(this)); 6360 }, 6361 6362 teardown: function() { 6363 if ( this.removeEventListener ) { 6364 for ( var i = toBind.length; i; ) { 6365 this.removeEventListener( toBind[--i], handler, false ); 6366 } 6367 } else { 6368 this.onmousewheel = null; 6369 } 6370 // Clean up the data we added to the element 6371 $.removeData(this, 'mousewheel-line-height'); 6372 $.removeData(this, 'mousewheel-page-height'); 6373 }, 6374 6375 getLineHeight: function(elem) { 6376 var $elem = $(elem), 6377 $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent'](); 6378 if (!$parent.length) { 6379 $parent = $('body'); 6380 } 6381 return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16; 6382 }, 6383 6384 getPageHeight: function(elem) { 6385 return $(elem).height(); 6386 }, 6387 6388 settings: { 6389 adjustOldDeltas: true, // see shouldAdjustOldDeltas() below 6390 normalizeOffset: true // calls getBoundingClientRect for each event 6391 } 6392 }; 6393 6394 $.fn.extend({ 6395 mousewheel: function(fn) { 6396 return fn ? this.on('mousewheel', fn) : this.trigger('mousewheel'); 6397 }, 6398 6399 unmousewheel: function(fn) { 6400 return this.off
vendor: 7,657 bytes, lines 6400-6619
6400('mousewheel', fn); 6401 } 6402 }); 6403 6404 6405 function handler(event) { 6406 var orgEvent = event || window.event, 6407 args = slice.call(arguments, 1), 6408 delta = 0, 6409 deltaX = 0, 6410 deltaY = 0, 6411 absDelta = 0, 6412 offsetX = 0, 6413 offsetY = 0; 6414 event = $.event.fix(orgEvent); 6415 event.type = 'mousewheel'; 6416 6417 // Old school scrollwheel delta 6418 if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; } 6419 if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; } 6420 if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; } 6421 if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; } 6422 6423 // Firefox < 17 horizontal scrolling related to DOMMouseScroll event 6424 if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { 6425 deltaX = deltaY * -1; 6426 deltaY = 0; 6427 } 6428 6429 // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy 6430 delta = deltaY === 0 ? deltaX : deltaY; 6431 6432 // New school wheel delta (wheel event) 6433 if ( 'deltaY' in orgEvent ) { 6434 deltaY = orgEvent.deltaY * -1; 6435 delta = deltaY; 6436 } 6437 if ( 'deltaX' in orgEvent ) { 6438 deltaX = orgEvent.deltaX; 6439 if ( deltaY === 0 ) { delta = deltaX * -1; } 6440 } 6441 6442 // No change actually happened, no reason to go any further 6443 if ( deltaY === 0 && deltaX === 0 ) { return; } 6444 6445 // Need to convert lines and pages to pixels if we aren't already in pixels 6446 // There are three delta modes: 6447 // * deltaMode 0 is by pixels, nothing to do 6448 // * deltaMode 1 is by lines 6449 // * deltaMode 2 is by pages 6450 if ( orgEvent.deltaMode === 1 ) { 6451 var lineHeight = $.data(this, 'mousewheel-line-height'); 6452 delta *= lineHeight; 6453 deltaY *= lineHeight; 6454 deltaX *= lineHeight; 6455 } else if ( orgEvent.deltaMode === 2 ) { 6456 var pageHeight = $.data(this, 'mousewheel-page-height'); 6457 delta *= pageHeight; 6458 deltaY *= pageHeight; 6459 deltaX *= pageHeight; 6460 } 6461 6462 // Store lowest absolute delta to normalize the delta values 6463 absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) ); 6464 6465 if ( !lowestDelta || absDelta < lowestDelta ) { 6466 lowestDelta = absDelta; 6467 6468 // Adjust older deltas if necessary 6469 if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) { 6470 lowestDelta /= 40; 6471 } 6472 } 6473 6474 // Adjust older deltas if necessary 6475 if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) { 6476 // Divide all the things by 40! 6477 delta /= 40; 6478 deltaX /= 40; 6479 deltaY /= 40; 6480 } 6481 6482 // Get a whole, normalized value for the deltas 6483 delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta); 6484 deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta); 6485 deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta); 6486 6487 // Normalise offsetX and offsetY properties 6488 if ( special.settings.normalizeOffset && this.getBoundingClientRect ) { 6489 var boundingRect = this.getBoundingClientRect(); 6490 offsetX = event.clientX - boundingRect.left; 6491 offsetY = event.clientY - boundingRect.top; 6492 } 6493 6494 // Add information to the event object 6495 event.deltaX = deltaX; 6496 event.deltaY = deltaY; 6497 event.deltaFactor = lowestDelta; 6498 event.offsetX = offsetX; 6499 event.offsetY = offsetY; 6500 // Go ahead and set deltaMode to 0 since we converted to pixels 6501 // Although this is a little odd since we overwrite the deltaX/Y 6502 // properties with normalized deltas. 6503 event.deltaMode = 0; 6504 6505 // Add event and delta to the front of the arguments 6506 args.unshift(event, delta, deltaX, deltaY); 6507 6508 // Clearout lowestDelta after sometime to better 6509 // handle multiple device types that give different 6510 // a different lowestDelta 6511 // Ex: trackpad = 3 and mouse wheel = 120 6512 if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); } 6513 nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200); 6514 6515 return ($.event.dispatch || $.event.handle).apply(this, args); 6516 } 6517 6518 function nullLowestDelta() { 6519 lowestDelta = null; 6520 } 6521 6522 function shouldAdjustOldDeltas(orgEvent, absDelta) { 6523 // If this is an older event and the delta is divisable by 120, 6524 // then we are assuming that the browser is treating this as an 6525 // older mouse wheel event and that we should divide the deltas 6526 // by 40 to try and get a more usable deltaFactor. 6527 // Side note, this actually impacts the reported scroll distance 6528 // in older browsers and can cause scrolling to be slower than native. 6529 // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false. 6530 return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0; 6531 } 6532 6533})); 6534 6535S2.define('jquery.select2',[ 6536 'jquery', 6537 'jquery-mousewheel', 6538 6539 './select2/core', 6540 './select2/defaults' 6541], function ($, _, Select2, Defaults) { 6542 if ($.fn.selectWoo == null) { 6543 // All methods that should return the element 6544 var thisMethods = ['open', 'close', 'destroy']; 6545 6546 $.fn.selectWoo = function (options) { 6547 options = options || {}; 6548 6549 if (typeof options === 'object') { 6550 this.each(function () { 6551 var instanceOptions = $.extend(true, {}, options); 6552 6553 var instance = new Select2($(this), instanceOptions); 6554 }); 6555 6556 return this; 6557 } else if (typeof options === 'string') { 6558 var ret; 6559 var args = Array.prototype.slice.call(arguments, 1); 6560 6561 this.each(function () { 6562 var instance = $(this).data('select2'); 6563 6564 if (instance == null && window.console && console.error) { 6565 console.error( 6566 'The select2(\'' + options + '\') method was called on an ' + 6567 'element that is not using Select2.' 6568 ); 6569 } 6570 6571 ret = instance[options].apply(instance, args); 6572 }); 6573 6574 // Check if we should be returning `this` 6575 if ($.inArray(options, thisMethods) > -1) { 6576 return this; 6577 } 6578 6579 return ret; 6580 } else { 6581 throw new Error('Invalid arguments for Select2: ' + options); 6582 } 6583 }; 6584 } 6585 6586 if ($.fn.select2 != null && $.fn.select2.defaults != null) { 6587 $.fn.selectWoo.defaults = $.fn.select2.defaults; 6588 } 6589 6590 if ($.fn.selectWoo.defaults == null) { 6591 $.fn.selectWoo.defaults = Defaults; 6592 } 6593 6594 // Also register selectWoo under select2 if select2 is not already present. 6595 $.fn.select2 = $.fn.select2 || $.fn.selectWoo; 6596 6597 return Select2; 6598}); 6599 6600 // Return the AMD loader configuration so it can be used outside of this file 6601 return { 6602 define: S2.define, 6603 require: S2.require 6604 }; 6605}()); 6606 6607 // Autoload the jQuery bindings 6608 // We know that all of the modules exist above this, so we're safe 6609 var select2 = S2.require('jquery.select2'); 6610 6611 // Hold the AMD module references on the jQuery function that was just loaded 6612 // This allows Select2 to use the internal loader outside of this file, such 6613 // as in the language files. 6614 jQuery.fn.select2.amd = S2; 6615 jQuery.fn.selectWoo.amd = S2; 6616 6617 // Return the Select2 instance for anyone who is importing it. 6618 return select2; 6619}));
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.