No Description

select2.min.js 112KB

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