select2.js 128 KB

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