select2.full.js 129 KB

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