select2.js 121 KB

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