select2.full.js 142 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827
  1. /*!
  2. * Select2 4.0.0-rc.1
  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. return Utils;
  600. });
  601. S2.define('select2/results',[
  602. 'jquery',
  603. './utils'
  604. ], function ($, Utils) {
  605. function Results ($element, options, dataAdapter) {
  606. this.$element = $element;
  607. this.data = dataAdapter;
  608. this.options = options;
  609. Results.__super__.constructor.call(this);
  610. }
  611. Utils.Extend(Results, Utils.Observable);
  612. Results.prototype.render = function () {
  613. var $results = $(
  614. '<ul class="select2-results__options" role="tree"></ul>'
  615. );
  616. if (this.options.get('multiple')) {
  617. $results.attr('aria-multiselectable', 'true');
  618. }
  619. this.$results = $results;
  620. return $results;
  621. };
  622. Results.prototype.clear = function () {
  623. this.$results.empty();
  624. };
  625. Results.prototype.displayMessage = function (params) {
  626. var escapeMarkup = this.options.get('escapeMarkup');
  627. this.clear();
  628. this.hideLoading();
  629. var $message = $(
  630. '<li role="treeitem" class="select2-results__option"></li>'
  631. );
  632. var message = this.options.get('translations').get(params.message);
  633. $message.append(
  634. escapeMarkup(
  635. message(params.args)
  636. )
  637. );
  638. this.$results.append($message);
  639. };
  640. Results.prototype.append = function (data) {
  641. this.hideLoading();
  642. var $options = [];
  643. if (data.results == null || data.results.length === 0) {
  644. if (this.$results.children().length === 0) {
  645. this.trigger('results:message', {
  646. message: 'noResults'
  647. });
  648. }
  649. return;
  650. }
  651. data.results = this.sort(data.results);
  652. for (var d = 0; d < data.results.length; d++) {
  653. var item = data.results[d];
  654. var $option = this.option(item);
  655. $options.push($option);
  656. }
  657. this.$results.append($options);
  658. };
  659. Results.prototype.position = function ($results, $dropdown) {
  660. var $resultsContainer = $dropdown.find('.select2-results');
  661. $resultsContainer.append($results);
  662. };
  663. Results.prototype.sort = function (data) {
  664. var sorter = this.options.get('sorter');
  665. return sorter(data);
  666. };
  667. Results.prototype.setClasses = function () {
  668. var self = this;
  669. this.data.current(function (selected) {
  670. var selectedIds = $.map(selected, function (s) {
  671. return s.id.toString();
  672. });
  673. var $options = self.$results
  674. .find('.select2-results__option[aria-selected]');
  675. $options.each(function () {
  676. var $option = $(this);
  677. var item = $.data(this, 'data');
  678. if ($.inArray(item.id, selectedIds) > -1) {
  679. $option.attr('aria-selected', 'true');
  680. } else {
  681. $option.attr('aria-selected', 'false');
  682. }
  683. });
  684. var $selected = $options.filter('[aria-selected=true]');
  685. // Check if there are any selected options
  686. if ($selected.length > 0) {
  687. // If there are selected options, highlight the first
  688. $selected.first().trigger('mouseenter');
  689. } else {
  690. // If there are no selected options, highlight the first option
  691. // in the dropdown
  692. $options.first().trigger('mouseenter');
  693. }
  694. });
  695. };
  696. Results.prototype.showLoading = function (params) {
  697. this.hideLoading();
  698. var loadingMore = this.options.get('translations').get('searching');
  699. var loading = {
  700. disabled: true,
  701. loading: true,
  702. text: loadingMore(params)
  703. };
  704. var $loading = this.option(loading);
  705. $loading.className += ' loading-results';
  706. this.$results.prepend($loading);
  707. };
  708. Results.prototype.hideLoading = function () {
  709. this.$results.find('.loading-results').remove();
  710. };
  711. Results.prototype.option = function (data) {
  712. var option = document.createElement('li');
  713. option.className = 'select2-results__option';
  714. var attrs = {
  715. 'role': 'treeitem',
  716. 'aria-selected': 'false'
  717. };
  718. if (data.disabled) {
  719. delete attrs['aria-selected'];
  720. attrs['aria-disabled'] = 'true';
  721. }
  722. if (data.id == null) {
  723. delete attrs['aria-selected'];
  724. }
  725. if (data._resultId != null) {
  726. option.id = data._resultId;
  727. }
  728. if (data.title) {
  729. option.title = data.title;
  730. }
  731. if (data.children) {
  732. attrs.role = 'group';
  733. attrs['aria-label'] = data.text;
  734. delete attrs['aria-selected'];
  735. }
  736. for (var attr in attrs) {
  737. var val = attrs[attr];
  738. option.setAttribute(attr, val);
  739. }
  740. if (data.children) {
  741. var $option = $(option);
  742. var label = document.createElement('strong');
  743. label.className = 'select2-results__group';
  744. var $label = $(label);
  745. this.template(data, label);
  746. var $children = [];
  747. for (var c = 0; c < data.children.length; c++) {
  748. var child = data.children[c];
  749. var $child = this.option(child);
  750. $children.push($child);
  751. }
  752. var $childrenContainer = $('<ul></ul>', {
  753. 'class': 'select2-results__options select2-results__options--nested'
  754. });
  755. $childrenContainer.append($children);
  756. $option.append(label);
  757. $option.append($childrenContainer);
  758. } else {
  759. this.template(data, option);
  760. }
  761. $.data(option, 'data', data);
  762. return option;
  763. };
  764. Results.prototype.bind = function (container, $container) {
  765. var self = this;
  766. var id = container.id + '-results';
  767. this.$results.attr('id', id);
  768. container.on('results:all', function (params) {
  769. self.clear();
  770. self.append(params.data);
  771. if (container.isOpen()) {
  772. self.setClasses();
  773. }
  774. });
  775. container.on('results:append', function (params) {
  776. self.append(params.data);
  777. if (container.isOpen()) {
  778. self.setClasses();
  779. }
  780. });
  781. container.on('query', function (params) {
  782. self.showLoading(params);
  783. });
  784. container.on('select', function () {
  785. if (!container.isOpen()) {
  786. return;
  787. }
  788. self.setClasses();
  789. });
  790. container.on('unselect', function () {
  791. if (!container.isOpen()) {
  792. return;
  793. }
  794. self.setClasses();
  795. });
  796. container.on('open', function () {
  797. // When the dropdown is open, aria-expended="true"
  798. self.$results.attr('aria-expanded', 'true');
  799. self.$results.attr('aria-hidden', 'false');
  800. self.setClasses();
  801. self.ensureHighlightVisible();
  802. });
  803. container.on('close', function () {
  804. // When the dropdown is closed, aria-expended="false"
  805. self.$results.attr('aria-expanded', 'false');
  806. self.$results.attr('aria-hidden', 'true');
  807. self.$results.removeAttr('aria-activedescendant');
  808. });
  809. container.on('results:toggle', function () {
  810. var $highlighted = self.getHighlightedResults();
  811. if ($highlighted.length === 0) {
  812. return;
  813. }
  814. $highlighted.trigger('mouseup');
  815. });
  816. container.on('results:select', function () {
  817. var $highlighted = self.getHighlightedResults();
  818. if ($highlighted.length === 0) {
  819. return;
  820. }
  821. var data = $highlighted.data('data');
  822. if ($highlighted.attr('aria-selected') == 'true') {
  823. self.trigger('close');
  824. } else {
  825. self.trigger('select', {
  826. data: data
  827. });
  828. }
  829. });
  830. container.on('results:previous', function () {
  831. var $highlighted = self.getHighlightedResults();
  832. var $options = self.$results.find('[aria-selected]');
  833. var currentIndex = $options.index($highlighted);
  834. // If we are already at te top, don't move further
  835. if (currentIndex === 0) {
  836. return;
  837. }
  838. var nextIndex = currentIndex - 1;
  839. // If none are highlighted, highlight the first
  840. if ($highlighted.length === 0) {
  841. nextIndex = 0;
  842. }
  843. var $next = $options.eq(nextIndex);
  844. $next.trigger('mouseenter');
  845. var currentOffset = self.$results.offset().top;
  846. var nextTop = $next.offset().top;
  847. var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
  848. if (nextIndex === 0) {
  849. self.$results.scrollTop(0);
  850. } else if (nextTop - currentOffset < 0) {
  851. self.$results.scrollTop(nextOffset);
  852. }
  853. });
  854. container.on('results:next', function () {
  855. var $highlighted = self.getHighlightedResults();
  856. var $options = self.$results.find('[aria-selected]');
  857. var currentIndex = $options.index($highlighted);
  858. var nextIndex = currentIndex + 1;
  859. // If we are at the last option, stay there
  860. if (nextIndex >= $options.length) {
  861. return;
  862. }
  863. var $next = $options.eq(nextIndex);
  864. $next.trigger('mouseenter');
  865. var currentOffset = self.$results.offset().top +
  866. self.$results.outerHeight(false);
  867. var nextBottom = $next.offset().top + $next.outerHeight(false);
  868. var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
  869. if (nextIndex === 0) {
  870. self.$results.scrollTop(0);
  871. } else if (nextBottom > currentOffset) {
  872. self.$results.scrollTop(nextOffset);
  873. }
  874. });
  875. container.on('results:focus', function (params) {
  876. params.element.addClass('select2-results__option--highlighted');
  877. });
  878. container.on('results:message', function (params) {
  879. self.displayMessage(params);
  880. });
  881. if ($.fn.mousewheel) {
  882. this.$results.on('mousewheel', function (e) {
  883. var top = self.$results.scrollTop();
  884. var bottom = (
  885. self.$results.get(0).scrollHeight -
  886. self.$results.scrollTop() +
  887. e.deltaY
  888. );
  889. var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
  890. var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
  891. if (isAtTop) {
  892. self.$results.scrollTop(0);
  893. e.preventDefault();
  894. e.stopPropagation();
  895. } else if (isAtBottom) {
  896. self.$results.scrollTop(
  897. self.$results.get(0).scrollHeight - self.$results.height()
  898. );
  899. e.preventDefault();
  900. e.stopPropagation();
  901. }
  902. });
  903. }
  904. this.$results.on('mouseup', '.select2-results__option[aria-selected]',
  905. function (evt) {
  906. var $this = $(this);
  907. var data = $this.data('data');
  908. if ($this.attr('aria-selected') === 'true') {
  909. if (self.options.get('multiple')) {
  910. self.trigger('unselect', {
  911. originalEvent: evt,
  912. data: data
  913. });
  914. } else {
  915. self.trigger('close');
  916. }
  917. return;
  918. }
  919. self.trigger('select', {
  920. originalEvent: evt,
  921. data: data
  922. });
  923. });
  924. this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
  925. function (evt) {
  926. var data = $(this).data('data');
  927. self.getHighlightedResults()
  928. .removeClass('select2-results__option--highlighted');
  929. self.trigger('results:focus', {
  930. data: data,
  931. element: $(this)
  932. });
  933. });
  934. };
  935. Results.prototype.getHighlightedResults = function () {
  936. var $highlighted = this.$results
  937. .find('.select2-results__option--highlighted');
  938. return $highlighted;
  939. };
  940. Results.prototype.destroy = function () {
  941. this.$results.remove();
  942. };
  943. Results.prototype.ensureHighlightVisible = function () {
  944. var $highlighted = this.getHighlightedResults();
  945. if ($highlighted.length === 0) {
  946. return;
  947. }
  948. var $options = this.$results.find('[aria-selected]');
  949. var currentIndex = $options.index($highlighted);
  950. var currentOffset = this.$results.offset().top;
  951. var nextTop = $highlighted.offset().top;
  952. var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
  953. var offsetDelta = nextTop - currentOffset;
  954. nextOffset -= $highlighted.outerHeight(false) * 2;
  955. if (currentIndex <= 2) {
  956. this.$results.scrollTop(0);
  957. } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
  958. this.$results.scrollTop(nextOffset);
  959. }
  960. };
  961. Results.prototype.template = function (result, container) {
  962. var template = this.options.get('templateResult');
  963. var escapeMarkup = this.options.get('escapeMarkup');
  964. var content = template(result);
  965. if (content == null) {
  966. container.style.display = 'none';
  967. } else if (typeof content === 'string') {
  968. container.innerHTML = escapeMarkup(content);
  969. } else {
  970. $(container).append(content);
  971. }
  972. };
  973. return Results;
  974. });
  975. S2.define('select2/keys',[
  976. ], function () {
  977. var KEYS = {
  978. BACKSPACE: 8,
  979. TAB: 9,
  980. ENTER: 13,
  981. SHIFT: 16,
  982. CTRL: 17,
  983. ALT: 18,
  984. ESC: 27,
  985. SPACE: 32,
  986. PAGE_UP: 33,
  987. PAGE_DOWN: 34,
  988. END: 35,
  989. HOME: 36,
  990. LEFT: 37,
  991. UP: 38,
  992. RIGHT: 39,
  993. DOWN: 40,
  994. DELETE: 46
  995. };
  996. return KEYS;
  997. });
  998. S2.define('select2/selection/base',[
  999. 'jquery',
  1000. '../utils',
  1001. '../keys'
  1002. ], function ($, Utils, KEYS) {
  1003. function BaseSelection ($element, options) {
  1004. this.$element = $element;
  1005. this.options = options;
  1006. BaseSelection.__super__.constructor.call(this);
  1007. }
  1008. Utils.Extend(BaseSelection, Utils.Observable);
  1009. BaseSelection.prototype.render = function () {
  1010. var $selection = $(
  1011. '<span class="select2-selection" role="combobox" ' +
  1012. 'aria-autocomplete="list" aria-haspopup="true" aria-expanded="false">' +
  1013. '</span>'
  1014. );
  1015. this._tabindex = 0;
  1016. if (this.$element.data('old-tabindex') != null) {
  1017. this._tabindex = this.$element.data('old-tabindex');
  1018. } else if (this.$element.attr('tabindex') != null) {
  1019. this._tabindex = this.$element.attr('tabindex');
  1020. }
  1021. $selection.attr('title', this.$element.attr('title'));
  1022. $selection.attr('tabindex', this._tabindex);
  1023. this.$selection = $selection;
  1024. return $selection;
  1025. };
  1026. BaseSelection.prototype.bind = function (container, $container) {
  1027. var self = this;
  1028. var id = container.id + '-container';
  1029. var resultsId = container.id + '-results';
  1030. this.container = container;
  1031. this.$selection.attr('aria-owns', resultsId);
  1032. this.$selection.on('focus', function (evt) {
  1033. self.trigger('focus', evt);
  1034. });
  1035. this.$selection.on('blur', function (evt) {
  1036. self.trigger('blur', evt);
  1037. });
  1038. this.$selection.on('keydown', function (evt) {
  1039. self.trigger('keypress', evt);
  1040. if (evt.which === KEYS.SPACE) {
  1041. evt.preventDefault();
  1042. }
  1043. });
  1044. container.on('results:focus', function (params) {
  1045. self.$selection.attr('aria-activedescendant', params.data._resultId);
  1046. });
  1047. container.on('selection:update', function (params) {
  1048. self.update(params.data);
  1049. });
  1050. container.on('open', function () {
  1051. // When the dropdown is open, aria-expanded="true"
  1052. self.$selection.attr('aria-expanded', 'true');
  1053. self._attachCloseHandler(container);
  1054. });
  1055. container.on('close', function () {
  1056. // When the dropdown is closed, aria-expanded="false"
  1057. self.$selection.attr('aria-expanded', 'false');
  1058. self.$selection.removeAttr('aria-activedescendant');
  1059. self.$selection.focus();
  1060. self._detachCloseHandler(container);
  1061. });
  1062. container.on('enable', function () {
  1063. self.$selection.attr('tabindex', self._tabindex);
  1064. });
  1065. container.on('disable', function () {
  1066. self.$selection.attr('tabindex', '-1');
  1067. });
  1068. };
  1069. BaseSelection.prototype._attachCloseHandler = function (container) {
  1070. var self = this;
  1071. $(document.body).on('mousedown.select2.' + container.id, function (e) {
  1072. var $target = $(e.target);
  1073. var $select = $target.closest('.select2');
  1074. var $all = $('.select2.select2-container--open');
  1075. $all.each(function () {
  1076. var $this = $(this);
  1077. if (this == $select[0]) {
  1078. return;
  1079. }
  1080. var $element = $this.data('element');
  1081. $element.select2('close');
  1082. });
  1083. });
  1084. };
  1085. BaseSelection.prototype._detachCloseHandler = function (container) {
  1086. $(document.body).off('mousedown.select2.' + container.id);
  1087. };
  1088. BaseSelection.prototype.position = function ($selection, $container) {
  1089. var $selectionContainer = $container.find('.selection');
  1090. $selectionContainer.append($selection);
  1091. };
  1092. BaseSelection.prototype.destroy = function () {
  1093. this._detachCloseHandler(this.container);
  1094. };
  1095. BaseSelection.prototype.update = function (data) {
  1096. throw new Error('The `update` method must be defined in child classes.');
  1097. };
  1098. return BaseSelection;
  1099. });
  1100. S2.define('select2/selection/single',[
  1101. 'jquery',
  1102. './base',
  1103. '../utils',
  1104. '../keys'
  1105. ], function ($, BaseSelection, Utils, KEYS) {
  1106. function SingleSelection () {
  1107. SingleSelection.__super__.constructor.apply(this, arguments);
  1108. }
  1109. Utils.Extend(SingleSelection, BaseSelection);
  1110. SingleSelection.prototype.render = function () {
  1111. var $selection = SingleSelection.__super__.render.call(this);
  1112. $selection.addClass('select2-selection--single');
  1113. $selection.html(
  1114. '<span class="select2-selection__rendered"></span>' +
  1115. '<span class="select2-selection__arrow" role="presentation">' +
  1116. '<b role="presentation"></b>' +
  1117. '</span>'
  1118. );
  1119. return $selection;
  1120. };
  1121. SingleSelection.prototype.bind = function (container, $container) {
  1122. var self = this;
  1123. SingleSelection.__super__.bind.apply(this, arguments);
  1124. var id = container.id + '-container';
  1125. this.$selection.find('.select2-selection__rendered').attr('id', id);
  1126. this.$selection.attr('aria-labelledby', id);
  1127. this.$selection.on('mousedown', function (evt) {
  1128. // Only respond to left clicks
  1129. if (evt.which !== 1) {
  1130. return;
  1131. }
  1132. self.trigger('toggle', {
  1133. originalEvent: evt
  1134. });
  1135. });
  1136. this.$selection.on('focus', function (evt) {
  1137. // User focuses on the container
  1138. });
  1139. this.$selection.on('blur', function (evt) {
  1140. // User exits the container
  1141. });
  1142. container.on('selection:update', function (params) {
  1143. self.update(params.data);
  1144. });
  1145. };
  1146. SingleSelection.prototype.clear = function () {
  1147. this.$selection.find('.select2-selection__rendered').empty();
  1148. };
  1149. SingleSelection.prototype.display = function (data) {
  1150. var template = this.options.get('templateSelection');
  1151. var escapeMarkup = this.options.get('escapeMarkup');
  1152. return escapeMarkup(template(data));
  1153. };
  1154. SingleSelection.prototype.selectionContainer = function () {
  1155. return $('<span></span>');
  1156. };
  1157. SingleSelection.prototype.update = function (data) {
  1158. if (data.length === 0) {
  1159. this.clear();
  1160. return;
  1161. }
  1162. var selection = data[0];
  1163. var formatted = this.display(selection);
  1164. var $rendered = this.$selection.find('.select2-selection__rendered');
  1165. $rendered.empty().append(formatted);
  1166. $rendered.prop('title', selection.title || selection.text);
  1167. };
  1168. return SingleSelection;
  1169. });
  1170. S2.define('select2/selection/multiple',[
  1171. 'jquery',
  1172. './base',
  1173. '../utils'
  1174. ], function ($, BaseSelection, Utils) {
  1175. function MultipleSelection ($element, options) {
  1176. MultipleSelection.__super__.constructor.apply(this, arguments);
  1177. }
  1178. Utils.Extend(MultipleSelection, BaseSelection);
  1179. MultipleSelection.prototype.render = function () {
  1180. var $selection = MultipleSelection.__super__.render.call(this);
  1181. $selection.addClass('select2-selection--multiple');
  1182. $selection.html(
  1183. '<ul class="select2-selection__rendered"></ul>'
  1184. );
  1185. return $selection;
  1186. };
  1187. MultipleSelection.prototype.bind = function (container, $container) {
  1188. var self = this;
  1189. MultipleSelection.__super__.bind.apply(this, arguments);
  1190. this.$selection.on('click', function (evt) {
  1191. self.trigger('toggle', {
  1192. originalEvent: evt
  1193. });
  1194. });
  1195. this.$selection.on('click', '.select2-selection__choice__remove',
  1196. function (evt) {
  1197. var $remove = $(this);
  1198. var $selection = $remove.parent();
  1199. var data = $selection.data('data');
  1200. self.trigger('unselect', {
  1201. originalEvent: evt,
  1202. data: data
  1203. });
  1204. });
  1205. };
  1206. MultipleSelection.prototype.clear = function () {
  1207. this.$selection.find('.select2-selection__rendered').empty();
  1208. };
  1209. MultipleSelection.prototype.display = function (data) {
  1210. var template = this.options.get('templateSelection');
  1211. var escapeMarkup = this.options.get('escapeMarkup');
  1212. return escapeMarkup(template(data));
  1213. };
  1214. MultipleSelection.prototype.selectionContainer = function () {
  1215. var $container = $(
  1216. '<li class="select2-selection__choice">' +
  1217. '<span class="select2-selection__choice__remove" role="presentation">' +
  1218. '&times;' +
  1219. '</span>' +
  1220. '</li>'
  1221. );
  1222. return $container;
  1223. };
  1224. MultipleSelection.prototype.update = function (data) {
  1225. this.clear();
  1226. if (data.length === 0) {
  1227. return;
  1228. }
  1229. var $selections = $();
  1230. for (var d = 0; d < data.length; d++) {
  1231. var selection = data[d];
  1232. var formatted = this.display(selection);
  1233. var $selection = this.selectionContainer();
  1234. $selection.append(formatted);
  1235. $selection.prop('title', selection.title || selection.text);
  1236. $selection.data('data', selection);
  1237. $selections = $selections.add($selection);
  1238. }
  1239. this.$selection.find('.select2-selection__rendered').append($selections);
  1240. };
  1241. return MultipleSelection;
  1242. });
  1243. S2.define('select2/selection/placeholder',[
  1244. '../utils'
  1245. ], function (Utils) {
  1246. function Placeholder (decorated, $element, options) {
  1247. this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
  1248. decorated.call(this, $element, options);
  1249. }
  1250. Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
  1251. if (typeof placeholder === 'string') {
  1252. placeholder = {
  1253. id: '',
  1254. text: placeholder
  1255. };
  1256. }
  1257. return placeholder;
  1258. };
  1259. Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
  1260. var $placeholder = this.selectionContainer();
  1261. $placeholder.html(this.display(placeholder));
  1262. $placeholder.addClass('select2-selection__placeholder')
  1263. .removeClass('select2-selection__choice');
  1264. return $placeholder;
  1265. };
  1266. Placeholder.prototype.update = function (decorated, data) {
  1267. var singlePlaceholder = (
  1268. data.length == 1 && data[0].id != this.placeholder.id
  1269. );
  1270. var multipleSelections = data.length > 1;
  1271. if (multipleSelections || singlePlaceholder) {
  1272. return decorated.call(this, data);
  1273. }
  1274. this.clear();
  1275. var $placeholder = this.createPlaceholder(this.placeholder);
  1276. this.$selection.find('.select2-selection__rendered').append($placeholder);
  1277. };
  1278. return Placeholder;
  1279. });
  1280. S2.define('select2/selection/allowClear',[
  1281. 'jquery'
  1282. ], function ($) {
  1283. function AllowClear () { }
  1284. AllowClear.prototype.bind = function (decorated, container, $container) {
  1285. var self = this;
  1286. decorated.call(this, container, $container);
  1287. if (self.placeholder == null) {
  1288. if (self.options.get('debug') && window.console && console.error) {
  1289. console.error(
  1290. 'Select2: The `allowClear` option should be used in combination ' +
  1291. 'with the `placeholder` option.'
  1292. );
  1293. }
  1294. }
  1295. this.$selection.on('mousedown', '.select2-selection__clear',
  1296. function (evt) {
  1297. // Ignore the event if it is disabled
  1298. if (self.options.get('disabled')) {
  1299. return;
  1300. }
  1301. evt.stopPropagation();
  1302. var data = $(this).data('data');
  1303. for (var d = 0; d < data.length; d++) {
  1304. var unselectData = {
  1305. data: data[d]
  1306. };
  1307. // Trigger the `unselect` event, so people can prevent it from being
  1308. // cleared.
  1309. self.trigger('unselect', unselectData);
  1310. // If the event was prevented, don't clear it out.
  1311. if (unselectData.prevented) {
  1312. return;
  1313. }
  1314. }
  1315. self.$element.val(self.placeholder.id).trigger('change');
  1316. self.trigger('toggle');
  1317. });
  1318. };
  1319. AllowClear.prototype.update = function (decorated, data) {
  1320. decorated.call(this, data);
  1321. if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
  1322. data.length === 0) {
  1323. return;
  1324. }
  1325. var $remove = $(
  1326. '<span class="select2-selection__clear">' +
  1327. '&times;' +
  1328. '</span>'
  1329. );
  1330. $remove.data('data', data);
  1331. this.$selection.find('.select2-selection__rendered').prepend($remove);
  1332. };
  1333. return AllowClear;
  1334. });
  1335. S2.define('select2/selection/search',[
  1336. 'jquery',
  1337. '../utils',
  1338. '../keys'
  1339. ], function ($, Utils, KEYS) {
  1340. function Search (decorated, $element, options) {
  1341. decorated.call(this, $element, options);
  1342. }
  1343. Search.prototype.render = function (decorated) {
  1344. var $search = $(
  1345. '<li class="select2-search select2-search--inline">' +
  1346. '<input class="select2-search__field" type="search" tabindex="-1"' +
  1347. ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
  1348. ' spellcheck="false" role="textbox" />' +
  1349. '</li>'
  1350. );
  1351. this.$searchContainer = $search;
  1352. this.$search = $search.find('input');
  1353. var $rendered = decorated.call(this);
  1354. return $rendered;
  1355. };
  1356. Search.prototype.bind = function (decorated, container, $container) {
  1357. var self = this;
  1358. decorated.call(this, container, $container);
  1359. container.on('open', function () {
  1360. self.$search.attr('tabindex', 0);
  1361. self.$search.focus();
  1362. });
  1363. container.on('close', function () {
  1364. self.$search.attr('tabindex', -1);
  1365. self.$search.val('');
  1366. self.$search.focus();
  1367. });
  1368. container.on('enable', function () {
  1369. self.$search.prop('disabled', false);
  1370. });
  1371. container.on('disable', function () {
  1372. self.$search.prop('disabled', true);
  1373. });
  1374. this.$selection.on('focusin', '.select2-search--inline', function (evt) {
  1375. self.trigger('focus', evt);
  1376. });
  1377. this.$selection.on('focusout', '.select2-search--inline', function (evt) {
  1378. self.trigger('blur', evt);
  1379. });
  1380. this.$selection.on('keydown', '.select2-search--inline', function (evt) {
  1381. evt.stopPropagation();
  1382. self.trigger('keypress', evt);
  1383. self._keyUpPrevented = evt.isDefaultPrevented();
  1384. var key = evt.which;
  1385. if (key === KEYS.BACKSPACE && self.$search.val() === '') {
  1386. var $previousChoice = self.$searchContainer
  1387. .prev('.select2-selection__choice');
  1388. if ($previousChoice.length > 0) {
  1389. var item = $previousChoice.data('data');
  1390. self.searchRemoveChoice(item);
  1391. }
  1392. }
  1393. });
  1394. // Workaround for browsers which do not support the `input` event
  1395. // This will prevent double-triggering of events for browsers which support
  1396. // both the `keyup` and `input` events.
  1397. this.$selection.on('input', '.select2-search--inline', function (evt) {
  1398. // Unbind the duplicated `keyup` event
  1399. self.$selection.off('keyup.search');
  1400. });
  1401. this.$selection.on('keyup.search input', '.select2-search--inline',
  1402. function (evt) {
  1403. self.handleSearch(evt);
  1404. });
  1405. };
  1406. Search.prototype.createPlaceholder = function (decorated, placeholder) {
  1407. this.$search.attr('placeholder', placeholder.text);
  1408. };
  1409. Search.prototype.update = function (decorated, data) {
  1410. this.$search.attr('placeholder', '');
  1411. decorated.call(this, data);
  1412. this.$selection.find('.select2-selection__rendered')
  1413. .append(this.$searchContainer);
  1414. this.resizeSearch();
  1415. };
  1416. Search.prototype.handleSearch = function () {
  1417. this.resizeSearch();
  1418. if (!this._keyUpPrevented) {
  1419. var input = this.$search.val();
  1420. this.trigger('query', {
  1421. term: input
  1422. });
  1423. }
  1424. this._keyUpPrevented = false;
  1425. };
  1426. Search.prototype.searchRemoveChoice = function (decorated, item) {
  1427. this.trigger('unselect', {
  1428. data: item
  1429. });
  1430. this.trigger('open');
  1431. this.$search.val(item.text + ' ');
  1432. };
  1433. Search.prototype.resizeSearch = function () {
  1434. this.$search.css('width', '25px');
  1435. var width = '';
  1436. if (this.$search.attr('placeholder') !== '') {
  1437. width = this.$selection.find('.select2-selection__rendered').innerWidth();
  1438. } else {
  1439. var minimumWidth = this.$search.val().length + 1;
  1440. width = (minimumWidth * 0.75) + 'em';
  1441. }
  1442. this.$search.css('width', width);
  1443. };
  1444. return Search;
  1445. });
  1446. S2.define('select2/selection/eventRelay',[
  1447. 'jquery'
  1448. ], function ($) {
  1449. function EventRelay () { }
  1450. EventRelay.prototype.bind = function (decorated, container, $container) {
  1451. var self = this;
  1452. var relayEvents = [
  1453. 'open', 'opening',
  1454. 'close', 'closing',
  1455. 'select', 'selecting',
  1456. 'unselect', 'unselecting'
  1457. ];
  1458. var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
  1459. decorated.call(this, container, $container);
  1460. container.on('*', function (name, params) {
  1461. // Ignore events that should not be relayed
  1462. if ($.inArray(name, relayEvents) === -1) {
  1463. return;
  1464. }
  1465. // The parameters should always be an object
  1466. params = params || {};
  1467. // Generate the jQuery event for the Select2 event
  1468. var evt = $.Event('select2:' + name, {
  1469. params: params
  1470. });
  1471. self.$element.trigger(evt);
  1472. // Only handle preventable events if it was one
  1473. if ($.inArray(name, preventableEvents) === -1) {
  1474. return;
  1475. }
  1476. params.prevented = evt.isDefaultPrevented();
  1477. });
  1478. };
  1479. return EventRelay;
  1480. });
  1481. S2.define('select2/translation',[
  1482. 'jquery',
  1483. 'require'
  1484. ], function ($, require) {
  1485. function Translation (dict) {
  1486. this.dict = dict || {};
  1487. }
  1488. Translation.prototype.all = function () {
  1489. return this.dict;
  1490. };
  1491. Translation.prototype.get = function (key) {
  1492. return this.dict[key];
  1493. };
  1494. Translation.prototype.extend = function (translation) {
  1495. this.dict = $.extend({}, translation.all(), this.dict);
  1496. };
  1497. // Static functions
  1498. Translation._cache = {};
  1499. Translation.loadPath = function (path) {
  1500. if (!(path in Translation._cache)) {
  1501. var translations = require(path);
  1502. Translation._cache[path] = translations;
  1503. }
  1504. return new Translation(Translation._cache[path]);
  1505. };
  1506. return Translation;
  1507. });
  1508. S2.define('select2/diacritics',[
  1509. ], function () {
  1510. var diacritics = {
  1511. '\u24B6': 'A',
  1512. '\uFF21': 'A',
  1513. '\u00C0': 'A',
  1514. '\u00C1': 'A',
  1515. '\u00C2': 'A',
  1516. '\u1EA6': 'A',
  1517. '\u1EA4': 'A',
  1518. '\u1EAA': 'A',
  1519. '\u1EA8': 'A',
  1520. '\u00C3': 'A',
  1521. '\u0100': 'A',
  1522. '\u0102': 'A',
  1523. '\u1EB0': 'A',
  1524. '\u1EAE': 'A',
  1525. '\u1EB4': 'A',
  1526. '\u1EB2': 'A',
  1527. '\u0226': 'A',
  1528. '\u01E0': 'A',
  1529. '\u00C4': 'A',
  1530. '\u01DE': 'A',
  1531. '\u1EA2': 'A',
  1532. '\u00C5': 'A',
  1533. '\u01FA': 'A',
  1534. '\u01CD': 'A',
  1535. '\u0200': 'A',
  1536. '\u0202': 'A',
  1537. '\u1EA0': 'A',
  1538. '\u1EAC': 'A',
  1539. '\u1EB6': 'A',
  1540. '\u1E00': 'A',
  1541. '\u0104': 'A',
  1542. '\u023A': 'A',
  1543. '\u2C6F': 'A',
  1544. '\uA732': 'AA',
  1545. '\u00C6': 'AE',
  1546. '\u01FC': 'AE',
  1547. '\u01E2': 'AE',
  1548. '\uA734': 'AO',
  1549. '\uA736': 'AU',
  1550. '\uA738': 'AV',
  1551. '\uA73A': 'AV',
  1552. '\uA73C': 'AY',
  1553. '\u24B7': 'B',
  1554. '\uFF22': 'B',
  1555. '\u1E02': 'B',
  1556. '\u1E04': 'B',
  1557. '\u1E06': 'B',
  1558. '\u0243': 'B',
  1559. '\u0182': 'B',
  1560. '\u0181': 'B',
  1561. '\u24B8': 'C',
  1562. '\uFF23': 'C',
  1563. '\u0106': 'C',
  1564. '\u0108': 'C',
  1565. '\u010A': 'C',
  1566. '\u010C': 'C',
  1567. '\u00C7': 'C',
  1568. '\u1E08': 'C',
  1569. '\u0187': 'C',
  1570. '\u023B': 'C',
  1571. '\uA73E': 'C',
  1572. '\u24B9': 'D',
  1573. '\uFF24': 'D',
  1574. '\u1E0A': 'D',
  1575. '\u010E': 'D',
  1576. '\u1E0C': 'D',
  1577. '\u1E10': 'D',
  1578. '\u1E12': 'D',
  1579. '\u1E0E': 'D',
  1580. '\u0110': 'D',
  1581. '\u018B': 'D',
  1582. '\u018A': 'D',
  1583. '\u0189': 'D',
  1584. '\uA779': 'D',
  1585. '\u01F1': 'DZ',
  1586. '\u01C4': 'DZ',
  1587. '\u01F2': 'Dz',
  1588. '\u01C5': 'Dz',
  1589. '\u24BA': 'E',
  1590. '\uFF25': 'E',
  1591. '\u00C8': 'E',
  1592. '\u00C9': 'E',
  1593. '\u00CA': 'E',
  1594. '\u1EC0': 'E',
  1595. '\u1EBE': 'E',
  1596. '\u1EC4': 'E',
  1597. '\u1EC2': 'E',
  1598. '\u1EBC': 'E',
  1599. '\u0112': 'E',
  1600. '\u1E14': 'E',
  1601. '\u1E16': 'E',
  1602. '\u0114': 'E',
  1603. '\u0116': 'E',
  1604. '\u00CB': 'E',
  1605. '\u1EBA': 'E',
  1606. '\u011A': 'E',
  1607. '\u0204': 'E',
  1608. '\u0206': 'E',
  1609. '\u1EB8': 'E',
  1610. '\u1EC6': 'E',
  1611. '\u0228': 'E',
  1612. '\u1E1C': 'E',
  1613. '\u0118': 'E',
  1614. '\u1E18': 'E',
  1615. '\u1E1A': 'E',
  1616. '\u0190': 'E',
  1617. '\u018E': 'E',
  1618. '\u24BB': 'F',
  1619. '\uFF26': 'F',
  1620. '\u1E1E': 'F',
  1621. '\u0191': 'F',
  1622. '\uA77B': 'F',
  1623. '\u24BC': 'G',
  1624. '\uFF27': 'G',
  1625. '\u01F4': 'G',
  1626. '\u011C': 'G',
  1627. '\u1E20': 'G',
  1628. '\u011E': 'G',
  1629. '\u0120': 'G',
  1630. '\u01E6': 'G',
  1631. '\u0122': 'G',
  1632. '\u01E4': 'G',
  1633. '\u0193': 'G',
  1634. '\uA7A0': 'G',
  1635. '\uA77D': 'G',
  1636. '\uA77E': 'G',
  1637. '\u24BD': 'H',
  1638. '\uFF28': 'H',
  1639. '\u0124': 'H',
  1640. '\u1E22': 'H',
  1641. '\u1E26': 'H',
  1642. '\u021E': 'H',
  1643. '\u1E24': 'H',
  1644. '\u1E28': 'H',
  1645. '\u1E2A': 'H',
  1646. '\u0126': 'H',
  1647. '\u2C67': 'H',
  1648. '\u2C75': 'H',
  1649. '\uA78D': 'H',
  1650. '\u24BE': 'I',
  1651. '\uFF29': 'I',
  1652. '\u00CC': 'I',
  1653. '\u00CD': 'I',
  1654. '\u00CE': 'I',
  1655. '\u0128': 'I',
  1656. '\u012A': 'I',
  1657. '\u012C': 'I',
  1658. '\u0130': 'I',
  1659. '\u00CF': 'I',
  1660. '\u1E2E': 'I',
  1661. '\u1EC8': 'I',
  1662. '\u01CF': 'I',
  1663. '\u0208': 'I',
  1664. '\u020A': 'I',
  1665. '\u1ECA': 'I',
  1666. '\u012E': 'I',
  1667. '\u1E2C': 'I',
  1668. '\u0197': 'I',
  1669. '\u24BF': 'J',
  1670. '\uFF2A': 'J',
  1671. '\u0134': 'J',
  1672. '\u0248': 'J',
  1673. '\u24C0': 'K',
  1674. '\uFF2B': 'K',
  1675. '\u1E30': 'K',
  1676. '\u01E8': 'K',
  1677. '\u1E32': 'K',
  1678. '\u0136': 'K',
  1679. '\u1E34': 'K',
  1680. '\u0198': 'K',
  1681. '\u2C69': 'K',
  1682. '\uA740': 'K',
  1683. '\uA742': 'K',
  1684. '\uA744': 'K',
  1685. '\uA7A2': 'K',
  1686. '\u24C1': 'L',
  1687. '\uFF2C': 'L',
  1688. '\u013F': 'L',
  1689. '\u0139': 'L',
  1690. '\u013D': 'L',
  1691. '\u1E36': 'L',
  1692. '\u1E38': 'L',
  1693. '\u013B': 'L',
  1694. '\u1E3C': 'L',
  1695. '\u1E3A': 'L',
  1696. '\u0141': 'L',
  1697. '\u023D': 'L',
  1698. '\u2C62': 'L',
  1699. '\u2C60': 'L',
  1700. '\uA748': 'L',
  1701. '\uA746': 'L',
  1702. '\uA780': 'L',
  1703. '\u01C7': 'LJ',
  1704. '\u01C8': 'Lj',
  1705. '\u24C2': 'M',
  1706. '\uFF2D': 'M',
  1707. '\u1E3E': 'M',
  1708. '\u1E40': 'M',
  1709. '\u1E42': 'M',
  1710. '\u2C6E': 'M',
  1711. '\u019C': 'M',
  1712. '\u24C3': 'N',
  1713. '\uFF2E': 'N',
  1714. '\u01F8': 'N',
  1715. '\u0143': 'N',
  1716. '\u00D1': 'N',
  1717. '\u1E44': 'N',
  1718. '\u0147': 'N',
  1719. '\u1E46': 'N',
  1720. '\u0145': 'N',
  1721. '\u1E4A': 'N',
  1722. '\u1E48': 'N',
  1723. '\u0220': 'N',
  1724. '\u019D': 'N',
  1725. '\uA790': 'N',
  1726. '\uA7A4': 'N',
  1727. '\u01CA': 'NJ',
  1728. '\u01CB': 'Nj',
  1729. '\u24C4': 'O',
  1730. '\uFF2F': 'O',
  1731. '\u00D2': 'O',
  1732. '\u00D3': 'O',
  1733. '\u00D4': 'O',
  1734. '\u1ED2': 'O',
  1735. '\u1ED0': 'O',
  1736. '\u1ED6': 'O',
  1737. '\u1ED4': 'O',
  1738. '\u00D5': 'O',
  1739. '\u1E4C': 'O',
  1740. '\u022C': 'O',
  1741. '\u1E4E': 'O',
  1742. '\u014C': 'O',
  1743. '\u1E50': 'O',
  1744. '\u1E52': 'O',
  1745. '\u014E': 'O',
  1746. '\u022E': 'O',
  1747. '\u0230': 'O',
  1748. '\u00D6': 'O',
  1749. '\u022A': 'O',
  1750. '\u1ECE': 'O',
  1751. '\u0150': 'O',
  1752. '\u01D1': 'O',
  1753. '\u020C': 'O',
  1754. '\u020E': 'O',
  1755. '\u01A0': 'O',
  1756. '\u1EDC': 'O',
  1757. '\u1EDA': 'O',
  1758. '\u1EE0': 'O',
  1759. '\u1EDE': 'O',
  1760. '\u1EE2': 'O',
  1761. '\u1ECC': 'O',
  1762. '\u1ED8': 'O',
  1763. '\u01EA': 'O',
  1764. '\u01EC': 'O',
  1765. '\u00D8': 'O',
  1766. '\u01FE': 'O',
  1767. '\u0186': 'O',
  1768. '\u019F': 'O',
  1769. '\uA74A': 'O',
  1770. '\uA74C': 'O',
  1771. '\u01A2': 'OI',
  1772. '\uA74E': 'OO',
  1773. '\u0222': 'OU',
  1774. '\u24C5': 'P',
  1775. '\uFF30': 'P',
  1776. '\u1E54': 'P',
  1777. '\u1E56': 'P',
  1778. '\u01A4': 'P',
  1779. '\u2C63': 'P',
  1780. '\uA750': 'P',
  1781. '\uA752': 'P',
  1782. '\uA754': 'P',
  1783. '\u24C6': 'Q',
  1784. '\uFF31': 'Q',
  1785. '\uA756': 'Q',
  1786. '\uA758': 'Q',
  1787. '\u024A': 'Q',
  1788. '\u24C7': 'R',
  1789. '\uFF32': 'R',
  1790. '\u0154': 'R',
  1791. '\u1E58': 'R',
  1792. '\u0158': 'R',
  1793. '\u0210': 'R',
  1794. '\u0212': 'R',
  1795. '\u1E5A': 'R',
  1796. '\u1E5C': 'R',
  1797. '\u0156': 'R',
  1798. '\u1E5E': 'R',
  1799. '\u024C': 'R',
  1800. '\u2C64': 'R',
  1801. '\uA75A': 'R',
  1802. '\uA7A6': 'R',
  1803. '\uA782': 'R',
  1804. '\u24C8': 'S',
  1805. '\uFF33': 'S',
  1806. '\u1E9E': 'S',
  1807. '\u015A': 'S',
  1808. '\u1E64': 'S',
  1809. '\u015C': 'S',
  1810. '\u1E60': 'S',
  1811. '\u0160': 'S',
  1812. '\u1E66': 'S',
  1813. '\u1E62': 'S',
  1814. '\u1E68': 'S',
  1815. '\u0218': 'S',
  1816. '\u015E': 'S',
  1817. '\u2C7E': 'S',
  1818. '\uA7A8': 'S',
  1819. '\uA784': 'S',
  1820. '\u24C9': 'T',
  1821. '\uFF34': 'T',
  1822. '\u1E6A': 'T',
  1823. '\u0164': 'T',
  1824. '\u1E6C': 'T',
  1825. '\u021A': 'T',
  1826. '\u0162': 'T',
  1827. '\u1E70': 'T',
  1828. '\u1E6E': 'T',
  1829. '\u0166': 'T',
  1830. '\u01AC': 'T',
  1831. '\u01AE': 'T',
  1832. '\u023E': 'T',
  1833. '\uA786': 'T',
  1834. '\uA728': 'TZ',
  1835. '\u24CA': 'U',
  1836. '\uFF35': 'U',
  1837. '\u00D9': 'U',
  1838. '\u00DA': 'U',
  1839. '\u00DB': 'U',
  1840. '\u0168': 'U',
  1841. '\u1E78': 'U',
  1842. '\u016A': 'U',
  1843. '\u1E7A': 'U',
  1844. '\u016C': 'U',
  1845. '\u00DC': 'U',
  1846. '\u01DB': 'U',
  1847. '\u01D7': 'U',
  1848. '\u01D5': 'U',
  1849. '\u01D9': 'U',
  1850. '\u1EE6': 'U',
  1851. '\u016E': 'U',
  1852. '\u0170': 'U',
  1853. '\u01D3': 'U',
  1854. '\u0214': 'U',
  1855. '\u0216': 'U',
  1856. '\u01AF': 'U',
  1857. '\u1EEA': 'U',
  1858. '\u1EE8': 'U',
  1859. '\u1EEE': 'U',
  1860. '\u1EEC': 'U',
  1861. '\u1EF0': 'U',
  1862. '\u1EE4': 'U',
  1863. '\u1E72': 'U',
  1864. '\u0172': 'U',
  1865. '\u1E76': 'U',
  1866. '\u1E74': 'U',
  1867. '\u0244': 'U',
  1868. '\u24CB': 'V',
  1869. '\uFF36': 'V',
  1870. '\u1E7C': 'V',
  1871. '\u1E7E': 'V',
  1872. '\u01B2': 'V',
  1873. '\uA75E': 'V',
  1874. '\u0245': 'V',
  1875. '\uA760': 'VY',
  1876. '\u24CC': 'W',
  1877. '\uFF37': 'W',
  1878. '\u1E80': 'W',
  1879. '\u1E82': 'W',
  1880. '\u0174': 'W',
  1881. '\u1E86': 'W',
  1882. '\u1E84': 'W',
  1883. '\u1E88': 'W',
  1884. '\u2C72': 'W',
  1885. '\u24CD': 'X',
  1886. '\uFF38': 'X',
  1887. '\u1E8A': 'X',
  1888. '\u1E8C': 'X',
  1889. '\u24CE': 'Y',
  1890. '\uFF39': 'Y',
  1891. '\u1EF2': 'Y',
  1892. '\u00DD': 'Y',
  1893. '\u0176': 'Y',
  1894. '\u1EF8': 'Y',
  1895. '\u0232': 'Y',
  1896. '\u1E8E': 'Y',
  1897. '\u0178': 'Y',
  1898. '\u1EF6': 'Y',
  1899. '\u1EF4': 'Y',
  1900. '\u01B3': 'Y',
  1901. '\u024E': 'Y',
  1902. '\u1EFE': 'Y',
  1903. '\u24CF': 'Z',
  1904. '\uFF3A': 'Z',
  1905. '\u0179': 'Z',
  1906. '\u1E90': 'Z',
  1907. '\u017B': 'Z',
  1908. '\u017D': 'Z',
  1909. '\u1E92': 'Z',
  1910. '\u1E94': 'Z',
  1911. '\u01B5': 'Z',
  1912. '\u0224': 'Z',
  1913. '\u2C7F': 'Z',
  1914. '\u2C6B': 'Z',
  1915. '\uA762': 'Z',
  1916. '\u24D0': 'a',
  1917. '\uFF41': 'a',
  1918. '\u1E9A': 'a',
  1919. '\u00E0': 'a',
  1920. '\u00E1': 'a',
  1921. '\u00E2': 'a',
  1922. '\u1EA7': 'a',
  1923. '\u1EA5': 'a',
  1924. '\u1EAB': 'a',
  1925. '\u1EA9': 'a',
  1926. '\u00E3': 'a',
  1927. '\u0101': 'a',
  1928. '\u0103': 'a',
  1929. '\u1EB1': 'a',
  1930. '\u1EAF': 'a',
  1931. '\u1EB5': 'a',
  1932. '\u1EB3': 'a',
  1933. '\u0227': 'a',
  1934. '\u01E1': 'a',
  1935. '\u00E4': 'a',
  1936. '\u01DF': 'a',
  1937. '\u1EA3': 'a',
  1938. '\u00E5': 'a',
  1939. '\u01FB': 'a',
  1940. '\u01CE': 'a',
  1941. '\u0201': 'a',
  1942. '\u0203': 'a',
  1943. '\u1EA1': 'a',
  1944. '\u1EAD': 'a',
  1945. '\u1EB7': 'a',
  1946. '\u1E01': 'a',
  1947. '\u0105': 'a',
  1948. '\u2C65': 'a',
  1949. '\u0250': 'a',
  1950. '\uA733': 'aa',
  1951. '\u00E6': 'ae',
  1952. '\u01FD': 'ae',
  1953. '\u01E3': 'ae',
  1954. '\uA735': 'ao',
  1955. '\uA737': 'au',
  1956. '\uA739': 'av',
  1957. '\uA73B': 'av',
  1958. '\uA73D': 'ay',
  1959. '\u24D1': 'b',
  1960. '\uFF42': 'b',
  1961. '\u1E03': 'b',
  1962. '\u1E05': 'b',
  1963. '\u1E07': 'b',
  1964. '\u0180': 'b',
  1965. '\u0183': 'b',
  1966. '\u0253': 'b',
  1967. '\u24D2': 'c',
  1968. '\uFF43': 'c',
  1969. '\u0107': 'c',
  1970. '\u0109': 'c',
  1971. '\u010B': 'c',
  1972. '\u010D': 'c',
  1973. '\u00E7': 'c',
  1974. '\u1E09': 'c',
  1975. '\u0188': 'c',
  1976. '\u023C': 'c',
  1977. '\uA73F': 'c',
  1978. '\u2184': 'c',
  1979. '\u24D3': 'd',
  1980. '\uFF44': 'd',
  1981. '\u1E0B': 'd',
  1982. '\u010F': 'd',
  1983. '\u1E0D': 'd',
  1984. '\u1E11': 'd',
  1985. '\u1E13': 'd',
  1986. '\u1E0F': 'd',
  1987. '\u0111': 'd',
  1988. '\u018C': 'd',
  1989. '\u0256': 'd',
  1990. '\u0257': 'd',
  1991. '\uA77A': 'd',
  1992. '\u01F3': 'dz',
  1993. '\u01C6': 'dz',
  1994. '\u24D4': 'e',
  1995. '\uFF45': 'e',
  1996. '\u00E8': 'e',
  1997. '\u00E9': 'e',
  1998. '\u00EA': 'e',
  1999. '\u1EC1': 'e',
  2000. '\u1EBF': 'e',
  2001. '\u1EC5': 'e',
  2002. '\u1EC3': 'e',
  2003. '\u1EBD': 'e',
  2004. '\u0113': 'e',
  2005. '\u1E15': 'e',
  2006. '\u1E17': 'e',
  2007. '\u0115': 'e',
  2008. '\u0117': 'e',
  2009. '\u00EB': 'e',
  2010. '\u1EBB': 'e',
  2011. '\u011B': 'e',
  2012. '\u0205': 'e',
  2013. '\u0207': 'e',
  2014. '\u1EB9': 'e',
  2015. '\u1EC7': 'e',
  2016. '\u0229': 'e',
  2017. '\u1E1D': 'e',
  2018. '\u0119': 'e',
  2019. '\u1E19': 'e',
  2020. '\u1E1B': 'e',
  2021. '\u0247': 'e',
  2022. '\u025B': 'e',
  2023. '\u01DD': 'e',
  2024. '\u24D5': 'f',
  2025. '\uFF46': 'f',
  2026. '\u1E1F': 'f',
  2027. '\u0192': 'f',
  2028. '\uA77C': 'f',
  2029. '\u24D6': 'g',
  2030. '\uFF47': 'g',
  2031. '\u01F5': 'g',
  2032. '\u011D': 'g',
  2033. '\u1E21': 'g',
  2034. '\u011F': 'g',
  2035. '\u0121': 'g',
  2036. '\u01E7': 'g',
  2037. '\u0123': 'g',
  2038. '\u01E5': 'g',
  2039. '\u0260': 'g',
  2040. '\uA7A1': 'g',
  2041. '\u1D79': 'g',
  2042. '\uA77F': 'g',
  2043. '\u24D7': 'h',
  2044. '\uFF48': 'h',
  2045. '\u0125': 'h',
  2046. '\u1E23': 'h',
  2047. '\u1E27': 'h',
  2048. '\u021F': 'h',
  2049. '\u1E25': 'h',
  2050. '\u1E29': 'h',
  2051. '\u1E2B': 'h',
  2052. '\u1E96': 'h',
  2053. '\u0127': 'h',
  2054. '\u2C68': 'h',
  2055. '\u2C76': 'h',
  2056. '\u0265': 'h',
  2057. '\u0195': 'hv',
  2058. '\u24D8': 'i',
  2059. '\uFF49': 'i',
  2060. '\u00EC': 'i',
  2061. '\u00ED': 'i',
  2062. '\u00EE': 'i',
  2063. '\u0129': 'i',
  2064. '\u012B': 'i',
  2065. '\u012D': 'i',
  2066. '\u00EF': 'i',
  2067. '\u1E2F': 'i',
  2068. '\u1EC9': 'i',
  2069. '\u01D0': 'i',
  2070. '\u0209': 'i',
  2071. '\u020B': 'i',
  2072. '\u1ECB': 'i',
  2073. '\u012F': 'i',
  2074. '\u1E2D': 'i',
  2075. '\u0268': 'i',
  2076. '\u0131': 'i',
  2077. '\u24D9': 'j',
  2078. '\uFF4A': 'j',
  2079. '\u0135': 'j',
  2080. '\u01F0': 'j',
  2081. '\u0249': 'j',
  2082. '\u24DA': 'k',
  2083. '\uFF4B': 'k',
  2084. '\u1E31': 'k',
  2085. '\u01E9': 'k',
  2086. '\u1E33': 'k',
  2087. '\u0137': 'k',
  2088. '\u1E35': 'k',
  2089. '\u0199': 'k',
  2090. '\u2C6A': 'k',
  2091. '\uA741': 'k',
  2092. '\uA743': 'k',
  2093. '\uA745': 'k',
  2094. '\uA7A3': 'k',
  2095. '\u24DB': 'l',
  2096. '\uFF4C': 'l',
  2097. '\u0140': 'l',
  2098. '\u013A': 'l',
  2099. '\u013E': 'l',
  2100. '\u1E37': 'l',
  2101. '\u1E39': 'l',
  2102. '\u013C': 'l',
  2103. '\u1E3D': 'l',
  2104. '\u1E3B': 'l',
  2105. '\u017F': 'l',
  2106. '\u0142': 'l',
  2107. '\u019A': 'l',
  2108. '\u026B': 'l',
  2109. '\u2C61': 'l',
  2110. '\uA749': 'l',
  2111. '\uA781': 'l',
  2112. '\uA747': 'l',
  2113. '\u01C9': 'lj',
  2114. '\u24DC': 'm',
  2115. '\uFF4D': 'm',
  2116. '\u1E3F': 'm',
  2117. '\u1E41': 'm',
  2118. '\u1E43': 'm',
  2119. '\u0271': 'm',
  2120. '\u026F': 'm',
  2121. '\u24DD': 'n',
  2122. '\uFF4E': 'n',
  2123. '\u01F9': 'n',
  2124. '\u0144': 'n',
  2125. '\u00F1': 'n',
  2126. '\u1E45': 'n',
  2127. '\u0148': 'n',
  2128. '\u1E47': 'n',
  2129. '\u0146': 'n',
  2130. '\u1E4B': 'n',
  2131. '\u1E49': 'n',
  2132. '\u019E': 'n',
  2133. '\u0272': 'n',
  2134. '\u0149': 'n',
  2135. '\uA791': 'n',
  2136. '\uA7A5': 'n',
  2137. '\u01CC': 'nj',
  2138. '\u24DE': 'o',
  2139. '\uFF4F': 'o',
  2140. '\u00F2': 'o',
  2141. '\u00F3': 'o',
  2142. '\u00F4': 'o',
  2143. '\u1ED3': 'o',
  2144. '\u1ED1': 'o',
  2145. '\u1ED7': 'o',
  2146. '\u1ED5': 'o',
  2147. '\u00F5': 'o',
  2148. '\u1E4D': 'o',
  2149. '\u022D': 'o',
  2150. '\u1E4F': 'o',
  2151. '\u014D': 'o',
  2152. '\u1E51': 'o',
  2153. '\u1E53': 'o',
  2154. '\u014F': 'o',
  2155. '\u022F': 'o',
  2156. '\u0231': 'o',
  2157. '\u00F6': 'o',
  2158. '\u022B': 'o',
  2159. '\u1ECF': 'o',
  2160. '\u0151': 'o',
  2161. '\u01D2': 'o',
  2162. '\u020D': 'o',
  2163. '\u020F': 'o',
  2164. '\u01A1': 'o',
  2165. '\u1EDD': 'o',
  2166. '\u1EDB': 'o',
  2167. '\u1EE1': 'o',
  2168. '\u1EDF': 'o',
  2169. '\u1EE3': 'o',
  2170. '\u1ECD': 'o',
  2171. '\u1ED9': 'o',
  2172. '\u01EB': 'o',
  2173. '\u01ED': 'o',
  2174. '\u00F8': 'o',
  2175. '\u01FF': 'o',
  2176. '\u0254': 'o',
  2177. '\uA74B': 'o',
  2178. '\uA74D': 'o',
  2179. '\u0275': 'o',
  2180. '\u01A3': 'oi',
  2181. '\u0223': 'ou',
  2182. '\uA74F': 'oo',
  2183. '\u24DF': 'p',
  2184. '\uFF50': 'p',
  2185. '\u1E55': 'p',
  2186. '\u1E57': 'p',
  2187. '\u01A5': 'p',
  2188. '\u1D7D': 'p',
  2189. '\uA751': 'p',
  2190. '\uA753': 'p',
  2191. '\uA755': 'p',
  2192. '\u24E0': 'q',
  2193. '\uFF51': 'q',
  2194. '\u024B': 'q',
  2195. '\uA757': 'q',
  2196. '\uA759': 'q',
  2197. '\u24E1': 'r',
  2198. '\uFF52': 'r',
  2199. '\u0155': 'r',
  2200. '\u1E59': 'r',
  2201. '\u0159': 'r',
  2202. '\u0211': 'r',
  2203. '\u0213': 'r',
  2204. '\u1E5B': 'r',
  2205. '\u1E5D': 'r',
  2206. '\u0157': 'r',
  2207. '\u1E5F': 'r',
  2208. '\u024D': 'r',
  2209. '\u027D': 'r',
  2210. '\uA75B': 'r',
  2211. '\uA7A7': 'r',
  2212. '\uA783': 'r',
  2213. '\u24E2': 's',
  2214. '\uFF53': 's',
  2215. '\u00DF': 's',
  2216. '\u015B': 's',
  2217. '\u1E65': 's',
  2218. '\u015D': 's',
  2219. '\u1E61': 's',
  2220. '\u0161': 's',
  2221. '\u1E67': 's',
  2222. '\u1E63': 's',
  2223. '\u1E69': 's',
  2224. '\u0219': 's',
  2225. '\u015F': 's',
  2226. '\u023F': 's',
  2227. '\uA7A9': 's',
  2228. '\uA785': 's',
  2229. '\u1E9B': 's',
  2230. '\u24E3': 't',
  2231. '\uFF54': 't',
  2232. '\u1E6B': 't',
  2233. '\u1E97': 't',
  2234. '\u0165': 't',
  2235. '\u1E6D': 't',
  2236. '\u021B': 't',
  2237. '\u0163': 't',
  2238. '\u1E71': 't',
  2239. '\u1E6F': 't',
  2240. '\u0167': 't',
  2241. '\u01AD': 't',
  2242. '\u0288': 't',
  2243. '\u2C66': 't',
  2244. '\uA787': 't',
  2245. '\uA729': 'tz',
  2246. '\u24E4': 'u',
  2247. '\uFF55': 'u',
  2248. '\u00F9': 'u',
  2249. '\u00FA': 'u',
  2250. '\u00FB': 'u',
  2251. '\u0169': 'u',
  2252. '\u1E79': 'u',
  2253. '\u016B': 'u',
  2254. '\u1E7B': 'u',
  2255. '\u016D': 'u',
  2256. '\u00FC': 'u',
  2257. '\u01DC': 'u',
  2258. '\u01D8': 'u',
  2259. '\u01D6': 'u',
  2260. '\u01DA': 'u',
  2261. '\u1EE7': 'u',
  2262. '\u016F': 'u',
  2263. '\u0171': 'u',
  2264. '\u01D4': 'u',
  2265. '\u0215': 'u',
  2266. '\u0217': 'u',
  2267. '\u01B0': 'u',
  2268. '\u1EEB': 'u',
  2269. '\u1EE9': 'u',
  2270. '\u1EEF': 'u',
  2271. '\u1EED': 'u',
  2272. '\u1EF1': 'u',
  2273. '\u1EE5': 'u',
  2274. '\u1E73': 'u',
  2275. '\u0173': 'u',
  2276. '\u1E77': 'u',
  2277. '\u1E75': 'u',
  2278. '\u0289': 'u',
  2279. '\u24E5': 'v',
  2280. '\uFF56': 'v',
  2281. '\u1E7D': 'v',
  2282. '\u1E7F': 'v',
  2283. '\u028B': 'v',
  2284. '\uA75F': 'v',
  2285. '\u028C': 'v',
  2286. '\uA761': 'vy',
  2287. '\u24E6': 'w',
  2288. '\uFF57': 'w',
  2289. '\u1E81': 'w',
  2290. '\u1E83': 'w',
  2291. '\u0175': 'w',
  2292. '\u1E87': 'w',
  2293. '\u1E85': 'w',
  2294. '\u1E98': 'w',
  2295. '\u1E89': 'w',
  2296. '\u2C73': 'w',
  2297. '\u24E7': 'x',
  2298. '\uFF58': 'x',
  2299. '\u1E8B': 'x',
  2300. '\u1E8D': 'x',
  2301. '\u24E8': 'y',
  2302. '\uFF59': 'y',
  2303. '\u1EF3': 'y',
  2304. '\u00FD': 'y',
  2305. '\u0177': 'y',
  2306. '\u1EF9': 'y',
  2307. '\u0233': 'y',
  2308. '\u1E8F': 'y',
  2309. '\u00FF': 'y',
  2310. '\u1EF7': 'y',
  2311. '\u1E99': 'y',
  2312. '\u1EF5': 'y',
  2313. '\u01B4': 'y',
  2314. '\u024F': 'y',
  2315. '\u1EFF': 'y',
  2316. '\u24E9': 'z',
  2317. '\uFF5A': 'z',
  2318. '\u017A': 'z',
  2319. '\u1E91': 'z',
  2320. '\u017C': 'z',
  2321. '\u017E': 'z',
  2322. '\u1E93': 'z',
  2323. '\u1E95': 'z',
  2324. '\u01B6': 'z',
  2325. '\u0225': 'z',
  2326. '\u0240': 'z',
  2327. '\u2C6C': 'z',
  2328. '\uA763': 'z',
  2329. '\u0386': '\u0391',
  2330. '\u0388': '\u0395',
  2331. '\u0389': '\u0397',
  2332. '\u038A': '\u0399',
  2333. '\u03AA': '\u0399',
  2334. '\u038C': '\u039F',
  2335. '\u038E': '\u03A5',
  2336. '\u03AB': '\u03A5',
  2337. '\u038F': '\u03A9',
  2338. '\u03AC': '\u03B1',
  2339. '\u03AD': '\u03B5',
  2340. '\u03AE': '\u03B7',
  2341. '\u03AF': '\u03B9',
  2342. '\u03CA': '\u03B9',
  2343. '\u0390': '\u03B9',
  2344. '\u03CC': '\u03BF',
  2345. '\u03CD': '\u03C5',
  2346. '\u03CB': '\u03C5',
  2347. '\u03B0': '\u03C5',
  2348. '\u03C9': '\u03C9',
  2349. '\u03C2': '\u03C3'
  2350. };
  2351. return diacritics;
  2352. });
  2353. S2.define('select2/data/base',[
  2354. '../utils'
  2355. ], function (Utils) {
  2356. function BaseAdapter ($element, options) {
  2357. BaseAdapter.__super__.constructor.call(this);
  2358. }
  2359. Utils.Extend(BaseAdapter, Utils.Observable);
  2360. BaseAdapter.prototype.current = function (callback) {
  2361. throw new Error('The `current` method must be defined in child classes.');
  2362. };
  2363. BaseAdapter.prototype.query = function (params, callback) {
  2364. throw new Error('The `query` method must be defined in child classes.');
  2365. };
  2366. BaseAdapter.prototype.bind = function (container, $container) {
  2367. // Can be implemented in subclasses
  2368. };
  2369. BaseAdapter.prototype.destroy = function () {
  2370. // Can be implemented in subclasses
  2371. };
  2372. BaseAdapter.prototype.generateResultId = function (container, data) {
  2373. var id = container.id + '-result-';
  2374. id += Utils.generateChars(4);
  2375. if (data.id != null) {
  2376. id += '-' + data.id.toString();
  2377. } else {
  2378. id += '-' + Utils.generateChars(4);
  2379. }
  2380. return id;
  2381. };
  2382. return BaseAdapter;
  2383. });
  2384. S2.define('select2/data/select',[
  2385. './base',
  2386. '../utils',
  2387. 'jquery'
  2388. ], function (BaseAdapter, Utils, $) {
  2389. function SelectAdapter ($element, options) {
  2390. this.$element = $element;
  2391. this.options = options;
  2392. SelectAdapter.__super__.constructor.call(this);
  2393. }
  2394. Utils.Extend(SelectAdapter, BaseAdapter);
  2395. SelectAdapter.prototype.current = function (callback) {
  2396. var data = [];
  2397. var self = this;
  2398. this.$element.find(':selected').each(function () {
  2399. var $option = $(this);
  2400. var option = self.item($option);
  2401. data.push(option);
  2402. });
  2403. callback(data);
  2404. };
  2405. SelectAdapter.prototype.select = function (data) {
  2406. var self = this;
  2407. // If data.element is a DOM nose, use it instead
  2408. if ($(data.element).is('option')) {
  2409. data.element.selected = true;
  2410. this.$element.trigger('change');
  2411. return;
  2412. }
  2413. if (this.$element.prop('multiple')) {
  2414. this.current(function (currentData) {
  2415. var val = [];
  2416. data = [data];
  2417. data.push.apply(data, currentData);
  2418. for (var d = 0; d < data.length; d++) {
  2419. var id = data[d].id;
  2420. if ($.inArray(id, val) === -1) {
  2421. val.push(id);
  2422. }
  2423. }
  2424. self.$element.val(val);
  2425. self.$element.trigger('change');
  2426. });
  2427. } else {
  2428. var val = data.id;
  2429. this.$element.val(val);
  2430. this.$element.trigger('change');
  2431. }
  2432. };
  2433. SelectAdapter.prototype.unselect = function (data) {
  2434. var self = this;
  2435. if (!this.$element.prop('multiple')) {
  2436. return;
  2437. }
  2438. if ($(data.element).is('option')) {
  2439. data.element.selected = false;
  2440. this.$element.trigger('change');
  2441. return;
  2442. }
  2443. this.current(function (currentData) {
  2444. var val = [];
  2445. for (var d = 0; d < currentData.length; d++) {
  2446. var id = currentData[d].id;
  2447. if (id !== data.id && $.inArray(id, val) === -1) {
  2448. val.push(id);
  2449. }
  2450. }
  2451. self.$element.val(val);
  2452. self.$element.trigger('change');
  2453. });
  2454. };
  2455. SelectAdapter.prototype.bind = function (container, $container) {
  2456. var self = this;
  2457. this.container = container;
  2458. container.on('select', function (params) {
  2459. self.select(params.data);
  2460. });
  2461. container.on('unselect', function (params) {
  2462. self.unselect(params.data);
  2463. });
  2464. };
  2465. SelectAdapter.prototype.destroy = function () {
  2466. // Remove anything added to child elements
  2467. this.$element.find('*').each(function () {
  2468. // Remove any custom data set by Select2
  2469. $.removeData(this, 'data');
  2470. });
  2471. };
  2472. SelectAdapter.prototype.query = function (params, callback) {
  2473. var data = [];
  2474. var self = this;
  2475. var $options = this.$element.children();
  2476. $options.each(function () {
  2477. var $option = $(this);
  2478. if (!$option.is('option') && !$option.is('optgroup')) {
  2479. return;
  2480. }
  2481. var option = self.item($option);
  2482. var matches = self.matches(params, option);
  2483. if (matches !== null) {
  2484. data.push(matches);
  2485. }
  2486. });
  2487. callback({
  2488. results: data
  2489. });
  2490. };
  2491. SelectAdapter.prototype.addOptions = function ($options) {
  2492. this.$element.append($options);
  2493. };
  2494. SelectAdapter.prototype.option = function (data) {
  2495. var option;
  2496. if (data.children) {
  2497. option = document.createElement('optgroup');
  2498. option.label = data.text;
  2499. } else {
  2500. option = document.createElement('option');
  2501. if (option.textContent !== undefined) {
  2502. option.textContent = data.text;
  2503. } else {
  2504. option.innerText = data.text;
  2505. }
  2506. }
  2507. if (data.id) {
  2508. option.value = data.id;
  2509. }
  2510. if (data.disabled) {
  2511. option.disabled = true;
  2512. }
  2513. if (data.selected) {
  2514. option.selected = true;
  2515. }
  2516. if (data.title) {
  2517. option.title = data.title;
  2518. }
  2519. var $option = $(option);
  2520. var normalizedData = this._normalizeItem(data);
  2521. normalizedData.element = option;
  2522. // Override the option's data with the combined data
  2523. $.data(option, 'data', normalizedData);
  2524. return $option;
  2525. };
  2526. SelectAdapter.prototype.item = function ($option) {
  2527. var data = {};
  2528. data = $.data($option[0], 'data');
  2529. if (data != null) {
  2530. return data;
  2531. }
  2532. if ($option.is('option')) {
  2533. data = {
  2534. id: $option.val(),
  2535. text: $option.text(),
  2536. disabled: $option.prop('disabled'),
  2537. selected: $option.prop('selected'),
  2538. title: $option.prop('title')
  2539. };
  2540. } else if ($option.is('optgroup')) {
  2541. data = {
  2542. text: $option.prop('label'),
  2543. children: [],
  2544. title: $option.prop('title')
  2545. };
  2546. var $children = $option.children('option');
  2547. var children = [];
  2548. for (var c = 0; c < $children.length; c++) {
  2549. var $child = $($children[c]);
  2550. var child = this.item($child);
  2551. children.push(child);
  2552. }
  2553. data.children = children;
  2554. }
  2555. data = this._normalizeItem(data);
  2556. data.element = $option[0];
  2557. $.data($option[0], 'data', data);
  2558. return data;
  2559. };
  2560. SelectAdapter.prototype._normalizeItem = function (item) {
  2561. if (!$.isPlainObject(item)) {
  2562. item = {
  2563. id: item,
  2564. text: item
  2565. };
  2566. }
  2567. item = $.extend({}, {
  2568. text: ''
  2569. }, item);
  2570. var defaults = {
  2571. selected: false,
  2572. disabled: false
  2573. };
  2574. if (item.id != null) {
  2575. item.id = item.id.toString();
  2576. }
  2577. if (item.text != null) {
  2578. item.text = item.text.toString();
  2579. }
  2580. if (item._resultId == null && item.id && this.container != null) {
  2581. item._resultId = this.generateResultId(this.container, item);
  2582. }
  2583. return $.extend({}, defaults, item);
  2584. };
  2585. SelectAdapter.prototype.matches = function (params, data) {
  2586. var matcher = this.options.get('matcher');
  2587. return matcher(params, data);
  2588. };
  2589. return SelectAdapter;
  2590. });
  2591. S2.define('select2/data/array',[
  2592. './select',
  2593. '../utils',
  2594. 'jquery'
  2595. ], function (SelectAdapter, Utils, $) {
  2596. function ArrayAdapter ($element, options) {
  2597. var data = options.get('data') || [];
  2598. ArrayAdapter.__super__.constructor.call(this, $element, options);
  2599. this.addOptions(this.convertToOptions(data));
  2600. }
  2601. Utils.Extend(ArrayAdapter, SelectAdapter);
  2602. ArrayAdapter.prototype.select = function (data) {
  2603. var $option = this.$element.find('option[value="' + data.id + '"]');
  2604. if ($option.length === 0) {
  2605. $option = this.option(data);
  2606. this.addOptions($option);
  2607. }
  2608. ArrayAdapter.__super__.select.call(this, data);
  2609. };
  2610. ArrayAdapter.prototype.convertToOptions = function (data) {
  2611. var self = this;
  2612. var $existing = this.$element.find('option');
  2613. var existingIds = $existing.map(function () {
  2614. return self.item($(this)).id;
  2615. }).get();
  2616. var $options = $();
  2617. // Filter out all items except for the one passed in the argument
  2618. function onlyItem (item) {
  2619. return function () {
  2620. return $(this).val() == item.id;
  2621. };
  2622. }
  2623. for (var d = 0; d < data.length; d++) {
  2624. var item = this._normalizeItem(data[d]);
  2625. // Skip items which were pre-loaded, only merge the data
  2626. if ($.inArray(item.id, existingIds) >= 0) {
  2627. var $existingOption = $existing.filter(onlyItem(item));
  2628. var existingData = this.item($existingOption);
  2629. var newData = $.extend(true, {}, existingData, item);
  2630. var $newOption = this.option(existingData);
  2631. $existingOption.replaceWith($newOption);
  2632. continue;
  2633. }
  2634. var $option = this.option(item);
  2635. if (item.children) {
  2636. var $children = this.convertToOptions(item.children);
  2637. $option.append($children);
  2638. }
  2639. $options = $options.add($option);
  2640. }
  2641. return $options;
  2642. };
  2643. return ArrayAdapter;
  2644. });
  2645. S2.define('select2/data/ajax',[
  2646. './array',
  2647. '../utils',
  2648. 'jquery'
  2649. ], function (ArrayAdapter, Utils, $) {
  2650. function AjaxAdapter ($element, options) {
  2651. this.ajaxOptions = this._applyDefaults(options.get('ajax'));
  2652. if (this.ajaxOptions.processResults != null) {
  2653. this.processResults = this.ajaxOptions.processResults;
  2654. }
  2655. ArrayAdapter.__super__.constructor.call(this, $element, options);
  2656. }
  2657. Utils.Extend(AjaxAdapter, ArrayAdapter);
  2658. AjaxAdapter.prototype._applyDefaults = function (options) {
  2659. var defaults = {
  2660. data: function (params) {
  2661. return {
  2662. q: params.term
  2663. };
  2664. },
  2665. transport: function (params, success, failure) {
  2666. var $request = $.ajax(params);
  2667. $request.then(success);
  2668. $request.fail(failure);
  2669. return $request;
  2670. }
  2671. };
  2672. return $.extend({}, defaults, options, true);
  2673. };
  2674. AjaxAdapter.prototype.processResults = function (results) {
  2675. return results;
  2676. };
  2677. AjaxAdapter.prototype.query = function (params, callback) {
  2678. var matches = [];
  2679. var self = this;
  2680. if (this._request) {
  2681. this._request.abort();
  2682. this._request = null;
  2683. }
  2684. var options = $.extend({
  2685. type: 'GET'
  2686. }, this.ajaxOptions);
  2687. if (typeof options.url === 'function') {
  2688. options.url = options.url(params);
  2689. }
  2690. if (typeof options.data === 'function') {
  2691. options.data = options.data(params);
  2692. }
  2693. function request () {
  2694. var $request = options.transport(options, function (data) {
  2695. var results = self.processResults(data, params);
  2696. if (self.options.get('debug') && window.console && console.error) {
  2697. // Check to make sure that the response included a `results` key.
  2698. if (!results || !results.results || !$.isArray(results.results)) {
  2699. console.error(
  2700. 'Select2: The AJAX results did not return an array in the ' +
  2701. '`results` key of the response.'
  2702. );
  2703. }
  2704. }
  2705. callback(results);
  2706. }, function () {
  2707. // TODO: Handle AJAX errors
  2708. });
  2709. self._request = $request;
  2710. }
  2711. if (this.ajaxOptions.delay && params.term !== '') {
  2712. if (this._queryTimeout) {
  2713. window.clearTimeout(this._queryTimeout);
  2714. }
  2715. this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
  2716. } else {
  2717. request();
  2718. }
  2719. };
  2720. return AjaxAdapter;
  2721. });
  2722. S2.define('select2/data/tags',[
  2723. 'jquery'
  2724. ], function ($) {
  2725. function Tags (decorated, $element, options) {
  2726. var tags = options.get('tags');
  2727. var createTag = options.get('createTag');
  2728. if (createTag !== undefined) {
  2729. this.createTag = createTag;
  2730. }
  2731. decorated.call(this, $element, options);
  2732. if ($.isArray(tags)) {
  2733. for (var t = 0; t < tags.length; t++) {
  2734. var tag = tags[t];
  2735. var item = this._normalizeItem(tag);
  2736. var $option = this.option(item);
  2737. this.$element.append($option);
  2738. }
  2739. }
  2740. }
  2741. Tags.prototype.query = function (decorated, params, callback) {
  2742. var self = this;
  2743. this._removeOldTags();
  2744. if (params.term == null || params.page != null) {
  2745. decorated.call(this, params, callback);
  2746. return;
  2747. }
  2748. function wrapper (obj, child) {
  2749. var data = obj.results;
  2750. for (var i = 0; i < data.length; i++) {
  2751. var option = data[i];
  2752. var checkChildren = (
  2753. option.children != null &&
  2754. !wrapper({
  2755. results: option.children
  2756. }, true)
  2757. );
  2758. var checkText = option.text === params.term;
  2759. if (checkText || checkChildren) {
  2760. if (child) {
  2761. return false;
  2762. }
  2763. obj.data = data;
  2764. callback(obj);
  2765. return;
  2766. }
  2767. }
  2768. if (child) {
  2769. return true;
  2770. }
  2771. var tag = self.createTag(params);
  2772. if (tag != null) {
  2773. var $option = self.option(tag);
  2774. $option.attr('data-select2-tag', true);
  2775. self.addOptions($option);
  2776. self.insertTag(data, tag);
  2777. }
  2778. obj.results = data;
  2779. callback(obj);
  2780. }
  2781. decorated.call(this, params, wrapper);
  2782. };
  2783. Tags.prototype.createTag = function (decorated, params) {
  2784. var term = $.trim(params.term);
  2785. if (term === '') {
  2786. return null;
  2787. }
  2788. return {
  2789. id: term,
  2790. text: term
  2791. };
  2792. };
  2793. Tags.prototype.insertTag = function (_, data, tag) {
  2794. data.unshift(tag);
  2795. };
  2796. Tags.prototype._removeOldTags = function (_) {
  2797. var tag = this._lastTag;
  2798. var $options = this.$element.find('option[data-select2-tag]');
  2799. $options.each(function () {
  2800. if (this.selected) {
  2801. return;
  2802. }
  2803. $(this).remove();
  2804. });
  2805. };
  2806. return Tags;
  2807. });
  2808. S2.define('select2/data/tokenizer',[
  2809. 'jquery'
  2810. ], function ($) {
  2811. function Tokenizer (decorated, $element, options) {
  2812. var tokenizer = options.get('tokenizer');
  2813. if (tokenizer !== undefined) {
  2814. this.tokenizer = tokenizer;
  2815. }
  2816. decorated.call(this, $element, options);
  2817. }
  2818. Tokenizer.prototype.bind = function (decorated, container, $container) {
  2819. decorated.call(this, container, $container);
  2820. this.$search = container.dropdown.$search || container.selection.$search ||
  2821. $container.find('.select2-search__field');
  2822. };
  2823. Tokenizer.prototype.query = function (decorated, params, callback) {
  2824. var self = this;
  2825. function select (data) {
  2826. self.select(data);
  2827. }
  2828. params.term = params.term || '';
  2829. var tokenData = this.tokenizer(params, this.options, select);
  2830. if (tokenData.term !== params.term) {
  2831. // Replace the search term if we have the search box
  2832. if (this.$search.length) {
  2833. this.$search.val(tokenData.term);
  2834. this.$search.focus();
  2835. }
  2836. params.term = tokenData.term;
  2837. }
  2838. decorated.call(this, params, callback);
  2839. };
  2840. Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
  2841. var separators = options.get('tokenSeparators') || [];
  2842. var term = params.term;
  2843. var i = 0;
  2844. var createTag = this.createTag || function (params) {
  2845. return {
  2846. id: params.term,
  2847. text: params.term
  2848. };
  2849. };
  2850. while (i < term.length) {
  2851. var termChar = term[i];
  2852. if ($.inArray(termChar, separators) === -1) {
  2853. i++;
  2854. continue;
  2855. }
  2856. var part = term.substr(0, i);
  2857. var partParams = $.extend({}, params, {
  2858. term: part
  2859. });
  2860. var data = createTag(partParams);
  2861. callback(data);
  2862. // Reset the term to not include the tokenized portion
  2863. term = term.substr(i + 1) || '';
  2864. i = 0;
  2865. }
  2866. return {
  2867. term: term
  2868. };
  2869. };
  2870. return Tokenizer;
  2871. });
  2872. S2.define('select2/data/minimumInputLength',[
  2873. ], function () {
  2874. function MinimumInputLength (decorated, $e, options) {
  2875. this.minimumInputLength = options.get('minimumInputLength');
  2876. decorated.call(this, $e, options);
  2877. }
  2878. MinimumInputLength.prototype.query = function (decorated, params, callback) {
  2879. params.term = params.term || '';
  2880. if (params.term.length < this.minimumInputLength) {
  2881. this.trigger('results:message', {
  2882. message: 'inputTooShort',
  2883. args: {
  2884. minimum: this.minimumInputLength,
  2885. input: params.term,
  2886. params: params
  2887. }
  2888. });
  2889. return;
  2890. }
  2891. decorated.call(this, params, callback);
  2892. };
  2893. return MinimumInputLength;
  2894. });
  2895. S2.define('select2/data/maximumInputLength',[
  2896. ], function () {
  2897. function MaximumInputLength (decorated, $e, options) {
  2898. this.maximumInputLength = options.get('maximumInputLength');
  2899. decorated.call(this, $e, options);
  2900. }
  2901. MaximumInputLength.prototype.query = function (decorated, params, callback) {
  2902. params.term = params.term || '';
  2903. if (this.maximumInputLength > 0 &&
  2904. params.term.length > this.maximumInputLength) {
  2905. this.trigger('results:message', {
  2906. message: 'inputTooLong',
  2907. args: {
  2908. maximum: this.maximumInputLength,
  2909. input: params.term,
  2910. params: params
  2911. }
  2912. });
  2913. return;
  2914. }
  2915. decorated.call(this, params, callback);
  2916. };
  2917. return MaximumInputLength;
  2918. });
  2919. S2.define('select2/data/maximumSelectionLength',[
  2920. ], function (){
  2921. function MaximumSelectionLength (decorated, $e, options) {
  2922. this.maximumSelectionLength = options.get('maximumSelectionLength');
  2923. decorated.call(this, $e, options);
  2924. }
  2925. MaximumSelectionLength.prototype.query =
  2926. function (decorated, params, callback) {
  2927. var self = this;
  2928. this.current(function (currentData) {
  2929. var count = currentData != null ? currentData.length : 0;
  2930. if (self.maximumSelectionLength > 0 &&
  2931. count >= self.maximumSelectionLength) {
  2932. self.trigger('results:message', {
  2933. message: 'maximumSelected',
  2934. args: {
  2935. maximum: self.maximumSelectionLength
  2936. }
  2937. });
  2938. return;
  2939. }
  2940. decorated.call(self, params, callback);
  2941. });
  2942. };
  2943. return MaximumSelectionLength;
  2944. });
  2945. S2.define('select2/dropdown',[
  2946. 'jquery',
  2947. './utils'
  2948. ], function ($, Utils) {
  2949. function Dropdown ($element, options) {
  2950. this.$element = $element;
  2951. this.options = options;
  2952. Dropdown.__super__.constructor.call(this);
  2953. }
  2954. Utils.Extend(Dropdown, Utils.Observable);
  2955. Dropdown.prototype.render = function () {
  2956. var $dropdown = $(
  2957. '<span class="select2-dropdown">' +
  2958. '<span class="select2-results"></span>' +
  2959. '</span>'
  2960. );
  2961. $dropdown.attr('dir', this.options.get('dir'));
  2962. this.$dropdown = $dropdown;
  2963. return $dropdown;
  2964. };
  2965. Dropdown.prototype.position = function ($dropdown, $container) {
  2966. // Should be implmented in subclasses
  2967. };
  2968. Dropdown.prototype.destroy = function () {
  2969. // Remove the dropdown from the DOM
  2970. this.$dropdown.remove();
  2971. };
  2972. return Dropdown;
  2973. });
  2974. S2.define('select2/dropdown/search',[
  2975. 'jquery',
  2976. '../utils'
  2977. ], function ($, Utils) {
  2978. function Search () { }
  2979. Search.prototype.render = function (decorated) {
  2980. var $rendered = decorated.call(this);
  2981. var $search = $(
  2982. '<span class="select2-search select2-search--dropdown">' +
  2983. '<input class="select2-search__field" type="search" tabindex="-1"' +
  2984. ' autocomplete="off" autocorrect="off" autocapitalize="off"' +
  2985. ' spellcheck="false" role="textbox" />' +
  2986. '</span>'
  2987. );
  2988. this.$searchContainer = $search;
  2989. this.$search = $search.find('input');
  2990. $rendered.prepend($search);
  2991. return $rendered;
  2992. };
  2993. Search.prototype.bind = function (decorated, container, $container) {
  2994. var self = this;
  2995. decorated.call(this, container, $container);
  2996. this.$search.on('keydown', function (evt) {
  2997. self.trigger('keypress', evt);
  2998. self._keyUpPrevented = evt.isDefaultPrevented();
  2999. });
  3000. // Workaround for browsers which do not support the `input` event
  3001. // This will prevent double-triggering of events for browsers which support
  3002. // both the `keyup` and `input` events.
  3003. this.$search.on('input', function (evt) {
  3004. // Unbind the duplicated `keyup` event
  3005. $(this).off('keyup');
  3006. });
  3007. this.$search.on('keyup input', function (evt) {
  3008. self.handleSearch(evt);
  3009. });
  3010. container.on('open', function () {
  3011. self.$search.attr('tabindex', 0);
  3012. self.$search.focus();
  3013. window.setTimeout(function () {
  3014. self.$search.focus();
  3015. }, 0);
  3016. });
  3017. container.on('close', function () {
  3018. self.$search.attr('tabindex', -1);
  3019. self.$search.val('');
  3020. });
  3021. container.on('results:all', function (params) {
  3022. if (params.query.term == null || params.query.term === '') {
  3023. var showSearch = self.showSearch(params);
  3024. if (showSearch) {
  3025. self.$searchContainer.removeClass('select2-search--hide');
  3026. } else {
  3027. self.$searchContainer.addClass('select2-search--hide');
  3028. }
  3029. }
  3030. });
  3031. };
  3032. Search.prototype.handleSearch = function (evt) {
  3033. if (!this._keyUpPrevented) {
  3034. var input = this.$search.val();
  3035. this.trigger('query', {
  3036. term: input
  3037. });
  3038. }
  3039. this._keyUpPrevented = false;
  3040. };
  3041. Search.prototype.showSearch = function (_, params) {
  3042. return true;
  3043. };
  3044. return Search;
  3045. });
  3046. S2.define('select2/dropdown/hidePlaceholder',[
  3047. ], function () {
  3048. function HidePlaceholder (decorated, $element, options, dataAdapter) {
  3049. this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
  3050. decorated.call(this, $element, options, dataAdapter);
  3051. }
  3052. HidePlaceholder.prototype.append = function (decorated, data) {
  3053. data.results = this.removePlaceholder(data.results);
  3054. decorated.call(this, data);
  3055. };
  3056. HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
  3057. if (typeof placeholder === 'string') {
  3058. placeholder = {
  3059. id: '',
  3060. text: placeholder
  3061. };
  3062. }
  3063. return placeholder;
  3064. };
  3065. HidePlaceholder.prototype.removePlaceholder = function (_, data) {
  3066. var modifiedData = data.slice(0);
  3067. for (var d = data.length - 1; d >= 0; d--) {
  3068. var item = data[d];
  3069. if (this.placeholder.id === item.id) {
  3070. modifiedData.splice(d, 1);
  3071. }
  3072. }
  3073. return modifiedData;
  3074. };
  3075. return HidePlaceholder;
  3076. });
  3077. S2.define('select2/dropdown/infiniteScroll',[
  3078. 'jquery'
  3079. ], function ($) {
  3080. function InfiniteScroll (decorated, $element, options, dataAdapter) {
  3081. this.lastParams = {};
  3082. decorated.call(this, $element, options, dataAdapter);
  3083. this.$loadingMore = this.createLoadingMore();
  3084. this.loading = false;
  3085. }
  3086. InfiniteScroll.prototype.append = function (decorated, data) {
  3087. this.$loadingMore.remove();
  3088. this.loading = false;
  3089. decorated.call(this, data);
  3090. if (this.showLoadingMore(data)) {
  3091. this.$results.append(this.$loadingMore);
  3092. }
  3093. };
  3094. InfiniteScroll.prototype.bind = function (decorated, container, $container) {
  3095. var self = this;
  3096. decorated.call(this, container, $container);
  3097. container.on('query', function (params) {
  3098. self.lastParams = params;
  3099. self.loading = true;
  3100. });
  3101. container.on('query:append', function (params) {
  3102. self.lastParams = params;
  3103. self.loading = true;
  3104. });
  3105. this.$results.on('scroll', function () {
  3106. var isLoadMoreVisible = $.contains(
  3107. document.documentElement,
  3108. self.$loadingMore[0]
  3109. );
  3110. if (self.loading || !isLoadMoreVisible) {
  3111. return;
  3112. }
  3113. var currentOffset = self.$results.offset().top +
  3114. self.$results.outerHeight(false);
  3115. var loadingMoreOffset = self.$loadingMore.offset().top +
  3116. self.$loadingMore.outerHeight(false);
  3117. if (currentOffset + 50 >= loadingMoreOffset) {
  3118. self.loadMore();
  3119. }
  3120. });
  3121. };
  3122. InfiniteScroll.prototype.loadMore = function () {
  3123. this.loading = true;
  3124. var params = $.extend({}, {page: 1}, this.lastParams);
  3125. params.page++;
  3126. this.trigger('query:append', params);
  3127. };
  3128. InfiniteScroll.prototype.showLoadingMore = function (_, data) {
  3129. return data.pagination && data.pagination.more;
  3130. };
  3131. InfiniteScroll.prototype.createLoadingMore = function () {
  3132. var $option = $(
  3133. '<li class="option load-more" role="treeitem"></li>'
  3134. );
  3135. var message = this.options.get('translations').get('loadingMore');
  3136. $option.html(message(this.lastParams));
  3137. return $option;
  3138. };
  3139. return InfiniteScroll;
  3140. });
  3141. S2.define('select2/dropdown/attachBody',[
  3142. 'jquery',
  3143. '../utils'
  3144. ], function ($, Utils) {
  3145. function AttachBody (decorated, $element, options) {
  3146. this.$dropdownParent = options.get('dropdownParent') || document.body;
  3147. decorated.call(this, $element, options);
  3148. }
  3149. AttachBody.prototype.bind = function (decorated, container, $container) {
  3150. var self = this;
  3151. var setupResultsEvents = false;
  3152. decorated.call(this, container, $container);
  3153. container.on('open', function () {
  3154. self._showDropdown();
  3155. self._attachPositioningHandler(container);
  3156. if (!setupResultsEvents) {
  3157. setupResultsEvents = true;
  3158. container.on('results:all', function () {
  3159. self._positionDropdown();
  3160. self._resizeDropdown();
  3161. });
  3162. container.on('results:append', function () {
  3163. self._positionDropdown();
  3164. self._resizeDropdown();
  3165. });
  3166. }
  3167. });
  3168. container.on('close', function () {
  3169. self._hideDropdown();
  3170. self._detachPositioningHandler(container);
  3171. });
  3172. this.$dropdownContainer.on('mousedown', function (evt) {
  3173. evt.stopPropagation();
  3174. });
  3175. };
  3176. AttachBody.prototype.position = function (decorated, $dropdown, $container) {
  3177. // Clone all of the container classes
  3178. $dropdown.attr('class', $container.attr('class'));
  3179. $dropdown.removeClass('select2');
  3180. $dropdown.addClass('select2-container--open');
  3181. $dropdown.css({
  3182. position: 'absolute',
  3183. top: -999999
  3184. });
  3185. this.$container = $container;
  3186. };
  3187. AttachBody.prototype.render = function (decorated) {
  3188. var $container = $('<span></span>');
  3189. var $dropdown = decorated.call(this);
  3190. $container.append($dropdown);
  3191. this.$dropdownContainer = $container;
  3192. return $container;
  3193. };
  3194. AttachBody.prototype._hideDropdown = function (decorated) {
  3195. this.$dropdownContainer.detach();
  3196. };
  3197. AttachBody.prototype._attachPositioningHandler = function (container) {
  3198. var self = this;
  3199. var scrollEvent = 'scroll.select2.' + container.id;
  3200. var resizeEvent = 'resize.select2.' + container.id;
  3201. var orientationEvent = 'orientationchange.select2.' + container.id;
  3202. var $watchers = this.$container.parents().filter(Utils.hasScroll);
  3203. $watchers.each(function () {
  3204. $(this).data('select2-scroll-position', {
  3205. x: $(this).scrollLeft(),
  3206. y: $(this).scrollTop()
  3207. });
  3208. });
  3209. $watchers.on(scrollEvent, function (ev) {
  3210. var position = $(this).data('select2-scroll-position');
  3211. $(this).scrollTop(position.y);
  3212. });
  3213. $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
  3214. function (e) {
  3215. self._positionDropdown();
  3216. self._resizeDropdown();
  3217. });
  3218. };
  3219. AttachBody.prototype._detachPositioningHandler = function (container) {
  3220. var scrollEvent = 'scroll.select2.' + container.id;
  3221. var resizeEvent = 'resize.select2.' + container.id;
  3222. var orientationEvent = 'orientationchange.select2.' + container.id;
  3223. var $watchers = this.$container.parents().filter(Utils.hasScroll);
  3224. $watchers.off(scrollEvent);
  3225. $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
  3226. };
  3227. AttachBody.prototype._positionDropdown = function () {
  3228. var $window = $(window);
  3229. var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
  3230. var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
  3231. var newDirection = null;
  3232. var position = this.$container.position();
  3233. var offset = this.$container.offset();
  3234. offset.bottom = offset.top + this.$container.outerHeight(false);
  3235. var container = {
  3236. height: this.$container.outerHeight(false)
  3237. };
  3238. container.top = offset.top;
  3239. container.bottom = offset.top + container.height;
  3240. var dropdown = {
  3241. height: this.$dropdown.outerHeight(false)
  3242. };
  3243. var viewport = {
  3244. top: $window.scrollTop(),
  3245. bottom: $window.scrollTop() + $window.height()
  3246. };
  3247. var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
  3248. var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
  3249. var css = {
  3250. left: offset.left,
  3251. top: container.bottom
  3252. };
  3253. if (!isCurrentlyAbove && !isCurrentlyBelow) {
  3254. newDirection = 'below';
  3255. }
  3256. if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
  3257. newDirection = 'above';
  3258. } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
  3259. newDirection = 'below';
  3260. }
  3261. if (newDirection == 'above' ||
  3262. (isCurrentlyAbove && newDirection !== 'below')) {
  3263. css.top = container.top - dropdown.height;
  3264. }
  3265. if (newDirection != null) {
  3266. this.$dropdown
  3267. .removeClass('select2-dropdown--below select2-dropdown--above')
  3268. .addClass('select2-dropdown--' + newDirection);
  3269. this.$container
  3270. .removeClass('select2-container--below select2-container--above')
  3271. .addClass('select2-container--' + newDirection);
  3272. }
  3273. this.$dropdownContainer.css(css);
  3274. };
  3275. AttachBody.prototype._resizeDropdown = function () {
  3276. this.$dropdownContainer.width();
  3277. this.$dropdown.css({
  3278. width: this.$container.outerWidth(false) + 'px'
  3279. });
  3280. };
  3281. AttachBody.prototype._showDropdown = function (decorated) {
  3282. this.$dropdownContainer.appendTo(this.$dropdownParent);
  3283. this._positionDropdown();
  3284. this._resizeDropdown();
  3285. };
  3286. return AttachBody;
  3287. });
  3288. S2.define('select2/dropdown/minimumResultsForSearch',[
  3289. ], function () {
  3290. function countResults (data) {
  3291. var count = 0;
  3292. for (var d = 0; d < data.length; d++) {
  3293. var item = data[d];
  3294. if (item.children) {
  3295. count += countResults(item.children);
  3296. } else {
  3297. count++;
  3298. }
  3299. }
  3300. return count;
  3301. }
  3302. function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
  3303. this.minimumResultsForSearch = options.get('minimumResultsForSearch');
  3304. if (this.minimumResultsForSearch < 0) {
  3305. this.minimumResultsForSearch = Infinity;
  3306. }
  3307. decorated.call(this, $element, options, dataAdapter);
  3308. }
  3309. MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
  3310. if (countResults(params.data.results) < this.minimumResultsForSearch) {
  3311. return false;
  3312. }
  3313. return decorated.call(this, params);
  3314. };
  3315. return MinimumResultsForSearch;
  3316. });
  3317. S2.define('select2/dropdown/selectOnClose',[
  3318. ], function () {
  3319. function SelectOnClose () { }
  3320. SelectOnClose.prototype.bind = function (decorated, container, $container) {
  3321. var self = this;
  3322. decorated.call(this, container, $container);
  3323. container.on('close', function () {
  3324. self._handleSelectOnClose();
  3325. });
  3326. };
  3327. SelectOnClose.prototype._handleSelectOnClose = function () {
  3328. var $highlightedResults = this.getHighlightedResults();
  3329. if ($highlightedResults.length < 1) {
  3330. return;
  3331. }
  3332. $highlightedResults.trigger('mouseup');
  3333. };
  3334. return SelectOnClose;
  3335. });
  3336. S2.define('select2/dropdown/closeOnSelect',[
  3337. ], function () {
  3338. function CloseOnSelect () { }
  3339. CloseOnSelect.prototype.bind = function (decorated, container, $container) {
  3340. var self = this;
  3341. decorated.call(this, container, $container);
  3342. container.on('select', function (evt) {
  3343. self._selectTriggered(evt);
  3344. });
  3345. container.on('unselect', function (evt) {
  3346. self._selectTriggered(evt);
  3347. });
  3348. };
  3349. CloseOnSelect.prototype._selectTriggered = function (_, evt) {
  3350. var originalEvent = evt.originalEvent;
  3351. // Don't close if the control key is being held
  3352. if (originalEvent && originalEvent.ctrlKey) {
  3353. return;
  3354. }
  3355. this.trigger('close');
  3356. };
  3357. return CloseOnSelect;
  3358. });
  3359. S2.define('select2/i18n/en',[],function () {
  3360. // English
  3361. return {
  3362. errorLoading: function () {
  3363. return 'The results could not be loaded.';
  3364. },
  3365. inputTooLong: function (args) {
  3366. var overChars = args.input.length - args.maximum;
  3367. var message = 'Please delete ' + overChars + ' character';
  3368. if (overChars != 1) {
  3369. message += 's';
  3370. }
  3371. return message;
  3372. },
  3373. inputTooShort: function (args) {
  3374. var remainingChars = args.minimum - args.input.length;
  3375. var message = 'Please enter ' + remainingChars + ' or more characters';
  3376. return message;
  3377. },
  3378. loadingMore: function () {
  3379. return 'Loading more results…';
  3380. },
  3381. maximumSelected: function (args) {
  3382. var message = 'You can only select ' + args.maximum + ' item';
  3383. if (args.maximum != 1) {
  3384. message += 's';
  3385. }
  3386. return message;
  3387. },
  3388. noResults: function () {
  3389. return 'No results found';
  3390. },
  3391. searching: function () {
  3392. return 'Searching…';
  3393. }
  3394. };
  3395. });
  3396. S2.define('select2/defaults',[
  3397. 'jquery',
  3398. './results',
  3399. './selection/single',
  3400. './selection/multiple',
  3401. './selection/placeholder',
  3402. './selection/allowClear',
  3403. './selection/search',
  3404. './selection/eventRelay',
  3405. './utils',
  3406. './translation',
  3407. './diacritics',
  3408. './data/select',
  3409. './data/array',
  3410. './data/ajax',
  3411. './data/tags',
  3412. './data/tokenizer',
  3413. './data/minimumInputLength',
  3414. './data/maximumInputLength',
  3415. './data/maximumSelectionLength',
  3416. './dropdown',
  3417. './dropdown/search',
  3418. './dropdown/hidePlaceholder',
  3419. './dropdown/infiniteScroll',
  3420. './dropdown/attachBody',
  3421. './dropdown/minimumResultsForSearch',
  3422. './dropdown/selectOnClose',
  3423. './dropdown/closeOnSelect',
  3424. './i18n/en'
  3425. ], function ($, ResultsList,
  3426. SingleSelection, MultipleSelection, Placeholder, AllowClear,
  3427. SelectionSearch, EventRelay,
  3428. Utils, Translation, DIACRITICS,
  3429. SelectData, ArrayData, AjaxData, Tags, Tokenizer,
  3430. MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
  3431. Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
  3432. AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
  3433. EnglishTranslation) {
  3434. function Defaults () {
  3435. this.reset();
  3436. }
  3437. Defaults.prototype.apply = function (options) {
  3438. options = $.extend({}, this.defaults, options);
  3439. if (options.dataAdapter == null) {
  3440. if (options.ajax != null) {
  3441. options.dataAdapter = AjaxData;
  3442. } else if (options.data != null) {
  3443. options.dataAdapter = ArrayData;
  3444. } else {
  3445. options.dataAdapter = SelectData;
  3446. }
  3447. if (options.minimumInputLength > 0) {
  3448. options.dataAdapter = Utils.Decorate(
  3449. options.dataAdapter,
  3450. MinimumInputLength
  3451. );
  3452. }
  3453. if (options.maximumInputLength > 0) {
  3454. options.dataAdapter = Utils.Decorate(
  3455. options.dataAdapter,
  3456. MaximumInputLength
  3457. );
  3458. }
  3459. if (options.maximumSelectionLength > 0) {
  3460. options.dataAdapter = Utils.Decorate(
  3461. options.dataAdapter,
  3462. MaximumSelectionLength
  3463. );
  3464. }
  3465. if (options.tags != null) {
  3466. options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
  3467. }
  3468. if (options.tokenSeparators != null || options.tokenizer != null) {
  3469. options.dataAdapter = Utils.Decorate(
  3470. options.dataAdapter,
  3471. Tokenizer
  3472. );
  3473. }
  3474. if (options.query != null) {
  3475. var Query = require(options.amdBase + 'compat/query');
  3476. options.dataAdapter = Utils.Decorate(
  3477. options.dataAdapter,
  3478. Query
  3479. );
  3480. }
  3481. if (options.initSelection != null) {
  3482. var InitSelection = require(options.amdBase + 'compat/initSelection');
  3483. options.dataAdapter = Utils.Decorate(
  3484. options.dataAdapter,
  3485. InitSelection
  3486. );
  3487. }
  3488. }
  3489. if (options.resultsAdapter == null) {
  3490. options.resultsAdapter = ResultsList;
  3491. if (options.ajax != null) {
  3492. options.resultsAdapter = Utils.Decorate(
  3493. options.resultsAdapter,
  3494. InfiniteScroll
  3495. );
  3496. }
  3497. if (options.placeholder != null) {
  3498. options.resultsAdapter = Utils.Decorate(
  3499. options.resultsAdapter,
  3500. HidePlaceholder
  3501. );
  3502. }
  3503. if (options.selectOnClose) {
  3504. options.resultsAdapter = Utils.Decorate(
  3505. options.resultsAdapter,
  3506. SelectOnClose
  3507. );
  3508. }
  3509. }
  3510. if (options.dropdownAdapter == null) {
  3511. if (options.multiple) {
  3512. options.dropdownAdapter = Dropdown;
  3513. } else {
  3514. var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
  3515. options.dropdownAdapter = SearchableDropdown;
  3516. }
  3517. if (options.minimumResultsForSearch !== 0) {
  3518. options.dropdownAdapter = Utils.Decorate(
  3519. options.dropdownAdapter,
  3520. MinimumResultsForSearch
  3521. );
  3522. }
  3523. if (options.closeOnSelect) {
  3524. options.dropdownAdapter = Utils.Decorate(
  3525. options.dropdownAdapter,
  3526. CloseOnSelect
  3527. );
  3528. }
  3529. options.dropdownAdapter = Utils.Decorate(
  3530. options.dropdownAdapter,
  3531. AttachBody
  3532. );
  3533. }
  3534. if (options.selectionAdapter == null) {
  3535. if (options.multiple) {
  3536. options.selectionAdapter = MultipleSelection;
  3537. } else {
  3538. options.selectionAdapter = SingleSelection;
  3539. }
  3540. // Add the placeholder mixin if a placeholder was specified
  3541. if (options.placeholder != null) {
  3542. options.selectionAdapter = Utils.Decorate(
  3543. options.selectionAdapter,
  3544. Placeholder
  3545. );
  3546. }
  3547. if (options.allowClear) {
  3548. options.selectionAdapter = Utils.Decorate(
  3549. options.selectionAdapter,
  3550. AllowClear
  3551. );
  3552. }
  3553. if (options.multiple) {
  3554. options.selectionAdapter = Utils.Decorate(
  3555. options.selectionAdapter,
  3556. SelectionSearch
  3557. );
  3558. }
  3559. options.selectionAdapter = Utils.Decorate(
  3560. options.selectionAdapter,
  3561. EventRelay
  3562. );
  3563. }
  3564. if (typeof options.language === 'string') {
  3565. // Check if the language is specified with a region
  3566. if (options.language.indexOf('-') > 0) {
  3567. // Extract the region information if it is included
  3568. var languageParts = options.language.split('-');
  3569. var baseLanguage = languageParts[0];
  3570. options.language = [options.language, baseLanguage];
  3571. } else {
  3572. options.language = [options.language];
  3573. }
  3574. }
  3575. if ($.isArray(options.language)) {
  3576. var languages = new Translation();
  3577. options.language.push('en');
  3578. var languageNames = options.language;
  3579. for (var l = 0; l < languageNames.length; l++) {
  3580. var name = languageNames[l];
  3581. var language = {};
  3582. try {
  3583. // Try to load it with the original name
  3584. language = Translation.loadPath(name);
  3585. } catch (e) {
  3586. try {
  3587. // If we couldn't load it, check if it wasn't the full path
  3588. name = this.defaults.amdLanguageBase + name;
  3589. language = Translation.loadPath(name);
  3590. } catch (ex) {
  3591. // The translation could not be loaded at all. Sometimes this is
  3592. // because of a configuration problem, other times this can be
  3593. // because of how Select2 helps load all possible translation files.
  3594. if (options.debug && window.console && console.warn) {
  3595. console.warn(
  3596. 'Select2: The language file for "' + name + '" could not be ' +
  3597. 'automatically loaded. A fallback will be used instead.'
  3598. );
  3599. }
  3600. continue;
  3601. }
  3602. }
  3603. languages.extend(language);
  3604. }
  3605. options.translations = languages;
  3606. } else {
  3607. options.translations = new Translation(options.language);
  3608. }
  3609. return options;
  3610. };
  3611. Defaults.prototype.reset = function () {
  3612. function stripDiacritics (text) {
  3613. // Used 'uni range + named function' from http://jsperf.com/diacritics/18
  3614. function match(a) {
  3615. return DIACRITICS[a] || a;
  3616. }
  3617. return text.replace(/[^\u0000-\u007E]/g, match);
  3618. }
  3619. function matcher (params, data) {
  3620. // Always return the object if there is nothing to compare
  3621. if ($.trim(params.term) === '') {
  3622. return data;
  3623. }
  3624. // Do a recursive check for options with children
  3625. if (data.children && data.children.length > 0) {
  3626. // Clone the data object if there are children
  3627. // This is required as we modify the object to remove any non-matches
  3628. var match = $.extend(true, {}, data);
  3629. // Check each child of the option
  3630. for (var c = data.children.length - 1; c >= 0; c--) {
  3631. var child = data.children[c];
  3632. var matches = matcher(params, child);
  3633. // If there wasn't a match, remove the object in the array
  3634. if (matches == null) {
  3635. match.children.splice(c, 1);
  3636. }
  3637. }
  3638. // If any children matched, return the new object
  3639. if (match.children.length > 0) {
  3640. return match;
  3641. }
  3642. // If there were no matching children, check just the plain object
  3643. return matcher(params, match);
  3644. }
  3645. var original = stripDiacritics(data.text).toUpperCase();
  3646. var term = stripDiacritics(params.term).toUpperCase();
  3647. // Check if the text contains the term
  3648. if (original.indexOf(term) > -1) {
  3649. return data;
  3650. }
  3651. // If it doesn't contain the term, don't return anything
  3652. return null;
  3653. }
  3654. this.defaults = {
  3655. amdBase: 'select2/',
  3656. amdLanguageBase: 'select2/i18n/',
  3657. closeOnSelect: true,
  3658. debug: false,
  3659. escapeMarkup: Utils.escapeMarkup,
  3660. language: EnglishTranslation,
  3661. matcher: matcher,
  3662. minimumInputLength: 0,
  3663. maximumInputLength: 0,
  3664. maximumSelectionLength: 0,
  3665. minimumResultsForSearch: 0,
  3666. selectOnClose: false,
  3667. sorter: function (data) {
  3668. return data;
  3669. },
  3670. templateResult: function (result) {
  3671. return result.text;
  3672. },
  3673. templateSelection: function (selection) {
  3674. return selection.text;
  3675. },
  3676. theme: 'default',
  3677. width: 'resolve'
  3678. };
  3679. };
  3680. Defaults.prototype.set = function (key, value) {
  3681. var camelKey = $.camelCase(key);
  3682. var data = {};
  3683. data[camelKey] = value;
  3684. var convertedData = Utils._convertData(data);
  3685. $.extend(this.defaults, convertedData);
  3686. };
  3687. var defaults = new Defaults();
  3688. return defaults;
  3689. });
  3690. S2.define('select2/options',[
  3691. 'jquery',
  3692. './defaults',
  3693. './utils'
  3694. ], function ($, Defaults, Utils) {
  3695. function Options (options, $element) {
  3696. this.options = options;
  3697. if ($element != null) {
  3698. this.fromElement($element);
  3699. }
  3700. this.options = Defaults.apply(this.options);
  3701. if ($element && $element.is('input')) {
  3702. var InputCompat = require(this.get('amdBase') + 'compat/inputData');
  3703. this.options.dataAdapter = Utils.Decorate(
  3704. this.options.dataAdapter,
  3705. InputCompat
  3706. );
  3707. }
  3708. }
  3709. Options.prototype.fromElement = function ($e) {
  3710. var excludedData = ['select2'];
  3711. if (this.options.multiple == null) {
  3712. this.options.multiple = $e.prop('multiple');
  3713. }
  3714. if (this.options.disabled == null) {
  3715. this.options.disabled = $e.prop('disabled');
  3716. }
  3717. if (this.options.language == null) {
  3718. if ($e.prop('lang')) {
  3719. this.options.language = $e.prop('lang').toLowerCase();
  3720. } else if ($e.closest('[lang]').prop('lang')) {
  3721. this.options.language = $e.closest('[lang]').prop('lang');
  3722. }
  3723. }
  3724. if (this.options.dir == null) {
  3725. if ($e.prop('dir')) {
  3726. this.options.dir = $e.prop('dir');
  3727. } else if ($e.closest('[dir]').prop('dir')) {
  3728. this.options.dir = $e.closest('[dir]').prop('dir');
  3729. } else {
  3730. this.options.dir = 'ltr';
  3731. }
  3732. }
  3733. $e.prop('disabled', this.options.disabled);
  3734. $e.prop('multiple', this.options.multiple);
  3735. if ($e.data('select2Tags')) {
  3736. if (this.options.debug && window.console && console.warn) {
  3737. console.warn(
  3738. 'Select2: The `data-select2-tags` attribute has been changed to ' +
  3739. 'use the `data-data` and `data-tags="true"` attributes and will be ' +
  3740. 'removed in future versions of Select2.'
  3741. );
  3742. }
  3743. $e.data('data', $e.data('select2Tags'));
  3744. $e.data('tags', true);
  3745. }
  3746. if ($e.data('ajaxUrl')) {
  3747. if (this.options.debug && window.console && console.warn) {
  3748. console.warn(
  3749. 'Select2: The `data-ajax-url` attribute has been changed to ' +
  3750. '`data-ajax--url` and support for the old attribute will be removed' +
  3751. ' in future versions of Select2.'
  3752. );
  3753. }
  3754. $e.attr('ajax--url', $e.data('ajaxUrl'));
  3755. $e.data('ajax--url', $e.data('ajaxUrl'));
  3756. }
  3757. var dataset = {};
  3758. // Prefer the element's `dataset` attribute if it exists
  3759. // jQuery 1.x does not correctly handle data attributes with multiple dashes
  3760. if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
  3761. dataset = $.extend(true, {}, $e[0].dataset, $e.data());
  3762. } else {
  3763. dataset = $e.data();
  3764. }
  3765. var data = $.extend(true, {}, dataset);
  3766. data = Utils._convertData(data);
  3767. for (var key in data) {
  3768. if ($.inArray(key, excludedData) > -1) {
  3769. continue;
  3770. }
  3771. if ($.isPlainObject(this.options[key])) {
  3772. $.extend(this.options[key], data[key]);
  3773. } else {
  3774. this.options[key] = data[key];
  3775. }
  3776. }
  3777. return this;
  3778. };
  3779. Options.prototype.get = function (key) {
  3780. return this.options[key];
  3781. };
  3782. Options.prototype.set = function (key, val) {
  3783. this.options[key] = val;
  3784. };
  3785. return Options;
  3786. });
  3787. S2.define('select2/core',[
  3788. 'jquery',
  3789. './options',
  3790. './utils',
  3791. './keys'
  3792. ], function ($, Options, Utils, KEYS) {
  3793. var Select2 = function ($element, options) {
  3794. if ($element.data('select2') != null) {
  3795. $element.data('select2').destroy();
  3796. }
  3797. this.$element = $element;
  3798. this.id = this._generateId($element);
  3799. options = options || {};
  3800. this.options = new Options(options, $element);
  3801. Select2.__super__.constructor.call(this);
  3802. // Set up the tabindex
  3803. var tabindex = $element.attr('tabindex') || 0;
  3804. $element.data('old-tabindex', tabindex);
  3805. $element.attr('tabindex', '-1');
  3806. // Set up containers and adapters
  3807. var DataAdapter = this.options.get('dataAdapter');
  3808. this.dataAdapter = new DataAdapter($element, this.options);
  3809. var $container = this.render();
  3810. this._placeContainer($container);
  3811. var SelectionAdapter = this.options.get('selectionAdapter');
  3812. this.selection = new SelectionAdapter($element, this.options);
  3813. this.$selection = this.selection.render();
  3814. this.selection.position(this.$selection, $container);
  3815. var DropdownAdapter = this.options.get('dropdownAdapter');
  3816. this.dropdown = new DropdownAdapter($element, this.options);
  3817. this.$dropdown = this.dropdown.render();
  3818. this.dropdown.position(this.$dropdown, $container);
  3819. var ResultsAdapter = this.options.get('resultsAdapter');
  3820. this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
  3821. this.$results = this.results.render();
  3822. this.results.position(this.$results, this.$dropdown);
  3823. // Bind events
  3824. var self = this;
  3825. // Bind the container to all of the adapters
  3826. this._bindAdapters();
  3827. // Register any DOM event handlers
  3828. this._registerDomEvents();
  3829. // Register any internal event handlers
  3830. this._registerDataEvents();
  3831. this._registerSelectionEvents();
  3832. this._registerDropdownEvents();
  3833. this._registerResultsEvents();
  3834. this._registerEvents();
  3835. // Set the initial state
  3836. this.dataAdapter.current(function (initialData) {
  3837. self.trigger('selection:update', {
  3838. data: initialData
  3839. });
  3840. });
  3841. // Hide the original select
  3842. $element.hide();
  3843. // Synchronize any monitored attributes
  3844. this._syncAttributes();
  3845. $element.data('select2', this);
  3846. };
  3847. Utils.Extend(Select2, Utils.Observable);
  3848. Select2.prototype._generateId = function ($element) {
  3849. var id = '';
  3850. if ($element.attr('id') != null) {
  3851. id = $element.attr('id');
  3852. } else if ($element.attr('name') != null) {
  3853. id = $element.attr('name') + '-' + Utils.generateChars(2);
  3854. } else {
  3855. id = Utils.generateChars(4);
  3856. }
  3857. id = 'select2-' + id;
  3858. return id;
  3859. };
  3860. Select2.prototype._placeContainer = function ($container) {
  3861. $container.insertAfter(this.$element);
  3862. var width = this._resolveWidth(this.$element, this.options.get('width'));
  3863. if (width != null) {
  3864. $container.css('width', width);
  3865. }
  3866. };
  3867. Select2.prototype._resolveWidth = function ($element, method) {
  3868. var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
  3869. if (method == 'resolve') {
  3870. var styleWidth = this._resolveWidth($element, 'style');
  3871. if (styleWidth != null) {
  3872. return styleWidth;
  3873. }
  3874. return this._resolveWidth($element, 'element');
  3875. }
  3876. if (method == 'element') {
  3877. var elementWidth = $element.outerWidth(false);
  3878. if (elementWidth <= 0) {
  3879. return 'auto';
  3880. }
  3881. return elementWidth + 'px';
  3882. }
  3883. if (method == 'style') {
  3884. var style = $element.attr('style');
  3885. if (typeof(style) !== 'string') {
  3886. return null;
  3887. }
  3888. var attrs = style.split(';');
  3889. for (var i = 0, l = attrs.length; i < l; i = i + 1) {
  3890. var attr = attrs[i].replace(/\s/g, '');
  3891. var matches = attr.match(WIDTH);
  3892. if (matches !== null && matches.length >= 1) {
  3893. return matches[1];
  3894. }
  3895. }
  3896. return null;
  3897. }
  3898. return method;
  3899. };
  3900. Select2.prototype._bindAdapters = function () {
  3901. this.dataAdapter.bind(this, this.$container);
  3902. this.selection.bind(this, this.$container);
  3903. this.dropdown.bind(this, this.$container);
  3904. this.results.bind(this, this.$container);
  3905. };
  3906. Select2.prototype._registerDomEvents = function () {
  3907. var self = this;
  3908. this.$element.on('change.select2', function () {
  3909. self.dataAdapter.current(function (data) {
  3910. self.trigger('selection:update', {
  3911. data: data
  3912. });
  3913. });
  3914. });
  3915. this._sync = Utils.bind(this._syncAttributes, this);
  3916. if (this.$element[0].attachEvent) {
  3917. this.$element[0].attachEvent('onpropertychange', this._sync);
  3918. }
  3919. var observer = window.MutationObserver ||
  3920. window.WebKitMutationObserver ||
  3921. window.MozMutationObserver
  3922. ;
  3923. if (observer != null) {
  3924. this._observer = new observer(function (mutations) {
  3925. $.each(mutations, self._sync);
  3926. });
  3927. this._observer.observe(this.$element[0], {
  3928. attributes: true,
  3929. subtree: false
  3930. });
  3931. } else if (this.$element[0].addEventListener) {
  3932. this.$element[0].addEventListener('DOMAttrModified', self._sync, false);
  3933. }
  3934. };
  3935. Select2.prototype._registerDataEvents = function () {
  3936. var self = this;
  3937. this.dataAdapter.on('*', function (name, params) {
  3938. self.trigger(name, params);
  3939. });
  3940. };
  3941. Select2.prototype._registerSelectionEvents = function () {
  3942. var self = this;
  3943. var nonRelayEvents = ['toggle'];
  3944. this.selection.on('toggle', function () {
  3945. self.toggleDropdown();
  3946. });
  3947. this.selection.on('*', function (name, params) {
  3948. if ($.inArray(name, nonRelayEvents) !== -1) {
  3949. return;
  3950. }
  3951. self.trigger(name, params);
  3952. });
  3953. };
  3954. Select2.prototype._registerDropdownEvents = function () {
  3955. var self = this;
  3956. this.dropdown.on('*', function (name, params) {
  3957. self.trigger(name, params);
  3958. });
  3959. };
  3960. Select2.prototype._registerResultsEvents = function () {
  3961. var self = this;
  3962. this.results.on('*', function (name, params) {
  3963. self.trigger(name, params);
  3964. });
  3965. };
  3966. Select2.prototype._registerEvents = function () {
  3967. var self = this;
  3968. this.on('open', function () {
  3969. self.$container.addClass('select2-container--open');
  3970. });
  3971. this.on('close', function () {
  3972. self.$container.removeClass('select2-container--open');
  3973. });
  3974. this.on('enable', function () {
  3975. self.$container.removeClass('select2-container--disabled');
  3976. });
  3977. this.on('disable', function () {
  3978. self.$container.addClass('select2-container--disabled');
  3979. });
  3980. this.on('focus', function () {
  3981. self.$container.addClass('select2-container--focus');
  3982. });
  3983. this.on('blur', function () {
  3984. self.$container.removeClass('select2-container--focus');
  3985. });
  3986. this.on('query', function (params) {
  3987. if (!self.isOpen()) {
  3988. self.trigger('open');
  3989. }
  3990. this.dataAdapter.query(params, function (data) {
  3991. self.trigger('results:all', {
  3992. data: data,
  3993. query: params
  3994. });
  3995. });
  3996. });
  3997. this.on('query:append', function (params) {
  3998. this.dataAdapter.query(params, function (data) {
  3999. self.trigger('results:append', {
  4000. data: data,
  4001. query: params
  4002. });
  4003. });
  4004. });
  4005. this.on('keypress', function (evt) {
  4006. var key = evt.which;
  4007. if (self.isOpen()) {
  4008. if (key === KEYS.ENTER) {
  4009. self.trigger('results:select');
  4010. evt.preventDefault();
  4011. } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
  4012. self.trigger('results:toggle');
  4013. evt.preventDefault();
  4014. } else if (key === KEYS.UP) {
  4015. self.trigger('results:previous');
  4016. evt.preventDefault();
  4017. } else if (key === KEYS.DOWN) {
  4018. self.trigger('results:next');
  4019. evt.preventDefault();
  4020. } else if (key === KEYS.ESC || key === KEYS.TAB) {
  4021. self.close();
  4022. evt.preventDefault();
  4023. }
  4024. } else {
  4025. if (key === KEYS.ENTER || key === KEYS.SPACE ||
  4026. ((key === KEYS.DOWN || key === KEYS.UP) && evt.altKey)) {
  4027. self.open();
  4028. evt.preventDefault();
  4029. }
  4030. }
  4031. });
  4032. };
  4033. Select2.prototype._syncAttributes = function () {
  4034. this.options.set('disabled', this.$element.prop('disabled'));
  4035. if (this.options.get('disabled')) {
  4036. if (this.isOpen()) {
  4037. this.close();
  4038. }
  4039. this.trigger('disable');
  4040. } else {
  4041. this.trigger('enable');
  4042. }
  4043. };
  4044. /**
  4045. * Override the trigger method to automatically trigger pre-events when
  4046. * there are events that can be prevented.
  4047. */
  4048. Select2.prototype.trigger = function (name, args) {
  4049. var actualTrigger = Select2.__super__.trigger;
  4050. var preTriggerMap = {
  4051. 'open': 'opening',
  4052. 'close': 'closing',
  4053. 'select': 'selecting',
  4054. 'unselect': 'unselecting'
  4055. };
  4056. if (name in preTriggerMap) {
  4057. var preTriggerName = preTriggerMap[name];
  4058. var preTriggerArgs = {
  4059. prevented: false,
  4060. name: name,
  4061. args: args
  4062. };
  4063. actualTrigger.call(this, preTriggerName, preTriggerArgs);
  4064. if (preTriggerArgs.prevented) {
  4065. args.prevented = true;
  4066. return;
  4067. }
  4068. }
  4069. actualTrigger.call(this, name, args);
  4070. };
  4071. Select2.prototype.toggleDropdown = function () {
  4072. if (this.options.get('disabled')) {
  4073. return;
  4074. }
  4075. if (this.isOpen()) {
  4076. this.close();
  4077. } else {
  4078. this.open();
  4079. }
  4080. };
  4081. Select2.prototype.open = function () {
  4082. if (this.isOpen()) {
  4083. return;
  4084. }
  4085. this.trigger('query', {});
  4086. this.trigger('open');
  4087. };
  4088. Select2.prototype.close = function () {
  4089. if (!this.isOpen()) {
  4090. return;
  4091. }
  4092. this.trigger('close');
  4093. };
  4094. Select2.prototype.isOpen = function () {
  4095. return this.$container.hasClass('select2-container--open');
  4096. };
  4097. Select2.prototype.enable = function (args) {
  4098. if (this.options.get('debug') && window.console && console.warn) {
  4099. console.warn(
  4100. 'Select2: The `select2("enable")` method has been deprecated and will' +
  4101. ' be removed in later Select2 versions. Use $element.prop("disabled")' +
  4102. ' instead.'
  4103. );
  4104. }
  4105. if (args == null || args.length === 0) {
  4106. args = [true];
  4107. }
  4108. var disabled = !args[0];
  4109. this.$element.prop('disabled', disabled);
  4110. };
  4111. Select2.prototype.data = function () {
  4112. if (this.options.get('debug') &&
  4113. arguments.length > 0 && window.console && console.warn) {
  4114. console.warn(
  4115. 'Select2: Data can no longer be set using `select2("data")`. You ' +
  4116. 'should consider setting the value instead using `$element.val()`.'
  4117. );
  4118. }
  4119. var data = [];
  4120. this.dataAdapter.current(function (currentData) {
  4121. data = currentData;
  4122. });
  4123. return data;
  4124. };
  4125. Select2.prototype.val = function (args) {
  4126. if (this.options.get('debug') && window.console && console.warn) {
  4127. console.warn(
  4128. 'Select2: The `select2("val")` method has been deprecated and will be' +
  4129. ' removed in later Select2 versions. Use $element.val() instead.'
  4130. );
  4131. }
  4132. if (args == null || args.length === 0) {
  4133. return this.$element.val();
  4134. }
  4135. var newVal = args[0];
  4136. if ($.isArray(newVal)) {
  4137. newVal = $.map(newVal, function (obj) {
  4138. return obj.toString();
  4139. });
  4140. }
  4141. this.$element.val(newVal).trigger('change');
  4142. };
  4143. Select2.prototype.destroy = function () {
  4144. this.$container.remove();
  4145. if (this.$element[0].detachEvent) {
  4146. this.$element[0].detachEvent('onpropertychange', this._sync);
  4147. }
  4148. if (this._observer != null) {
  4149. this._observer.disconnect();
  4150. this._observer = null;
  4151. } else if (this.$element[0].removeEventListener) {
  4152. this.$element[0]
  4153. .removeEventListener('DOMAttrModified', this._sync, false);
  4154. }
  4155. this._sync = null;
  4156. this.$element.off('.select2');
  4157. this.$element.attr('tabindex', this.$element.data('old-tabindex'));
  4158. this.$element.show();
  4159. this.$element.removeData('select2');
  4160. this.dataAdapter.destroy();
  4161. this.selection.destroy();
  4162. this.dropdown.destroy();
  4163. this.results.destroy();
  4164. this.dataAdapter = null;
  4165. this.selection = null;
  4166. this.dropdown = null;
  4167. this.results = null;
  4168. };
  4169. Select2.prototype.render = function () {
  4170. var $container = $(
  4171. '<span class="select2 select2-container">' +
  4172. '<span class="selection"></span>' +
  4173. '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
  4174. '</span>'
  4175. );
  4176. $container.attr('dir', this.options.get('dir'));
  4177. this.$container = $container;
  4178. this.$container.addClass('select2-container--' + this.options.get('theme'));
  4179. $container.data('element', this.$element);
  4180. return $container;
  4181. };
  4182. return Select2;
  4183. });
  4184. /*!
  4185. * jQuery Mousewheel 3.1.12
  4186. *
  4187. * Copyright 2014 jQuery Foundation and other contributors
  4188. * Released under the MIT license.
  4189. * http://jquery.org/license
  4190. */
  4191. (function (factory) {
  4192. if ( typeof S2.define === 'function' && S2.define.amd ) {
  4193. // AMD. Register as an anonymous module.
  4194. S2.define('jquery.mousewheel',['jquery'], factory);
  4195. } else if (typeof exports === 'object') {
  4196. // Node/CommonJS style for Browserify
  4197. module.exports = factory;
  4198. } else {
  4199. // Browser globals
  4200. factory(jQuery);
  4201. }
  4202. }(function ($) {
  4203. var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
  4204. toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
  4205. ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
  4206. slice = Array.prototype.slice,
  4207. nullLowestDeltaTimeout, lowestDelta;
  4208. if ( $.event.fixHooks ) {
  4209. for ( var i = toFix.length; i; ) {
  4210. $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
  4211. }
  4212. }
  4213. var special = $.event.special.mousewheel = {
  4214. version: '3.1.12',
  4215. setup: function() {
  4216. if ( this.addEventListener ) {
  4217. for ( var i = toBind.length; i; ) {
  4218. this.addEventListener( toBind[--i], handler, false );
  4219. }
  4220. } else {
  4221. this.onmousewheel = handler;
  4222. }
  4223. // Store the line height and page height for this particular element
  4224. $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
  4225. $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
  4226. },
  4227. teardown: function() {
  4228. if ( this.removeEventListener ) {
  4229. for ( var i = toBind.length; i; ) {
  4230. this.removeEventListener( toBind[--i], handler, false );
  4231. }
  4232. } else {
  4233. this.onmousewheel = null;
  4234. }
  4235. // Clean up the data we added to the element
  4236. $.removeData(this, 'mousewheel-line-height');
  4237. $.removeData(this, 'mousewheel-page-height');
  4238. },
  4239. getLineHeight: function(elem) {
  4240. var $elem = $(elem),
  4241. $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
  4242. if (!$parent.length) {
  4243. $parent = $('body');
  4244. }
  4245. return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
  4246. },
  4247. getPageHeight: function(elem) {
  4248. return $(elem).height();
  4249. },
  4250. settings: {
  4251. adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
  4252. normalizeOffset: true // calls getBoundingClientRect for each event
  4253. }
  4254. };
  4255. $.fn.extend({
  4256. mousewheel: function(fn) {
  4257. return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
  4258. },
  4259. unmousewheel: function(fn) {
  4260. return this.unbind('mousewheel', fn);
  4261. }
  4262. });
  4263. function handler(event) {
  4264. var orgEvent = event || window.event,
  4265. args = slice.call(arguments, 1),
  4266. delta = 0,
  4267. deltaX = 0,
  4268. deltaY = 0,
  4269. absDelta = 0,
  4270. offsetX = 0,
  4271. offsetY = 0;
  4272. event = $.event.fix(orgEvent);
  4273. event.type = 'mousewheel';
  4274. // Old school scrollwheel delta
  4275. if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
  4276. if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
  4277. if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
  4278. if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
  4279. // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
  4280. if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
  4281. deltaX = deltaY * -1;
  4282. deltaY = 0;
  4283. }
  4284. // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
  4285. delta = deltaY === 0 ? deltaX : deltaY;
  4286. // New school wheel delta (wheel event)
  4287. if ( 'deltaY' in orgEvent ) {
  4288. deltaY = orgEvent.deltaY * -1;
  4289. delta = deltaY;
  4290. }
  4291. if ( 'deltaX' in orgEvent ) {
  4292. deltaX = orgEvent.deltaX;
  4293. if ( deltaY === 0 ) { delta = deltaX * -1; }
  4294. }
  4295. // No change actually happened, no reason to go any further
  4296. if ( deltaY === 0 && deltaX === 0 ) { return; }
  4297. // Need to convert lines and pages to pixels if we aren't already in pixels
  4298. // There are three delta modes:
  4299. // * deltaMode 0 is by pixels, nothing to do
  4300. // * deltaMode 1 is by lines
  4301. // * deltaMode 2 is by pages
  4302. if ( orgEvent.deltaMode === 1 ) {
  4303. var lineHeight = $.data(this, 'mousewheel-line-height');
  4304. delta *= lineHeight;
  4305. deltaY *= lineHeight;
  4306. deltaX *= lineHeight;
  4307. } else if ( orgEvent.deltaMode === 2 ) {
  4308. var pageHeight = $.data(this, 'mousewheel-page-height');
  4309. delta *= pageHeight;
  4310. deltaY *= pageHeight;
  4311. deltaX *= pageHeight;
  4312. }
  4313. // Store lowest absolute delta to normalize the delta values
  4314. absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
  4315. if ( !lowestDelta || absDelta < lowestDelta ) {
  4316. lowestDelta = absDelta;
  4317. // Adjust older deltas if necessary
  4318. if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
  4319. lowestDelta /= 40;
  4320. }
  4321. }
  4322. // Adjust older deltas if necessary
  4323. if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
  4324. // Divide all the things by 40!
  4325. delta /= 40;
  4326. deltaX /= 40;
  4327. deltaY /= 40;
  4328. }
  4329. // Get a whole, normalized value for the deltas
  4330. delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
  4331. deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
  4332. deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
  4333. // Normalise offsetX and offsetY properties
  4334. if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
  4335. var boundingRect = this.getBoundingClientRect();
  4336. offsetX = event.clientX - boundingRect.left;
  4337. offsetY = event.clientY - boundingRect.top;
  4338. }
  4339. // Add information to the event object
  4340. event.deltaX = deltaX;
  4341. event.deltaY = deltaY;
  4342. event.deltaFactor = lowestDelta;
  4343. event.offsetX = offsetX;
  4344. event.offsetY = offsetY;
  4345. // Go ahead and set deltaMode to 0 since we converted to pixels
  4346. // Although this is a little odd since we overwrite the deltaX/Y
  4347. // properties with normalized deltas.
  4348. event.deltaMode = 0;
  4349. // Add event and delta to the front of the arguments
  4350. args.unshift(event, delta, deltaX, deltaY);
  4351. // Clearout lowestDelta after sometime to better
  4352. // handle multiple device types that give different
  4353. // a different lowestDelta
  4354. // Ex: trackpad = 3 and mouse wheel = 120
  4355. if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
  4356. nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
  4357. return ($.event.dispatch || $.event.handle).apply(this, args);
  4358. }
  4359. function nullLowestDelta() {
  4360. lowestDelta = null;
  4361. }
  4362. function shouldAdjustOldDeltas(orgEvent, absDelta) {
  4363. // If this is an older event and the delta is divisable by 120,
  4364. // then we are assuming that the browser is treating this as an
  4365. // older mouse wheel event and that we should divide the deltas
  4366. // by 40 to try and get a more usable deltaFactor.
  4367. // Side note, this actually impacts the reported scroll distance
  4368. // in older browsers and can cause scrolling to be slower than native.
  4369. // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
  4370. return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
  4371. }
  4372. }));
  4373. S2.define('select2/compat/matcher',[
  4374. 'jquery'
  4375. ], function ($) {
  4376. function oldMatcher (matcher) {
  4377. function wrappedMatcher (params, data) {
  4378. var match = $.extend(true, {}, data);
  4379. if (params.term == null || $.trim(params.term) === '') {
  4380. return match;
  4381. }
  4382. if (data.children) {
  4383. for (var c = data.children.length - 1; c >= 0; c--) {
  4384. var child = data.children[c];
  4385. // Check if the child object matches
  4386. // The old matcher returned a boolean true or false
  4387. var doesMatch = matcher(params.term, child.text, child);
  4388. // If the child didn't match, pop it off
  4389. if (!doesMatch) {
  4390. match.children.splice(c, 1);
  4391. }
  4392. }
  4393. if (match.children.length > 0) {
  4394. return match;
  4395. }
  4396. }
  4397. if (matcher(params.term, data.text, data)) {
  4398. return match;
  4399. }
  4400. return null;
  4401. }
  4402. return wrappedMatcher;
  4403. }
  4404. return oldMatcher;
  4405. });
  4406. S2.define('select2/compat/initSelection',[
  4407. 'jquery'
  4408. ], function ($) {
  4409. function InitSelection (decorated, $element, options) {
  4410. if (options.get('debug') && window.console && console.warn) {
  4411. console.warn(
  4412. 'Select2: The `initSelection` option has been deprecated in favor' +
  4413. ' of a custom data adapter that overrides the `current` method. ' +
  4414. 'This method is now called multiple times instead of a single ' +
  4415. 'time when the instance is initialized. Support will be removed ' +
  4416. 'for the `initSelection` option in future versions of Select2'
  4417. );
  4418. }
  4419. this.initSelection = options.get('initSelection');
  4420. this._isInitialized = false;
  4421. decorated.call(this, $element, options);
  4422. }
  4423. InitSelection.prototype.current = function (decorated, callback) {
  4424. var self = this;
  4425. if (this._isInitialized) {
  4426. decorated.call(this, callback);
  4427. return;
  4428. }
  4429. this.initSelection.call(null, this.$element, function (data) {
  4430. self._isInitialized = true;
  4431. if (!$.isArray(data)) {
  4432. data = [data];
  4433. }
  4434. callback(data);
  4435. });
  4436. };
  4437. return InitSelection;
  4438. });
  4439. S2.define('select2/compat/inputData',[
  4440. 'jquery'
  4441. ], function ($) {
  4442. function InputData (decorated, $element, options) {
  4443. this._currentData = [];
  4444. this._valueSeparator = options.get('valueSeparator') || ',';
  4445. if ($element.prop('type') === 'hidden') {
  4446. if (options.get('debug') && console && console.warn) {
  4447. console.warn(
  4448. 'Select2: Using a hidden input with Select2 is no longer ' +
  4449. 'supported and may stop working in the future. It is recommended ' +
  4450. 'to use a `<select>` element instead.'
  4451. );
  4452. }
  4453. }
  4454. decorated.call(this, $element, options);
  4455. }
  4456. InputData.prototype.current = function (_, callback) {
  4457. function getSelected (data, selectedIds) {
  4458. var selected = [];
  4459. if (data.selected || $.inArray(data.id, selectedIds) !== -1) {
  4460. data.selected = true;
  4461. selected.push(data);
  4462. } else {
  4463. data.selected = false;
  4464. }
  4465. if (data.children) {
  4466. selected.push.apply(selected, getSelected(data.children, selectedIds));
  4467. }
  4468. return selected;
  4469. }
  4470. var selected = [];
  4471. for (var d = 0; d < this._currentData.length; d++) {
  4472. var data = this._currentData[d];
  4473. selected.push.apply(
  4474. selected,
  4475. getSelected(
  4476. data,
  4477. this.$element.val().split(
  4478. this._valueSeparator
  4479. )
  4480. )
  4481. );
  4482. }
  4483. callback(selected);
  4484. };
  4485. InputData.prototype.select = function (_, data) {
  4486. if (!this.options.get('multiple')) {
  4487. this.current(function (allData) {
  4488. $.map(allData, function (data) {
  4489. data.selected = false;
  4490. });
  4491. });
  4492. this.$element.val(data.id);
  4493. this.$element.trigger('change');
  4494. } else {
  4495. var value = this.$element.val();
  4496. value += this._valueSeparator + data.id;
  4497. this.$element.val(value);
  4498. this.$element.trigger('change');
  4499. }
  4500. };
  4501. InputData.prototype.unselect = function (_, data) {
  4502. var self = this;
  4503. data.selected = false;
  4504. this.current(function (allData) {
  4505. var values = [];
  4506. for (var d = 0; d < allData.length; d++) {
  4507. var item = allData[d];
  4508. if (data.id == item.id) {
  4509. continue;
  4510. }
  4511. values.push(item.id);
  4512. }
  4513. self.$element.val(values.join(self._valueSeparator));
  4514. self.$element.trigger('change');
  4515. });
  4516. };
  4517. InputData.prototype.query = function (_, params, callback) {
  4518. var results = [];
  4519. for (var d = 0; d < this._currentData.length; d++) {
  4520. var data = this._currentData[d];
  4521. var matches = this.matches(params, data);
  4522. if (matches !== null) {
  4523. results.push(matches);
  4524. }
  4525. }
  4526. callback({
  4527. results: results
  4528. });
  4529. };
  4530. InputData.prototype.addOptions = function (_, $options) {
  4531. var options = $.map($options, function (option) {
  4532. return $.data(option, 'data');
  4533. });
  4534. this._currentData.push.apply(this._currentData, options);
  4535. };
  4536. return InputData;
  4537. });
  4538. S2.define('select2/compat/query',[
  4539. ], function () {
  4540. function Query (decorated, $element, options) {
  4541. if (options.get('debug') && window.console && console.warn) {
  4542. console.warn(
  4543. 'Select2: The `query` option has been deprecated in favor of a ' +
  4544. 'custom data adapter that overrides the `query` method. Support ' +
  4545. 'will be removed for the `query` option in future versions of ' +
  4546. 'Select2.'
  4547. );
  4548. }
  4549. decorated.call(this, $element, options);
  4550. }
  4551. Query.prototype.query = function (_, params, callback) {
  4552. params.callback = callback;
  4553. var query = this.options.get('query');
  4554. query.call(null, params);
  4555. };
  4556. return Query;
  4557. });
  4558. S2.define('select2/dropdown/attachContainer',[
  4559. ], function () {
  4560. function AttachContainer (decorated, $element, options) {
  4561. decorated.call(this, $element, options);
  4562. }
  4563. AttachContainer.prototype.position =
  4564. function (decorated, $dropdown, $container) {
  4565. var $dropdownContainer = $container.find('.dropdown-wrapper');
  4566. $dropdownContainer.append($dropdown);
  4567. $dropdown.addClass('select2-dropdown--below');
  4568. $container.addClass('select2-container--below');
  4569. };
  4570. return AttachContainer;
  4571. });
  4572. S2.define('select2/dropdown/stopPropagation',[
  4573. ], function () {
  4574. function StopPropagation () { }
  4575. StopPropagation.prototype.bind = function (decorated, container, $container) {
  4576. decorated.call(this, container, $container);
  4577. var stoppedEvents = [
  4578. 'blur',
  4579. 'change',
  4580. 'click',
  4581. 'dblclick',
  4582. 'focus',
  4583. 'focusin',
  4584. 'focusout',
  4585. 'input',
  4586. 'keydown',
  4587. 'keyup',
  4588. 'keypress',
  4589. 'mousedown',
  4590. 'mouseenter',
  4591. 'mouseleave',
  4592. 'mousemove',
  4593. 'mouseover',
  4594. 'mouseup',
  4595. 'search',
  4596. 'touchend',
  4597. 'touchstart'
  4598. ];
  4599. this.$dropdown.on(stoppedEvents.join(' '), function (evt) {
  4600. evt.stopPropagation();
  4601. });
  4602. };
  4603. return StopPropagation;
  4604. });
  4605. S2.define('select2/selection/stopPropagation',[
  4606. ], function () {
  4607. function StopPropagation () { }
  4608. StopPropagation.prototype.bind = function (decorated, container, $container) {
  4609. decorated.call(this, container, $container);
  4610. var stoppedEvents = [
  4611. 'blur',
  4612. 'change',
  4613. 'click',
  4614. 'dblclick',
  4615. 'focus',
  4616. 'focusin',
  4617. 'focusout',
  4618. 'input',
  4619. 'keydown',
  4620. 'keyup',
  4621. 'keypress',
  4622. 'mousedown',
  4623. 'mouseenter',
  4624. 'mouseleave',
  4625. 'mousemove',
  4626. 'mouseover',
  4627. 'mouseup',
  4628. 'search',
  4629. 'touchend',
  4630. 'touchstart'
  4631. ];
  4632. this.$selection.on(stoppedEvents.join(' '), function (evt) {
  4633. evt.stopPropagation();
  4634. });
  4635. };
  4636. return StopPropagation;
  4637. });
  4638. S2.define('jquery.select2',[
  4639. 'jquery',
  4640. './select2/core',
  4641. './select2/defaults'
  4642. ], function ($, Select2, Defaults) {
  4643. // Force jQuery.mousewheel to be loaded if it hasn't already
  4644. try {
  4645. require('jquery.mousewheel');
  4646. } catch (Exception) { }
  4647. if ($.fn.select2 == null) {
  4648. $.fn.select2 = function (options) {
  4649. options = options || {};
  4650. if (typeof options === 'object') {
  4651. this.each(function () {
  4652. var instanceOptions = $.extend({}, options, true);
  4653. var instance = new Select2($(this), instanceOptions);
  4654. });
  4655. return this;
  4656. } else if (typeof options === 'string') {
  4657. var instance = this.data('select2');
  4658. var args = Array.prototype.slice.call(arguments, 1);
  4659. return instance[options](args);
  4660. } else {
  4661. throw new Error('Invalid arguments for Select2: ' + options);
  4662. }
  4663. };
  4664. }
  4665. if ($.fn.select2.defaults == null) {
  4666. $.fn.select2.defaults = Defaults;
  4667. }
  4668. return Select2;
  4669. });
  4670. // Return the AMD loader configuration so it can be used outside of this file
  4671. return {
  4672. define: S2.define,
  4673. require: S2.require
  4674. };
  4675. }());
  4676. // Autoload the jQuery bindings
  4677. // We know that all of the modules exist above this, so we're safe
  4678. var select2 = S2.require('jquery.select2');
  4679. // Hold the AMD module references on the jQuery function that was just loaded
  4680. // This allows Select2 to use the internal loader outside of this file, such
  4681. // as in the language files.
  4682. $.fn.select2.amd = S2;
  4683. // Return the Select2 instance for anyone who is importing it.
  4684. return select2;
  4685. }));