PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.9.1
Secure Custom Fields v6.9.1
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / assets / inc / select2 / 3 / select2.min.js
secure-custom-fields / assets / inc / select2 / 3 Last commit date
index.php 1 year ago select2-spinner.gif 1 year ago select2.css 1 year ago select2.js 1 year ago select2.min.js 1 year ago select2.png 1 year ago select2x2.png 1 year ago
select2.min.js
4528 lines
1 /*
2 Copyright 2014 Igor Vaynberg
3
4 Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014
5
6 This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
7 General Public License version 2 (the "GPL License"). You may choose either license to govern your
8 use of this software only upon the condition that you accept all of the terms of either the Apache
9 License or the GPL License.
10
11 You may obtain a copy of the Apache License and the GPL License at:
12
13 http://www.apache.org/licenses/LICENSE-2.0
14 http://www.gnu.org/licenses/gpl-2.0.html
15
16 Unless required by applicable law or agreed to in writing, software distributed under the Apache License
17 or the GPL Licesnse is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
18 either express or implied. See the Apache License and the GPL License for the specific language governing
19 permissions and limitations under the Apache License and the GPL License.
20 */
21 ! ( function ( a ) {
22 'undefined' == typeof a.fn.each2 &&
23 a.extend( a.fn, {
24 each2: function ( b ) {
25 for (
26 var c = a( [ 0 ] ), d = -1, e = this.length;
27 ++d < e &&
28 ( c.context = c[ 0 ] = this[ d ] ) &&
29 b.call( c[ 0 ], d, c ) !== ! 1;
30
31 );
32 return this;
33 },
34 } );
35 } )( jQuery ),
36 ( function ( a, b ) {
37 'use strict';
38 function n( b ) {
39 var c = a( document.createTextNode( '' ) );
40 b.before( c ), c.before( b ), c.remove();
41 }
42 function o( a ) {
43 function b( a ) {
44 return m[ a ] || a;
45 }
46 return a.replace( /[^\u0000-\u007E]/g, b );
47 }
48 function p( a, b ) {
49 for ( var c = 0, d = b.length; d > c; c += 1 )
50 if ( r( a, b[ c ] ) ) return c;
51 return -1;
52 }
53 function q() {
54 var b = a( l );
55 b.appendTo( document.body );
56 var c = {
57 width: b.width() - b[ 0 ].clientWidth,
58 height: b.height() - b[ 0 ].clientHeight,
59 };
60 return b.remove(), c;
61 }
62 function r( a, c ) {
63 return a === c
64 ? ! 0
65 : a === b || c === b
66 ? ! 1
67 : null === a || null === c
68 ? ! 1
69 : a.constructor === String
70 ? a + '' == c + ''
71 : c.constructor === String
72 ? c + '' == a + ''
73 : ! 1;
74 }
75 function s( a, b, c ) {
76 var d, e, f;
77 if ( null === a || a.length < 1 ) return [];
78 for ( d = a.split( b ), e = 0, f = d.length; f > e; e += 1 )
79 d[ e ] = c( d[ e ] );
80 return d;
81 }
82 function t( a ) {
83 return a.outerWidth( ! 1 ) - a.width();
84 }
85 function u( c ) {
86 var d = 'keyup-change-value';
87 c.on( 'keydown', function () {
88 a.data( c, d ) === b && a.data( c, d, c.val() );
89 } ),
90 c.on( 'keyup', function () {
91 var e = a.data( c, d );
92 e !== b &&
93 c.val() !== e &&
94 ( a.removeData( c, d ), c.trigger( 'keyup-change' ) );
95 } );
96 }
97 function v( c ) {
98 c.on( 'mousemove', function ( c ) {
99 var d = h;
100 ( d === b || d.x !== c.pageX || d.y !== c.pageY ) &&
101 a( c.target ).trigger( 'mousemove-filtered', c );
102 } );
103 }
104 function w( a, c, d ) {
105 d = d || b;
106 var e;
107 return function () {
108 var b = arguments;
109 window.clearTimeout( e ),
110 ( e = window.setTimeout( function () {
111 c.apply( d, b );
112 }, a ) );
113 };
114 }
115 function x( a, b ) {
116 var c = w( a, function ( a ) {
117 b.trigger( 'scroll-debounced', a );
118 } );
119 b.on( 'scroll', function ( a ) {
120 p( a.target, b.get() ) >= 0 && c( a );
121 } );
122 }
123 function y( a ) {
124 a[ 0 ] !== document.activeElement &&
125 window.setTimeout( function () {
126 var d,
127 b = a[ 0 ],
128 c = a.val().length;
129 a.focus();
130 var e = b.offsetWidth > 0 || b.offsetHeight > 0;
131 e &&
132 b === document.activeElement &&
133 ( b.setSelectionRange
134 ? b.setSelectionRange( c, c )
135 : b.createTextRange &&
136 ( ( d = b.createTextRange() ),
137 d.collapse( ! 1 ),
138 d.select() ) );
139 }, 0 );
140 }
141 function z( b ) {
142 b = a( b )[ 0 ];
143 var c = 0,
144 d = 0;
145 if ( 'selectionStart' in b )
146 ( c = b.selectionStart ), ( d = b.selectionEnd - c );
147 else if ( 'selection' in document ) {
148 b.focus();
149 var e = document.selection.createRange();
150 ( d = document.selection.createRange().text.length ),
151 e.moveStart( 'character', -b.value.length ),
152 ( c = e.text.length - d );
153 }
154 return { offset: c, length: d };
155 }
156 function A( a ) {
157 a.preventDefault(), a.stopPropagation();
158 }
159 function B( a ) {
160 a.preventDefault(), a.stopImmediatePropagation();
161 }
162 function C( b ) {
163 if ( ! g ) {
164 var c =
165 b[ 0 ].currentStyle ||
166 window.getComputedStyle( b[ 0 ], null );
167 ( g = a( document.createElement( 'div' ) ).css( {
168 position: 'absolute',
169 left: '-10000px',
170 top: '-10000px',
171 display: 'none',
172 fontSize: c.fontSize,
173 fontFamily: c.fontFamily,
174 fontStyle: c.fontStyle,
175 fontWeight: c.fontWeight,
176 letterSpacing: c.letterSpacing,
177 textTransform: c.textTransform,
178 whiteSpace: 'nowrap',
179 } ) ),
180 g.attr( 'class', 'select2-sizer' ),
181 a( document.body ).append( g );
182 }
183 return g.text( b.val() ), g.width();
184 }
185 function D( b, c, d ) {
186 var e,
187 g,
188 f = [];
189 ( e = a.trim( b.attr( 'class' ) ) ),
190 e &&
191 ( ( e = '' + e ),
192 a( e.split( /\s+/ ) ).each2( function () {
193 0 === this.indexOf( 'select2-' ) && f.push( this );
194 } ) ),
195 ( e = a.trim( c.attr( 'class' ) ) ),
196 e &&
197 ( ( e = '' + e ),
198 a( e.split( /\s+/ ) ).each2( function () {
199 0 !== this.indexOf( 'select2-' ) &&
200 ( ( g = d( this ) ), g && f.push( g ) );
201 } ) ),
202 b.attr( 'class', f.join( ' ' ) );
203 }
204 function E( a, b, c, d ) {
205 var e = o( a.toUpperCase() ).indexOf( o( b.toUpperCase() ) ),
206 f = b.length;
207 return 0 > e
208 ? ( c.push( d( a ) ), void 0 )
209 : ( c.push( d( a.substring( 0, e ) ) ),
210 c.push( "<span class='select2-match'>" ),
211 c.push( d( a.substring( e, e + f ) ) ),
212 c.push( '</span>' ),
213 c.push( d( a.substring( e + f, a.length ) ) ),
214 void 0 );
215 }
216 function F( a ) {
217 var b = {
218 '\\': '&#92;',
219 '&': '&amp;',
220 '<': '&lt;',
221 '>': '&gt;',
222 '"': '&quot;',
223 "'": '&#39;',
224 '/': '&#47;',
225 };
226 return String( a ).replace( /[&<>"'\/\\]/g, function ( a ) {
227 return b[ a ];
228 } );
229 }
230 function G( c ) {
231 var d,
232 e = null,
233 f = c.quietMillis || 100,
234 g = c.url,
235 h = this;
236 return function ( i ) {
237 window.clearTimeout( d ),
238 ( d = window.setTimeout( function () {
239 var d = c.data,
240 f = g,
241 j =
242 c.transport ||
243 a.fn.select2.ajaxDefaults.transport,
244 k = {
245 type: c.type || 'GET',
246 cache: c.cache || ! 1,
247 jsonpCallback: c.jsonpCallback || b,
248 dataType: c.dataType || 'json',
249 },
250 l = a.extend(
251 {},
252 a.fn.select2.ajaxDefaults.params,
253 k
254 );
255 ( d = d
256 ? d.call( h, i.term, i.page, i.context )
257 : null ),
258 ( f =
259 'function' == typeof f
260 ? f.call( h, i.term, i.page, i.context )
261 : f ),
262 e && 'function' == typeof e.abort && e.abort(),
263 c.params &&
264 ( a.isFunction( c.params )
265 ? a.extend( l, c.params.call( h ) )
266 : a.extend( l, c.params ) ),
267 a.extend( l, {
268 url: f,
269 dataType: c.dataType,
270 data: d,
271 success: function ( a ) {
272 var b = c.results( a, i.page, i );
273 i.callback( b );
274 },
275 error: function ( a, b, c ) {
276 var d = {
277 hasError: ! 0,
278 jqXHR: a,
279 textStatus: b,
280 errorThrown: c,
281 };
282 i.callback( d );
283 },
284 } ),
285 ( e = j.call( h, l ) );
286 }, f ) );
287 };
288 }
289 function H( b ) {
290 var d,
291 e,
292 c = b,
293 f = function ( a ) {
294 return '' + a.text;
295 };
296 a.isArray( c ) && ( ( e = c ), ( c = { results: e } ) ),
297 a.isFunction( c ) === ! 1 &&
298 ( ( e = c ),
299 ( c = function () {
300 return e;
301 } ) );
302 var g = c();
303 return (
304 g.text &&
305 ( ( f = g.text ),
306 a.isFunction( f ) ||
307 ( ( d = g.text ),
308 ( f = function ( a ) {
309 return a[ d ];
310 } ) ) ),
311 function ( b ) {
312 var g,
313 d = b.term,
314 e = { results: [] };
315 return '' === d
316 ? ( b.callback( c() ), void 0 )
317 : ( ( g = function ( c, e ) {
318 var h, i;
319 if ( ( ( c = c[ 0 ] ), c.children ) ) {
320 h = {};
321 for ( i in c )
322 c.hasOwnProperty( i ) &&
323 ( h[ i ] = c[ i ] );
324 ( h.children = [] ),
325 a( c.children ).each2( function (
326 a,
327 b
328 ) {
329 g( b, h.children );
330 } ),
331 ( h.children.length ||
332 b.matcher( d, f( h ), c ) ) &&
333 e.push( h );
334 } else b.matcher( d, f( c ), c ) && e.push( c );
335 } ),
336 a( c().results ).each2( function ( a, b ) {
337 g( b, e.results );
338 } ),
339 b.callback( e ),
340 void 0 );
341 }
342 );
343 }
344 function I( c ) {
345 var d = a.isFunction( c );
346 return function ( e ) {
347 var f = e.term,
348 g = { results: [] },
349 h = d ? c( e ) : c;
350 a.isArray( h ) &&
351 ( a( h ).each( function () {
352 var a = this.text !== b,
353 c = a ? this.text : this;
354 ( '' === f || e.matcher( f, c ) ) &&
355 g.results.push(
356 a ? this : { id: this, text: this }
357 );
358 } ),
359 e.callback( g ) );
360 };
361 }
362 function J( b, c ) {
363 if ( a.isFunction( b ) ) return ! 0;
364 if ( ! b ) return ! 1;
365 if ( 'string' == typeof b ) return ! 0;
366 throw new Error(
367 c + ' must be a string, function, or falsy value'
368 );
369 }
370 function K( b, c ) {
371 if ( a.isFunction( b ) ) {
372 var d = Array.prototype.slice.call( arguments, 2 );
373 return b.apply( c, d );
374 }
375 return b;
376 }
377 function L( b ) {
378 var c = 0;
379 return (
380 a.each( b, function ( a, b ) {
381 b.children ? ( c += L( b.children ) ) : c++;
382 } ),
383 c
384 );
385 }
386 function M( a, c, d, e ) {
387 var h,
388 i,
389 j,
390 k,
391 l,
392 f = a,
393 g = ! 1;
394 if (
395 ! e.createSearchChoice ||
396 ! e.tokenSeparators ||
397 e.tokenSeparators.length < 1
398 )
399 return b;
400 for (;;) {
401 for (
402 i = -1, j = 0, k = e.tokenSeparators.length;
403 k > j &&
404 ( ( l = e.tokenSeparators[ j ] ),
405 ( i = a.indexOf( l ) ),
406 ! ( i >= 0 ) );
407 j++
408 );
409 if ( 0 > i ) break;
410 if (
411 ( ( h = a.substring( 0, i ) ),
412 ( a = a.substring( i + l.length ) ),
413 h.length > 0 &&
414 ( ( h = e.createSearchChoice.call( this, h, c ) ),
415 h !== b &&
416 null !== h &&
417 e.id( h ) !== b &&
418 null !== e.id( h ) ) )
419 ) {
420 for ( g = ! 1, j = 0, k = c.length; k > j; j++ )
421 if ( r( e.id( h ), e.id( c[ j ] ) ) ) {
422 g = ! 0;
423 break;
424 }
425 g || d( h );
426 }
427 }
428 return f !== a ? a : void 0;
429 }
430 function N() {
431 var b = this;
432 a.each( arguments, function ( a, c ) {
433 b[ c ].remove(), ( b[ c ] = null );
434 } );
435 }
436 function O( b, c ) {
437 var d = function () {};
438 return (
439 ( d.prototype = new b() ),
440 ( d.prototype.constructor = d ),
441 ( d.prototype.parent = b.prototype ),
442 ( d.prototype = a.extend( d.prototype, c ) ),
443 d
444 );
445 }
446 if ( window.Select2 === b ) {
447 var c,
448 d,
449 e,
450 f,
451 g,
452 i,
453 j,
454 h = { x: 0, y: 0 },
455 k = {
456 TAB: 9,
457 ENTER: 13,
458 ESC: 27,
459 SPACE: 32,
460 LEFT: 37,
461 UP: 38,
462 RIGHT: 39,
463 DOWN: 40,
464 SHIFT: 16,
465 CTRL: 17,
466 ALT: 18,
467 PAGE_UP: 33,
468 PAGE_DOWN: 34,
469 HOME: 36,
470 END: 35,
471 BACKSPACE: 8,
472 DELETE: 46,
473 isArrow: function ( a ) {
474 switch ( ( a = a.which ? a.which : a ) ) {
475 case k.LEFT:
476 case k.RIGHT:
477 case k.UP:
478 case k.DOWN:
479 return ! 0;
480 }
481 return ! 1;
482 },
483 isControl: function ( a ) {
484 var b = a.which;
485 switch ( b ) {
486 case k.SHIFT:
487 case k.CTRL:
488 case k.ALT:
489 return ! 0;
490 }
491 return a.metaKey ? ! 0 : ! 1;
492 },
493 isFunctionKey: function ( a ) {
494 return (
495 ( a = a.which ? a.which : a ), a >= 112 && 123 >= a
496 );
497 },
498 },
499 l = "<div class='select2-measure-scrollbar'></div>",
500 m = {
501 '\u24b6': 'A',
502 '\uff21': 'A',
503 '\xc0': 'A',
504 '\xc1': 'A',
505 '\xc2': 'A',
506 '\u1ea6': 'A',
507 '\u1ea4': 'A',
508 '\u1eaa': 'A',
509 '\u1ea8': 'A',
510 '\xc3': 'A',
511 '\u0100': 'A',
512 '\u0102': 'A',
513 '\u1eb0': 'A',
514 '\u1eae': 'A',
515 '\u1eb4': 'A',
516 '\u1eb2': 'A',
517 '\u0226': 'A',
518 '\u01e0': 'A',
519 '\xc4': 'A',
520 '\u01de': 'A',
521 '\u1ea2': 'A',
522 '\xc5': 'A',
523 '\u01fa': 'A',
524 '\u01cd': 'A',
525 '\u0200': 'A',
526 '\u0202': 'A',
527 '\u1ea0': 'A',
528 '\u1eac': 'A',
529 '\u1eb6': 'A',
530 '\u1e00': 'A',
531 '\u0104': 'A',
532 '\u023a': 'A',
533 '\u2c6f': 'A',
534 '\ua732': 'AA',
535 '\xc6': 'AE',
536 '\u01fc': 'AE',
537 '\u01e2': 'AE',
538 '\ua734': 'AO',
539 '\ua736': 'AU',
540 '\ua738': 'AV',
541 '\ua73a': 'AV',
542 '\ua73c': 'AY',
543 '\u24b7': 'B',
544 '\uff22': 'B',
545 '\u1e02': 'B',
546 '\u1e04': 'B',
547 '\u1e06': 'B',
548 '\u0243': 'B',
549 '\u0182': 'B',
550 '\u0181': 'B',
551 '\u24b8': 'C',
552 '\uff23': 'C',
553 '\u0106': 'C',
554 '\u0108': 'C',
555 '\u010a': 'C',
556 '\u010c': 'C',
557 '\xc7': 'C',
558 '\u1e08': 'C',
559 '\u0187': 'C',
560 '\u023b': 'C',
561 '\ua73e': 'C',
562 '\u24b9': 'D',
563 '\uff24': 'D',
564 '\u1e0a': 'D',
565 '\u010e': 'D',
566 '\u1e0c': 'D',
567 '\u1e10': 'D',
568 '\u1e12': 'D',
569 '\u1e0e': 'D',
570 '\u0110': 'D',
571 '\u018b': 'D',
572 '\u018a': 'D',
573 '\u0189': 'D',
574 '\ua779': 'D',
575 '\u01f1': 'DZ',
576 '\u01c4': 'DZ',
577 '\u01f2': 'Dz',
578 '\u01c5': 'Dz',
579 '\u24ba': 'E',
580 '\uff25': 'E',
581 '\xc8': 'E',
582 '\xc9': 'E',
583 '\xca': 'E',
584 '\u1ec0': 'E',
585 '\u1ebe': 'E',
586 '\u1ec4': 'E',
587 '\u1ec2': 'E',
588 '\u1ebc': 'E',
589 '\u0112': 'E',
590 '\u1e14': 'E',
591 '\u1e16': 'E',
592 '\u0114': 'E',
593 '\u0116': 'E',
594 '\xcb': 'E',
595 '\u1eba': 'E',
596 '\u011a': 'E',
597 '\u0204': 'E',
598 '\u0206': 'E',
599 '\u1eb8': 'E',
600 '\u1ec6': 'E',
601 '\u0228': 'E',
602 '\u1e1c': 'E',
603 '\u0118': 'E',
604 '\u1e18': 'E',
605 '\u1e1a': 'E',
606 '\u0190': 'E',
607 '\u018e': 'E',
608 '\u24bb': 'F',
609 '\uff26': 'F',
610 '\u1e1e': 'F',
611 '\u0191': 'F',
612 '\ua77b': 'F',
613 '\u24bc': 'G',
614 '\uff27': 'G',
615 '\u01f4': 'G',
616 '\u011c': 'G',
617 '\u1e20': 'G',
618 '\u011e': 'G',
619 '\u0120': 'G',
620 '\u01e6': 'G',
621 '\u0122': 'G',
622 '\u01e4': 'G',
623 '\u0193': 'G',
624 '\ua7a0': 'G',
625 '\ua77d': 'G',
626 '\ua77e': 'G',
627 '\u24bd': 'H',
628 '\uff28': 'H',
629 '\u0124': 'H',
630 '\u1e22': 'H',
631 '\u1e26': 'H',
632 '\u021e': 'H',
633 '\u1e24': 'H',
634 '\u1e28': 'H',
635 '\u1e2a': 'H',
636 '\u0126': 'H',
637 '\u2c67': 'H',
638 '\u2c75': 'H',
639 '\ua78d': 'H',
640 '\u24be': 'I',
641 '\uff29': 'I',
642 '\xcc': 'I',
643 '\xcd': 'I',
644 '\xce': 'I',
645 '\u0128': 'I',
646 '\u012a': 'I',
647 '\u012c': 'I',
648 '\u0130': 'I',
649 '\xcf': 'I',
650 '\u1e2e': 'I',
651 '\u1ec8': 'I',
652 '\u01cf': 'I',
653 '\u0208': 'I',
654 '\u020a': 'I',
655 '\u1eca': 'I',
656 '\u012e': 'I',
657 '\u1e2c': 'I',
658 '\u0197': 'I',
659 '\u24bf': 'J',
660 '\uff2a': 'J',
661 '\u0134': 'J',
662 '\u0248': 'J',
663 '\u24c0': 'K',
664 '\uff2b': 'K',
665 '\u1e30': 'K',
666 '\u01e8': 'K',
667 '\u1e32': 'K',
668 '\u0136': 'K',
669 '\u1e34': 'K',
670 '\u0198': 'K',
671 '\u2c69': 'K',
672 '\ua740': 'K',
673 '\ua742': 'K',
674 '\ua744': 'K',
675 '\ua7a2': 'K',
676 '\u24c1': 'L',
677 '\uff2c': 'L',
678 '\u013f': 'L',
679 '\u0139': 'L',
680 '\u013d': 'L',
681 '\u1e36': 'L',
682 '\u1e38': 'L',
683 '\u013b': 'L',
684 '\u1e3c': 'L',
685 '\u1e3a': 'L',
686 '\u0141': 'L',
687 '\u023d': 'L',
688 '\u2c62': 'L',
689 '\u2c60': 'L',
690 '\ua748': 'L',
691 '\ua746': 'L',
692 '\ua780': 'L',
693 '\u01c7': 'LJ',
694 '\u01c8': 'Lj',
695 '\u24c2': 'M',
696 '\uff2d': 'M',
697 '\u1e3e': 'M',
698 '\u1e40': 'M',
699 '\u1e42': 'M',
700 '\u2c6e': 'M',
701 '\u019c': 'M',
702 '\u24c3': 'N',
703 '\uff2e': 'N',
704 '\u01f8': 'N',
705 '\u0143': 'N',
706 '\xd1': 'N',
707 '\u1e44': 'N',
708 '\u0147': 'N',
709 '\u1e46': 'N',
710 '\u0145': 'N',
711 '\u1e4a': 'N',
712 '\u1e48': 'N',
713 '\u0220': 'N',
714 '\u019d': 'N',
715 '\ua790': 'N',
716 '\ua7a4': 'N',
717 '\u01ca': 'NJ',
718 '\u01cb': 'Nj',
719 '\u24c4': 'O',
720 '\uff2f': 'O',
721 '\xd2': 'O',
722 '\xd3': 'O',
723 '\xd4': 'O',
724 '\u1ed2': 'O',
725 '\u1ed0': 'O',
726 '\u1ed6': 'O',
727 '\u1ed4': 'O',
728 '\xd5': 'O',
729 '\u1e4c': 'O',
730 '\u022c': 'O',
731 '\u1e4e': 'O',
732 '\u014c': 'O',
733 '\u1e50': 'O',
734 '\u1e52': 'O',
735 '\u014e': 'O',
736 '\u022e': 'O',
737 '\u0230': 'O',
738 '\xd6': 'O',
739 '\u022a': 'O',
740 '\u1ece': 'O',
741 '\u0150': 'O',
742 '\u01d1': 'O',
743 '\u020c': 'O',
744 '\u020e': 'O',
745 '\u01a0': 'O',
746 '\u1edc': 'O',
747 '\u1eda': 'O',
748 '\u1ee0': 'O',
749 '\u1ede': 'O',
750 '\u1ee2': 'O',
751 '\u1ecc': 'O',
752 '\u1ed8': 'O',
753 '\u01ea': 'O',
754 '\u01ec': 'O',
755 '\xd8': 'O',
756 '\u01fe': 'O',
757 '\u0186': 'O',
758 '\u019f': 'O',
759 '\ua74a': 'O',
760 '\ua74c': 'O',
761 '\u01a2': 'OI',
762 '\ua74e': 'OO',
763 '\u0222': 'OU',
764 '\u24c5': 'P',
765 '\uff30': 'P',
766 '\u1e54': 'P',
767 '\u1e56': 'P',
768 '\u01a4': 'P',
769 '\u2c63': 'P',
770 '\ua750': 'P',
771 '\ua752': 'P',
772 '\ua754': 'P',
773 '\u24c6': 'Q',
774 '\uff31': 'Q',
775 '\ua756': 'Q',
776 '\ua758': 'Q',
777 '\u024a': 'Q',
778 '\u24c7': 'R',
779 '\uff32': 'R',
780 '\u0154': 'R',
781 '\u1e58': 'R',
782 '\u0158': 'R',
783 '\u0210': 'R',
784 '\u0212': 'R',
785 '\u1e5a': 'R',
786 '\u1e5c': 'R',
787 '\u0156': 'R',
788 '\u1e5e': 'R',
789 '\u024c': 'R',
790 '\u2c64': 'R',
791 '\ua75a': 'R',
792 '\ua7a6': 'R',
793 '\ua782': 'R',
794 '\u24c8': 'S',
795 '\uff33': 'S',
796 '\u1e9e': 'S',
797 '\u015a': 'S',
798 '\u1e64': 'S',
799 '\u015c': 'S',
800 '\u1e60': 'S',
801 '\u0160': 'S',
802 '\u1e66': 'S',
803 '\u1e62': 'S',
804 '\u1e68': 'S',
805 '\u0218': 'S',
806 '\u015e': 'S',
807 '\u2c7e': 'S',
808 '\ua7a8': 'S',
809 '\ua784': 'S',
810 '\u24c9': 'T',
811 '\uff34': 'T',
812 '\u1e6a': 'T',
813 '\u0164': 'T',
814 '\u1e6c': 'T',
815 '\u021a': 'T',
816 '\u0162': 'T',
817 '\u1e70': 'T',
818 '\u1e6e': 'T',
819 '\u0166': 'T',
820 '\u01ac': 'T',
821 '\u01ae': 'T',
822 '\u023e': 'T',
823 '\ua786': 'T',
824 '\ua728': 'TZ',
825 '\u24ca': 'U',
826 '\uff35': 'U',
827 '\xd9': 'U',
828 '\xda': 'U',
829 '\xdb': 'U',
830 '\u0168': 'U',
831 '\u1e78': 'U',
832 '\u016a': 'U',
833 '\u1e7a': 'U',
834 '\u016c': 'U',
835 '\xdc': 'U',
836 '\u01db': 'U',
837 '\u01d7': 'U',
838 '\u01d5': 'U',
839 '\u01d9': 'U',
840 '\u1ee6': 'U',
841 '\u016e': 'U',
842 '\u0170': 'U',
843 '\u01d3': 'U',
844 '\u0214': 'U',
845 '\u0216': 'U',
846 '\u01af': 'U',
847 '\u1eea': 'U',
848 '\u1ee8': 'U',
849 '\u1eee': 'U',
850 '\u1eec': 'U',
851 '\u1ef0': 'U',
852 '\u1ee4': 'U',
853 '\u1e72': 'U',
854 '\u0172': 'U',
855 '\u1e76': 'U',
856 '\u1e74': 'U',
857 '\u0244': 'U',
858 '\u24cb': 'V',
859 '\uff36': 'V',
860 '\u1e7c': 'V',
861 '\u1e7e': 'V',
862 '\u01b2': 'V',
863 '\ua75e': 'V',
864 '\u0245': 'V',
865 '\ua760': 'VY',
866 '\u24cc': 'W',
867 '\uff37': 'W',
868 '\u1e80': 'W',
869 '\u1e82': 'W',
870 '\u0174': 'W',
871 '\u1e86': 'W',
872 '\u1e84': 'W',
873 '\u1e88': 'W',
874 '\u2c72': 'W',
875 '\u24cd': 'X',
876 '\uff38': 'X',
877 '\u1e8a': 'X',
878 '\u1e8c': 'X',
879 '\u24ce': 'Y',
880 '\uff39': 'Y',
881 '\u1ef2': 'Y',
882 '\xdd': 'Y',
883 '\u0176': 'Y',
884 '\u1ef8': 'Y',
885 '\u0232': 'Y',
886 '\u1e8e': 'Y',
887 '\u0178': 'Y',
888 '\u1ef6': 'Y',
889 '\u1ef4': 'Y',
890 '\u01b3': 'Y',
891 '\u024e': 'Y',
892 '\u1efe': 'Y',
893 '\u24cf': 'Z',
894 '\uff3a': 'Z',
895 '\u0179': 'Z',
896 '\u1e90': 'Z',
897 '\u017b': 'Z',
898 '\u017d': 'Z',
899 '\u1e92': 'Z',
900 '\u1e94': 'Z',
901 '\u01b5': 'Z',
902 '\u0224': 'Z',
903 '\u2c7f': 'Z',
904 '\u2c6b': 'Z',
905 '\ua762': 'Z',
906 '\u24d0': 'a',
907 '\uff41': 'a',
908 '\u1e9a': 'a',
909 '\xe0': 'a',
910 '\xe1': 'a',
911 '\xe2': 'a',
912 '\u1ea7': 'a',
913 '\u1ea5': 'a',
914 '\u1eab': 'a',
915 '\u1ea9': 'a',
916 '\xe3': 'a',
917 '\u0101': 'a',
918 '\u0103': 'a',
919 '\u1eb1': 'a',
920 '\u1eaf': 'a',
921 '\u1eb5': 'a',
922 '\u1eb3': 'a',
923 '\u0227': 'a',
924 '\u01e1': 'a',
925 '\xe4': 'a',
926 '\u01df': 'a',
927 '\u1ea3': 'a',
928 '\xe5': 'a',
929 '\u01fb': 'a',
930 '\u01ce': 'a',
931 '\u0201': 'a',
932 '\u0203': 'a',
933 '\u1ea1': 'a',
934 '\u1ead': 'a',
935 '\u1eb7': 'a',
936 '\u1e01': 'a',
937 '\u0105': 'a',
938 '\u2c65': 'a',
939 '\u0250': 'a',
940 '\ua733': 'aa',
941 '\xe6': 'ae',
942 '\u01fd': 'ae',
943 '\u01e3': 'ae',
944 '\ua735': 'ao',
945 '\ua737': 'au',
946 '\ua739': 'av',
947 '\ua73b': 'av',
948 '\ua73d': 'ay',
949 '\u24d1': 'b',
950 '\uff42': 'b',
951 '\u1e03': 'b',
952 '\u1e05': 'b',
953 '\u1e07': 'b',
954 '\u0180': 'b',
955 '\u0183': 'b',
956 '\u0253': 'b',
957 '\u24d2': 'c',
958 '\uff43': 'c',
959 '\u0107': 'c',
960 '\u0109': 'c',
961 '\u010b': 'c',
962 '\u010d': 'c',
963 '\xe7': 'c',
964 '\u1e09': 'c',
965 '\u0188': 'c',
966 '\u023c': 'c',
967 '\ua73f': 'c',
968 '\u2184': 'c',
969 '\u24d3': 'd',
970 '\uff44': 'd',
971 '\u1e0b': 'd',
972 '\u010f': 'd',
973 '\u1e0d': 'd',
974 '\u1e11': 'd',
975 '\u1e13': 'd',
976 '\u1e0f': 'd',
977 '\u0111': 'd',
978 '\u018c': 'd',
979 '\u0256': 'd',
980 '\u0257': 'd',
981 '\ua77a': 'd',
982 '\u01f3': 'dz',
983 '\u01c6': 'dz',
984 '\u24d4': 'e',
985 '\uff45': 'e',
986 '\xe8': 'e',
987 '\xe9': 'e',
988 '\xea': 'e',
989 '\u1ec1': 'e',
990 '\u1ebf': 'e',
991 '\u1ec5': 'e',
992 '\u1ec3': 'e',
993 '\u1ebd': 'e',
994 '\u0113': 'e',
995 '\u1e15': 'e',
996 '\u1e17': 'e',
997 '\u0115': 'e',
998 '\u0117': 'e',
999 '\xeb': 'e',
1000 '\u1ebb': 'e',
1001 '\u011b': 'e',
1002 '\u0205': 'e',
1003 '\u0207': 'e',
1004 '\u1eb9': 'e',
1005 '\u1ec7': 'e',
1006 '\u0229': 'e',
1007 '\u1e1d': 'e',
1008 '\u0119': 'e',
1009 '\u1e19': 'e',
1010 '\u1e1b': 'e',
1011 '\u0247': 'e',
1012 '\u025b': 'e',
1013 '\u01dd': 'e',
1014 '\u24d5': 'f',
1015 '\uff46': 'f',
1016 '\u1e1f': 'f',
1017 '\u0192': 'f',
1018 '\ua77c': 'f',
1019 '\u24d6': 'g',
1020 '\uff47': 'g',
1021 '\u01f5': 'g',
1022 '\u011d': 'g',
1023 '\u1e21': 'g',
1024 '\u011f': 'g',
1025 '\u0121': 'g',
1026 '\u01e7': 'g',
1027 '\u0123': 'g',
1028 '\u01e5': 'g',
1029 '\u0260': 'g',
1030 '\ua7a1': 'g',
1031 '\u1d79': 'g',
1032 '\ua77f': 'g',
1033 '\u24d7': 'h',
1034 '\uff48': 'h',
1035 '\u0125': 'h',
1036 '\u1e23': 'h',
1037 '\u1e27': 'h',
1038 '\u021f': 'h',
1039 '\u1e25': 'h',
1040 '\u1e29': 'h',
1041 '\u1e2b': 'h',
1042 '\u1e96': 'h',
1043 '\u0127': 'h',
1044 '\u2c68': 'h',
1045 '\u2c76': 'h',
1046 '\u0265': 'h',
1047 '\u0195': 'hv',
1048 '\u24d8': 'i',
1049 '\uff49': 'i',
1050 '\xec': 'i',
1051 '\xed': 'i',
1052 '\xee': 'i',
1053 '\u0129': 'i',
1054 '\u012b': 'i',
1055 '\u012d': 'i',
1056 '\xef': 'i',
1057 '\u1e2f': 'i',
1058 '\u1ec9': 'i',
1059 '\u01d0': 'i',
1060 '\u0209': 'i',
1061 '\u020b': 'i',
1062 '\u1ecb': 'i',
1063 '\u012f': 'i',
1064 '\u1e2d': 'i',
1065 '\u0268': 'i',
1066 '\u0131': 'i',
1067 '\u24d9': 'j',
1068 '\uff4a': 'j',
1069 '\u0135': 'j',
1070 '\u01f0': 'j',
1071 '\u0249': 'j',
1072 '\u24da': 'k',
1073 '\uff4b': 'k',
1074 '\u1e31': 'k',
1075 '\u01e9': 'k',
1076 '\u1e33': 'k',
1077 '\u0137': 'k',
1078 '\u1e35': 'k',
1079 '\u0199': 'k',
1080 '\u2c6a': 'k',
1081 '\ua741': 'k',
1082 '\ua743': 'k',
1083 '\ua745': 'k',
1084 '\ua7a3': 'k',
1085 '\u24db': 'l',
1086 '\uff4c': 'l',
1087 '\u0140': 'l',
1088 '\u013a': 'l',
1089 '\u013e': 'l',
1090 '\u1e37': 'l',
1091 '\u1e39': 'l',
1092 '\u013c': 'l',
1093 '\u1e3d': 'l',
1094 '\u1e3b': 'l',
1095 '\u017f': 'l',
1096 '\u0142': 'l',
1097 '\u019a': 'l',
1098 '\u026b': 'l',
1099 '\u2c61': 'l',
1100 '\ua749': 'l',
1101 '\ua781': 'l',
1102 '\ua747': 'l',
1103 '\u01c9': 'lj',
1104 '\u24dc': 'm',
1105 '\uff4d': 'm',
1106 '\u1e3f': 'm',
1107 '\u1e41': 'm',
1108 '\u1e43': 'm',
1109 '\u0271': 'm',
1110 '\u026f': 'm',
1111 '\u24dd': 'n',
1112 '\uff4e': 'n',
1113 '\u01f9': 'n',
1114 '\u0144': 'n',
1115 '\xf1': 'n',
1116 '\u1e45': 'n',
1117 '\u0148': 'n',
1118 '\u1e47': 'n',
1119 '\u0146': 'n',
1120 '\u1e4b': 'n',
1121 '\u1e49': 'n',
1122 '\u019e': 'n',
1123 '\u0272': 'n',
1124 '\u0149': 'n',
1125 '\ua791': 'n',
1126 '\ua7a5': 'n',
1127 '\u01cc': 'nj',
1128 '\u24de': 'o',
1129 '\uff4f': 'o',
1130 '\xf2': 'o',
1131 '\xf3': 'o',
1132 '\xf4': 'o',
1133 '\u1ed3': 'o',
1134 '\u1ed1': 'o',
1135 '\u1ed7': 'o',
1136 '\u1ed5': 'o',
1137 '\xf5': 'o',
1138 '\u1e4d': 'o',
1139 '\u022d': 'o',
1140 '\u1e4f': 'o',
1141 '\u014d': 'o',
1142 '\u1e51': 'o',
1143 '\u1e53': 'o',
1144 '\u014f': 'o',
1145 '\u022f': 'o',
1146 '\u0231': 'o',
1147 '\xf6': 'o',
1148 '\u022b': 'o',
1149 '\u1ecf': 'o',
1150 '\u0151': 'o',
1151 '\u01d2': 'o',
1152 '\u020d': 'o',
1153 '\u020f': 'o',
1154 '\u01a1': 'o',
1155 '\u1edd': 'o',
1156 '\u1edb': 'o',
1157 '\u1ee1': 'o',
1158 '\u1edf': 'o',
1159 '\u1ee3': 'o',
1160 '\u1ecd': 'o',
1161 '\u1ed9': 'o',
1162 '\u01eb': 'o',
1163 '\u01ed': 'o',
1164 '\xf8': 'o',
1165 '\u01ff': 'o',
1166 '\u0254': 'o',
1167 '\ua74b': 'o',
1168 '\ua74d': 'o',
1169 '\u0275': 'o',
1170 '\u01a3': 'oi',
1171 '\u0223': 'ou',
1172 '\ua74f': 'oo',
1173 '\u24df': 'p',
1174 '\uff50': 'p',
1175 '\u1e55': 'p',
1176 '\u1e57': 'p',
1177 '\u01a5': 'p',
1178 '\u1d7d': 'p',
1179 '\ua751': 'p',
1180 '\ua753': 'p',
1181 '\ua755': 'p',
1182 '\u24e0': 'q',
1183 '\uff51': 'q',
1184 '\u024b': 'q',
1185 '\ua757': 'q',
1186 '\ua759': 'q',
1187 '\u24e1': 'r',
1188 '\uff52': 'r',
1189 '\u0155': 'r',
1190 '\u1e59': 'r',
1191 '\u0159': 'r',
1192 '\u0211': 'r',
1193 '\u0213': 'r',
1194 '\u1e5b': 'r',
1195 '\u1e5d': 'r',
1196 '\u0157': 'r',
1197 '\u1e5f': 'r',
1198 '\u024d': 'r',
1199 '\u027d': 'r',
1200 '\ua75b': 'r',
1201 '\ua7a7': 'r',
1202 '\ua783': 'r',
1203 '\u24e2': 's',
1204 '\uff53': 's',
1205 '\xdf': 's',
1206 '\u015b': 's',
1207 '\u1e65': 's',
1208 '\u015d': 's',
1209 '\u1e61': 's',
1210 '\u0161': 's',
1211 '\u1e67': 's',
1212 '\u1e63': 's',
1213 '\u1e69': 's',
1214 '\u0219': 's',
1215 '\u015f': 's',
1216 '\u023f': 's',
1217 '\ua7a9': 's',
1218 '\ua785': 's',
1219 '\u1e9b': 's',
1220 '\u24e3': 't',
1221 '\uff54': 't',
1222 '\u1e6b': 't',
1223 '\u1e97': 't',
1224 '\u0165': 't',
1225 '\u1e6d': 't',
1226 '\u021b': 't',
1227 '\u0163': 't',
1228 '\u1e71': 't',
1229 '\u1e6f': 't',
1230 '\u0167': 't',
1231 '\u01ad': 't',
1232 '\u0288': 't',
1233 '\u2c66': 't',
1234 '\ua787': 't',
1235 '\ua729': 'tz',
1236 '\u24e4': 'u',
1237 '\uff55': 'u',
1238 '\xf9': 'u',
1239 '\xfa': 'u',
1240 '\xfb': 'u',
1241 '\u0169': 'u',
1242 '\u1e79': 'u',
1243 '\u016b': 'u',
1244 '\u1e7b': 'u',
1245 '\u016d': 'u',
1246 '\xfc': 'u',
1247 '\u01dc': 'u',
1248 '\u01d8': 'u',
1249 '\u01d6': 'u',
1250 '\u01da': 'u',
1251 '\u1ee7': 'u',
1252 '\u016f': 'u',
1253 '\u0171': 'u',
1254 '\u01d4': 'u',
1255 '\u0215': 'u',
1256 '\u0217': 'u',
1257 '\u01b0': 'u',
1258 '\u1eeb': 'u',
1259 '\u1ee9': 'u',
1260 '\u1eef': 'u',
1261 '\u1eed': 'u',
1262 '\u1ef1': 'u',
1263 '\u1ee5': 'u',
1264 '\u1e73': 'u',
1265 '\u0173': 'u',
1266 '\u1e77': 'u',
1267 '\u1e75': 'u',
1268 '\u0289': 'u',
1269 '\u24e5': 'v',
1270 '\uff56': 'v',
1271 '\u1e7d': 'v',
1272 '\u1e7f': 'v',
1273 '\u028b': 'v',
1274 '\ua75f': 'v',
1275 '\u028c': 'v',
1276 '\ua761': 'vy',
1277 '\u24e6': 'w',
1278 '\uff57': 'w',
1279 '\u1e81': 'w',
1280 '\u1e83': 'w',
1281 '\u0175': 'w',
1282 '\u1e87': 'w',
1283 '\u1e85': 'w',
1284 '\u1e98': 'w',
1285 '\u1e89': 'w',
1286 '\u2c73': 'w',
1287 '\u24e7': 'x',
1288 '\uff58': 'x',
1289 '\u1e8b': 'x',
1290 '\u1e8d': 'x',
1291 '\u24e8': 'y',
1292 '\uff59': 'y',
1293 '\u1ef3': 'y',
1294 '\xfd': 'y',
1295 '\u0177': 'y',
1296 '\u1ef9': 'y',
1297 '\u0233': 'y',
1298 '\u1e8f': 'y',
1299 '\xff': 'y',
1300 '\u1ef7': 'y',
1301 '\u1e99': 'y',
1302 '\u1ef5': 'y',
1303 '\u01b4': 'y',
1304 '\u024f': 'y',
1305 '\u1eff': 'y',
1306 '\u24e9': 'z',
1307 '\uff5a': 'z',
1308 '\u017a': 'z',
1309 '\u1e91': 'z',
1310 '\u017c': 'z',
1311 '\u017e': 'z',
1312 '\u1e93': 'z',
1313 '\u1e95': 'z',
1314 '\u01b6': 'z',
1315 '\u0225': 'z',
1316 '\u0240': 'z',
1317 '\u2c6c': 'z',
1318 '\ua763': 'z',
1319 '\u0386': '\u0391',
1320 '\u0388': '\u0395',
1321 '\u0389': '\u0397',
1322 '\u038a': '\u0399',
1323 '\u03aa': '\u0399',
1324 '\u038c': '\u039f',
1325 '\u038e': '\u03a5',
1326 '\u03ab': '\u03a5',
1327 '\u038f': '\u03a9',
1328 '\u03ac': '\u03b1',
1329 '\u03ad': '\u03b5',
1330 '\u03ae': '\u03b7',
1331 '\u03af': '\u03b9',
1332 '\u03ca': '\u03b9',
1333 '\u0390': '\u03b9',
1334 '\u03cc': '\u03bf',
1335 '\u03cd': '\u03c5',
1336 '\u03cb': '\u03c5',
1337 '\u03b0': '\u03c5',
1338 '\u03c9': '\u03c9',
1339 '\u03c2': '\u03c3',
1340 };
1341 ( i = a( document ) ),
1342 ( f = ( function () {
1343 var a = 1;
1344 return function () {
1345 return a++;
1346 };
1347 } )() ),
1348 ( c = O( Object, {
1349 bind: function ( a ) {
1350 var b = this;
1351 return function () {
1352 a.apply( b, arguments );
1353 };
1354 },
1355 init: function ( c ) {
1356 var d,
1357 e,
1358 g = '.select2-results';
1359 ( this.opts = c = this.prepareOpts( c ) ),
1360 ( this.id = c.id ),
1361 c.element.data( 'select2' ) !== b &&
1362 null !== c.element.data( 'select2' ) &&
1363 c.element.data( 'select2' ).destroy(),
1364 ( this.container = this.createContainer() ),
1365 ( this.liveRegion = a(
1366 '.select2-hidden-accessible'
1367 ) ),
1368 0 == this.liveRegion.length &&
1369 ( this.liveRegion = a( '<span>', {
1370 role: 'status',
1371 'aria-live': 'polite',
1372 } )
1373 .addClass( 'select2-hidden-accessible' )
1374 .appendTo( document.body ) ),
1375 ( this.containerId =
1376 's2id_' +
1377 ( c.element.attr( 'id' ) || 'autogen' + f() ) ),
1378 ( this.containerEventName = this.containerId
1379 .replace( /([.])/g, '_' )
1380 .replace(
1381 /([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,
1382 '\\$1'
1383 ) ),
1384 this.container.attr( 'id', this.containerId ),
1385 this.container.attr(
1386 'title',
1387 c.element.attr( 'title' )
1388 ),
1389 ( this.body = a( document.body ) ),
1390 D(
1391 this.container,
1392 this.opts.element,
1393 this.opts.adaptContainerCssClass
1394 ),
1395 this.container.attr(
1396 'style',
1397 c.element.attr( 'style' )
1398 ),
1399 this.container.css(
1400 K( c.containerCss, this.opts.element )
1401 ),
1402 this.container.addClass(
1403 K( c.containerCssClass, this.opts.element )
1404 ),
1405 ( this.elementTabIndex = this.opts.element.attr(
1406 'tabindex'
1407 ) ),
1408 this.opts.element
1409 .data( 'select2', this )
1410 .attr( 'tabindex', '-1' )
1411 .before( this.container )
1412 .on( 'click.select2', A ),
1413 this.container.data( 'select2', this ),
1414 ( this.dropdown = this.container.find(
1415 '.select2-drop'
1416 ) ),
1417 D(
1418 this.dropdown,
1419 this.opts.element,
1420 this.opts.adaptDropdownCssClass
1421 ),
1422 this.dropdown.addClass(
1423 K( c.dropdownCssClass, this.opts.element )
1424 ),
1425 this.dropdown.data( 'select2', this ),
1426 this.dropdown.on( 'click', A ),
1427 ( this.results = d = this.container.find( g ) ),
1428 ( this.search = e = this.container.find(
1429 'input.select2-input'
1430 ) ),
1431 ( this.queryCount = 0 ),
1432 ( this.resultsPage = 0 ),
1433 ( this.context = null ),
1434 this.initContainer(),
1435 this.container.on( 'click', A ),
1436 v( this.results ),
1437 this.dropdown.on(
1438 'mousemove-filtered',
1439 g,
1440 this.bind( this.highlightUnderEvent )
1441 ),
1442 this.dropdown.on(
1443 'touchstart touchmove touchend',
1444 g,
1445 this.bind( function ( a ) {
1446 ( this._touchEvent = ! 0 ),
1447 this.highlightUnderEvent( a );
1448 } )
1449 ),
1450 this.dropdown.on(
1451 'touchmove',
1452 g,
1453 this.bind( this.touchMoved )
1454 ),
1455 this.dropdown.on(
1456 'touchstart touchend',
1457 g,
1458 this.bind( this.clearTouchMoved )
1459 ),
1460 this.dropdown.on(
1461 'click',
1462 this.bind( function () {
1463 this._touchEvent &&
1464 ( ( this._touchEvent = ! 1 ),
1465 this.selectHighlighted() );
1466 } )
1467 ),
1468 x( 80, this.results ),
1469 this.dropdown.on(
1470 'scroll-debounced',
1471 g,
1472 this.bind( this.loadMoreIfNeeded )
1473 ),
1474 a( this.container ).on(
1475 'change',
1476 '.select2-input',
1477 function ( a ) {
1478 a.stopPropagation();
1479 }
1480 ),
1481 a( this.dropdown ).on(
1482 'change',
1483 '.select2-input',
1484 function ( a ) {
1485 a.stopPropagation();
1486 }
1487 ),
1488 a.fn.mousewheel &&
1489 d.mousewheel( function ( a, b, c, e ) {
1490 var f = d.scrollTop();
1491 e > 0 && 0 >= f - e
1492 ? ( d.scrollTop( 0 ), A( a ) )
1493 : 0 > e &&
1494 d.get( 0 ).scrollHeight -
1495 d.scrollTop() +
1496 e <=
1497 d.height() &&
1498 ( d.scrollTop(
1499 d.get( 0 ).scrollHeight -
1500 d.height()
1501 ),
1502 A( a ) );
1503 } ),
1504 u( e ),
1505 e.on(
1506 'keyup-change input paste',
1507 this.bind( this.updateResults )
1508 ),
1509 e.on( 'focus', function () {
1510 e.addClass( 'select2-focused' );
1511 } ),
1512 e.on( 'blur', function () {
1513 e.removeClass( 'select2-focused' );
1514 } ),
1515 this.dropdown.on(
1516 'mouseup',
1517 g,
1518 this.bind( function ( b ) {
1519 a( b.target ).closest(
1520 '.select2-result-selectable'
1521 ).length > 0 &&
1522 ( this.highlightUnderEvent( b ),
1523 this.selectHighlighted( b ) );
1524 } )
1525 ),
1526 this.dropdown.on(
1527 'click mouseup mousedown touchstart touchend focusin',
1528 function ( a ) {
1529 a.stopPropagation();
1530 }
1531 ),
1532 ( this.nextSearchTerm = b ),
1533 a.isFunction( this.opts.initSelection ) &&
1534 ( this.initSelection(), this.monitorSource() ),
1535 null !== c.maximumInputLength &&
1536 this.search.attr(
1537 'maxlength',
1538 c.maximumInputLength
1539 );
1540 var h = c.element.prop( 'disabled' );
1541 h === b && ( h = ! 1 ), this.enable( ! h );
1542 var i = c.element.prop( 'readonly' );
1543 i === b && ( i = ! 1 ),
1544 this.readonly( i ),
1545 ( j = j || q() ),
1546 ( this.autofocus = c.element.prop( 'autofocus' ) ),
1547 c.element.prop( 'autofocus', ! 1 ),
1548 this.autofocus && this.focus(),
1549 this.search.attr(
1550 'placeholder',
1551 c.searchInputPlaceholder
1552 );
1553 },
1554 destroy: function () {
1555 var a = this.opts.element,
1556 c = a.data( 'select2' ),
1557 d = this;
1558 this.close(),
1559 a.length &&
1560 a[ 0 ].detachEvent &&
1561 d._sync &&
1562 a.each( function () {
1563 d._sync &&
1564 this.detachEvent(
1565 'onpropertychange',
1566 d._sync
1567 );
1568 } ),
1569 this.propertyObserver &&
1570 ( this.propertyObserver.disconnect(),
1571 ( this.propertyObserver = null ) ),
1572 ( this._sync = null ),
1573 c !== b &&
1574 ( c.container.remove(),
1575 c.liveRegion.remove(),
1576 c.dropdown.remove(),
1577 a
1578 .show()
1579 .removeData( 'select2' )
1580 .off( '.select2' )
1581 .prop( 'autofocus', this.autofocus || ! 1 ),
1582 this.elementTabIndex
1583 ? a.attr( {
1584 tabindex: this.elementTabIndex,
1585 } )
1586 : a.removeAttr( 'tabindex' ),
1587 a.show() ),
1588 N.call(
1589 this,
1590 'container',
1591 'liveRegion',
1592 'dropdown',
1593 'results',
1594 'search'
1595 );
1596 },
1597 optionToData: function ( a ) {
1598 return a.is( 'option' )
1599 ? {
1600 id: a.prop( 'value' ),
1601 text: a.text(),
1602 element: a.get(),
1603 css: a.attr( 'class' ),
1604 disabled: a.prop( 'disabled' ),
1605 locked:
1606 r( a.attr( 'locked' ), 'locked' ) ||
1607 r( a.data( 'locked' ), ! 0 ),
1608 }
1609 : a.is( 'optgroup' )
1610 ? {
1611 text: a.attr( 'label' ),
1612 children: [],
1613 element: a.get(),
1614 css: a.attr( 'class' ),
1615 }
1616 : void 0;
1617 },
1618 prepareOpts: function ( c ) {
1619 var d,
1620 e,
1621 g,
1622 h,
1623 i = this;
1624 if (
1625 ( ( d = c.element ),
1626 'select' === d.get( 0 ).tagName.toLowerCase() &&
1627 ( this.select = e = c.element ),
1628 e &&
1629 a.each(
1630 [
1631 'id',
1632 'multiple',
1633 'ajax',
1634 'query',
1635 'createSearchChoice',
1636 'initSelection',
1637 'data',
1638 'tags',
1639 ],
1640 function () {
1641 if ( this in c )
1642 throw new Error(
1643 "Option '" +
1644 this +
1645 "' is not allowed for Select2 when attached to a <select> element."
1646 );
1647 }
1648 ),
1649 ( c = a.extend(
1650 {},
1651 {
1652 populateResults: function ( d, e, g ) {
1653 var h,
1654 j = this.opts.id,
1655 k = this.liveRegion;
1656 ( h = function ( d, e, l ) {
1657 var m, n, o, p, q, r, s, t, u, v;
1658 d = c.sortResults( d, e, g );
1659 var w = [];
1660 for (
1661 m = 0, n = d.length;
1662 n > m;
1663 m += 1
1664 )
1665 ( o = d[ m ] ),
1666 ( q = o.disabled === ! 0 ),
1667 ( p = ! q && j( o ) !== b ),
1668 ( r =
1669 o.children &&
1670 o.children.length > 0 ),
1671 ( s = a( '<li></li>' ) ),
1672 s.addClass(
1673 'select2-results-dept-' +
1674 l
1675 ),
1676 s.addClass(
1677 'select2-result'
1678 ),
1679 s.addClass(
1680 p
1681 ? 'select2-result-selectable'
1682 : 'select2-result-unselectable'
1683 ),
1684 q &&
1685 s.addClass(
1686 'select2-disabled'
1687 ),
1688 r &&
1689 s.addClass(
1690 'select2-result-with-children'
1691 ),
1692 s.addClass(
1693 i.opts.formatResultCssClass(
1694 o
1695 )
1696 ),
1697 s.attr(
1698 'role',
1699 'presentation'
1700 ),
1701 ( t = a(
1702 document.createElement(
1703 'div'
1704 )
1705 ) ),
1706 t.addClass(
1707 'select2-result-label'
1708 ),
1709 t.attr(
1710 'id',
1711 'select2-result-label-' +
1712 f()
1713 ),
1714 t.attr( 'role', 'option' ),
1715 ( v = c.formatResult(
1716 o,
1717 t,
1718 g,
1719 i.opts.escapeMarkup
1720 ) ),
1721 v !== b &&
1722 ( t.html( v ),
1723 s.append( t ) ),
1724 r &&
1725 ( ( u = a(
1726 '<ul></ul>'
1727 ) ),
1728 u.addClass(
1729 'select2-result-sub'
1730 ),
1731 h(
1732 o.children,
1733 u,
1734 l + 1
1735 ),
1736 s.append( u ) ),
1737 s.data( 'select2-data', o ),
1738 w.push( s[ 0 ] );
1739 e.append( w ),
1740 k.text(
1741 c.formatMatches( d.length )
1742 );
1743 } ),
1744 h( e, d, 0 );
1745 },
1746 },
1747 a.fn.select2.defaults,
1748 c
1749 ) ),
1750 'function' != typeof c.id &&
1751 ( ( g = c.id ),
1752 ( c.id = function ( a ) {
1753 return a[ g ];
1754 } ) ),
1755 a.isArray( c.element.data( 'select2Tags' ) ) )
1756 ) {
1757 if ( 'tags' in c )
1758 throw (
1759 "tags specified as both an attribute 'data-select2-tags' and in options of Select2 " +
1760 c.element.attr( 'id' )
1761 );
1762 c.tags = c.element.data( 'select2Tags' );
1763 }
1764 if (
1765 ( e
1766 ? ( ( c.query = this.bind( function ( a ) {
1767 var f,
1768 g,
1769 h,
1770 c = { results: [], more: ! 1 },
1771 e = a.term;
1772 ( h = function ( b, c ) {
1773 var d;
1774 b.is( 'option' )
1775 ? a.matcher( e, b.text(), b ) &&
1776 c.push( i.optionToData( b ) )
1777 : b.is( 'optgroup' ) &&
1778 ( ( d = i.optionToData( b ) ),
1779 b
1780 .children()
1781 .each2( function (
1782 a,
1783 b
1784 ) {
1785 h( b, d.children );
1786 } ),
1787 d.children.length > 0 &&
1788 c.push( d ) );
1789 } ),
1790 ( f = d.children() ),
1791 this.getPlaceholder() !== b &&
1792 f.length > 0 &&
1793 ( ( g = this.getPlaceholderOption() ),
1794 g && ( f = f.not( g ) ) ),
1795 f.each2( function ( a, b ) {
1796 h( b, c.results );
1797 } ),
1798 a.callback( c );
1799 } ) ),
1800 ( c.id = function ( a ) {
1801 return a.id;
1802 } ) )
1803 : 'query' in c ||
1804 ( 'ajax' in c
1805 ? ( ( h = c.element.data(
1806 'ajax-url'
1807 ) ),
1808 h &&
1809 h.length > 0 &&
1810 ( c.ajax.url = h ),
1811 ( c.query = G.call(
1812 c.element,
1813 c.ajax
1814 ) ) )
1815 : 'data' in c
1816 ? ( c.query = H( c.data ) )
1817 : 'tags' in c &&
1818 ( ( c.query = I( c.tags ) ),
1819 c.createSearchChoice === b &&
1820 ( c.createSearchChoice = function (
1821 b
1822 ) {
1823 return {
1824 id: a.trim( b ),
1825 text: a.trim( b ),
1826 };
1827 } ),
1828 c.initSelection === b &&
1829 ( c.initSelection = function (
1830 b,
1831 d
1832 ) {
1833 var e = [];
1834 a(
1835 s(
1836 b.val(),
1837 c.separator,
1838 c.transformVal
1839 )
1840 ).each( function () {
1841 var b = {
1842 id: this,
1843 text: this,
1844 },
1845 d = c.tags;
1846 a.isFunction( d ) &&
1847 ( d = d() ),
1848 a( d ).each(
1849 function () {
1850 return r(
1851 this.id,
1852 b.id
1853 )
1854 ? ( ( b = this ),
1855 ! 1 )
1856 : void 0;
1857 }
1858 ),
1859 e.push( b );
1860 } ),
1861 d( e );
1862 } ) ) ),
1863 'function' != typeof c.query )
1864 )
1865 throw (
1866 'query function not defined for Select2 ' +
1867 c.element.attr( 'id' )
1868 );
1869 if ( 'top' === c.createSearchChoicePosition )
1870 c.createSearchChoicePosition = function ( a, b ) {
1871 a.unshift( b );
1872 };
1873 else if ( 'bottom' === c.createSearchChoicePosition )
1874 c.createSearchChoicePosition = function ( a, b ) {
1875 a.push( b );
1876 };
1877 else if (
1878 'function' != typeof c.createSearchChoicePosition
1879 )
1880 throw "invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function";
1881 return c;
1882 },
1883 monitorSource: function () {
1884 var d,
1885 c = this.opts.element,
1886 e = this;
1887 c.on(
1888 'change.select2',
1889 this.bind( function () {
1890 this.opts.element.data(
1891 'select2-change-triggered'
1892 ) !== ! 0 && this.initSelection();
1893 } )
1894 ),
1895 ( this._sync = this.bind( function () {
1896 var a = c.prop( 'disabled' );
1897 a === b && ( a = ! 1 ), this.enable( ! a );
1898 var d = c.prop( 'readonly' );
1899 d === b && ( d = ! 1 ),
1900 this.readonly( d ),
1901 this.container &&
1902 ( D(
1903 this.container,
1904 this.opts.element,
1905 this.opts.adaptContainerCssClass
1906 ),
1907 this.container.addClass(
1908 K(
1909 this.opts.containerCssClass,
1910 this.opts.element
1911 )
1912 ) ),
1913 this.dropdown &&
1914 ( D(
1915 this.dropdown,
1916 this.opts.element,
1917 this.opts.adaptDropdownCssClass
1918 ),
1919 this.dropdown.addClass(
1920 K(
1921 this.opts.dropdownCssClass,
1922 this.opts.element
1923 )
1924 ) );
1925 } ) ),
1926 c.length &&
1927 c[ 0 ].attachEvent &&
1928 c.each( function () {
1929 this.attachEvent(
1930 'onpropertychange',
1931 e._sync
1932 );
1933 } ),
1934 ( d =
1935 window.MutationObserver ||
1936 window.WebKitMutationObserver ||
1937 window.MozMutationObserver ),
1938 d !== b &&
1939 ( this.propertyObserver &&
1940 ( delete this.propertyObserver,
1941 ( this.propertyObserver = null ) ),
1942 ( this.propertyObserver = new d( function (
1943 b
1944 ) {
1945 a.each( b, e._sync );
1946 } ) ),
1947 this.propertyObserver.observe( c.get( 0 ), {
1948 attributes: ! 0,
1949 subtree: ! 1,
1950 } ) );
1951 },
1952 triggerSelect: function ( b ) {
1953 var c = a.Event( 'select2-selecting', {
1954 val: this.id( b ),
1955 object: b,
1956 choice: b,
1957 } );
1958 return (
1959 this.opts.element.trigger( c ),
1960 ! c.isDefaultPrevented()
1961 );
1962 },
1963 triggerChange: function ( b ) {
1964 ( b = b || {} ),
1965 ( b = a.extend( {}, b, {
1966 type: 'change',
1967 val: this.val(),
1968 } ) ),
1969 this.opts.element.data(
1970 'select2-change-triggered',
1971 ! 0
1972 ),
1973 this.opts.element.trigger( b ),
1974 this.opts.element.data(
1975 'select2-change-triggered',
1976 ! 1
1977 ),
1978 this.opts.element.click(),
1979 this.opts.blurOnChange && this.opts.element.blur();
1980 },
1981 isInterfaceEnabled: function () {
1982 return this.enabledInterface === ! 0;
1983 },
1984 enableInterface: function () {
1985 var a = this._enabled && ! this._readonly,
1986 b = ! a;
1987 return a === this.enabledInterface
1988 ? ! 1
1989 : ( this.container.toggleClass(
1990 'select2-container-disabled',
1991 b
1992 ),
1993 this.close(),
1994 ( this.enabledInterface = a ),
1995 ! 0 );
1996 },
1997 enable: function ( a ) {
1998 a === b && ( a = ! 0 ),
1999 this._enabled !== a &&
2000 ( ( this._enabled = a ),
2001 this.opts.element.prop( 'disabled', ! a ),
2002 this.enableInterface() );
2003 },
2004 disable: function () {
2005 this.enable( ! 1 );
2006 },
2007 readonly: function ( a ) {
2008 a === b && ( a = ! 1 ),
2009 this._readonly !== a &&
2010 ( ( this._readonly = a ),
2011 this.opts.element.prop( 'readonly', a ),
2012 this.enableInterface() );
2013 },
2014 opened: function () {
2015 return this.container
2016 ? this.container.hasClass( 'select2-dropdown-open' )
2017 : ! 1;
2018 },
2019 positionDropdown: function () {
2020 var v,
2021 w,
2022 x,
2023 y,
2024 z,
2025 b = this.dropdown,
2026 c = this.container,
2027 d = c.offset(),
2028 e = c.outerHeight( ! 1 ),
2029 f = c.outerWidth( ! 1 ),
2030 g = b.outerHeight( ! 1 ),
2031 h = a( window ),
2032 i = h.width(),
2033 k = h.height(),
2034 l = h.scrollLeft() + i,
2035 m = h.scrollTop() + k,
2036 n = d.top + e,
2037 o = d.left,
2038 p = m >= n + g,
2039 q = d.top - g >= h.scrollTop(),
2040 r = b.outerWidth( ! 1 ),
2041 s = function () {
2042 return l >= o + r;
2043 },
2044 t = function () {
2045 return d.left + l + c.outerWidth( ! 1 ) > r;
2046 },
2047 u = b.hasClass( 'select2-drop-above' );
2048 u
2049 ? ( ( w = ! 0 ),
2050 ! q && p && ( ( x = ! 0 ), ( w = ! 1 ) ) )
2051 : ( ( w = ! 1 ),
2052 ! p && q && ( ( x = ! 0 ), ( w = ! 0 ) ) ),
2053 x &&
2054 ( b.hide(),
2055 ( d = this.container.offset() ),
2056 ( e = this.container.outerHeight( ! 1 ) ),
2057 ( f = this.container.outerWidth( ! 1 ) ),
2058 ( g = b.outerHeight( ! 1 ) ),
2059 ( l = h.scrollLeft() + i ),
2060 ( m = h.scrollTop() + k ),
2061 ( n = d.top + e ),
2062 ( o = d.left ),
2063 ( r = b.outerWidth( ! 1 ) ),
2064 b.show(),
2065 this.focusSearch() ),
2066 this.opts.dropdownAutoWidth
2067 ? ( ( z = a( '.select2-results', b )[ 0 ] ),
2068 b.addClass( 'select2-drop-auto-width' ),
2069 b.css( 'width', '' ),
2070 ( r =
2071 b.outerWidth( ! 1 ) +
2072 ( z.scrollHeight === z.clientHeight
2073 ? 0
2074 : j.width ) ),
2075 r > f ? ( f = r ) : ( r = f ),
2076 ( g = b.outerHeight( ! 1 ) ) )
2077 : this.container.removeClass(
2078 'select2-drop-auto-width'
2079 ),
2080 'static' !== this.body.css( 'position' ) &&
2081 ( ( v = this.body.offset() ),
2082 ( n -= v.top ),
2083 ( o -= v.left ) ),
2084 ! s() &&
2085 t() &&
2086 ( o =
2087 d.left +
2088 this.container.outerWidth( ! 1 ) -
2089 r ),
2090 ( y = { left: o, width: f } ),
2091 w
2092 ? ( ( y.top = d.top - g ),
2093 ( y.bottom = 'auto' ),
2094 this.container.addClass(
2095 'select2-drop-above'
2096 ),
2097 b.addClass( 'select2-drop-above' ) )
2098 : ( ( y.top = n ),
2099 ( y.bottom = 'auto' ),
2100 this.container.removeClass(
2101 'select2-drop-above'
2102 ),
2103 b.removeClass( 'select2-drop-above' ) ),
2104 ( y = a.extend(
2105 y,
2106 K( this.opts.dropdownCss, this.opts.element )
2107 ) ),
2108 b.css( y );
2109 },
2110 shouldOpen: function () {
2111 var b;
2112 return this.opened()
2113 ? ! 1
2114 : this._enabled === ! 1 || this._readonly === ! 0
2115 ? ! 1
2116 : ( ( b = a.Event( 'select2-opening' ) ),
2117 this.opts.element.trigger( b ),
2118 ! b.isDefaultPrevented() );
2119 },
2120 clearDropdownAlignmentPreference: function () {
2121 this.container.removeClass( 'select2-drop-above' ),
2122 this.dropdown.removeClass( 'select2-drop-above' );
2123 },
2124 open: function () {
2125 return this.shouldOpen()
2126 ? ( this.opening(),
2127 i.on( 'mousemove.select2Event', function ( a ) {
2128 ( h.x = a.pageX ), ( h.y = a.pageY );
2129 } ),
2130 ! 0 )
2131 : ! 1;
2132 },
2133 opening: function () {
2134 var f,
2135 b = this.containerEventName,
2136 c = 'scroll.' + b,
2137 d = 'resize.' + b,
2138 e = 'orientationchange.' + b;
2139 this.container
2140 .addClass( 'select2-dropdown-open' )
2141 .addClass( 'select2-container-active' ),
2142 this.clearDropdownAlignmentPreference(),
2143 this.dropdown[ 0 ] !==
2144 this.body.children().last()[ 0 ] &&
2145 this.dropdown.detach().appendTo( this.body ),
2146 ( f = a( '#select2-drop-mask' ) ),
2147 0 === f.length &&
2148 ( ( f = a( document.createElement( 'div' ) ) ),
2149 f
2150 .attr( 'id', 'select2-drop-mask' )
2151 .attr( 'class', 'select2-drop-mask' ),
2152 f.hide(),
2153 f.appendTo( this.body ),
2154 f.on(
2155 'mousedown touchstart click',
2156 function ( b ) {
2157 n( f );
2158 var d,
2159 c = a( '#select2-drop' );
2160 c.length > 0 &&
2161 ( ( d = c.data( 'select2' ) ),
2162 d.opts.selectOnBlur &&
2163 d.selectHighlighted( {
2164 noFocus: ! 0,
2165 } ),
2166 d.close(),
2167 b.preventDefault(),
2168 b.stopPropagation() );
2169 }
2170 ) ),
2171 this.dropdown.prev()[ 0 ] !== f[ 0 ] &&
2172 this.dropdown.before( f ),
2173 a( '#select2-drop' ).removeAttr( 'id' ),
2174 this.dropdown.attr( 'id', 'select2-drop' ),
2175 f.show(),
2176 this.positionDropdown(),
2177 this.dropdown.show(),
2178 this.positionDropdown(),
2179 this.dropdown.addClass( 'select2-drop-active' );
2180 var g = this;
2181 this.container
2182 .parents()
2183 .add( window )
2184 .each( function () {
2185 a( this ).on(
2186 d + ' ' + c + ' ' + e,
2187 function () {
2188 g.opened() && g.positionDropdown();
2189 }
2190 );
2191 } );
2192 },
2193 close: function () {
2194 if ( this.opened() ) {
2195 var b = this.containerEventName,
2196 c = 'scroll.' + b,
2197 d = 'resize.' + b,
2198 e = 'orientationchange.' + b;
2199 this.container
2200 .parents()
2201 .add( window )
2202 .each( function () {
2203 a( this ).off( c ).off( d ).off( e );
2204 } ),
2205 this.clearDropdownAlignmentPreference(),
2206 a( '#select2-drop-mask' ).hide(),
2207 this.dropdown.removeAttr( 'id' ),
2208 this.dropdown.hide(),
2209 this.container
2210 .removeClass( 'select2-dropdown-open' )
2211 .removeClass( 'select2-container-active' ),
2212 this.results.empty(),
2213 i.off( 'mousemove.select2Event' ),
2214 this.clearSearch(),
2215 this.search.removeClass( 'select2-active' ),
2216 this.opts.element.trigger(
2217 a.Event( 'select2-close' )
2218 );
2219 }
2220 },
2221 externalSearch: function ( a ) {
2222 this.open(),
2223 this.search.val( a ),
2224 this.updateResults( ! 1 );
2225 },
2226 clearSearch: function () {},
2227 getMaximumSelectionSize: function () {
2228 return K(
2229 this.opts.maximumSelectionSize,
2230 this.opts.element
2231 );
2232 },
2233 ensureHighlightVisible: function () {
2234 var c,
2235 d,
2236 e,
2237 f,
2238 g,
2239 h,
2240 i,
2241 j,
2242 b = this.results;
2243 if ( ( ( d = this.highlight() ), ! ( 0 > d ) ) ) {
2244 if ( 0 == d ) return b.scrollTop( 0 ), void 0;
2245 ( c = this.findHighlightableChoices().find(
2246 '.select2-result-label'
2247 ) ),
2248 ( e = a( c[ d ] ) ),
2249 ( j = ( e.offset() || {} ).top || 0 ),
2250 ( f = j + e.outerHeight( ! 0 ) ),
2251 d === c.length - 1 &&
2252 ( ( i = b.find(
2253 'li.select2-more-results'
2254 ) ),
2255 i.length > 0 &&
2256 ( f =
2257 i.offset().top +
2258 i.outerHeight( ! 0 ) ) ),
2259 ( g = b.offset().top + b.outerHeight( ! 1 ) ),
2260 f > g &&
2261 b.scrollTop( b.scrollTop() + ( f - g ) ),
2262 ( h = j - b.offset().top ),
2263 0 > h &&
2264 'none' != e.css( 'display' ) &&
2265 b.scrollTop( b.scrollTop() + h );
2266 }
2267 },
2268 findHighlightableChoices: function () {
2269 return this.results.find(
2270 '.select2-result-selectable:not(.select2-disabled):not(.select2-selected)'
2271 );
2272 },
2273 moveHighlight: function ( b ) {
2274 for (
2275 var c = this.findHighlightableChoices(),
2276 d = this.highlight();
2277 d > -1 && d < c.length;
2278
2279 ) {
2280 d += b;
2281 var e = a( c[ d ] );
2282 if (
2283 e.hasClass( 'select2-result-selectable' ) &&
2284 ! e.hasClass( 'select2-disabled' ) &&
2285 ! e.hasClass( 'select2-selected' )
2286 ) {
2287 this.highlight( d );
2288 break;
2289 }
2290 }
2291 },
2292 highlight: function ( b ) {
2293 var d,
2294 e,
2295 c = this.findHighlightableChoices();
2296 return 0 === arguments.length
2297 ? p(
2298 c.filter( '.select2-highlighted' )[ 0 ],
2299 c.get()
2300 )
2301 : ( b >= c.length && ( b = c.length - 1 ),
2302 0 > b && ( b = 0 ),
2303 this.removeHighlight(),
2304 ( d = a( c[ b ] ) ),
2305 d.addClass( 'select2-highlighted' ),
2306 this.search.attr(
2307 'aria-activedescendant',
2308 d
2309 .find( '.select2-result-label' )
2310 .attr( 'id' )
2311 ),
2312 this.ensureHighlightVisible(),
2313 this.liveRegion.text( d.text() ),
2314 ( e = d.data( 'select2-data' ) ),
2315 e &&
2316 this.opts.element.trigger( {
2317 type: 'select2-highlight',
2318 val: this.id( e ),
2319 choice: e,
2320 } ),
2321 void 0 );
2322 },
2323 removeHighlight: function () {
2324 this.results
2325 .find( '.select2-highlighted' )
2326 .removeClass( 'select2-highlighted' );
2327 },
2328 touchMoved: function () {
2329 this._touchMoved = ! 0;
2330 },
2331 clearTouchMoved: function () {
2332 this._touchMoved = ! 1;
2333 },
2334 countSelectableResults: function () {
2335 return this.findHighlightableChoices().length;
2336 },
2337 highlightUnderEvent: function ( b ) {
2338 var c = a( b.target ).closest(
2339 '.select2-result-selectable'
2340 );
2341 if (
2342 c.length > 0 &&
2343 ! c.is( '.select2-highlighted' )
2344 ) {
2345 var d = this.findHighlightableChoices();
2346 this.highlight( d.index( c ) );
2347 } else 0 == c.length && this.removeHighlight();
2348 },
2349 loadMoreIfNeeded: function () {
2350 var c,
2351 a = this.results,
2352 b = a.find( 'li.select2-more-results' ),
2353 d = this.resultsPage + 1,
2354 e = this,
2355 f = this.search.val(),
2356 g = this.context;
2357 0 !== b.length &&
2358 ( ( c =
2359 b.offset().top - a.offset().top - a.height() ),
2360 c <= this.opts.loadMorePadding &&
2361 ( b.addClass( 'select2-active' ),
2362 this.opts.query( {
2363 element: this.opts.element,
2364 term: f,
2365 page: d,
2366 context: g,
2367 matcher: this.opts.matcher,
2368 callback: this.bind( function ( c ) {
2369 e.opened() &&
2370 ( e.opts.populateResults.call(
2371 this,
2372 a,
2373 c.results,
2374 { term: f, page: d, context: g }
2375 ),
2376 e.postprocessResults( c, ! 1, ! 1 ),
2377 c.more === ! 0
2378 ? ( b
2379 .detach()
2380 .appendTo( a )
2381 .html(
2382 e.opts.escapeMarkup(
2383 K(
2384 e.opts
2385 .formatLoadMore,
2386 e.opts
2387 .element,
2388 d + 1
2389 )
2390 )
2391 ),
2392 window.setTimeout(
2393 function () {
2394 e.loadMoreIfNeeded();
2395 },
2396 10
2397 ) )
2398 : b.remove(),
2399 e.positionDropdown(),
2400 ( e.resultsPage = d ),
2401 ( e.context = c.context ),
2402 this.opts.element.trigger( {
2403 type: 'select2-loaded',
2404 items: c,
2405 } ) );
2406 } ),
2407 } ) ) );
2408 },
2409 tokenize: function () {},
2410 updateResults: function ( c ) {
2411 function m() {
2412 d.removeClass( 'select2-active' ),
2413 h.positionDropdown(),
2414 e.find(
2415 '.select2-no-results,.select2-selection-limit,.select2-searching'
2416 ).length
2417 ? h.liveRegion.text( e.text() )
2418 : h.liveRegion.text(
2419 h.opts.formatMatches(
2420 e.find(
2421 '.select2-result-selectable:not(".select2-selected")'
2422 ).length
2423 )
2424 );
2425 }
2426 function n( a ) {
2427 e.html( a ), m();
2428 }
2429 var g,
2430 i,
2431 l,
2432 d = this.search,
2433 e = this.results,
2434 f = this.opts,
2435 h = this,
2436 j = d.val(),
2437 k = a.data( this.container, 'select2-last-term' );
2438 if (
2439 ( c === ! 0 || ! k || ! r( j, k ) ) &&
2440 ( a.data( this.container, 'select2-last-term', j ),
2441 c === ! 0 ||
2442 ( this.showSearchInput !== ! 1 &&
2443 this.opened() ) )
2444 ) {
2445 l = ++this.queryCount;
2446 var o = this.getMaximumSelectionSize();
2447 if (
2448 o >= 1 &&
2449 ( ( g = this.data() ),
2450 a.isArray( g ) &&
2451 g.length >= o &&
2452 J(
2453 f.formatSelectionTooBig,
2454 'formatSelectionTooBig'
2455 ) )
2456 )
2457 return (
2458 n(
2459 "<li class='select2-selection-limit'>" +
2460 K(
2461 f.formatSelectionTooBig,
2462 f.element,
2463 o
2464 ) +
2465 '</li>'
2466 ),
2467 void 0
2468 );
2469 if ( d.val().length < f.minimumInputLength )
2470 return (
2471 J(
2472 f.formatInputTooShort,
2473 'formatInputTooShort'
2474 )
2475 ? n(
2476 "<li class='select2-no-results'>" +
2477 K(
2478 f.formatInputTooShort,
2479 f.element,
2480 d.val(),
2481 f.minimumInputLength
2482 ) +
2483 '</li>'
2484 )
2485 : n( '' ),
2486 c &&
2487 this.showSearch &&
2488 this.showSearch( ! 0 ),
2489 void 0
2490 );
2491 if (
2492 f.maximumInputLength &&
2493 d.val().length > f.maximumInputLength
2494 )
2495 return (
2496 J(
2497 f.formatInputTooLong,
2498 'formatInputTooLong'
2499 )
2500 ? n(
2501 "<li class='select2-no-results'>" +
2502 K(
2503 f.formatInputTooLong,
2504 f.element,
2505 d.val(),
2506 f.maximumInputLength
2507 ) +
2508 '</li>'
2509 )
2510 : n( '' ),
2511 void 0
2512 );
2513 f.formatSearching &&
2514 0 === this.findHighlightableChoices().length &&
2515 n(
2516 "<li class='select2-searching'>" +
2517 K( f.formatSearching, f.element ) +
2518 '</li>'
2519 ),
2520 d.addClass( 'select2-active' ),
2521 this.removeHighlight(),
2522 ( i = this.tokenize() ),
2523 i != b && null != i && d.val( i ),
2524 ( this.resultsPage = 1 ),
2525 f.query( {
2526 element: f.element,
2527 term: d.val(),
2528 page: this.resultsPage,
2529 context: null,
2530 matcher: f.matcher,
2531 callback: this.bind( function ( g ) {
2532 var i;
2533 if ( l == this.queryCount ) {
2534 if ( ! this.opened() )
2535 return (
2536 this.search.removeClass(
2537 'select2-active'
2538 ),
2539 void 0
2540 );
2541 if (
2542 g.hasError !== b &&
2543 J(
2544 f.formatAjaxError,
2545 'formatAjaxError'
2546 )
2547 )
2548 return (
2549 n(
2550 "<li class='select2-ajax-error'>" +
2551 K(
2552 f.formatAjaxError,
2553 f.element,
2554 g.jqXHR,
2555 g.textStatus,
2556 g.errorThrown
2557 ) +
2558 '</li>'
2559 ),
2560 void 0
2561 );
2562 if (
2563 ( ( this.context =
2564 g.context === b
2565 ? null
2566 : g.context ),
2567 this.opts.createSearchChoice &&
2568 '' !== d.val() &&
2569 ( ( i = this.opts.createSearchChoice.call(
2570 h,
2571 d.val(),
2572 g.results
2573 ) ),
2574 i !== b &&
2575 null !== i &&
2576 h.id( i ) !== b &&
2577 null !== h.id( i ) &&
2578 0 ===
2579 a(
2580 g.results
2581 ).filter(
2582 function () {
2583 return r(
2584 h.id(
2585 this
2586 ),
2587 h.id(
2588 i
2589 )
2590 );
2591 }
2592 ).length &&
2593 this.opts.createSearchChoicePosition(
2594 g.results,
2595 i
2596 ) ),
2597 0 === g.results.length &&
2598 J(
2599 f.formatNoMatches,
2600 'formatNoMatches'
2601 ) )
2602 )
2603 return (
2604 n(
2605 "<li class='select2-no-results'>" +
2606 K(
2607 f.formatNoMatches,
2608 f.element,
2609 d.val()
2610 ) +
2611 '</li>'
2612 ),
2613 void 0
2614 );
2615 e.empty(),
2616 h.opts.populateResults.call(
2617 this,
2618 e,
2619 g.results,
2620 {
2621 term: d.val(),
2622 page: this.resultsPage,
2623 context: null,
2624 }
2625 ),
2626 g.more === ! 0 &&
2627 J(
2628 f.formatLoadMore,
2629 'formatLoadMore'
2630 ) &&
2631 ( e.append(
2632 "<li class='select2-more-results'>" +
2633 f.escapeMarkup(
2634 K(
2635 f.formatLoadMore,
2636 f.element,
2637 this
2638 .resultsPage
2639 )
2640 ) +
2641 '</li>'
2642 ),
2643 window.setTimeout(
2644 function () {
2645 h.loadMoreIfNeeded();
2646 },
2647 10
2648 ) ),
2649 this.postprocessResults( g, c ),
2650 m(),
2651 this.opts.element.trigger( {
2652 type: 'select2-loaded',
2653 items: g,
2654 } );
2655 }
2656 } ),
2657 } );
2658 }
2659 },
2660 cancel: function () {
2661 this.close();
2662 },
2663 blur: function () {
2664 this.opts.selectOnBlur &&
2665 this.selectHighlighted( { noFocus: ! 0 } ),
2666 this.close(),
2667 this.container.removeClass(
2668 'select2-container-active'
2669 ),
2670 this.search[ 0 ] === document.activeElement &&
2671 this.search.blur(),
2672 this.clearSearch(),
2673 this.selection
2674 .find( '.select2-search-choice-focus' )
2675 .removeClass( 'select2-search-choice-focus' );
2676 },
2677 focusSearch: function () {
2678 y( this.search );
2679 },
2680 selectHighlighted: function ( a ) {
2681 if ( this._touchMoved )
2682 return this.clearTouchMoved(), void 0;
2683 var b = this.highlight(),
2684 c = this.results.find( '.select2-highlighted' ),
2685 d = c
2686 .closest( '.select2-result' )
2687 .data( 'select2-data' );
2688 d
2689 ? ( this.highlight( b ), this.onSelect( d, a ) )
2690 : a && a.noFocus && this.close();
2691 },
2692 getPlaceholder: function () {
2693 var a;
2694 return (
2695 this.opts.element.attr( 'placeholder' ) ||
2696 this.opts.element.attr( 'data-placeholder' ) ||
2697 this.opts.element.data( 'placeholder' ) ||
2698 this.opts.placeholder ||
2699 ( ( a = this.getPlaceholderOption() ) !== b
2700 ? a.text()
2701 : b )
2702 );
2703 },
2704 getPlaceholderOption: function () {
2705 if ( this.select ) {
2706 var c = this.select.children( 'option' ).first();
2707 if ( this.opts.placeholderOption !== b )
2708 return (
2709 ( 'first' === this.opts.placeholderOption &&
2710 c ) ||
2711 ( 'function' ==
2712 typeof this.opts.placeholderOption &&
2713 this.opts.placeholderOption(
2714 this.select
2715 ) )
2716 );
2717 if ( '' === a.trim( c.text() ) && '' === c.val() )
2718 return c;
2719 }
2720 },
2721 initContainerWidth: function () {
2722 function c() {
2723 var c, d, e, f, g, h;
2724 if ( 'off' === this.opts.width ) return null;
2725 if ( 'element' === this.opts.width )
2726 return 0 === this.opts.element.outerWidth( ! 1 )
2727 ? 'auto'
2728 : this.opts.element.outerWidth( ! 1 ) +
2729 'px';
2730 if (
2731 'copy' === this.opts.width ||
2732 'resolve' === this.opts.width
2733 ) {
2734 if (
2735 ( ( c = this.opts.element.attr( 'style' ) ),
2736 c !== b )
2737 )
2738 for (
2739 d = c.split( ';' ), f = 0, g = d.length;
2740 g > f;
2741 f += 1
2742 )
2743 if (
2744 ( ( h = d[ f ].replace(
2745 /\s/g,
2746 ''
2747 ) ),
2748 ( e = h.match(
2749 /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i
2750 ) ),
2751 null !== e && e.length >= 1 )
2752 )
2753 return e[ 1 ];
2754 return 'resolve' === this.opts.width
2755 ? ( ( c = this.opts.element.css(
2756 'width'
2757 ) ),
2758 c.indexOf( '%' ) > 0
2759 ? c
2760 : 0 ===
2761 this.opts.element.outerWidth(
2762 ! 1
2763 )
2764 ? 'auto'
2765 : this.opts.element.outerWidth(
2766 ! 1
2767 ) + 'px' )
2768 : null;
2769 }
2770 return a.isFunction( this.opts.width )
2771 ? this.opts.width()
2772 : this.opts.width;
2773 }
2774 var d = c.call( this );
2775 null !== d && this.container.css( 'width', d );
2776 },
2777 } ) ),
2778 ( d = O( c, {
2779 createContainer: function () {
2780 var b = a( document.createElement( 'div' ) )
2781 .attr( { class: 'select2-container' } )
2782 .html(
2783 [
2784 "<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>",
2785 " <span class='select2-chosen'>&#160;</span><abbr class='select2-search-choice-close'></abbr>",
2786 " <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>",
2787 '</a>',
2788 "<label for='' class='select2-offscreen'></label>",
2789 "<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />",
2790 "<div class='select2-drop select2-display-none'>",
2791 " <div class='select2-search'>",
2792 " <label for='' class='select2-offscreen'></label>",
2793 " <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'",
2794 " aria-autocomplete='list' />",
2795 ' </div>',
2796 " <ul class='select2-results' role='listbox'>",
2797 ' </ul>',
2798 '</div>',
2799 ].join( '' )
2800 );
2801 return b;
2802 },
2803 enableInterface: function () {
2804 this.parent.enableInterface.apply( this, arguments ) &&
2805 this.focusser.prop(
2806 'disabled',
2807 ! this.isInterfaceEnabled()
2808 );
2809 },
2810 opening: function () {
2811 var c, d, e;
2812 this.opts.minimumResultsForSearch >= 0 &&
2813 this.showSearch( ! 0 ),
2814 this.parent.opening.apply( this, arguments ),
2815 this.showSearchInput !== ! 1 &&
2816 this.search.val( this.focusser.val() ),
2817 this.opts.shouldFocusInput( this ) &&
2818 ( this.search.focus(),
2819 ( c = this.search.get( 0 ) ),
2820 c.createTextRange
2821 ? ( ( d = c.createTextRange() ),
2822 d.collapse( ! 1 ),
2823 d.select() )
2824 : c.setSelectionRange &&
2825 ( ( e = this.search.val().length ),
2826 c.setSelectionRange( e, e ) ) ),
2827 '' === this.search.val() &&
2828 this.nextSearchTerm != b &&
2829 ( this.search.val( this.nextSearchTerm ),
2830 this.search.select() ),
2831 this.focusser.prop( 'disabled', ! 0 ).val( '' ),
2832 this.updateResults( ! 0 ),
2833 this.opts.element.trigger(
2834 a.Event( 'select2-open' )
2835 );
2836 },
2837 close: function () {
2838 this.opened() &&
2839 ( this.parent.close.apply( this, arguments ),
2840 this.focusser.prop( 'disabled', ! 1 ),
2841 this.opts.shouldFocusInput( this ) &&
2842 this.focusser.focus() );
2843 },
2844 focus: function () {
2845 this.opened()
2846 ? this.close()
2847 : ( this.focusser.prop( 'disabled', ! 1 ),
2848 this.opts.shouldFocusInput( this ) &&
2849 this.focusser.focus() );
2850 },
2851 isFocused: function () {
2852 return this.container.hasClass(
2853 'select2-container-active'
2854 );
2855 },
2856 cancel: function () {
2857 this.parent.cancel.apply( this, arguments ),
2858 this.focusser.prop( 'disabled', ! 1 ),
2859 this.opts.shouldFocusInput( this ) &&
2860 this.focusser.focus();
2861 },
2862 destroy: function () {
2863 a(
2864 "label[for='" + this.focusser.attr( 'id' ) + "']"
2865 ).attr( 'for', this.opts.element.attr( 'id' ) ),
2866 this.parent.destroy.apply( this, arguments ),
2867 N.call( this, 'selection', 'focusser' );
2868 },
2869 initContainer: function () {
2870 var b,
2871 g,
2872 c = this.container,
2873 d = this.dropdown,
2874 e = f();
2875 this.opts.minimumResultsForSearch < 0
2876 ? this.showSearch( ! 1 )
2877 : this.showSearch( ! 0 ),
2878 ( this.selection = b = c.find(
2879 '.select2-choice'
2880 ) ),
2881 ( this.focusser = c.find( '.select2-focusser' ) ),
2882 b
2883 .find( '.select2-chosen' )
2884 .attr( 'id', 'select2-chosen-' + e ),
2885 this.focusser.attr(
2886 'aria-labelledby',
2887 'select2-chosen-' + e
2888 ),
2889 this.results.attr( 'id', 'select2-results-' + e ),
2890 this.search.attr(
2891 'aria-owns',
2892 'select2-results-' + e
2893 ),
2894 this.focusser.attr( 'id', 's2id_autogen' + e ),
2895 ( g = a(
2896 "label[for='" +
2897 this.opts.element.attr( 'id' ) +
2898 "']"
2899 ) ),
2900 this.opts.element.focus(
2901 this.bind( function () {
2902 this.focus();
2903 } )
2904 ),
2905 this.focusser
2906 .prev()
2907 .text( g.text() )
2908 .attr( 'for', this.focusser.attr( 'id' ) );
2909 var h = this.opts.element.attr( 'title' );
2910 this.opts.element.attr( 'title', h || g.text() ),
2911 this.focusser.attr(
2912 'tabindex',
2913 this.elementTabIndex
2914 ),
2915 this.search.attr(
2916 'id',
2917 this.focusser.attr( 'id' ) + '_search'
2918 ),
2919 this.search
2920 .prev()
2921 .text(
2922 a(
2923 "label[for='" +
2924 this.focusser.attr( 'id' ) +
2925 "']"
2926 ).text()
2927 )
2928 .attr( 'for', this.search.attr( 'id' ) ),
2929 this.search.on(
2930 'keydown',
2931 this.bind( function ( a ) {
2932 if (
2933 this.isInterfaceEnabled() &&
2934 229 != a.keyCode
2935 ) {
2936 if (
2937 a.which === k.PAGE_UP ||
2938 a.which === k.PAGE_DOWN
2939 )
2940 return A( a ), void 0;
2941 switch ( a.which ) {
2942 case k.UP:
2943 case k.DOWN:
2944 return (
2945 this.moveHighlight(
2946 a.which === k.UP
2947 ? -1
2948 : 1
2949 ),
2950 A( a ),
2951 void 0
2952 );
2953 case k.ENTER:
2954 return (
2955 this.selectHighlighted(),
2956 A( a ),
2957 void 0
2958 );
2959 case k.TAB:
2960 return (
2961 this.selectHighlighted( {
2962 noFocus: ! 0,
2963 } ),
2964 void 0
2965 );
2966 case k.ESC:
2967 return (
2968 this.cancel( a ),
2969 A( a ),
2970 void 0
2971 );
2972 }
2973 }
2974 } )
2975 ),
2976 this.search.on(
2977 'blur',
2978 this.bind( function () {
2979 document.activeElement ===
2980 this.body.get( 0 ) &&
2981 window.setTimeout(
2982 this.bind( function () {
2983 this.opened() &&
2984 this.search.focus();
2985 } ),
2986 0
2987 );
2988 } )
2989 ),
2990 this.focusser.on(
2991 'keydown',
2992 this.bind( function ( a ) {
2993 if (
2994 this.isInterfaceEnabled() &&
2995 a.which !== k.TAB &&
2996 ! k.isControl( a ) &&
2997 ! k.isFunctionKey( a ) &&
2998 a.which !== k.ESC
2999 ) {
3000 if (
3001 this.opts.openOnEnter === ! 1 &&
3002 a.which === k.ENTER
3003 )
3004 return A( a ), void 0;
3005 if (
3006 a.which == k.DOWN ||
3007 a.which == k.UP ||
3008 ( a.which == k.ENTER &&
3009 this.opts.openOnEnter )
3010 ) {
3011 if (
3012 a.altKey ||
3013 a.ctrlKey ||
3014 a.shiftKey ||
3015 a.metaKey
3016 )
3017 return;
3018 return this.open(), A( a ), void 0;
3019 }
3020 return a.which == k.DELETE ||
3021 a.which == k.BACKSPACE
3022 ? ( this.opts.allowClear &&
3023 this.clear(),
3024 A( a ),
3025 void 0 )
3026 : void 0;
3027 }
3028 } )
3029 ),
3030 u( this.focusser ),
3031 this.focusser.on(
3032 'keyup-change input',
3033 this.bind( function ( a ) {
3034 if (
3035 this.opts.minimumResultsForSearch >= 0
3036 ) {
3037 if (
3038 ( a.stopPropagation(),
3039 this.opened() )
3040 )
3041 return;
3042 this.open();
3043 }
3044 } )
3045 ),
3046 b.on(
3047 'mousedown touchstart',
3048 'abbr',
3049 this.bind( function ( a ) {
3050 this.isInterfaceEnabled() &&
3051 ( this.clear(),
3052 B( a ),
3053 this.close(),
3054 this.selection &&
3055 this.selection.focus() );
3056 } )
3057 ),
3058 b.on(
3059 'mousedown touchstart',
3060 this.bind( function ( c ) {
3061 n( b ),
3062 this.container.hasClass(
3063 'select2-container-active'
3064 ) ||
3065 this.opts.element.trigger(
3066 a.Event( 'select2-focus' )
3067 ),
3068 this.opened()
3069 ? this.close()
3070 : this.isInterfaceEnabled() &&
3071 this.open(),
3072 A( c );
3073 } )
3074 ),
3075 d.on(
3076 'mousedown touchstart',
3077 this.bind( function () {
3078 this.opts.shouldFocusInput( this ) &&
3079 this.search.focus();
3080 } )
3081 ),
3082 b.on(
3083 'focus',
3084 this.bind( function ( a ) {
3085 A( a );
3086 } )
3087 ),
3088 this.focusser
3089 .on(
3090 'focus',
3091 this.bind( function () {
3092 this.container.hasClass(
3093 'select2-container-active'
3094 ) ||
3095 this.opts.element.trigger(
3096 a.Event( 'select2-focus' )
3097 ),
3098 this.container.addClass(
3099 'select2-container-active'
3100 );
3101 } )
3102 )
3103 .on(
3104 'blur',
3105 this.bind( function () {
3106 this.opened() ||
3107 ( this.container.removeClass(
3108 'select2-container-active'
3109 ),
3110 this.opts.element.trigger(
3111 a.Event( 'select2-blur' )
3112 ) );
3113 } )
3114 ),
3115 this.search.on(
3116 'focus',
3117 this.bind( function () {
3118 this.container.hasClass(
3119 'select2-container-active'
3120 ) ||
3121 this.opts.element.trigger(
3122 a.Event( 'select2-focus' )
3123 ),
3124 this.container.addClass(
3125 'select2-container-active'
3126 );
3127 } )
3128 ),
3129 this.initContainerWidth(),
3130 this.opts.element.hide(),
3131 this.setPlaceholder();
3132 },
3133 clear: function ( b ) {
3134 var c = this.selection.data( 'select2-data' );
3135 if ( c ) {
3136 var d = a.Event( 'select2-clearing' );
3137 if (
3138 ( this.opts.element.trigger( d ),
3139 d.isDefaultPrevented() )
3140 )
3141 return;
3142 var e = this.getPlaceholderOption();
3143 this.opts.element.val( e ? e.val() : '' ),
3144 this.selection
3145 .find( '.select2-chosen' )
3146 .empty(),
3147 this.selection.removeData( 'select2-data' ),
3148 this.setPlaceholder(),
3149 b !== ! 1 &&
3150 ( this.opts.element.trigger( {
3151 type: 'select2-removed',
3152 val: this.id( c ),
3153 choice: c,
3154 } ),
3155 this.triggerChange( { removed: c } ) );
3156 }
3157 },
3158 initSelection: function () {
3159 if ( this.isPlaceholderOptionSelected() )
3160 this.updateSelection( null ),
3161 this.close(),
3162 this.setPlaceholder();
3163 else {
3164 var c = this;
3165 this.opts.initSelection.call(
3166 null,
3167 this.opts.element,
3168 function ( a ) {
3169 a !== b &&
3170 null !== a &&
3171 ( c.updateSelection( a ),
3172 c.close(),
3173 c.setPlaceholder(),
3174 ( c.nextSearchTerm = c.opts.nextSearchTerm(
3175 a,
3176 c.search.val()
3177 ) ) );
3178 }
3179 );
3180 }
3181 },
3182 isPlaceholderOptionSelected: function () {
3183 var a;
3184 return this.getPlaceholder() === b
3185 ? ! 1
3186 : ( ( a = this.getPlaceholderOption() ) !== b &&
3187 a.prop( 'selected' ) ) ||
3188 '' === this.opts.element.val() ||
3189 this.opts.element.val() === b ||
3190 null === this.opts.element.val();
3191 },
3192 prepareOpts: function () {
3193 var b = this.parent.prepareOpts.apply(
3194 this,
3195 arguments
3196 ),
3197 c = this;
3198 return (
3199 'select' ===
3200 b.element.get( 0 ).tagName.toLowerCase()
3201 ? ( b.initSelection = function ( a, b ) {
3202 var d = a
3203 .find( 'option' )
3204 .filter( function () {
3205 return (
3206 this.selected &&
3207 ! this.disabled
3208 );
3209 } );
3210 b( c.optionToData( d ) );
3211 } )
3212 : 'data' in b &&
3213 ( b.initSelection =
3214 b.initSelection ||
3215 function ( c, d ) {
3216 var e = c.val(),
3217 f = null;
3218 b.query( {
3219 matcher: function ( a, c, d ) {
3220 var g = r( e, b.id( d ) );
3221 return g && ( f = d ), g;
3222 },
3223 callback: a.isFunction( d )
3224 ? function () {
3225 d( f );
3226 }
3227 : a.noop,
3228 } );
3229 } ),
3230 b
3231 );
3232 },
3233 getPlaceholder: function () {
3234 return this.select && this.getPlaceholderOption() === b
3235 ? b
3236 : this.parent.getPlaceholder.apply(
3237 this,
3238 arguments
3239 );
3240 },
3241 setPlaceholder: function () {
3242 var a = this.getPlaceholder();
3243 if ( this.isPlaceholderOptionSelected() && a !== b ) {
3244 if (
3245 this.select &&
3246 this.getPlaceholderOption() === b
3247 )
3248 return;
3249 this.selection
3250 .find( '.select2-chosen' )
3251 .html( this.opts.escapeMarkup( a ) ),
3252 this.selection.addClass( 'select2-default' ),
3253 this.container.removeClass(
3254 'select2-allowclear'
3255 );
3256 }
3257 },
3258 postprocessResults: function ( a, b, c ) {
3259 var d = 0,
3260 e = this;
3261 if (
3262 ( this.findHighlightableChoices().each2( function (
3263 a,
3264 b
3265 ) {
3266 return r(
3267 e.id( b.data( 'select2-data' ) ),
3268 e.opts.element.val()
3269 )
3270 ? ( ( d = a ), ! 1 )
3271 : void 0;
3272 } ),
3273 c !== ! 1 &&
3274 ( b === ! 0 && d >= 0
3275 ? this.highlight( d )
3276 : this.highlight( 0 ) ),
3277 b === ! 0 )
3278 ) {
3279 var g = this.opts.minimumResultsForSearch;
3280 g >= 0 && this.showSearch( L( a.results ) >= g );
3281 }
3282 },
3283 showSearch: function ( b ) {
3284 this.showSearchInput !== b &&
3285 ( ( this.showSearchInput = b ),
3286 this.dropdown
3287 .find( '.select2-search' )
3288 .toggleClass( 'select2-search-hidden', ! b ),
3289 this.dropdown
3290 .find( '.select2-search' )
3291 .toggleClass( 'select2-offscreen', ! b ),
3292 a( this.dropdown, this.container ).toggleClass(
3293 'select2-with-searchbox',
3294 b
3295 ) );
3296 },
3297 onSelect: function ( a, b ) {
3298 if ( this.triggerSelect( a ) ) {
3299 var c = this.opts.element.val(),
3300 d = this.data();
3301 this.opts.element.val( this.id( a ) ),
3302 this.updateSelection( a ),
3303 this.opts.element.trigger( {
3304 type: 'select2-selected',
3305 val: this.id( a ),
3306 choice: a,
3307 } ),
3308 ( this.nextSearchTerm = this.opts.nextSearchTerm(
3309 a,
3310 this.search.val()
3311 ) ),
3312 this.close(),
3313 ( b && b.noFocus ) ||
3314 ! this.opts.shouldFocusInput( this ) ||
3315 this.focusser.focus(),
3316 r( c, this.id( a ) ) ||
3317 this.triggerChange( {
3318 added: a,
3319 removed: d,
3320 } );
3321 }
3322 },
3323 updateSelection: function ( a ) {
3324 var d,
3325 e,
3326 c = this.selection.find( '.select2-chosen' );
3327 this.selection.data( 'select2-data', a ),
3328 c.empty(),
3329 null !== a &&
3330 ( d = this.opts.formatSelection(
3331 a,
3332 c,
3333 this.opts.escapeMarkup
3334 ) ),
3335 d !== b && c.append( d ),
3336 ( e = this.opts.formatSelectionCssClass( a, c ) ),
3337 e !== b && c.addClass( e ),
3338 this.selection.removeClass( 'select2-default' ),
3339 this.opts.allowClear &&
3340 this.getPlaceholder() !== b &&
3341 this.container.addClass( 'select2-allowclear' );
3342 },
3343 val: function () {
3344 var a,
3345 c = ! 1,
3346 d = null,
3347 e = this,
3348 f = this.data();
3349 if ( 0 === arguments.length )
3350 return this.opts.element.val();
3351 if (
3352 ( ( a = arguments[ 0 ] ),
3353 arguments.length > 1 && ( c = arguments[ 1 ] ),
3354 this.select )
3355 )
3356 this.select
3357 .val( a )
3358 .find( 'option' )
3359 .filter( function () {
3360 return this.selected;
3361 } )
3362 .each2( function ( a, b ) {
3363 return ( d = e.optionToData( b ) ), ! 1;
3364 } ),
3365 this.updateSelection( d ),
3366 this.setPlaceholder(),
3367 c &&
3368 this.triggerChange( {
3369 added: d,
3370 removed: f,
3371 } );
3372 else {
3373 if ( ! a && 0 !== a )
3374 return this.clear( c ), void 0;
3375 if ( this.opts.initSelection === b )
3376 throw new Error(
3377 'cannot call val() if initSelection() is not defined'
3378 );
3379 this.opts.element.val( a ),
3380 this.opts.initSelection(
3381 this.opts.element,
3382 function ( a ) {
3383 e.opts.element.val(
3384 a ? e.id( a ) : ''
3385 ),
3386 e.updateSelection( a ),
3387 e.setPlaceholder(),
3388 c &&
3389 e.triggerChange( {
3390 added: a,
3391 removed: f,
3392 } );
3393 }
3394 );
3395 }
3396 },
3397 clearSearch: function () {
3398 this.search.val( '' ), this.focusser.val( '' );
3399 },
3400 data: function ( a ) {
3401 var c,
3402 d = ! 1;
3403 return 0 === arguments.length
3404 ? ( ( c = this.selection.data( 'select2-data' ) ),
3405 c == b && ( c = null ),
3406 c )
3407 : ( arguments.length > 1 && ( d = arguments[ 1 ] ),
3408 a
3409 ? ( ( c = this.data() ),
3410 this.opts.element.val(
3411 a ? this.id( a ) : ''
3412 ),
3413 this.updateSelection( a ),
3414 d &&
3415 this.triggerChange( {
3416 added: a,
3417 removed: c,
3418 } ) )
3419 : this.clear( d ),
3420 void 0 );
3421 },
3422 } ) ),
3423 ( e = O( c, {
3424 createContainer: function () {
3425 var b = a( document.createElement( 'div' ) )
3426 .attr( {
3427 class:
3428 'select2-container select2-container-multi',
3429 } )
3430 .html(
3431 [
3432 "<ul class='select2-choices'>",
3433 " <li class='select2-search-field'>",
3434 " <label for='' class='select2-offscreen'></label>",
3435 " <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>",
3436 ' </li>',
3437 '</ul>',
3438 "<div class='select2-drop select2-drop-multi select2-display-none'>",
3439 " <ul class='select2-results'>",
3440 ' </ul>',
3441 '</div>',
3442 ].join( '' )
3443 );
3444 return b;
3445 },
3446 prepareOpts: function () {
3447 var b = this.parent.prepareOpts.apply(
3448 this,
3449 arguments
3450 ),
3451 c = this;
3452 return (
3453 'select' ===
3454 b.element.get( 0 ).tagName.toLowerCase()
3455 ? ( b.initSelection = function ( a, b ) {
3456 var d = [];
3457 a
3458 .find( 'option' )
3459 .filter( function () {
3460 return (
3461 this.selected &&
3462 ! this.disabled
3463 );
3464 } )
3465 .each2( function ( a, b ) {
3466 d.push( c.optionToData( b ) );
3467 } ),
3468 b( d );
3469 } )
3470 : 'data' in b &&
3471 ( b.initSelection =
3472 b.initSelection ||
3473 function ( c, d ) {
3474 var e = s(
3475 c.val(),
3476 b.separator,
3477 b.transformVal
3478 ),
3479 f = [];
3480 b.query( {
3481 matcher: function ( c, d, g ) {
3482 var h = a.grep(
3483 e,
3484 function ( a ) {
3485 return r(
3486 a,
3487 b.id( g )
3488 );
3489 }
3490 ).length;
3491 return h && f.push( g ), h;
3492 },
3493 callback: a.isFunction( d )
3494 ? function () {
3495 for (
3496 var a = [],
3497 c = 0;
3498 c < e.length;
3499 c++
3500 )
3501 for (
3502 var g =
3503 e[
3504 c
3505 ],
3506 h = 0;
3507 h <
3508 f.length;
3509 h++
3510 ) {
3511 var i =
3512 f[ h ];
3513 if (
3514 r(
3515 g,
3516 b.id(
3517 i
3518 )
3519 )
3520 ) {
3521 a.push(
3522 i
3523 ),
3524 f.splice(
3525 h,
3526 1
3527 );
3528 break;
3529 }
3530 }
3531 d( a );
3532 }
3533 : a.noop,
3534 } );
3535 } ),
3536 b
3537 );
3538 },
3539 selectChoice: function ( a ) {
3540 var b = this.container.find(
3541 '.select2-search-choice-focus'
3542 );
3543 ( b.length && a && a[ 0 ] == b[ 0 ] ) ||
3544 ( b.length &&
3545 this.opts.element.trigger(
3546 'choice-deselected',
3547 b
3548 ),
3549 b.removeClass( 'select2-search-choice-focus' ),
3550 a &&
3551 a.length &&
3552 ( this.close(),
3553 a.addClass( 'select2-search-choice-focus' ),
3554 this.opts.element.trigger(
3555 'choice-selected',
3556 a
3557 ) ) );
3558 },
3559 destroy: function () {
3560 a(
3561 "label[for='" + this.search.attr( 'id' ) + "']"
3562 ).attr( 'for', this.opts.element.attr( 'id' ) ),
3563 this.parent.destroy.apply( this, arguments ),
3564 N.call( this, 'searchContainer', 'selection' );
3565 },
3566 initContainer: function () {
3567 var c,
3568 b = '.select2-choices';
3569 ( this.searchContainer = this.container.find(
3570 '.select2-search-field'
3571 ) ),
3572 ( this.selection = c = this.container.find( b ) );
3573 var d = this;
3574 this.selection.on(
3575 'click',
3576 '.select2-container:not(.select2-container-disabled) .select2-search-choice:not(.select2-locked)',
3577 function () {
3578 d.search[ 0 ].focus(),
3579 d.selectChoice( a( this ) );
3580 }
3581 ),
3582 this.search.attr( 'id', 's2id_autogen' + f() ),
3583 this.search
3584 .prev()
3585 .text(
3586 a(
3587 "label[for='" +
3588 this.opts.element.attr( 'id' ) +
3589 "']"
3590 ).text()
3591 )
3592 .attr( 'for', this.search.attr( 'id' ) ),
3593 this.opts.element.focus(
3594 this.bind( function () {
3595 this.focus();
3596 } )
3597 ),
3598 this.search.on(
3599 'input paste',
3600 this.bind( function () {
3601 ( this.search.attr( 'placeholder' ) &&
3602 0 == this.search.val().length ) ||
3603 ( this.isInterfaceEnabled() &&
3604 ( this.opened() || this.open() ) );
3605 } )
3606 ),
3607 this.search.attr(
3608 'tabindex',
3609 this.elementTabIndex
3610 ),
3611 ( this.keydowns = 0 ),
3612 this.search.on(
3613 'keydown',
3614 this.bind( function ( a ) {
3615 if ( this.isInterfaceEnabled() ) {
3616 ++this.keydowns;
3617 var b = c.find(
3618 '.select2-search-choice-focus'
3619 ),
3620 d = b.prev(
3621 '.select2-search-choice:not(.select2-locked)'
3622 ),
3623 e = b.next(
3624 '.select2-search-choice:not(.select2-locked)'
3625 ),
3626 f = z( this.search );
3627 if (
3628 b.length &&
3629 ( a.which == k.LEFT ||
3630 a.which == k.RIGHT ||
3631 a.which == k.BACKSPACE ||
3632 a.which == k.DELETE ||
3633 a.which == k.ENTER )
3634 ) {
3635 var g = b;
3636 return (
3637 a.which == k.LEFT && d.length
3638 ? ( g = d )
3639 : a.which == k.RIGHT
3640 ? ( g = e.length
3641 ? e
3642 : null )
3643 : a.which === k.BACKSPACE
3644 ? this.unselect(
3645 b.first()
3646 ) &&
3647 ( this.search.width( 10 ),
3648 ( g = d.length ? d : e ) )
3649 : a.which == k.DELETE
3650 ? this.unselect(
3651 b.first()
3652 ) &&
3653 ( this.search.width( 10 ),
3654 ( g = e.length
3655 ? e
3656 : null ) )
3657 : a.which == k.ENTER &&
3658 ( g = null ),
3659 this.selectChoice( g ),
3660 A( a ),
3661 ( g && g.length ) ||
3662 this.open(),
3663 void 0
3664 );
3665 }
3666 if (
3667 ( ( a.which === k.BACKSPACE &&
3668 1 == this.keydowns ) ||
3669 a.which == k.LEFT ) &&
3670 0 == f.offset &&
3671 ! f.length
3672 )
3673 return (
3674 this.selectChoice(
3675 c
3676 .find(
3677 '.select2-search-choice:not(.select2-locked)'
3678 )
3679 .last()
3680 ),
3681 A( a ),
3682 void 0
3683 );
3684 if (
3685 ( this.selectChoice( null ),
3686 this.opened() )
3687 )
3688 switch ( a.which ) {
3689 case k.UP:
3690 case k.DOWN:
3691 return (
3692 this.moveHighlight(
3693 a.which === k.UP
3694 ? -1
3695 : 1
3696 ),
3697 A( a ),
3698 void 0
3699 );
3700 case k.ENTER:
3701 return (
3702 this.selectHighlighted(),
3703 A( a ),
3704 void 0
3705 );
3706 case k.TAB:
3707 return (
3708 this.selectHighlighted(
3709 { noFocus: ! 0 }
3710 ),
3711 this.close(),
3712 void 0
3713 );
3714 case k.ESC:
3715 return (
3716 this.cancel( a ),
3717 A( a ),
3718 void 0
3719 );
3720 }
3721 if (
3722 a.which !== k.TAB &&
3723 ! k.isControl( a ) &&
3724 ! k.isFunctionKey( a ) &&
3725 a.which !== k.BACKSPACE &&
3726 a.which !== k.ESC
3727 ) {
3728 if ( a.which === k.ENTER ) {
3729 if (
3730 this.opts.openOnEnter ===
3731 ! 1
3732 )
3733 return;
3734 if (
3735 a.altKey ||
3736 a.ctrlKey ||
3737 a.shiftKey ||
3738 a.metaKey
3739 )
3740 return;
3741 }
3742 this.open(),
3743 ( a.which === k.PAGE_UP ||
3744 a.which === k.PAGE_DOWN ) &&
3745 A( a ),
3746 a.which === k.ENTER && A( a );
3747 }
3748 }
3749 } )
3750 ),
3751 this.search.on(
3752 'keyup',
3753 this.bind( function () {
3754 ( this.keydowns = 0 ), this.resizeSearch();
3755 } )
3756 ),
3757 this.search.on(
3758 'blur',
3759 this.bind( function ( b ) {
3760 this.container.removeClass(
3761 'select2-container-active'
3762 ),
3763 this.search.removeClass(
3764 'select2-focused'
3765 ),
3766 this.selectChoice( null ),
3767 this.opened() || this.clearSearch(),
3768 b.stopImmediatePropagation(),
3769 this.opts.element.trigger(
3770 a.Event( 'select2-blur' )
3771 );
3772 } )
3773 ),
3774 this.container.on(
3775 'click',
3776 b,
3777 this.bind( function ( b ) {
3778 this.isInterfaceEnabled() &&
3779 ( a( b.target ).closest(
3780 '.select2-search-choice'
3781 ).length > 0 ||
3782 ( this.selectChoice( null ),
3783 this.clearPlaceholder(),
3784 this.container.hasClass(
3785 'select2-container-active'
3786 ) ||
3787 this.opts.element.trigger(
3788 a.Event( 'select2-focus' )
3789 ),
3790 this.open(),
3791 this.focusSearch(),
3792 b.preventDefault() ) );
3793 } )
3794 ),
3795 this.container.on(
3796 'focus',
3797 b,
3798 this.bind( function () {
3799 this.isInterfaceEnabled() &&
3800 ( this.container.hasClass(
3801 'select2-container-active'
3802 ) ||
3803 this.opts.element.trigger(
3804 a.Event( 'select2-focus' )
3805 ),
3806 this.container.addClass(
3807 'select2-container-active'
3808 ),
3809 this.dropdown.addClass(
3810 'select2-drop-active'
3811 ),
3812 this.clearPlaceholder() );
3813 } )
3814 ),
3815 this.initContainerWidth(),
3816 this.opts.element.hide(),
3817 this.clearSearch();
3818 },
3819 enableInterface: function () {
3820 this.parent.enableInterface.apply( this, arguments ) &&
3821 this.search.prop(
3822 'disabled',
3823 ! this.isInterfaceEnabled()
3824 );
3825 },
3826 initSelection: function () {
3827 if (
3828 ( '' === this.opts.element.val() &&
3829 '' === this.opts.element.text() &&
3830 ( this.updateSelection( [] ),
3831 this.close(),
3832 this.clearSearch() ),
3833 this.select || '' !== this.opts.element.val() )
3834 ) {
3835 var c = this;
3836 this.opts.initSelection.call(
3837 null,
3838 this.opts.element,
3839 function ( a ) {
3840 a !== b &&
3841 null !== a &&
3842 ( c.updateSelection( a ),
3843 c.close(),
3844 c.clearSearch() );
3845 }
3846 );
3847 }
3848 },
3849 clearSearch: function () {
3850 var a = this.getPlaceholder(),
3851 c = this.getMaxSearchWidth();
3852 a !== b &&
3853 0 === this.getVal().length &&
3854 this.search.hasClass( 'select2-focused' ) === ! 1
3855 ? ( this.search
3856 .val( a )
3857 .addClass( 'select2-default' ),
3858 this.search.width(
3859 c > 0 ? c : this.container.css( 'width' )
3860 ) )
3861 : this.search.val( '' ).width( 10 );
3862 },
3863 clearPlaceholder: function () {
3864 this.search.hasClass( 'select2-default' ) &&
3865 this.search
3866 .val( '' )
3867 .removeClass( 'select2-default' );
3868 },
3869 opening: function () {
3870 this.clearPlaceholder(),
3871 this.resizeSearch(),
3872 this.parent.opening.apply( this, arguments ),
3873 this.focusSearch(),
3874 '' === this.search.val() &&
3875 this.nextSearchTerm != b &&
3876 ( this.search.val( this.nextSearchTerm ),
3877 this.search.select() ),
3878 this.updateResults( ! 0 ),
3879 this.opts.shouldFocusInput( this ) &&
3880 this.search.focus(),
3881 this.opts.element.trigger(
3882 a.Event( 'select2-open' )
3883 );
3884 },
3885 close: function () {
3886 this.opened() &&
3887 this.parent.close.apply( this, arguments );
3888 },
3889 focus: function () {
3890 this.close(), this.search.focus();
3891 },
3892 isFocused: function () {
3893 return this.search.hasClass( 'select2-focused' );
3894 },
3895 updateSelection: function ( b ) {
3896 var c = [],
3897 d = [],
3898 e = this;
3899 a( b ).each( function () {
3900 p( e.id( this ), c ) < 0 &&
3901 ( c.push( e.id( this ) ), d.push( this ) );
3902 } ),
3903 ( b = d ),
3904 this.selection
3905 .find( '.select2-search-choice' )
3906 .remove(),
3907 a( b ).each( function () {
3908 e.addSelectedChoice( this );
3909 } ),
3910 e.postprocessResults();
3911 },
3912 tokenize: function () {
3913 var a = this.search.val();
3914 ( a = this.opts.tokenizer.call(
3915 this,
3916 a,
3917 this.data(),
3918 this.bind( this.onSelect ),
3919 this.opts
3920 ) ),
3921 null != a &&
3922 a != b &&
3923 ( this.search.val( a ),
3924 a.length > 0 && this.open() );
3925 },
3926 onSelect: function ( a, c ) {
3927 this.triggerSelect( a ) &&
3928 '' !== a.text &&
3929 ( this.addSelectedChoice( a ),
3930 this.opts.element.trigger( {
3931 type: 'selected',
3932 val: this.id( a ),
3933 choice: a,
3934 } ),
3935 ( this.nextSearchTerm = this.opts.nextSearchTerm(
3936 a,
3937 this.search.val()
3938 ) ),
3939 this.clearSearch(),
3940 this.updateResults(),
3941 ( this.select || ! this.opts.closeOnSelect ) &&
3942 this.postprocessResults(
3943 a,
3944 ! 1,
3945 this.opts.closeOnSelect === ! 0
3946 ),
3947 this.opts.closeOnSelect
3948 ? ( this.close(), this.search.width( 10 ) )
3949 : this.countSelectableResults() > 0
3950 ? ( this.search.width( 10 ),
3951 this.resizeSearch(),
3952 this.getMaximumSelectionSize() > 0 &&
3953 this.val().length >=
3954 this.getMaximumSelectionSize()
3955 ? this.updateResults( ! 0 )
3956 : this.nextSearchTerm != b &&
3957 ( this.search.val(
3958 this.nextSearchTerm
3959 ),
3960 this.updateResults(),
3961 this.search.select() ),
3962 this.positionDropdown() )
3963 : ( this.close(), this.search.width( 10 ) ),
3964 this.triggerChange( { added: a } ),
3965 ( c && c.noFocus ) || this.focusSearch() );
3966 },
3967 cancel: function () {
3968 this.close(), this.focusSearch();
3969 },
3970 addSelectedChoice: function ( c ) {
3971 var j,
3972 k,
3973 d = ! c.locked,
3974 e = a(
3975 "<li class='select2-search-choice'> <div></div> <a href='#' class='select2-search-choice-close' tabindex='-1'></a></li>"
3976 ),
3977 f = a(
3978 "<li class='select2-search-choice select2-locked'><div></div></li>"
3979 ),
3980 g = d ? e : f,
3981 h = this.id( c ),
3982 i = this.getVal();
3983 ( j = this.opts.formatSelection(
3984 c,
3985 g.find( 'div' ),
3986 this.opts.escapeMarkup
3987 ) ),
3988 j != b &&
3989 g
3990 .find( 'div' )
3991 .replaceWith(
3992 a( '<div></div>' ).html( j )
3993 ),
3994 ( k = this.opts.formatSelectionCssClass(
3995 c,
3996 g.find( 'div' )
3997 ) ),
3998 k != b && g.addClass( k ),
3999 d &&
4000 g
4001 .find( '.select2-search-choice-close' )
4002 .on( 'mousedown', A )
4003 .on(
4004 'click dblclick',
4005 this.bind( function ( b ) {
4006 this.isInterfaceEnabled() &&
4007 ( this.unselect(
4008 a( b.target )
4009 ),
4010 this.selection
4011 .find(
4012 '.select2-search-choice-focus'
4013 )
4014 .removeClass(
4015 'select2-search-choice-focus'
4016 ),
4017 A( b ),
4018 this.close(),
4019 this.focusSearch() );
4020 } )
4021 )
4022 .on(
4023 'focus',
4024 this.bind( function () {
4025 this.isInterfaceEnabled() &&
4026 ( this.container.addClass(
4027 'select2-container-active'
4028 ),
4029 this.dropdown.addClass(
4030 'select2-drop-active'
4031 ) );
4032 } )
4033 ),
4034 g.data( 'select2-data', c ),
4035 g.insertBefore( this.searchContainer ),
4036 i.push( h ),
4037 this.setVal( i );
4038 },
4039 unselect: function ( b ) {
4040 var d,
4041 e,
4042 c = this.getVal();
4043 if (
4044 ( ( b = b.closest( '.select2-search-choice' ) ),
4045 0 === b.length )
4046 )
4047 throw (
4048 'Invalid argument: ' +
4049 b +
4050 '. Must be .select2-search-choice'
4051 );
4052 if ( ( d = b.data( 'select2-data' ) ) ) {
4053 var f = a.Event( 'select2-removing' );
4054 if (
4055 ( ( f.val = this.id( d ) ),
4056 ( f.choice = d ),
4057 this.opts.element.trigger( f ),
4058 f.isDefaultPrevented() )
4059 )
4060 return ! 1;
4061 for ( ; ( e = p( this.id( d ), c ) ) >= 0; )
4062 c.splice( e, 1 ),
4063 this.setVal( c ),
4064 this.select && this.postprocessResults();
4065 return (
4066 b.remove(),
4067 this.opts.element.trigger( {
4068 type: 'select2-removed',
4069 val: this.id( d ),
4070 choice: d,
4071 } ),
4072 this.triggerChange( { removed: d } ),
4073 ! 0
4074 );
4075 }
4076 },
4077 postprocessResults: function ( a, b, c ) {
4078 var d = this.getVal(),
4079 e = this.results.find( '.select2-result' ),
4080 f = this.results.find(
4081 '.select2-result-with-children'
4082 ),
4083 g = this;
4084 e.each2( function ( a, b ) {
4085 var c = g.id( b.data( 'select2-data' ) );
4086 p( c, d ) >= 0 &&
4087 ( b.addClass( 'select2-selected' ),
4088 b
4089 .find( '.select2-result-selectable' )
4090 .addClass( 'select2-selected' ) );
4091 } ),
4092 f.each2( function ( a, b ) {
4093 b.is( '.select2-result-selectable' ) ||
4094 0 !==
4095 b.find(
4096 '.select2-result-selectable:not(.select2-selected)'
4097 ).length ||
4098 b.addClass( 'select2-selected' );
4099 } ),
4100 -1 == this.highlight() &&
4101 c !== ! 1 &&
4102 this.opts.closeOnSelect === ! 0 &&
4103 g.highlight( 0 ),
4104 ! this.opts.createSearchChoice &&
4105 ! e.filter(
4106 '.select2-result:not(.select2-selected)'
4107 ).length > 0 &&
4108 ( ! a ||
4109 ( a &&
4110 ! a.more &&
4111 0 ===
4112 this.results.find(
4113 '.select2-no-results'
4114 ).length ) ) &&
4115 J(
4116 g.opts.formatNoMatches,
4117 'formatNoMatches'
4118 ) &&
4119 this.results.append(
4120 "<li class='select2-no-results'>" +
4121 K(
4122 g.opts.formatNoMatches,
4123 g.opts.element,
4124 g.search.val()
4125 ) +
4126 '</li>'
4127 );
4128 },
4129 getMaxSearchWidth: function () {
4130 return this.selection.width() - t( this.search );
4131 },
4132 resizeSearch: function () {
4133 var a,
4134 b,
4135 c,
4136 d,
4137 e,
4138 f = t( this.search );
4139 ( a = C( this.search ) + 10 ),
4140 ( b = this.search.offset().left ),
4141 ( c = this.selection.width() ),
4142 ( d = this.selection.offset().left ),
4143 ( e = c - ( b - d ) - f ),
4144 a > e && ( e = c - f ),
4145 40 > e && ( e = c - f ),
4146 0 >= e && ( e = a ),
4147 this.search.width( Math.floor( e ) );
4148 },
4149 getVal: function () {
4150 var a;
4151 return this.select
4152 ? ( ( a = this.select.val() ), null === a ? [] : a )
4153 : ( ( a = this.opts.element.val() ),
4154 s(
4155 a,
4156 this.opts.separator,
4157 this.opts.transformVal
4158 ) );
4159 },
4160 setVal: function ( b ) {
4161 var c;
4162 this.select
4163 ? this.select.val( b )
4164 : ( ( c = [] ),
4165 a( b ).each( function () {
4166 p( this, c ) < 0 && c.push( this );
4167 } ),
4168 this.opts.element.val(
4169 0 === c.length
4170 ? ''
4171 : c.join( this.opts.separator )
4172 ) );
4173 },
4174 buildChangeDetails: function ( a, b ) {
4175 for (
4176 var b = b.slice( 0 ), a = a.slice( 0 ), c = 0;
4177 c < b.length;
4178 c++
4179 )
4180 for ( var d = 0; d < a.length; d++ )
4181 r(
4182 this.opts.id( b[ c ] ),
4183 this.opts.id( a[ d ] )
4184 ) &&
4185 ( b.splice( c, 1 ),
4186 c > 0 && c--,
4187 a.splice( d, 1 ),
4188 d-- );
4189 return { added: b, removed: a };
4190 },
4191 val: function ( c, d ) {
4192 var e,
4193 f = this;
4194 if ( 0 === arguments.length ) return this.getVal();
4195 if (
4196 ( ( e = this.data() ),
4197 e.length || ( e = [] ),
4198 ! c && 0 !== c )
4199 )
4200 return (
4201 this.opts.element.val( '' ),
4202 this.updateSelection( [] ),
4203 this.clearSearch(),
4204 d &&
4205 this.triggerChange( {
4206 added: this.data(),
4207 removed: e,
4208 } ),
4209 void 0
4210 );
4211 if ( ( this.setVal( c ), this.select ) )
4212 this.opts.initSelection(
4213 this.select,
4214 this.bind( this.updateSelection )
4215 ),
4216 d &&
4217 this.triggerChange(
4218 this.buildChangeDetails(
4219 e,
4220 this.data()
4221 )
4222 );
4223 else {
4224 if ( this.opts.initSelection === b )
4225 throw new Error(
4226 'val() cannot be called if initSelection() is not defined'
4227 );
4228 this.opts.initSelection(
4229 this.opts.element,
4230 function ( b ) {
4231 var c = a.map( b, f.id );
4232 f.setVal( c ),
4233 f.updateSelection( b ),
4234 f.clearSearch(),
4235 d &&
4236 f.triggerChange(
4237 f.buildChangeDetails(
4238 e,
4239 f.data()
4240 )
4241 );
4242 }
4243 );
4244 }
4245 this.clearSearch();
4246 },
4247 onSortStart: function () {
4248 if ( this.select )
4249 throw new Error(
4250 "Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead."
4251 );
4252 this.search.width( 0 ), this.searchContainer.hide();
4253 },
4254 onSortEnd: function () {
4255 var b = [],
4256 c = this;
4257 this.searchContainer.show(),
4258 this.searchContainer.appendTo(
4259 this.searchContainer.parent()
4260 ),
4261 this.resizeSearch(),
4262 this.selection
4263 .find( '.select2-search-choice' )
4264 .each( function () {
4265 b.push(
4266 c.opts.id(
4267 a( this ).data( 'select2-data' )
4268 )
4269 );
4270 } ),
4271 this.setVal( b ),
4272 this.triggerChange();
4273 },
4274 data: function ( b, c ) {
4275 var e,
4276 f,
4277 d = this;
4278 return 0 === arguments.length
4279 ? this.selection
4280 .children( '.select2-search-choice' )
4281 .map( function () {
4282 return a( this ).data( 'select2-data' );
4283 } )
4284 .get()
4285 : ( ( f = this.data() ),
4286 b || ( b = [] ),
4287 ( e = a.map( b, function ( a ) {
4288 return d.opts.id( a );
4289 } ) ),
4290 this.setVal( e ),
4291 this.updateSelection( b ),
4292 this.clearSearch(),
4293 c &&
4294 this.triggerChange(
4295 this.buildChangeDetails(
4296 f,
4297 this.data()
4298 )
4299 ),
4300 void 0 );
4301 },
4302 } ) ),
4303 ( a.fn.select2 = function () {
4304 var d,
4305 e,
4306 f,
4307 g,
4308 h,
4309 c = Array.prototype.slice.call( arguments, 0 ),
4310 i = [
4311 'val',
4312 'destroy',
4313 'opened',
4314 'open',
4315 'close',
4316 'focus',
4317 'isFocused',
4318 'container',
4319 'dropdown',
4320 'onSortStart',
4321 'onSortEnd',
4322 'enable',
4323 'disable',
4324 'readonly',
4325 'positionDropdown',
4326 'data',
4327 'search',
4328 ],
4329 j = [ 'opened', 'isFocused', 'container', 'dropdown' ],
4330 k = [ 'val', 'data' ],
4331 l = { search: 'externalSearch' };
4332 return (
4333 this.each( function () {
4334 if ( 0 === c.length || 'object' == typeof c[ 0 ] )
4335 ( d =
4336 0 === c.length
4337 ? {}
4338 : a.extend( {}, c[ 0 ] ) ),
4339 ( d.element = a( this ) ),
4340 'select' ===
4341 d.element.get( 0 ).tagName.toLowerCase()
4342 ? ( h = d.element.prop( 'multiple' ) )
4343 : ( ( h = d.multiple || ! 1 ),
4344 'tags' in d &&
4345 ( d.multiple = h = ! 0 ) ),
4346 ( e = h
4347 ? new window.Select2[ 'class' ].multi()
4348 : new window.Select2[
4349 'class'
4350 ].single() ),
4351 e.init( d );
4352 else {
4353 if ( 'string' != typeof c[ 0 ] )
4354 throw (
4355 'Invalid arguments to select2 plugin: ' +
4356 c
4357 );
4358 if ( p( c[ 0 ], i ) < 0 )
4359 throw 'Unknown method: ' + c[ 0 ];
4360 if (
4361 ( ( g = b ),
4362 ( e = a( this ).data( 'select2' ) ),
4363 e === b )
4364 )
4365 return;
4366 if (
4367 ( ( f = c[ 0 ] ),
4368 'container' === f
4369 ? ( g = e.container )
4370 : 'dropdown' === f
4371 ? ( g = e.dropdown )
4372 : ( l[ f ] && ( f = l[ f ] ),
4373 ( g = e[ f ].apply(
4374 e,
4375 c.slice( 1 )
4376 ) ) ),
4377 p( c[ 0 ], j ) >= 0 ||
4378 ( p( c[ 0 ], k ) >= 0 &&
4379 1 == c.length ) )
4380 )
4381 return ! 1;
4382 }
4383 } ),
4384 g === b ? this : g
4385 );
4386 } ),
4387 ( a.fn.select2.defaults = {
4388 width: 'copy',
4389 loadMorePadding: 0,
4390 closeOnSelect: ! 0,
4391 openOnEnter: ! 0,
4392 containerCss: {},
4393 dropdownCss: {},
4394 containerCssClass: '',
4395 dropdownCssClass: '',
4396 formatResult: function ( a, b, c, d ) {
4397 var e = [];
4398 return E( this.text( a ), c.term, e, d ), e.join( '' );
4399 },
4400 transformVal: function ( b ) {
4401 return a.trim( b );
4402 },
4403 formatSelection: function ( a, c, d ) {
4404 return a ? d( this.text( a ) ) : b;
4405 },
4406 sortResults: function ( a ) {
4407 return a;
4408 },
4409 formatResultCssClass: function ( a ) {
4410 return a.css;
4411 },
4412 formatSelectionCssClass: function () {
4413 return b;
4414 },
4415 minimumResultsForSearch: 0,
4416 minimumInputLength: 0,
4417 maximumInputLength: null,
4418 maximumSelectionSize: 0,
4419 id: function ( a ) {
4420 return a == b ? null : a.id;
4421 },
4422 text: function ( b ) {
4423 return b && this.data && this.data.text
4424 ? a.isFunction( this.data.text )
4425 ? this.data.text( b )
4426 : b[ this.data.text ]
4427 : b.text;
4428 },
4429 matcher: function ( a, b ) {
4430 return (
4431 o( '' + b )
4432 .toUpperCase()
4433 .indexOf( o( '' + a ).toUpperCase() ) >= 0
4434 );
4435 },
4436 separator: ',',
4437 tokenSeparators: [],
4438 tokenizer: M,
4439 escapeMarkup: F,
4440 blurOnChange: ! 1,
4441 selectOnBlur: ! 1,
4442 adaptContainerCssClass: function ( a ) {
4443 return a;
4444 },
4445 adaptDropdownCssClass: function () {
4446 return null;
4447 },
4448 nextSearchTerm: function () {
4449 return b;
4450 },
4451 searchInputPlaceholder: '',
4452 createSearchChoicePosition: 'top',
4453 shouldFocusInput: function ( a ) {
4454 var b =
4455 'ontouchstart' in window ||
4456 navigator.msMaxTouchPoints > 0;
4457 return b
4458 ? a.opts.minimumResultsForSearch < 0
4459 ? ! 1
4460 : ! 0
4461 : ! 0;
4462 },
4463 } ),
4464 ( a.fn.select2.locales = [] ),
4465 ( a.fn.select2.locales.en = {
4466 formatMatches: function ( a ) {
4467 return 1 === a
4468 ? 'One result is available, press enter to select it.'
4469 : a +
4470 ' results are available, use up and down arrow keys to navigate.';
4471 },
4472 formatNoMatches: function () {
4473 return 'No matches found';
4474 },
4475 formatAjaxError: function () {
4476 return 'Loading failed';
4477 },
4478 formatInputTooShort: function ( a, b ) {
4479 var c = b - a.length;
4480 return (
4481 'Please enter ' +
4482 c +
4483 ' or more character' +
4484 ( 1 == c ? '' : 's' )
4485 );
4486 },
4487 formatInputTooLong: function ( a, b ) {
4488 var c = a.length - b;
4489 return (
4490 'Please delete ' +
4491 c +
4492 ' character' +
4493 ( 1 == c ? '' : 's' )
4494 );
4495 },
4496 formatSelectionTooBig: function ( a ) {
4497 return (
4498 'You can only select ' +
4499 a +
4500 ' item' +
4501 ( 1 == a ? '' : 's' )
4502 );
4503 },
4504 formatLoadMore: function () {
4505 return 'Loading more results\u2026';
4506 },
4507 formatSearching: function () {
4508 return 'Searching\u2026';
4509 },
4510 } ),
4511 a.extend( a.fn.select2.defaults, a.fn.select2.locales.en ),
4512 ( a.fn.select2.ajaxDefaults = {
4513 transport: a.ajax,
4514 params: { type: 'GET', cache: ! 1, dataType: 'json' },
4515 } ),
4516 ( window.Select2 = {
4517 query: { ajax: G, local: H, tags: I },
4518 util: {
4519 debounce: w,
4520 markMatch: E,
4521 escapeMarkup: F,
4522 stripDiacritics: o,
4523 },
4524 class: { abstract: c, single: d, multi: e },
4525 } );
4526 }
4527 } )( jQuery );
4528